PeriodicWallsUnitTest.cpp File Reference

Classes

class  PeriodicWalls
 

Functions

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

Function Documentation

◆ main()

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

Start off my solving the default problem

135 {
137  PeriodicWalls problem;
139  species.setDensity(2000);
140  species.setStiffness(10000);
141  species.setDissipation(1);
142  problem.speciesHandler.copyAndAddObject(species);
143 
144  problem.setTimeMax(0.11);
145  problem.setTimeStep(1.1e-05);
147  problem.getTimeStep()));
148  problem.setName("PeriodicWallsUnitTest");
149 
150  problem.solve();
151 
152  Vec3D goodPos;
153  Vec3D goodVel;
154  std::vector<BaseParticle*>::iterator pIt = problem.particleHandler.begin();
155 
156  goodPos = Vec3D(0.00950076062215577, 0.002, 0);
157  goodVel = Vec3D(-0.005560409816604, 0, 0);
158  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
159  {
160  logger(FATAL, "E0 The particle is in the wrong position. It is %, however is should be %",
161  (*pIt)->getPosition(), goodPos);
162  }
163  if (!(*pIt)->getVelocity().isEqualTo(goodVel, 1e-10))
164  {
165  logger(FATAL, "E0 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(),
166  goodVel);
167  }
168  ++pIt;
169 
170  goodPos = Vec3D(0.000725163257251641, 0.002, 0);
171  goodVel = Vec3D(-0.000808302139899, 0, 0);
172  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
173  {
174  logger(FATAL, "E1 The particle is in the wrong position. It is %, however is should be %",
175  (*pIt)->getPosition(), goodPos);
176  }
177  if (!(*pIt)->getVelocity().isEqualTo(goodVel, 1e-10))
178  {
179  logger(FATAL, "E1 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(),
180  goodVel);
181  }
182  ++pIt;
183 
184  goodPos = Vec3D(0.00950076062215577, 0.003, 0);
185  goodVel = Vec3D(-0.005560409816604, 0, 0);
186  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
187  {
188  logger(FATAL, "E2 The particle is in the wrong position. It is %, however is should be %",
189  (*pIt)->getPosition(), goodPos);
190  }
191  if (!(*pIt)->getVelocity().isEqualTo(goodVel, 1e-10))
192  {
193  logger(FATAL, "E2 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(),
194  goodVel);
195  }
196  ++pIt;
197 
198  goodPos = Vec3D(0.000725163257251641, 0.003, 0);
199  goodVel = Vec3D(-0.000808302139899, 0, 0);
200  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
201  {
202  logger(FATAL, "E3 The particle is in the wrong position. It is %, however is should be %",
203  (*pIt)->getPosition(), goodPos);
204  }
205  if (!(*pIt)->getVelocity().isEqualTo(goodVel, 1e-10))
206  {
207  logger(FATAL, "E3 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(),
208  goodVel);
209  }
210  ++pIt;
211 
212  goodPos = Vec3D(0.0004992393778432442, 0.004, 0);
213  goodVel = Vec3D(0.00556040981661, 0, 0);
214  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
215  {
216  logger(FATAL, "E4 The particle is in the wrong position. It is %, however is should be %",
217  (*pIt)->getPosition(), goodPos);
218  }
219  if (!(*pIt)->getVelocity().isEqualTo(goodVel, 1e-10))
220  {
221  logger(FATAL, "E4 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(),
222  goodVel);
223  }
224  ++pIt;
225 
226  goodPos = Vec3D(0.00927483674274562, 0.004, 0);
227  goodVel = Vec3D(0.0008083021398896, 0, 0);
228  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
229  {
230  logger(FATAL, "E5 The particle is in the wrong position. It is %, however is should be %",
231  (*pIt)->getPosition(), goodPos);
232  }
233  if (!(*pIt)->getVelocity().isEqualTo(goodVel, 1e-10))
234  {
235  logger(FATAL, "E5 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(),
236  goodVel);
237  }
238  ++pIt;
239 
240  goodPos = Vec3D(0.000499239377843248, 0.005, 0);
241  goodVel = Vec3D(0.00556040981661, 0, 0);
242  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
243  {
244  logger(FATAL, "E6 The particle is in the wrong position. It is %, however is should be %",
245  (*pIt)->getPosition(), goodPos);
246  }
247  if (!(*pIt)->getVelocity().isEqualTo(goodVel, 1e-10))
248  {
249  logger(FATAL, "E6 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(),
250  goodVel);
251  }
252  ++pIt;
253 
254  goodPos = Vec3D(0.00927483674274562, 0.005, 0);
255  goodVel = Vec3D(0.0008083021398892, 0, 0);
256  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
257  {
258  logger(FATAL, "E7 The particle is in the wrong position. It is %, however is should be %",
259  (*pIt)->getPosition(), goodPos);
260  }
261  if (!(*pIt)->getVelocity().isEqualTo(goodVel, 1e-10))
262  {
263  logger(FATAL, "E7 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(),
264  goodVel);
265  }
266  ++pIt;
267 
268  goodPos = Vec3D(0.00149923937784423, 0.006, 0);
269  goodVel = Vec3D(0.005560409816606, 0, 0);
270  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
271  {
272  logger(FATAL, "E8 The particle is in the wrong position. It is %, however is should be %",
273  (*pIt)->getPosition(), goodPos);
274  }
275  if (!(*pIt)->getVelocity().isEqualTo(goodVel, 1e-10))
276  {
277  logger(FATAL, "E8 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(),
278  goodVel);
279  }
280  ++pIt;
281 
282  goodPos = Vec3D(0.000274836742748357, 0.006, 0);
283  goodVel = Vec3D(0.0008083021398959, 0, 0);
284  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
285  {
286  logger(FATAL, "E9 The particle is in the wrong position. It is %, however is should be %",
287  (*pIt)->getPosition(), goodPos);
288  }
289  if (!(*pIt)->getVelocity().isEqualTo(goodVel, 1e-10))
290  {
291  logger(FATAL, "E9 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(),
292  goodVel);
293  }
294  ++pIt;
295 
296  goodPos = Vec3D(0.000368955529803987, 0.000368955529803987, 0);
297  goodVel = Vec3D(0.005560480643586, 0.005560480643586, 0);
298  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
299  {
300  logger(FATAL, "E10 The particle is in the wrong position. It is %, however is should be %",
301  (*pIt)->getPosition(), goodPos);
302  }
303  if (!(*pIt)->getVelocity().isEqualTo(goodVel, 1e-10))
304  {
305  logger(FATAL, "E10 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(),
306  goodVel);
307  }
308  ++pIt;
309 
310  goodPos = Vec3D(0.0094902039201126, 0.0094902039201126, 0);
311  goodVel = Vec3D(0.0008081850585628, 0.0008081850585628, 0);
312  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
313  {
314  logger(FATAL, "E11 The particle is in the wrong position. It is %, however is should be %",
315  (*pIt)->getPosition(), goodPos);
316  }
317  if (!(*pIt)->getVelocity().isEqualTo(goodVel, 1e-10))
318  {
319  logger(FATAL, "E11 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(),
320  goodVel);
321  }
322  ++pIt;
323 
324  goodPos = Vec3D(0.00963104447019111, 0.00963104447019111, 0.001);
325  goodVel = Vec3D(-0.005560480643562, -0.005560480643562, 0);
326  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
327  {
328  logger(FATAL, "E12 The particle is in the wrong position. It is %, however is should be %",
329  (*pIt)->getPosition(), goodPos);
330  }
331  if (!(*pIt)->getVelocity().isEqualTo(goodVel, 1e-10))
332  {
333  logger(FATAL, "E12 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(),
334  goodVel);
335  }
336  ++pIt;
337 
338  goodPos = Vec3D(0.00050979607988006, 0.00050979607988006, 0.001);
339  goodVel = Vec3D(-0.0008081850586013, -0.0008081850586013, 0);
340  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
341  {
342  logger(FATAL, "E13 The particle is in the wrong position. It is %, however is should be %",
343  (*pIt)->getPosition(), goodPos);
344  }
345  if (!(*pIt)->getVelocity().isEqualTo(goodVel, 1e-10))
346  {
347  logger(FATAL, "E13 The particle has the wrong velocity. It is %, however is should be %",
348  (*pIt)->getVelocity(), goodVel);
349  }
350 
351 
352 }
LL< Log::FATAL > FATAL
Definition of the different loglevels by its wrapper class LL. These are used as tags in template met...
Definition: Logger.cc:52
Logger< MERCURYDPM_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here.
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:690
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
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
Mdouble getTimeStep() const
Returns the simulation time step.
Definition: DPMBase.cc:1250
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created.
Definition: DPMBase.h:1437
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 solve()
The work horse of the code.
Definition: DPMBase.cc:4270
Mdouble getTimeMax() const
Returns the maximum simulation duration.
Definition: DPMBase.cc:888
void setDissipation(Mdouble dissipation)
Allows the normal dissipation to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:117
void setStiffness(Mdouble new_k)
Allows the spring constant to be changed.
Definition: LinearViscoelasticNormalSpecies.cc:93
void setDensity(Mdouble density)
Definition: ParticleSpecies.cc:108
Definition: PeriodicWallsUnitTest.cpp:32
Definition: Vector.h:51
unsigned int getSaveCountFromNumberOfSavesAndTimeMaxAndTimeStep(unsigned int numberOfSaves, Mdouble timeMax, Mdouble timeStep)
Returns the correct saveCount if the total number of saves, the final time and the time step is known...
Definition: FormulaHelpers.cc:96

References BaseHandler< T >::begin(), BaseHandler< T >::copyAndAddObject(), FATAL, helpers::getSaveCountFromNumberOfSavesAndTimeMaxAndTimeStep(), DPMBase::getTimeMax(), DPMBase::getTimeStep(), logger, DPMBase::particleHandler, ParticleSpecies::setDensity(), LinearViscoelasticNormalSpecies::setDissipation(), DPMBase::setName(), DPMBase::setSaveCount(), LinearViscoelasticNormalSpecies::setStiffness(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), DPMBase::solve(), and DPMBase::speciesHandler.