v0.13.1
Loading...
Searching...
No Matches
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 {
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,
57 EntitiesFieldData::EntData &data) {
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
90 VectorDouble Nf;
91 MoFEMErrorCode doWork(int side, EntityType type,
92 EntitiesFieldData::EntData &data) {
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 }
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
199 DEPRECATED inline MoFEMErrorCode addThermalSterssElement(
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
ForcesAndSourcesCore::UserDataOperator UserDataOperator
@ VERBOSE
Definition: definitions.h:209
@ MF_ZERO
Definition: definitions.h:98
#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
@ MAT_ELASTICSET
block name is "MAT_ELASTIC"
Definition: definitions.h:159
@ BLOCKSET
Definition: definitions.h:148
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
@ MOFEM_INVALID_DATA
Definition: definitions.h:36
#define DEPRECATED
Definition: definitions.h:17
#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
static double phi
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
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
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
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string &name_filed)=0
set finite element field data
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
virtual bool check_field(const std::string &name) const =0
check if field is in database
#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet in a moFEM field.
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:10
constexpr auto field_name
#define _F(n)
Definition: quad.c:25
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
Deprecated interface functions.
boost::shared_ptr< const NumeredEntFiniteElement > getNumeredEntFiniteElementPtr() const
Return raw pointer to NumeredEntFiniteElement.
@ OPROW
operator doWork function is executed on FE rows
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
boost::ptr_vector< UserDataOperator > & getOpPtrVector()
Use to push back operator for row operator.
VolumeElementForcesAndSourcesCore(Interface &m_field, const EntityType type=MBTET)
MyVolumeFE(MoFEM::Interface &m_field)
OpGetTemperatureAtGaussPts(const std::string field_name, CommonData &common_data, int _verb=0)
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
OpThermalStressRhs(const std::string field_name, Vec _F, BlockData &data, CommonData &common_data, int _verb=0)
Implentation of thermal stress element.
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")
MyVolumeFE & getLoopThermalStressRhs()
ThermalStressElement(MoFEM::Interface &m_field)
std::map< int, BlockData > setOfBlocks
MoFEM::Interface & mField
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")
MoFEMErrorCode setThermalStressRhsOperators(string field_name, string thermal_field_name, Vec &F, int verb=0)
double ref_temp