v0.14.0
Public Member Functions | Public Attributes | List of all members
BoneRemodeling::OpPostProcStress Struct Reference

Used to post proc stresses, energy, source term. More...

#include <users_modules/bone_remodelling/src/Remodeling.hpp>

Inheritance diagram for BoneRemodeling::OpPostProcStress:
[legend]
Collaboration diagram for BoneRemodeling::OpPostProcStress:
[legend]

Public Member Functions

 OpPostProcStress (moab::Interface &post_proc_mesh, std::vector< EntityHandle > &map_gauss_pts, Remodeling::CommonData &common_data)
 
MoFEMErrorCode 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 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, 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. More...
 
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. More...
 
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. More...
 
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. 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

Remodeling::CommonDatacommonData
 
moab::Interface & postProcMesh
 
std::vector< EntityHandle > & mapGaussPts
 
- 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...
 
using AdjCache = std::map< EntityHandle, std::vector< boost::weak_ptr< NumeredEntFiniteElement > >>
 
- 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)
 
- Protected Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
ForcesAndSourcesCoreptrFE
 

Detailed Description

Used to post proc stresses, energy, source term.

calculation of principal stresses. for e.g.

Definition at line 374 of file Remodeling.hpp.

Constructor & Destructor Documentation

◆ OpPostProcStress()

OpPostProcStress::OpPostProcStress ( moab::Interface &  post_proc_mesh,
std::vector< EntityHandle > &  map_gauss_pts,
Remodeling::CommonData common_data 
)
Examples
Remodeling.hpp.

Definition at line 550 of file Remodeling.cpp.

554  "DISPLACEMENTS", UserDataOperator::OPROW),
555  commonData(common_data), postProcMesh(post_proc_mesh),
556  mapGaussPts(map_gauss_pts) {
557  // Set that this operator is executed only for vertices on element
558  doVertices = true;
559  doEdges = false;
560  doQuads = false;
561  doTris = false;
562  doTets = false;
563  doPrisms = false;
564 }

Member Function Documentation

◆ doWork()

MoFEMErrorCode OpPostProcStress::doWork ( int  side,
EntityType  type,
DataForcesAndSourcesCore::EntData data 
)
Examples
Remodeling.hpp.

Definition at line 567 of file Remodeling.cpp.

568  {
569 
571 
572  if (type != MBVERTEX)
574  double def_VAL[9];
575  bzero(def_VAL, 9 * sizeof(double));
576 
577  Tag th_piola2;
578  CHKERR postProcMesh.tag_get_handle("Piola_Stress2", 9, MB_TYPE_DOUBLE,
579  th_piola2, MB_TAG_CREAT | MB_TAG_SPARSE,
580  def_VAL);
581 
582  Tag th_psi;
583  CHKERR postProcMesh.tag_get_handle("psi", 1, MB_TYPE_DOUBLE, th_psi,
584  MB_TAG_CREAT | MB_TAG_SPARSE, def_VAL);
585 
586  Tag th_rho;
587  CHKERR postProcMesh.tag_get_handle("RHO", 1, MB_TYPE_DOUBLE, th_rho,
588  MB_TAG_CREAT | MB_TAG_SPARSE, def_VAL);
589 
590  Tag th_piola1;
591  Tag principal;
592  Tag th_prin_stress_vect1, th_prin_stress_vect2, th_prin_stress_vect3;
593  Tag th_R;
594  Tag th_grad_rho;
595  if (!commonData.less_post_proc) {
596 
597  CHKERR postProcMesh.tag_get_handle("Piola_Stress1", 9, MB_TYPE_DOUBLE,
598  th_piola1, MB_TAG_CREAT | MB_TAG_SPARSE,
599  def_VAL);
600 
601  CHKERR postProcMesh.tag_get_handle("Principal_stress", 3, MB_TYPE_DOUBLE,
602  principal, MB_TAG_CREAT | MB_TAG_SPARSE,
603  def_VAL);
604 
605  CHKERR postProcMesh.tag_get_handle("Principal_stress_S1", 3, MB_TYPE_DOUBLE,
606  th_prin_stress_vect1,
607  MB_TAG_CREAT | MB_TAG_SPARSE, def_VAL);
608  CHKERR postProcMesh.tag_get_handle("Principal_stress_S2", 3, MB_TYPE_DOUBLE,
609  th_prin_stress_vect2,
610  MB_TAG_CREAT | MB_TAG_SPARSE, def_VAL);
611  CHKERR postProcMesh.tag_get_handle("Principal_stress_S3", 3, MB_TYPE_DOUBLE,
612  th_prin_stress_vect3,
613  MB_TAG_CREAT | MB_TAG_SPARSE, def_VAL);
614 
615  CHKERR postProcMesh.tag_get_handle("R", 1, MB_TYPE_DOUBLE, th_R,
616  MB_TAG_CREAT | MB_TAG_SPARSE, def_VAL);
617 
618  CHKERR postProcMesh.tag_get_handle("grad_rho", 3, MB_TYPE_DOUBLE,
619  th_grad_rho,
620  MB_TAG_CREAT | MB_TAG_SPARSE, def_VAL);
621  }
622 
623  const int nb_gauss_pts = commonData.data.gradDispPtr->size2();
626  auto P = getFTensor2FromMat<3, 3>(commonData.data.matP);
629 
631  auto grad_rho = getFTensor1FromMat<3>(*commonData.data.gradRhoPtr);
632 
633  MatrixDouble3by3 stress(3, 3);
634  VectorDouble3 eigen_values(3);
635  MatrixDouble3by3 eigen_vectors(3, 3);
636 
637  for (int gg = 0; gg != nb_gauss_pts; gg++) {
638 
639  double val = psi;
640  CHKERR postProcMesh.tag_set_data(th_psi, &mapGaussPts[gg], 1, &val);
641  val = rho;
642  CHKERR postProcMesh.tag_set_data(th_rho, &mapGaussPts[gg], 1, &val);
643 
644  // S is symmetric tensor, need to map it to non-symmetric tensor to save it
645  // on moab tag to be viable in paraview.
646  for (int ii = 0; ii != 3; ii++) {
647  for (int jj = 0; jj != 3; jj++) {
648  stress(ii, jj) = S(ii, jj);
649  }
650  }
651  CHKERR postProcMesh.tag_set_data(th_piola2, &mapGaussPts[gg], 1,
652  &stress(0, 0));
653 
654  if (!commonData.less_post_proc) {
655 
656  for (int ii = 0; ii != 3; ii++) {
657  for (int jj = 0; jj != 3; jj++) {
658  stress(ii, jj) = P(ii, jj);
659  }
660  }
661  CHKERR postProcMesh.tag_set_data(th_piola1, &mapGaussPts[gg], 1,
662  &stress(0, 0));
663  val = R;
664  CHKERR postProcMesh.tag_set_data(th_R, &mapGaussPts[gg], 1, &val);
665  const double t2[] = {grad_rho(0), grad_rho(1), grad_rho(2)};
666  CHKERR postProcMesh.tag_set_data(th_grad_rho, &mapGaussPts[gg], 1, t2);
667 
668  // Add calculation of eigen values, i.e. prinple stresses.
669  noalias(eigen_vectors) = stress;
670  VectorDouble3 prin_stress_vect1(3);
671  VectorDouble3 prin_stress_vect2(3);
672  VectorDouble3 prin_stress_vect3(3);
673  // LAPACK - eigenvalues and vectors. Applied twice for initial creates
674  // memory space
675  int n = 3, lda = 3, info, lwork = -1;
676  double wkopt;
677  info = lapack_dsyev('V', 'U', n, &(eigen_vectors.data()[0]), lda,
678  &(eigen_values.data()[0]), &wkopt, lwork);
679  if (info != 0)
680  SETERRQ1(PETSC_COMM_SELF, 1,
681  "something is wrong with lapack_dsyev info = %d", info);
682  lwork = (int)wkopt;
683  double work[lwork];
684  info = lapack_dsyev('V', 'U', n, &(eigen_vectors.data()[0]), lda,
685  &(eigen_values.data()[0]), work, lwork);
686  if (info != 0)
687  SETERRQ1(PETSC_COMM_SELF, 1,
688  "something is wrong with lapack_dsyev info = %d", info);
689 
690  for (int ii = 0; ii < 3; ii++) {
691  prin_stress_vect1[ii] = eigen_vectors(0, ii);
692  prin_stress_vect2[ii] = eigen_vectors(1, ii);
693  prin_stress_vect3[ii] = eigen_vectors(2, ii);
694  }
695 
696  CHKERR postProcMesh.tag_set_data(principal, &mapGaussPts[gg], 1,
697  &eigen_values[0]);
698  CHKERR postProcMesh.tag_set_data(th_prin_stress_vect1, &mapGaussPts[gg],
699  1, &*prin_stress_vect1.begin());
700  CHKERR postProcMesh.tag_set_data(th_prin_stress_vect2, &mapGaussPts[gg],
701  1, &*prin_stress_vect2.begin());
702  CHKERR postProcMesh.tag_set_data(th_prin_stress_vect3, &mapGaussPts[gg],
703  1, &*prin_stress_vect3.begin());
704  }
705 
706  ++S;
707  ++P;
708  ++psi;
709  ++R;
710  ++rho;
711  ++grad_rho;
712  }
713 
715 }

Member Data Documentation

◆ commonData

Remodeling::CommonData& BoneRemodeling::OpPostProcStress::commonData
Examples
Remodeling.hpp.

Definition at line 377 of file Remodeling.hpp.

◆ mapGaussPts

std::vector<EntityHandle>& BoneRemodeling::OpPostProcStress::mapGaussPts
Examples
Remodeling.hpp.

Definition at line 379 of file Remodeling.hpp.

◆ postProcMesh

moab::Interface& BoneRemodeling::OpPostProcStress::postProcMesh
Examples
Remodeling.hpp.

Definition at line 378 of file Remodeling.hpp.


The documentation for this struct was generated from the following files:
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
MoFEM::DataOperator::doTris
bool & doTris
\deprectaed
Definition: DataOperators.hpp:93
MoFEM::Types::VectorDouble3
VectorBoundedArray< double, 3 > VectorDouble3
Definition: Types.hpp:92
rho
double rho
Definition: plastic.cpp:191
MoFEM::Types::MatrixDouble
UBlasMatrix< double > MatrixDouble
Definition: Types.hpp:77
BoneRemodeling::OpPostProcStress::postProcMesh
moab::Interface & postProcMesh
Definition: Remodeling.hpp:378
BoneRemodeling::Remodeling::CommonData::DataContainers::vecR
VectorDouble vecR
Mass sorce.
Definition: Remodeling.hpp:192
MoFEM::DataOperator::doPrisms
bool & doPrisms
\deprectaed
Definition: DataOperators.hpp:95
MoFEM::DataOperator::doTets
bool & doTets
\deprectaed
Definition: DataOperators.hpp:94
FTensor::Tensor2_symmetric
Definition: Tensor2_symmetric_value.hpp:13
BoneRemodeling::Remodeling::CommonData::DataContainers::rhoPtr
boost::shared_ptr< VectorDouble > rhoPtr
Ptr to density matrix container.
Definition: Remodeling.hpp:187
MoFEM::DataOperator::doVertices
bool & doVertices
\deprectaed If false skip vertices
Definition: DataOperators.hpp:90
BoneRemodeling::Remodeling::CommonData::DataContainers::gradDispPtr
boost::shared_ptr< MatrixDouble > gradDispPtr
Ptr to gradient of displacements matrix container.
Definition: Remodeling.hpp:185
BoneRemodeling::Remodeling::CommonData::less_post_proc
PetscBool less_post_proc
reduce file size
Definition: Remodeling.hpp:163
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
SYMMETRIC_TENSOR2_MAT_PTR
#define SYMMETRIC_TENSOR2_MAT_PTR(MAT)
Definition: Remodeling.cpp:54
R
@ R
Definition: free_surface.cpp:394
BoneRemodeling::Remodeling::CommonData::DataContainers::gradRhoPtr
boost::shared_ptr< MatrixDouble > gradRhoPtr
Gradient of density field.
Definition: Remodeling.hpp:188
convert.type
type
Definition: convert.py:64
MoFEM::getFTensor0FromVec
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
Definition: Templates.hpp:135
EshelbianPlasticity::P
@ P
Definition: EshelbianContact.cpp:193
BoneRemodeling::Remodeling::CommonData::DataContainers::vecPsi
VectorDouble vecPsi
Elastic energy density.
Definition: Remodeling.hpp:189
MoFEM::DataOperator::doQuads
bool & doQuads
\deprectaed
Definition: DataOperators.hpp:92
convert.n
n
Definition: convert.py:82
MoFEM::DataOperator::doEdges
bool & doEdges
\deprectaed If false skip edges
Definition: DataOperators.hpp:91
BoneRemodeling::OpPostProcStress::mapGaussPts
std::vector< EntityHandle > & mapGaussPts
Definition: Remodeling.hpp:379
BoneRemodeling::Remodeling::CommonData::DataContainers::matP
MatrixDouble matP
1st Piola stress
Definition: Remodeling.hpp:191
UserDataOperator
ForcesAndSourcesCore::UserDataOperator UserDataOperator
Definition: HookeElement.hpp:75
lapack_dsyev
static __CLPK_integer lapack_dsyev(char jobz, char uplo, __CLPK_integer n, __CLPK_doublereal *a, __CLPK_integer lda, __CLPK_doublereal *w, __CLPK_doublereal *work, __CLPK_integer lwork)
Definition: lapack_wrap.h:261
MoFEM::Types::MatrixDouble3by3
MatrixBoundedArray< double, 9 > MatrixDouble3by3
Definition: Types.hpp:105
BoneRemodeling::OpPostProcStress::commonData
Remodeling::CommonData & commonData
Definition: Remodeling.hpp:377
BoneRemodeling::Remodeling::CommonData::DataContainers::matS
MatrixDouble matS
2nd Piola stress
Definition: Remodeling.hpp:190
BoneRemodeling::Remodeling::CommonData::data
DataContainers data
Definition: Remodeling.hpp:203
convert.int
int
Definition: convert.py:64
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
MoFEM::ForcesAndSourcesCore::UserDataOperator::OPROW
@ OPROW
operator doWork function is executed on FE rows
Definition: ForcesAndSourcesCore.hpp:567