v0.16.0
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
PostProcStress Struct Reference

#include "users_modules/basic_finite_elements/src/PostProcStresses.hpp"

Inheritance diagram for PostProcStress:
[legend]
Collaboration diagram for PostProcStress:
[legend]

Public Member Functions

 PostProcStress (moab::Interface &post_proc_mesh, std::vector< EntityHandle > &map_gauss_pts, Range &post_proc_elements, const std::string field_name, NonlinearElasticElement::BlockData &data, boost::shared_ptr< MatrixDouble > field_values_ptr, boost::shared_ptr< MatrixDouble > mesh_positions_ptr, boost::shared_ptr< MatrixDouble > field_gradient_ptr, const std::string mesh_positions_field_name="MESH_NODE_POSITIONS", const bool field_disp=false, const bool replace_nonanumber_by_max_value=false, const double max_val=1e16, const bool print_cauchy_stress=false)
 
MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 
- Public Member Functions inherited from MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator
int getNumNodes ()
 get element number of nodes
 
const EntityHandle * getConn ()
 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)
 Constructor for operators working on finite element spaces.
 
 UserDataOperator (const std::string field_name, const char type, const bool symm=true)
 Constructor for operators working on a single field.
 
 UserDataOperator (const std::string row_field_name, const std::string col_field_name, const char type, const bool symm=true)
 Constructor for operators working on two fields (bilinear forms)
 
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
 
KspMethod::KSPContext getKSPCtx () const
 
SnesMethod::SNESContext getSNESCtx () 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
 
MoFEM::InterfacegetMField ()
 
moab::Interface & getMoab ()
 
virtual boost::weak_ptr< ForcesAndSourcesCoregetSubPipelinePtr () const
 
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

moab::Interface & postProcMesh
 
std::vector< EntityHandle > & mapGaussPts
 
RangepostProcElements
 
NonlinearElasticElement::BlockDatadAta
 
boost::shared_ptr< MatrixDouble > fieldValuesPtr
 
boost::shared_ptr< MatrixDouble > meshPositionsPtr
 
boost::shared_ptr< MatrixDouble > fieldGradientPtr
 
const std::string meshPositionsFieldName
 
const bool fieldDisp
 
const bool replaceNonANumberByMaxValue
 
const double maxVal
 
const bool printCauchy
 
NonlinearElasticElement::CommonData nonLinearElementCommonData
 
- 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 = 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

Examples
mofem/users_modules/basic_finite_elements/nonlinear_elastic_materials/src/NonlinearElasticElementInterface.hpp, mofem/users_modules/basic_finite_elements/nonlinear_elasticity/nonlinear_dynamics.cpp, and mofem/users_modules/bone_remodelling/src/impl/Remodeling.cpp.

Definition at line 17 of file PostProcStresses.hpp.

Constructor & Destructor Documentation

◆ PostProcStress()

PostProcStress::PostProcStress ( moab::Interface &  post_proc_mesh,
std::vector< EntityHandle > &  map_gauss_pts,
Range post_proc_elements,
const std::string  field_name,
NonlinearElasticElement::BlockData data,
boost::shared_ptr< MatrixDouble >  field_values_ptr,
boost::shared_ptr< MatrixDouble >  mesh_positions_ptr,
boost::shared_ptr< MatrixDouble >  field_gradient_ptr,
const std::string  mesh_positions_field_name = "MESH_NODE_POSITIONS",
const bool  field_disp = false,
const bool  replace_nonanumber_by_max_value = false,
const double  max_val = 1e16,
const bool  print_cauchy_stress = false 
)
inline

Definition at line 34 of file PostProcStresses.hpp.

49 field_name, ForcesAndSourcesCore::UserDataOperator::OPROW),
50 postProcMesh(post_proc_mesh), mapGaussPts(map_gauss_pts),
51 postProcElements(post_proc_elements), dAta(data),
52 fieldValuesPtr(field_values_ptr), meshPositionsPtr(mesh_positions_ptr),
53 fieldGradientPtr(field_gradient_ptr),
54 meshPositionsFieldName(mesh_positions_field_name),
55 fieldDisp(field_disp),
56 replaceNonANumberByMaxValue(replace_nonanumber_by_max_value),
57 maxVal(max_val), printCauchy(print_cauchy_stress) {}
constexpr auto field_name
NonlinearElasticElement::BlockData & dAta
const bool replaceNonANumberByMaxValue
std::vector< EntityHandle > & mapGaussPts
boost::shared_ptr< MatrixDouble > fieldGradientPtr
const double maxVal
boost::shared_ptr< MatrixDouble > meshPositionsPtr
boost::shared_ptr< MatrixDouble > fieldValuesPtr
moab::Interface & postProcMesh
const std::string meshPositionsFieldName

Member Function Documentation

◆ doWork()

MoFEMErrorCode PostProcStress::doWork ( int  side,
EntityType  type,
EntitiesFieldData::EntData &  data 
)
inline

Definition at line 61 of file PostProcStresses.hpp.

62 {
64
65 if (type != MBVERTEX)
67 if (data.getIndices().size() == 0)
69 if (dAta.tEts.find(getNumeredEntFiniteElementPtr()->getEnt()) ==
70 dAta.tEts.end()) {
72 }
73
74 const auto &dof_ptr = data.getFieldDofs()[0];
75
76 int id = dAta.iD;
77
78 Tag th_id;
79 int def_block_id = -1;
80 CHKERR postProcMesh.tag_get_handle("BLOCK_ID", 1, MB_TYPE_INTEGER, th_id,
81 MB_TAG_CREAT | MB_TAG_SPARSE,
82 &def_block_id);
83 CHKERR postProcMesh.tag_clear_data(th_id, postProcElements, &id);
84
85 string tag_name_piola1 = dof_ptr->getName() + "_PIOLA1_STRESS";
86 string tag_name_energy = dof_ptr->getName() + "_ENERGY_DENSITY";
87
88 int tag_length = 9;
89 double def_VAL[tag_length];
90 bzero(def_VAL, tag_length * sizeof(double));
91 Tag th_piola1, th_energy, th_cauchy;
92 CHKERR postProcMesh.tag_get_handle(tag_name_piola1.c_str(), tag_length,
93 MB_TYPE_DOUBLE, th_piola1,
94 MB_TAG_CREAT | MB_TAG_SPARSE, def_VAL);
95 CHKERR postProcMesh.tag_get_handle(tag_name_energy.c_str(), 1,
96 MB_TYPE_DOUBLE, th_energy,
97 MB_TAG_CREAT | MB_TAG_SPARSE, def_VAL);
98
99 if (printCauchy) {
100 string tag_name_cauchy = "MED_" + dof_ptr->getName() + "_CAUCHY_STRESS";
101 CHKERR postProcMesh.tag_get_handle(tag_name_cauchy.c_str(), tag_length,
102 MB_TYPE_DOUBLE, th_cauchy,
103 MB_TAG_CREAT | MB_TAG_SPARSE, def_VAL);
104 }
105
106 int nb_gauss_pts = data.getN().size1();
107 if (mapGaussPts.size() != (unsigned int)nb_gauss_pts) {
108 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
109 "Nb. of integration points is not equal to number points on "
110 "post-processing mesh");
111 }
112 if (!fieldGradientPtr ||
113 fieldGradientPtr->size1() != (unsigned int)nb_gauss_pts ||
114 fieldGradientPtr->size2() != 9) {
115 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
116 "Gradient of field not found, filed <%s> not found",
117 rowFieldName.c_str());
118 }
119
120 auto make_field_values = [](auto values_ptr) {
121 std::vector<VectorDouble> values;
122 if (!values_ptr)
123 return values;
124 values.resize(values_ptr->size1());
125 for (size_t gg = 0; gg != values_ptr->size1(); ++gg) {
126 values[gg].resize(values_ptr->size2(), false);
127 for (size_t rr = 0; rr != values_ptr->size2(); ++rr) {
128 values[gg][rr] = (*values_ptr)(gg, rr);
129 }
130 }
131 return values;
132 };
133
134 auto make_gradients = [](auto gradient_ptr) {
135 std::vector<MatrixDouble> gradients;
136 if (!gradient_ptr)
137 return gradients;
138 const size_t field_rank = gradient_ptr->size2() / 3;
139 gradients.resize(gradient_ptr->size1());
140 for (size_t gg = 0; gg != gradient_ptr->size1(); ++gg) {
141 gradients[gg].resize(field_rank, 3, false);
142 for (size_t rr = 0; rr != field_rank; ++rr) {
143 for (size_t cc = 0; cc != 3; ++cc) {
144 gradients[gg](rr, cc) = (*gradient_ptr)(gg, 3 * rr + cc);
145 }
146 }
147 }
148 return gradients;
149 };
150
151 std::map<std::string, std::vector<VectorDouble>> field_map{
152 {rowFieldName, make_field_values(fieldValuesPtr)},
153 {meshPositionsFieldName, make_field_values(meshPositionsPtr)}};
154 std::map<std::string, std::vector<MatrixDouble>> gradient_map{
155 {rowFieldName, make_gradients(fieldGradientPtr)}};
156
157 MatrixDouble3by3 H, invH;
158 double detH;
159
161 dAta.materialDoublePtr->opPtr = this;
162 CHKERR dAta.materialDoublePtr->getDataOnPostProcessor(field_map,
163 gradient_map);
164
167
168 MatrixDouble3by3 maxP(3, 3);
169 maxP.clear();
170
171 for (int gg = 0; gg != nb_gauss_pts; ++gg) {
172
173 dAta.materialDoublePtr->gG = gg;
174 dAta.materialDoublePtr->F.resize(3, 3);
175 noalias(dAta.materialDoublePtr->F) =
176 gradient_map[rowFieldName][gg];
177 if (fieldDisp) {
178 for (int dd = 0; dd != 3; dd++) {
179 dAta.materialDoublePtr->F(dd, dd) += 1;
180 }
181 }
182 if (gradient_map[meshPositionsFieldName].size() ==
183 (unsigned int)nb_gauss_pts) {
184 H.resize(3, 3);
185 invH.resize(3, 3);
186 noalias(H) = gradient_map[meshPositionsFieldName][gg];
187 detH = determinantTensor3by3(H);
188 CHKERR invertTensor3by3(H, detH, invH);
189 noalias(dAta.materialDoublePtr->F) =
190 prod(dAta.materialDoublePtr->F, invH);
191 }
192
193 int nb_active_variables = 9;
194 CHKERR dAta.materialDoublePtr->setUserActiveVariables(
195 nb_active_variables);
196 CHKERR dAta.materialDoublePtr->calculateP_PiolaKirchhoffI(
198 CHKERR dAta.materialDoublePtr->calculateElasticEnergy(
200 CHKERR postProcMesh.tag_set_data(th_piola1, &mapGaussPts[gg], 1,
201 &dAta.materialDoublePtr->P(0, 0));
202 CHKERR postProcMesh.tag_set_data(th_energy, &mapGaussPts[gg], 1,
203 &dAta.materialDoublePtr->eNergy);
204 if (printCauchy) {
205 dAta.materialDoublePtr->sigmaCauchy.resize(3, 3);
206 CHKERR dAta.materialDoublePtr->calculateCauchyStress(
208 CHKERR postProcMesh.tag_set_data(
209 th_cauchy, &mapGaussPts[gg], 1,
210 &dAta.materialDoublePtr->sigmaCauchy(0, 0));
211 }
212 }
213
215 MatrixDouble3by3 P(3, 3);
216 for (int gg = 0; gg != nb_gauss_pts; ++gg) {
217 double val_energy;
218 CHKERR postProcMesh.tag_get_data(th_energy, &mapGaussPts[gg], 1,
219 &val_energy);
220 if (!std::isnormal(val_energy)) {
221 CHKERR postProcMesh.tag_set_data(th_energy, &mapGaussPts[gg], 1,
222 &maxVal);
223 CHKERR postProcMesh.tag_get_data(th_piola1, &mapGaussPts[gg], 1,
224 &P(0, 0));
225 for (unsigned int r = 0; r != P.size1(); ++r) {
226 for (unsigned int c = 0; c != P.size2(); ++c) {
227 if (!std::isnormal(P(r, c)))
228 P(r, c) = copysign(maxVal, P(r, c));
229 }
230 }
231 CHKERR postProcMesh.tag_set_data(th_piola1, &mapGaussPts[gg], 1,
232 &P(0, 0));
233 }
234 }
235 }
236
238 }
std::string type
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
const double c
speed of light (cm/ns)
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition ddTensor0.hpp:33
MatrixBoundedArray< double, 9 > MatrixDouble3by3
Definition Types.hpp:105
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.
MoFEMErrorCode determinantTensor3by3(T1 &t, T2 &det)
Calculate determinant 3 by 3.
int r
Definition sdf.py:205
boost::shared_ptr< const NumeredEntFiniteElement > getNumeredEntFiniteElementPtr() const
Return raw pointer to NumeredEntFiniteElement.
boost::shared_ptr< FunctionsToCalculatePiolaKirchhoffI< double > > materialDoublePtr
Range tEts
constrains elements in block set
std::map< std::string, std::vector< VectorDouble > > dataAtGaussPts
std::map< std::string, std::vector< MatrixDouble > > gradAtGaussPts
NonlinearElasticElement::CommonData nonLinearElementCommonData
double H
Hardening.
Definition plastic.cpp:129

Member Data Documentation

◆ dAta

NonlinearElasticElement::BlockData& PostProcStress::dAta

Definition at line 24 of file PostProcStresses.hpp.

◆ fieldDisp

const bool PostProcStress::fieldDisp

Definition at line 29 of file PostProcStresses.hpp.

◆ fieldGradientPtr

boost::shared_ptr<MatrixDouble> PostProcStress::fieldGradientPtr

Definition at line 27 of file PostProcStresses.hpp.

◆ fieldValuesPtr

boost::shared_ptr<MatrixDouble> PostProcStress::fieldValuesPtr

Definition at line 25 of file PostProcStresses.hpp.

◆ mapGaussPts

std::vector<EntityHandle>& PostProcStress::mapGaussPts

Definition at line 21 of file PostProcStresses.hpp.

◆ maxVal

const double PostProcStress::maxVal

Definition at line 31 of file PostProcStresses.hpp.

◆ meshPositionsFieldName

const std::string PostProcStress::meshPositionsFieldName

Definition at line 28 of file PostProcStresses.hpp.

◆ meshPositionsPtr

boost::shared_ptr<MatrixDouble> PostProcStress::meshPositionsPtr

Definition at line 26 of file PostProcStresses.hpp.

◆ nonLinearElementCommonData

NonlinearElasticElement::CommonData PostProcStress::nonLinearElementCommonData

Definition at line 59 of file PostProcStresses.hpp.

◆ postProcElements

Range& PostProcStress::postProcElements

Definition at line 22 of file PostProcStresses.hpp.

◆ postProcMesh

moab::Interface& PostProcStress::postProcMesh

Definition at line 20 of file PostProcStresses.hpp.

◆ printCauchy

const bool PostProcStress::printCauchy

Definition at line 32 of file PostProcStresses.hpp.

◆ replaceNonANumberByMaxValue

const bool PostProcStress::replaceNonANumberByMaxValue

Definition at line 30 of file PostProcStresses.hpp.


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