v0.13.1
Loading...
Searching...
No Matches
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::VolumeElementForcesAndSourcesCore::UserDataOperator
int getNumNodes ()
 get element number of nodes More...
 
const EntityHandlegetConn ()
 get element connectivity More...
 
double getVolume () const
 element volume (linear geometry) More...
 
doublegetVolume ()
 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...
 
VolumeElementForcesAndSourcesCoregetVolumeFE () 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...
 
std::string getFEName () const
 Get name of the element. More...
 
ForcesAndSourcesCoregetPtrFE () const
 
ForcesAndSourcesCoregetSidePtrFE () const
 
ForcesAndSourcesCoregetRefinePtrFE () const
 
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 getTStimeStep () 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...
 
doublegetMeasure ()
 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 ,
  OPLAST = 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::VolumeElementForcesAndSourcesCore::UserDataOperator
MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
virtual MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
- Protected Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
ForcesAndSourcesCoreptrFE
 

Detailed Description

Calculate explicit derivative of free energy.

Definition at line 459 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 412 of file NonLinearElasticElement.cpp.

417 : VolumeElementForcesAndSourcesCore::UserDataOperator(
418 field_name, UserDataOperator::OPROW),
419 dAta(data), commonData(common_data), tAg(tag), gRadient(gradient),
420 hEssian(hessian), aLe(ale), fieldDisp(field_disp) {}
constexpr auto field_name
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 423 of file NonLinearElasticElement.cpp.

423 {
425 CHKERR dAta.materialAdoublePtr->calculateElasticEnergy(
429}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
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 529 of file NonLinearElasticElement.cpp.

531 {
533
534 // do it only once, no need to repeat this for edges,faces or tets
535 if (row_type != MBVERTEX)
537
538 if (dAta.tEts.find(getNumeredEntFiniteElementPtr()->getEnt()) ==
539 dAta.tEts.end()) {
541 }
542
543 int nb_dofs = row_data.getFieldData().size();
544 if (nb_dofs == 0)
546 dAta.materialAdoublePtr->commonDataPtr = &commonData;
547 dAta.materialAdoublePtr->opPtr = this;
548
549 int nb_gauss_pts = row_data.getN().size1();
550 commonData.eNergy.resize(nb_gauss_pts);
551 commonData.jacEnergy.resize(nb_gauss_pts);
552
554 if (aLe) {
556 }
557
558 for (int gg = 0; gg != nb_gauss_pts; gg++) {
559
560 dAta.materialAdoublePtr->gG = gg;
561
562 // Record tag and calualte stress
564 CHKERR recordTag(gg);
565 }
566
567 activeVariables.resize(nbActiveVariables, false);
568 if (!aLe) {
569 for (int dd1 = 0; dd1 < 3; dd1++) {
570 for (int dd2 = 0; dd2 < 3; dd2++) {
571 activeVariables(dd1 * 3 + dd2) = (*ptrh)[gg](dd1, dd2);
572 }
573 }
574 } else {
575 for (int dd1 = 0; dd1 < 3; dd1++) {
576 for (int dd2 = 0; dd2 < 3; dd2++) {
577 activeVariables(dd1 * 3 + dd2) = (*ptrh)[gg](dd1, dd2);
578 }
579 }
580 for (int dd1 = 0; dd1 < 3; dd1++) {
581 for (int dd2 = 0; dd2 < 3; dd2++) {
582 activeVariables(9 + dd1 * 3 + dd2) = (*ptrH)[gg](dd1, dd2);
583 }
584 }
585 }
586 CHKERR dAta.materialAdoublePtr->setUserActiveVariables(activeVariables);
587
588 // Play tag and calculate stress or tangent
589 CHKERR playTag(gg);
590 }
591
593}
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
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 495 of file NonLinearElasticElement.cpp.

495 {
497
498 if (gRadient) {
499 commonData.jacEnergy[gg].resize(nbActiveVariables, false);
500 int r = ::gradient(tAg, nbActiveVariables, &activeVariables[0],
501 &commonData.jacEnergy[gg][0]);
502 if (r < 0) {
503 // That means that energy function is not smooth and derivative
504 // can not be calculated,
505 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
506 "ADOL-C function evaluation with error");
507 }
508 }
509
510 if (hEssian) {
512 false);
513 double *H[nbActiveVariables];
514 for (int n = 0; n != nbActiveVariables; n++) {
516 }
517 int r = ::hessian(tAg, nbActiveVariables, &*activeVariables.begin(), H);
518 if (r < 0) {
519 // That means that energy function is not smooth and derivative
520 // can not be calculated,
521 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
522 "ADOL-C function evaluation with error");
523 }
524 }
525
527}
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition: definitions.h:34
FTensor::Index< 'n', SPACE_DIM > n
const double r
rate factor
double H
Definition: plastic.cpp:100

◆ recordTag()

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

Record ADOL-C tape.

Returns
error code

Definition at line 432 of file NonLinearElasticElement.cpp.

432 {
434
435 trace_on(tAg, 0);
436
437 if (!aLe) {
438
440 for (int dd1 = 0; dd1 < 3; dd1++) {
441 for (int dd2 = 0; dd2 < 3; dd2++) {
442 dAta.materialAdoublePtr->F(dd1, dd2) <<= (*ptrh)[gg](dd1, dd2);
443 if (fieldDisp) {
444 if (dd1 == dd2) {
445 dAta.materialAdoublePtr->F(dd1, dd2) += 1;
446 }
447 }
449 }
450 }
451
452 } else {
453
455
456 dAta.materialAdoublePtr->h.resize(3, 3, false);
457 for (int dd1 = 0; dd1 < 3; dd1++) {
458 for (int dd2 = 0; dd2 < 3; dd2++) {
459 dAta.materialAdoublePtr->h(dd1, dd2) <<= (*ptrh)[gg](dd1, dd2);
461 }
462 }
463
464 dAta.materialAdoublePtr->H.resize(3, 3, false);
465 for (int dd1 = 0; dd1 < 3; dd1++) {
466 for (int dd2 = 0; dd2 < 3; dd2++) {
467 dAta.materialAdoublePtr->H(dd1, dd2) <<= (*ptrH)[gg](dd1, dd2);
469 }
470 }
471
473 dAta.materialAdoublePtr->invH.resize(3, 3, false);
477
478 auto &t_F = dAta.materialAdoublePtr->t_F;
479 auto &t_h = dAta.materialAdoublePtr->t_h;
480 auto &t_invH = dAta.materialAdoublePtr->t_invH;
481
482 t_F(i, j) = t_h(i, k) * t_invH(k, j);
483
484 }
485
486 CHKERR dAta.materialAdoublePtr->setUserActiveVariables(nbActiveVariables);
488
489 trace_off();
490
492}
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:1323
static auto determinantTensor3by3(T &t)
Calculate the determinant of a 3x3 matrix or a tensor of rank 2.
Definition: Templates.hpp:1312
virtual MoFEMErrorCode calculateEnergy(const int gg)
Calculate Paola-Kirchhoff I stress.

◆ recordTagForIntegrationPoint()

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

Check if tape is recorded for given integration point.

Parameters
ggintegration point
Returns
true if tag is recorded

Definition at line 492 of file NonLinearElasticElement.hpp.

492 {
493 if (gg == 0)
494 return true;
495 return false;
496 }

Member Data Documentation

◆ activeVariables

VectorDouble NonlinearElasticElement::OpJacobianEnergy::activeVariables

Definition at line 477 of file NonLinearElasticElement.hpp.

◆ aLe

bool NonlinearElasticElement::OpJacobianEnergy::aLe

true if arbitrary Lagrangian-Eulerian formulation

Definition at line 468 of file NonLinearElasticElement.hpp.

◆ commonData

CommonData& NonlinearElasticElement::OpJacobianEnergy::commonData

Definition at line 463 of file NonLinearElasticElement.hpp.

◆ dAta

BlockData& NonlinearElasticElement::OpJacobianEnergy::dAta

Definition at line 462 of file NonLinearElasticElement.hpp.

◆ fieldDisp

bool NonlinearElasticElement::OpJacobianEnergy::fieldDisp

true if displacements instead spatial positions used

Definition at line 469 of file NonLinearElasticElement.hpp.

◆ gRadient

bool NonlinearElasticElement::OpJacobianEnergy::gRadient

if set true gradient of energy is calculated

Definition at line 466 of file NonLinearElasticElement.hpp.

◆ hEssian

bool NonlinearElasticElement::OpJacobianEnergy::hEssian

if set true hessian of energy is calculated

Definition at line 467 of file NonLinearElasticElement.hpp.

◆ i

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

Definition at line 483 of file NonLinearElasticElement.hpp.

◆ j

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

Definition at line 484 of file NonLinearElasticElement.hpp.

◆ k

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

Definition at line 485 of file NonLinearElasticElement.hpp.

◆ nbActiveVariables

int NonlinearElasticElement::OpJacobianEnergy::nbActiveVariables

Definition at line 478 of file NonLinearElasticElement.hpp.

◆ ptrh

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

Definition at line 480 of file NonLinearElasticElement.hpp.

◆ ptrH

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

Definition at line 481 of file NonLinearElasticElement.hpp.

◆ tAg

int NonlinearElasticElement::OpJacobianEnergy::tAg

tape tag

Definition at line 465 of file NonLinearElasticElement.hpp.


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