v0.13.1
Public Member Functions | Public Attributes | List of all members
SmallStrainPlasticity::OpCalculateStress Struct Reference

#include <users_modules/small_strain_plasticity/src/SmallStrainPlasticity.hpp>

Inheritance diagram for SmallStrainPlasticity::OpCalculateStress:
[legend]
Collaboration diagram for SmallStrainPlasticity::OpCalculateStress:
[legend]

Public Member Functions

 OpCalculateStress (MoFEM::Interface &m_field, string field_name, CommonData &common_data, ClosestPointProjection &cp, bool is_linear=true)
 
PetscErrorCode getTags ()
 
PetscErrorCode setTagsData (const EntityHandle tet, const int nb_gauss_pts, const int nb_internal_variables)
 
PetscErrorCode doWork (int side, EntityType type, DataForcesAndSourcesCore::EntData &data)
 
- Public Member Functions inherited from MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator
int getNumNodes ()
 get element number of nodes More...
 
const EntityHandle * getConn ()
 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 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

MoFEM::InterfacemField
 
CommonDatacommonData
 
ClosestPointProjectioncP
 
bool initCp
 
bool isLinear
 
bool hessianWCalculated
 
Tag thPlasticStrain
 
Tag thInternalVariables
 
- 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

Definition at line 603 of file SmallStrainPlasticity.hpp.

Constructor & Destructor Documentation

◆ OpCalculateStress()

SmallStrainPlasticity::OpCalculateStress::OpCalculateStress ( MoFEM::Interface m_field,
string  field_name,
CommonData common_data,
ClosestPointProjection cp,
bool  is_linear = true 
)

Member Function Documentation

◆ doWork()

PetscErrorCode SmallStrainPlasticity::OpCalculateStress::doWork ( int  side,
EntityType  type,
DataForcesAndSourcesCore::EntData data 
)
Examples
SmallStrainPlasticity.hpp.

Definition at line 477 of file SmallStrainPlasticity.cpp.

479 {
480 PetscFunctionBegin;
481
482 try {
483
484 //do it only once, no need to repeat this for edges,faces or tets
485 if(type != MBVERTEX) PetscFunctionReturn(0);
486
487 int nb_dofs = data.getFieldData().size();
488 if(nb_dofs==0) PetscFunctionReturn(0);
489
490 int nb_gauss_pts = data.getN().size1();
491 int nb_internal_variables = cP.internalVariables.size();
492 if(!initCp) {
493 ierr = getTags(); CHKERRQ(ierr);
494 }
495 EntityHandle tet = getNumeredEntFiniteElementPtr()->getEnt();
496 ierr = setTagsData(tet,nb_gauss_pts,nb_internal_variables); CHKERRQ(ierr);
497
498 commonData.sTress.resize(nb_gauss_pts);
499 commonData.materialTangentOperator.resize(nb_gauss_pts);
500 commonData.plasticStrain.resize(nb_gauss_pts);
501 commonData.internalVariables.resize(nb_gauss_pts);
502 commonData.internalFluxes.resize(nb_gauss_pts);
503 commonData.deltaGamma.resize(nb_gauss_pts);
504
505 // B-bar
506 double ave_tr_strain = 0;
507 if(commonData.bBar) {
508 double v = 0;
509 for(int gg = 0;gg<nb_gauss_pts;gg++) {
510 double val = getVolume()*getGaussPts()(3,gg);
511 v += val;
512 for(int ii = 0;ii<3;ii++) {
513 ave_tr_strain += val*commonData.gradAtGaussPts[rowFieldName][gg](ii,ii)/3.;
514 }
515 // cerr << commonData.gradAtGaussPts[rowFieldName][gg] << endl;
516 }
517 ave_tr_strain /= v;
518 // cerr << "v " << v << " ave_tr_strain " << ave_tr_strain << endl;
519 }
520
521 for(int gg = 0;gg<nb_gauss_pts;gg++) {
522
523 VectorAdaptor plastic_strain = VectorAdaptor(
524 6,ublas::shallow_array_adaptor<double>(6,&commonData.plasticStrainPtr[gg*6])
525 );
526 VectorAdaptor internal_variables = VectorAdaptor(
527 nb_internal_variables,
528 ublas::shallow_array_adaptor<double>(
529 nb_internal_variables,&commonData.internalVariablesPtr[gg*nb_internal_variables]
530 )
531 );
532
533 cP.sTrain.resize(6,false);
534 {
535 double tr_strain = 0;
536 for(int ii = 0;ii<3;ii++) {
538 tr_strain += cP.sTrain[ii]/3;
539 }
540 if(commonData.bBar) {
541 for(int ii = 0;ii<3;ii++) {
542 cP.sTrain[ii] += ave_tr_strain-tr_strain;
543 }
544 }
545 cP.sTrain[3] =
548 cP.sTrain[4] =
551 cP.sTrain[5] =
554 // cerr << "Grad " << commonData.gradAtGaussPts[rowFieldName][gg] << endl;
555 // cerr << cP.sTrain << endl;
556 }
557
558
559 {
560 cP.plasticStrain0.resize(6,false);
561 noalias(cP.plasticStrain0) = plastic_strain;
562 cP.internalVariables0.resize(nb_internal_variables,false);
563 noalias(cP.internalVariables0) = internal_variables;
564 cP.plasticStrain.resize(6,false);
565 noalias(cP.plasticStrain) = plastic_strain;
566 cP.internalVariables.resize(nb_internal_variables,false);
567 noalias(cP.internalVariables) = internal_variables;
568 cP.deltaGamma = 0;
569 commonData.sTress[gg].clear();
570 commonData.internalFluxes[gg].clear();
571 }
572
573 if(!initCp) {
574 cP.gG = 0;
575 ierr = cP.evaluatePotentials(); CHKERRQ(ierr);
576 } else {
577 cP.gG = 1;
578 ierr = cP.setActiveVariablesW(); CHKERRQ(ierr);
579 if(
580 getFEMethod()->snes_ctx ==
581 SnesMethod::CTX_SNESSETJACOBIAN &&
583 ) {
584 ierr = cP.pLayW(); CHKERRQ(ierr);
585 hessianWCalculated = true;
586 } else {
587 ierr = cP.pLayW_NoHessian(); CHKERRQ(ierr);
588 }
589 ierr = cP.setActiveVariablesYH(); CHKERRQ(ierr);
590 ierr = cP.pLayY_NoGradient(); CHKERRQ(ierr);
591 // cerr << "C " << cP.C << endl;
592 }
593
594 double y = cP.y;
595 if(y>0) {
596 // ierr = PCFactorSetMatSolverPackage(cP.pC,MATSOLVERPETSC); CHKERRQ(ierr);
597 // ierr = KSPMonitorCancel(cP.kSp); CHKERRQ(ierr);
598 // ierr = SNESMonitorCancel(cP.sNes); CHKERRQ(ierr);
599 // ierr = SNESSetTolerances(cP.sNes,cP.tOl,1e-12,0,20,1000); CHKERRQ(ierr);
600 // ierr = SNESLineSearchSetType(cP.lineSearch,SNESLINESEARCHBT); CHKERRQ(ierr);
601 ierr = cP.solveColasetProjection(); CHKERRQ(ierr);
602 }
603
604 {
605 commonData.sTress[gg].resize(6,false);
606 noalias(commonData.sTress[gg]) = cP.sTress;
607 commonData.plasticStrain[gg].resize(6,false);
609 commonData.internalVariables[gg].resize(nb_internal_variables,false);
611 commonData.internalFluxes[gg].resize(nb_internal_variables,false);
614 }
615
616 if(getFEMethod()->snes_ctx == SnesMethod::CTX_SNESSETJACOBIAN) {
617 int iter;
618 ierr = SNESGetIterationNumber(getFEMethod()->snes,&iter); CHKERRQ(ierr);
619 commonData.materialTangentOperator[gg].resize(6,6,false);
620 if(iter>0 && cP.deltaGamma>0) {
621 ierr = cP.consistentTangent(); CHKERRQ(ierr);
623 } else {
624 noalias(commonData.materialTangentOperator[gg]) = cP.C;
625 }
626 }
627
628 if(getFEMethod()->snes_ctx == SnesMethod::CTX_SNESSETFUNCTION) {
629 int iter;
630 ierr = SNESGetIterationNumber(getFEMethod()->snes,&iter); CHKERRQ(ierr);
631 if(iter>1) {
632 ierr = SNESSetLagJacobian(getFEMethod()->snes,1); CHKERRQ(ierr);
633 }
634 }
635
636
637 initCp = true;
638
639 }
640
641 } catch (const std::exception& ex) {
642 ostringstream ss;
643 ss << "throw in method: " << ex.what() << endl;
644 SETERRQ(PETSC_COMM_SELF,1,ss.str().c_str());
645 }
646
647 PetscFunctionReturn(0);
648}
const double v
phase velocity of light in medium (cm/ns)
static MoFEMErrorCodeGeneric< PetscErrorCode > ierr
Definition: Exceptions.hpp:76
VectorShallowArrayAdaptor< double > VectorAdaptor
Definition: Types.hpp:115
boost::shared_ptr< const NumeredEntFiniteElement > getNumeredEntFiniteElementPtr() const
Return raw pointer to NumeredEntFiniteElement.
const FEMethod * getFEMethod() const
Return raw pointer to Finite Element Method object.
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
ublas::symmetric_matrix< double, ublas::lower > C
map< string, vector< MatrixDouble > > gradAtGaussPts
vector< MatrixDouble > materialTangentOperator
PetscErrorCode setTagsData(const EntityHandle tet, const int nb_gauss_pts, const int nb_internal_variables)

◆ getTags()

PetscErrorCode SmallStrainPlasticity::OpCalculateStress::getTags ( )
Examples
SmallStrainPlasticity.hpp.

Definition at line 420 of file SmallStrainPlasticity.cpp.

420 {
421 PetscFunctionBegin;
422
423 rval = mField.get_moab().tag_get_handle(
424 "PLASTIC_STRAIN",thPlasticStrain
425 ); CHKERRQ_MOAB(rval);
426 rval = mField.get_moab().tag_get_handle(
427 "INTERNAL_VARIABLES",thInternalVariables
428 ); CHKERRQ_MOAB(rval);
429 PetscFunctionReturn(0);
430}
#define CHKERRQ_MOAB(a)
check error code of MoAB function
Definition: definitions.h:454
static MoFEMErrorCodeGeneric< moab::ErrorCode > rval
Definition: Exceptions.hpp:74
virtual moab::Interface & get_moab()=0

◆ setTagsData()

PetscErrorCode SmallStrainPlasticity::OpCalculateStress::setTagsData ( const EntityHandle  tet,
const int  nb_gauss_pts,
const int  nb_internal_variables 
)
Examples
SmallStrainPlasticity.hpp.

Definition at line 432 of file SmallStrainPlasticity.cpp.

434 {
435 PetscFunctionBegin;
436
438 {
439 rval = mField.get_moab().tag_get_by_ptr(
441 );
442 if(rval != MB_SUCCESS || commonData.plasticStrainSize != 6*nb_gauss_pts) {
443 v.resize(6*nb_gauss_pts,false);
444 v.clear();
445 int tag_size[1];
446 tag_size[0] = v.size();
447 void const* tag_data[] = { &v[0] };
448 rval = mField.get_moab().tag_set_by_ptr(
449 thPlasticStrain,&tet,1,tag_data,tag_size
450 ); CHKERRQ_MOAB(rval);
451 rval = mField.get_moab().tag_get_by_ptr(
453 ); CHKERRQ_MOAB(rval);
454 }
455 }
456 if(nb_internal_variables>0) {
457 rval = mField.get_moab().tag_get_by_ptr(
459 );
460 if(rval != MB_SUCCESS || commonData.internalVariablesSize != nb_internal_variables*nb_gauss_pts) {
461 v.resize(nb_internal_variables*nb_gauss_pts,false);
462 v.clear();
463 int tag_size[1];
464 tag_size[0] = v.size();
465 void const* tag_data[] = { &v[0] };
466 rval = mField.get_moab().tag_set_by_ptr(
467 thInternalVariables,&tet,1,tag_data,tag_size
468 ); CHKERRQ_MOAB(rval);
469 rval = mField.get_moab().tag_get_by_ptr(
471 );
472 }
473 }
474 PetscFunctionReturn(0);
475}
UBlasVector< double > VectorDouble
Definition: Types.hpp:68

Member Data Documentation

◆ commonData

CommonData& SmallStrainPlasticity::OpCalculateStress::commonData
Examples
SmallStrainPlasticity.hpp.

Definition at line 606 of file SmallStrainPlasticity.hpp.

◆ cP

ClosestPointProjection& SmallStrainPlasticity::OpCalculateStress::cP
Examples
SmallStrainPlasticity.hpp.

Definition at line 607 of file SmallStrainPlasticity.hpp.

◆ hessianWCalculated

bool SmallStrainPlasticity::OpCalculateStress::hessianWCalculated
Examples
SmallStrainPlasticity.hpp.

Definition at line 610 of file SmallStrainPlasticity.hpp.

◆ initCp

bool SmallStrainPlasticity::OpCalculateStress::initCp
Examples
SmallStrainPlasticity.hpp.

Definition at line 609 of file SmallStrainPlasticity.hpp.

◆ isLinear

bool SmallStrainPlasticity::OpCalculateStress::isLinear
Examples
SmallStrainPlasticity.hpp.

Definition at line 610 of file SmallStrainPlasticity.hpp.

◆ mField

MoFEM::Interface& SmallStrainPlasticity::OpCalculateStress::mField
Examples
SmallStrainPlasticity.hpp.

Definition at line 605 of file SmallStrainPlasticity.hpp.

◆ thInternalVariables

Tag SmallStrainPlasticity::OpCalculateStress::thInternalVariables
Examples
SmallStrainPlasticity.hpp.

Definition at line 631 of file SmallStrainPlasticity.hpp.

◆ thPlasticStrain

Tag SmallStrainPlasticity::OpCalculateStress::thPlasticStrain
Examples
SmallStrainPlasticity.hpp.

Definition at line 630 of file SmallStrainPlasticity.hpp.


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