v0.14.0
ThermalStressElement.hpp
Go to the documentation of this file.
1 /** \file ThermalStressElement.hpp
2  \ingroup mofem_thermal_elem
3  \brief Implementation of thermal stresses element
4 
5 */
6 
7 
8 
9 #ifndef __THERMALSTRESSELEMENT_HPP
10 #define __THERMALSTRESSELEMENT_HPP
11 
12 /** \brief Implentation of thermal stress element
13 \ingroup mofem_thermal_elem
14 */
16 
20  int getRule(int order) { return 2 * (order - 1); };
21  };
22 
25 
28  : feThermalStressRhs(m_field), mField(m_field) {}
29 
30  struct BlockData {
31  double youngModulus;
32  double poissonRatio;
37  };
38  std::map<int, BlockData> setOfBlocks;
39 
40  struct CommonData {
42  };
44 
47 
49  int verb;
51  CommonData &common_data, int _verb = 0)
52  : MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator(
54  commonData(common_data), verb(_verb) {}
55 
56  MoFEMErrorCode doWork(int side, EntityType type,
59  if (data.getFieldData().size() == 0)
61  int nb_dofs = data.getFieldData().size();
62  int nb_gauss_pts = data.getN().size1();
63  // initialize
64  commonData.temperatureAtGaussPts.resize(nb_gauss_pts);
65  if (type == MBVERTEX) {
66  std::fill(commonData.temperatureAtGaussPts.begin(),
68  }
69  for (int gg = 0; gg < nb_gauss_pts; gg++) {
71  inner_prod(data.getN(gg, nb_dofs), data.getFieldData());
72  }
74  }
75  };
76 
79 
80  Vec F;
83  int verb;
84  OpThermalStressRhs(const std::string field_name, Vec _F, BlockData &data,
85  CommonData &common_data, int _verb = 0)
86  : MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator(
88  F(_F), dAta(data), commonData(common_data), verb(_verb) {}
89 
91  MoFEMErrorCode doWork(int side, EntityType type,
94 
95  if (data.getIndices().size() == 0)
97  if (dAta.tEts.find(getNumeredEntFiniteElementPtr()->getEnt()) ==
98  dAta.tEts.end())
100 
101  const auto &dof_ptr = data.getFieldDofs()[0];
102  int rank = dof_ptr->getNbOfCoeffs();
103  if (rank != 3) {
104  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
105  "data inconsistency");
106  }
107 
108  unsigned int nb_dofs = data.getIndices().size();
109  if (nb_dofs % rank != 0) {
110  SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
111  "data inconsistency");
112  }
113  if (data.getN().size2() < nb_dofs / rank) {
114  SETERRQ3(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
115  "data inconsistency N.size2 %d nb_dof %d rank %d",
116  data.getN().size2(), nb_dofs, rank);
117  }
118 
119  Nf.resize(nb_dofs);
120  bzero(&*Nf.data().begin(), nb_dofs * sizeof(FieldData));
121 
122  if (verb > VERBOSE) {
123  if (type == MBVERTEX) {
124  cout << commonData.temperatureAtGaussPts << std::endl;
125  cout << "thermal expansion " << dAta.thermalExpansion << std::endl;
126  }
127  }
128 
129  for (unsigned int gg = 0; gg < data.getN().size1(); gg++) {
130 
132  SETERRQ(PETSC_COMM_SELF, MOFEM_INVALID_DATA, "invalid data");
133  }
134 
135  double phi =
137  double eps_thermal = dAta.thermalExpansion * phi;
138  double sig_thermal =
139  -eps_thermal * (dAta.youngModulus / (1. - 2 * dAta.poissonRatio));
140 
141  double val = sig_thermal * getVolume() * getGaussPts()(3, gg);
142 
143  double *diff_N;
144  diff_N = &data.getDiffN()(gg, 0);
145  cblas_daxpy(nb_dofs, val, diff_N, 1, &Nf[0], 1);
146  }
147 
148  CHKERR VecSetValues(F, data.getIndices().size(), &data.getIndices()[0],
149  &Nf[0], ADD_VALUES);
150 
152  }
153  };
154 
156  const std::string fe_name, const std::string field_name,
157  const std::string thermal_field_name,
158  const std::string mesh_nodals_positions = "MESH_NODE_POSITIONS") {
160  if (mField.check_field(thermal_field_name)) {
161 
167  thermal_field_name);
168  if (mField.check_field(mesh_nodals_positions)) {
170  fe_name, mesh_nodals_positions);
171  }
173  mField, BLOCKSET | MAT_ELASTICSET, it)) {
174  Mat_Elastic mydata;
175  CHKERR it->getAttributeDataStructure(mydata);
176  setOfBlocks[it->getMeshsetId()].youngModulus = mydata.data.Young;
177  setOfBlocks[it->getMeshsetId()].poissonRatio = mydata.data.Poisson;
178  setOfBlocks[it->getMeshsetId()].thermalExpansion =
179  mydata.data.ThermalExpansion;
180  CHKERR mField.get_moab().get_entities_by_type(
181  it->meshset, MBTET, setOfBlocks[it->getMeshsetId()].tEts, true);
183  setOfBlocks[it->getMeshsetId()].tEts, MBTET, fe_name);
184  double ref_temp;
185  PetscBool flg;
186  CHKERR PetscOptionsGetReal(PETSC_NULL, PETSC_NULL, "-my_ref_temp",
187  &ref_temp, &flg);
188  if (flg == PETSC_TRUE) {
189  PetscPrintf(mField.get_comm(), "set refernce temperature %3.2f\n",
190  ref_temp);
191  setOfBlocks[it->getMeshsetId()].refTemperature = ref_temp;
192  }
193  }
194  }
196  }
197 
198  /// \deprecated Do not use this fiction with spelling mistake
200  const std::string fe_name, const std::string field_name,
201  const std::string thermal_field_name,
202  const std::string mesh_nodals_positions = "MESH_NODE_POSITIONS") {
203  return addThermalStressElement(fe_name, field_name, thermal_field_name,
204  mesh_nodals_positions);
205  }
206 
208  string thermal_field_name, Vec &F,
209  int verb = 0) {
211  if (mField.check_field(thermal_field_name)) {
212  std::map<int, BlockData>::iterator sit = setOfBlocks.begin();
213  for (; sit != setOfBlocks.end(); sit++) {
214  // add finite elemen
216  new OpGetTemperatureAtGaussPts(thermal_field_name, commonData,
217  verb));
219  field_name, F, sit->second, commonData, verb));
220  }
221  }
223  }
224 };
225 
226 #endif //__THERMALSTRESSELEMENT_HPP
ThermalStressElement::OpGetTemperatureAtGaussPts::verb
int verb
Definition: ThermalStressElement.hpp:49
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:447
ThermalStressElement::addThermalSterssElement
DEPRECATED MoFEMErrorCode addThermalSterssElement(const std::string fe_name, const std::string field_name, const std::string thermal_field_name, const std::string mesh_nodals_positions="MESH_NODE_POSITIONS")
Definition: ThermalStressElement.hpp:199
ThermalStressElement::ThermalStressElement
ThermalStressElement(MoFEM::Interface &m_field)
Definition: ThermalStressElement.hpp:27
ThermalStressElement::BlockData
Definition: ThermalStressElement.hpp:30
ThermalStressElement::OpGetTemperatureAtGaussPts::OpGetTemperatureAtGaussPts
OpGetTemperatureAtGaussPts(const std::string field_name, CommonData &common_data, int _verb=0)
Definition: ThermalStressElement.hpp:50
ThermalStressElement::OpGetTemperatureAtGaussPts::commonData
CommonData & commonData
Definition: ThermalStressElement.hpp:48
ThermalStressElement::mField
MoFEM::Interface & mField
Definition: ThermalStressElement.hpp:26
DEPRECATED
#define DEPRECATED
Definition: definitions.h:17
ThermalStressElement::CommonData::temperatureAtGaussPts
VectorDouble temperatureAtGaussPts
Definition: ThermalStressElement.hpp:41
ThermalStressElement::OpGetTemperatureAtGaussPts::doWork
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Definition: ThermalStressElement.hpp:56
MoFEM::CoreInterface::get_comm
virtual MPI_Comm & get_comm() const =0
MoFEM::CoreInterface::modify_finite_element_add_field_row
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
phi
static double phi
Definition: poisson_2d_dis_galerkin.cpp:29
_F
#define _F(n)
Definition: quad.c:25
ThermalStressElement::MyVolumeFE::MyVolumeFE
MyVolumeFE(MoFEM::Interface &m_field)
Definition: ThermalStressElement.hpp:18
ThermalStressElement::OpThermalStressRhs::verb
int verb
Definition: ThermalStressElement.hpp:83
MoFEM::Exceptions::MoFEMErrorCode
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
Definition: Exceptions.hpp:56
_IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_
#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet in a moFEM field.
Definition: MeshsetsManager.hpp:49
ThermalStressElement::addThermalStressElement
MoFEMErrorCode addThermalStressElement(const std::string fe_name, const std::string field_name, const std::string thermal_field_name, const std::string mesh_nodals_positions="MESH_NODE_POSITIONS")
Definition: ThermalStressElement.hpp:155
ref_temp
double ref_temp
Definition: thermo_elastic.cpp:124
ThermalStressElement::CommonData
Definition: ThermalStressElement.hpp:40
ThermalStressElement::OpThermalStressRhs::F
Vec F
Definition: ThermalStressElement.hpp:80
ThermalStressElement::MyVolumeFE::getRule
int getRule(int order)
Definition: ThermalStressElement.hpp:20
ThermalStressElement::BlockData::thermalExpansion
double thermalExpansion
Definition: ThermalStressElement.hpp:33
ThermalStressElement::setThermalStressRhsOperators
MoFEMErrorCode setThermalStressRhsOperators(string field_name, string thermal_field_name, Vec &F, int verb=0)
Definition: ThermalStressElement.hpp:207
ThermalStressElement::BlockData::tEts
Range tEts
Definition: ThermalStressElement.hpp:36
MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator::getVolume
double getVolume() const
element volume (linear geometry)
Definition: VolumeElementForcesAndSourcesCore.hpp:161
MoFEM::VecSetValues
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
Definition: EntitiesFieldData.hpp:1576
order
constexpr int order
Definition: dg_projection.cpp:18
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
MoFEM::ForcesAndSourcesCore::UserDataOperator::getGaussPts
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
Definition: ForcesAndSourcesCore.hpp:1235
MoFEM::VolumeElementForcesAndSourcesCore::VolumeElementForcesAndSourcesCore
VolumeElementForcesAndSourcesCore(Interface &m_field, const EntityType type=MBTET)
Definition: VolumeElementForcesAndSourcesCore.cpp:9
MoFEM::CoreInterface::add_ents_to_finite_element_by_type
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string &name, const bool recursive=true)=0
add entities to finite element
VERBOSE
@ VERBOSE
Definition: definitions.h:209
ThermalStressElement::OpGetTemperatureAtGaussPts
Definition: ThermalStressElement.hpp:45
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:535
MoFEM::CoreInterface::add_finite_element
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
MoFEM::CoreInterface::get_moab
virtual moab::Interface & get_moab()=0
MoFEM
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
MoFEM::CoreInterface::modify_finite_element_add_field_col
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
MoFEM::PetscOptionsGetReal
PetscErrorCode PetscOptionsGetReal(PetscOptions *, const char pre[], const char name[], PetscReal *dval, PetscBool *set)
Definition: DeprecatedPetsc.hpp:152
MoFEM::ForcesAndSourcesCore::UserDataOperator
Definition: ForcesAndSourcesCore.hpp:549
convert.type
type
Definition: convert.py:64
ThermalStressElement::OpThermalStressRhs::Nf
VectorDouble Nf
Definition: ThermalStressElement.hpp:90
ThermalStressElement::OpThermalStressRhs::OpThermalStressRhs
OpThermalStressRhs(const std::string field_name, Vec _F, BlockData &data, CommonData &common_data, int _verb=0)
Definition: ThermalStressElement.hpp:84
MAT_ELASTICSET
@ MAT_ELASTICSET
block name is "MAT_ELASTIC"
Definition: definitions.h:159
ThermalStressElement::BlockData::youngModulus
double youngModulus
Definition: ThermalStressElement.hpp:31
MoFEM::ForcesAndSourcesCore::UserDataOperator::getNumeredEntFiniteElementPtr
boost::shared_ptr< const NumeredEntFiniteElement > getNumeredEntFiniteElementPtr() const
Return raw pointer to NumeredEntFiniteElement.
Definition: ForcesAndSourcesCore.hpp:999
ThermalStressElement::MyVolumeFE
Definition: ThermalStressElement.hpp:17
MoFEM::CoreInterface::check_field
virtual bool check_field(const std::string &name) const =0
check if field is in database
ThermalStressElement::OpThermalStressRhs
Definition: ThermalStressElement.hpp:77
MoFEM::VolumeElementForcesAndSourcesCore
Volume finite element base.
Definition: VolumeElementForcesAndSourcesCore.hpp:26
ThermalStressElement::OpThermalStressRhs::dAta
BlockData & dAta
Definition: ThermalStressElement.hpp:81
ThermalStressElement::feThermalStressRhs
MyVolumeFE feThermalStressRhs
Definition: ThermalStressElement.hpp:23
MoFEM::VolumeElementForcesAndSourcesCore::UserDataOperator
Definition: VolumeElementForcesAndSourcesCore.hpp:108
ThermalStressElement::BlockData::BlockData
BlockData()
Definition: ThermalStressElement.hpp:35
ThermalStressElement::BlockData::poissonRatio
double poissonRatio
Definition: ThermalStressElement.hpp:32
EntData
EntitiesFieldData::EntData EntData
Definition: child_and_parent.cpp:37
field_name
constexpr auto field_name
Definition: poisson_2d_homogeneous.cpp:13
ThermalStressElement::OpThermalStressRhs::doWork
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
Definition: ThermalStressElement.hpp:91
ThermalStressElement::commonData
CommonData commonData
Definition: ThermalStressElement.hpp:43
Range
MF_ZERO
@ MF_ZERO
Definition: definitions.h:98
ThermalStressElement::OpThermalStressRhs::commonData
CommonData & commonData
Definition: ThermalStressElement.hpp:82
BLOCKSET
@ BLOCKSET
Definition: definitions.h:148
ThermalStressElement::setOfBlocks
std::map< int, BlockData > setOfBlocks
Definition: ThermalStressElement.hpp:38
MoFEM::ForcesAndSourcesCore::getOpPtrVector
boost::ptr_deque< UserDataOperator > & getOpPtrVector()
Use to push back operator for row operator.
Definition: ForcesAndSourcesCore.hpp:83
MoFEM::Types::FieldData
double FieldData
Field data type.
Definition: Types.hpp:25
EigenMatrix::Vec
const FTensor::Tensor2< T, Dim, Dim > Vec
Definition: MatrixFunction.hpp:66
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::CoreInterface::modify_finite_element_add_field_data
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_filed)=0
set finite element field data
MoFEM::Types::VectorDouble
UBlasVector< double > VectorDouble
Definition: Types.hpp:68
ThermalStressElement::getLoopThermalStressRhs
MyVolumeFE & getLoopThermalStressRhs()
Definition: ThermalStressElement.hpp:24
ThermalStressElement::BlockData::refTemperature
double refTemperature
Definition: ThermalStressElement.hpp:34
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:416
ThermalStressElement
Implentation of thermal stress element.
Definition: ThermalStressElement.hpp:15
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:346
MOFEM_INVALID_DATA
@ MOFEM_INVALID_DATA
Definition: definitions.h:36
F
@ F
Definition: free_surface.cpp:394
MoFEM::ForcesAndSourcesCore::UserDataOperator::OPROW
@ OPROW
operator doWork function is executed on FE rows
Definition: ForcesAndSourcesCore.hpp:567