LifeV
lifev/structure/testsuite/structuralsolver/main.cpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 /**
27  \file main.cpp
28 
29  This test is the case of traction of a cube. It does not use the symmetry BCs
30  This test uses the FESpace which is the standard in LifeV and the ETFESpace
31  The FESpace is used for the BCs of Neumann type since in the ET branch there
32  is not the integration over the boundary faces.
33 
34  \author Paolo Tricerri <paolo.tricerri@epfl.ch>
35  \date 1861-03-17
36  */
37 
38 #ifdef TWODIM
39 #error test_structure cannot be compiled in 2D
40 #endif
41 
42 
43 #include <Epetra_ConfigDefs.h>
44 #ifdef EPETRA_MPI
45 #include <mpi.h>
46 #include <Epetra_MpiComm.h>
47 #else
48 #include <Epetra_SerialComm.h>
49 #endif
50 
51 
52 #include <lifev/core/LifeV.hpp>
53 #include <lifev/core/algorithm/PreconditionerIfpack.hpp>
54 #include <lifev/core/algorithm/PreconditionerML.hpp>
55 
56 #include <lifev/core/array/MapEpetra.hpp>
57 
58 #include <lifev/core/fem/TimeAdvance.hpp>
59 #include <lifev/core/fem/TimeAdvanceNewmark.hpp>
60 #include <lifev/core/fem/TimeAdvanceBDF.hpp>
61 
62 #include <lifev/core/mesh/MeshData.hpp>
63 #include <lifev/core/mesh/MeshPartitioner.hpp>
64 
65 #include <lifev/structure/solver/StructuralConstitutiveLawData.hpp>
66 
67 #include <lifev/structure/solver/StructuralConstitutiveLaw.hpp>
68 #include <lifev/structure/solver/StructuralOperator.hpp>
69 #include <lifev/structure/solver/isotropic/VenantKirchhoffMaterialLinear.hpp>
70 #include <lifev/structure/solver/isotropic/VenantKirchhoffMaterialNonLinear.hpp>
71 #include <lifev/structure/solver/isotropic/ExponentialMaterialNonLinear.hpp>
72 #include <lifev/structure/solver/isotropic/VenantKirchhoffMaterialNonLinearPenalized.hpp>
73 #include <lifev/structure/solver/isotropic/SecondOrderExponentialMaterialNonLinear.hpp>
74 #include <lifev/structure/solver/isotropic/NeoHookeanMaterialNonLinear.hpp>
75 
76 #include <lifev/core/filter/ExporterEnsight.hpp>
77 #ifdef HAVE_HDF5
78 #include <lifev/core/filter/ExporterHDF5.hpp>
79 #endif
80 #include <lifev/core/filter/ExporterEmpty.hpp>
81 
82 //Includes for the Expression Template
83 #include <lifev/eta/fem/ETFESpace.hpp>
84 
85 #include <iostream>
86 
87 
88 using namespace LifeV;
89 
90 int returnValue = EXIT_FAILURE;
92 
93 namespace
94 {
95 static bool regIF = (PRECFactory::instance().registerProduct ( "Ifpack", &createIfpack ) );
96 static bool regML = (PRECFactory::instance().registerProduct ( "ML", &createML ) );
97 }
98 
99 
101 {
102  std::string stringList = list;
103  std::set<UInt> setList;
104  if ( list == "" )
105  {
106  return setList;
107  }
108  size_t commaPos = 0;
109  while ( commaPos != std::string::npos )
110  {
111  commaPos = stringList.find ( "," );
112  setList.insert ( atoi ( stringList.substr ( 0, commaPos ).c_str() ) );
113  stringList = stringList.substr ( commaPos + 1 );
114  }
115  setList.insert ( atoi ( stringList.c_str() ) );
116  return setList;
117 }
118 
119 
120 class Structure
121 {
122 public:
123 
124  /** @name Constructors, destructor
125  */
126  //@{
127  Structure ( int argc,
128  char** argv,
129  std::shared_ptr<Epetra_Comm> structComm );
130 
132  {}
133  //@}
134 
135  //@{
136  void run()
137  {
138  run3d();
139  }
140  void CheckResultLE (const Real& dispNorm, const Real& time);
141  void CheckResultSVK (const Real& dispNorm, const Real& time);
142  void CheckResultSVKPenalized (const Real& dispNorm, const Real& time);
143  void CheckResultEXP (const Real& dispNorm, const Real& time);
144  void CheckResultNH (const Real& dispNorm, const Real& time);
145  void CheckResult2ndOrderExponential (const Real& dispNorm, const Real& time);
146  void resultChanged (Real time);
147  //@}
148 
149 protected:
150 
151 private:
152 
153  /**
154  * run the 2D driven cylinder simulation
155  */
156  void run2d();
157 
158  /**
159  * run the 3D driven cylinder simulation
160  */
161  void run3d();
162 
163 private:
164  struct Private;
166 };
167 
168 
169 
170 struct Structure::Private
171 {
173  rho (1), poisson (1), young (1), bulk (1), alpha (1), gamma (1)
174  {}
175  typedef std::function<Real ( Real const&, Real const&, Real const&, Real const&, ID const& ) > fct_type;
176  double rho, poisson, young, bulk, alpha, gamma;
177 
179 
181 
182  static Real bcZero (const Real& /*t*/, const Real& /*X*/, const Real& /*Y*/, const Real& /*Z*/, const ID& /*i*/)
183  {
184  return 0.;
185  }
186 
187  static Real bcNonZero (const Real& /*t*/, const Real& /*X*/, const Real& /*Y*/, const Real& /*Z*/, const ID& /*i*/)
188  {
189  return 300000.;
190  }
191 
192  static Real bcNonZeroSecondOrderExponential (const Real& /*t*/, const Real& /*X*/, const Real& /*Y*/, const Real& /*Z*/, const ID& /*i*/)
193  {
194  return 19180.;
195  }
196 
197  static Real d0 (const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
198  {
199 
200  switch (i)
201  {
202  case 0:
203  return 0.088002 * ( x + 0.5 );
204  break;
205  case 1:
206  return - ( 0.02068 * 2.0 ) * ( y );
207  break;
208  case 2:
209  return - ( 0.02068 * 2.0 ) * ( z );
210  break;
211  default:
212  ERROR_MSG ("This entry is not allowed: ud_functions.hpp");
213  return 0.;
214  break;
215  }
216 
217  }
218 
219 };
220 
221 
222 
223 Structure::Structure ( int argc,
224  char** argv,
225  std::shared_ptr<Epetra_Comm> structComm) :
226  parameters ( new Private() )
227 {
228  GetPot command_line (argc, argv);
229  std::string data_file_name = command_line.follow ("data", 2, "-f", "--file");
230  GetPot dataFile ( data_file_name );
231  parameters->data_file_name = data_file_name;
232 
233  parameters->rho = dataFile ( "solid/physics/density", 1. );
234  parameters->young = dataFile ( "solid/physics/young", 1. );
235  parameters->poisson = dataFile ( "solid/physics/poisson", 1. );
236  parameters->bulk = dataFile ( "solid/physics/bulk", 1. );
237  parameters->alpha = dataFile ( "solid/physics/alpha", 1. );
238  parameters->gamma = dataFile ( "solid/physics/gamma", 1. );
239 
240  std::cout << "density = " << parameters->rho << std::endl
241  << "young = " << parameters->young << std::endl
242  << "poisson = " << parameters->poisson << std::endl
243  << "bulk = " << parameters->bulk << std::endl
244  << "alpha = " << parameters->alpha << std::endl
245  << "gamma = " << parameters->gamma << std::endl;
246 
247  parameters->comm = structComm;
248  int ntasks = parameters->comm->NumProc();
249 
250  if (!parameters->comm->MyPID() )
251  {
252  std::cout << "My PID = " << parameters->comm->MyPID() << " out of " << ntasks << " running." << std::endl;
253  }
254 }
255 
256 
257 
258 void
259 Structure::run2d()
260 {
261  std::cout << "2D cylinder test case is not available yet\n";
262 }
263 
264 
265 
266 void
267 Structure::run3d()
268 {
269  typedef StructuralOperator< RegionMesh<LinearTetra> >::vector_Type vector_Type;
270  typedef std::shared_ptr<vector_Type> vectorPtr_Type;
271  typedef std::shared_ptr< TimeAdvance< vector_Type > > timeAdvance_Type;
272  typedef FESpace< RegionMesh<LinearTetra>, MapEpetra > solidFESpace_Type;
273  typedef std::shared_ptr<solidFESpace_Type> solidFESpacePtr_Type;
274 
275  typedef ETFESpace< RegionMesh<LinearTetra>, MapEpetra, 3, 3 > solidETFESpace_Type;
276  typedef std::shared_ptr<solidETFESpace_Type> solidETFESpacePtr_Type;
277 
278 
279  bool verbose = (parameters->comm->MyPID() == 0);
280 
281  //! Number of boundary conditions for the velocity and mesh motion
282  std::shared_ptr<BCHandler> BCh ( new BCHandler() );
283 
284  //! dataElasticStructure
285  GetPot dataFile ( parameters->data_file_name.c_str() );
286 
287  std::shared_ptr<StructuralConstitutiveLawData> dataStructure (new StructuralConstitutiveLawData( ) );
288  dataStructure->setup (dataFile);
289 
290  MeshData meshData;
291  meshData.setup (dataFile, "solid/space_discretization");
292 
293 
294  std::shared_ptr<RegionMesh<LinearTetra> > fullMeshPtr (new RegionMesh<LinearTetra> ( parameters->comm ) );
295  std::shared_ptr<RegionMesh<LinearTetra> > localMeshPtr (new RegionMesh<LinearTetra> ( parameters->comm ) );
296 
297  readMesh (*fullMeshPtr, meshData);
298 
299  MeshPartitioner< RegionMesh<LinearTetra> > meshPart ( fullMeshPtr, parameters->comm );
300  localMeshPtr = meshPart.meshPartition();
301 
302  std::string dOrder = dataFile ( "solid/space_discretization/order", "P1");
303 
304  //Mainly used for BCs assembling (Neumann type)
305  solidFESpacePtr_Type dFESpace ( new solidFESpace_Type (localMeshPtr, dOrder, 3, parameters->comm) );
306  solidETFESpacePtr_Type dETFESpace ( new solidETFESpace_Type (meshPart, & (dFESpace->refFE() ), & (dFESpace->fe().geoMap() ), parameters->comm) );
307 
308  if (verbose)
309  {
310  std::cout << std::endl;
311  }
312 
313  std::string timeAdvanceMethod = dataFile ( "solid/time_discretization/method", "Newmark");
314 
315  timeAdvance_Type timeAdvance ( TimeAdvanceFactory::instance().createObject ( timeAdvanceMethod ) );
316 
317  UInt OrderDev = 2;
318 
319  //! initialization of parameters of time Advance method:
320  if (timeAdvanceMethod == "Newmark")
321  {
322  timeAdvance->setup ( dataStructure->dataTimeAdvance()->coefficientsNewmark() , OrderDev);
323  }
324 
325  if (timeAdvanceMethod == "BDF")
326  {
327  timeAdvance->setup (dataStructure->dataTimeAdvance()->orderBDF() , OrderDev);
328  }
329 
330  timeAdvance->setTimeStep (dataStructure->dataTime()->timeStep() );
331  //timeAdvance->showMe();
332 
333  //! #################################################################################
334  //! BOUNDARY CONDITIONS
335  //! #################################################################################
336  std::vector <ID> compx (1), compy (1), compz (1), compxy (2), compxz (2), compyz (2);
337  compx[0] = 0;
338  compy[0] = 1, compz[0] = 2;
339  compxy[0] = 0;
340  compxy[1] = 1;
341  compxz[0] = 0;
342  compxz[1] = 2;
343  compyz[0] = 1;
344  compyz[1] = 2;
345 
346  BCFunctionBase zero (Private::bcZero);
347  BCFunctionBase nonZero;
348 
349  if ( dataStructure->solidTypeIsotropic().compare ("secondOrderExponential") )
350  {
351  nonZero.setFunction (Private::bcNonZero);
352  }
353  else
354  {
355  nonZero.setFunction (Private::bcNonZeroSecondOrderExponential);
356  }
357 
358 
359  //! =================================================================================
360  //! BC for StructuredCube4_test_structuralsolver.mesh
361  //! =================================================================================
362  BCh->addBC ("EdgesIn", 20, Natural, Component, nonZero, compx);
363  BCh->addBC ("EdgesIn", 40, Essential, Component, zero, compx);
364  //! =================================================================================
365 
366  //! 1. Constructor of the structuralSolver
367  StructuralOperator< RegionMesh<LinearTetra> > solid;
368 
369  //! 2. Setup of the structuralSolver
370  solid.setup (dataStructure,
371  dFESpace,
372  dETFESpace,
373  BCh,
374  parameters->comm);
375 
376  //! 3. Setting data from getPot
377  solid.setDataFromGetPot (dataFile);
378 
379  //! 4. Building system using TimeAdvance class
380  double timeAdvanceCoefficient = timeAdvance->coefficientSecondDerivative ( 0 ) / (dataStructure->dataTime()->timeStep() * dataStructure->dataTime()->timeStep() );
381  solid.buildSystem (timeAdvanceCoefficient);
382 
383 
384  //dataStructure->showMe();
385  //! =================================================================================
386  //! Temporal data and initial conditions
387  //! =================================================================================
388 
389  //! 5. Initial data
390  Real dt = dataStructure->dataTime()->timeStep();
391  // Real T = dataStructure->dataTime()->endTime();
392 
393  vectorPtr_Type rhs (new vector_Type (solid.displacement(), Unique) );
394  vectorPtr_Type disp (new vector_Type (solid.displacement(), Unique) );
395  vectorPtr_Type vel (new vector_Type (solid.displacement(), Unique) );
396  vectorPtr_Type acc (new vector_Type (solid.displacement(), Unique) );
397 
398  if (verbose)
399  {
400  std::cout << "S- initialization ... ";
401  }
402 
403  std::vector<vectorPtr_Type> uv0;
404 
405  if (timeAdvanceMethod == "Newmark")
406  {
407  uv0.push_back (disp);
408  uv0.push_back (vel);
409  uv0.push_back (acc);
410  }
411 
412  vectorPtr_Type initialDisplacement (new vector_Type (solid.displacement(), Unique) );
413 
414  if ( !dataStructure->solidTypeIsotropic().compare ("secondOrderExponential") )
415  {
416  dFESpace->interpolate ( static_cast<solidFESpace_Type::function_Type> ( Private::d0 ), *initialDisplacement, 0.0 );
417  }
418 
419  if (timeAdvanceMethod == "BDF")
420  {
421  Real tZero = dataStructure->dataTime()->initialTime();
422 
423  for ( UInt previousPass = 0; previousPass < timeAdvance->size() ; previousPass++)
424  {
425  Real previousTimeStep = tZero - previousPass * dt;
426  std::cout << "BDF " << previousTimeStep << "\n";
427  if ( !dataStructure->solidTypeIsotropic().compare ("secondOrderExponential") )
428  {
429  uv0.push_back (initialDisplacement);
430  }
431  else
432  {
433  uv0.push_back (disp);
434  }
435  }
436  }
437 
438  timeAdvance->setInitialCondition (uv0);
439 
440  timeAdvance->setTimeStep ( dt );
441 
442  timeAdvance->updateRHSContribution ( dt );
443 
444  if ( !dataStructure->solidTypeIsotropic().compare ("secondOrderExponential") )
445  {
446  solid.initialize ( initialDisplacement );
447  }
448  else
449  {
450  solid.initialize ( disp );
451  }
452 
453  MPI_Barrier (MPI_COMM_WORLD);
454 
455  if (verbose )
456  {
457  std::cout << "ok." << std::endl;
458  }
459 
460  std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporter;
461 
462  std::string const exporterType = dataFile ( "exporter/type", "ensight");
463 #ifdef HAVE_HDF5
464  if (exporterType.compare ("hdf5") == 0)
465  {
466  exporter.reset ( new ExporterHDF5<RegionMesh<LinearTetra> > ( dataFile, "structure" ) );
467  }
468  else
469 #endif
470  {
471  if (exporterType.compare ("none") == 0)
472  {
473  exporter.reset ( new ExporterEmpty<RegionMesh<LinearTetra> > ( dataFile, meshPart.meshPartition(), "structure", parameters->comm->MyPID() ) );
474  }
475 
476  else
477  {
478  exporter.reset ( new ExporterEnsight<RegionMesh<LinearTetra> > ( dataFile, meshPart.meshPartition(), "structure", parameters->comm->MyPID() ) );
479  }
480  }
481 
482  exporter->setPostDir ( "./" );
483  exporter->setMeshProcId ( meshPart.meshPartition(), parameters->comm->MyPID() );
484 
485  vectorPtr_Type solidDisp ( new vector_Type (solid.displacement(), exporter->mapType() ) );
486  vectorPtr_Type solidVel ( new vector_Type (solid.displacement(), exporter->mapType() ) );
487  vectorPtr_Type solidAcc ( new vector_Type (solid.displacement(), exporter->mapType() ) );
488 
489  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "displacement", dFESpace, solidDisp, UInt (0) );
490  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "velocity", dFESpace, solidVel, UInt (0) );
491  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "acceleration", dFESpace, solidAcc, UInt (0) );
492 
493  exporter->postProcess ( 0 );
494  /*
495  //!--------------------------------------------------------------------------------------------
496  //! MATLAB FILE WITH DISPLACEMENT OF A CHOSEN POINT
497  //!--------------------------------------------------------------------------------------------
498  cout.precision(16);
499  ofstream file_comp( "Displacement_components_NL.m" );
500  if ( !file_comp )
501  {
502  std::cout <<" Unable to open file! You need to specify the output folder in the data file " << std::endl;
503  }
504 
505  int IDPoint = 73; // StructuredCube4
506  //int IDPoint = 401; // StructuredCube8
507  //int IDPoint = 2593; // StructuredCube16
508 
509  //int IDPoint = 74;// cube4x4.mesh
510  //int IDPoint = 315;// cube8x8.mesh
511  //int IDPoint = 1526;// cube16x16.mesh
512 
513  file_comp << " % TEST NONLINEAR ELASTICITY" << endl;
514  file_comp << " % Displacement components of ID node " << IDPoint << " :" << endl;
515  file_comp << " % Each row is a time step" << endl;
516  file_comp << " % First column = comp x, second = comp y and third = comp z. " << endl;
517  file_comp << endl;
518  file_comp << " SolidDisp_NL = [ " ;
519 
520  for ( UInt k = IDPoint - 1; k <= solid.displacement().size() - 1; k = k + solid.displacement().size()/nDimensions )
521  {
522  file_comp<< solid.displacement()[ k ] << " ";
523  }
524 
525  file_comp<< endl;
526  */
527  //!--------------------------------------------------------------------------------------------
528  //!The update of the RHS is done by the TimeAdvance class
529  //solid.updateSystem();
530  //! =================================================================================
531 
532 
533  Real normVect;
534  normVect = solid.displacement().norm2();
535  std::cout << "The norm 2 of the displacement field is: " << normVect << std::endl;
536 
537  //! =============================================================================
538  //! Temporal loop
539  //! =============================================================================
540  // for (Real time = dt; time <= T; time += dt)
541  for (dataStructure->dataTime()->setTime ( dt ) ; dataStructure->dataTime()->canAdvance( ); dataStructure->dataTime()->updateTime( ) )
542  {
543  // dataStructure->dataTime()->setTime(time);
544 
545  if (verbose)
546  {
547  std::cout << std::endl;
548  std::cout << "S- Now we are at time " << dataStructure->dataTime()->time() << " s." << std::endl;
549  }
550 
551  if (verbose)
552  {
553  std::cout << std::endl;
554  std::cout << "S- Now we are at time " << dataStructure->dataTime()->time() << " s." << std::endl;
555  }
556 
557  //! 6. Updating right-hand side
558  *rhs *= 0;
559  timeAdvance->updateRHSContribution ( dt );
560  *rhs += *solid.massMatrix() * timeAdvance->rhsContributionSecondDerivative() / timeAdvanceCoefficient;
561  solid.setRightHandSide ( *rhs );
562 
563  //! 7. Iterate --> Calling Newton
564  solid.iterate ( BCh );
565 
566  timeAdvance->shiftRight ( solid.displacement() );
567 
568  *solidDisp = solid.displacement();
569  *solidVel = timeAdvance->firstDerivative();
570  *solidAcc = timeAdvance->secondDerivative();
571 
572  exporter->postProcess ( dataStructure->dataTime()->time() );
573 
574  /* This part lets to save the displacement at one point of the mesh and to check the result
575  w.r.t. manufactured solution.
576  //!--------------------------------------------------------------------------------------------------
577  //! MATLAB FILE WITH DISPLACEMENT OF A CHOOSEN POINT
578  //!--------------------------------------------------------------------------------------------------
579  cout <<"******* DISPLACEMENT COMPONENTS of ID node "<< IDPoint << " *******"<< std::endl;
580  for ( UInt k = IDPoint - 1 ; k <= solid.displacement().size() - 1; k = k + solid.displacement().size()/nDimensions )
581  {
582  file_comp<< solid.displacement()[ k ] << " ";
583  cout.precision(16);
584  cout <<"*********************************************************"<< std::endl;
585  cout <<" solid.disp()[ "<< k <<" ] = "<< solid.displacement()[ k ] << std::endl;
586  cout <<"*********************************************************"<< std::endl;
587  }
588  file_comp<< endl;
589  */
590 
591  Real normVect;
592  normVect = solid.displacement().norm2();
593  std::cout << "The norm 2 of the displacement field is: " << normVect << std::endl;
594 
595  ///////// CHECKING THE RESULTS OF THE TEST AT EVERY TIMESTEP
596  if (!dataStructure->solidTypeIsotropic().compare ("linearVenantKirchhoff") )
597  {
598  CheckResultLE (normVect, dataStructure->dataTime()->time() );
599  }
600  else if (!dataStructure->solidTypeIsotropic().compare ("nonLinearVenantKirchhoff") )
601  {
602  CheckResultSVK (normVect, dataStructure->dataTime()->time() );
603  }
604  else if (!dataStructure->solidTypeIsotropic().compare ("nonLinearVenantKirchhoffPenalized") )
605  {
606  CheckResultSVKPenalized (normVect, dataStructure->dataTime()->time() );
607  }
608  else if (!dataStructure->solidTypeIsotropic().compare ("exponential") )
609  {
610  CheckResultEXP (normVect, dataStructure->dataTime()->time() );
611  }
612  else if (!dataStructure->solidTypeIsotropic().compare ("secondOrderExponential") )
613  {
614  CheckResult2ndOrderExponential (normVect, dataStructure->dataTime()->time() );
615  }
616  else
617  {
618  CheckResultNH (normVect, dataStructure->dataTime()->time() );
619  }
620 
621  ///////// END OF CHECK
622 
623 
624  //!--------------------------------------------------------------------------------------------------
625 
626  MPI_Barrier (MPI_COMM_WORLD);
627  }
628 }
629 
630 
631 
632 void Structure::CheckResultLE (const Real& dispNorm, const Real& time)
633 {
634  if ( time == 0.1 && std::fabs (dispNorm - 0.276527) <= 1e-5 )
635  {
636  this->resultChanged (time);
637  }
638  if ( time == 0.2 && std::fabs (dispNorm - 0.276536) <= 1e-5 )
639  {
640  this->resultChanged (time);
641  }
642  if ( time == 0.3 && std::fabs (dispNorm - 0.276529) <= 1e-5 )
643  {
644  this->resultChanged (time);
645  }
646  if ( time == 0.4 && std::fabs (dispNorm - 0.276531) <= 1e-5 )
647  {
648  this->resultChanged (time);
649  }
650 }
651 
652 void Structure::CheckResultSVK (const Real& dispNorm, const Real& time)
653 {
654  if ( time == 0.1 && std::fabs (dispNorm - 0.263348) <= 1e-5 )
655  {
656  this->resultChanged (time);
657  }
658  if ( time == 0.2 && std::fabs (dispNorm - 0.263350) <= 1e-5 )
659  {
660  this->resultChanged (time);
661  }
662  if ( time == 0.3 && std::fabs (dispNorm - 0.263350) <= 1e-5 )
663  {
664  this->resultChanged (time);
665  }
666  if ( time == 0.4 && std::fabs (dispNorm - 0.263351) <= 1e-5 )
667  {
668  this->resultChanged (time);
669  }
670 }
671 void Structure::CheckResultSVKPenalized (const Real& dispNorm, const Real& time)
672 {
673  if ( time == 0.1 && std::fabs (dispNorm - 0.254316) <= 1e-5 )
674  {
675  this->resultChanged (time);
676  }
677  if ( time == 0.2 && std::fabs (dispNorm - 0.254322) <= 1e-5 )
678  {
679  this->resultChanged (time);
680  }
681  if ( time == 0.3 && std::fabs (dispNorm - 0.254317) <= 1e-5 )
682  {
683  this->resultChanged (time);
684  }
685  if ( time == 0.4 && std::fabs (dispNorm - 0.254318) <= 1e-5 )
686  {
687  this->resultChanged (time);
688  }
689 }
690 void Structure::CheckResultEXP (const Real& dispNorm, const Real& time)
691 {
692  if ( time == 0.1 && std::fabs (dispNorm - 0.284844) <= 1e-5 )
693  {
694  this->resultChanged (time);
695  }
696  if ( time == 0.2 && std::fabs (dispNorm - 0.284853) <= 1e-5 )
697  {
698  this->resultChanged (time);
699  }
700  if ( time == 0.3 && std::fabs (dispNorm - 0.284846) <= 1e-5 )
701  {
702  this->resultChanged (time);
703  }
704  if ( time == 0.4 && std::fabs (dispNorm - 0.284848) <= 1e-5 )
705  {
706  this->resultChanged (time);
707  }
708 }
709 
710 void Structure::CheckResultNH (const Real& dispNorm, const Real& time)
711 {
712  if ( time == 0.1 && std::fabs (dispNorm - 0.286120) <= 1e-5 )
713  {
714  this->resultChanged (time);
715  }
716  if ( time == 0.2 && std::fabs (dispNorm - 0.286129) <= 1e-5 )
717  {
718  this->resultChanged (time);
719  }
720  if ( time == 0.3 && std::fabs (dispNorm - 0.286122) <= 1e-5 )
721  {
722  this->resultChanged (time);
723  }
724  if ( time == 0.4 && std::fabs (dispNorm - 0.286123) <= 1e-5 )
725  {
726  this->resultChanged (time);
727  }
728 }
729 
730 
731 void Structure::CheckResult2ndOrderExponential (const Real& dispNorm, const Real& time)
732 {
733  if ( time == 0.1 && std::fabs (dispNorm - 0.561523) <= 1e-5 )
734  {
735  this->resultChanged (time);
736  }
737  if ( time == 0.2 && std::fabs (dispNorm - 0.561496) <= 1e-5 )
738  {
739  this->resultChanged (time);
740  }
741  if ( time == 0.3 && std::fabs (dispNorm - 0.561517) <= 1e-5 )
742  {
743  this->resultChanged (time);
744  }
745  if ( time == 0.4 && std::fabs (dispNorm - 0.561512) <= 1e-5 )
746  {
747  this->resultChanged (time);
748  }
749 }
750 
751 
752 
753 void Structure::resultChanged (Real time)
754 {
755  std::cout << "Correct value at time: " << time << std::endl;
756  returnValue = EXIT_SUCCESS;
757 }
758 
759 
760 
761 int
762 main ( int argc, char** argv )
763 {
764 
765 #ifdef HAVE_MPI
766  MPI_Init (&argc, &argv);
767  std::shared_ptr<Epetra_MpiComm> Comm (new Epetra_MpiComm ( MPI_COMM_WORLD ) );
768  if ( Comm->MyPID() == 0 )
769  {
770  std::cout << "% using MPI" << std::endl;
771  }
772 #else
773  std::shared_ptr<Epetra_SerialComm> Comm ( new Epetra_SerialComm() );
774  std::cout << "% using serial Version" << std::endl;
775 #endif
776 
777  Structure structure ( argc, argv, Comm );
778  structure.run();
779 
780 #ifdef HAVE_MPI
781  MPI_Finalize();
782 #endif
783  return returnValue ;
784 }
static Real bcNonZeroSecondOrderExponential(const Real &, const Real &, const Real &, const Real &, const ID &)
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
Structure(int argc, char **argv, std::shared_ptr< Epetra_Comm > structComm)
int main(int argc, char **argv)
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
Definition: GetPot.hpp:507
void CheckResultLE(const Real &dispNorm, const Real &time)
std::function< Real(Real const &, Real const &, Real const &, Real const &, ID const &) > fct_type
std::shared_ptr< hdf5Filter_Type > hdf5FilterPtr_Type
void CheckResultEXP(const Real &dispNorm, const Real &time)
static Real bcZero(const Real &, const Real &, const Real &, const Real &, const ID &)
#define ERROR_MSG(A)
Definition: LifeAssert.hpp:69
void CheckResultNH(const Real &dispNorm, const Real &time)
void run3d()
run the 3D driven cylinder simulation
uint32_type ID
IDs.
Definition: LifeV.hpp:194
void CheckResultSVKPenalized(const Real &dispNorm, const Real &time)
static Real d0(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
void run2d()
run the 2D driven cylinder simulation
MeshData - class for handling spatial discretization.
Definition: MeshData.hpp:72
void CheckResultSVK(const Real &dispNorm, const Real &time)
double Real
Generic real data.
Definition: LifeV.hpp:175
static Real bcNonZero(const Real &, const Real &, const Real &, const Real &, const ID &)
void CheckResult2ndOrderExponential(const Real &dispNorm, const Real &time)
std::set< UInt > parseList(const std::string &list)
void resultChanged(Real time)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191