v0.13.0
Public Member Functions | Public Attributes | List of all members
NonlinearElasticElement::OpJacobianEnergy Struct Reference

Calculate explicit derivative of free energy. More...

#include <users_modules/basic_finite_elements/src/NonLinearElasticElement.hpp>

Inheritance diagram for NonlinearElasticElement::OpJacobianEnergy:
[legend]
Collaboration diagram for NonlinearElasticElement::OpJacobianEnergy:
[legend]

Public Member Functions

 OpJacobianEnergy (const std::string field_name, BlockData &data, CommonData &common_data, int tag, bool gradient, bool hessian, bool ale, bool field_disp)
 
virtual bool recordTagForIntegrationPoint (const int gg)
 Check if tape is recorded for given integration point. More...
 
virtual MoFEMErrorCode calculateEnergy (const int gg)
 Calculate Paola-Kirchhoff I stress. More...
 
virtual MoFEMErrorCode recordTag (const int gg)
 Record ADOL-C tape. More...
 
virtual MoFEMErrorCode playTag (const int gg)
 Play ADOL-C tape. More...
 
MoFEMErrorCode doWork (int row_side, EntityType row_type, EntitiesFieldData::EntData &row_data)
 
- Public Member Functions inherited from MoFEM::VolumeElementForcesAndSourcesCoreBase::UserDataOperator
int getNumNodes ()
 get element number of nodes More...
 
const EntityHandlegetConn ()
 get element connectivity More...
 
double getVolume () const
 element volume (linear geometry) More...
 
double & getVolume ()
 element volume (linear geometry) More...
 
FTensor::Tensor2< double *, 3, 3 > & getJac ()
 get element Jacobian More...
 
FTensor::Tensor2< double *, 3, 3 > & getInvJac ()
 get element inverse Jacobian More...
 
VectorDoublegetCoords ()
 nodal coordinates More...
 
VolumeElementForcesAndSourcesCoreBasegetVolumeFE () const
 return pointer to Generic Volume Finite Element object More...
 
- Public Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
 UserDataOperator (const FieldSpace space, const char type=OPSPACE, const bool symm=true)
 
 UserDataOperator (const std::string &field_name, const char type, const bool symm=true)
 
 UserDataOperator (const std::string &row_field_name, const std::string &col_field_name, const char type, const bool symm=true)
 
boost::shared_ptr< const NumeredEntFiniteElementgetNumeredEntFiniteElementPtr () const
 Return raw pointer to NumeredEntFiniteElement. More...
 
EntityHandle getFEEntityHandle () const
 Return finite element entity handle. More...
 
int getFEDim () const
 Get dimension of finite element. More...
 
EntityType getFEType () const
 Get dimension of finite element. More...
 
boost::weak_ptr< SideNumbergetSideNumberPtr (const int side_number, const EntityType type)
 Get the side number pointer. More...
 
EntityHandle getSideEntity (const int side_number, const EntityType type)
 Get the side entity. More...
 
int getNumberOfNodesOnElement () const
 Get the number of nodes on finite element. More...
 
MoFEMErrorCode getProblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get row indices. More...
 
MoFEMErrorCode getProblemColIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get col indices. More...
 
const FEMethodgetFEMethod () const
 Return raw pointer to Finite Element Method object. More...
 
int getOpType () const
 Get operator types. More...
 
void setOpType (const OpType type)
 Set operator type. More...
 
void addOpType (const OpType type)
 Add operator type. More...
 
int getNinTheLoop () const
 get number of finite element in the loop More...
 
int getLoopSize () const
 get size of elements in the loop More...
 
const std::string & getFEName () const
 Get name of the element. More...
 
const PetscData::SwitchesgetDataCtx () const
 
const KspMethod::KSPContext getKSPCtx () const
 
const SnesMethod::SNESContext getSNESCtx () const
 
const TSMethod::TSContext getTSCtx () const
 
Vec getKSPf () const
 
Mat getKSPA () const
 
Mat getKSPB () const
 
Vec getSNESf () const
 
Vec getSNESx () const
 
Mat getSNESA () const
 
Mat getSNESB () const
 
Vec getTSu () const
 
Vec getTSu_t () const
 
Vec getTSu_tt () const
 
Vec getTSf () const
 
Mat getTSA () const
 
Mat getTSB () const
 
int getTSstep () const
 
double getTStime () const
 
double getTSa () const
 
double getTSaa () const
 
MatrixDoublegetGaussPts ()
 matrix of integration (Gauss) points for Volume Element More...
 
auto getFTensor0IntegrationWeight ()
 Get integration weights. More...
 
MatrixDoublegetCoordsAtGaussPts ()
 Gauss points and weight, matrix (nb. of points x 3) More...
 
auto getFTensor1CoordsAtGaussPts ()
 Get coordinates at integration points assuming linear geometry. More...
 
double getMeasure () const
 get measure of element More...
 
double & getMeasure ()
 get measure of element More...
 
MoFEMErrorCode loopSide (const string &fe_name, ForcesAndSourcesCore *side_fe, const size_t dim, const EntityHandle ent_for_side=0, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User call this function to loop over elements on the side of face. This function calls finite element with is operator to do calculations. More...
 
MoFEMErrorCode loopThis (const string &fe_name, ForcesAndSourcesCore *parent_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User call this function to loop over parent elements. This function calls finite element with is operator to do calculations. More...
 
MoFEMErrorCode loopParent (const string &fe_name, ForcesAndSourcesCore *parent_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User call this function to loop over parent elements. This function calls finite element with is operator to do calculations. More...
 
MoFEMErrorCode loopChildren (const string &fe_name, ForcesAndSourcesCore *child_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User call this function to loop over parent elements. This function calls finite element with is operator to do calculations. More...
 
- Public Member Functions inherited from MoFEM::DataOperator
 DataOperator (const bool symm=true)
 
virtual ~DataOperator ()=default
 
virtual MoFEMErrorCode doWork (int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)
 Operator for bi-linear form, usually to calculate values on left hand side. More...
 
virtual MoFEMErrorCode opLhs (EntitiesFieldData &row_data, EntitiesFieldData &col_data)
 
virtual MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 Operator for linear form, usually to calculate values on right hand side. More...
 
virtual MoFEMErrorCode opRhs (EntitiesFieldData &data, const bool error_if_no_base=false)
 
bool getSymm () const
 Get if operator uses symmetry of DOFs or not. More...
 
void setSymm ()
 set if operator is executed taking in account symmetry More...
 
void unSetSymm ()
 unset if operator is executed for non symmetric problem More...
 

Public Attributes

BlockDatadAta
 
CommonDatacommonData
 
int tAg
 tape tag More...
 
bool gRadient
 if set true gradient of energy is calculated More...
 
bool hEssian
 if set true hessian of energy is calculated More...
 
bool aLe
 true if arbitrary Lagrangian-Eulerian formulation More...
 
bool fieldDisp
 true if displacements instead spatial positions used More...
 
VectorDouble activeVariables
 
int nbActiveVariables
 
std::vector< MatrixDouble > * ptrh
 
std::vector< MatrixDouble > * ptrH
 
FTensor::Index< 'i', 3 > i
 
FTensor::Index< 'j', 3 > j
 
FTensor::Index< 'k', 3 > k
 
- Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
char opType
 
std::string rowFieldName
 
std::string colFieldName
 
FieldSpace sPace
 
- Public Attributes inherited from MoFEM::DataOperator
DoWorkLhsHookFunType doWorkLhsHook
 
DoWorkRhsHookFunType doWorkRhsHook
 
bool sYmm
 If true assume that matrix is symmetric structure. More...
 
std::array< bool, MBMAXTYPE > doEntities
 If true operator is executed for entity. More...
 
booldoVertices
 \deprectaed If false skip vertices More...
 
booldoEdges
 \deprectaed If false skip edges More...
 
booldoQuads
 \deprectaed More...
 
booldoTris
 \deprectaed More...
 
booldoTets
 \deprectaed More...
 
booldoPrisms
 \deprectaed More...
 

Additional Inherited Members

- Public Types inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
enum  OpType { OPROW = 1 << 0 , OPCOL = 1 << 1 , OPROWCOL = 1 << 2 , OPSPACE = 1 << 3 }
 Controls loop over entities on element. More...
 
- Public Types inherited from MoFEM::DataOperator
using DoWorkLhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int row_side, int col_side, EntityType row_type, EntityType col_type, EntitiesFieldData::EntData &row_data, EntitiesFieldData::EntData &col_data)>
 
using DoWorkRhsHookFunType = boost::function< MoFEMErrorCode(DataOperator *op_ptr, int side, EntityType type, EntitiesFieldData::EntData &data)>
 
- Static Public Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
static const char *const OpTypeNames []
 
- Protected Member Functions inherited from MoFEM::VolumeElementForcesAndSourcesCoreBase::UserDataOperator
MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
- Protected Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
ForcesAndSourcesCoregetPtrFE () const
 
ForcesAndSourcesCoregetSidePtrFE () const
 
ForcesAndSourcesCoregetRefinePtrFE () const
 
- Protected Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
ForcesAndSourcesCoreptrFE
 

Detailed Description

Calculate explicit derivative of free energy.

Definition at line 472 of file NonLinearElasticElement.hpp.

Constructor & Destructor Documentation

◆ OpJacobianEnergy()

NonlinearElasticElement::OpJacobianEnergy::OpJacobianEnergy ( const std::string  field_name,
BlockData data,
CommonData common_data,
int  tag,
bool  gradient,
bool  hessian,
bool  ale,
bool  field_disp 
)
Parameters
field_namefield name for spatial positions or displacements

Definition at line 423 of file NonLinearElasticElement.cpp.

429  field_name, UserDataOperator::OPROW),
430  dAta(data), commonData(common_data), tAg(tag), gRadient(gradient),
431  hEssian(hessian), aLe(ale), fieldDisp(field_disp) {}
ForcesAndSourcesCore::UserDataOperator UserDataOperator
bool gRadient
if set true gradient of energy is calculated
bool fieldDisp
true if displacements instead spatial positions used
bool hEssian
if set true hessian of energy is calculated
bool aLe
true if arbitrary Lagrangian-Eulerian formulation

Member Function Documentation

◆ calculateEnergy()

MoFEMErrorCode NonlinearElasticElement::OpJacobianEnergy::calculateEnergy ( const int  gg)
virtual

Calculate Paola-Kirchhoff I stress.

Returns
error code

Definition at line 434 of file NonLinearElasticElement.cpp.

434  {
436  CHKERR dAta.materialAdoublePtr->calculateElasticEnergy(
438  dAta.materialAdoublePtr->eNergy >>= commonData.eNergy[gg];
440 }
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
#define CHKERR
Inline error check.
Definition: definitions.h:548
boost::shared_ptr< const NumeredEntFiniteElement > getNumeredEntFiniteElementPtr() const
Return raw pointer to NumeredEntFiniteElement.
boost::shared_ptr< FunctionsToCalculatePiolaKirchhoffI< adouble > > materialAdoublePtr

◆ doWork()

MoFEMErrorCode NonlinearElasticElement::OpJacobianEnergy::doWork ( int  row_side,
EntityType  row_type,
EntitiesFieldData::EntData row_data 
)

Definition at line 540 of file NonLinearElasticElement.cpp.

542  {
544 
545  // do it only once, no need to repeat this for edges,faces or tets
546  if (row_type != MBVERTEX)
548 
549  if (dAta.tEts.find(getNumeredEntFiniteElementPtr()->getEnt()) ==
550  dAta.tEts.end()) {
552  }
553 
554  int nb_dofs = row_data.getFieldData().size();
555  if (nb_dofs == 0)
557  dAta.materialAdoublePtr->commonDataPtr = &commonData;
558  dAta.materialAdoublePtr->opPtr = this;
559 
560  int nb_gauss_pts = row_data.getN().size1();
561  commonData.eNergy.resize(nb_gauss_pts);
562  commonData.jacEnergy.resize(nb_gauss_pts);
563 
565  if (aLe) {
567  }
568 
569  for (int gg = 0; gg != nb_gauss_pts; gg++) {
570 
571  dAta.materialAdoublePtr->gG = gg;
572 
573  // Record tag and calualte stress
575  CHKERR recordTag(gg);
576  }
577 
578  activeVariables.resize(nbActiveVariables, false);
579  if (!aLe) {
580  for (int dd1 = 0; dd1 < 3; dd1++) {
581  for (int dd2 = 0; dd2 < 3; dd2++) {
582  activeVariables(dd1 * 3 + dd2) = (*ptrh)[gg](dd1, dd2);
583  }
584  }
585  } else {
586  for (int dd1 = 0; dd1 < 3; dd1++) {
587  for (int dd2 = 0; dd2 < 3; dd2++) {
588  activeVariables(dd1 * 3 + dd2) = (*ptrh)[gg](dd1, dd2);
589  }
590  }
591  for (int dd1 = 0; dd1 < 3; dd1++) {
592  for (int dd2 = 0; dd2 < 3; dd2++) {
593  activeVariables(9 + dd1 * 3 + dd2) = (*ptrH)[gg](dd1, dd2);
594  }
595  }
596  }
597  CHKERR dAta.materialAdoublePtr->setUserActiveVariables(activeVariables);
598 
599  // Play tag and calculate stress or tangent
600  CHKERR playTag(gg);
601  }
602 
604 }
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
MatrixDouble & getN(const FieldApproximationBase base)
get base functions this return matrix (nb. of rows is equal to nb. of Gauss pts, nb....
const VectorDouble & getFieldData() const
get dofs values
Range tEts
constrains elements in block set
std::map< std::string, std::vector< MatrixDouble > > gradAtGaussPts
virtual bool recordTagForIntegrationPoint(const int gg)
Check if tape is recorded for given integration point.
virtual MoFEMErrorCode playTag(const int gg)
Play ADOL-C tape.
virtual MoFEMErrorCode recordTag(const int gg)
Record ADOL-C tape.

◆ playTag()

MoFEMErrorCode NonlinearElasticElement::OpJacobianEnergy::playTag ( const int  gg)
virtual

Play ADOL-C tape.

Returns
error code

Definition at line 506 of file NonLinearElasticElement.cpp.

506  {
508 
509  if (gRadient) {
510  commonData.jacEnergy[gg].resize(nbActiveVariables, false);
511  int r = ::gradient(tAg, nbActiveVariables, &activeVariables[0],
512  &commonData.jacEnergy[gg][0]);
513  if (r < 0) {
514  // That means that energy function is not smooth and derivative
515  // can not be calculated,
516  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
517  "ADOL-C function evaluation with error");
518  }
519  }
520 
521  if (hEssian) {
523  false);
524  double *H[nbActiveVariables];
525  for (int n = 0; n != nbActiveVariables; n++) {
527  }
528  int r = ::hessian(tAg, nbActiveVariables, &*activeVariables.begin(), H);
529  if (r < 0) {
530  // That means that energy function is not smooth and derivative
531  // can not be calculated,
532  SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
533  "ADOL-C function evaluation with error");
534  }
535  }
536 
538 }
static Index< 'n', 3 > n
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition: definitions.h:47
const double r
rate factor
double H
Definition: plastic.cpp:109

◆ recordTag()

MoFEMErrorCode NonlinearElasticElement::OpJacobianEnergy::recordTag ( const int  gg)
virtual

Record ADOL-C tape.

Returns
error code

Definition at line 443 of file NonLinearElasticElement.cpp.

443  {
445 
446  trace_on(tAg, 0);
447 
448  if (!aLe) {
449 
450  nbActiveVariables = 0;
451  for (int dd1 = 0; dd1 < 3; dd1++) {
452  for (int dd2 = 0; dd2 < 3; dd2++) {
453  dAta.materialAdoublePtr->F(dd1, dd2) <<= (*ptrh)[gg](dd1, dd2);
454  if (fieldDisp) {
455  if (dd1 == dd2) {
456  dAta.materialAdoublePtr->F(dd1, dd2) += 1;
457  }
458  }
460  }
461  }
462 
463  } else {
464 
465  nbActiveVariables = 0;
466 
467  dAta.materialAdoublePtr->h.resize(3, 3, false);
468  for (int dd1 = 0; dd1 < 3; dd1++) {
469  for (int dd2 = 0; dd2 < 3; dd2++) {
470  dAta.materialAdoublePtr->h(dd1, dd2) <<= (*ptrh)[gg](dd1, dd2);
472  }
473  }
474 
475  dAta.materialAdoublePtr->H.resize(3, 3, false);
476  for (int dd1 = 0; dd1 < 3; dd1++) {
477  for (int dd2 = 0; dd2 < 3; dd2++) {
478  dAta.materialAdoublePtr->H(dd1, dd2) <<= (*ptrH)[gg](dd1, dd2);
480  }
481  }
482 
484  dAta.materialAdoublePtr->invH.resize(3, 3, false);
486  dAta.materialAdoublePtr->detH,
487  dAta.materialAdoublePtr->invH);
488 
489  auto &t_F = dAta.materialAdoublePtr->t_F;
490  auto &t_h = dAta.materialAdoublePtr->t_h;
491  auto &t_invH = dAta.materialAdoublePtr->t_invH;
492 
493  t_F(i, j) = t_h(i, k) * t_invH(k, j);
494 
495  }
496 
497  CHKERR dAta.materialAdoublePtr->setUserActiveVariables(nbActiveVariables);
499 
500  trace_off();
501 
503 }
MoFEMErrorCode invertTensor3by3(ublas::matrix< T, L, A > &jac_data, ublas::vector< T, A > &det_data, ublas::matrix< T, L, A > &inv_jac_data)
Calculate inverse of tensor rank 2 at integration points.
Definition: Templates.hpp:1172
static auto determinantTensor3by3(T &t)
Calculate the determinant of a 3x3 matrix or a tensor of rank 2.
Definition: Templates.hpp:1161
virtual MoFEMErrorCode calculateEnergy(const int gg)
Calculate Paola-Kirchhoff I stress.

◆ recordTagForIntegrationPoint()

virtual bool NonlinearElasticElement::OpJacobianEnergy::recordTagForIntegrationPoint ( const int  gg)
virtual

Check if tape is recorded for given integration point.

Parameters
ggintegration point
Returns
true if tag is recorded

Definition at line 505 of file NonLinearElasticElement.hpp.

505  {
506  if (gg == 0)
507  return true;
508  return false;
509  }

Member Data Documentation

◆ activeVariables

VectorDouble NonlinearElasticElement::OpJacobianEnergy::activeVariables

Definition at line 490 of file NonLinearElasticElement.hpp.

◆ aLe

bool NonlinearElasticElement::OpJacobianEnergy::aLe

true if arbitrary Lagrangian-Eulerian formulation

Definition at line 481 of file NonLinearElasticElement.hpp.

◆ commonData

CommonData& NonlinearElasticElement::OpJacobianEnergy::commonData

Definition at line 476 of file NonLinearElasticElement.hpp.

◆ dAta

BlockData& NonlinearElasticElement::OpJacobianEnergy::dAta

Definition at line 475 of file NonLinearElasticElement.hpp.

◆ fieldDisp

bool NonlinearElasticElement::OpJacobianEnergy::fieldDisp

true if displacements instead spatial positions used

Definition at line 482 of file NonLinearElasticElement.hpp.

◆ gRadient

bool NonlinearElasticElement::OpJacobianEnergy::gRadient

if set true gradient of energy is calculated

Definition at line 479 of file NonLinearElasticElement.hpp.

◆ hEssian

bool NonlinearElasticElement::OpJacobianEnergy::hEssian

if set true hessian of energy is calculated

Definition at line 480 of file NonLinearElasticElement.hpp.

◆ i

FTensor::Index<'i', 3> NonlinearElasticElement::OpJacobianEnergy::i

Definition at line 496 of file NonLinearElasticElement.hpp.

◆ j

FTensor::Index<'j', 3> NonlinearElasticElement::OpJacobianEnergy::j

Definition at line 497 of file NonLinearElasticElement.hpp.

◆ k

FTensor::Index<'k', 3> NonlinearElasticElement::OpJacobianEnergy::k

Definition at line 498 of file NonLinearElasticElement.hpp.

◆ nbActiveVariables

int NonlinearElasticElement::OpJacobianEnergy::nbActiveVariables

Definition at line 491 of file NonLinearElasticElement.hpp.

◆ ptrh

std::vector<MatrixDouble>* NonlinearElasticElement::OpJacobianEnergy::ptrh

Definition at line 493 of file NonLinearElasticElement.hpp.

◆ ptrH

std::vector<MatrixDouble>* NonlinearElasticElement::OpJacobianEnergy::ptrH

Definition at line 494 of file NonLinearElasticElement.hpp.

◆ tAg

int NonlinearElasticElement::OpJacobianEnergy::tAg

tape tag

Definition at line 478 of file NonLinearElasticElement.hpp.


The documentation for this struct was generated from the following files: