LifeV
lifev/structure/testsuite/principalTensions/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  \author Paolo Tricerri <paolo.tricerri@epfl.ch>
29  \date 2012-05-01
30  */
31 #undef HAVE_HDF5
32 #ifdef TWODIM
33 #error test_structure cannot be compiled in 2D
34 #endif
35 
36 // Tell the compiler to ignore specific kind of warnings:
37 #pragma GCC diagnostic ignored "-Wunused-variable"
38 #pragma GCC diagnostic ignored "-Wunused-parameter"
39 
40 #include <Epetra_ConfigDefs.h>
41 #ifdef EPETRA_MPI
42 #include <mpi.h>
43 #include <Epetra_MpiComm.h>
44 #else
45 #include <Epetra_SerialComm.h>
46 #endif
47 
48 //Tell the compiler to restore the warning previously silented
49 #pragma GCC diagnostic warning "-Wunused-variable"
50 #pragma GCC diagnostic warning "-Wunused-parameter"
51 
52 #include <lifev/core/LifeV.hpp>
53 
54 #include <lifev/core/array/MapEpetra.hpp>
55 
56 #include <lifev/core/mesh/MeshData.hpp>
57 #include <lifev/core/mesh/MeshPartitioner.hpp>
58 
59 #include <lifev/structure/solver/StructuralConstitutiveLawData.hpp>
60 #include <lifev/structure/solver/StructuralOperator.hpp>
61 
62 #include <lifev/structure/solver/WallTensionEstimator.hpp>
63 #include <lifev/structure/solver/WallTensionEstimatorData.hpp>
64 
65 #include <lifev/core/filter/ExporterEnsight.hpp>
66 #ifdef HAVE_HDF5
67 #include <lifev/core/filter/ExporterHDF5.hpp>
68 #endif
69 #include <lifev/core/filter/ExporterEmpty.hpp>
70 
71 #include <iostream>
72 
73 
74 using namespace LifeV;
75 
76 int returnValue = EXIT_FAILURE;
77 
79 {
80  std::string stringList = list;
81  std::set<UInt> setList;
82  if ( list == "" )
83  {
84  return setList;
85  }
86  size_t commaPos = 0;
87  while ( commaPos != std::string::npos )
88  {
89  commaPos = stringList.find ( "," );
90  setList.insert ( atoi ( stringList.substr ( 0, commaPos ).c_str() ) );
91  stringList = stringList.substr ( commaPos + 1 );
92  }
93  setList.insert ( atoi ( stringList.c_str() ) );
94  return setList;
95 }
96 
97 
98 class Structure
99 {
100 public:
101 
103 
104  // Filters
105  typedef LifeV::Exporter<mesh_Type > filter_Type;
107 
108  typedef LifeV::ExporterEmpty<mesh_Type > emptyFilter_Type;
110  typedef LifeV::ExporterEnsight<mesh_Type > ensightFilter_Type;
112 
115 
116 
117 #ifdef HAVE_HDF5
120 #endif
121 
122 
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 CheckResultDisplacement (const Real tensNorm);
141  void CheckResultEigenvalues (const Real tensNorm);
142  void CheckResultTensions (const Real tensNorm,const Real testETA);
143  void checkLinearElastic (const Real tensNorm,const Real testETA);
144  void checkVenantKirchhoff (const Real tensNorm,const Real testETA);
145  void checkVenantKirchhoffPenalized (const Real tensNorm,const Real testETA);
146  void checkNeoHookean (const Real tensNorm,const Real testETA);
147  void check2ndOrderExponential (const Real tensNorm,const Real testETA);
148  void resultCorrect ( void );
149  //@}
150 
151 protected:
152 
153 private:
154 
155  /**
156  * run the 2D driven cylinder simulation
157  */
158  void run2d();
159 
160  /**
161  * run the 3D driven cylinder simulation
162  */
163  void run3d();
164 
165 private:
166  struct Private;
170 };
171 
172 
173 
174 struct Structure::Private
175 {
177  rho (1),
178  poisson (1),
179  young (1),
180  bulk (1),
181  alpha (1),
182  gamma (1)
183  {}
184  typedef std::function<Real ( Real const&, Real const&, Real const&, Real const&, ID const& ) > fct_type;
185  double rho, poisson, young, bulk, alpha, gamma;
186 
187  static Real displacementLinearElastic (const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
188  {
189 
190  switch (i)
191  {
192  case 0:
193  return - 0.018374999999251 * ( x - 0.5 );
194  break;
195  case 1:
196  return 0.074999999996944 / 2.0 * ( y );
197  break;
198  case 2:
199  return - 0.018374999999251 * ( z + 0.5 );
200  break;
201  default:
202  ERROR_MSG ("This entry is not allowed: ud_functions.hpp");
203  return 0.;
204  break;
205  }
206 
207  }
208 
209  static Real displacementVenantKirchhoff (const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
210  {
211  switch (i)
212  {
213  case 0:
214  return - 0.0179039 * ( x - 0.5 );
215  break;
216  case 1:
217  return 0.07115742 / 2.0 * ( y );
218  break;
219  case 2:
220  return - 0.0179039 * ( z + 0.5 );
221  break;
222  default:
223  ERROR_MSG ("This entry is not allowed: ud_functions.hpp");
224  return 0.;
225  break;
226  }
227  }
228 
229  static Real displacementVenantKirchhoffPenalized (const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
230  {
231  switch (i)
232  {
233  case 0:
234  return - 0.01649141 * ( x - 0.5 );
235  break;
236  case 1:
237  return 0.069238236 / 2.0 * ( y );
238  break;
239  case 2:
240  return - 0.01649141 * ( z + 0.5 );
241  break;
242  default:
243  ERROR_MSG ("This entry is not allowed: ud_functions.hpp");
244  return 0.;
245  break;
246  }
247  }
248 
249  static Real displacementNeoHookean (const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
250  {
251  switch (i)
252  {
253  case 0:
254  return - 0.018542821 * ( x - 0.5 );
255  break;
256  case 1:
257  return 0.077904116 / 2.0 * ( y );
258  break;
259  case 2:
260  return - 0.018542821 * ( z + 0.5 );
261  break;
262  default:
263  ERROR_MSG ("This entry is not allowed: ud_functions.hpp");
264  return 0.;
265  break;
266  }
267  }
268 
269  static Real displacementSecondOrderExponential (const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
270  {
271  switch (i)
272  {
273  case 0:
274  return - 0.055120902 * ( x - 0.5 );
275  break;
276  case 1:
277  return 0.240591303 / 2.0 * ( y );
278  break;
279  case 2:
280  return - 0.055120902 * ( z + 0.5 );
281  break;
282  default:
283  ERROR_MSG ("This entry is not allowed: ud_functions.hpp");
284  return 0.;
285  break;
286  }
287  }
288 
290 
292 
293 };
294 
295 
296 
297 Structure::Structure ( int argc,
298  char** argv,
299  std::shared_ptr<Epetra_Comm> structComm) :
300  parameters ( new Private() )
301 {
302  GetPot command_line (argc, argv);
303  std::string data_file_name = command_line.follow ("data", 2, "-f", "--file");
304  GetPot dataFile ( data_file_name );
305  parameters->data_file_name = data_file_name;
306 
307  parameters->comm = structComm;
308  int ntasks = parameters->comm->NumProc();
309 
310  if (!parameters->comm->MyPID() )
311  {
312  std::cout << "My PID = " << parameters->comm->MyPID() << " out of " << ntasks << " running." << std::endl;
313  }
314 }
315 
316 
317 
318 void
319 Structure::run2d()
320 {
321  std::cout << "2D cylinder test case is not available yet\n";
322 }
323 
324 
325 
326 void
327 Structure::run3d()
328 {
329  // General typedefs
330  typedef WallTensionEstimator< mesh_Type >::solutionVect_Type vector_Type;
331  typedef std::shared_ptr<vector_Type> vectorPtr_Type;
332  typedef FESpace< mesh_Type, MapEpetra > solidFESpace_Type;
333  typedef std::shared_ptr<solidFESpace_Type> solidFESpacePtr_Type;
334 
335  typedef ETFESpace< RegionMesh<LinearTetra>, MapEpetra, 3, 3 > solidETFESpace_Type;
336  typedef std::shared_ptr<solidETFESpace_Type> solidETFESpacePtr_Type;
337 
338 
339  //! BChandler use to create the StructuralOperator object
340  std::shared_ptr<BCHandler> BCh ( new BCHandler() );
341 
342 
343  bool verbose = (parameters->comm->MyPID() == 0);
344 
345  //! dataElasticStructure for parameters
346  GetPot dataFile ( parameters->data_file_name.c_str() );
347 
348  std::shared_ptr<StructuralConstitutiveLawData> dataStructure (new StructuralConstitutiveLawData( ) );
349  dataStructure->setup (dataFile);
350 
351  //! Parameters for the analysis
352  std::shared_ptr<WallTensionEstimatorData> tensionData (new WallTensionEstimatorData( ) );
353  tensionData->setup (dataFile);
354 
355  tensionData->showMe();
356  //! Read and partition mesh
357  MeshData meshData;
358  meshData.setup (dataFile, "solid/space_discretization");
359 
360 
361  std::shared_ptr<mesh_Type > fullMeshPtr (new RegionMesh<LinearTetra> ( ( parameters->comm ) ) );
362  std::shared_ptr<mesh_Type > localMeshPtr (new RegionMesh<LinearTetra> ( ( parameters->comm ) ) );
363 
364  readMesh (*fullMeshPtr, meshData);
365 
366  MeshPartitioner< mesh_Type > meshPart ( fullMeshPtr, parameters->comm );
367  localMeshPtr = meshPart.meshPartition();
368 
369  //! Functional spaces - needed for the computations of the gradients
370  std::string dOrder = dataFile ( "solid/space_discretization/order", "P1");
371  solidFESpacePtr_Type dFESpace ( new solidFESpace_Type (localMeshPtr, dOrder, 3, parameters->comm) );
372  solidETFESpacePtr_Type dETFESpace ( new solidETFESpace_Type (meshPart, & (dFESpace->refFE() ), & (dFESpace->fe().geoMap() ), parameters->comm) );
373 
374 
375  // Building a quadrature rule to evaluate tensions
376  QuadratureRule fakeQuadratureRule;
377 
378  Real refElemArea (0); //area of reference element
379  //compute the area of reference element
380  for (UInt iq = 0; iq < dFESpace->qr().nbQuadPt(); iq++)
381  {
382  refElemArea += dFESpace->qr().weight (iq);
383  }
384 
385  Real wQuad (refElemArea / dFESpace->refFE().nbDof() );
386 
387  //Setting the quadrature Points = DOFs of the element and weight = 1
388  std::vector<GeoVector> coords = dFESpace->refFE().refCoor();
389  std::vector<Real> weights (dFESpace->fe().nbFEDof(), wQuad);
390  fakeQuadratureRule.setDimensionShape ( shapeDimension (dFESpace->refFE().shape() ), dFESpace->refFE().shape() );
391  fakeQuadratureRule.setPoints (coords, weights);
392 
393 
394  if (verbose)
395  {
396  std::cout << std::endl;
397  }
398 
399 
400  //! Setting the marker for the volumes
401  UInt marker = dataFile ( "solid/physics/material_flag", 1);
402 
403  //! 1. Constructor of the class to compute the tensions
404  std::shared_ptr<WallTensionEstimator< mesh_Type > > solid ( new WallTensionEstimator< mesh_Type >() );
405 
406  // 1.1 Creating the solid object one
407  StructuralOperator< RegionMesh<LinearTetra> > solidOperator;
408 
409  //! 2. Its setup
410  solid->setup (dataStructure,
411  tensionData,
412  dFESpace,
413  dETFESpace,
414  parameters->comm,
415  marker);
416 
417  //! 2. Setup of the structuralSolver
418  solidOperator.setup (dataStructure,
419  dFESpace,
420  dETFESpace,
421  BCh,
422  parameters->comm);
423 
424  //! 3. Creation of the importers to read the displacement field
425  std::string const filename = tensionData->nameFile();
426  std::string const importerType = tensionData->typeFile();
427 
428  std::string iterationString; //useful to iterate over the strings
429 
430  if (verbose)
431  {
432  std::cout << "The filename is : " << filename << std::endl;
433  std::cout << "The importerType is: " << importerType << std::endl;
434  }
435 
436 #ifdef HAVE_HDF5
437  if (importerType.compare ("hdf5") == 0)
438  {
439  M_importer.reset ( new hdf5Filter_Type (dataFile, filename) );
440  }
441  else
442 #endif
443  {
444  if (importerType.compare ("none") == 0)
445  {
446  M_importer.reset ( new emptyFilter_Type ( dataFile, solid->dFESpace().mesh(), "solid", solid->dFESpace().map().comm().MyPID() ) );
447  }
448  else
449  {
450  M_importer.reset ( new ensightFilter_Type ( dataFile, filename ) );
451  }
452  }
453  M_importer->setMeshProcId (solid->dFESpace().mesh(), solid->dFESpace().map().comm().MyPID() );
454 
455  // The vector where the solution will be stored
456  vectorPtr_Type solidDisp (new vector_Type (solid->dFESpace().map(), M_importer->mapType() ) );
457 
458 
459  //! 6. Post-processing setting
460  std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporter;
461 
462  std::string const exporterType = dataFile ( "exporter/type", "hdf5");
463  std::string const nameExporter = dataFile ( "exporter/name", "tensions");
464 
465 #ifdef HAVE_HDF5
466  if (exporterType.compare ("hdf5") == 0)
467  {
468  M_exporter.reset ( new hdf5Filter_Type ( dataFile, nameExporter ) );
469  }
470  else
471 #endif
472  {
473  if (exporterType.compare ("none") == 0)
474  {
475  M_exporter.reset ( new emptyFilter_Type ( dataFile, meshPart.meshPartition(), nameExporter, parameters->comm->MyPID() ) ) ;
476  }
477 
478  else
479  {
480  M_exporter.reset ( new ensightFilter_Type ( dataFile, meshPart.meshPartition(), nameExporter, parameters->comm->MyPID() ) ) ;
481  }
482  }
483 
484  M_exporter->setMeshProcId (solid->dFESpace().mesh(), solid->dFESpace().map().comm().MyPID() );
485 
486  vectorPtr_Type solidTensions ( new vector_Type (solid->principalStresses(), M_exporter->mapType() ) );
487 
488  vectorPtr_Type sigma_1;
489  vectorPtr_Type sigma_2;
490  vectorPtr_Type sigma_3;
491 
492  // Debug vectors
493  // vectorPtr_Type dX_1;
494  // vectorPtr_Type dX_2;
495  // vectorPtr_Type dX_3;
496 
497  vectorPtr_Type patchAreaVector;
498  vectorPtr_Type vectorEigenvalues;
499 
500 
501  sigma_1.reset( new vector_Type( dFESpace->map() ) );
502  sigma_2.reset( new vector_Type( dFESpace->map() ) );
503  sigma_3.reset( new vector_Type( dFESpace->map() ) );
504 
505  // dX_1.reset( new vector_Type( dFESpace->map() ) );
506  // dX_2.reset( new vector_Type( dFESpace->map() ) );
507  // dX_3.reset( new vector_Type( dFESpace->map() ) );
508 
509  patchAreaVector.reset ( new vector_Type ( dETFESpace->map() ) );
510  vectorEigenvalues.reset( new vector_Type( dFESpace->map() ) );
511 
512  {
513  using namespace ExpressionAssembly;
514 
516  evaluateNode( elements ( dETFESpace->mesh() ),
517  fakeQuadratureRule,
518  dETFESpace,
519  dot( vMeas , phi_i )
520  ) >> patchAreaVector;
521  patchAreaVector->globalAssemble();
522  }
523 
524  // M_exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "sigma1", dFESpace, sigma_1, UInt (0) );
525  // M_exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "sigma2", dFESpace, sigma_2, UInt (0) );
526  // M_exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "sigma3", dFESpace, sigma_3, UInt (0) );
527 
528  // M_exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "dX1", dFESpace, dX_1, UInt (0) );
529  // M_exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "dX2", dFESpace, dX_2, UInt (0) );
530  // M_exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "dX3", dFESpace, dX_3, UInt (0) );
531 
532  M_exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "eigenvalues", dFESpace, vectorEigenvalues, UInt (0) );
533  M_exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "vonMises", dFESpace, solidTensions, UInt (0) );
534  M_exporter->postProcess ( 0.0 );
535 
536 
537  //Post processing for the displacement gradient
538  // std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporterX;
539  // std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporterY;
540  // std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporterZ;
541 
542  // //Setting pointers
543  // exporterX.reset ( new ExporterHDF5<RegionMesh<LinearTetra> > ( dataFile, "gradX" ) );
544  // exporterY.reset ( new ExporterHDF5<RegionMesh<LinearTetra> > ( dataFile, "gradY" ) );
545  // exporterZ.reset ( new ExporterHDF5<RegionMesh<LinearTetra> > ( dataFile, "gradZ" ) );
546 
547  // exporterX->setMeshProcId (solid->dFESpace().mesh(), solid->dFESpace().map().comm().MyPID() );
548  // exporterY->setMeshProcId (solid->dFESpace().mesh(), solid->dFESpace().map().comm().MyPID() );
549  // exporterZ->setMeshProcId (solid->dFESpace().mesh(), solid->dFESpace().map().comm().MyPID() );
550 
551  // //Defining the vectors
552  // vectorPtr_Type gradX ( new vector_Type (solid->gradientX(), M_exporter->mapType() ) );
553  // vectorPtr_Type gradY ( new vector_Type (solid->gradientY(), M_exporter->mapType() ) );
554  // vectorPtr_Type gradZ ( new vector_Type (solid->gradientZ(), M_exporter->mapType() ) );
555 
556  // //Adding variable
557  // exporterX->addVariable ( ExporterData<mesh_Type >::VectorField, "gradX", solid->dFESpacePtr(),
558  // gradX, UInt (0) );
559  // exporterY->addVariable ( ExporterData<mesh_Type >::VectorField, "gradY", solid->dFESpacePtr(),
560  // gradY, UInt (0) );
561  // exporterZ->addVariable ( ExporterData<mesh_Type >::VectorField, "gradZ", solid->dFESpacePtr(),
562  // gradZ, UInt (0) );
563 
564  // exporterX->postProcess ( 0.0 );
565  // exporterY->postProcess ( 0.0 );
566  // exporterZ->postProcess ( 0.0 );
567 
568 
569  //! =================================================================================
570  //! Analysis - Istant or Interval
571  //! =================================================================================
572 
573  MPI_Barrier (MPI_COMM_WORLD);
574 
575  //! 5. For each interval, the analysis is performed
576  LifeV::Real dt = dataFile ( "solid/time_discretization/timestep", 0.0);
577  std::string const nameField = dataFile ( "solid/analysis/nameField", "NO_DEFAULT_VALUE");
578 
579  if ( !tensionData->analysisType().compare ("istant") )
580  {
581  //Get the iteration number
582  iterationString = tensionData->iterStart (0);
583  LifeV::Real startTime = tensionData->initialTime (0);
584 
585  // In the case of Exponential law we are checking the three ways
586  if( !dataStructure->solidTypeIsotropic().compare("exponential") )
587  {
588  /*!Definition of the ExporterData, used to load the solution inside the previously defined vectors*/
589  LifeV::ExporterData<mesh_Type> solutionDispl (LifeV::ExporterData<mesh_Type>::VectorField, nameField + "." + iterationString, dFESpace, solidDisp, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime );
590 
591  //Read the variable
592  M_importer->readVariable (solutionDispl);
593  M_importer->closeFile();
594  }
595  else if ( !dataStructure->solidTypeIsotropic().compare("linearVenantKirchhoff") ) // LE
596  {
597  dFESpace->interpolate ( static_cast<solidFESpace_Type::function_Type> ( Private::displacementLinearElastic ),
598  *solidDisp, 0.0 );
599  }
600  else if ( !dataStructure->solidTypeIsotropic().compare("nonLinearVenantKirchhoff") ) // SVK
601  {
602  dFESpace->interpolate ( static_cast<solidFESpace_Type::function_Type> ( Private::displacementVenantKirchhoff ),
603  *solidDisp, 0.0 );
604  }
605  else if ( !dataStructure->solidTypeIsotropic().compare("nonLinearVenantKirchhoffPenalized") ) // SVKP
606  {
607  dFESpace->interpolate ( static_cast<solidFESpace_Type::function_Type> ( Private::displacementVenantKirchhoffPenalized ),
608  *solidDisp, 0.0 );
609  }
610  else if ( !dataStructure->solidTypeIsotropic().compare("neoHookean") ) // NH
611  {
612  dFESpace->interpolate ( static_cast<solidFESpace_Type::function_Type> ( Private::displacementNeoHookean ),
613  *solidDisp, 0.0 );
614  }
615  else
616  {
617  dFESpace->interpolate ( static_cast<solidFESpace_Type::function_Type> ( Private::displacementSecondOrderExponential ),
618  *solidDisp, 0.0 );
619  }
620 
621  solidOperator.computeCauchyStressTensor( solidDisp, fakeQuadratureRule, sigma_1, sigma_2, sigma_3 );
622  // Concluding reconstruction
623  *sigma_1 = *sigma_1 / *patchAreaVector;
624  *sigma_2 = *sigma_2 / *patchAreaVector;
625  *sigma_3 = *sigma_3 / *patchAreaVector;
626 
627  // Computing eigenvalues
628  solidOperator.computePrincipalTensions( sigma_1, sigma_2, sigma_3, vectorEigenvalues );
629 
630  // //Create and exporter to check importing
631  // std::string expVerFile = "verificationDisplExporter";
632  // LifeV::ExporterHDF5<RegionMesh<LinearTetra> > exporter ( dataFile, meshPart.meshPartition(), expVerFile, parameters->comm->MyPID() );
633  // vectorPtr_Type vectVer ( new vector_Type (solid->displacement(), exporter.mapType() ) );
634 
635  // exporter.addVariable ( ExporterData<mesh_Type >::VectorField, "displVer", solid->dFESpacePtr(),
636  // vectVer, UInt (0) );
637 
638  // exporter.postProcess (0.0);
639  // *vectVer = *solidDisp;
640  // exporter.postProcess (startTime);
641 
642  //Set the current solution as the displacement vector to use
643  solid->setDisplacement (*solidDisp);
644 
645  std::cout << "The norm of the set displacement, at time " << startTime << ", is: " << solid->displacement().norm2() << std::endl;
646 
647  //Perform the analysis
648  solid->analyzeTensions();
649 
650  // //Extracting the gradient
651  // *gradX = solid->gradientX();
652  // *gradY = solid->gradientY();
653  // *gradZ = solid->gradientZ();
654 
655  // exporterX->postProcess ( startTime );
656  // exporterY->postProcess ( startTime );
657  // exporterZ->postProcess ( startTime );
658 
659  //Extracting the tensions
660  std::cout << std::endl;
661  std::cout << "Norm of the tension vector: " << solid->principalStresses().norm2() << std::endl;
662  std::cout << "Norm of the vector eigenvalues: " << vectorEigenvalues->norm2() << std::endl;
663 
664  // *dX_1 = solid->gradientX();
665  // *dX_2 = solid->gradientY();
666  // *dX_3 = solid->gradientZ();
667 
668 
669  M_exporter->postProcess ( startTime );
670 
671  if (verbose )
672  {
673  std::cout << "Analysis Completed!" << std::endl;
674  }
675 
676  returnValue = EXIT_FAILURE;
677 
678  if( !dataStructure->solidTypeIsotropic().compare("exponential") )
679  {
680  ///////// CHECKING THE RESULTS OF THE TEST AT EVERY TIMESTEP
681  if ( !tensionData->recoveryVariable().compare ("displacement") )
682  {
683  CheckResultDisplacement ( solid->principalStresses().norm2() );
684  }
685  else if ( !tensionData->recoveryVariable().compare ("eigenvalues") )
686  {
687  CheckResultEigenvalues ( solid->principalStresses().norm2() );
688  }
689  else
690  {
691  CheckResultTensions ( solid->principalStresses().norm2(), vectorEigenvalues->norm2() );
692  }
693  }
694 
695  else if ( !dataStructure->solidTypeIsotropic().compare("linearVenantKirchhoff") ) // LE
696  {
697  checkLinearElastic( solid->principalStresses().norm2(), vectorEigenvalues->norm2() );
698  }
699  else if ( !dataStructure->solidTypeIsotropic().compare("nonLinearVenantKirchhoff") ) // SVK
700  {
701  checkVenantKirchhoff( solid->principalStresses().norm2(), vectorEigenvalues->norm2() );
702  }
703  else if ( !dataStructure->solidTypeIsotropic().compare("nonLinearVenantKirchhoffPenalized") ) // SVKP
704  {
705  checkVenantKirchhoffPenalized( solid->principalStresses().norm2(), vectorEigenvalues->norm2() );
706  }
707  else if ( !dataStructure->solidTypeIsotropic().compare("neoHookean") ) // NH
708  {
709  checkNeoHookean( solid->principalStresses().norm2(), vectorEigenvalues->norm2() );
710  }
711  else
712  {
713  check2ndOrderExponential( solid->principalStresses().norm2(), vectorEigenvalues->norm2() );
714  }
715  ///////// END OF CHECK
716 
717  //Closing files
718  M_exporter->closeFile();
719  // exporterX->closeFile();
720  // exporterY->closeFile();
721  // exporterZ->closeFile();
722  // exporter.closeFile();
723 
724 
725  }
726  else
727  {
728  std::cout << "Work in progress! " << std::endl;
729  }
730 
731  if (verbose )
732  {
733  std::cout << "finished" << std::endl;
734  }
735 
736  MPI_Barrier (MPI_COMM_WORLD);
737  //!---------------------------------------------.-----------------------------------------------------
738 }
739 
740 void Structure::CheckResultDisplacement (const Real tensNorm)
741 {
742  if ( ( (std::fabs (tensNorm - 4.67086e6) / 4.67086e6) <= 1e-5 ) )
743  {
744  this->resultCorrect( );
745  }
746 }
747 
748 void Structure::CheckResultEigenvalues (const Real tensNorm)
749 {
750  if ( ( (std::fabs (tensNorm - 4.67086e6) / 4.67086e6) <= 1e-5 ) )
751  {
752  this->resultCorrect( );
753  }
754 }
755 
756 void Structure::CheckResultTensions (const Real tensNorm, const Real testETA)
757 {
758  if ( ( ( std::fabs (tensNorm - 4.67086e6) / 4.67086e6) <= 1e-5 ) &&
759  ( std::fabs ( testETA - 4.67086e6) / 4.67086e6) <= 1e-5 )
760  {
761  this->resultCorrect( );
762  }
763 }
764 
765 void Structure::checkLinearElastic (const Real tensNorm, const Real testETA)
766 {
767  if ( ( ( std::fabs (tensNorm - 4.5e+6) / 4.5e+6) <= 1e-5 ) && ( ( std::fabs (testETA - 4.5e+6) / 4.5e+6) <= 1e-5 ) )
768  {
769  this->resultCorrect( );
770  }
771 }
772 
773 void Structure::checkVenantKirchhoff (const Real tensNorm, const Real testETA)
774 {
775  if ( ( ( std::fabs (tensNorm - 4.66588e+6) / 4.66588e+6) <= 1e-5 ) &&
776  ( ( std::fabs (testETA - 4.66588e+6) / 4.66588e+6) <= 1e-5 ) )
777  {
778  this->resultCorrect( );
779  }
780 }
781 
782 void Structure::checkVenantKirchhoffPenalized (const Real tensNorm, const Real testETA)
783 {
784  if ( ( ( std::fabs (tensNorm - 4.65222e+6) / 4.65222e+6) <= 1e-5 ) &&
785  ( ( std::fabs (testETA - 4.65222e+6) / 4.65222e+6) <= 1e-5 ) )
786  {
787  this->resultCorrect( );
788  }
789 }
790 
791 void Structure::checkNeoHookean (const Real tensNorm, const Real testETA)
792 {
793  if ( ( ( std::fabs (tensNorm - 4.67165e+6) / 4.67165e+6) <= 1e-5 ) &&
794  ( ( std::fabs (testETA - 4.67165e+6) / 4.67165e+6) <= 1e-5 ) )
795  {
796  this->resultCorrect( );
797  }
798 }
799 
800 void Structure::check2ndOrderExponential (const Real tensNorm, const Real testETA)
801 {
802  if ( ( ( std::fabs (testETA - 1.17608e+6) / 1.17608e+6) <= 1e-5 ) &&
803  ( ( std::fabs (tensNorm - 1.17608e+6) / 1.17608e+6) <= 1e-5 ) )
804  {
805  this->resultCorrect( );
806  }
807 }
808 
809 void Structure::resultCorrect ( void )
810 {
811  std::cout << "Correct Result after the Analysis" << std::endl;
812  returnValue = EXIT_SUCCESS;
813 }
814 
815 
816 int
817 main ( int argc, char** argv )
818 {
819 
820 #ifdef HAVE_MPI
821  MPI_Init (&argc, &argv);
822  std::shared_ptr<Epetra_MpiComm> Comm (new Epetra_MpiComm ( MPI_COMM_WORLD ) );
823  if ( Comm->MyPID() == 0 )
824  {
825  std::cout << "% using MPI" << std::endl;
826  }
827 #else
828  std::shared_ptr<Epetra_SerialComm> Comm ( new Epetra_SerialComm() );
829  std::cout << "% using serial Version" << std::endl;
830 #endif
831 
832  Structure structure ( argc, argv, Comm );
833  structure.run();
834 
835 #ifdef HAVE_MPI
836  MPI_Finalize();
837 #endif
838  return returnValue ;
839 }
void checkVenantKirchhoffPenalized(const Real tensNorm, const Real testETA)
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)
void resultCorrect(void)
class ExpressionEmult Class for representing the transpose operation of an expression ...
void checkNeoHookean(const Real tensNorm, const Real testETA)
std::shared_ptr< emptyFilter_Type > emptyFilterPtr_Type
FESpace - Short description here please!
Definition: FESpace.hpp:78
void checkVenantKirchhoff(const Real tensNorm, const Real testETA)
int main(int argc, char **argv)
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
Definition: GetPot.hpp:507
void CheckResultDisplacement(const Real tensNorm)
static Real displacementLinearElastic(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
std::function< Real(Real const &, Real const &, Real const &, Real const &, ID const &) > fct_type
LifeV::ExporterEnsight< mesh_Type > ensightFilter_Type
LifeV::Exporter< mesh_Type > filter_Type
void check2ndOrderExponential(const Real tensNorm, const Real testETA)
void CheckResultEigenvalues(const Real tensNorm)
std::shared_ptr< hdf5Filter_Type > hdf5FilterPtr_Type
static Real displacementSecondOrderExponential(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
#define ERROR_MSG(A)
Definition: LifeAssert.hpp:69
LifeV::ExporterEmpty< mesh_Type > emptyFilter_Type
Epetra_Import const & importer()
Getter for the Epetra_Import.
Definition: MapEpetra.cpp:394
static Real displacementNeoHookean(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
static Real displacementVenantKirchhoff(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
void run3d()
run the 3D driven cylinder simulation
uint32_type ID
IDs.
Definition: LifeV.hpp:194
ETFESpace< RegionMesh< LinearTetra >, MapEpetra, 3, 3 > solidETFESpace_Type
LifeV::RegionMesh< LinearTetra > mesh_Type
std::shared_ptr< std::vector< Int > > M_isOnProc
void run2d()
run the 2D driven cylinder simulation
void checkLinearElastic(const Real tensNorm, const Real testETA)
std::shared_ptr< ensightFilter_Type > ensightFilterPtr_Type
MeshData - class for handling spatial discretization.
Definition: MeshData.hpp:72
ExpressionMeas - Expression for the measure of the element.
double Real
Generic real data.
Definition: LifeV.hpp:175
std::set< UInt > parseList(const std::string &list)
int operator()(const char *VarName, int Default) const
Definition: GetPot.hpp:2021
std::shared_ptr< solidETFESpace_Type > solidETFESpacePtr_Type
std::shared_ptr< LifeV::Exporter< mesh_Type > > filterPtr_Type
static Real displacementVenantKirchhoffPenalized(const Real &, const Real &x, const Real &y, const Real &z, const ID &i)
QuadratureRule - The basis class for storing and accessing quadrature rules.
void CheckResultTensions(const Real tensNorm, const Real testETA)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191