v0.15.0
Loading...
Searching...
No Matches
EshelbianPlasticity::EshelbianMonitor Struct Reference
Inheritance diagram for EshelbianPlasticity::EshelbianMonitor:
[legend]
Collaboration diagram for EshelbianPlasticity::EshelbianMonitor:
[legend]

Public Types

using Ele = ForcesAndSourcesCore
 
using VolEle = VolumeElementForcesAndSourcesCore
 
using VolOp = VolumeElementForcesAndSourcesCore::UserDataOperator
 
using SetPtsData = FieldEvaluatorInterface::SetPtsData
 
using PtsHashMap = std::map<std::string, std::array<double, 3>>
 
using FaceSideEle
 
- Public Types inherited from MoFEM::KspMethod
enum  KSPContext { CTX_SETFUNCTION , CTX_OPERATORS , CTX_KSPNONE }
 pass information about context of KSP/DM for with finite element is computed More...
 
- Public Types inherited from MoFEM::PetscData
enum  DataContext {
  CTX_SET_NONE = 0 , CTX_SET_F = 1 << 0 , CTX_SET_A = 1 << 1 , CTX_SET_B = 1 << 2 ,
  CTX_SET_X = 1 << 3 , CTX_SET_DX = 1 << 4 , CTX_SET_X_T = 1 << 5 , CTX_SET_X_TT = 1 << 6 ,
  CTX_SET_TIME = 1 << 7
}
 
using Switches = std::bitset<8>
 
- Public Types inherited from MoFEM::SnesMethod
enum  SNESContext { CTX_SNESSETFUNCTION , CTX_SNESSETJACOBIAN , CTX_SNESNONE }
 
- Public Types inherited from MoFEM::TSMethod
enum  TSContext {
  CTX_TSSETRHSFUNCTION , CTX_TSSETRHSJACOBIAN , CTX_TSSETIFUNCTION , CTX_TSSETIJACOBIAN ,
  CTX_TSTSMONITORSET , CTX_TSNONE
}
 
- Public Types inherited from MoFEM::TaoMethod
enum  TAOContext { CTX_TAO_OBJECTIVE , CTX_TAO_GRADIENT , CTX_TAO_HESSIAN , CTX_TAO_NONE }
 

Public Member Functions

 EshelbianMonitor (EshelbianCore &ep)
 
MoFEMErrorCode preProcess ()
 function is run at the beginning of loop
 
MoFEMErrorCode operator() ()
 function is run for every finite element
 
MoFEMErrorCode postProcess ()
 function is run at the end of loop
 
- Public Member Functions inherited from MoFEM::FEMethod
MoFEMErrorCode query_interface (boost::typeindex::type_index type_index, UnknownInterface **iface) const
 
 FEMethod ()=default
 
auto getFEName () const
 get finite element name
 
auto getDataDofsPtr () const
 
auto getDataVectorDofsPtr () const
 
const FieldEntity_vector_viewgetDataFieldEnts () const
 
boost::shared_ptr< FieldEntity_vector_view > & getDataFieldEntsPtr () const
 
auto & getRowFieldEnts () const
 
auto & getRowFieldEntsPtr () const
 
auto & getColFieldEnts () const
 
auto & getColFieldEntsPtr () const
 
auto getRowDofsPtr () const
 
auto getColDofsPtr () const
 
auto getNumberOfNodes () const
 
EntityHandle getFEEntityHandle () const
 
MoFEMErrorCode getNodeData (const std::string field_name, VectorDouble &data, const bool reset_dofs=true)
 
- Public Member Functions inherited from MoFEM::BasicMethod
 BasicMethod ()
 
virtual ~BasicMethod ()=default
 
int getNinTheLoop () const
 get number of evaluated element in the loop
 
int getLoopSize () const
 get loop size
 
auto getLoHiFERank () const
 Get lo and hi processor rank of iterated entities.
 
auto getLoFERank () const
 Get upper rank in loop for iterating elements.
 
auto getHiFERank () const
 Get upper rank in loop for iterating elements.
 
unsigned int getFieldBitNumber (std::string field_name) const
 
MoFEMErrorCode copyBasicMethod (const BasicMethod &basic)
 Copy data from other base method to this base method.
 
boost::weak_ptr< CacheTuplegetCacheWeakPtr () const
 Get the cache weak ptr object.
 
- Public Member Functions inherited from MoFEM::KspMethod
MoFEMErrorCode query_interface (boost::typeindex::type_index type_index, UnknownInterface **iface) const
 
 KspMethod ()
 
virtual ~KspMethod ()=default
 
MoFEMErrorCode copyKsp (const KspMethod &ksp)
 copy data form another method
 
- Public Member Functions inherited from MoFEM::PetscData
 PetscData ()
 
virtual ~PetscData ()=default
 
MoFEMErrorCode copyPetscData (const PetscData &petsc_data)
 
- Public Member Functions inherited from MoFEM::UnknownInterface
template<class IFACE >
MoFEMErrorCode registerInterface (bool error_if_registration_failed=true)
 Register interface.
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE *&iface) const
 Get interface reference to pointer of interface.
 
template<class IFACE >
MoFEMErrorCode getInterface (IFACE **const iface) const
 Get interface pointer to pointer of interface.
 
template<class IFACE , typename boost::enable_if< boost::is_pointer< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get interface pointer to pointer of interface.
 
template<class IFACE , typename boost::enable_if< boost::is_reference< IFACE >, int >::type = 0>
IFACE getInterface () const
 Get reference to interface.
 
template<class IFACE >
IFACE * getInterface () const
 Function returning pointer to interface.
 
virtual ~UnknownInterface ()=default
 
- Public Member Functions inherited from MoFEM::SnesMethod
MoFEMErrorCode query_interface (boost::typeindex::type_index type_index, UnknownInterface **iface) const
 
 SnesMethod ()
 
virtual ~SnesMethod ()=default
 
MoFEMErrorCode copySnes (const SnesMethod &snes)
 Copy snes data.
 
- Public Member Functions inherited from MoFEM::TSMethod
MoFEMErrorCode query_interface (boost::typeindex::type_index type_index, UnknownInterface **iface) const
 
 TSMethod ()
 
virtual ~TSMethod ()=default
 
MoFEMErrorCode copyTs (const TSMethod &ts)
 Copy TS solver data.
 
- Public Member Functions inherited from MoFEM::TaoMethod
MoFEMErrorCode query_interface (boost::typeindex::type_index type_index, UnknownInterface **iface) const
 
 TaoMethod ()
 
virtual ~TaoMethod ()=default
 
MoFEMErrorCode copyTao (const TaoMethod &tao)
 Copy TAO data.
 

Public Attributes

EshelbianCoreeP
 
boost::shared_ptr< SetPtsDatadataFieldEval
 
boost::shared_ptr< VolElevolPostProcEnergy
 
boost::shared_ptr< doublegEnergy
 
PtsHashMap ptsHashMap
 
PetscBool writeRestart = PETSC_FALSE
 
- Public Attributes inherited from MoFEM::FEMethod
std::string feName
 Name of finite element.
 
boost::shared_ptr< const NumeredEntFiniteElementnumeredEntFiniteElementPtr
 
boost::function< bool(FEMethod *fe_method_ptr)> exeTestHook
 Tet if element to skip element.
 
- Public Attributes inherited from MoFEM::BasicMethod
int nInTheLoop
 number currently of processed method
 
int loopSize
 local number oe methods to process
 
std::pair< int, int > loHiFERank
 Llo and hi processor rank of iterated entities.
 
int rAnk
 processor rank
 
int sIze
 number of processors in communicator
 
const RefEntity_multiIndexrefinedEntitiesPtr
 container of mofem dof entities
 
const RefElement_multiIndexrefinedFiniteElementsPtr
 container of mofem finite element entities
 
const ProblemproblemPtr
 raw pointer to problem
 
const Field_multiIndexfieldsPtr
 raw pointer to fields container
 
const FieldEntity_multiIndexentitiesPtr
 raw pointer to container of field entities
 
const DofEntity_multiIndexdofsPtr
 raw pointer container of dofs
 
const FiniteElement_multiIndexfiniteElementsPtr
 raw pointer to container finite elements
 
const EntFiniteElement_multiIndexfiniteElementsEntitiesPtr
 
const FieldEntityEntFiniteElementAdjacencyMap_multiIndexadjacenciesPtr
 
boost::function< MoFEMErrorCode()> preProcessHook
 Hook function for pre-processing.
 
boost::function< MoFEMErrorCode()> postProcessHook
 Hook function for post-processing.
 
boost::function< MoFEMErrorCode()> operatorHook
 Hook function for operator.
 
boost::movelib::unique_ptr< boolvecAssembleSwitch
 
boost::movelib::unique_ptr< boolmatAssembleSwitch
 
boost::weak_ptr< CacheTuplecacheWeakPtr
 
- Public Attributes inherited from MoFEM::KspMethod
KSPContext ksp_ctx
 Context.
 
KSP ksp
 KSP solver.
 
Vec & ksp_f
 
Mat & ksp_A
 
Mat & ksp_B
 
- Public Attributes inherited from MoFEM::PetscData
Switches data_ctx
 
Vec f
 
Mat A
 
Mat B
 
Vec x
 
Vec dx
 
Vec x_t
 
Vec x_tt
 
- Public Attributes inherited from MoFEM::SnesMethod
SNESContext snes_ctx
 
SNES snes
 snes solver
 
Vec & snes_x
 state vector
 
Vec & snes_dx
 solution update
 
Vec & snes_f
 residual
 
Mat & snes_A
 jacobian matrix
 
Mat & snes_B
 preconditioner of jacobian matrix
 
- Public Attributes inherited from MoFEM::TSMethod
TS ts
 time solver
 
TSContext ts_ctx
 
PetscInt ts_step
 time step number
 
PetscReal ts_a
 shift for U_t (see PETSc Time Solver)
 
PetscReal ts_aa
 shift for U_tt shift for U_tt
 
PetscReal ts_t
 time
 
PetscReal ts_dt
 time step size
 
Vec & ts_u
 state vector
 
Vec & ts_u_t
 time derivative of state vector
 
Vec & ts_u_tt
 second time derivative of state vector
 
Vec & ts_F
 residual vector
 
Mat & ts_A
 
Mat & ts_B
 Preconditioner for ts_A.
 
- Public Attributes inherited from MoFEM::TaoMethod
TAOContext tao_ctx
 
Tao tao
 tao solver
 
Vec & tao_x
 
Vec & tao_f
 state vector
 
Mat & tao_A
 gradient vector
 
Mat & tao_B
 hessian matrix
 

Additional Inherited Members

- Static Public Member Functions inherited from MoFEM::UnknownInterface
static MoFEMErrorCode getLibVersion (Version &version)
 Get library version.
 
static MoFEMErrorCode getFileVersion (moab::Interface &moab, Version &version)
 Get database major version.
 
static MoFEMErrorCode setFileVersion (moab::Interface &moab, Version version=Version(MoFEM_VERSION_MAJOR, MoFEM_VERSION_MINOR, MoFEM_VERSION_BUILD))
 Get database major version.
 
static MoFEMErrorCode getInterfaceVersion (Version &version)
 Get database major version.
 
- Static Public Attributes inherited from MoFEM::PetscData
static constexpr Switches CtxSetNone = PetscData::Switches(CTX_SET_NONE)
 
static constexpr Switches CtxSetF = PetscData::Switches(CTX_SET_F)
 
static constexpr Switches CtxSetA = PetscData::Switches(CTX_SET_A)
 
static constexpr Switches CtxSetB = PetscData::Switches(CTX_SET_B)
 
static constexpr Switches CtxSetX = PetscData::Switches(CTX_SET_X)
 
static constexpr Switches CtxSetDX = PetscData::Switches(CTX_SET_DX)
 
static constexpr Switches CtxSetX_T = PetscData::Switches(CTX_SET_X_T)
 
static constexpr Switches CtxSetX_TT = PetscData::Switches(CTX_SET_X_TT)
 
static constexpr Switches CtxSetTime = PetscData::Switches(CTX_SET_TIME)
 

Detailed Description

Definition at line 7 of file EshelbianPlasticity.cpp.

Member Typedef Documentation

◆ Ele

◆ FaceSideEle

Initial value:
PipelineManager::ElementsAndOpsByDim<SPACE_DIM>::FaceSideEle

Definition at line 14 of file EshelbianPlasticity.cpp.

◆ PtsHashMap

using EshelbianPlasticity::EshelbianMonitor::PtsHashMap = std::map<std::string, std::array<double, 3>>

Definition at line 13 of file EshelbianPlasticity.cpp.

◆ SetPtsData

◆ VolEle

◆ VolOp

using EshelbianPlasticity::EshelbianMonitor::VolOp = VolumeElementForcesAndSourcesCore::UserDataOperator

Definition at line 11 of file EshelbianPlasticity.cpp.

Constructor & Destructor Documentation

◆ EshelbianMonitor()

EshelbianPlasticity::EshelbianMonitor::EshelbianMonitor ( EshelbianCore & ep)
inline

Definition at line 24 of file EshelbianPlasticity.cpp.

36 {
37#include <phg-quadrule/quad.h>
38}
39
40#include <queue>
41
42namespace EshelbianPlasticity {
43struct VolUserDataOperatorStabAssembly
44 : public VolumeElementForcesAndSourcesCore::UserDataOperator {
45 using VolumeElementForcesAndSourcesCore::UserDataOperator::UserDataOperator;
46};
47struct FaceUserDataOperatorStabAssembly
48 : public FaceElementForcesAndSourcesCore::UserDataOperator {
49 using FaceElementForcesAndSourcesCore::UserDataOperator::UserDataOperator;
50};
51
52} // namespace EshelbianPlasticity
53
54static auto send_type(MoFEM::Interface &m_field, Range r,
55 const EntityType type) {
56 ParallelComm *pcomm =
57 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
58
59 auto dim = CN::Dimension(type);
60
61 std::vector<int> sendcounts(pcomm->size());
62 std::vector<int> displs(pcomm->size());
63 std::vector<int> sendbuf(r.size());
64 if (pcomm->rank() == 0) {
65 for (auto p = 1; p != pcomm->size(); p++) {
66 auto part_ents = m_field.getInterface<CommInterface>()
67 ->getPartEntities(m_field.get_moab(), p)
68 .subset_by_dimension(SPACE_DIM);
69 Range faces;
70 CHKERR m_field.get_moab().get_adjacencies(part_ents, dim, true, faces,
71 moab::Interface::UNION);
72 faces = intersect(faces, r);
73 sendcounts[p] = faces.size();
74 displs[p] = sendbuf.size();
75 for (auto f : faces) {
76 auto id = id_from_handle(f);
77 sendbuf.push_back(id);
78 }
79 }
80 }
81
82 int recv_data;
83 MPI_Scatter(sendcounts.data(), 1, MPI_INT, &recv_data, 1, MPI_INT, 0,
84 pcomm->comm());
85 std::vector<int> recvbuf(recv_data);
86 MPI_Scatterv(sendbuf.data(), sendcounts.data(), displs.data(), MPI_INT,
87 recvbuf.data(), recv_data, MPI_INT, 0, pcomm->comm());
88
89 if (pcomm->rank() > 0) {
90 Range r;
91 for (auto &f : recvbuf) {
92 r.insert(ent_form_type_and_id(type, f));
93 }
94 return r;
95 }
96
97 return r;
98}
99
100static auto get_range_from_block(MoFEM::Interface &m_field,
101 const std::string block_name, int dim) {
102 Range r;
103
104 auto mesh_mng = m_field.getInterface<MeshsetsManager>();
105 auto bcs = mesh_mng->getCubitMeshsetPtr(
106
107 std::regex((boost::format("%s(.*)") % block_name).str())
108
109 );
110
111 for (auto bc : bcs) {
112 Range faces;
113 CHK_MOAB_THROW(bc->getMeshsetIdEntitiesByDimension(m_field.get_moab(), dim,
114 faces, true),
115 "get meshset ents");
116 r.merge(faces);
117 }
118
119 return r;
120};
121
122static auto get_range_from_block_map(MoFEM::Interface &m_field,
123 const std::string block_name, int dim) {
124 std::map<std::string, Range> r;
125
126 auto mesh_mng = m_field.getInterface<MeshsetsManager>();
127 auto bcs = mesh_mng->getCubitMeshsetPtr(
128
129 std::regex((boost::format("%s(.*)") % block_name).str())
130
131 );
132
133 for (auto bc : bcs) {
134 Range faces;
135 CHK_MOAB_THROW(bc->getMeshsetIdEntitiesByDimension(m_field.get_moab(), dim,
136 faces, true),
137 "get meshset ents");
138 r[bc->getName()] = faces;
139 }
140
141 return r;
142}
143
144static auto get_block_meshset(MoFEM::Interface &m_field, const int ms_id,
145 const unsigned int cubit_bc_type) {
146 auto mesh_mng = m_field.getInterface<MeshsetsManager>();
147 EntityHandle meshset;
148 CHKERR mesh_mng->getMeshset(ms_id, cubit_bc_type, meshset);
149 return meshset;
150};
151
152static auto save_range(moab::Interface &moab, const std::string name,
153 const Range r, std::vector<Tag> tags = {}) {
static auto send_type(MoFEM::Interface &m_field, Range r, const EntityType type)
static auto get_block_meshset(MoFEM::Interface &m_field, const int ms_id, const unsigned int cubit_bc_type)
static auto get_range_from_block_map(MoFEM::Interface &m_field, const std::string block_name, int dim)
Range get_range_from_block(MoFEM::Interface &m_field, const std::string block_name, int dim)
Definition adjoint.cpp:2579
constexpr int SPACE_DIM
#define MYPCOMM_INDEX
default communicator number PCOMM
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
#define CHKERR
Inline error check.
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
auto id_from_handle(const EntityHandle h)
auto ent_form_type_and_id(const EntityType type, const EntityID id)
get entity handle from type and id
int r
Definition sdf.py:8
Managing BitRefLevels.
virtual moab::Interface & get_moab()=0
Deprecated interface functions.
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
auto save_range

Member Function Documentation

◆ operator()()

MoFEMErrorCode EshelbianPlasticity::EshelbianMonitor::operator() ( )
inlinevirtual

function is run for every finite element

It is used to calculate element local matrices and assembly. It can be used for post-processing.

Reimplemented from MoFEM::BasicMethod.

Definition at line 158 of file EshelbianPlasticity.cpp.

◆ postProcess()

MoFEMErrorCode EshelbianPlasticity::EshelbianMonitor::postProcess ( )
inlinevirtual

function is run at the end of loop

It is used to assembly matrices and vectors, calculating global variables, f.e. total internal energy, ect.

Iterating over dofs: Example1 iterating over dofs in row by name of the field for(IT_GET_FEROW_BY_NAME_DOFS_FOR_LOOP(this,"DISPLACEMENT",it)) { ... }

Reimplemented from MoFEM::BasicMethod.

Definition at line 160 of file EshelbianPlasticity.cpp.

160 {
161 MOFEM_LOG("SELF", Sev::warning) << "Empty range for " << name;
162 }
164};
165
166static auto filter_true_skin(MoFEM::Interface &m_field, Range &&skin) {
167 Range boundary_ents;
168 ParallelComm *pcomm =
169 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
170 CHK_MOAB_THROW(pcomm->filter_pstatus(skin,
171 PSTATUS_SHARED | PSTATUS_MULTISHARED,
172 PSTATUS_NOT, -1, &boundary_ents),
173 "filter_pstatus");
174 return boundary_ents;
175};
176
177static auto filter_owners(MoFEM::Interface &m_field, Range skin) {
178 Range owner_ents;
179 ParallelComm *pcomm =
180 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
181 CHK_MOAB_THROW(pcomm->filter_pstatus(skin, PSTATUS_NOT_OWNED, PSTATUS_NOT, -1,
182 &owner_ents),
183 "filter_pstatus");
184 return owner_ents;
185};
186
187static auto get_skin(MoFEM::Interface &m_field, Range body_ents) {
188 Skinner skin(&m_field.get_moab());
189 Range skin_ents;
190 CHK_MOAB_THROW(skin.find_skin(0, body_ents, false, skin_ents), "find_skin");
191 return skin_ents;
192};
193
194static auto get_crack_front_edges(MoFEM::Interface &m_field,
195 Range crack_faces) {
196 ParallelComm *pcomm =
197 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
198 auto &moab = m_field.get_moab();
199 Range crack_skin_without_bdy;
200 if (pcomm->rank() == 0) {
201 Range crack_edges;
202 CHKERR moab.get_adjacencies(crack_faces, 1, true, crack_edges,
203 moab::Interface::UNION);
204 auto crack_skin = get_skin(m_field, crack_faces);
205 Range body_ents;
207 m_field.get_moab().get_entities_by_dimension(0, SPACE_DIM, body_ents),
208 "get_entities_by_dimension");
209 auto body_skin = get_skin(m_field, body_ents);
210 Range body_skin_edges;
211 CHK_MOAB_THROW(moab.get_adjacencies(body_skin, 1, true, body_skin_edges,
212 moab::Interface::UNION),
213 "get_adjacencies");
214 crack_skin_without_bdy = subtract(crack_skin, body_skin_edges);
215 auto front_edges_map = get_range_from_block_map(m_field, "FRONT", 1);
216 for (auto &m : front_edges_map) {
217 auto add_front = subtract(m.second, crack_edges);
218 auto i = intersect(m.second, crack_edges);
219 if (i.empty()) {
220 crack_skin_without_bdy.merge(add_front);
221 } else {
222 auto i_skin = get_skin(m_field, i);
223 Range adj_i_skin;
224 CHKERR moab.get_adjacencies(i_skin, 1, true, adj_i_skin,
225 moab::Interface::UNION);
226 adj_i_skin = subtract(intersect(adj_i_skin, m.second), crack_edges);
227 crack_skin_without_bdy.merge(adj_i_skin);
228 }
229 }
230 }
231 return send_type(m_field, crack_skin_without_bdy, MBEDGE);
232}
233
235 Range crack_faces) {
236
237 ParallelComm *pcomm =
238 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
239
240 MOFEM_LOG("EP", Sev::noisy) << "get_two_sides_of_crack_surface";
241
242 if (!pcomm->rank()) {
243
244 auto impl = [&](auto &saids) {
246
247 auto &moab = m_field.get_moab();
248
249 auto get_adj = [&](auto e, auto dim) {
250 Range adj;
251 CHK_MOAB_THROW(m_field.get_moab().get_adjacencies(
252 e, dim, true, adj, moab::Interface::UNION),
253 "get adj");
254 return adj;
255 };
256
257 auto get_conn = [&](auto e) {
258 Range conn;
259 CHK_MOAB_THROW(m_field.get_moab().get_connectivity(e, conn, true),
260 "get connectivity");
261 return conn;
262 };
263
264 constexpr bool debug = false;
265 Range body_ents;
266 CHKERR m_field.get_moab().get_entities_by_dimension(0, SPACE_DIM,
267 body_ents);
268 auto body_skin = get_skin(m_field, body_ents);
269 auto body_skin_edges = get_adj(body_skin, 1);
270
271 auto crack_skin =
272 subtract(get_skin(m_field, crack_faces), body_skin_edges);
273 auto crack_skin_conn = get_conn(crack_skin);
274 auto crack_skin_conn_edges = get_adj(crack_skin_conn, 1);
275 auto crack_edges = get_adj(crack_faces, 1);
276 crack_edges = subtract(crack_edges, crack_skin);
277 auto all_tets = get_adj(crack_edges, 3);
278 crack_edges = subtract(crack_edges, crack_skin_conn_edges);
279 auto crack_conn = get_conn(crack_edges);
280 all_tets.merge(get_adj(crack_conn, 3));
281
282 if (debug) {
283 CHKERR save_range(m_field.get_moab(), "crack_faces.vtk", crack_faces);
284 CHKERR save_range(m_field.get_moab(), "all_crack_tets.vtk", all_tets);
285 CHKERR save_range(m_field.get_moab(), "crack_edges_all.vtk",
286 crack_edges);
287 }
288
289 if (crack_faces.size()) {
290 auto grow = [&](auto r) {
291 auto crack_faces_conn = get_conn(crack_faces);
292 Range v;
293 auto size_r = 0;
294 while (size_r != r.size() && r.size() > 0) {
295 size_r = r.size();
296 CHKERR moab.get_connectivity(r, v, true);
297 v = subtract(v, crack_faces_conn);
298 if (v.size()) {
299 CHKERR moab.get_adjacencies(v, SPACE_DIM, true, r,
300 moab::Interface::UNION);
301 r = intersect(r, all_tets);
302 }
303 if (r.empty()) {
304 break;
305 }
306 }
307 return r;
308 };
309
310 Range all_tets_ord = all_tets;
311 while (all_tets.size()) {
312 Range faces = get_adj(unite(saids.first, saids.second), 2);
313 faces = subtract(crack_faces, faces);
314 if (faces.size()) {
315 Range tets;
316 auto fit = faces.begin();
317 for (; fit != faces.end(); ++fit) {
318 tets = intersect(get_adj(Range(*fit, *fit), 3), all_tets);
319 if (tets.size() == 2) {
320 break;
321 }
322 }
323 if (tets.empty()) {
324 break;
325 } else {
326 saids.first.insert(tets[0]);
327 saids.first = grow(saids.first);
328 all_tets = subtract(all_tets, saids.first);
329 if (tets.size() == 2) {
330 saids.second.insert(tets[1]);
331 saids.second = grow(saids.second);
332 all_tets = subtract(all_tets, saids.second);
333 }
334 }
335 } else {
336 break;
337 }
338 }
339
340 saids.first = subtract(all_tets_ord, saids.second);
341 saids.second = subtract(all_tets_ord, saids.first);
342 }
343
345 };
346
347 std::pair<Range, Range> saids;
348 if (crack_faces.size())
349 CHK_THROW_MESSAGE(impl(saids), "get crack both sides");
350 return saids;
351 }
352
353 MOFEM_LOG("EP", Sev::noisy) << "get_two_sides_of_crack_surface <- done";
354
355 return std::pair<Range, Range>();
356}
357
358namespace EshelbianPlasticity {
359
360struct SetIntegrationAtFrontVolume {
361
362 SetIntegrationAtFrontVolume(boost::shared_ptr<Range> front_nodes,
363 boost::shared_ptr<Range> front_edges)
364 : frontNodes(front_nodes), frontEdges(front_edges){};
365
366 MoFEMErrorCode operator()(ForcesAndSourcesCore *fe_raw_ptr, int order_row,
367 int order_col, int order_data) {
369
370 constexpr bool debug = false;
371
372 constexpr int numNodes = 4;
373 constexpr int numEdges = 6;
374 constexpr int refinementLevels = 4;
375
376 auto &m_field = fe_raw_ptr->mField;
377 auto fe_ptr = static_cast<Fe *>(fe_raw_ptr);
378 auto fe_handle = fe_ptr->getFEEntityHandle();
379
380 auto set_base_quadrature = [&]() {
382 int rule = 2 * order_data + 1;
383 if (rule < QUAD_3D_TABLE_SIZE) {
384 if (QUAD_3D_TABLE[rule]->dim != 3) {
385 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
386 "wrong dimension");
387 }
388 if (QUAD_3D_TABLE[rule]->order < rule) {
389 SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
390 "wrong order %d != %d", QUAD_3D_TABLE[rule]->order, rule);
391 }
392 const size_t nb_gauss_pts = QUAD_3D_TABLE[rule]->npoints;
393 auto &gauss_pts = fe_ptr->gaussPts;
394 gauss_pts.resize(4, nb_gauss_pts, false);
395 cblas_dcopy(nb_gauss_pts, &QUAD_3D_TABLE[rule]->points[1], 4,
396 &gauss_pts(0, 0), 1);
397 cblas_dcopy(nb_gauss_pts, &QUAD_3D_TABLE[rule]->points[2], 4,
398 &gauss_pts(1, 0), 1);
399 cblas_dcopy(nb_gauss_pts, &QUAD_3D_TABLE[rule]->points[3], 4,
400 &gauss_pts(2, 0), 1);
401 cblas_dcopy(nb_gauss_pts, QUAD_3D_TABLE[rule]->weights, 1,
402 &gauss_pts(3, 0), 1);
403 auto &data = fe_ptr->dataOnElement[H1];
404 data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 4,
405 false);
406 double *shape_ptr =
407 &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
408 cblas_dcopy(4 * nb_gauss_pts, QUAD_3D_TABLE[rule]->points, 1, shape_ptr,
409 1);
410 } else {
411 SETERRQ(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
412 "rule > quadrature order %d < %d", rule, QUAD_3D_TABLE_SIZE);
413 }
415 };
416
417 CHKERR set_base_quadrature();
418
420
421 auto get_singular_nodes = [&]() {
422 int num_nodes;
423 const EntityHandle *conn;
424 CHKERR m_field.get_moab().get_connectivity(fe_handle, conn, num_nodes,
425 true);
426 std::bitset<numNodes> singular_nodes;
427 for (auto nn = 0; nn != numNodes; ++nn) {
428 if (frontNodes->find(conn[nn]) != frontNodes->end()) {
429 singular_nodes.set(nn);
430 } else {
431 singular_nodes.reset(nn);
432 }
433 }
434 return singular_nodes;
435 };
436
437 auto get_singular_edges = [&]() {
438 std::bitset<numEdges> singular_edges;
439 for (int ee = 0; ee != numEdges; ee++) {
440 EntityHandle edge;
441 CHKERR m_field.get_moab().side_element(fe_handle, 1, ee, edge);
442 if (frontEdges->find(edge) != frontEdges->end()) {
443 singular_edges.set(ee);
444 } else {
445 singular_edges.reset(ee);
446 }
447 }
448 return singular_edges;
449 };
450
451 auto set_gauss_pts = [&](auto &ref_gauss_pts) {
453 fe_ptr->gaussPts.swap(ref_gauss_pts);
454 const size_t nb_gauss_pts = fe_ptr->gaussPts.size2();
455 auto &data = fe_ptr->dataOnElement[H1];
456 data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 4);
457 double *shape_ptr =
458 &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
459 CHKERR ShapeMBTET(shape_ptr, &fe_ptr->gaussPts(0, 0),
460 &fe_ptr->gaussPts(1, 0), &fe_ptr->gaussPts(2, 0),
461 nb_gauss_pts);
463 };
464
465 auto singular_nodes = get_singular_nodes();
466 if (singular_nodes.count()) {
467 auto it_map_ref_coords = mapRefCoords.find(singular_nodes.to_ulong());
468 if (it_map_ref_coords != mapRefCoords.end()) {
469 CHKERR set_gauss_pts(it_map_ref_coords->second);
471 } else {
472
473 auto refine_quadrature = [&]() {
475
476 const int max_level = refinementLevels;
477 EntityHandle tet;
478
479 moab::Core moab_ref;
480 double base_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1};
481 EntityHandle nodes[4];
482 for (int nn = 0; nn != 4; nn++)
483 CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
484 CHKERR moab_ref.create_element(MBTET, nodes, 4, tet);
485 MoFEM::CoreTmp<-1> mofem_ref_core(moab_ref, PETSC_COMM_SELF, -2);
486 MoFEM::Interface &m_field_ref = mofem_ref_core;
487 {
488 Range tets(tet, tet);
489 Range edges;
490 CHKERR m_field_ref.get_moab().get_adjacencies(
491 tets, 1, true, edges, moab::Interface::UNION);
492 CHKERR m_field_ref.getInterface<BitRefManager>()->setBitRefLevel(
493 tets, BitRefLevel().set(0), false, VERBOSE);
494 }
495
static auto get_two_sides_of_crack_surface(MoFEM::Interface &m_field, Range crack_faces)
static auto filter_owners(MoFEM::Interface &m_field, Range skin)
static auto filter_true_skin(MoFEM::Interface &m_field, Range &&skin)
static auto get_skin(MoFEM::Interface &m_field, Range body_ents)
static auto get_crack_front_edges(MoFEM::Interface &m_field, Range crack_faces)
@ VERBOSE
@ NOBASE
Definition definitions.h:59
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ H1
continuous field
Definition definitions.h:85
@ MOFEM_DATA_INCONSISTENCY
Definition definitions.h:31
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
constexpr int order
static const bool debug
PetscErrorCode ShapeMBTET(double *N, const double *G_X, const double *G_Y, const double *G_Z, int DIM)
calculate shape functions
Definition fem_tools.c:306
#define MOFEM_LOG(channel, severity)
Log.
FTensor::Index< 'i', SPACE_DIM > i
const double v
phase velocity of light in medium (cm/ns)
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition Types.hpp:40
#define QUAD_3D_TABLE_SIZE
Definition quad.h:186
static QUAD *const QUAD_3D_TABLE[]
Definition quad.h:187
FTensor::Index< 'm', 3 > m
MoFEMErrorCode operator()(ForcesAndSourcesCore *fe_raw_ptr, int order_row, int order_col, int order_data)
static std::map< long int, MatrixDouble > mapRefCoords
SetIntegrationAtFrontVolume(boost::shared_ptr< Range > front_nodes, boost::shared_ptr< Range > front_edges)
Managing BitRefLevels.
virtual MPI_Comm & get_comm() const =0
structure to get information form mofem into EntitiesFieldData
int order
Definition quad.h:28
int npoints
Definition quad.h:29

◆ preProcess()

MoFEMErrorCode EshelbianPlasticity::EshelbianMonitor::preProcess ( )
inlinevirtual

function is run at the beginning of loop

It is used to zeroing matrices and vectors, calculation of shape functions on reference element, preprocessing boundary conditions, etc.

Reimplemented from MoFEM::BasicMethod.

Definition at line 156 of file EshelbianPlasticity.cpp.

Member Data Documentation

◆ dataFieldEval

boost::shared_ptr<SetPtsData> EshelbianPlasticity::EshelbianMonitor::dataFieldEval

Definition at line 18 of file EshelbianPlasticity.cpp.

◆ eP

EshelbianCore& EshelbianPlasticity::EshelbianMonitor::eP

Definition at line 17 of file EshelbianPlasticity.cpp.

◆ gEnergy

boost::shared_ptr<double> EshelbianPlasticity::EshelbianMonitor::gEnergy

Definition at line 20 of file EshelbianPlasticity.cpp.

◆ ptsHashMap

PtsHashMap EshelbianPlasticity::EshelbianMonitor::ptsHashMap

Definition at line 21 of file EshelbianPlasticity.cpp.

◆ volPostProcEnergy

boost::shared_ptr<VolEle> EshelbianPlasticity::EshelbianMonitor::volPostProcEnergy

Definition at line 19 of file EshelbianPlasticity.cpp.

◆ writeRestart

PetscBool EshelbianPlasticity::EshelbianMonitor::writeRestart = PETSC_FALSE

Definition at line 22 of file EshelbianPlasticity.cpp.


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