# Coordinates of Each Component of a solution Vector

Hi

For a solution vector from a Function, i.e.,

Function solution(V);

*solution.vector()

Is there a way to obtain the coordinates of each component in 'exactly' the order in which they are set in the vector.

This is because I need to create objects based on coordinates of each component, carry out some manipulations and set the solution vector in exactly the correct(same) order.

Prior to the 1.1 release, I was able to do the following:

<START>

for (VertexIterator vertex(mesh); !vertex.end(); ++vertex) {

// create objects based on vertex coordinates

// store objects in a std::vector

}

// Manipulate objects here

//Store solution values in correct order

double block[mesh.

dolfin::uint rows[mesh.

for (unsigned int i = 0; i < mesh.num_

rows[i] = i;

// Iterate through objects

for (...)

{

//store solution in appropriate location

block[i] = some_function();

}

Function new_solution(V)

new_solution.

</END>

Granted, this works only for P1 elements but now all my code is broken and I've been trying to fix it to no avail.

Is there a way I can do this?

Many thanks

Pietro

## Question information

- Language:
- English Edit question

- Status:
- Answered

- For:
- DOLFIN Edit question

- Assignee:
- No assignee Edit question

- Last query:
- 2013-01-25

- Last reply:
- 2013-01-25

Johan Hake (johan-hake) said : | #1 |

I am working on a function to tabulate this map. It will work for

elements which has dofs only on vertices. So also CG1 vector elements.

The syntax should look something like:

vert_map = V.dofmap(

u = Function(V)

u_verts = u.vector(

for Python and in C++ vert_map will be a std::vector<

Johan

On 01/25/2013 11:11 PM, Pietro Maximoff wrote:

> New question #220174 on DOLFIN:

> https:/

>

> Hi

>

> For a solution vector from a Function, i.e.,

> Function solution(V);

> *solution.vector()

> Is there a way to obtain the coordinates of each component in 'exactly' the order in which they are set in the vector.

>

> This is because I need to create objects based on coordinates of each component, carry out some manipulations and set the solution vector in exactly the correct(same) order.

>

> Prior to the 1.1 release, I was able to do the following:

>

> <START>

>

> for (VertexIterator vertex(mesh); !vertex.end(); ++vertex) {

> // create objects based on vertex coordinates

> // store objects in a std::vector

> }

>

> // Manipulate objects here

>

> //Store solution values in correct order

> double block[mesh.

> dolfin::uint rows[mesh.

> for (unsigned int i = 0; i < mesh.num_

> rows[i] = i;

>

> // Iterate through objects

> for (...)

> {

> //store solution in appropriate location

> block[i] = some_function();

> }

>

> Function new_solution(V)

> new_solution.

>

> </END>

>

> Granted, this works only for P1 elements but now all my code is broken and I've been trying to fix it to no avail.

>

> Is there a way I can do this?

>

> Many thanks

>

> Pietro

>

>

Pietro Maximoff (segment-x) said : | #2 |

Excellent!!!

I'd really appreciate it if you could let us know when it's done so I can download one of the snapshots.

Many thanks,

Pietro

Pietro Maximoff (segment-x) said : | #3 |

Hi Johan,

While you're working on the function, is there a way to revert to 1.0 via dorsal ?

Pietro

## Can you help with this problem?

Provide an answer of your own, or ask Pietro Maximoff for more information if necessary.