Visualization of analytical solution

Hi all,

I am currently working on a benchmark problem and I am thinking that it would be nice to visualize both analytical and numerical solutions.

Here in order to visualize the analytical solution, I am thinking about implementing it into the MaterialModel::NamedAdditionalOuputs class, then generating the visualization in the PostProcess::VisualizationPostProcessors::NamedAdditionalOutputs. Yet I am wondering if there is any other simpler way to do that or if there is any example I can follow.

Thanks in advance,
Regards,
Ray

Yes, this sounds like a reasonable approach. We currently have no example that does this, but it would be very interesting to have! Let us know if you something we could try and include in one of the examples.
You could also interpolate the analytical solution to a compositional field and output that, but you have to do a few tricks (you will need fields for each velocity component) and the FE degree is likely not correct (for example for the pressure, which should be 1 instead of 2). So, I think your plan sounds easier.

Ray,

I am currently working on a benchmark problem and I am thinking that it would
be nice to visualize both analytical and numerical solutions.

Here in order to visualize the analytical solution, I am thinking about
implementing it into the MaterialModel::NamedAdditionalOuputs class, then
generating the visualization in the
PostProcess::VisualizationPostProcessors::NamedAdditionalOutputs. Yet I am
wondering if there is any other simpler way to do that or if there is any
example I can follow.

Timo’s suggestions work, but I’d like to provide a slightly different
perspective: You can’t see differences in figures that are below 10% of the
function values. As a consequence, for most benchmarks, visualizing the exact
solution will almost certainly look exactly like the numerical solution. When
you see pictures in papers that show the “exact solution”, they almost always
show the “numerical solution on a fine grid” instead.

In other words, it may not be worth your time to figure out a way to output
the exact solution :slight_smile:

Best
W.

Dear Timo and Wolfgang,

Thank you so much for your messages. The goal of visualizing the analytical solution is that I can then plot the relative error between analytical and numerical solutions throughout the entire domain. Thus I am thinking that I would be able to do it on Paraview if I can graphically output the analytical solution. Or maybe there are better approaches out there.

Thanks,
Ray

This is not a good idea:

  1. this will output a linear interpolation of the exact solution, so you are not comparing against the exact solution.
  2. Operations in paraview are not exact but operate on (incorrectly) interpolated data.
  3. I don’t trust paraview to be accurate even knowing these limitations.

Just compute the errors like we do in several of the benchmark/ examples (see burstedde for example).

Just to extend a bit on this: Of course doing what you planned will give you an estimate for the differences between analytical and numerical solution, however as Timo pointed out it will be a pretty rough estimate, and you might as well use the Paraview “Calculator” filter to compute the analytical solution in Paraview, which might be simpler than implementing it in aspect. If you want to have more accurate estimates for the error (in particular if you want to quantify the error and not just get an impression for where the errors are) then you would need to calculate the error inside aspect, e.g. in as postprocessor (as in benchmarks/burstedde/burstedde.cc in the postprocessor class) which computes a combined norm of the error, or as a named additional named output in the material model, which would output the error at every point in the domain.

Best,
Rene

Thanks a lot! Calculating the errors inside the Aspect indeed sounds like a more accurate approach.

This may sound like a very silly question, but here in order to visualize the solution via the named additional output, I am wondering if I have to implement anything inside the Visualization::Postprocessor::NamedAdditionalOutuputs, or just fill the outputs in the material model is fine.

Best,
Ray

You would need to

  1. Create a new class derived from NamedAdditionalMaterialOutputs (see SeismicAdditionalOutputs for example)
  2. Your material model needs to implement create_additional_named_outputs() (see CompositionReaction for an example).
  3. You need to enable the “named additional outputs” visualization postprocessor.

That’s it.

Thanks Timo! That makes much better sense now.

But when I am trying to enable the visualization postprocessor by entering my ‘named output’ (i.e. the error in this case) or ‘named additional outputs’ in the List of Output Variables of the parameter file. Aspect still gives me the invalid parameter file error. Thus I am wondering if I am still missing a step here.

Thanks a lot for the help

set List of output variables = named additional outputs
should be working. If not, please post your .prm and the precise error message.

Just figured it out today, thanks a lot!