On Sun, 26 Apr 2009, Colby Lemon wrote:
> I have been trying to get started with libmesh, and seem to have run up
> against a very similar problem to what Brent wrote about in this thread. In
> particular, I am trying to use the MeshFunction class to get access to the
> Poisson solution from example 3 and 4 at non-nodal locations.
If your non-nodal locations are in an element for which you have an
Elem (e.g. if you're in the middle of looping over all elements) then
you don't want to use a MeshFunction at all - just initialize an FE
object with the points you want to evaluate, then sum up
coefficient-weighted shape function values (as in ex13 when u, u_old,
etc. are calculated).
If you don't have an Elem and you really need a MeshFunction, then if
you're running in parallel you'll currently need a serial
NumericVector to use. See exact_error_estimator.C for an example:
fine_soln->init (fine_system.solution->size(), true, SERIAL);
(*fine_soln) = global_soln;
> While trying to assign a std::vector<Number> to a NumericVector<Number>
> (with the line of code "NumericVector<Number>& vec2 = vec;", where vec has
> been returned from equation_systems.build_solution_vector(vec).), I have run
> up against "error: invalid initialization of reference of type
> ‘NumericVector<double>&’ from expression of type ‘std::vector<double,
> std::allocator<double> >’".
> I apologize if I'm missing something obvious, but my C++ is a little rusty
> (it's been about 10 years since I've used it much).
Yes, your bug here is a C++ issue: even if you can convert type A to
type B, you can't make a reference-to-B refer to an object of A.