LifeV
lifev/structure/testsuite/evaluateNodalETA/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/VectorEpetra.hpp>
55 #include <lifev/core/array/MapEpetra.hpp>
56 
57 #include <lifev/core/mesh/MeshData.hpp>
58 #include <lifev/core/mesh/MeshPartitioner.hpp>
59 
60 #include <lifev/structure/fem/ExpressionDefinitions.hpp>
61 #include <lifev/structure/solver/StructuralConstitutiveLawData.hpp>
62 
63 // Evaluation operations
64 #include <lifev/core/array/MatrixSmall.hpp>
65 #include <lifev/eta/expression/Evaluate.hpp>
66 
67 #include <lifev/core/filter/ExporterEnsight.hpp>
68 #ifdef HAVE_HDF5
69 #include <lifev/core/filter/ExporterHDF5.hpp>
70 #endif
71 #include <lifev/core/filter/ExporterEmpty.hpp>
72 
73 #include <iostream>
74 #include "ud_functions.hpp"
75 
76 
77 using namespace LifeV;
78 
79 int returnValue = EXIT_FAILURE;
80 
82 {
83  std::string stringList = list;
84  std::set<UInt> setList;
85  if ( list == "" )
86  {
87  return setList;
88  }
89  size_t commaPos = 0;
90  while ( commaPos != std::string::npos )
91  {
92  commaPos = stringList.find ( "," );
93  setList.insert ( atoi ( stringList.substr ( 0, commaPos ).c_str() ) );
94  stringList = stringList.substr ( commaPos + 1 );
95  }
96  setList.insert ( atoi ( stringList.c_str() ) );
97  return setList;
98 }
99 
100 
101 class Structure
102 {
103 public:
104 
106 
107  // Filters
108  typedef LifeV::Exporter<mesh_Type > filter_Type;
110 
115 
116 #ifdef HAVE_HDF5
119 #endif
120 
121 
122 
123  /** @name Constructors, destructor
124  */
125  //@{
126  Structure ( int argc,
127  char** argv,
128  std::shared_ptr<Epetra_Comm> structComm );
129 
131  {}
132  //@}
133 
134  //@{
135  void run()
136  {
137  run3d();
138  }
139  //@}
140 
141 protected:
142 
143 private:
144 
145  /**
146  * run the 2D driven cylinder simulation
147  */
148  void run2d();
149 
150  /**
151  * run the 3D driven cylinder simulation
152  */
153  void run3d();
154 
155  void checkResults( const Real a, const Real c,
156  const Real e, const Real f,
157  const Real g, const Real h, const Real i,
158  const Real l, const Real m, const Real n,
159  const Real o);
160 
161 
162 private:
163  struct Private;
164  std::shared_ptr<Private> parameters;
165 };
166 
167 
168 
169 struct Structure::Private
170 {
172  rho (1),
173  poisson (1),
174  young (1),
175  bulk (1),
176  alpha (1),
177  gamma (1)
178  {}
179  typedef std::function<Real ( Real const&, Real const&, Real const&, Real const&, ID const& ) > fct_type;
180  double rho, poisson, young, bulk, alpha, gamma;
181 
182  std::string data_file_name;
183 
184  std::shared_ptr<Epetra_Comm> comm;
185 
186 };
187 
188 
189 
190 Structure::Structure ( int argc,
191  char** argv,
192  std::shared_ptr<Epetra_Comm> structComm) :
193  parameters ( new Private() )
194 {
195  GetPot command_line (argc, argv);
196  std::string data_file_name = command_line.follow ("data", 2, "-f", "--file");
197  GetPot dataFile ( data_file_name );
198  parameters->data_file_name = data_file_name;
199 
200  parameters->comm = structComm;
201  int ntasks = parameters->comm->NumProc();
202 
203  if (!parameters->comm->MyPID() )
204  {
205  std::cout << "My PID = " << parameters->comm->MyPID() << " out of " << ntasks << " running." << std::endl;
206  }
207 }
208 
209 
210 
211 void
212 Structure::run2d()
213 {
214  std::cout << "2D cylinder test case is not available yet\n";
215 }
216 
217 
218 
219 void
220 Structure::run3d()
221 {
222 
223  // General typedefs
224  typedef VectorEpetra vector_Type;
225  typedef std::shared_ptr<vector_Type> vectorPtr_Type;
226  typedef FESpace< mesh_Type, MapEpetra > solidFESpace_Type;
227  typedef std::shared_ptr<solidFESpace_Type> solidFESpacePtr_Type;
228 
229  typedef ETFESpace< RegionMesh<LinearTetra>, MapEpetra, 3, 3 > solidETFESpace_Type;
230  typedef std::shared_ptr<solidETFESpace_Type> solidETFESpacePtr_Type;
231 
232  typedef ETFESpace< RegionMesh<LinearTetra>, MapEpetra, 3, 1 > scalarETFESpace_Type;
233  typedef std::shared_ptr<scalarETFESpace_Type> scalarETFESpacePtr_Type;
234 
235  // typedefs for fibers
236  typedef std::function<Real ( Real const&, Real const&, Real const&, Real const&, ID const& ) > fiberFunction_Type;
237  typedef std::shared_ptr<fiberFunction_Type> fiberFunctionPtr_Type;
238 
239  typedef std::vector<fiberFunctionPtr_Type> vectorFiberFunction_Type;
240  typedef std::shared_ptr<vectorFiberFunction_Type> vectorFiberFunctionPtr_Type;
241 
242  typedef std::vector<vectorPtr_Type> vectorInterpolatedFibers_Type;
243 
244 
245 
246  bool verbose = (parameters->comm->MyPID() == 0);
247 
248  //! dataElasticStructure for parameters
249  GetPot dataFile ( parameters->data_file_name.c_str() );
250  std::shared_ptr<StructuralConstitutiveLawData> dataStructure (new StructuralConstitutiveLawData( ) );
251  dataStructure->setup (dataFile);
252 
253  //! Read and partition mesh
254  MeshData meshData;
255  meshData.setup (dataFile, "solid/space_discretization");
256 
257  std::shared_ptr<mesh_Type > fullMeshPtr (new RegionMesh<LinearTetra> ( ( parameters->comm ) ) );
258  std::shared_ptr<mesh_Type > localMeshPtr (new RegionMesh<LinearTetra> ( ( parameters->comm ) ) );
259  readMesh (*fullMeshPtr, meshData);
260 
261  MeshPartitioner< mesh_Type > meshPart ( fullMeshPtr, parameters->comm );
262  localMeshPtr = meshPart.meshPartition();
263 
264  //! Functional spaces - needed for the computations of the gradients
265  std::string dOrder = dataFile ( "solid/space_discretization/order", "P1");
266  solidFESpacePtr_Type dFESpace ( new solidFESpace_Type (localMeshPtr, dOrder, 3, parameters->comm) );
267  solidETFESpacePtr_Type dETFESpace ( new solidETFESpace_Type (meshPart, & (dFESpace->refFE() ), & (dFESpace->fe().geoMap() ), parameters->comm) );
268 
269  //! Scalar ETFEspace to evaluate scalar quantities
270  solidFESpacePtr_Type dScalarFESpace ( new solidFESpace_Type (localMeshPtr, dOrder, 1, parameters->comm) );
271  scalarETFESpacePtr_Type dScalarETFESpace ( new scalarETFESpace_Type (meshPart, & (dFESpace->refFE() ), & (dFESpace->fe().geoMap() ), parameters->comm) );
272 
273 
274  if (verbose)
275  {
276  std::cout << std::endl;
277  }
278 
279  // The vector where the solution will be stored
280  vectorPtr_Type solidDisp (new vector_Type (dFESpace->map(), LifeV::Unique ) );
281  *solidDisp *= 0.0;
282 
283 
284  // Set up of the fiber field
285 
286  // Setting the fibers
287  vectorFiberFunctionPtr_Type pointerToVectorOfFamilies( new vectorFiberFunction_Type( ) );
288  (*pointerToVectorOfFamilies).resize( dataStructure->numberFibersFamilies( ) );
289 
290  if( verbose )
291  std::cout << "Size of the number of families: " << (*pointerToVectorOfFamilies).size() << std::endl;
292 
293  fibersDirectionList setOfFiberFunctions;
294  setOfFiberFunctions.setupFiberDefinitions( dataStructure->numberFibersFamilies( ) );
295 
296  // Setting the vector of fibers functions
297  for( UInt k(1); k <= pointerToVectorOfFamilies->size( ); k++ )
298  {
299  // Setting up the name of the function to define the family
300  std::string family="Family";
301  // adding the number of the family
302  std::string familyNumber;
303  std::ostringstream number;
304  number << ( k );
305  familyNumber = number.str();
306 
307  // Name of the function to create
308  std::string creationString = family + familyNumber;
309  (*pointerToVectorOfFamilies)[ k-1 ].reset( new fiberFunction_Type() );
310  (*pointerToVectorOfFamilies)[ k-1 ] = setOfFiberFunctions.fiberDefinition( creationString );
311  }
312 
313 
314  vectorInterpolatedFibers_Type vectorInterpolated(0);
315 
316  // Interpolating fiber fields
317  vectorInterpolated.resize( (*pointerToVectorOfFamilies).size() );
318 
319  for( UInt k(0); k < (*pointerToVectorOfFamilies).size(); k++ )
320  {
321  vectorInterpolated[ k ].reset( new vector_Type( dFESpace->map() ) );
322  dFESpace->interpolate ( *( ( *(pointerToVectorOfFamilies) )[ k ] ) ,
323  * ( ( vectorInterpolated )[ k ] ),
324  0.0 );
325  }
326 
327 
328 
329  //! 6. Post-processing setting
330  std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporter;
331 
332  std::string const exporterType = dataFile ( "exporter/type", "hdf5");
333  std::string const nameExporter = dataFile ( "exporter/name", "jacobian");
334 
335 #ifdef HAVE_HDF5
336  if (exporterType.compare ("hdf5") == 0)
337  {
338  exporter.reset ( new hdf5Filter_Type ( dataFile, nameExporter ) );
339  }
340  else
341 #endif
342  {
343  if (exporterType.compare ("none") == 0)
344  {
345  exporter.reset ( new emptyFilter_Type ( dataFile, meshPart.meshPartition(), nameExporter, parameters->comm->MyPID() ) ) ;
346  }
347 
348  else
349  {
350  exporter.reset ( new ensightFilter_Type ( dataFile, meshPart.meshPartition(), nameExporter, parameters->comm->MyPID() ) ) ;
351  }
352  }
353 
354  exporter->setMeshProcId (dFESpace->mesh(), dFESpace->map().comm().MyPID() );
355 
356  // Scalar vector to have scalar quantities
357  vectorPtr_Type patchAreaVector ( new vector_Type ( dETFESpace->map(), LifeV::Unique ) );
358  vectorPtr_Type patchAreaVectorScalar ( new vector_Type ( dScalarETFESpace->map(), Unique ) );
359  vectorPtr_Type JacobianZero( new vector_Type( dScalarETFESpace->map(), Unique ) );
360  vectorPtr_Type JacobianZeroA( new vector_Type( dScalarETFESpace->map(), Unique ) );
361  vectorPtr_Type JacobianA( new vector_Type( dScalarETFESpace->map(), Unique ) );
362 
363  // vectorPtr_Type jacobianVector ( new vector_Type (solid.displacement(), LifeV::Unique ) );
364  // vectorPtr_Type jacobianReference ( new vector_Type (solid.displacement(), LifeV::Unique ) );
365 
366 
367  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField, "J_0", dScalarFESpace, JacobianA, UInt (0) );
368  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField, "J_0(ta)", dScalarFESpace, JacobianZeroA, UInt (0) );
369  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField, "Ja", dScalarFESpace, JacobianA, UInt (0) );
370 
371  vectorInterpolatedFibers_Type stretchesVector(0);
372  stretchesVector.resize( (*pointerToVectorOfFamilies).size() );
373 
374  vectorInterpolatedFibers_Type atanStretchesVector(0);
375  atanStretchesVector.resize( (*pointerToVectorOfFamilies).size() );
376 
377  vectorInterpolatedFibers_Type scalarExpressionMultimechanism(0);
378  scalarExpressionMultimechanism.resize( (*pointerToVectorOfFamilies).size() );
379 
380  // Deformation Gradient Fa
381  vectorInterpolatedFibers_Type Fa_col1(0);
382  Fa_col1.resize( (*pointerToVectorOfFamilies).size() );
383 
384  vectorInterpolatedFibers_Type Fa_col2(0);
385  Fa_col2.resize( (*pointerToVectorOfFamilies).size() );
386 
387  vectorInterpolatedFibers_Type Fa_col3(0);
388  Fa_col3.resize( (*pointerToVectorOfFamilies).size() );
389 
390  // Outer product Tensor
391  vectorInterpolatedFibers_Type Mith_col1(0);
392  Mith_col1.resize( (*pointerToVectorOfFamilies).size() );
393 
394  vectorInterpolatedFibers_Type Mith_col2(0);
395  Mith_col2.resize( (*pointerToVectorOfFamilies).size() );
396 
397  vectorInterpolatedFibers_Type Mith_col3(0);
398  Mith_col3.resize( (*pointerToVectorOfFamilies).size() );
399 
400  // FzeroAminusT
401  vectorInterpolatedFibers_Type FzeroAminusT_col1(0);
402  FzeroAminusT_col1.resize( (*pointerToVectorOfFamilies).size() );
403 
404  vectorInterpolatedFibers_Type FzeroAminusT_col2(0);
405  FzeroAminusT_col2.resize( (*pointerToVectorOfFamilies).size() );
406 
407  vectorInterpolatedFibers_Type FzeroAminusT_col3(0);
408  FzeroAminusT_col3.resize( (*pointerToVectorOfFamilies).size() );
409 
410  // Piola Kirchhoff
411  vectorInterpolatedFibers_Type P_col1(0);
412  P_col1.resize( (*pointerToVectorOfFamilies).size() );
413 
414  vectorInterpolatedFibers_Type P_col2(0);
415  P_col2.resize( (*pointerToVectorOfFamilies).size() );
416 
417  vectorInterpolatedFibers_Type P_col3(0);
418  P_col3.resize( (*pointerToVectorOfFamilies).size() );
419 
420 
421  // Adding the fibers vectors
422  // Setting the vector of fibers functions
423  for( UInt k(1); k <= pointerToVectorOfFamilies->size( ); k++ )
424  {
425  stretchesVector[ k - 1 ].reset( new vector_Type( dScalarFESpace->map() ) );
426  atanStretchesVector[ k - 1 ].reset( new vector_Type( dScalarFESpace->map() ) );
427  scalarExpressionMultimechanism[ k - 1 ].reset( new vector_Type( dScalarFESpace->map() ) );
428 
429  Fa_col1[ k - 1 ].reset( new vector_Type( dFESpace->map() ) );
430  Fa_col2[ k - 1 ].reset( new vector_Type( dFESpace->map() ) );
431  Fa_col3[ k - 1 ].reset( new vector_Type( dFESpace->map() ) );
432 
433  Mith_col1[ k - 1 ].reset( new vector_Type( dFESpace->map() ) );
434  Mith_col2[ k - 1 ].reset( new vector_Type( dFESpace->map() ) );
435  Mith_col3[ k - 1 ].reset( new vector_Type( dFESpace->map() ) );
436 
437  FzeroAminusT_col1[ k - 1 ].reset( new vector_Type( dFESpace->map() ) );
438  FzeroAminusT_col2[ k - 1 ].reset( new vector_Type( dFESpace->map() ) );
439  FzeroAminusT_col3[ k - 1 ].reset( new vector_Type( dFESpace->map() ) );
440 
441  P_col1[ k - 1 ].reset( new vector_Type( dFESpace->map() ) );
442  P_col2[ k - 1 ].reset( new vector_Type( dFESpace->map() ) );
443  P_col3[ k - 1 ].reset( new vector_Type( dFESpace->map() ) );
444 
445 
446  // Setting up the name of the function to define the family
447  std::string stretchfamily="stretchFamily-";
448  std::string familyAtan="atanStretchFamily-";
449  std::string familyScalar="scalarQuantityFamily-";
450 
451  std::string Fa1="Fa1-";
452  std::string Fa2="Fa2-";
453  std::string Fa3="Fa3-";
454 
455  std::string Mith1="Mith1-";
456  std::string Mith2="Mith2-";
457  std::string Mith3="Mith3-";
458 
459  std::string FzeroAminusT1="FzeroAminusT1-";
460  std::string FzeroAminusT2="FzeroAminusT2-";
461  std::string FzeroAminusT3="FzeroAminusT3-";
462 
463  std::string P1="P1-";
464  std::string P2="P2-";
465  std::string P3="P3-";
466 
467 
468  // adding the number of the family
469  std::string familyNumber;
470  std::ostringstream number;
471  number << ( k );
472  familyNumber = number.str();
473 
474  // Name of the function to create
475  std::string creationString = stretchfamily + familyNumber;
476  std::string creationStringAtan = familyAtan + familyNumber;
477  std::string creationStringScalar = familyScalar + familyNumber;
478 
479  std::string creationStringFa1 = Fa1 + familyNumber;
480  std::string creationStringFa2 = Fa2 + familyNumber;
481  std::string creationStringFa3 = Fa3 + familyNumber;
482 
483  std::string creationStringFzeroAminusT1 = FzeroAminusT1 + familyNumber;
484  std::string creationStringFzeroAminusT2 = FzeroAminusT2 + familyNumber;
485  std::string creationStringFzeroAminusT3 = FzeroAminusT3 + familyNumber;
486 
487  std::string creationStringMith1 = Mith1 + familyNumber;
488  std::string creationStringMith2 = Mith2 + familyNumber;
489  std::string creationStringMith3 = Mith3 + familyNumber;
490 
491  std::string creationStringP1 = P1 + familyNumber;
492  std::string creationStringP2 = P2 + familyNumber;
493  std::string creationStringP3 = P3 + familyNumber;
494 
495  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField, creationString, dScalarFESpace, stretchesVector[ k-1 ], UInt (0) );
496  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField, creationStringAtan, dScalarFESpace, atanStretchesVector[ k-1 ], UInt (0) );
497  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField, creationStringScalar, dScalarFESpace, scalarExpressionMultimechanism[ k-1 ], UInt (0) );
498 
499  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, creationStringFa1, dFESpace, Fa_col1[ k-1 ], UInt (0) );
500  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, creationStringFa2, dFESpace, Fa_col2[ k-1 ], UInt (0) );
501  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, creationStringFa3, dFESpace, Fa_col3[ k-1 ], UInt (0) );
502 
503  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, creationStringFzeroAminusT1, dFESpace, FzeroAminusT_col1[ k-1 ], UInt (0) );
504  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, creationStringFzeroAminusT2, dFESpace, FzeroAminusT_col2[ k-1 ], UInt (0) );
505  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, creationStringFzeroAminusT3, dFESpace, FzeroAminusT_col3[ k-1 ], UInt (0) );
506 
507  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, creationStringMith1, dFESpace, Mith_col1[ k-1 ], UInt (0) );
508  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, creationStringMith2, dFESpace, Mith_col2[ k-1 ], UInt (0) );
509  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, creationStringMith3, dFESpace, Mith_col3[ k-1 ], UInt (0) );
510 
511  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, creationStringP1, dFESpace, P_col1[ k-1 ], UInt (0) );
512  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, creationStringP2, dFESpace, P_col2[ k-1 ], UInt (0) );
513  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, creationStringP3, dFESpace, P_col3[ k-1 ], UInt (0) );
514 
515  }
516 
517 
518  exporter->postProcess ( 0.0 );
519 
520  MPI_Barrier (MPI_COMM_WORLD);
521 
522  QuadratureRule fakeQuadratureRule;
523 
524  Real refElemArea (0); //area of reference element
525  //compute the area of reference element
526  for (UInt iq = 0; iq < dFESpace->qr().nbQuadPt(); iq++)
527  {
528  refElemArea += dFESpace->qr().weight (iq);
529  }
530 
531  Real wQuad (refElemArea / dFESpace->refFE().nbDof() );
532 
533  //Setting the quadrature Points = DOFs of the element and weight = 1
534  std::vector<GeoVector> coords = dFESpace->refFE().refCoor();
535  std::vector<Real> weights (dFESpace->fe().nbFEDof(), wQuad);
536  fakeQuadratureRule.setDimensionShape ( shapeDimension (dFESpace->refFE().shape() ), dFESpace->refFE().shape() );
537  fakeQuadratureRule.setPoints (coords, weights);
538 
539  //fakeQuadratureRule.showMe();
540 
541  // //Compute the gradient along X of the displacement field
542  // *grDisplX = dFESpace->gradientRecovery (*solidDisp, 0);
543 
544  // //Compute the gradient along Y of the displacement field
545  // *grDisplY = dFESpace->gradientRecovery (*solidDisp, 1);
546 
547  // //Compute the gradient along Z of the displacement field
548  // *grDisplZ = dFESpace->gradientRecovery (*solidDisp, 2);
549 
550  using namespace ExpressionAssembly;
551 
552  // Trying to compute the Jacobian using ET
553  MatrixSmall<3,3> identity;
554  identity (0, 0) = 1.0;
555  identity (0, 1) = 0.0;
556  identity (0, 2) = 0.0;
557  identity (1, 0) = 0.0;
558  identity (1, 1) = 1.0;
559  identity (1, 2) = 0.0;
560  identity (2, 0) = 0.0;
561  identity (2, 1) = 0.0;
562  identity (2, 2) = 1.0;
563 
564 
565 
566  // Definition of F
568  ExpressionDefinitions::deformationGradient ( dETFESpace, *solidDisp, 0, identity );
569 
570  // Definition of J
571  ExpressionDefinitions::determinantTensorF_Type J = ExpressionDefinitions::determinantF( F );
572 
573  // Definition of F_0(ta)
575  ExpressionDefinitions::deformationGradient ( dETFESpace, *solidDisp, 0, identity );
576 
577  // Definition of J
578  ExpressionDefinitions::determinantTensorF_Type JzeroA = ExpressionDefinitions::determinantF( FzeroA );
579 
580  evaluateNode( elements ( dScalarETFESpace->mesh() ),
581  fakeQuadratureRule,
582  dScalarETFESpace,
583  meas_K * phi_i
584  ) >> patchAreaVectorScalar;
585  patchAreaVectorScalar->globalAssemble();
586 
587  // Definition of J_a
588  vectorPtr_Type jacobianActivation( new vector_Type( dScalarETFESpace->map() ) );
589  evaluateNode( elements ( dScalarETFESpace->mesh() ),
590  fakeQuadratureRule,
591  dScalarETFESpace,
592  meas_K * JzeroA * phi_i
593  ) >> jacobianActivation;
594  jacobianActivation->globalAssemble();
595  *( jacobianActivation ) = *( jacobianActivation ) / *patchAreaVectorScalar;
596 
598  ExpressionDefinitions::interpolateScalarValue( dScalarETFESpace, *( jacobianActivation ) );
599 
601  ExpressionMultimechanism::activateDeterminantF( J, ithJzeroA );
602 
603  // Definition of J_a^(-2.0/3.0)
605  ExpressionMultimechanism::activeIsochoricDeterminant( Ja );
606 
607  // Definition of C = F^T F
609  ExpressionDefinitions::tensorC( transpose(F), F );
610 
611  LifeChrono chrono;
612  chrono.start();
613 
614  evaluateNode( elements ( dScalarETFESpace->mesh() ),
615  fakeQuadratureRule,
616  dScalarETFESpace,
617  meas_K * J * phi_i
618  ) >> JacobianZero;
619  JacobianZero->globalAssemble();
620 
621  *JacobianZero = *JacobianZero / *patchAreaVectorScalar;
622 
623 
624  evaluateNode( elements ( dScalarETFESpace->mesh() ),
625  fakeQuadratureRule,
626  dScalarETFESpace,
627  meas_K * JzeroA * phi_i
628  ) >> JacobianZeroA;
629  JacobianZeroA->globalAssemble();
630 
631  *JacobianZeroA = *JacobianZeroA / *patchAreaVectorScalar;
632 
633 
634  evaluateNode( elements ( dScalarETFESpace->mesh() ),
635  fakeQuadratureRule,
636  dScalarETFESpace,
637  meas_K * JactiveEl * phi_i
638  ) >> JacobianA;
639  JacobianA->globalAssemble();
640 
641  *JacobianA = *JacobianA / *patchAreaVectorScalar;
642 
643  //Extracting the tensions
644 
645  // The patch area in vectorial form
647  evaluateNode( elements ( dETFESpace->mesh() ),
648  fakeQuadratureRule,
649  dETFESpace,
650  dot( vMeas , phi_i )
651  ) >> patchAreaVector;
652  patchAreaVector->globalAssemble();
653 
654  for( UInt i(0); i < pointerToVectorOfFamilies->size( ); i++ )
655  {
656 
657  // Fibers definitions
658  ExpressionDefinitions::interpolatedValue_Type fiberIth =
659  ExpressionDefinitions::interpolateFiber( dETFESpace, *(vectorInterpolated[ i ] ) );
660 
661  // FzeroA ( for zero displacement and activation at 1 it's equal to F )
662  ExpressionDefinitions::deformationGradient_Type ithFzeroA =
663  ExpressionDefinitions::deformationGradient ( dETFESpace, *solidDisp, 0, identity );
664 
665  // Definiton of FzeroA^{-T}
666  ExpressionDefinitions::minusTransposedTensor_Type FzeroAminusT =
667  ExpressionDefinitions::minusT( ithFzeroA );
668 
669  // Definition of FzeroA^{-1}
670  ExpressionDefinitions::inverseTensor_Type FzeroAminus1 =
671  ExpressionDefinitions::inv( ithFzeroA );
672 
673  // Definition of Ca = F_0^{-T}(ta) * C_0 * F_0^{-1}(ta)
674  ExpressionMultimechanism::rightCauchyGreenMultiMechanism_Type Ca =
675  ExpressionMultimechanism::activationRightCauchyGreen( FzeroAminusT, C, FzeroAminus1 );
676 
677  // Definition of the direction of the fiber at the activation moment = F_0(ta) * f_0
678  ExpressionMultimechanism::activatedFiber_Type activeIthFiber =
679  ExpressionMultimechanism::activateFiberDirection( ithFzeroA, fiberIth );
680 
681  ExpressionMultimechanism::normalizedVector_Type normalizedFiber =
682  ExpressionMultimechanism::unitVector( activeIthFiber );
683  // Definition of the tensor M = ithFiber \otimes ithFiber
684  // At the moment, it's automatic that the method constructs the expression M = ithFiber \otimes ithFiber
685  // For a more general case, the file ExpressionDefinitions.hpp should be changed
686  ExpressionMultimechanism::activeNormalizedOuterProduct_Type Mith =
687  ExpressionMultimechanism::activeNormalizedOuterProduct( normalizedFiber );
688 
689  // Definition of the fourth invariant : I_4^i = C:Mith
690  ExpressionMultimechanism::activeStretch_Type IVith =
691  ExpressionMultimechanism::activeFiberStretch( Ca, Mith );
692 
693  // Definition of the fouth isochoric invariant : J^(-2.0/3.0) * I_4^i
694  ExpressionMultimechanism::activeNoInterpolationStretch_Type IVithBar =
695  ExpressionMultimechanism::activeNoInterpolationFourthInvariant( JactiveEl, IVith );
696 
697 
698  evaluateNode( elements ( dScalarETFESpace->mesh() ),
699  fakeQuadratureRule,
700  dScalarETFESpace,
701  meas_K * IVithBar * phi_i
702  ) >> stretchesVector[ i ];
703  stretchesVector[ i ]->globalAssemble();
704 
705  *( stretchesVector[ i ] ) = *( stretchesVector[ i ] ) / *patchAreaVectorScalar;
706 
707  evaluateNode( elements ( dScalarETFESpace->mesh() ),
708  fakeQuadratureRule,
709  dScalarETFESpace,
710  meas_K * atan( IVithBar - value( dataStructure->ithCharacteristicStretch( i ) ),
711  dataStructure->smoothness() , ( 1.0 / 3.14159265359 ), (1.0/2.0) ) * phi_i
712  ) >> atanStretchesVector[ i ];
713  atanStretchesVector[ i ]->globalAssemble();
714 
715  *( atanStretchesVector[ i ] ) = *( atanStretchesVector[ i ] ) / *patchAreaVectorScalar;
716 
717  Real stretch = dataStructure->ithCharacteristicStretch( i );
718  Real pi = 3.14159265359;
719 
720  evaluateNode( elements ( dScalarETFESpace->mesh() ),
721  fakeQuadratureRule,
722  dScalarETFESpace,
723  meas_K *
724  JzeroA * atan( IVithBar - value( stretch ) , dataStructure->smoothness(), ( 1 / pi ), ( 1.0/2.0 ) ) * JactiveEl *
725  (value( 2.0 ) * value( dataStructure->ithStiffnessFibers( i ) ) * JactiveEl * ( IVithBar - value( stretch ) ) *
726  exp( value( dataStructure->ithNonlinearityFibers( i ) ) * ( IVithBar- value( stretch ) ) * ( IVithBar- value( stretch ) ) ) ) * phi_i
727  ) >> scalarExpressionMultimechanism[ i ];
728  scalarExpressionMultimechanism[ i ]->globalAssemble();
729 
730  *( scalarExpressionMultimechanism[ i ] ) = *( scalarExpressionMultimechanism[ i ] ) / *patchAreaVectorScalar;
731 
732 
733  // exporting the components of the Piola-Kirchhoff tensor
734  // Definition of the expression definition the portion of the Piola-Kirchhoff
735 
736  ExpressionMultimechanism::deformationActivatedTensor_Type Fa =
737  ExpressionMultimechanism::createDeformationActivationTensor( F , FzeroAminus1);
738 
739  typedef ExpressionProduct<ExpressionMultimechanism::deformationActivatedTensor_Type,
740  ExpressionMultimechanism::activeNormalizedOuterProduct_Type> productFaMith_Type;
741 
742  typedef ExpressionProduct< productFaMith_Type,
743  ExpressionDefinitions::minusTransposedTensor_Type> firstPartPiolaMultimech_Type;
744 
745  productFaMith_Type FaMith( Fa, Mith );
746  firstPartPiolaMultimech_Type firstPartPiola( FaMith, FzeroAminusT );
747 
748  //Extract columns
749  ExpressionVectorFromNonConstantMatrix< ExpressionMultimechanism::deformationActivatedTensor_Type,3 ,3 > Fa_i1( Fa, 0 );
750  ExpressionVectorFromNonConstantMatrix< ExpressionMultimechanism::deformationActivatedTensor_Type,3 ,3 > Fa_i2( Fa, 1 );
751  ExpressionVectorFromNonConstantMatrix< ExpressionMultimechanism::deformationActivatedTensor_Type,3 ,3 > Fa_i3( Fa, 2 );
752 
753  ExpressionVectorFromNonConstantMatrix< ExpressionMultimechanism::activeNormalizedOuterProduct_Type,3 ,3 > Mith_i1( Mith, 0 );
754  ExpressionVectorFromNonConstantMatrix< ExpressionMultimechanism::activeNormalizedOuterProduct_Type,3 ,3 > Mith_i2( Mith, 1 );
755  ExpressionVectorFromNonConstantMatrix< ExpressionMultimechanism::activeNormalizedOuterProduct_Type,3 ,3 > Mith_i3( Mith, 2 );
756 
757  ExpressionVectorFromNonConstantMatrix< ExpressionDefinitions::minusTransposedTensor_Type,3 ,3 > FzeroAminusT_i1( FzeroAminusT, 0 );
758  ExpressionVectorFromNonConstantMatrix< ExpressionDefinitions::minusTransposedTensor_Type,3 ,3 > FzeroAminusT_i2( FzeroAminusT, 1 );
759  ExpressionVectorFromNonConstantMatrix< ExpressionDefinitions::minusTransposedTensor_Type,3 ,3 > FzeroAminusT_i3( FzeroAminusT, 2 );
760 
761  ExpressionVectorFromNonConstantMatrix< firstPartPiolaMultimech_Type,3 ,3 > P_i1( firstPartPiola, 0 );
762  ExpressionVectorFromNonConstantMatrix< firstPartPiolaMultimech_Type,3 ,3 > P_i2( firstPartPiola, 1 );
763  ExpressionVectorFromNonConstantMatrix< firstPartPiolaMultimech_Type,3 ,3 > P_i3( firstPartPiola, 2 );
764 
765  evaluateNode( elements ( dETFESpace->mesh() ),
766  fakeQuadratureRule,
767  dETFESpace,
768  meas_K * dot ( Fa_i1, phi_i)
769  ) >> Fa_col1[ i ];
770  Fa_col1[ i ]->globalAssemble();
771 
772  *(Fa_col1[i]) = *(Fa_col1[i]) / *patchAreaVector;
773 
774  evaluateNode( elements ( dETFESpace->mesh() ),
775  fakeQuadratureRule,
776  dETFESpace,
777  meas_K * dot ( Fa_i2, phi_i)
778  ) >> Fa_col2[ i ];
779  Fa_col2[ i ]->globalAssemble();
780  *(Fa_col2[i]) = *(Fa_col2[i]) / *patchAreaVector;
781 
782  evaluateNode( elements ( dETFESpace->mesh() ),
783  fakeQuadratureRule,
784  dETFESpace,
785  meas_K * dot ( Fa_i3, phi_i)
786  ) >> Fa_col3[ i ];
787  Fa_col3[ i ]->globalAssemble();
788  *(Fa_col3[i]) = *(Fa_col3[i]) / *patchAreaVector;
789 
790 
791  evaluateNode( elements ( dETFESpace->mesh() ),
792  fakeQuadratureRule,
793  dETFESpace,
794  meas_K * dot ( Mith_i1, phi_i)
795  ) >> Mith_col1[ i ];
796  Mith_col1[ i ]->globalAssemble();
797  *(Mith_col1[i]) = *(Mith_col1[i]) / *patchAreaVector;
798 
799  evaluateNode( elements ( dETFESpace->mesh() ),
800  fakeQuadratureRule,
801  dETFESpace,
802  meas_K * dot ( Mith_i2, phi_i)
803  ) >> Mith_col2[ i ];
804  Mith_col2[ i ]->globalAssemble();
805  *(Mith_col2[i]) = *(Mith_col2[i]) / *patchAreaVector;
806 
807  evaluateNode( elements ( dETFESpace->mesh() ),
808  fakeQuadratureRule,
809  dETFESpace,
810  meas_K * dot ( Mith_i3, phi_i)
811  ) >> Mith_col3[ i ];
812  Mith_col3[ i ]->globalAssemble();
813  *(Mith_col3[i]) = *(Mith_col3[i]) / *patchAreaVector;
814 
815 
816  evaluateNode( elements ( dETFESpace->mesh() ),
817  fakeQuadratureRule,
818  dETFESpace,
819  meas_K * dot ( FzeroAminusT_i1, phi_i)
820  ) >> FzeroAminusT_col1[ i ];
821  FzeroAminusT_col1[ i ]->globalAssemble();
822  *(FzeroAminusT_col1[i]) = *(FzeroAminusT_col1[i]) / *patchAreaVector;
823 
824  evaluateNode( elements ( dETFESpace->mesh() ),
825  fakeQuadratureRule,
826  dETFESpace,
827  meas_K * dot ( FzeroAminusT_i2, phi_i)
828  ) >> FzeroAminusT_col2[ i ];
829  FzeroAminusT_col2[ i ]->globalAssemble();
830  *(FzeroAminusT_col2[i]) = *(FzeroAminusT_col2[i]) / *patchAreaVector;
831 
832  evaluateNode( elements ( dETFESpace->mesh() ),
833  fakeQuadratureRule,
834  dETFESpace,
835  meas_K * dot ( FzeroAminusT_i3, phi_i)
836  ) >> FzeroAminusT_col3[ i ];
837  FzeroAminusT_col3[ i ]->globalAssemble();
838  *(FzeroAminusT_col3[i]) = *(FzeroAminusT_col3[i]) / *patchAreaVector;
839 
840 
841  evaluateNode( elements ( dETFESpace->mesh() ),
842  fakeQuadratureRule,
843  dETFESpace,
844  meas_K * dot ( P_i1, phi_i)
845  ) >> P_col1[ i ];
846  P_col1[ i ]->globalAssemble();
847  *(P_col1[i]) = *(P_col1[i]) / *patchAreaVector;
848 
849  evaluateNode( elements ( dETFESpace->mesh() ),
850  fakeQuadratureRule,
851  dETFESpace,
852  meas_K * dot ( P_i2, phi_i)
853  ) >> P_col2[ i ];
854  P_col2[ i ]->globalAssemble();
855  *(P_col2[i]) = *(P_col2[i]) / *patchAreaVector;
856 
857  evaluateNode( elements ( dETFESpace->mesh() ),
858  fakeQuadratureRule,
859  dETFESpace,
860  meas_K * dot ( P_i3, phi_i)
861  ) >> P_col3[ i ];
862  P_col3[ i ]->globalAssemble();
863  *(P_col3[i]) = *(P_col3[i]) / *patchAreaVector;
864 
865  }
866 
867  exporter->postProcess ( 1.0 );
868 
869  if (verbose )
870  {
871  std::cout << "Analysis Completed!" << std::endl;
872  }
873 
874  //Closing files
875  exporter->closeFile();
876 
877  if (verbose )
878  {
879  std::cout << "finished" << std::endl;
880  }
881 
882  MPI_Barrier (MPI_COMM_WORLD);
883 
884  checkResults( patchAreaVectorScalar->normInf(),
885  patchAreaVector->normInf(),
886  JacobianZero->normInf(), JacobianZeroA->normInf(), JacobianA->normInf(),
887  atanStretchesVector[0]->normInf(),atanStretchesVector[1]->normInf(),
888  scalarExpressionMultimechanism[0]->norm2(), scalarExpressionMultimechanism[1]->norm2(),
889  Mith_col1[0]->normInf(), Mith_col1[1]->normInf());
890 
891  //!---------------------------------------------.-----------------------------------------------------
892 }
893 
894 void
895 Structure::checkResults(const Real a, const Real c,
896  const Real e, const Real f,
897  const Real g, const Real h, const Real i,
898  const Real l, const Real m, const Real n,
899  const Real o)
900 {
901 
902  if( std::fabs( a - 0.072916) < 1e-6 &&
903  std::fabs( c - 0.072916) < 1e-6 &&
904  std::fabs( e - 1 ) < 1e-6 &&
905  std::fabs( f - 1 ) < 1e-6 &&
906  std::fabs( g - 1 ) < 1e-6 &&
907  std::fabs( h - 3.18309e-05 ) < 1e-9 &&
908  std::fabs( i - 3.18309e-05 ) < 1e-9 &&
909  std::fabs( l - 6968.505143 ) < 1e-6 &&
910  std::fabs( m - 6968.505143 ) < 1e-6 &&
911  std::fabs( n - 0.433012 ) < 1e-6 &&
912  std::fabs( o - 0.433012 ) < 1e-6 )
913  {
914  std::cout << "Correct result! "<< std::endl;
915  returnValue = EXIT_SUCCESS;
916  }
917 
918 }
919 
920 int
921 main ( int argc, char** argv )
922 {
923 
924 #ifdef HAVE_MPI
925  MPI_Init (&argc, &argv);
926  std::shared_ptr<Epetra_MpiComm> Comm (new Epetra_MpiComm ( MPI_COMM_WORLD ) );
927  if ( Comm->MyPID() == 0 )
928  {
929  std::cout << "% using MPI" << std::endl;
930  }
931 #else
932  std::shared_ptr<Epetra_SerialComm> Comm ( new Epetra_SerialComm() );
933  std::cout << "% using serial Version" << std::endl;
934 #endif
935 
936  Structure structure ( argc, argv, Comm );
937  structure.run();
938 
939 #ifdef HAVE_MPI
940  MPI_Finalize();
941 #endif
942  return returnValue ;
943 }
VectorEpetra - The Epetra Vector format Wrapper.
Structure(int argc, char **argv, std::shared_ptr< Epetra_Comm > structComm)
class ExpressionEmult Class for representing the transpose operation of an expression ...
ExporterEnsight data exporter.
std::shared_ptr< emptyFilter_Type > emptyFilterPtr_Type
FESpace - Short description here please!
Definition: FESpace.hpp:78
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
Definition: GetPot.hpp:507
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
std::shared_ptr< hdf5Filter_Type > hdf5FilterPtr_Type
ExpressionIsochoricChangeOfVariable< activatedDeterminantF_Type > activeIsochoricDeterminant_Type
std::set< UInt > parseList(const std::string &list)
LifeV::ExporterEmpty< mesh_Type > emptyFilter_Type
Epetra_Import const & importer()
Getter for the Epetra_Import.
Definition: MapEpetra.cpp:394
ExpressionInterpolateValue< MeshType, MapEpetra, 3, 1 > interpolatedScalarValue_Type
void run3d()
run the 3D driven cylinder simulation
LifeV::RegionMesh< LinearTetra > mesh_Type
void checkResults(const Real a, const Real c, const Real e, const Real f, const Real g, const Real h, const Real i, const Real l, const Real m, const Real n, const Real o)
ExpressionProduct< ExpressionTranspose< ExpressionAddition< ExpressionInterpolateGradient< MeshType, MapEpetra, 3, 3 >, ExpressionMatrix< 3, 3 > > >, ExpressionAddition< ExpressionInterpolateGradient< MeshType, MapEpetra, 3, 3 >, ExpressionMatrix< 3, 3 > > > rightCauchyGreenTensor_Type
std::shared_ptr< std::vector< Int > > M_isOnProc
void run2d()
run the 2D driven cylinder simulation
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
ExpressionAddition< ExpressionInterpolateGradient< MeshType, MapEpetra, 3, 3 >, ExpressionMatrix< 3, 3 > > deformationGradient_Type
std::shared_ptr< LifeV::Exporter< mesh_Type > > filterPtr_Type
ExpressionDeterminant< ExpressionAddition< ExpressionInterpolateGradient< MeshType, MapEpetra, 3, 3 >, ExpressionMatrix< 3, 3 > > > determinantTensorF_Type
QuadratureRule - The basis class for storing and accessing quadrature rules.
ExpressionDivision< ExpressionDefinitions::determinantTensorF_Type, ExpressionDefinitions::interpolatedScalarValue_Type > activatedDeterminantF_Type
int main(int argc, char **argv)