CGHandlerSelfTest.cpp File Reference
#include "Mercury3D.h"
#include "StatisticsVector.h"
#include "Walls/InfiniteWall.h"
#include "CG/CG.h"
#include "CG/TimeSmoothedCG.h"
#include "CG/TimeAveragedCG.h"
#include "CG/Functions/Lucy.h"
#include "CG/Functions/Linear.h"
#include "CG/Functions/Heaviside.h"
#include "CG/Functions/Gauss.h"
#include <cmath>
#include <iostream>
#include <iomanip>
#include <Species/LinearViscoelasticSpecies.h>

Classes

class  CGHandlerSelfTest
 In this file a cubic packing of 5^3 particles in a tri-axial box is created and allowed to settle under small gravity. After that Z statistics are calculated. More...
 

Functions

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

Function Documentation

◆ main()

int main ( int argc  ,
char argv[] 
)
114 {
115  //declare the DPM problem and set the name
116  CGHandlerSelfTest problem;
117  problem.setName("CGHandlerSelfTest");
118 
119  //set gravity and the species properties
120  problem.setSystemDimensions(3);
121  problem.setGravity(Vec3D(0., 0., -1.));
123  species->setDensity(6.0 / constants::pi);
124  species->setCollisionTimeAndRestitutionCoefficient(.01, .1, 1.);
125 
126  //accordingly, set the time step, final time, and save count
127  problem.setTimeStep(.0002);
128  problem.setTimeMax(0.5); //a total of 5000 time steps
129  problem.setSaveCount(20);
130 
131  //define the different coarse-graining objects
133  cg0.statFile.setSaveCount(5);
134  cg0.statFile.setName(problem.getName() + ".LucyO.T.stat");
135  cg0.setTimeMax(0.2);
136  problem.cgHandler.copyAndAddObject(cg0);
137 
139  cg1.setWidthTime(0.01);
140  cg1.setTimeStep(0.001);
141  cg1.setTimeMax(0.2);
142  cg1.statFile.setSaveCount(5);
143  cg1.statFile.setName(problem.getName() + ".LucyO.TS.stat");
144  problem.cgHandler.copyAndAddObject(cg1);
145 
147  cg2.setTimeMin(0.3);
148  cg2.statFile.setSaveCount(5);
149  cg2.statFile.setName(problem.getName() + ".LucyO.TA.stat");
150  problem.cgHandler.copyAndAddObject(cg2);
151 
152  helpers::writeToFile(problem.getName()+".time.gnu","set title 'check if time-dependent, time-smoothed and time-averaged solutions agree'\n"
153  "set xlabel 't'\n "
154  "set ylabel 'volume-averaged contact force'\n"
155  "p 'CGHandlerSelfTest.LucyO.T.stat' u 1:24 w l t 'time-dependent', 'CGHandlerSelfTest.LucyO.TS.stat' u 1:24 w l t 'time-smoothed', 'CGHandlerSelfTest.LucyO.TA.stat' u (0):24 w p t 'time-averaged'"
156  );
157 
158 
159 // CG<CGCoordinates::Z> cgB;
160 // cgB.setNZ(200);
161 // cgB.setWidth(0.3);
162 // cgB.statFile.setSaveCount(20000);
163 // cgB.statFile.setName(problem.getName() + ".LucyZ.stat");
164 // problem.cgHandler.copyAndAddObject(cgB);
165 //
166 // CG<CGFunctions::LinearZ> cgC;
167 // cgC.setNZ(200);
168 // cgC.setWidth(0.3);
169 // cgC.statFile.setSaveCount(20000);
170 // cgC.statFile.setName(problem.getName() + ".LinearZ.stat");
171 // problem.cgHandler.copyAndAddObject(cgC);
172 //
173 // CG<CGFunctions::HeavisideZ> cgD;
174 // cgD.setNZ(200);
175 // cgD.setWidth(0.3);
176 // cgD.statFile.setSaveCount(20000);
177 // cgD.statFile.setName(problem.getName() + ".HeavisideZ.stat");
178 // problem.cgHandler.copyAndAddObject(cgD);
179 //
180 // CG<CGFunctions::GaussZ> cgE;
181 // cgE.setNZ(200);
182 // cgE.setWidth(0.1);
183 // cgE.statFile.setSaveCount(20000);
184 // cgE.statFile.setName(problem.getName() + ".GaussZ.stat");
185 // problem.cgHandler.copyAndAddObject(cgE);
186 //
187 // CG<CGCoordinates::XZ> cgF;
188 // cgF.setNX(30);
189 // cgF.setNZ(30);
190 // cgF.setWidth(0.45);
191 // cgF.statFile.setSaveCount(20000);
192 // cgF.statFile.setName(problem.getName() + ".LucyXZ.stat");
193 // problem.cgHandler.copyAndAddObject(cgF);
194 //
195 // CG<CGFunctions::LinearXZ> cgG;
196 // cgG.setNX(30);
197 // cgG.setNZ(30);
198 // cgG.setWidth(0.45);
199 // cgG.statFile.setSaveCount(20000);
200 // cgG.statFile.setName(problem.getName() + ".LinearXZ.stat");
201 // problem.cgHandler.copyAndAddObject(cgG);
202 //
203 // CG<CGFunctions::HeavisideXZ> cgH;
204 // cgH.setNX(30);
205 // cgH.setNZ(30);
206 // cgH.setWidth(0.45);
207 // cgH.statFile.setSaveCount(20000);
208 // cgH.statFile.setName(problem.getName() + ".HeavisideXZ.stat");
209 // problem.cgHandler.copyAndAddObject(cgH);
210 //
211 // CG<CGFunctions::GaussXZ> cgI;
212 // cgI.setNX(30);
213 // cgI.setNZ(30);
214 // cgI.setWidth(0.15);
215 // cgI.statFile.setSaveCount(20000);
216 // cgI.statFile.setName(problem.getName() + ".GaussXZ.stat");
217 // problem.cgHandler.copyAndAddObject(cgI);
218 //
219 // CG<CGCoordinates::XYZ> cgJ;
220 // cgJ.setNX(10);
221 // cgJ.setNY(10);
222 // cgJ.setNZ(10);
223 // cgJ.setWidth(0.45);
224 // cgJ.statFile.setSaveCount(20000);
225 // cgJ.statFile.setName(problem.getName() + ".LucyXYZ.stat");
226 // problem.cgHandler.copyAndAddObject(cgJ);
227 //
228 // CG<CGFunctions::LinearXYZ> cgK;
229 // cgK.setNX(10);
230 // cgK.setNY(10);
231 // cgK.setNZ(10);
232 // cgK.setWidth(0.45);
233 // cgK.statFile.setSaveCount(20000);
234 // cgK.statFile.setName(problem.getName() + ".LinearXYZ.stat");
235 // problem.cgHandler.copyAndAddObject(cgK);
236 //
237 // CG<CGFunctions::HeavisideXYZ> cgL;
238 // cgL.setNX(10);
239 // cgL.setNY(10);
240 // cgL.setNZ(10);
241 // cgL.setWidth(0.45);
242 // cgL.statFile.setSaveCount(20000);
243 // cgL.statFile.setName(problem.getName() + ".HeavisideXYZ.stat");
244 // problem.cgHandler.copyAndAddObject(cgL);
245 //
246 // CG<CGFunctions::GaussXYZ> cgM;
247 // cgM.setNX(10);
248 // cgM.setNY(10);
249 // cgM.setNZ(10);
250 // cgM.setWidth(0.15);
251 // cgM.statFile.setSaveCount(20000);
252 // cgM.statFile.setName(problem.getName() + ".GaussXYZ.stat");
253 // problem.cgHandler.copyAndAddObject(cgM);
254 //
255 // CG<CGFunctions::GaussY> cg7;
256 // cg7.setNY(200);
257 // cg7.setWidth(0.15);
258 // cg7.statFile.setSaveCount(20000);
259 // cg7.statFile.setName(problem.getName() + ".GaussY.stat");
260 // problem.cgHandler.copyAndAddObject(cg7);
261 //
262 // CG<CGFunctions::GaussX> cg8;
263 // cg8.setNX(200);
264 // cg8.setWidth(0.15);
265 // cg8.statFile.setSaveCount(20000);
266 // cg8.statFile.setName(problem.getName() + ".GaussX.stat");
267 // problem.cgHandler.copyAndAddObject(cg8);
268 //
269 // CG<CGFunctions::GaussYZ> cg9;
270 // cg9.setNY(30);
271 // cg9.setNZ(30);
272 // cg9.setWidth(0.15);
273 // cg9.statFile.setSaveCount(20000);
274 // cg9.statFile.setName(problem.getName() + ".GaussYZ.stat");
275 // problem.cgHandler.copyAndAddObject(cg9);
276 //
277 // CG<CGFunctions::GaussXY> cgA;
278 // cgA.setNX(30);
279 // cgA.setNY(30);
280 // cgA.setWidth(0.15);
281 // cgA.statFile.setSaveCount(20000);
282 // cgA.statFile.setName(problem.getName() + ".GaussXY.stat");
283 // problem.cgHandler.copyAndAddObject(cgA);
284 
285  //run the simulation
286  problem.solve(argc, argv);
287 }
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
Definition: LinearViscoelasticSpecies.h:33
File statFile
File class to handle the output into a .stat file.
Definition: BaseCG.h:376
void setTimeMin(Mdouble timeMin)
Sets timeMin_, the lower limit of the temporal domain.
Definition: BaseCG.cc:146
void setTimeMax(Mdouble timeMax)
Sets timeMax_, the upper limit of the temporal domain.
Definition: BaseCG.cc:151
std::enable_if<!std::is_pointer< U >::value, U * >::type copyAndAddObject(const U &object)
Creates a copy of a Object and adds it to the BaseHandler.
Definition: BaseHandler.h:379
In this file a cubic packing of 5^3 particles in a tri-axial box is created and allowed to settle und...
Definition: CGHandlerLargeSelfTest.cpp:39
Evaluates time-resolved continuum fields and writes the data into a stat file.
Definition: CG.h:76
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:408
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. LinearViscoelasticSpecies, etc.
Definition: DPMBase.h:1427
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: DPMBase.cc:422
const std::string & getName() const
Returns the name of the file. Does not allow to change it though.
Definition: DPMBase.cc:399
CGHandler cgHandler
Object of the class cgHandler.
Definition: DPMBase.h:1473
void setTimeStep(Mdouble newDt)
Sets a new value for the simulation time step.
Definition: DPMBase.cc:1234
void setTimeMax(Mdouble newTMax)
Sets a new value for the maximum simulation duration.
Definition: DPMBase.cc:873
void setSystemDimensions(unsigned int newDim)
Sets the system dimensionality.
Definition: DPMBase.cc:1417
void solve()
The work horse of the code.
Definition: DPMBase.cc:4270
void setGravity(Vec3D newGravity)
Sets a new value for the gravitational acceleration.
Definition: DPMBase.cc:1383
void setName(const std::string &name)
Sets the file name, e.g. "Name.data".
Definition: File.cc:198
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_.
Definition: File.cc:273
Evaluates time-averaged continuum fields and writes the data into a stat file.
Definition: TimeAveragedCG.h:59
Evaluates time-smoothed continuum fields and writes the data into a stat file.
Definition: TimeSmoothedCG.h:60
void setTimeStep(Mdouble timeStep)
void setWidthTime(Mdouble widthTime)
Definition: Vector.h:51
const Mdouble pi
Definition: ExtendedMath.h:45
bool writeToFile(std::string filename, std::string filecontent)
Writes a string to a file.
Definition: FileIOHelpers.cc:58

References DPMBase::cgHandler, BaseHandler< T >::copyAndAddObject(), DPMBase::getName(), constants::pi, DPMBase::setGravity(), DPMBase::setName(), File::setName(), DPMBase::setSaveCount(), File::setSaveCount(), DPMBase::setSystemDimensions(), DPMBase::setTimeMax(), BaseCG::setTimeMax(), BaseCG::setTimeMin(), DPMBase::setTimeStep(), TimeSmoothedCG< Coordinates, BaseFunction, Fields >::setTimeStep(), TimeSmoothedCG< Coordinates, BaseFunction, Fields >::setWidthTime(), DPMBase::solve(), DPMBase::speciesHandler, BaseCG::statFile, and helpers::writeToFile().