v0.14.0
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
HookeInternalStressElement::OpSaveStress Struct Reference

#include <users_modules/mortar_contact/src/HookeInternalStressElement.hpp>

Inheritance diagram for HookeInternalStressElement::OpSaveStress:
[legend]
Collaboration diagram for HookeInternalStressElement::OpSaveStress:
[legend]

Public Member Functions

 OpSaveStress (const string row_field, const string col_field, boost::shared_ptr< DataAtIntegrationPts > data_at_pts, map< int, BlockData > &block_sets_ptr, moab::Interface &output_mesh, double scale_factor, bool save_mean=false, bool is_ale=false, bool is_field_disp=true)
 
MoFEMErrorCode doWork (int row_side, EntityType row_type, EntData &row_data)
 Operator for linear form, usually to calculate values on right hand side. More...
 
- 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

boost::shared_ptr< DataAtIntegrationPtsdataAtPts
 
map< int, BlockData > & blockSetsPtr
 
moab::Interface & outputMesh
 
bool isALE
 
bool isFieldDisp
 
double scaleFactor
 
bool saveMean
 
- 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)
 
virtual MoFEMErrorCode setPtrFE (ForcesAndSourcesCore *ptr)
 
- Protected Attributes inherited from MoFEM::ForcesAndSourcesCore::UserDataOperator
ForcesAndSourcesCoreptrFE
 

Detailed Description

Examples
mortar_contact_thermal.cpp, and simple_contact_thermal.cpp.

Definition at line 117 of file HookeInternalStressElement.hpp.

Constructor & Destructor Documentation

◆ OpSaveStress()

HookeInternalStressElement::OpSaveStress::OpSaveStress ( const string  row_field,
const string  col_field,
boost::shared_ptr< DataAtIntegrationPts data_at_pts,
map< int, BlockData > &  block_sets_ptr,
moab::Interface &  output_mesh,
double  scale_factor,
bool  save_mean = false,
bool  is_ale = false,
bool  is_field_disp = true 
)
inline

Member Function Documentation

◆ doWork()

MoFEMErrorCode HookeInternalStressElement::OpSaveStress::doWork ( int  side,
EntityType  type,
EntData data 
)
virtual

Operator for linear form, usually to calculate values on right hand side.

Reimplemented from MoFEM::DataOperator.

Examples
HookeInternalStressElement.hpp.

Definition at line 291 of file HookeInternalStressElement.hpp.

292 {
294
295 if (row_type != MBVERTEX) {
297 }
298
299 const EntityHandle ent = getFEEntityHandle();
300
301 auto tensor_to_tensor = [](const auto &t1, auto &t2) {
302 t2(0, 0) = t1(0, 0);
303 t2(1, 1) = t1(1, 1);
304 t2(2, 2) = t1(2, 2);
305 t2(0, 1) = t2(1, 0) = t1(1, 0);
306 t2(0, 2) = t2(2, 0) = t1(2, 0);
307 t2(1, 2) = t2(2, 1) = t1(2, 1);
308 };
309
310 auto tensor_to_vector = [](const auto &t, auto &v) {
311 v(0) = t(0, 0);
312 v(1) = t(1, 1);
313 v(2) = t(2, 2);
314 v(3) = t(0, 1);
315 v(4) = t(0, 2);
316 v(5) = t(1, 2);
317 };
318
319 auto get_tag_handle = [&](auto name, auto size) {
320 Tag th;
321 std::vector<double> def_vals(size, 0.0);
322 CHKERR outputMesh.tag_get_handle(name, size, MB_TYPE_DOUBLE, th,
323 MB_TAG_CREAT | MB_TAG_SPARSE,
324 def_vals.data());
325 return th;
326 };
327
328 const int nb_integration_pts = row_data.getN().size1();
329
330 auto th_internal_stress =
331 get_tag_handle("INTERNAL_STRESS", 9 * nb_integration_pts);
332 auto th_actual_stress =
333 get_tag_handle("ACTUAL_STRESS", 9 * nb_integration_pts);
334 auto th_deviatoric_stress =
335 get_tag_handle("DEVIATORIC_STRESS", 9 * nb_integration_pts);
336 auto th_hydrostatic_stress =
337 get_tag_handle("HYDROSTATIC_STRESS", 9 * nb_integration_pts);
338
339 auto th_internal_stress_mean = get_tag_handle("MED_INTERNAL_STRESS", 9);
340 auto th_actual_stress_mean = get_tag_handle("MED_ACTUAL_STRESS", 9);
341
346
347 auto t_h = getFTensor2FromMat<3, 3>(*dataAtPts->hMat);
348 auto t_H = getFTensor2FromMat<3, 3>(*dataAtPts->HMat);
349
350 dataAtPts->stiffnessMat->resize(36, 1, false);
352 MAT_TO_DDG(dataAtPts->stiffnessMat));
353 for (auto &m : (blockSetsPtr)) {
354 const double young = m.second.E;
355 const double poisson = m.second.PoissonRatio;
356
357 const double coefficient = young / ((1 + poisson) * (1 - 2 * poisson));
358
359 t_D(i, j, k, l) = 0.;
360 t_D(0, 0, 0, 0) = t_D(1, 1, 1, 1) = t_D(2, 2, 2, 2) = 1 - poisson;
361 t_D(0, 1, 0, 1) = t_D(0, 2, 0, 2) = t_D(1, 2, 1, 2) =
362 0.5 * (1 - 2 * poisson);
363 t_D(0, 0, 1, 1) = t_D(1, 1, 0, 0) = t_D(0, 0, 2, 2) = t_D(2, 2, 0, 0) =
364 t_D(1, 1, 2, 2) = t_D(2, 2, 1, 1) = poisson;
365 t_D(i, j, k, l) *= coefficient;
366
367 break; // FIXME: calculates only first block
368 }
369
370 double detH = 0.;
373
375 FTensor::Tensor2_symmetric<double, 3> t_small_strain_symm;
376
378
379 auto t_internal_stress =
380 getFTensor2FromMat<3, 3>(*dataAtPts->internalStressMat);
381
382 dataAtPts->actualStressMat->resize(9, nb_integration_pts, false);
383 auto t_actual_stress = getFTensor2FromMat<3, 3>(*dataAtPts->actualStressMat);
384
385 dataAtPts->deviatoricStressMat->resize(9, nb_integration_pts, false);
386 auto t_deviatoric_stress =
387 getFTensor2FromMat<3, 3>(*dataAtPts->deviatoricStressMat);
388 dataAtPts->hydrostaticStressMat->resize(9, nb_integration_pts, false);
389 auto t_hydrostatic_stress =
390 getFTensor2FromMat<3, 3>(*dataAtPts->hydrostaticStressMat);
391
392 FTensor::Tensor2<double, 3, 3> t_internal_stress_mean;
393 FTensor::Tensor2<double, 3, 3> t_actual_stress_mean;
394
395 t_internal_stress_mean(i, j) = 0.;
396 t_actual_stress_mean(i, j) = 0.;
397
398 auto t_w = getFTensor0IntegrationWeight();
399
400 for (int gg = 0; gg != nb_integration_pts; ++gg) {
401
402 if (!isALE) {
403 t_small_strain_symm(i, j) = (t_h(i, j) || t_h(j, i)) / 2.;
404 } else {
405 CHKERR determinantTensor3by3(t_H, detH);
406 CHKERR invertTensor3by3(t_H, detH, t_invH);
407 t_F(i, j) = t_h(i, k) * t_invH(k, j);
408 t_small_strain_symm(i, j) = (t_F(i, j) || t_F(j, i)) / 2.;
409 ++t_H;
410 }
411
412 if (isALE || !isFieldDisp) {
413 for (auto ii : {0, 1, 2}) {
414 t_small_strain_symm(ii, ii) -= 1.;
415 }
416 }
417
418 // symmetric tensors need improvement
419 t_stress_symm(i, j) = t_D(i, j, k, l) * t_small_strain_symm(k, l);
420 tensor_to_tensor(t_stress_symm, t_stress);
421 t_actual_stress(i, j) = t_stress(i, j) + t_internal_stress(i, j);
422
423 t_actual_stress(i, j) *= scaleFactor;
424 t_internal_stress(i, j) *= scaleFactor;
425
426 double hydrostatic_pressure =
427 (t_actual_stress(0, 0) + t_actual_stress(1, 1) +
428 t_actual_stress(2, 2)) /
429 3.;
430
431 t_hydrostatic_stress(i, j) = 0.;
432 for (auto ii : {0, 1, 2}) {
433 t_hydrostatic_stress(ii, ii) += hydrostatic_pressure;
434 }
435
436 t_deviatoric_stress(i, j) = t_actual_stress(i, j);
437 for (auto ii : {0, 1, 2}) {
438 t_deviatoric_stress(ii, ii) -= hydrostatic_pressure;
439 }
440
441 t_actual_stress_mean(i, j) += t_w * t_actual_stress(i, j);
442 t_internal_stress_mean(i, j) += t_w * t_internal_stress(i, j);
443
444 ++t_w;
445 ++t_h;
446 ++t_actual_stress;
447 ++t_internal_stress;
448 }
449
450 if (saveMean) {
451 VectorDouble vec_actual_stress_mean;
452 vec_actual_stress_mean.resize(9, false);
453 vec_actual_stress_mean.clear();
454
455 VectorDouble vec_internal_stress_mean;
456 vec_internal_stress_mean.resize(9, false);
457 vec_internal_stress_mean.clear();
458
459 tensor_to_vector(t_actual_stress_mean, vec_actual_stress_mean);
460 tensor_to_vector(t_internal_stress_mean, vec_internal_stress_mean);
461
462 CHKERR outputMesh.tag_set_data(th_actual_stress_mean, &ent, 1,
463 &*(vec_actual_stress_mean.data().begin()));
464 CHKERR outputMesh.tag_set_data(th_internal_stress_mean, &ent, 1,
465 &*(vec_internal_stress_mean.data().begin()));
466 } else {
467 CHKERR outputMesh.tag_set_data(
468 th_internal_stress, &ent, 1,
469 &*(dataAtPts->internalStressMat->data().begin()));
470 CHKERR outputMesh.tag_set_data(
471 th_actual_stress, &ent, 1,
472 &*(dataAtPts->actualStressMat->data().begin()));
473
474 CHKERR outputMesh.tag_set_data(
475 th_hydrostatic_stress, &ent, 1,
476 &*(dataAtPts->hydrostaticStressMat->data().begin()));
477 CHKERR outputMesh.tag_set_data(
478 th_deviatoric_stress, &ent, 1,
479 &*(dataAtPts->deviatoricStressMat->data().begin()));
480 }
481
483}
#define MAT_TO_DDG(SM)
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
#define CHKERR
Inline error check.
Definition: definitions.h:535
FTensor::Index< 'm', SPACE_DIM > m
FTensor::Index< 'i', SPACE_DIM > i
const double v
phase velocity of light in medium (cm/ns)
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
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.
Definition: Templates.hpp:1504
static auto determinantTensor3by3(T &t)
Calculate the determinant of a 3x3 matrix or a tensor of rank 2.
Definition: Templates.hpp:1493
constexpr double t
plate stiffness
Definition: plate.cpp:59
EntityHandle getFEEntityHandle() const
Return finite element entity handle.
auto getFTensor0IntegrationWeight()
Get integration weights.

Member Data Documentation

◆ blockSetsPtr

map<int, BlockData>& HookeInternalStressElement::OpSaveStress::blockSetsPtr

◆ dataAtPts

boost::shared_ptr<DataAtIntegrationPts> HookeInternalStressElement::OpSaveStress::dataAtPts

◆ isALE

bool HookeInternalStressElement::OpSaveStress::isALE

◆ isFieldDisp

bool HookeInternalStressElement::OpSaveStress::isFieldDisp

◆ outputMesh

moab::Interface& HookeInternalStressElement::OpSaveStress::outputMesh

◆ saveMean

bool HookeInternalStressElement::OpSaveStress::saveMean

◆ scaleFactor

double HookeInternalStressElement::OpSaveStress::scaleFactor

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