MercuryDPM  Trunk
Writing a particle simulation with analytical output

This feature is still in development, so the documentation is meant for developers only. However, anyone is welcome to give it a try.

The evaluation of coarse-grained continuum fields in Mercury is done by the class CG. To turn on coarse-graining (cg), one has to pick a cg function (e.g. Gauss) and define its parameters (e.g. width=1). Then one has to pick points where the continuum fields should be evaluated. While these points can be chosen arbitrarily, it is often advantageous to create a mesh of points along the Cartesian coordinates, using nx-by-ny-by-nz points, with nx=ny=nz=10. Finally, one has to define how often the evaluation should take place, e.g. every saveCount=20'000 time steps. This can be done by inserting the following code into the main function, before the solve command is executed:

CG<CGFunctions::GaussXYZ> cg;
cg.setNX(10);
cg.setNY(10);
cg.setNZ(10);
cg.setWidth(0.15);
cg.statFile.setSaveCount(20000);

Here, problem specifies the DPMBase object. The output will we written in a file named (problemName).stat. To change the name of the output file to e.g. (problemName).GaussXYZ.stat, add the line

cg.statFile.setName(problem.getName() + ".GaussXYZ.stat");

Note that CGFunctions::GaussXYZ is only a typedef (=short name) for the class CGFunctions::Gauss<CGCoordinates::XYZ>.

# Spatial averaging

Most DPM problems have certain Cartesian directions in which the flow is homogeneous; take e.g. the problem of chute flow over a inclined plane [add name of demo code here], where the flow is homogeneous in x and y, and locally varying in z, e.g. the density satisfies rho(x,y,z)=rho(z). Thus, it is enough to spatially resolve the continuum fields in z and average over x and y. This can be done in Mercury by defining a spatially averaging cg function, e.g.

CG<CGFunctions::GaussZ> cg;
cg.setNZ(10);
cg.setWidth(0.15);
cg.statFile.setSaveCount(20000);

For fully averaged systems, use CGCoordinates::O, e.g.

CG<CGFunctions::GaussO> cg;

# Temporal averaging

If your DPM problem is steady, it is not necessary to resolve the continuum fields in time. This can be done in Mercury by using time-averaging cg, e.g.

TimeAveragedCG<CGFunctions::GaussZ> cg;
cg.setNZ(10);
cg.setWidth(0.15);
cg.statFile.setSaveCount(20000);

To limit the time interval over which the continuum fields are evaluated to e.g. $$[10,20]$$, use

cg.setTimeMin(10);
cg.setTimeMax(20);

# Temporal smoothing

If your DPM problem is unsteady, time-dependent CG should be used. This, however, often leads to high fluctuations in the resulting continuum fields, as the amount of data that is evaluated to obtain a value for the continuum field is insufficient. In this case, time-smoothing can be used:

TimeSmoothedCG<CGFunctions::GaussZ> cg; cg.setWidthTime(0.01); cg.setTimeStep(0.004); cg.setTimeMax(0.2); cg.statFile.setSaveCount(5); problem.cgHandler.copyAndAddObject(cg);

Like CG, this class should be used to evaluate time-dependent fields. However, as the data is averaged over several time steps, the resulting fields are smoother and more reliable, as they use more information.

# Different cg functions

You can also use other cg functions than Gauss. The other available options are Heaviside, Linear and Lucy, e.g.

CG<CGFunctions::LucyZ> cg;

# Multiple cg evaluations

Note that you are not limited to one choice of cg evaluation for your problem. For example you can create both time-averaged and time resolved data by adding two cg objects (just make sure that they have different names for the output file):

CG<CGFunctions::LucyO> cg0;
cg0.statFile.setSaveCount(20);
cg0.statFile.setName(problem.getName() + ".LucyO.stat");

TimeAveragedCG<CGFunctions::LucyO> cg1;
cg1.statFile.setSaveCount(20000);

# Code structure of MercuryCG

Here is a list of the different classes that comprise MercuryCG.

• class CGHandler:
Handler that stores all CG objects.
• classes CG, TimeSmoothedCG, TimeAveragedCG:
The three available CG classes, used to obtain time-resolved, time smoothed, and time-averaged continuum fields. Contains a vector of CGPoints.
• templated class CGPoint:
Derived from a CGFields and a CGFunctions class. Does the main work of evaluating the continuum fields at a given position.
• namespace CGFields:
Contains the classes StandardFields etc.
• namespace CGFunctions:
Contains the templated classes Gauss, Heaviside, Linear, Lucy (the latter three are derived from Polynomial). Contains the definition of the cg function used. Derived from a CGCoordinates class.
• namespace CGCoordinates:
Contains the classes O, X, Y, Z, XY, XZ, YZ, XYZ: Contains the position of the CGPoint.