Adapting Mesh to an Exact Function (06-exact)

This technique can be useful in a number of situations, for example when a time-dependent proces starts from a complicated initial condition that would not be represented with sufficient accuracy on a coarse initial mesh.

Assigning an exact function to the fine mesh

At the beginning of each adaptivity step, instead of calculating a solution on the fine mesh, we assign the exact function to it:

// Assign the function f() to the fine mesh.
info("Assigning f() to the fine mesh.");
if(ref_sln != NULL) delete ref_sln;
ref_sln = new ExactSolutionCustom(ref_space->get_mesh());

The rest of the adaptivity loop is as usual.

Sample results

Sample solution and mesh are shown below:

Resulting solution and mesh