CGExactOverlapUnitTestOverlap.cpp File Reference

Classes

class  CGExactOverlapUnitTest
 Tests if the displacement momentum density is correctly calculated. More...
 

Functions

int main (int argc, char *argv[])
 

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)
77 {
78  //declare the DPM problem and set the name
80  problem.setTimeMax(0.1);
81  problem.setTimeStep(0.1);
82  problem.setFileType(FileType::NO_FILE);
83 
84  // Test a particle sitting at the corner of the grid cell
85  Mdouble radius = 0.1;
86  problem.setParameters(radius, radius*Vec3D(-1, -1, -1), radius*Vec3D(1, 1, 1), radius*Vec3D(1, 1, 1));
88  cg0->selectSpecies(0);
89 
90  //run the simulation
91  problem.solve(argc, argv);
92 
93  Mdouble density = cg0->evaluateAverage().getDensity();
94  Mdouble expectedDensity = constants::pi * radius * radius * radius / 6 / problem.getVolume();
95 
96  logger.assert_always(std::abs(density-expectedDensity) < 1e-10, "Density is %, but should be %", density, expectedDensity);
97 
98  // Place a particle, so that a cap of height h is inside the grid cell
99  Mdouble h = 0.05;
100  radius = 0.1;
101  problem.clear();
102  problem.setParameters(radius, Vec3D(-2*radius, -2*radius, radius-h), Vec3D(2*radius, 2*radius, 2*radius), radius*Vec3D(0, 0, 0));
104  cg1->selectSpecies(0);
105 
106  //run the simulation
107  problem.solve(argc, argv);
108 
109  density = cg1->evaluateAverage().getDensity();
110  expectedDensity = constants::pi * h * h / 3 * (3*radius - h) / problem.getVolume();
111 
112  logger.assert_always(std::abs(density-expectedDensity) < 1e-10, "Spherecap: Density is %, but should be %", density, expectedDensity);
113 
114  // Place a particle, so that a spherical segemtn with height h and distance d between the segments bottom and the sphere's center is inside the grid cell
115  h = 0.05;
116  Mdouble d = -0.025;
117  radius = 0.1;
118 
119  // The bottom radius
120  Mdouble a1 = std::sqrt(radius*radius - d*d);
121  // The top radius
122  Mdouble a2 = std::sqrt(radius*radius - (d+h)*(d+h));
123 
124  logger(INFO, "a1 = %, a2 = %", a1, a2);
125 
126  problem.clear();
127  problem.setParameters(radius, Vec3D(-2*radius, -2*radius, d), Vec3D(2*radius, 2*radius, d+h), Vec3D(0, 0, 0));
129  cg2->selectSpecies(0);
130 
131  //run the simulation
132  problem.solve(argc, argv);
133 
134  density = cg2->evaluateAverage().getDensity();
135  expectedDensity = constants::pi * h * (3*a1*a1 + 3*a2*a2 + h*h) / 6 / problem.getVolume();
136 
137  logger.assert_always(std::abs(density-expectedDensity) < 1e-10, "Spherical segment: Density is %, but should be %", density, expectedDensity);
138 
139  // Place a particle, so that a spherical segemtn with height h and distance d between the segments bottom and the sphere's center is inside the grid cell
140  h = 0.1;
141  d = -0.025;
142  radius = 0.1;
143 
144  // The bottom radius
145  a1 = std::sqrt(radius*radius - d*d);
146  // The top radius
147  a2 = std::sqrt(radius*radius - (d+h)*(d+h));
148  logger(INFO, "a1 = %, a2 = %", a1, a2);
149 
150  problem.clear();
151  problem.setParameters(radius, Vec3D(-2*radius, -2*radius, d), Vec3D(2*radius, 2*radius, d+h), Vec3D(0, 0, 0));
153  cg3->selectSpecies(0);
154 
155  //run the simulation
156  problem.solve(argc, argv);
157 
158  density = cg3->evaluateAverage().getDensity();
159  expectedDensity = constants::pi * h * (3*a1*a1 + 3*a2*a2 + h*h) / 6 / problem.getVolume();
160 
161  logger.assert_always(std::abs(density-expectedDensity) < 1e-10, "Spherical segment 2: Density is %, but should be %", density, expectedDensity);
162 }
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
AnnoyingScalar sqrt(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:134
Array< double, 1, 3 > e(1./3., 0.5, 2.)
@ NO_FILE
file will not be created/read
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
Tests if the displacement momentum density is correctly calculated.
Definition: CGExactOverlapUnitTestOverlap.cpp:16
Evaluates time-averaged continuum fields and writes the data into a stat file.
Definition: TimeAveragedCG.h:39
Definition: Kernel/Math/Vector.h:30
#define INFO(i)
Definition: mumps_solver.h:54
density
Definition: UniformPSDSelfTest.py:19
radius
Definition: UniformPSDSelfTest.py:15
const Mdouble pi
Definition: ExtendedMath.h:23
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

References abs(), UniformPSDSelfTest::density, e(), INFO, logger, NO_FILE, constants::pi, problem, UniformPSDSelfTest::radius, and sqrt().