LifeV
lifev/structure/examples/example_evaluatingScalarVectorialTensorialQuantitiesUsingETA/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 #include <Epetra_ConfigDefs.h>
37 #ifdef EPETRA_MPI
38 #include <mpi.h>
39 #include <Epetra_MpiComm.h>
40 #else
41 #include <Epetra_SerialComm.h>
42 #endif
43 
44 #include <lifev/core/LifeV.hpp>
45 
46 #include <lifev/core/array/MapEpetra.hpp>
47 
48 #include <lifev/core/mesh/MeshData.hpp>
49 #include <lifev/core/mesh/MeshPartitioner.hpp>
50 #include <lifev/core/filter/PartitionIO.hpp>
51 
52 #include <lifev/structure/solver/StructuralConstitutiveLawData.hpp>
53 #include <lifev/structure/solver/StructuralConstitutiveLaw.hpp>
54 #include <lifev/structure/solver/StructuralOperator.hpp>
55 #include <lifev/structure/fem/ExpressionDefinitions.hpp>
56 
57 #include <lifev/structure/solver/isotropic/ExponentialMaterialNonLinear.hpp>
58 // #include <lifev/structure/solver/anisotropic/AnisotropicMultimechanismMaterialNonLinear.hpp>
59 
60 // Evaluation operations
61 #include <lifev/core/array/MatrixSmall.hpp>
62 #include <lifev/eta/expression/Evaluate.hpp>
63 
64 #include <lifev/core/filter/ExporterEnsight.hpp>
65 #ifdef HAVE_HDF5
66 #include <lifev/core/filter/ExporterHDF5.hpp>
67 #endif
68 #include <lifev/core/filter/ExporterEmpty.hpp>
69 
70 #include <iostream>
71 #include "ud_functions.hpp"
72 
73 using namespace LifeV;
74 
75 int returnValue = EXIT_SUCCESS;
76 
78 {
79  std::string stringList = list;
80  std::set<UInt> setList;
81  if ( list == "" )
82  {
83  return setList;
84  }
85  size_t commaPos = 0;
86  while ( commaPos != std::string::npos )
87  {
88  commaPos = stringList.find ( "," );
89  setList.insert ( atoi ( stringList.substr ( 0, commaPos ).c_str() ) );
90  stringList = stringList.substr ( commaPos + 1 );
91  }
92  setList.insert ( atoi ( stringList.c_str() ) );
93  return setList;
94 }
95 
96 class Structure
97 {
98 public:
99 
101 
102  // Filters
103  typedef LifeV::Exporter<mesh_Type > filter_Type;
105 
106  typedef LifeV::ExporterEmpty<mesh_Type > emptyFilter_Type;
108  typedef LifeV::ExporterEnsight<mesh_Type > ensightFilter_Type;
110 
111 #ifdef HAVE_HDF5
114 #endif
115 
116 
117 
118  /** @name Constructors, destructor
119  */
120  //@{
121  Structure ( int argc,
122  char** argv,
123  std::shared_ptr<Epetra_Comm> structComm );
124 
126  {}
127  //@}
128 
129  //@{
130  void run()
131  {
132  run3d();
133  }
134  //@}
135 
136 protected:
137 
138 private:
139 
140  /**
141  * run the 2D driven cylinder simulation
142  */
143  void run2d();
144 
145  /**
146  * run the 3D driven cylinder simulation
147  */
148  void run3d();
149 
150 private:
151  struct Private;
154 };
155 
156 
157 
158 struct Structure::Private
159 {
161  rho (1),
162  poisson (1),
163  young (1),
164  bulk (1),
165  alpha (1),
166  gamma (1)
167  {}
168  typedef std::function<Real ( Real const&, Real const&, Real const&, Real const&, ID const& ) > fct_type;
169  double rho, poisson, young, bulk, alpha, gamma;
170 
172 
174 
175 };
176 
177 
178 
179 Structure::Structure ( int argc,
180  char** argv,
181  std::shared_ptr<Epetra_Comm> structComm) :
182  parameters ( new Private() )
183 {
184  GetPot command_line (argc, argv);
185  std::string data_file_name = command_line.follow ("data", 2, "-f", "--file");
186  GetPot dataFile ( data_file_name );
187  parameters->data_file_name = data_file_name;
188 
189  parameters->comm = structComm;
190  int ntasks = parameters->comm->NumProc();
191 
192  if (!parameters->comm->MyPID() )
193  {
194  std::cout << "My PID = " << parameters->comm->MyPID() << " out of " << ntasks << " running." << std::endl;
195  }
196 }
197 
198 
199 
200 void
201 Structure::run2d()
202 {
203  std::cout << "2D cylinder test case is not available yet\n";
204 }
205 
206 
207 
208 void
209 Structure::run3d()
210 {
211  typedef std::shared_ptr<VectorEpetra> vectorPtr_Type;
212 
213  // typedefs for fibers
214  // std function for fiber direction
215  typedef std::function<Real ( Real const&, Real const&, Real const&, Real const&, ID const& ) > fiberFunction_Type;
216  typedef std::shared_ptr<fiberFunction_Type> fiberFunctionPtr_Type;
217 
218  typedef std::vector<fiberFunctionPtr_Type> vectorFiberFunction_Type;
219  typedef std::shared_ptr<vectorFiberFunction_Type> vectorFiberFunctionPtr_Type;
220 
221  typedef std::vector<vectorPtr_Type> listOfFiberDirections_Type;
222 
223  // General typedefs
224  typedef StructuralOperator<mesh_Type >::vector_Type 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  bool verbose = (parameters->comm->MyPID() == 0);
236 
237  //! dataElasticStructure for parameters
238  GetPot dataFile ( parameters->data_file_name.c_str() );
239  std::shared_ptr<StructuralConstitutiveLawData> dataStructure (new StructuralConstitutiveLawData( ) );
240  dataStructure->setup (dataFile);
241 
242  dataStructure->showMe();
243 
244  //! Read and partition mesh
245  MeshData meshData;
246  meshData.setup (dataFile, "solid/space_discretization");
247 
248  //Loading a partitoned mesh or reading a new one
249  const std::string partitioningMesh = dataFile ( "partitioningOffline/loadMesh", "no");
250 
251  //Creation of pointers
252  std::shared_ptr<MeshPartitioner<mesh_Type> > meshPart;
253  std::shared_ptr<mesh_Type> pointerToMesh;
254 
255  if ( ! (partitioningMesh.compare ("no") ) )
256  {
257  std::shared_ptr<mesh_Type > fullMeshPtr (new mesh_Type ( ( parameters->comm ) ) );
258  //Creating a new mesh from scratch
259  MeshData meshData;
260  meshData.setup (dataFile, "solid/space_discretization");
261  readMesh (*fullMeshPtr, meshData);
262 
263  meshPart.reset ( new MeshPartitioner<mesh_Type> (fullMeshPtr, parameters->comm ) );
264 
265  pointerToMesh = meshPart->meshPartition();
266  }
267  else
268  {
269  //Creating a mesh object from a partitioned mesh
270  const std::string partsFileName (dataFile ("partitioningOffline/hdf5_file_name", "NO_DEFAULT_VALUE.h5") );
271 
272  std::shared_ptr<Epetra_MpiComm> mpiComm =
273  std::dynamic_pointer_cast<Epetra_MpiComm>(parameters->comm);
274  PartitionIO<mesh_Type> partitionIO (partsFileName, mpiComm);
275 
276  partitionIO.read (pointerToMesh);
277 
278  }
279 
280 
281  //! Functional spaces - needed for the computations of the gradients
282  std::string dOrder = dataFile ( "solid/space_discretization/order", "P1");
283  solidFESpacePtr_Type dFESpace ( new solidFESpace_Type (pointerToMesh, dOrder, 3, parameters->comm) );
284  solidETFESpacePtr_Type dETFESpace ( new solidETFESpace_Type (pointerToMesh, & (dFESpace->refFE() ), & (dFESpace->fe().geoMap() ), parameters->comm) );
285 
286  //! Scalar ETFEspace to evaluate scalar quantities
287  solidFESpacePtr_Type dScalarFESpace ( new solidFESpace_Type (pointerToMesh, dOrder, 1, parameters->comm) );
288  scalarETFESpacePtr_Type dScalarETFESpace ( new scalarETFESpace_Type (pointerToMesh, & (dFESpace->refFE() ), & (dFESpace->fe().geoMap() ), parameters->comm) );
289 
290  // Setting the fibers
291  vectorFiberFunctionPtr_Type pointerToVectorOfFamilies( new vectorFiberFunction_Type( ) );
292  (*pointerToVectorOfFamilies).resize( dataStructure->numberFibersFamilies( ) );
293 
294  // Interpolate fibers
295  std::vector<vectorPtr_Type> vectorInterpolated(0);
296  vectorPtr_Type referenceDirectionVector;
297 
298  // Interpolating fiber fields
299  vectorInterpolated.resize( (*pointerToVectorOfFamilies).size() );
300 
301  fibersDirectionList setOfFiberFunctions;
302  setOfFiberFunctions.setupFiberDefinitions( dataStructure->numberFibersFamilies( ) );
303 
304  if( !dataStructure->constitutiveLaw().compare("anisotropic") )
305  {
306 
307  if( verbose )
308  std::cout << "Number of families: " << (*pointerToVectorOfFamilies).size() << std::endl;
309 
310  // Setting the vector of fibers functions
311  for( UInt k(1); k <= pointerToVectorOfFamilies->size( ); k++ )
312  {
313  // Setting up the name of the function to define the family
314  std::string family="Family";
315  // adding the number of the family
316  std::string familyNumber;
317  std::ostringstream number;
318  number << ( k );
319  familyNumber = number.str();
320 
321  // Name of the function to create
322  std::string creationString = family + familyNumber;
323  (*pointerToVectorOfFamilies)[ k-1 ].reset( new fiberFunction_Type() );
324  (*pointerToVectorOfFamilies)[ k-1 ] = setOfFiberFunctions.fiberDefinition( creationString );
325  }
326 
327 
328  for( UInt k(0); k < (*pointerToVectorOfFamilies).size(); k++ )
329  {
330  vectorInterpolated[ k ].reset( new vector_Type( dFESpace->map() ) );
331  dFESpace->interpolate ( *( ( *(pointerToVectorOfFamilies) )[ k ] ) ,
332  * ( ( vectorInterpolated )[ k ] ),
333  0.0 );
334  }
335 
336  referenceDirectionVector.reset( new vector_Type( dFESpace->map() ) );
337  dFESpace->interpolate ( static_cast<solidFESpace_Type::function_Type> ( referenceDirection ),
338  * ( referenceDirectionVector ),
339  0.0 );
340  }
341 
342 
343  //! 3. Creation of the importers to read the displacement field
344  std::string const filename = dataFile ( "importer/filename", "structure");
345  std::string const importerType = dataFile ( "importer/type", "hdf5");
346 
347  // How many solution do we have to read?
348  std::string readType = dataFile ( "importer/analysis", "instant");
349  UInt numberOfSol(0);
350  UInt start(0);
351  UInt end(0);
352 
353  if( !readType.compare("instant") )
354  {
355  numberOfSol = dataFile.vector_variable_size ( "importer/iteration" );
356  ASSERT( numberOfSol, "You did not set any solution to read!! ");
357  }
358  else
359  {
360  start = dataFile ( "importer/iterationStart" , 0 );
361  end = dataFile ( "importer/iterationEnd" , 0 );
362  numberOfSol = end - start;
363  }
364  ASSERT( numberOfSol, "You did not set any solution to read!! ");
365 
366  if (verbose)
367  {
368  std::cout << "The filename is : " << filename << std::endl;
369  std::cout << "The importerType is: " << importerType << std::endl;
370  }
371 
372 #ifdef HAVE_HDF5
373  if (importerType.compare ("hdf5") == 0)
374  {
375  M_importer.reset ( new hdf5Filter_Type (dataFile, filename) );
376  }
377  else
378 #endif
379  {
380  if (importerType.compare ("none") == 0)
381  {
382  M_importer.reset ( new emptyFilter_Type ( dataFile, dFESpace->mesh(), "solid", dFESpace->map().comm().MyPID() ) );
383  }
384  else
385  {
386  M_importer.reset ( new ensightFilter_Type ( dataFile, filename ) );
387  }
388  }
389  M_importer->setMeshProcId (dFESpace->mesh(), dFESpace->map().comm().MyPID() );
390 
391  //! 6. Post-processing setting
392  std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporter;
393 
394  std::string const exporterType = dataFile ( "exporter/type", "hdf5");
395  std::string const nameExporter = dataFile ( "exporter/name", "jacobian");
396 
397 #ifdef HAVE_HDF5
398  if (exporterType.compare ("hdf5") == 0)
399  {
400  exporter.reset ( new hdf5Filter_Type ( dataFile, nameExporter) );
401  }
402  else
403 #endif
404  {
405  if (exporterType.compare ("none") == 0)
406  {
407  exporter.reset ( new emptyFilter_Type ( dataFile, pointerToMesh, nameExporter, parameters->comm->MyPID() ) ) ;
408  }
409 
410  else
411  {
412  exporter.reset ( new ensightFilter_Type ( dataFile, pointerToMesh, nameExporter, parameters->comm->MyPID() ) ) ;
413  }
414  }
415  exporter->setMeshProcId (dFESpace->mesh(), dFESpace->map().comm().MyPID() );
416 
417  // Scalar vector to have scalar quantities
418  vectorPtr_Type patchAreaVector;
419  vectorPtr_Type patchAreaVectorScalar;
420  vectorPtr_Type jacobianF;
421 
422  vectorPtr_Type disp;
423  vectorPtr_Type dispRead;
424 
425  vectorPtr_Type family1;
426  vectorPtr_Type family2;
427  vectorPtr_Type family1Read;
428  vectorPtr_Type family2Read;
429  vectorPtr_Type family1Computed;
430  vectorPtr_Type family2Computed;
431 
432  std::vector< vectorPtr_Type > activationFunction(0);
433  std::vector< vectorPtr_Type > stretch(0);
434  std::vector< vectorPtr_Type > deformedVector(0);
435  std::vector< vectorPtr_Type > characteristicAngle(0);
436  std::vector< vectorPtr_Type > referenceAngle(0);
437 
438  // vectorPtr_Type deformationGradient_1;
439  // vectorPtr_Type deformationGradient_2;
440  // vectorPtr_Type deformationGradient_3;
441 
442  // // To check
443  // vectorPtr_Type reconstructed_1;
444  // vectorPtr_Type reconstructed_2;
445  // vectorPtr_Type reconstructed_3;
446 
447  if( !dataStructure->constitutiveLaw().compare("anisotropic") )
448  {
449  activationFunction.resize( dataStructure->numberFibersFamilies( ) );
450  stretch.resize( dataStructure->numberFibersFamilies( ) );
451  deformedVector.resize( dataStructure->numberFibersFamilies( ) );
452  characteristicAngle.resize( dataStructure->numberFibersFamilies( ) );
453  referenceAngle.resize( dataStructure->numberFibersFamilies( ) );
454 
455  family1.reset( new vector_Type( dFESpace->map() ) );
456  family2.reset( new vector_Type( dFESpace->map() ) );
457  family1Computed.reset( new vector_Type( dFESpace->map() ) );
458  family2Computed.reset( new vector_Type( dFESpace->map() ) );
459 
460  family1Read.reset( new vector_Type( dFESpace->map() ) );
461  family2Read.reset( new vector_Type( dFESpace->map() ) );
462  }
463 
464  patchAreaVector.reset ( new vector_Type ( dETFESpace->map() ) );
465  patchAreaVectorScalar.reset ( new vector_Type ( dScalarETFESpace->map() ) );
466  jacobianF.reset ( new vector_Type ( dScalarETFESpace->map() ) );
467 
468  disp.reset( new vector_Type( dFESpace->map() ) );
469  dispRead.reset( new vector_Type( dFESpace->map() ) );
470 
471  // deformationGradient_1.reset( new vector_Type( dFESpace->map() ) );
472  // deformationGradient_2.reset( new vector_Type( dFESpace->map() ) );
473  // deformationGradient_3.reset( new vector_Type( dFESpace->map() ) );
474 
475  // reconstructed_1.reset( new vector_Type( dFESpace->map() ) );
476  // reconstructed_2.reset( new vector_Type( dFESpace->map() ) );
477  // reconstructed_3.reset( new vector_Type( dFESpace->map() ) );
478 
479  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "displacement",
480  dFESpace, dispRead, UInt (0) );
481 
482  // exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "deformationGradient_1",
483  // dFESpace, deformationGradient_1, UInt (0) );
484 
485  // exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "deformationGradient_2",
486  // dFESpace, deformationGradient_2, UInt (0) );
487 
488  // exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "deformationGradient_3",
489  // dFESpace, deformationGradient_3, UInt (0) );
490 
491  // exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "reconstructed_1",
492  // dFESpace, reconstructed_1, UInt (0) );
493 
494  // exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "reconstructed_2",
495  // dFESpace, reconstructed_2, UInt (0) );
496 
497  // exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "reconstructed_3",
498  // dFESpace, reconstructed_3, UInt (0) );
499 
500  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField, "jacobianF",
501  dScalarFESpace, jacobianF, UInt (0) );
502 
503  if( !dataStructure->constitutiveLaw().compare("anisotropic") )
504  {
505  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "family1",
506  dFESpace, family1Read, UInt (0) );
507 
508  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "family2",
509  dFESpace, family2Read, UInt (0) );
510 
511  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "family1Computed",
512  dFESpace, family1Computed, UInt (0) );
513 
514  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "family2Computed",
515  dFESpace, family2Computed, UInt (0) );
516 
517  for( UInt i(0); i < dataStructure->numberFibersFamilies( ); i++ )
518  {
519  std::string familyNumber;
520  std::ostringstream number;
521  number << ( i + 1 );
522  familyNumber = number.str();
523 
524  activationFunction[ i ].reset( new vector_Type( dScalarFESpace->map() ) );
525  stretch[ i ].reset( new vector_Type( dScalarFESpace->map() ) );
526  deformedVector[ i ].reset( new vector_Type( dFESpace->map() ) );
527  characteristicAngle[ i ].reset( new vector_Type( dScalarFESpace->map() ) );
528  referenceAngle[ i ].reset( new vector_Type( dScalarFESpace->map() ) );
529 
530  std::string stringNameA("activation");
531  std::string stringNameS("stretch");
532  std::string deformedName("deformed");
533  std::string angleName("angle");
534  std::string refAngleName("refAngle");
535 
536  stringNameA += "-"; stringNameA += familyNumber;
537  stringNameS += "-"; stringNameS += familyNumber;
538  deformedName += "-"; deformedName += familyNumber;
539  angleName += "-"; angleName += familyNumber;
540  refAngleName += "-"; refAngleName += familyNumber;
541 
542  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField, stringNameA,
543  dScalarFESpace, activationFunction[ i ], UInt (0) );
544 
545  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField, stringNameS,
546  dScalarFESpace, stretch[ i ], UInt (0) );
547 
548  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, deformedName,
549  dFESpace, deformedVector[ i ], UInt (0) );
550 
551  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField, angleName,
552  dScalarFESpace, characteristicAngle[ i ], UInt (0) );
553 
554  exporter->addVariable ( ExporterData<RegionMesh<LinearTetra> >::ScalarField, refAngleName,
555  dScalarFESpace, referenceAngle[ i ], UInt (0) );
556 
557  }
558 
559  *family1Computed = *(vectorInterpolated[ 0 ] );
560  *family2Computed = *(vectorInterpolated[ 1 ] );
561 
562  }
563 
564  exporter->postProcess ( 0.0 );
565 
566  //! =================================================================================
567  //! Analysis - Istant or Interval
568  //! =================================================================================
569 
570  MPI_Barrier (MPI_COMM_WORLD);
571 
572  QuadratureRule fakeQuadratureRule;
573 
574  Real refElemArea (0); //area of reference element
575  //compute the area of reference element
576  for (UInt iq = 0; iq < dFESpace->qr().nbQuadPt(); iq++)
577  {
578  refElemArea += dFESpace->qr().weight (iq);
579  }
580 
581  Real wQuad (refElemArea / dFESpace->refFE().nbDof() );
582 
583  //Setting the quadrature Points = DOFs of the element and weight = 1
584  std::vector<GeoVector> coords = dFESpace->refFE().refCoor();
585  std::vector<Real> weights (dFESpace->fe().nbFEDof(), wQuad);
586  fakeQuadratureRule.setDimensionShape ( shapeDimension (dFESpace->refFE().shape() ), dFESpace->refFE().shape() );
587  fakeQuadratureRule.setPoints (coords, weights);
588 
589  //fakeQuadratureRule.showMe();
590  using namespace ExpressionAssembly;
591 
592  // Trying to compute the Jacobian using ET
593  MatrixSmall<3,3> identity;
594  identity (0, 0) = 1.0;
595  identity (0, 1) = 0.0;
596  identity (0, 2) = 0.0;
597  identity (1, 0) = 0.0;
598  identity (1, 1) = 1.0;
599  identity (1, 2) = 0.0;
600  identity (2, 0) = 0.0;
601  identity (2, 1) = 0.0;
602  identity (2, 2) = 1.0;
603 
604  // Computing areas
605  evaluateNode( elements ( dScalarETFESpace->mesh() ),
606  fakeQuadratureRule,
607  dScalarETFESpace,
608  meas_K * phi_i
609  ) >> patchAreaVectorScalar;
610  patchAreaVectorScalar->globalAssemble();
611 
613  evaluateNode( elements ( dETFESpace->mesh() ),
614  fakeQuadratureRule,
615  dETFESpace,
616  dot( vMeas , phi_i )
617  ) >> patchAreaVector;
618  patchAreaVector->globalAssemble();
619 
620  std::string const nameField = dataFile ( "importer/nameField", "displacement");
621  UInt i,k;
622 
623  for( i=0,k =0; i < numberOfSol; i++, k++ )
624  {
625 
626  // *reconstructed_1 *=0.0; *reconstructed_2 *=0.0; *reconstructed_3 *=0.0;
627  // *deformationGradient_1 *=0.0; *deformationGradient_2 *=0.0; *deformationGradient_3 *=0.0;
628  *jacobianF *= 0.0;
629 
630  // Reading the solution
631  // resetting the element of the vector
632  *disp *= 0.0;
633  *dispRead *= 0.0;
634 
635  if( !dataStructure->constitutiveLaw().compare("anisotropic") )
636  {
637  *family1 *= 0.0;
638  *family2 *= 0.0;
639 
640  *family1Read *= 0.0;
641  *family2Read *= 0.0;
642  }
643 
644  UInt current(0);
645  if( !readType.compare("interval") )
646  {
647  current = i + start;
648  }
649  else
650  {
651  current = dataFile ( "importer/iteration" , 100000, i );
652  }
653  // Transform current ingot a string
654  std::string iterationString;
655  std::ostringstream number;
656  number.fill ( '0' );
657  number << std::setw (5) << ( current );
658  iterationString = number.str();
659  std::string fam1 = "Family-1";
660  std::string fam2 = "Family-2";
661 
662  std::cout << "Current reading: " << iterationString << std::endl;
663 
664  /*!Definition of the ExporterData, used to load the solution inside the previously defined vectors*/
665  LifeV::ExporterData<mesh_Type> solutionDispl (LifeV::ExporterData<mesh_Type>::VectorField,nameField + "." + iterationString,
666  dFESpace, disp, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime );
667 
668 
669  //Read the variable
670  M_importer->readVariable (solutionDispl);
671  *dispRead = *disp;
672 
673  // Computing references
674  // *reconstructed_1 = dFESpace->gradientRecovery (*disp, 0);
675  // *reconstructed_2 = dFESpace->gradientRecovery (*disp, 1);
676  // *reconstructed_3 = dFESpace->gradientRecovery (*disp, 2);
677 
678  // Defining expressions
680  ExpressionDefinitions::deformationGradient ( dETFESpace, *disp, 0, identity );
681 
682  // Definition of C = F^T F
684  ExpressionDefinitions::tensorC( transpose(F), F );
685 
686  // Definition of J
688  ExpressionDefinitions::determinantF( F );
689 
690  // Definition of J^-(2/3) = det( C ) using the isochoric/volumetric decomposition
692  ExpressionDefinitions::powerExpression( J , (-2.0/3.0) );
693 
694  // ExpressionVectorFromNonConstantMatrix< ExpressionDefinitions::deformationGradient_Type,3 ,3 > Fi1( F, 0 );
695  // ExpressionVectorFromNonConstantMatrix< ExpressionDefinitions::deformationGradient_Type,3 ,3 > Fi2( F, 1 );
696  // ExpressionVectorFromNonConstantMatrix< ExpressionDefinitions::deformationGradient_Type,3 ,3 > Fi3( F, 2 );
697 
698  // // Deformation gradient
699  // evaluateNode( elements ( dETFESpace->mesh() ),
700  // fakeQuadratureRule,
701  // dETFESpace,
702  // meas_K * dot ( Fi1, phi_i)
703  // ) >> deformationGradient_1;
704  // deformationGradient_1->globalAssemble();
705  // *deformationGradient_1 = *deformationGradient_1 / *patchAreaVector;
706 
707  // evaluateNode( elements ( dETFESpace->mesh() ),
708  // fakeQuadratureRule,
709  // dETFESpace,
710  // meas_K * dot ( Fi2, phi_i)
711  // ) >> deformationGradient_2;
712  // deformationGradient_2->globalAssemble();
713  // *deformationGradient_2 = *deformationGradient_2 / *patchAreaVector;
714 
715  // evaluateNode( elements ( dETFESpace->mesh() ),
716  // fakeQuadratureRule,
717  // dETFESpace,
718  // meas_K * dot ( Fi3, phi_i)
719  // ) >> deformationGradient_3;
720  // deformationGradient_3->globalAssemble();
721  // *deformationGradient_3 = *deformationGradient_3 / *patchAreaVector;
722 
723 
724  evaluateNode( elements ( dETFESpace->mesh() ),
725  fakeQuadratureRule,
726  dScalarETFESpace,
727  meas_K * J * phi_i
728  ) >> jacobianF;
729  jacobianF->globalAssemble();
730  *jacobianF = *jacobianF / *patchAreaVectorScalar;
731 
732  if( !dataStructure->constitutiveLaw().compare("anisotropic") )
733  {
734  LifeV::ExporterData<mesh_Type> family1Data (LifeV::ExporterData<mesh_Type>::VectorField,fam1 + "." + iterationString,
735  dFESpace, family1, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime );
736 
737  LifeV::ExporterData<mesh_Type> family2Data (LifeV::ExporterData<mesh_Type>::VectorField,fam2 + "." + iterationString,
738  dFESpace, family2, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime );
739 
740  M_importer->readVariable (family2Data);
741  M_importer->readVariable (family1Data);
742 
743  *family1Read = *family1;
744  *family2Read = *family2;
745 
746  // Evaluating quantities that are related to fibers
747  for( UInt j(0); j < dataStructure->numberFibersFamilies( ); j++ )
748  {
749  // Fibers definitions
750  ExpressionDefinitions::interpolatedValue_Type fiberIth =
751  ExpressionDefinitions::interpolateFiber( dETFESpace, *(vectorInterpolated[ j ] ) );
752 
753  // f /otimes f
754  ExpressionDefinitions::outerProduct_Type Mith = ExpressionDefinitions::fiberTensor( fiberIth );
755 
756  // Definition of the fourth invariant : I_4^i = C:Mith
757  ExpressionDefinitions::stretch_Type IVith = ExpressionDefinitions::fiberStretch( C, Mith );
758 
759  // Definition of the fouth isochoric invariant : J^(-2.0/3.0) * I_4^i
760  ExpressionDefinitions::isochoricStretch_Type IVithBar =
761  ExpressionDefinitions::isochoricFourthInvariant( Jel, IVith );
762 
763  *stretch[ j ] *= 0.0;
764  *activationFunction[ j ] *= 0.0;
765  *deformedVector[ j ] *= 0.0;
766 
767  evaluateNode( elements ( dScalarETFESpace->mesh() ),
768  fakeQuadratureRule,
769  dScalarETFESpace,
770  meas_K * IVithBar * phi_i
771  ) >> stretch[ j ];
772  stretch[ j ]->globalAssemble();
773  *(stretch[ j ]) = *(stretch[ j ]) / *patchAreaVectorScalar;
774 
775  Real stretch = dataStructure->ithCharacteristicStretch( j ) * dataStructure->ithCharacteristicStretch( j );
776  evaluateNode( elements ( dScalarETFESpace->mesh() ),
777  fakeQuadratureRule,
778  dScalarETFESpace,
779  meas_K * atan( IVithBar - value( stretch ) , dataStructure->smoothness() , ( 1 / 3.14159265359 ), ( 1.0/2.0 ) ) * phi_i
780  ) >> activationFunction[ j ];
781  activationFunction[ j ]->globalAssemble();
782  *(activationFunction[ j ]) = *(activationFunction[ j ]) / *patchAreaVectorScalar;
783 
784  evaluateNode( elements ( dETFESpace->mesh() ),
785  fakeQuadratureRule,
786  dETFESpace,
787  meas_K * dot( ( F * value( dETFESpace ,*vectorInterpolated[ j ] ) ) , phi_i )
788  ) >> deformedVector[ j ];
789  deformedVector[ j ]->globalAssemble();
790  *deformedVector[ j ] = *deformedVector[ j ] / *patchAreaVector;
791 
792  evaluateNode( elements ( dScalarETFESpace->mesh() ),
793  fakeQuadratureRule,
794  dScalarETFESpace,
795  meas_K * dot( normalize( value( dETFESpace, *deformedVector[j] ) ) , value( dETFESpace, *referenceDirectionVector ) ) * phi_i
796  ) >> characteristicAngle[ j ];
797  characteristicAngle[ j ]->globalAssemble();
798  *(characteristicAngle[ j ]) = *(characteristicAngle[ j ]) / *patchAreaVectorScalar;
799 
800  evaluateNode( elements ( dScalarETFESpace->mesh() ),
801  fakeQuadratureRule,
802  dScalarETFESpace,
803  meas_K * dot( normalize( value( dETFESpace, *vectorInterpolated[j] ) ) , value( dETFESpace, *referenceDirectionVector ) ) * phi_i
804  ) >> referenceAngle[ j ];
805  referenceAngle[ j ]->globalAssemble();
806  *(referenceAngle[ j ]) = *(referenceAngle[ j ]) / *patchAreaVectorScalar;
807 
808  }
809 
810  }
811  exporter->postProcess( dataStructure->dataTime()->initialTime() + k * dataStructure->dataTime()->timeStep() );
812  }
813 
814 
815  if (verbose )
816  {
817  std::cout << "Analysis Completed!" << std::endl;
818  }
819 
820  //Closing files
821  exporter->closeFile( );
822  M_importer->closeFile( );
823 
824  MPI_Barrier (MPI_COMM_WORLD);
825  //!---------------------------------------------.-----------------------------------------------------
826 }
827 
828 int
829 main ( int argc, char** argv )
830 {
831 
832 #ifdef HAVE_MPI
833  MPI_Init (&argc, &argv);
834  std::shared_ptr<Epetra_MpiComm> Comm (new Epetra_MpiComm ( MPI_COMM_WORLD ) );
835  if ( Comm->MyPID() == 0 )
836  {
837  std::cout << "% using MPI" << std::endl;
838  }
839 #else
840  std::shared_ptr<Epetra_SerialComm> Comm ( new Epetra_SerialComm() );
841  std::cout << "% using serial Version" << std::endl;
842 #endif
843 
844  Structure structure ( argc, argv, Comm );
845  structure.run();
846 
847 #ifdef HAVE_MPI
848  MPI_Finalize();
849 #endif
850  return returnValue ;
851 }
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)
class ExpressionEmult Class for representing the transpose operation of an expression ...
std::shared_ptr< emptyFilter_Type > emptyFilterPtr_Type
FESpace - Short description here please!
Definition: FESpace.hpp:78
int main(int argc, char **argv)
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
LifeV::ExporterEmpty< mesh_Type > emptyFilter_Type
Epetra_Import const & importer()
Getter for the Epetra_Import.
Definition: MapEpetra.cpp:394
void run3d()
run the 3D driven cylinder simulation
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
LifeV::RegionMesh< LinearTetra > mesh_Type
ExpressionProduct< ExpressionTranspose< ExpressionAddition< ExpressionInterpolateGradient< MeshType, MapEpetra, 3, 3 >, ExpressionMatrix< 3, 3 > > >, ExpressionAddition< ExpressionInterpolateGradient< MeshType, MapEpetra, 3, 3 >, ExpressionMatrix< 3, 3 > > > rightCauchyGreenTensor_Type
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::set< UInt > parseList(const std::string &list)
int operator()(const char *VarName, int Default, unsigned Idx) const
Definition: GetPot.hpp:2137
int operator()(const char *VarName, int Default) const
Definition: GetPot.hpp:2021
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.
ExpressionPower< ExpressionDeterminant< ExpressionAddition< ExpressionInterpolateGradient< MeshType, MapEpetra, 3, 3 >, ExpressionMatrix< 3, 3 > > > > powerExpression_Type
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
unsigned vector_variable_size(const char *VarName) const
Definition: GetPot.hpp:2291