LifeV
lifev/structure/examples/example_CookMembrane/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 
30 
31  Attention: At the moment the restart works only if the solution is saved at
32  each time step
33  \date 2005-04-16
34  */
35 #undef HAVE_HDF5
36 #ifdef TWODIM
37 #error test_structure cannot be compiled in 2D
38 #endif
39 
40 // Tell the compiler to ignore specific kind of warnings:
41 #pragma GCC diagnostic ignored "-Wunused-variable"
42 #pragma GCC diagnostic ignored "-Wunused-parameter"
43 
44 #include <Epetra_ConfigDefs.h>
45 #ifdef EPETRA_MPI
46 #include <mpi.h>
47 #include <Epetra_MpiComm.h>
48 #else
49 #include <Epetra_SerialComm.h>
50 #endif
51 
52 //Tell the compiler to restore the warning previously silented
53 #pragma GCC diagnostic warning "-Wunused-variable"
54 #pragma GCC diagnostic warning "-Wunused-parameter"
55 
56 #include <lifev/core/LifeV.hpp>
57 #include <lifev/core/algorithm/PreconditionerIfpack.hpp>
58 #include <lifev/core/algorithm/PreconditionerML.hpp>
59 
60 
61 //Include fils which were in the structure.cpp file
62 #include <lifev/core/array/MapEpetra.hpp>
63 
64 #include <lifev/core/fem/TimeAdvance.hpp>
65 #include <lifev/core/fem/TimeAdvanceNewmark.hpp>
66 #include <lifev/core/fem/TimeAdvanceBDF.hpp>
67 
68 #include <lifev/core/mesh/MeshData.hpp>
69 #include <lifev/core/mesh/MeshPartitioner.hpp>
70 
71 #include <lifev/structure/solver/StructuralConstitutiveLawData.hpp>
72 
73 #include <lifev/structure/solver/StructuralConstitutiveLaw.hpp>
74 #include <lifev/structure/solver/StructuralOperator.hpp>
75 #include <lifev/structure/solver/VenantKirchhoffMaterialLinear.hpp>
76 #include <lifev/structure/solver/VenantKirchhoffMaterialNonLinear.hpp>
77 #include <lifev/structure/solver/NeoHookeanMaterialNonLinear.hpp>
78 #include <lifev/structure/solver/ExponentialMaterialNonLinear.hpp>
79 
80 #include <lifev/core/filter/Exporter.hpp>
81 #include <lifev/core/filter/ExporterEnsight.hpp>
82 #ifdef HAVE_HDF5
83 #include <lifev/core/filter/ExporterHDF5.hpp>
84 #endif
85 #include <lifev/core/filter/ExporterEmpty.hpp>
86 #include <lifev/core/filter/ExporterVTK.hpp>
87 
88 #include <iostream>
89 
90 
91 using namespace LifeV;
92 
93 int returnValue = EXIT_FAILURE;
95 
96 namespace
97 {
98 static bool regIF = (PRECFactory::instance().registerProduct ( "Ifpack", &createIfpack ) );
99 static bool regML = (PRECFactory::instance().registerProduct ( "ML", &createML ) );
100 }
101 
103 {
104  std::string stringList = list;
105  std::set<UInt> setList;
106  if ( list == "" )
107  {
108  return setList;
109  }
110  size_t commaPos = 0;
111  while ( commaPos != std::string::npos )
112  {
113  commaPos = stringList.find ( "," );
114  setList.insert ( atoi ( stringList.substr ( 0, commaPos ).c_str() ) );
115  stringList = stringList.substr ( commaPos + 1 );
116  }
117  setList.insert ( atoi ( stringList.c_str() ) );
118  return setList;
119 }
120 
121 
122 class Structure
123 {
124 public:
125 
130 
131  typedef std::function<Real ( Real const&, Real const&, Real const&, Real const&, ID const& ) > fct_type;
132  //Exporters Typedefs
133  typedef LifeV::Exporter<mesh_Type > filter_Type;
135 
136  typedef LifeV::ExporterEmpty<mesh_Type > emptyExporter_Type;
138 
139  typedef LifeV::ExporterEnsight<mesh_Type > ensightFilter_Type;
141 
142  typedef LifeV::ExporterData<mesh_Type> exporterData_Type;
144 
145  typedef LifeV::ExporterVTK<mesh_Type> exporterVTK_Type;
147 
148 #ifdef HAVE_HDF5
151 #endif
152 
155 
156 
159 
160  /** @name Constructors, destructor
161  */
162  //@{
163  Structure ( int argc,
164  char** argv,
165  std::shared_ptr<Epetra_Comm> structComm );
166 
168  {}
169  //@}
170 
171  //@{
172  void run()
173  {
174  run3d();
175  }
176  //@}
177 
178 protected:
179 
180 private:
181 
182  /**
183  * run the 2D driven cylinder simulation
184  */
185  void run2d();
186 
187  /**
188  * run the 3D driven cylinder simulation
189  */
190  void run3d();
191 
192 private:
193  struct Private;
197 
199 
203 
204 };
205 
206 
207 
208 struct Structure::Private
209 {
211  rho (1), poisson (1), young (1), bulk (1), alpha (1), gamma (1)
212  {}
213  double rho, poisson, young, bulk, alpha, gamma;
214 
216 
218 
219  static Real bcZero (const Real& /*t*/, const Real& /*X*/, const Real& /*Y*/, const Real& /*Z*/, const ID& /*i*/)
220  {
221  return 0.;
222  }
223 
224  static Real bcNonZero (const Real& /*t*/, const Real& /*X*/, const Real& /*Y*/, const Real& /*Z*/, const ID& i)
225  {
226  switch (i)
227  {
228  case 0:
229  return 0.0;
230  break;
231  case 1:
232  return 300000.0;
233  break;
234  case 2:
235  return 0.0;
236  break;
237 
238  }
239  return 0;
240  }
241 
242  static Real bcPressure (const Real& /*t*/, const Real& x, const Real& y, const Real& /*Z*/, const ID& i)
243  {
244  Real radius = 0.5;
245  Real pressure = 5000;
246  //3000/(2*0.5*40*3.1415962);
247  switch (i)
248  {
249  case 0:
250  return pressure * std::fabs ( ( x / radius ) );
251  break;
252  case 1:
253  return pressure * std::fabs ( ( y / radius ) );
254  break;
255  case 2:
256  return 0.0;
257  break;
258 
259  }
260  return 0;
261 
262  }
263 
264  static Real pressureUsingNormal (const Real& /*t*/, const Real& /*X*/, const Real& /*Y*/, const Real& /*Z*/, const ID& /*i*/)
265  {
266 
267  return -5000;
268  // if( t < 15.0 )
269  // return -(300000/(2*3.1415962*0.5*40))*(1/15)*t;
270  // else
271  // return -300000/(2*3.1415962*0.5*40);
272  }
273 
274 
275 };
276 
277 
278 
279 Structure::Structure ( int argc,
280  char** argv,
281  std::shared_ptr<Epetra_Comm> structComm) :
282  parameters ( new Private() ),
283  dFESpace(),
284  dETFESpace(),
286 {
287  GetPot command_line (argc, argv);
288  std::string data_file_name = command_line.follow ("data", 2, "-f", "--file");
289  GetPot dataFile ( data_file_name );
290  parameters->data_file_name = data_file_name;
291 
292  parameters->rho = dataFile ( "solid/physics/density", 1. );
293  parameters->young = dataFile ( "solid/physics/young", 1. );
294  parameters->poisson = dataFile ( "solid/physics/poisson", 1. );
295  parameters->bulk = dataFile ( "solid/physics/bulk", 1. );
296  parameters->alpha = dataFile ( "solid/physics/alpha", 1. );
297  parameters->gamma = dataFile ( "solid/physics/gamma", 1. );
298 
299  std::cout << "density = " << parameters->rho << std::endl
300  << "young = " << parameters->young << std::endl
301  << "poisson = " << parameters->poisson << std::endl
302  << "bulk = " << parameters->bulk << std::endl
303  << "alpha = " << parameters->alpha << std::endl
304  << "gamma = " << parameters->gamma << std::endl;
305 
306  parameters->comm = structComm;
307  int ntasks = parameters->comm->NumProc();
308 
309  if (!parameters->comm->MyPID() )
310  {
311  std::cout << "My PID = " << parameters->comm->MyPID() << " out of " << ntasks << " running." << std::endl;
312  }
313 }
314 
315 
316 
317 void
318 Structure::run2d()
319 {
320  std::cout << "2D cylinder test case is not available yet\n";
321 }
322 
323 
324 
325 void
326 Structure::run3d()
327 {
328 
329  bool verbose = (parameters->comm->MyPID() == 0);
330 
331  //! Number of boundary conditions for the velocity and mesh motion
332  std::shared_ptr<BCHandler> BCh ( new BCHandler() );
333 
334  //! dataElasticStructure
335  GetPot dataFile ( parameters->data_file_name.c_str() );
336 
337  std::shared_ptr<StructuralConstitutiveLawData> dataStructure (new StructuralConstitutiveLawData( ) );
338  dataStructure->setup (dataFile);
339 
340  MeshData meshData;
341  meshData.setup (dataFile, "solid/space_discretization");
342 
343  std::shared_ptr<RegionMesh<LinearTetra> > fullMeshPtr (new RegionMesh<LinearTetra> ( ( parameters->comm ) ) );
344  readMesh (*fullMeshPtr, meshData);
345 
346  //fullMeshPtr->showMe( );
347 
348  MeshPartitioner< RegionMesh<LinearTetra> > meshPart ( fullMeshPtr, parameters->comm );
349 
350  std::string dOrder = dataFile ( "solid/space_discretization/order", "P1");
351 
352  dFESpace.reset ( new solidFESpace_Type (meshPart, dOrder, 3, parameters->comm) );
353  dETFESpace.reset ( new solidETFESpace_Type (meshPart, & (dFESpace->refFE() ), & (dFESpace->fe().geoMap() ), parameters->comm) );
354 
355  // if( dOrder.compare("P2") == 0 )
356  // exporterFESpace.reset( new solidFESpace_Type(meshPart,"P1",3,parameters->comm) );
357 
358  if (verbose)
359  {
360  std::cout << std::endl;
361  }
362 
363  std::string timeAdvanceMethod = dataFile ( "solid/time_discretization/method", "Newmark");
364 
365  timeAdvance_type timeAdvance ( TimeAdvanceFactory::instance().createObject ( timeAdvanceMethod ) );
366 
367  UInt OrderDev = 2;
368 
369  //! initialization of parameters of time Advance method:
370  if (timeAdvanceMethod == "Newmark")
371  {
372  timeAdvance->setup ( dataStructure->dataTimeAdvance()->coefficientsNewmark() , OrderDev);
373  }
374 
375  if (timeAdvanceMethod == "BDF")
376  {
377  timeAdvance->setup (dataStructure->dataTimeAdvance()->orderBDF() , OrderDev);
378  }
379 
380  timeAdvance->setTimeStep (dataStructure->dataTime()->timeStep() );
381  // timeAdvance->showMe();
382 
383  //! #################################################################################
384  //! BOUNDARY CONDITIONS
385  //! #################################################################################
386  std::vector <ID> compx (1), compy (1), compz (1), compxy (2), compxz (2), compyz (2);
387  compx[0] = 0;
388  compy[0] = 1, compz[0] = 2;
389  compxy[0] = 0;
390  compxy[1] = 1;
391  compxz[0] = 0;
392  compxz[1] = 2;
393  compyz[0] = 1;
394  compyz[1] = 2;
395 
396  BCFunctionBase zero (Private::bcZero);
397  BCFunctionBase nonZero (Private::bcNonZero);
398  BCFunctionBase pressure (Private::bcPressure);
399  BCFunctionBase pressureNormal (Private::pressureUsingNormal);
400 
401 
402  //! =================================================================================
403  //! BC for cookMembraneMedit.mesh
404  //! =================================================================================
405  //Condition for Extension
406  //This conditions have to be changed according to script used to generate the mesh
407  //cookMembraneStructure.geo or cookMembrane.geo
408  BCh->addBC ("EdgesIn", 40, Essential, Full, zero, 3);
409  BCh->addBC ("EdgesIn", 60, Natural, Full, zero, 3);
410  BCh->addBC ("EdgesIn", 20, Natural, Full, zero, 3);
411  BCh->addBC ("EdgesIn", 70, Natural, Full, zero, 3);
412  BCh->addBC ("EdgesIn", 30, Natural, Full, zero, 3);
413  BCh->addBC ("EdgesIn", 50, Natural, Full, nonZero, 3);
414 
415  // BCh->addBC("EdgesIn", 40, Essential, Component, zero, compz);
416  // BCh->addBC("EdgesIn", 20, Essential, Component, zero, compz);
417  // BCh->addBC("EdgesIn", 30, Essential, Component, zero, compz);
418  // BCh->addBC("EdgesIn", 70, Essential, Component, zero, compz);
419 
420  //! 1. Constructor of the structuralSolver
421  StructuralOperator< RegionMesh<LinearTetra> > solid;
422 
423  //! 2. Setup of the structuralSolver
424  solid.setup (dataStructure,
425  dFESpace,
426  dETFESpace,
427  BCh,
428  parameters->comm);
429 
430  //! 3. Setting data from getPot
431  solid.setDataFromGetPot (dataFile);
432 
433  //! 4. Building system using TimeAdvance class
434  double timeAdvanceCoefficient = timeAdvance->coefficientSecondDerivative ( 0 ) / (dataStructure->dataTime()->timeStep() * dataStructure->dataTime()->timeStep() );
435  solid.buildSystem (timeAdvanceCoefficient);
436 
437  if (verbose)
438  {
439  std::cout << "S- initialization ... ";
440  }
441 
442  //Initialization of TimeAdvance
443  std::string const restart = dataFile ( "importer/restart", "none");
444  std::vector<vectorPtr_Type> solutionStencil;
445 
446  if ( restart.compare ( "none" ) )
447  {
448  //Reading fileNames - setting data for reading
449  std::string const importerType = dataFile ( "importer/type", "ensight");
450  std::string const fileName = dataFile ( "importer/filename", "structure");
451  std::string const initialLoaded = dataFile ( "importer/initialSol", "NO_DEFAULT_VALUE");
452  //LifeV::Real initialTime = dataFile ( "importer/initialTime", 0.0);
453 
454  //Creating the importer for the case P2 if vtk is used.
455  //For other exporters we have to go from P1 to P2
456  // if( dataStructure->order().compare("P2") == 0 )
457  // {
458  // importerSolid.reset( new exporterVTK_Type ( dataFile, fileName ) );
459  // }
460 
461  //Creating the importer
462 #ifdef HAVE_HDF5
463  if ( !importerType.compare ("hdf5") )
464  {
465  importerSolid.reset ( new hdf5Filter_Type ( dataFile, fileName) );
466  }
467  else
468 #endif
469  {
470  if ( !importerType.compare ("none") )
471  {
472  importerSolid.reset ( new emptyExporter_Type ( dataFile, dFESpace->mesh(), "solid", dFESpace->map().comm().MyPID() ) );
473  }
474  else
475  {
476  importerSolid.reset ( new ensightFilter_Type ( dataFile, fileName) );
477  }
478  }
479  importerSolid->setMeshProcId (dFESpace->mesh(), dFESpace->map().comm().MyPID() );
480 
481  //Creation of Exporter to check the loaded solution (working only for HDF5)
482  // std::string expVerFile = "verificationDisplExporter";
483  // LifeV::ExporterHDF5<RegionMesh<LinearTetra> > exporter( dataFile, meshPart.meshPartition(), expVerFile, parameters->comm->MyPID());
484  // vectorPtr_Type vectVer ( new vector_Type(solid.displacement(), LifeV::Unique ) );
485 
486  // exporter.addVariable( ExporterData<mesh_Type >::VectorField, "displVer", dFESpace, vectVer, UInt(0) );
487 
488  // exporter.postProcess(0.0);
489 
490  //Reading the displacement field and the timesteps need by the TimeAdvance class
491  vectorPtr_Type solidDisp;
492 
493  solidDisp.reset (new vector_Type (dFESpace->map(), Unique ) );
494 
495  std::string iterationString;
496 
497  std::cout << "size TimeAdvance:" << timeAdvance->size() << std::endl;
498 
499  //Loading the stencil
500  exporterDataPtr_Type solidDataReader;
501  iterationString = initialLoaded;
502  for (UInt iterInit = 0; iterInit < timeAdvance->size(); iterInit++ )
503  {
504  *solidDisp *= 0.0;
505 
506  solidDataReader.reset (new exporterData_Type (exporterData_Type::VectorField, std::string ("displacement." + iterationString), dFESpace, solidDisp, UInt (0), LifeV::ExporterData<mesh_Type>::UnsteadyRegime) );
507 
508  importerSolid->readVariable ( *solidDataReader );
509 
510  std::cout << "Norm of the " << iterInit + 1 << "-th solution : " << solidDisp->norm2() << std::endl;
511 
512  //Exporting the just loaded solution (debug purposes)
513  // Real currentLoading(iterInit + 1.0);
514  // *vectVer = *solidDisp;
515  // exporter.postProcess( currentLoading )
516 
517  solutionStencil.push_back ( solidDisp );
518 
519 
520  //initializing the displacement field in the StructuralSolver class with the first solution
521  if ( !iterInit )
522  {
523  solid.initialize ( solidDisp );
524  }
525 
526  //Updating string name
527  int iterations = std::atoi (iterationString.c_str() );
528  iterations--;
529 
530  std::ostringstream iter;
531  iter.fill ( '0' );
532  iter << std::setw (5) << ( iterations );
533  iterationString = iter.str();
534 
535  }
536 
537  importerSolid->closeFile();
538 
539  //Putting the vector in the TimeAdvance Stencil
540  timeAdvance->setInitialCondition (solutionStencil);
541  }
542  else //Initialize with zero vectors
543  {
544 
545  std::cout << "Starting from scratch" << std::endl;
546  vectorPtr_Type disp (new vector_Type (solid.displacement(), Unique) );
547 
548  if (timeAdvanceMethod == "Newmark")
549  {
550  solutionStencil.push_back (disp);
551  solutionStencil.push_back (disp);
552  solutionStencil.push_back (disp);
553  }
554 
555  if (timeAdvanceMethod == "BDF")
556  {
557  for ( UInt previousPass = 0; previousPass < dataStructure->dataTimeAdvance()->orderBDF() ; previousPass++)
558  {
559  solutionStencil.push_back (disp);
560  }
561  }
562 
563  timeAdvance->setInitialCondition (solutionStencil);
564 
565  }
566 
567 
568 
569  //! =================================================================================
570  //! Temporal data and initial conditions
571  //! =================================================================================
572 
573  timeAdvance->setTimeStep (dataStructure->dataTime()->timeStep() );
574 
575  timeAdvance->updateRHSContribution (dataStructure->dataTime()->timeStep() );
576 
577  MPI_Barrier (MPI_COMM_WORLD);
578 
579  if (verbose )
580  {
581  std::cout << "ok." << std::endl;
582  }
583 
584  std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporterSolid;
585 
586  //std::shared_ptr< Exporter<RegionMesh<LinearTetra> > > exporterCheck;
587 
588  std::string const exporterType = dataFile ( "exporter/type", "ensight");
589  std::string const exportFileName = dataFile ( "exporter/nameFile", "structure");
590  std::string const exportCheckName = "checkExporter";
591 
592  //If exporterVTK is used
593  // if( dataStructure->order().compare("P2") == 0 )
594  // {
595  // exporterSolid.reset( new exporterVTK_Type ( dataFile, exportFileName ) );
596  // exporterCheck.reset( new exporterVTK_Type ( dataFile, exportCheckName ) );
597  // }
598 
599 #ifdef HAVE_HDF5
600  if (exporterType.compare ("hdf5") == 0)
601  {
602  exporterSolid.reset ( new hdf5Filter_Type ( dataFile, exportFileName ) );
603  //exporterCheck.reset( new hdf5Filter_Type ( dataFile, exportCheckName ) );
604  }
605  else
606 #endif
607  {
608  if (exporterType.compare ("none") == 0)
609  {
610  exporterSolid.reset ( new emptyExporter_Type ( dataFile, meshPart.meshPartition(), exportFileName, parameters->comm->MyPID() ) );
611  }
612  else
613  {
614  exporterSolid.reset ( new ensightFilter_Type ( dataFile, meshPart.meshPartition(), exportFileName, parameters->comm->MyPID() ) );
615  }
616  }
617 
618  exporterSolid->setPostDir ( "./" );
619  exporterSolid->setMeshProcId ( meshPart.meshPartition(), parameters->comm->MyPID() );
620  //exporterCheck->setMeshProcId( meshPart.meshPartition(), parameters->comm->MyPID() );
621 
622  // if( dataStructure->order().compare("P2") == 0 )
623  // {
624  // exporterSolid->setDataFromGetPot( dataFile, "exporter" );
625  // exporterCheck->setDataFromGetPot( dataFile, "exporter" );
626  // }
627 
628  //discretization FESpace : the possibilities offered by the FESpace class
629  //export FESpace : P1 since Paraview does not read higher fields
630 
631  //This are the vector to extract the displacement, velocity and acceleration.
632  //Their map has to be the one of the discretization FESpace
633  vectorPtr_Type solidDisp ( new vector_Type (solid.displacement(), Unique ) );
634  vectorPtr_Type solidVel ( new vector_Type (solid.displacement(), Unique ) );
635  vectorPtr_Type solidAcc ( new vector_Type (solid.displacement(), Unique ) );
636  //Created for debug reasons. The map has to be the one of the discretization FESpace
637  //vectorPtr_Type rhsVector ( new vector_Type(solid.rhs(), Unique ) );
638 
639  vectorPtr_Type solidDispReduced;
640  vectorPtr_Type solidVelReduced;
641  vectorPtr_Type solidAccReduced;
642  vectorPtr_Type rhsVectorReduced;
643 
644  // if( dataStructure->order().compare("P2") == 0 )
645  // {
646  // solidDispReduced.reset( new vector_Type( exporterFESpace->map(), Unique ) );
647  // solidVelReduced.reset( new vector_Type( exporterFESpace->map(), Unique ) );
648  // solidAccReduced.reset( new vector_Type( exporterFESpace->map(), Unique ) );
649  // //rhsVectorReduced.reset( new vector_Type( exporterFESpace->map(), Unique ) );
650  // exporterSolid->addVariable( ExporterData<RegionMesh<LinearTetra> >::VectorField, "displacement", exporterFESpace, solidDispReduced, UInt(0) );
651  // exporterSolid->addVariable( ExporterData<RegionMesh<LinearTetra> >::VectorField, "velocity", exporterFESpace, solidVelReduced, UInt(0) );
652  // exporterSolid->addVariable( ExporterData<RegionMesh<LinearTetra> >::VectorField, "acceleration", exporterFESpace, solidAccReduced, UInt(0) );
653  // //exporterCheck->addVariable( ExporterData<RegionMesh<LinearTetra> >::VectorField, "rhs", exporterFESpace, rhsVectorReduced, UInt(0) );
654  // }
655  // else
656  // {
657  exporterSolid->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "displacement", dFESpace, solidDisp, UInt (0) );
658  exporterSolid->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "velocity", dFESpace, solidVel, UInt (0) );
659  exporterSolid->addVariable ( ExporterData<RegionMesh<LinearTetra> >::VectorField, "acceleration", dFESpace, solidAcc, UInt (0) );
660  //exporterCheck->addVariable( ExporterData<RegionMesh<LinearTetra> >::VectorField, "rhs", dFESpace, rhsVector, UInt(0) );
661  // }
662 
663  exporterSolid->postProcess ( 0 );
664  //exporterCheck->postProcess( 0 );
665 
666  //!--------------------------------------------------------------------------------------------
667  //!The update of the RHS is done by the TimeAdvance class
668  //solid.updateSystem();
669  //! =================================================================================
670 
671  vectorPtr_Type rhs (new vector_Type (solid.displacement(), Unique) );
672 
673  //! 5. Initial data
674  Real initialTime = dataStructure->dataTime()->initialTime();
675  Real dt = dataStructure->dataTime()->timeStep();
676  Real T = dataStructure->dataTime()->endTime();
677 
678  //! =============================================================================
679  //! Temporal loop
680  //! =============================================================================
681  for (Real time = initialTime + dt; time <= T; time += dt)
682  {
683  dataStructure->dataTime()->setTime (time);
684 
685  if (verbose)
686  {
687  std::cout << std::endl;
688  std::cout << "S- Now we are at time " << dataStructure->dataTime()->time() << " s." << std::endl;
689  }
690 
691  //! 6. Updating right-hand side
692  *rhs *= 0;
693  timeAdvance->updateRHSContribution ( dt );
694  *rhs += *solid.massMatrix() * timeAdvance->rhsContributionSecondDerivative() / timeAdvanceCoefficient;
695 
696  std::cout << "Norm of the rhsNoBC: " << (*rhs).norm2() << std::endl;
697  solid.setRightHandSide ( *rhs );
698 
699  //! 7. Iterate --> Calling Newton
700  solid.iterate ( BCh );
701 
702  timeAdvance->shiftRight ( solid.displacement() );
703 
704  *solidDisp = solid.displacement();
705  *solidVel = timeAdvance->firstDerivative();
706  *solidAcc = timeAdvance->secondDerivative();
707  //*rhsVector = solid.rhs();
708 
709  // if( dataStructure->order().compare("P2") == 0 )
710  // {
711  // *solidDispReduced = exporterFESpace->feToFEInterpolate( *dFESpace, *solidDisp);
712  // *solidVelReduced = exporterFESpace->feToFEInterpolate( *dFESpace, *solidVel );
713  // *solidAccReduced = exporterFESpace->feToFEInterpolate( *dFESpace, *solidAcc );
714  // //*rhsVectorReduced = exporterFESpace->feToFEInterpolate( *dFESpace, *rhsVector );
715  // exporterSolid->postProcess( time );
716  // }
717  // else
718  // {
719  exporterSolid->postProcess ( time );
720  //exporterCheck->postProcess( time );
721  // }
722 
723  Real normVect;
724  normVect = solid.displacement().norm2();
725  std::cout << "The norm 2 of the displacement field is: " << normVect << std::endl;
726 
727 
728  //!--------------------------------------------------------------------------------------------------
729 
730  MPI_Barrier (MPI_COMM_WORLD);
731  }
732 
733  exporterSolid->closeFile();
734 }
735 
736 
737 int
738 main ( int argc, char** argv )
739 {
740 
741 #ifdef HAVE_MPI
742  MPI_Init (&argc, &argv);
743  std::shared_ptr<Epetra_MpiComm> Comm (new Epetra_MpiComm ( MPI_COMM_WORLD ) );
744  if ( Comm->MyPID() == 0 )
745  {
746  std::cout << "% using MPI" << std::endl;
747  }
748 #else
749  std::shared_ptr<Epetra_SerialComm> Comm ( new Epetra_SerialComm() );
750  std::cout << "% using serial Version" << std::endl;
751 #endif
752 
753  Structure structure ( argc, argv, Comm );
754  structure.run();
755 
756 #ifdef HAVE_MPI
757  MPI_Finalize();
758 #endif
759  return returnValue ;
760 }
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
Structure(int argc, char **argv, std::shared_ptr< Epetra_Comm > structComm)
int main(int argc, char **argv)
GetPot(const int argc_, char **argv_, const char *FieldSeparator=0x0)
Definition: GetPot.hpp:507
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
FESpace< RegionMesh< LinearTetra >, MapEpetra > solidFESpace_Type
static Real bcZero(const Real &, const Real &, const Real &, const Real &, const ID &)
LifeV::ExporterVTK< mesh_Type > exporterVTK_Type
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< exporterVTK_Type > exporterVTKPtr_Type
LifeV::ExporterData< mesh_Type > exporterData_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
LifeV::ExporterEmpty< mesh_Type > emptyExporter_Type
std::shared_ptr< vector_Type > vectorPtr_Type
double Real
Generic real data.
Definition: LifeV.hpp:175
static Real bcNonZero(const Real &, const Real &, const Real &, const Real &, const ID &)
std::shared_ptr< emptyExporter_Type > emptyExporterPtr_Type
static Real pressureUsingNormal(const Real &, const Real &, const Real &, const Real &, const ID &)
std::set< UInt > parseList(const std::string &list)
static Real bcPressure(const Real &, const Real &x, const Real &y, const Real &, const ID &i)
std::shared_ptr< solidETFESpace_Type > solidETFESpacePtr_Type
std::shared_ptr< LifeV::Exporter< mesh_Type > > filterPtr_Type
StructuralOperator< RegionMesh< LinearTetra > >::vector_Type vector_Type
std::shared_ptr< solidFESpace_Type > solidFESpacePtr_Type
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
std::shared_ptr< TimeAdvance< vector_Type > > timeAdvance_type
std::shared_ptr< exporterData_Type > exporterDataPtr_Type