v0.15.0
Loading...
Searching...
No Matches
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.
 
virtual MoFEMErrorCode calculateEnergy (const int gg)
 Calculate Paola-Kirchhoff I stress.
 
virtual MoFEMErrorCode recordTag (const int gg)
 Record ADOL-C tape.
 
virtual MoFEMErrorCode playTag (const int gg)
 Play ADOL-C tape.
 
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
 
const EntityHandlegetConn ()
 get element connectivity
 
double getVolume () const
 element volume (linear geometry)
 
doublegetVolume ()
 element volume (linear geometry)
 
FTensor::Tensor2< double *, 3, 3 > & getJac ()
 get element Jacobian
 
FTensor::Tensor2< double *, 3, 3 > & getInvJac ()
 get element inverse Jacobian
 
VectorDoublegetCoords ()
 nodal coordinates
 
VolumeElementForcesAndSourcesCoregetVolumeFE () const
 return pointer to Generic Volume Finite Element object
 
- 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.
 
EntityHandle getFEEntityHandle () const
 Return finite element entity handle.
 
int getFEDim () const
 Get dimension of finite element.
 
EntityType getFEType () const
 Get dimension of finite element.
 
boost::weak_ptr< SideNumbergetSideNumberPtr (const int side_number, const EntityType type)
 Get the side number pointer.
 
EntityHandle getSideEntity (const int side_number, const EntityType type)
 Get the side entity.
 
int getNumberOfNodesOnElement () const
 Get the number of nodes on finite element.
 
MoFEMErrorCode getProblemRowIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get row indices.
 
MoFEMErrorCode getProblemColIndices (const std::string filed_name, const EntityType type, const int side, VectorInt &indices) const
 Get col indices.
 
const FEMethodgetFEMethod () const
 Return raw pointer to Finite Element Method object.
 
int getOpType () const
 Get operator types.
 
void setOpType (const OpType type)
 Set operator type.
 
void addOpType (const OpType type)
 Add operator type.
 
int getNinTheLoop () const
 get number of finite element in the loop
 
int getLoopSize () const
 get size of elements in the loop
 
std::string getFEName () const
 Get name of the element.
 
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
 
auto getFTensor0IntegrationWeight ()
 Get integration weights.
 
MatrixDoublegetCoordsAtGaussPts ()
 Gauss points and weight, matrix (nb. of points x 3)
 
auto getFTensor1CoordsAtGaussPts ()
 Get coordinates at integration points assuming linear geometry.
 
double getMeasure () const
 get measure of element
 
doublegetMeasure ()
 get measure of element
 
MoFEMErrorCode loopSide (const string &fe_name, ForcesAndSourcesCore *side_fe, const size_t dim, const EntityHandle ent_for_side=0, boost::shared_ptr< Range > fe_range=nullptr, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy, AdjCache *adj_cache=nullptr)
 User calls this function to loop over elements on the side of face. This function calls finite element with its operator to do calculations.
 
MoFEMErrorCode loopThis (const string &fe_name, ForcesAndSourcesCore *this_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over the same element using a different set of integration points. This function calls finite element with its operator to do calculations.
 
MoFEMErrorCode loopParent (const string &fe_name, ForcesAndSourcesCore *parent_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations.
 
MoFEMErrorCode loopChildren (const string &fe_name, ForcesAndSourcesCore *child_fe, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 User calls this function to loop over parent elements. This function calls finite element with its operator to do calculations.
 
MoFEMErrorCode loopRange (const string &fe_name, ForcesAndSourcesCore *range_fe, boost::shared_ptr< Range > fe_range, const int verb=QUIET, const LogManager::SeverityLevel sev=Sev::noisy)
 Iterate over range of elements.
 
- 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.
 
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.
 
virtual MoFEMErrorCode opRhs (EntitiesFieldData &data, const bool error_if_no_base=false)
 
bool getSymm () const
 Get if operator uses symmetry of DOFs or not.
 
void setSymm ()
 set if operator is executed taking in account symmetry
 
void unSetSymm ()
 unset if operator is executed for non symmetric problem
 

Public Attributes

BlockDatadAta
 
CommonDatacommonData
 
int tAg
 tape tag
 
bool gRadient
 if set true gradient of energy is calculated
 
bool hEssian
 if set true hessian of energy is calculated
 
bool aLe
 true if arbitrary Lagrangian-Eulerian formulation
 
bool fieldDisp
 true if displacements instead spatial positions used
 
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.
 
std::array< bool, MBMAXTYPE > doEntities
 If true operator is executed for entity.
 
booldoVertices
 \deprectaed If false skip vertices
 
booldoEdges
 \deprectaed If false skip edges
 
booldoQuads
 \deprectaed
 
booldoTris
 \deprectaed
 
booldoTets
 \deprectaed
 
booldoPrisms
 \deprectaed
 

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...
 
using AdjCache
 
- Public Types inherited from MoFEM::DataOperator
using DoWorkLhsHookFunType
 
using DoWorkRhsHookFunType
 
- 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)
 
- Protected Member Functions inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
- 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 410 of file NonLinearElasticElement.cpp.

415 : VolumeElementForcesAndSourcesCore::UserDataOperator(
416 field_name, UserDataOperator::OPROW),
417 dAta(data), commonData(common_data), tAg(tag), gRadient(gradient),
418 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 421 of file NonLinearElasticElement.cpp.

421 {
423 CHKERR dAta.materialAdoublePtr->calculateElasticEnergy(
427}
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
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 527 of file NonLinearElasticElement.cpp.

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

493 {
495
496 if (gRadient) {
497 commonData.jacEnergy[gg].resize(nbActiveVariables, false);
498 int r = ::gradient(tAg, nbActiveVariables, &activeVariables[0],
499 &commonData.jacEnergy[gg][0]);
500 if (r < 0) {
501 // That means that energy function is not smooth and derivative
502 // can not be calculated,
503 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
504 "ADOL-C function evaluation with error");
505 }
506 }
507
508 if (hEssian) {
510 false);
511 double *H[nbActiveVariables];
512 for (int n = 0; n != nbActiveVariables; n++) {
514 }
515 int r = ::hessian(tAg, nbActiveVariables, &*activeVariables.begin(), H);
516 if (r < 0) {
517 // That means that energy function is not smooth and derivative
518 // can not be calculated,
519 SETERRQ(PETSC_COMM_SELF, MOFEM_OPERATION_UNSUCCESSFUL,
520 "ADOL-C function evaluation with error");
521 }
522 }
523
525}
@ MOFEM_OPERATION_UNSUCCESSFUL
Definition definitions.h:34
const double n
refractive index of diffusive medium
int r
Definition sdf.py:8
double H
Hardening.
Definition plastic.cpp:128

◆ recordTag()

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

Record ADOL-C tape.

Returns
error code

Definition at line 430 of file NonLinearElasticElement.cpp.

430 {
432
433 trace_on(tAg, 0);
434
435 if (!aLe) {
436
438 for (int dd1 = 0; dd1 < 3; dd1++) {
439 for (int dd2 = 0; dd2 < 3; dd2++) {
440 dAta.materialAdoublePtr->F(dd1, dd2) <<= (*ptrh)[gg](dd1, dd2);
441 if (fieldDisp) {
442 if (dd1 == dd2) {
443 dAta.materialAdoublePtr->F(dd1, dd2) += 1;
444 }
445 }
447 }
448 }
449
450 } else {
451
453
454 dAta.materialAdoublePtr->h.resize(3, 3, false);
455 for (int dd1 = 0; dd1 < 3; dd1++) {
456 for (int dd2 = 0; dd2 < 3; dd2++) {
457 dAta.materialAdoublePtr->h(dd1, dd2) <<= (*ptrh)[gg](dd1, dd2);
459 }
460 }
461
462 dAta.materialAdoublePtr->H.resize(3, 3, false);
463 for (int dd1 = 0; dd1 < 3; dd1++) {
464 for (int dd2 = 0; dd2 < 3; dd2++) {
465 dAta.materialAdoublePtr->H(dd1, dd2) <<= (*ptrH)[gg](dd1, dd2);
467 }
468 }
469
471 dAta.materialAdoublePtr->invH.resize(3, 3, false);
475
476 auto &t_F = dAta.materialAdoublePtr->t_F;
477 auto &t_h = dAta.materialAdoublePtr->t_h;
478 auto &t_invH = dAta.materialAdoublePtr->t_invH;
479
480 t_F(i, j) = t_h(i, k) * t_invH(k, j);
481
482 }
483
484 CHKERR dAta.materialAdoublePtr->setUserActiveVariables(nbActiveVariables);
486
487 trace_off();
488
490}
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.
static auto determinantTensor3by3(T &t)
Calculate the determinant of a 3x3 matrix or a tensor of rank 2.
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 481 of file NonLinearElasticElement.hpp.

◆ ptrh

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

Definition at line 480 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: