MercuryDPM  0.11
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PeriodicWallsUnitTest.cpp File Reference
#include <sstream>
#include <iostream>
#include <cstdlib>
#include "Mercury2D.h"
#include "Boundaries/PeriodicBoundary.h"
#include "Particles/BaseParticle.h"
#include "Species/LinearViscoelasticSpecies.h"
#include <Logger.h>

Go to the source code of this file.

Classes

class  periodic_walls
 

Functions

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

Function Documentation

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

Start off my solving the default problem

Definition at line 119 of file PeriodicWallsUnitTest.cpp.

References SpeciesHandler::addObject(), BaseHandler< T >::begin(), FATAL, helpers::getSaveCountFromNumberOfSavesAndTimeMaxAndTimestep(), DPMBase::getTimeMax(), DPMBase::getTimeStep(), logger, DPMBase::particleHandler, Files::setName(), Files::setSaveCount(), DPMBase::setTimeMax(), DPMBase::setTimeStep(), DPMBase::solve(), and DPMBase::speciesHandler.

120 {
122  periodic_walls problem;
123  auto species = new LinearViscoelasticSpecies;
124  problem.speciesHandler.addObject(species);
125  species->setDensity(2000);
126  species->setStiffness(10000);
127  species->setDissipation(1);
128 
129  problem.setTimeMax(0.11);
130  problem.setTimeStep(1.1e-05);
131  //problem.setSaveCount(helpers::getSaveCountFromNumberOfSavesAndTimeMaxAndTimestep(1,problem.getTimeMax(),problem.getTimeStep()));
133  problem.setName("PeriodicWallsUnitTest");
134 
135  problem.solve();
136 
137  Vec3D goodPos;
138  Vec3D goodVel;
139  std::vector<BaseParticle*>::iterator pIt = problem.particleHandler.begin();
140 
141  goodPos=Vec3D(0.00950076062215577,0.002,0);
142  goodVel=Vec3D(-0.005560409816604,0,0);
143  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
144  {
145  logger(FATAL, "E0 The particle is in the wrong position. It is %, however is should be %", (*pIt)->getPosition(), goodPos);
146  }
147  if (!(*pIt)->getVelocity().isEqualTo(goodVel , 1e-10))
148  {
149  logger(FATAL, "E0 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(), goodVel);
150  }
151  ++pIt;
152 
153  goodPos=Vec3D(0.000725163257251641,0.002,0);
154  goodVel=Vec3D(-0.000808302139899,0,0);
155  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
156  {
157  logger(FATAL, "E1 The particle is in the wrong position. It is %, however is should be %", (*pIt)->getPosition(), goodPos);
158  }
159  if (!(*pIt)->getVelocity().isEqualTo(goodVel , 1e-10))
160  {
161  logger(FATAL, "E1 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(), goodVel);
162  }
163  ++pIt;
164 
165  goodPos=Vec3D(0.00950076062215577,0.003,0);
166  goodVel=Vec3D(-0.005560409816604,0,0);
167  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
168  {
169  logger(FATAL, "E2 The particle is in the wrong position. It is %, however is should be %", (*pIt)->getPosition(), goodPos);
170  }
171  if (!(*pIt)->getVelocity().isEqualTo(goodVel , 1e-10))
172  {
173  logger(FATAL, "E2 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(), goodVel);
174  }
175  ++pIt;
176 
177  goodPos=Vec3D(0.000725163257251641,0.003,0);
178  goodVel=Vec3D(-0.000808302139899,0,0);
179  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
180  {
181  logger(FATAL, "E3 The particle is in the wrong position. It is %, however is should be %", (*pIt)->getPosition(), goodPos);
182  }
183  if (!(*pIt)->getVelocity().isEqualTo(goodVel , 1e-10))
184  {
185  logger(FATAL, "E3 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(), goodVel);
186  }
187  ++pIt;
188 
189  goodPos=Vec3D(0.0004992393778432442,0.004,0);
190  goodVel=Vec3D(0.00556040981661,0,0);
191  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
192  {
193  logger(FATAL, "E4 The particle is in the wrong position. It is %, however is should be %", (*pIt)->getPosition(), goodPos);
194  }
195  if (!(*pIt)->getVelocity().isEqualTo(goodVel , 1e-10))
196  {
197  logger(FATAL, "E4 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(), goodVel);
198  }
199  ++pIt;
200 
201  goodPos=Vec3D(0.00927483674274562,0.004,0);
202  goodVel=Vec3D(0.0008083021398896,0,0);
203  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
204  {
205  logger(FATAL, "E5 The particle is in the wrong position. It is %, however is should be %", (*pIt)->getPosition(), goodPos);
206  }
207  if (!(*pIt)->getVelocity().isEqualTo(goodVel , 1e-10))
208  {
209  logger(FATAL, "E5 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(), goodVel);
210  }
211  ++pIt;
212 
213  goodPos=Vec3D(0.000499239377843248,0.005,0);
214  goodVel=Vec3D(0.00556040981661,0,0);
215  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
216  {
217  logger(FATAL, "E6 The particle is in the wrong position. It is %, however is should be %", (*pIt)->getPosition(), goodPos);
218  }
219  if (!(*pIt)->getVelocity().isEqualTo(goodVel , 1e-10))
220  {
221  logger(FATAL, "E6 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(), goodVel);
222  }
223  ++pIt;
224 
225  goodPos=Vec3D(0.00927483674274562,0.005,0);
226  goodVel=Vec3D(0.0008083021398892,0,0);
227  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
228  {
229  logger(FATAL, "E7 The particle is in the wrong position. It is %, however is should be %", (*pIt)->getPosition(), goodPos);
230  }
231  if (!(*pIt)->getVelocity().isEqualTo(goodVel , 1e-10))
232  {
233  logger(FATAL, "E7 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(), goodVel);
234  }
235  ++pIt;
236 
237  goodPos=Vec3D(0.00149923937784423,0.006,0);
238  goodVel=Vec3D(0.005560409816606,0,0);
239  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
240  {
241  logger(FATAL, "E8 The particle is in the wrong position. It is %, however is should be %", (*pIt)->getPosition(), goodPos);
242  }
243  if (!(*pIt)->getVelocity().isEqualTo(goodVel , 1e-10))
244  {
245  logger(FATAL, "E8 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(), goodVel);
246  }
247  ++pIt;
248 
249  goodPos=Vec3D(0.000274836742748357,0.006,0);
250  goodVel=Vec3D(0.0008083021398959,0,0);
251  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
252  {
253  logger(FATAL, "E9 The particle is in the wrong position. It is %, however is should be %", (*pIt)->getPosition(), goodPos);
254  }
255  if (!(*pIt)->getVelocity().isEqualTo(goodVel , 1e-10))
256  {
257  logger(FATAL, "E9 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(), goodVel);
258  }
259  ++pIt;
260 
261  goodPos=Vec3D(0.000368955529803987, 0.000368955529803987,0);
262  goodVel=Vec3D(0.005560480643586,0.005560480643586,0);
263  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
264  {
265  logger(FATAL, "E10 The particle is in the wrong position. It is %, however is should be %", (*pIt)->getPosition(), goodPos);
266  }
267  if (!(*pIt)->getVelocity().isEqualTo(goodVel , 1e-10))
268  {
269  logger(FATAL, "E10 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(), goodVel);
270  }
271  ++pIt;
272 
273  goodPos=Vec3D(0.0094902039201126, 0.0094902039201126 ,0);
274  goodVel=Vec3D(0.0008081850585628,0.0008081850585628,0);
275  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
276  {
277  logger(FATAL, "E11 The particle is in the wrong position. It is %, however is should be %", (*pIt)->getPosition(), goodPos);
278  }
279  if (!(*pIt)->getVelocity().isEqualTo(goodVel , 1e-10))
280  {
281  logger(FATAL, "E11 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(), goodVel);
282  }
283  ++pIt;
284 
285  goodPos=Vec3D(0.00963104447019111, 0.00963104447019111,0.001);
286  goodVel=Vec3D(-0.005560480643562,-0.005560480643562,0);
287  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
288  {
289  logger(FATAL, "E12 The particle is in the wrong position. It is %, however is should be %", (*pIt)->getPosition(), goodPos);
290  }
291  if (!(*pIt)->getVelocity().isEqualTo(goodVel , 1e-10))
292  {
293  logger(FATAL, "E12 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(), goodVel);
294  }
295  ++pIt;
296 
297  goodPos=Vec3D(0.00050979607988006, 0.00050979607988006,0.001);
298  goodVel=Vec3D(-0.0008081850586013,-0.0008081850586013,0);
299  if (!(*pIt)->getPosition().isEqualTo(goodPos, 1e-10))
300  {
301  logger(FATAL, "E13 The particle is in the wrong position. It is %, however is should be %", (*pIt)->getPosition(), goodPos);
302  }
303  if (!(*pIt)->getVelocity().isEqualTo(goodVel , 1e-10))
304  {
305  logger.log(Log::FATAL, "E13 The particle has the wrong velocity. It is %, however is should be %", (*pIt)->getVelocity(), goodVel);
306  }
307 
308 
309 }
void solve()
The work horse of the code.
Definition: DPMBase.cc:1895
void setTimeMax(Mdouble newTMax)
Allows the upper time limit to be changed.
Definition: DPMBase.cc:179
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:482
void setName(const std::string &name)
Allows to set the name of all the files (ene, data, fstat, restart, stat)
Definition: Files.cc:149
virtual void addObject(ParticleSpecies *const S)
Adds a new ParticleSpecies to the SpeciesHandler.
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:878
LL< Log::FATAL > FATAL
Fatal log level.
Definition: Logger.cc:25
void setSaveCount(unsigned int saveCount)
Sets File::saveCount_ for all files (ene, data, fstat, restart, stat)
Definition: Files.cc:138
Species< LinearViscoelasticNormalSpecies > LinearViscoelasticSpecies
SpeciesHandler speciesHandler
A handler to that stores the species type i.e. elastic, linear visco-elastic... et cetera...
Definition: DPMBase.h:868
void setTimeStep(Mdouble newDt)
Allows the time step dt to be changed.
Definition: DPMBase.cc:353
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
Mdouble getTimeStep() const
Allows the time step dt to be accessed.
Definition: DPMBase.cc:368
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: Helpers.cc:343
Mdouble getTimeMax() const
Allows the user to access the total simulation time during the simulation. Cannot change it though...
Definition: DPMBase.cc:194