Question #129296 on DOLFIN changed: https://answers.launchpad.net/dolfin/+question/129296
Johan Hake proposed the following answer: On Thursday October 14 2010 15:34:09 Jack wrote: > Question #129296 on DOLFIN changed: > https://answers.launchpad.net/dolfin/+question/129296 > > Jack requested for more information: > Thanks again, Johan, works brilliantly. > > If I may just impose on you again. > > The only part of my code that now breaks down with MPI is where I have > to allocate to each member of a std::vector, the corresponding values > from a Function u, i.e., > > int j = 0; > for (std::vector<foo*>::iterator p = instances.begin(); p != > instances.end(); ++p) { (*p)->set_value( u.vector()[j] ); > ++j; > } If instances is a std::vector of size v.local_size() then you should be able to do something like: Array<double> values(v.size()); v.get_local(values); for (std::vector<foo*>::iterator p = instances.begin(); p != instances.end(); ++p) { (*p)->set_value( values[j] ); ++j; } Johan > Is there a way to reduce this to the local size of the u vector and > associate the correct local range? > > Many thanks > > Jack -- You received this question notification because you are a member of DOLFIN Team, which is an answer contact for DOLFIN. _______________________________________________ Mailing list: https://launchpad.net/~dolfin Post to : [email protected] Unsubscribe : https://launchpad.net/~dolfin More help : https://help.launchpad.net/ListHelp

