44 #ifndef _STRUCTURALCONSTITUTIVELAW_H_    45 #define _STRUCTURALCONSTITUTIVELAW_H_ 1
    53 #include <Epetra_Vector.h>    54 #include <EpetraExt_MatrixMatrix.h>    55 #include <Epetra_SerialDenseMatrix.h>    58 #include <lifev/core/array/MatrixEpetra.hpp>    59 #include <lifev/core/array/VectorEpetra.hpp>    61 #include <lifev/structure/fem/AssemblyElementalStructure.hpp>    62 #include <lifev/core/fem/FESpace.hpp>    64 #include <lifev/core/LifeV.hpp>    65 #include <lifev/core/util/Displayer.hpp>    67 #include <lifev/structure/solver/StructuralConstitutiveLawData.hpp>    69 #include <lifev/structure/solver/isotropic/StructuralIsotropicConstitutiveLaw.hpp>    71 #include <lifev/structure/solver/anisotropic/StructuralAnisotropicConstitutiveLaw.hpp>    74 #include <lifev/eta/fem/ETFESpace.hpp>    75 #include <lifev/eta/expression/Integrate.hpp>    76 #include <lifev/eta/expression/Evaluate.hpp>    87 template <
typename MeshType>
    88 class StructuralConstitutiveLaw
    97     typedef StructuralIsotropicConstitutiveLaw<MeshType>                 isotropicLaw_Type;
    98     typedef std::shared_ptr<isotropicLaw_Type>                         isotropicLawPtr_Type;
   100     typedef StructuralAnisotropicConstitutiveLaw<MeshType>               anisotropicLaw_Type;
   101     typedef std::shared_ptr<anisotropicLaw_Type>                       anisotropicLawPtr_Type;
   103     typedef MatrixEpetra<
Real>                                           matrix_Type;
   104     typedef std::shared_ptr<matrix_Type>                               matrixPtr_Type;
   105     typedef VectorEpetra                                                 vector_Type;
   106     typedef std::shared_ptr<vector_Type>                               vectorPtr_Type;
   108     typedef typename std::shared_ptr<data_Type>                        dataPtr_Type;
   109     typedef typename std::shared_ptr<
const Displayer>                  displayerPtr_Type;
   111     typedef std::vector< 
typename MeshType::element_Type* >              vectorVolumes_Type;
   113     typedef std::map< UInt, vectorVolumes_Type>           mapMarkerVolumes_Type;
   114     typedef std::shared_ptr<mapMarkerVolumes_Type>      mapMarkerVolumesPtr_Type;
   116     typedef std::vector<UInt>                             vectorIndexes_Type;
   117     typedef std::map< UInt, vectorIndexes_Type>           mapMarkerIndexes_Type;
   118     typedef std::shared_ptr<mapMarkerIndexes_Type>      mapMarkerIndexesPtr_Type;
   121     typedef ETFESpace<MeshType, MapEpetra, 3, 3 >         ETFESpace_Type;
   122     typedef std::shared_ptr<ETFESpace_Type>             ETFESpacePtr_Type;
   124     typedef FESpace< MeshType, MapEpetra >                FESpace_Type;
   125     typedef std::shared_ptr<FESpace_Type>               FESpacePtr_Type;
   128     typedef std::vector<std::vector<Real> >           vectorsParameters_Type;
   129     typedef std::shared_ptr<vectorsParameters_Type> vectorsParametersPtr_Type;
   137     StructuralConstitutiveLaw();
   139     virtual ~StructuralConstitutiveLaw() {}
   155     void setup ( 
const FESpacePtr_Type& dFESpace,
   156          const ETFESpacePtr_Type& ETFESpace,
   157          const std::shared_ptr<
const MapEpetra>&   monolithicMap,
   158          const UInt offset, 
const dataPtr_Type& dataMaterial,
   159          const displayerPtr_Type& displayer  );
   166     void computeLinearStiff ( dataPtr_Type& dataMaterial,
   167                   const mapMarkerVolumesPtr_Type ,
   168                   const mapMarkerIndexesPtr_Type  );
   177     void updateJacobianMatrix ( 
const vector_Type& disp, 
const dataPtr_Type& dataMaterial,
   178                                 const mapMarkerVolumesPtr_Type mapsMarkerVolumes,
   179                                 const mapMarkerIndexesPtr_Type mapsMarkerIndexes,
   180                                 const displayerPtr_Type& displayer );
   193     void computeStiffness ( 
const vector_Type& sol, 
const UInt iter, 
Real factor, 
const dataPtr_Type& dataMaterial,
   194                             const mapMarkerVolumesPtr_Type mapsMarkerVolumes,
   195                             const mapMarkerIndexesPtr_Type mapsMarkerIndexes,
   196                             const displayerPtr_Type& displayer );
   204     void showMe ( std::string 
const& fileNameStiff, std::string 
const& fileNameJacobian );
   214     void computeLocalFirstPiolaKirchhoffTensor ( Epetra_SerialDenseMatrix& firstPiola,
   215                                                  const Epetra_SerialDenseMatrix& tensorF,
   216                                                  const Epetra_SerialDenseMatrix& cofactorF,
   217                                                  const std::vector<Real>& invariants,
   218                                                  const UInt material);
   227     void computeCauchyStressTensor ( 
const vectorPtr_Type disp,
   229                      vectorPtr_Type sigma_1,
   230                      vectorPtr_Type sigma_2,
   231                      vectorPtr_Type sigma_3);
   248     MapEpetra   
const& map()     
const   254     FESpace_Type& dFESpace()
   256         return *M_dispFESpace;
   260     ETFESpace_Type& dETFESpace()
   262         return *M_dispETFESpace;
   266     matrixPtr_Type 
const jacobian()    
const   271     isotropicLawPtr_Type isotropicLaw( ) 
const   273         return M_isotropicLaw;
   276     anisotropicLawPtr_Type anisotropicLaw( ) 
const   278         return M_anisotropicLaw;
   282     const matrixPtr_Type  stiffMatrix();
   285     const vectorPtr_Type  stiffVector();
   287     void apply ( 
const vector_Type& sol, vector_Type& res,
   288                  const mapMarkerVolumesPtr_Type mapsMarkerVolumes,
   289                  const mapMarkerIndexesPtr_Type mapsMarkerIndexes);
   297     FESpacePtr_Type                                M_dispFESpace;
   299     ETFESpacePtr_Type                              M_dispETFESpace;
   301     std::shared_ptr<
const MapEpetra>             M_localMap;
   304     matrixPtr_Type                                 M_jacobian;
   309     dataPtr_Type                                   M_dataMaterial;
   311     isotropicLawPtr_Type                           M_isotropicLaw;
   313     anisotropicLawPtr_Type                         M_anisotropicLaw;
   315     displayerPtr_Type                              M_displayer;
   317     matrixPtr_Type                                 M_matrixStiffness;
   319     vectorPtr_Type                                 M_vectorStiffness;
   326 template <
typename MeshType>
   327 StructuralConstitutiveLaw<MeshType>::StructuralConstitutiveLaw( ) :
   335     M_anisotropicLaw             ( ),
   337     M_matrixStiffness            ( ),
   338     M_vectorStiffness            ( )
   343 template <
typename MeshType>
   345 StructuralConstitutiveLaw<MeshType>::setup (
const FESpacePtr_Type& dFESpace,
   346                                             const ETFESpacePtr_Type& dETFESpace,
   347                                             const std::shared_ptr<
const MapEpetra>&  monolithicMap,
   348                                             const UInt offset, 
const dataPtr_Type& dataMaterial, 
const displayerPtr_Type& displayer
   351     M_dispFESpace                   = dFESpace;
   352     M_dispETFESpace                 = dETFESpace;
   353     M_localMap                      = monolithicMap;
   354     M_jacobian.reset                (
new matrix_Type (*M_localMap) );
   356     M_dataMaterial                  = dataMaterial;
   359     M_isotropicLaw.reset ( isotropicLaw_Type::StructureIsotropicMaterialFactory::instance().createObject ( M_dataMaterial->solidTypeIsotropic() ) );
   361     if( !M_dataMaterial->constitutiveLaw().compare(
"anisotropic") )
   363           M_anisotropicLaw.reset ( anisotropicLaw_Type::StructureAnisotropicMaterialFactory::instance().createObject ( M_dataMaterial->solidTypeAnisotropic() ) );
   367     M_displayer = displayer;
   369     M_matrixStiffness.reset         ( 
new matrix_Type(*M_localMap) );
   370     M_vectorStiffness.reset         ( 
new vector_Type(*M_localMap) );
   373     M_isotropicLaw->setup( dFESpace, dETFESpace, monolithicMap, offset, M_dataMaterial );
   374     if( !M_dataMaterial->constitutiveLaw().compare(
"anisotropic") )
   376         M_anisotropicLaw->setup( dFESpace, dETFESpace, monolithicMap, offset, M_dataMaterial );
   381 template <
typename MeshType>
   382 void StructuralConstitutiveLaw<MeshType>::computeLinearStiff (dataPtr_Type& dataMaterial,
   383                                                               const mapMarkerVolumesPtr_Type mapsMarkerVolumes,
   384                                                               const mapMarkerIndexesPtr_Type mapsMarkerIndexes)
   387   M_isotropicLaw->computeLinearStiff(dataMaterial, mapsMarkerVolumes, mapsMarkerIndexes);
   394 template <
typename MeshType>
   395 void StructuralConstitutiveLaw<MeshType>::updateJacobianMatrix (
const vector_Type& disp,
   396                                                                 const dataPtr_Type& dataMaterial,
   397                                                                 const mapMarkerVolumesPtr_Type mapsMarkerVolumes,
   398                                                                 const mapMarkerIndexesPtr_Type mapsMarkerIndexes,
   399                                                                 const displayerPtr_Type& displayer)
   402     M_jacobian.reset (
new matrix_Type (*M_localMap) );
   406     M_displayer->leaderPrint (
"\n  S-  Updating the Jacobian Matrix ( isotropic part )\n");
   407     M_isotropicLaw->updateJacobianMatrix ( disp, dataMaterial, mapsMarkerVolumes, mapsMarkerIndexes, displayer);
   409     *M_jacobian += *M_isotropicLaw->jacobian();
   411     if( !M_dataMaterial->constitutiveLaw().compare(
"anisotropic") )
   414     M_displayer->leaderPrint (
"\n  S-  Updating the Jacobian Matrix ( anisotropic part )\n");
   416     M_anisotropicLaw->updateJacobianMatrix (disp, dataMaterial, mapsMarkerVolumes, mapsMarkerIndexes, displayer);
   418     *M_jacobian += *M_anisotropicLaw->jacobian();
   421     M_jacobian->globalAssemble();
   424 template <
typename MeshType>
   425 void StructuralConstitutiveLaw<MeshType>::computeStiffness ( 
const vector_Type& sol, 
const UInt iter, 
Real factor, 
const dataPtr_Type& dataMaterial,
   426                                                              const mapMarkerVolumesPtr_Type mapsMarkerVolumes,
   427                                                              const mapMarkerIndexesPtr_Type mapsMarkerIndexes,
   428                                                              const displayerPtr_Type& displayer )
   435     M_vectorStiffness.reset (
new vector_Type (*M_localMap) );
   436     *M_vectorStiffness *= 0.0;
   439     M_displayer->leaderPrint (
"\n  S-  Updating the VectorStiffness ( isotropic part )\n");
   440     M_isotropicLaw->computeStiffness ( sol, factor, dataMaterial, mapsMarkerVolumes, mapsMarkerIndexes, displayer);
   442     *M_vectorStiffness += *M_isotropicLaw->stiffVector();
   445     if( !M_dataMaterial->constitutiveLaw().compare(
"anisotropic") )
   448         displayer->leaderPrint (
"\n  S-  Updating the VectorStiffness ( anisotropic part )\n");
   457         M_anisotropicLaw->computeStiffness (sol, iter, factor, dataMaterial, mapsMarkerVolumes, mapsMarkerIndexes, displayer);
   459         *M_vectorStiffness += *M_anisotropicLaw->stiffVector();
   462     M_vectorStiffness->globalAssemble();
   465 template <
typename MeshType>
   467 StructuralConstitutiveLaw<MeshType>::showMe ( std::string 
const& fileNameStiff,
   468                           std::string 
const& fileNameJacobian
   472     M_isotropicLaw->showMe ( fileNameStiff, fileNameJacobian);
   474     if( !M_dataMaterial->constitutiveLaw().compare(
"anisotropic") )
   477         M_anisotropicLaw->showMe ( fileNameStiff, fileNameJacobian);
   482 template <
typename MeshType>
   484 StructuralConstitutiveLaw<MeshType>::computeLocalFirstPiolaKirchhoffTensor ( Epetra_SerialDenseMatrix& firstPiola,
   485                                                                              const Epetra_SerialDenseMatrix& tensorF,
   486                                                                              const Epetra_SerialDenseMatrix& cofactorF,
   487                                                                              const std::vector<Real>& invariants,
   490     firstPiola.Scale(0.0);
   492     Epetra_SerialDenseMatrix isotropicFirstPiola(firstPiola);
   495     Epetra_SerialDenseMatrix anisotropicFirstPiola(firstPiola);
   498     M_isotropicLaw->computeLocalFirstPiolaKirchhoffTensor ( isotropicFirstPiola, tensorF, cofactorF, invariants, marker);
   500     firstPiola += isotropicFirstPiola;
   502     if( !M_dataMaterial->constitutiveLaw().compare(
"anisotropic") )
   505         M_anisotropicLaw->computeLocalFirstPiolaKirchhoffTensor ( anisotropicFirstPiola, tensorF, cofactorF, invariants, marker);
   507         firstPiola += anisotropicFirstPiola;
   512 template <
typename MeshType>
   513 const typename StructuralConstitutiveLaw<MeshType>::matrixPtr_Type StructuralConstitutiveLaw<MeshType>::stiffMatrix()
   516     ASSERT( !M_dataMaterial->solidTypeIsotropic().compare(
"linearVenantKirchhoff"), 
" No Stiffness Matrix defined for the nonlinear case! ");
   519     M_matrixStiffness.reset (
new matrix_Type(*M_localMap) );
   520     *M_matrixStiffness *= 0.0;
   523     *M_matrixStiffness += *M_isotropicLaw->stiffMatrix();
   525     M_matrixStiffness->globalAssemble();
   528     return M_matrixStiffness;
   532 template <
typename MeshType>
   533 const typename StructuralConstitutiveLaw<MeshType>::vectorPtr_Type StructuralConstitutiveLaw<MeshType>::stiffVector()
   536     ASSERT( M_dataMaterial->solidTypeIsotropic().compare(
"linearVenantKirchhoff"), 
" No Stiffness Vector defined for the linear case! ");
   539     M_vectorStiffness.reset (
new vector_Type (*M_localMap) );
   540     *M_vectorStiffness *= 0.0;
   543     *M_vectorStiffness += *M_isotropicLaw->stiffVector();
   545     if( !M_dataMaterial->constitutiveLaw().compare(
"anisotropic") )
   548         *M_vectorStiffness += *M_anisotropicLaw->stiffVector();
   551     M_vectorStiffness->globalAssemble();
   554     return M_vectorStiffness;
   557 template <
typename MeshType>
   558 void StructuralConstitutiveLaw<MeshType>::apply ( 
const vector_Type& sol, vector_Type& res,
   559                                                   const mapMarkerVolumesPtr_Type mapsMarkerVolumes,
   560                                                   const mapMarkerIndexesPtr_Type mapsMarkerIndexes)
   563   vector_Type copyResIsotropic(res);
   566   M_isotropicLaw->apply ( sol, copyResIsotropic, mapsMarkerVolumes, mapsMarkerIndexes, M_displayer);
   571   res += copyResIsotropic;
   573   if( !M_dataMaterial->constitutiveLaw().compare(
"anisotropic") )
   575       vector_Type copyResAnisotropic(res);
   576       M_anisotropicLaw->apply ( sol, copyResAnisotropic, mapsMarkerVolumes, mapsMarkerIndexes, M_displayer);
   577       res += copyResAnisotropic;
   582 template <
typename MeshType>
   584 StructuralConstitutiveLaw<MeshType>::computeCauchyStressTensor ( 
const vectorPtr_Type disp,
   586                                  vectorPtr_Type sigma_1,
   587                                  vectorPtr_Type sigma_2, vectorPtr_Type sigma_3 )
   593   vectorPtr_Type sigma1CopyIso;
   594   vectorPtr_Type sigma2CopyIso;
   595   vectorPtr_Type sigma3CopyIso;
   597   sigma1CopyIso.reset( 
new vector_Type(*M_localMap) );
   598   sigma2CopyIso.reset( 
new vector_Type(*M_localMap) );
   599   sigma3CopyIso.reset( 
new vector_Type(*M_localMap) );
   601   vectorPtr_Type sigma1CopyAniso;
   602   vectorPtr_Type sigma2CopyAniso;
   603   vectorPtr_Type sigma3CopyAniso;
   605   sigma1CopyAniso.reset( 
new vector_Type(*M_localMap) );
   606   sigma2CopyAniso.reset( 
new vector_Type(*M_localMap) );
   607   sigma3CopyAniso.reset( 
new vector_Type(*M_localMap) );
   609   M_isotropicLaw->computeCauchyStressTensor( disp, evalQuad, sigma1CopyIso, sigma2CopyIso, sigma3CopyIso );
   611   *sigma_1 += *sigma1CopyIso;
   612   *sigma_2 += *sigma2CopyIso;
   613   *sigma_3 += *sigma3CopyIso;
   615   if( !M_dataMaterial->constitutiveLaw().compare(
"anisotropic") )
   617       M_anisotropicLaw->computeCauchyStressTensor( disp, evalQuad, sigma1CopyAniso, sigma2CopyAniso,sigma3CopyAniso );
   619       *sigma_1 += *sigma1CopyAniso;
   620       *sigma_2 += *sigma2CopyAniso;
   621       *sigma_3 += *sigma3CopyAniso;
   625   sigma_1->globalAssemble();
   626   sigma_2->globalAssemble();
   627   sigma_3->globalAssemble();
 FESpace - Short description here please! 
 
double Real
Generic real data. 
 
QuadratureRule - The basis class for storing and accessing quadrature rules. 
 
class ETFESpace A light, templated version of the FESpace 
 
DataElasticStructure - Data container for solid problems with elastic structure. 
 
uint32_type UInt
generic unsigned integer (used mainly for addressing)