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

Operator post-procesing stresses for Hook isotropic material. More...

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

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

Public Member Functions

 PostProcHookStress (MoFEM::Interface &m_field, moab::Interface &post_proc_mesh, std::vector< EntityHandle > &map_gauss_pts, Range &post_proc_elements, const std::string field_name, boost::shared_ptr< MatrixDouble > field_gradient_ptr, const bool is_field_disp=true)
 
MoFEMErrorCode getMatParameters (double *_lambda, double *_mu, int *_block_id)
 get material parameter
 
MoFEMErrorCode doWork (int side, EntityType type, EntitiesFieldData::EntData &data)
 Here real work is done.
 
- 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

MoFEM::InterfacemField
 
moab::Interface & postProcMesh
 
std::vector< EntityHandle > & mapGaussPts
 
RangepostProcElements
 
bool isFieldDisp
 
boost::shared_ptr< MatrixDouble > fieldGradientPtr
 
- 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

Operator post-procesing stresses for Hook isotropic material.

Example how to use it

PostProcBrokenMeshInMoab<VolumeElementForcesAndSourcesCore> post_proc(m_field);
{
auto disp_ptr = boost::make_shared<MatrixDouble>();
auto disp_grad_ptr = boost::make_shared<MatrixDouble>();
post_proc.getOpPtrVector().push_back(
new OpCalculateVectorFieldValues<3>("DISPLACEMENT", disp_ptr));
post_proc.getOpPtrVector().push_back(
new OpCalculateVectorFieldGradient<3, 3>(
"DISPLACEMENT", disp_grad_ptr));
//add postprocessing for stresses
post_proc.getOpPtrVector().push_back(
m_field,
post_proc.getPostProcMesh(),
post_proc.getMapGaussPts(),
post_proc.getPostProcElements(),
"DISPLACEMENT",
disp_grad_ptr,
&elastic.setOfBlocks
)
);
using OpPPMap = OpPostProcMapInMoab<3, 3>;
post_proc.getOpPtrVector().push_back(
new OpPPMap(post_proc.getPostProcMesh(), post_proc.getMapGaussPts(),
{}, {{"DISPLACEMENT", disp_ptr}},
{{"DISPLACEMENT_GRAD", disp_grad_ptr}}, {}));
CHKERR DMoFEMLoopFiniteElements(dm,"ELASTIC",&post_proc);
CHKERR post_proc.writeFile("out.h5m");
}
#define CHKERR
Inline error check.
PetscErrorCode DMoFEMLoopFiniteElements(DM dm, const char fe_name[], MoFEM::FEMethod *method, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr())
Executes FEMethod for finite elements in DM.
Definition DMMoFEM.cpp:576
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
Post post-proc data at points from hash maps.
Operator post-procesing stresses for Hook isotropic material.
Examples
mofem/users_modules/basic_finite_elements/elasticity/elasticity.cpp.

Definition at line 49 of file PostProcHookStresses.hpp.

Constructor & Destructor Documentation

◆ PostProcHookStress()

PostProcHookStress::PostProcHookStress ( MoFEM::Interface m_field,
moab::Interface &  post_proc_mesh,
std::vector< EntityHandle > &  map_gauss_pts,
Range post_proc_elements,
const std::string  field_name,
boost::shared_ptr< MatrixDouble >  field_gradient_ptr,
const bool  is_field_disp = true 
)
inline

Constructor

Definition at line 69 of file PostProcHookStresses.hpp.

80 field_name, ForcesAndSourcesCore::UserDataOperator::OPROW),
81 mField(m_field), postProcMesh(post_proc_mesh),
82 mapGaussPts(map_gauss_pts), postProcElements(post_proc_elements),
83#ifdef __NONLINEAR_ELASTIC_HPP
84 setOfBlocksMaterialDataPtr(set_of_block_data_ptr),
85#endif //__NONLINEAR_ELASTIC_HPP
86 fieldGradientPtr(field_gradient_ptr), isFieldDisp(is_field_disp) {
87 }
constexpr auto field_name
boost::shared_ptr< MatrixDouble > fieldGradientPtr
moab::Interface & postProcMesh
MoFEM::Interface & mField
std::vector< EntityHandle > & mapGaussPts

Member Function Documentation

◆ doWork()

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

Here real work is done.

Definition at line 151 of file PostProcHookStresses.hpp.

152 {
154
155 if (type != MBVERTEX)
157 if (data.getFieldData().size() == 0)
159
160 int id;
161 double lambda, mu;
163
164 MatrixDouble D_lambda, D_mu, D;
165 D_lambda.resize(6, 6);
166 D_lambda.clear();
167 for (int rr = 0; rr < 3; rr++) {
168 for (int cc = 0; cc < 3; cc++) {
169 D_lambda(rr, cc) = 1;
170 }
171 }
172 D_mu.resize(6, 6);
173 D_mu.clear();
174 for (int rr = 0; rr < 6; rr++) {
175 D_mu(rr, rr) = rr < 3 ? 2 : 1;
176 }
177 D = lambda * D_lambda + mu * D_mu;
178
179 int tag_length = 9;
180 double def_VAL[tag_length];
181 bzero(def_VAL, tag_length * sizeof(double));
182 Tag th_stress;
183 CHKERR postProcMesh.tag_get_handle("STRESS", 9, MB_TYPE_DOUBLE, th_stress,
184 MB_TAG_CREAT | MB_TAG_SPARSE, def_VAL);
185
186 Tag th_id;
187 int def_block_id = -1;
188 CHKERR postProcMesh.tag_get_handle("BLOCK_ID", 1, MB_TYPE_INTEGER, th_id,
189 MB_TAG_CREAT | MB_TAG_SPARSE,
190 &def_block_id);
191 CHKERR postProcMesh.tag_clear_data(th_id, postProcElements, &id);
192
193 VectorDouble strain;
194 VectorDouble stress;
195 MatrixDouble Stress;
196
197 int nb_gauss_pts = data.getN().size1();
198 if (mapGaussPts.size() != (unsigned int)nb_gauss_pts)
199 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY, "data inconsistency");
200
201 if (!fieldGradientPtr ||
202 fieldGradientPtr->size1() != (unsigned int)nb_gauss_pts ||
203 fieldGradientPtr->size2() != 9) {
204 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
205 "Gradient of field %s is not available", rowFieldName.c_str());
206 }
207 const auto &gradient = *fieldGradientPtr;
208
209 for (int gg = 0; gg != nb_gauss_pts; ++gg) {
210
211 strain.resize(6);
212 strain[0] = gradient(gg, 0);
213 strain[1] = gradient(gg, 4);
214 strain[2] = gradient(gg, 8);
215 strain[3] = gradient(gg, 1) + gradient(gg, 3);
216 strain[4] = gradient(gg, 5) + gradient(gg, 7);
217 strain[5] = gradient(gg, 2) + gradient(gg, 6);
218
219 if (!isFieldDisp) {
220 strain[0] -= 1.0;
221 strain[1] -= 1.0;
222 strain[2] -= 1.0;
223 }
224
225 stress.resize(6);
226 noalias(stress) = prod(D, strain);
227
228 Stress.resize(3, 3);
229 Stress(0, 0) = stress[0];
230 Stress(1, 1) = stress[1];
231 Stress(2, 2) = stress[2];
232 Stress(0, 1) = Stress(1, 0) = stress[3];
233 Stress(1, 2) = Stress(2, 1) = stress[4];
234 Stress(2, 0) = Stress(0, 2) = stress[5];
235
236 CHKERR postProcMesh.tag_set_data(th_stress, &mapGaussPts[gg], 1,
237 &Stress(0, 0));
238 }
239
241 }
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()
static double lambda
double D
UBlasMatrix< double > MatrixDouble
Definition Types.hpp:77
UBlasVector< double > VectorDouble
Definition Types.hpp:68
MoFEMErrorCode getMatParameters(double *_lambda, double *_mu, int *_block_id)
get material parameter

◆ getMatParameters()

MoFEMErrorCode PostProcHookStress::getMatParameters ( double _lambda,
double _mu,
int *  _block_id 
)
inline

get material parameter

Material parameters are read form BlockSet, however if block data are present, use data how are set for elastic element operators.

Parameters
_lambdaelastic material constant
_muelastic material constant
_block_idblock id
Returns
error code

Definition at line 102 of file PostProcHookStresses.hpp.

103 {
105
106 *_lambda = 1;
107 *_mu = 1;
108
109 EntityHandle ent = getNumeredEntFiniteElementPtr()->getEnt();
112 Mat_Elastic mydata;
113 CHKERR it->getAttributeDataStructure(mydata);
114
115 Range meshsets;
116 CHKERR mField.get_moab().get_entities_by_type(it->meshset, MBENTITYSET,
117 meshsets, false);
118 meshsets.insert(it->meshset);
119 for (Range::iterator mit = meshsets.begin(); mit != meshsets.end();
120 mit++) {
121 if (mField.get_moab().contains_entities(*mit, &ent, 1)) {
122 *_lambda = LAMBDA(mydata.data.Young, mydata.data.Poisson);
123 *_mu = MU(mydata.data.Young, mydata.data.Poisson);
124 *_block_id = it->getMeshsetId();
125#ifdef __NONLINEAR_ELASTIC_HPP
126 if (setOfBlocksMaterialDataPtr) {
127 *_lambda =
128 LAMBDA(setOfBlocksMaterialDataPtr->at(*_block_id).E,
129 setOfBlocksMaterialDataPtr->at(*_block_id).PoissonRatio);
130 *_mu = MU(setOfBlocksMaterialDataPtr->at(*_block_id).E,
131 setOfBlocksMaterialDataPtr->at(*_block_id).PoissonRatio);
132 }
133#endif //__NONLINEAR_ELASTIC_HPP
135 }
136 }
137 }
138
139 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
140 "Element is not in elastic block, however you run linear elastic "
141 "analysis with that element\n"
142 "top tip: check if you update block sets after mesh refinements or "
143 "interface insertion");
144
146 }
@ MAT_ELASTICSET
block name is "MAT_ELASTIC"
@ BLOCKSET
#define MU(E, NU)
Definition fem_tools.h:23
#define LAMBDA(E, NU)
Definition fem_tools.h:22
#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet in a moFEM field.
virtual moab::Interface & get_moab()=0
boost::shared_ptr< const NumeredEntFiniteElement > getNumeredEntFiniteElementPtr() const
Return raw pointer to NumeredEntFiniteElement.

Member Data Documentation

◆ fieldGradientPtr

boost::shared_ptr<MatrixDouble> PostProcHookStress::fieldGradientPtr

Definition at line 64 of file PostProcHookStresses.hpp.

◆ isFieldDisp

bool PostProcHookStress::isFieldDisp

Definition at line 56 of file PostProcHookStresses.hpp.

◆ mapGaussPts

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

Definition at line 54 of file PostProcHookStresses.hpp.

◆ mField

MoFEM::Interface& PostProcHookStress::mField

Definition at line 52 of file PostProcHookStresses.hpp.

◆ postProcElements

Range& PostProcHookStress::postProcElements

Definition at line 55 of file PostProcHookStresses.hpp.

◆ postProcMesh

moab::Interface& PostProcHookStress::postProcMesh

Definition at line 53 of file PostProcHookStresses.hpp.


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