This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Output and visualise coefficent in forms

0 votes

Hi all,

I have a form with several coefficients like:

NonlinearProblem::ResidualForm F(functionspace);

F.coefficent_a = coefficent_a;
F.coefficent_b = coefficent_b;

Is is possible to output these coefficients of F, so that I can be more confident that the assignment of the coefficient is correct?

I just found that I can get the coefficent by:

std::shared_ptr <const GenericFunction> a(F.coefficient("coefficent_a"));;

But still have no idea to output a GenericFunction.

Thanks.

asked Oct 10, 2015 by qiangzini FEniCS Novice (760 points)

1 Answer

0 votes

Seems as if I can do that simply by:

    auto b = std::dynamic_pointer_cast<const Function> (F.coefficient("gammaf"));
    a = std::const_pointer_cast<Function> (b);
    File file3 ( comm, "F.gammaf.pvd", "compressed");
    file3 << *a;

Not sure if it is correct, although the output was what I want it to be.

Any comments?

Thanks!

answered Oct 12, 2015 by qiangzini FEniCS Novice (760 points)
...