v0.15.0
Loading...
Searching...
No Matches
Classes | Namespaces | Macros | Functions
EshelbianPlasticity.cpp File Reference

Implementation of automatic differentiation. More...

#include <MoFEM.hpp>
#include <CGGTonsorialBubbleBase.hpp>
#include <EshelbianPlasticity.hpp>
#include <boost/math/constants/constants.hpp>
#include <cholesky.hpp>
#include <EshelbianAux.hpp>
#include <EshelbianContact.hpp>
#include <phg-quadrule/quad.h>
#include <queue>
#include "impl/EshelbianMonitor.cpp"
#include "impl/SetUpSchurImpl.cpp"
#include "impl/TSElasticPostStep.cpp"
#include <impl/EshelbianContact.cpp>

Go to the source code of this file.

Classes

struct  EshelbianPlasticity::VolUserDataOperatorStabAssembly
 
struct  EshelbianPlasticity::FaceUserDataOperatorStabAssembly
 
struct  EshelbianPlasticity::SetIntegrationAtFrontVolume
 
struct  EshelbianPlasticity::SetIntegrationAtFrontVolume::Fe
 
struct  EshelbianPlasticity::SetIntegrationAtFrontFace
 
struct  EshelbianPlasticity::SetIntegrationAtFrontFace::Fe
 
struct  EshelbianPlasticity::VolRule
 Set integration rule on element. More...
 
struct  EshelbianPlasticity::FaceRule
 
struct  EshelbianPlasticity::solve_elastic_setup
 

Namespaces

namespace  EshelbianPlasticity
 

Macros

#define SINGULARITY
 

Functions

static auto send_type (MoFEM::Interface &m_field, Range r, const EntityType type)
 
static auto get_range_from_block (MoFEM::Interface &m_field, const std::string block_name, int dim)
 
static auto get_range_from_block_map (MoFEM::Interface &m_field, const std::string block_name, int dim)
 
static auto get_block_meshset (MoFEM::Interface &m_field, const int ms_id, const unsigned int cubit_bc_type)
 
static auto save_range (moab::Interface &moab, const std::string name, const Range r, std::vector< Tag > tags={})
 
static auto filter_true_skin (MoFEM::Interface &m_field, Range &&skin)
 
static auto filter_owners (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)
 
static auto get_two_sides_of_crack_surface (MoFEM::Interface &m_field, Range crack_faces)
 

Detailed Description

Implementation of automatic differentiation.

Definition in file EshelbianPlasticity.cpp.

Macro Definition Documentation

◆ SINGULARITY

#define SINGULARITY

Definition at line 11 of file EshelbianPlasticity.cpp.

Function Documentation

◆ filter_owners()

static auto filter_owners ( MoFEM::Interface m_field,
Range  skin 
)
static
Examples
EshelbianPlasticity.cpp.

Definition at line 180 of file EshelbianPlasticity.cpp.

180 {
181 Range owner_ents;
182 ParallelComm *pcomm =
183 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
184 CHK_MOAB_THROW(pcomm->filter_pstatus(skin, PSTATUS_NOT_OWNED, PSTATUS_NOT, -1,
185 &owner_ents),
186 "filter_pstatus");
187 return owner_ents;
188};
#define MYPCOMM_INDEX
default communicator number PCOMM
#define CHK_MOAB_THROW(err, msg)
Check error code of MoAB function and throw MoFEM exception.
virtual moab::Interface & get_moab()=0

◆ filter_true_skin()

static auto filter_true_skin ( MoFEM::Interface m_field,
Range &&  skin 
)
static
Examples
EshelbianPlasticity.cpp, adolc_plasticity.cpp, plastic.cpp, seepage.cpp, tensor_divergence_operator.cpp, and thermo_elastic.cpp.

Definition at line 169 of file EshelbianPlasticity.cpp.

169 {
170 Range boundary_ents;
171 ParallelComm *pcomm =
172 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
173 CHK_MOAB_THROW(pcomm->filter_pstatus(skin,
174 PSTATUS_SHARED | PSTATUS_MULTISHARED,
175 PSTATUS_NOT, -1, &boundary_ents),
176 "filter_pstatus");
177 return boundary_ents;
178};

◆ get_block_meshset()

static auto get_block_meshset ( MoFEM::Interface m_field,
const int  ms_id,
const unsigned int  cubit_bc_type 
)
static
Examples
EshelbianPlasticity.cpp.

Definition at line 147 of file EshelbianPlasticity.cpp.

148 {
149 auto mesh_mng = m_field.getInterface<MeshsetsManager>();
150 EntityHandle meshset;
151 CHKERR mesh_mng->getMeshset(ms_id, cubit_bc_type, meshset);
152 return meshset;
153};
#define CHKERR
Inline error check.
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.

◆ get_crack_front_edges()

static auto get_crack_front_edges ( MoFEM::Interface m_field,
Range  crack_faces 
)
static
Examples
EshelbianPlasticity.cpp.

Definition at line 197 of file EshelbianPlasticity.cpp.

198 {
199 ParallelComm *pcomm =
200 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
201 auto &moab = m_field.get_moab();
202 Range crack_skin_without_bdy;
203 if (pcomm->rank() == 0) {
204 Range crack_edges;
205 CHKERR moab.get_adjacencies(crack_faces, 1, true, crack_edges,
206 moab::Interface::UNION);
207 auto crack_skin = get_skin(m_field, crack_faces);
208 Range body_ents;
210 m_field.get_moab().get_entities_by_dimension(0, SPACE_DIM, body_ents),
211 "get_entities_by_dimension");
212 auto body_skin = get_skin(m_field, body_ents);
213 Range body_skin_edges;
214 CHK_MOAB_THROW(moab.get_adjacencies(body_skin, 1, true, body_skin_edges,
215 moab::Interface::UNION),
216 "get_adjacencies");
217 crack_skin_without_bdy = subtract(crack_skin, body_skin_edges);
218 auto front_edges_map = get_range_from_block_map(m_field, "FRONT", 1);
219 for (auto &m : front_edges_map) {
220 auto add_front = subtract(m.second, crack_edges);
221 auto i = intersect(m.second, crack_edges);
222 if (i.empty()) {
223 crack_skin_without_bdy.merge(add_front);
224 } else {
225 auto i_skin = get_skin(m_field, i);
226 Range adj_i_skin;
227 CHKERR moab.get_adjacencies(i_skin, 1, true, adj_i_skin,
228 moab::Interface::UNION);
229 adj_i_skin = subtract(intersect(adj_i_skin, m.second), crack_edges);
230 crack_skin_without_bdy.merge(adj_i_skin);
231 }
232 }
233 }
234 return send_type(m_field, crack_skin_without_bdy, MBEDGE);
235}
static auto send_type(MoFEM::Interface &m_field, Range r, const EntityType type)
static auto get_range_from_block_map(MoFEM::Interface &m_field, const std::string block_name, int dim)
static auto get_skin(MoFEM::Interface &m_field, Range body_ents)
constexpr int SPACE_DIM
FTensor::Index< 'i', SPACE_DIM > i
FTensor::Index< 'm', 3 > m

◆ get_range_from_block()

static auto get_range_from_block ( MoFEM::Interface m_field,
const std::string  block_name,
int  dim 
)
static

Definition at line 103 of file EshelbianPlasticity.cpp.

104 {
105 Range r;
106
107 auto mesh_mng = m_field.getInterface<MeshsetsManager>();
108 auto bcs = mesh_mng->getCubitMeshsetPtr(
109
110 std::regex((boost::format("%s(.*)") % block_name).str())
111
112 );
113
114 for (auto bc : bcs) {
115 Range faces;
116 CHK_MOAB_THROW(bc->getMeshsetIdEntitiesByDimension(m_field.get_moab(), dim,
117 faces, true),
118 "get meshset ents");
119 r.merge(faces);
120 }
121
122 return r;
123};
MoFEMErrorCode getCubitMeshsetPtr(const int ms_id, const CubitBCType cubit_bc_type, const CubitMeshSets **cubit_meshset_ptr) const
get cubit meshset
int r
Definition sdf.py:8

◆ get_range_from_block_map()

static auto get_range_from_block_map ( MoFEM::Interface m_field,
const std::string  block_name,
int  dim 
)
static
Examples
EshelbianPlasticity.cpp.

Definition at line 125 of file EshelbianPlasticity.cpp.

126 {
127 std::map<std::string, Range> r;
128
129 auto mesh_mng = m_field.getInterface<MeshsetsManager>();
130 auto bcs = mesh_mng->getCubitMeshsetPtr(
131
132 std::regex((boost::format("%s(.*)") % block_name).str())
133
134 );
135
136 for (auto bc : bcs) {
137 Range faces;
138 CHK_MOAB_THROW(bc->getMeshsetIdEntitiesByDimension(m_field.get_moab(), dim,
139 faces, true),
140 "get meshset ents");
141 r[bc->getName()] = faces;
142 }
143
144 return r;
145}

◆ get_skin()

static auto get_skin ( MoFEM::Interface m_field,
Range  body_ents 
)
static

Definition at line 190 of file EshelbianPlasticity.cpp.

190 {
191 Skinner skin(&m_field.get_moab());
192 Range skin_ents;
193 CHK_MOAB_THROW(skin.find_skin(0, body_ents, false, skin_ents), "find_skin");
194 return skin_ents;
195};

◆ get_two_sides_of_crack_surface()

static auto get_two_sides_of_crack_surface ( MoFEM::Interface m_field,
Range  crack_faces 
)
static
Examples
EshelbianPlasticity.cpp.

Definition at line 237 of file EshelbianPlasticity.cpp.

238 {
239
240 ParallelComm *pcomm =
241 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
242
243 MOFEM_LOG("EP", Sev::noisy) << "get_two_sides_of_crack_surface";
244
245 if (!pcomm->rank()) {
246
247 auto impl = [&](auto &saids) {
249
250 auto &moab = m_field.get_moab();
251
252 auto get_adj = [&](auto e, auto dim) {
253 Range adj;
254 CHK_MOAB_THROW(m_field.get_moab().get_adjacencies(
255 e, dim, true, adj, moab::Interface::UNION),
256 "get adj");
257 return adj;
258 };
259
260 auto get_conn = [&](auto e) {
261 Range conn;
262 CHK_MOAB_THROW(m_field.get_moab().get_connectivity(e, conn, true),
263 "get connectivity");
264 return conn;
265 };
266
267 constexpr bool debug = false;
268 Range body_ents;
269 CHKERR m_field.get_moab().get_entities_by_dimension(0, SPACE_DIM,
270 body_ents);
271 auto body_skin = get_skin(m_field, body_ents);
272 auto body_skin_edges = get_adj(body_skin, 1);
273
274 auto crack_skin =
275 subtract(get_skin(m_field, crack_faces), body_skin_edges);
276 auto crack_skin_conn = get_conn(crack_skin);
277 auto crack_skin_conn_edges = get_adj(crack_skin_conn, 1);
278 auto crack_edges = get_adj(crack_faces, 1);
279 crack_edges = subtract(crack_edges, crack_skin);
280 auto all_tets = get_adj(crack_edges, 3);
281 crack_edges = subtract(crack_edges, crack_skin_conn_edges);
282 auto crack_conn = get_conn(crack_edges);
283 all_tets.merge(get_adj(crack_conn, 3));
284
285 if (debug) {
286 CHKERR save_range(m_field.get_moab(), "crack_faces.vtk", crack_faces);
287 CHKERR save_range(m_field.get_moab(), "all_crack_tets.vtk", all_tets);
288 CHKERR save_range(m_field.get_moab(), "crack_edges_all.vtk",
289 crack_edges);
290 }
291
292 if (crack_faces.size()) {
293 auto grow = [&](auto r) {
294 auto crack_faces_conn = get_conn(crack_faces);
295 Range v;
296 auto size_r = 0;
297 while (size_r != r.size() && r.size() > 0) {
298 size_r = r.size();
299 CHKERR moab.get_connectivity(r, v, true);
300 v = subtract(v, crack_faces_conn);
301 if (v.size()) {
302 CHKERR moab.get_adjacencies(v, SPACE_DIM, true, r,
303 moab::Interface::UNION);
304 r = intersect(r, all_tets);
305 }
306 if (r.empty()) {
307 break;
308 }
309 }
310 return r;
311 };
312
313 Range all_tets_ord = all_tets;
314 while (all_tets.size()) {
315 Range faces = get_adj(unite(saids.first, saids.second), 2);
316 faces = subtract(crack_faces, faces);
317 if (faces.size()) {
318 Range tets;
319 auto fit = faces.begin();
320 for (; fit != faces.end(); ++fit) {
321 tets = intersect(get_adj(Range(*fit, *fit), 3), all_tets);
322 if (tets.size() == 2) {
323 break;
324 }
325 }
326 if (tets.empty()) {
327 break;
328 } else {
329 saids.first.insert(tets[0]);
330 saids.first = grow(saids.first);
331 all_tets = subtract(all_tets, saids.first);
332 if (tets.size() == 2) {
333 saids.second.insert(tets[1]);
334 saids.second = grow(saids.second);
335 all_tets = subtract(all_tets, saids.second);
336 }
337 }
338 } else {
339 break;
340 }
341 }
342
343 saids.first = subtract(all_tets_ord, saids.second);
344 saids.second = subtract(all_tets_ord, saids.first);
345 }
346
348 };
349
350 std::pair<Range, Range> saids;
351 if (crack_faces.size())
352 CHK_THROW_MESSAGE(impl(saids), "get crack both sides");
353 return saids;
354 }
355
356 MOFEM_LOG("EP", Sev::noisy) << "get_two_sides_of_crack_surface <- done";
357
358 return std::pair<Range, Range>();
359}
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define MOFEM_LOG(channel, severity)
Log.
const double v
phase velocity of light in medium (cm/ns)
static const bool debug
auto save_range

◆ save_range()

static auto save_range ( moab::Interface &  moab,
const std::string  name,
const Range  r,
std::vector< Tag tags = {} 
)
static

Definition at line 155 of file EshelbianPlasticity.cpp.

156 {}) {
158 auto out_meshset = get_temp_meshset_ptr(moab);
159 CHKERR moab.add_entities(*out_meshset, r);
160 if (r.size()) {
161 CHKERR moab.write_file(name.c_str(), "VTK", "", out_meshset->get_ptr(), 1,
162 tags.data(), tags.size());
163 } else {
164 MOFEM_LOG("SELF", Sev::warning) << "Empty range for " << name;
165 }
167};
auto get_temp_meshset_ptr(moab::Interface &moab)
Create smart pointer to temporary meshset.

◆ send_type()

static auto send_type ( MoFEM::Interface m_field,
Range  r,
const EntityType  type 
)
static
Examples
EshelbianPlasticity.cpp.

Definition at line 57 of file EshelbianPlasticity.cpp.

58 {
59 ParallelComm *pcomm =
60 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
61
62 auto dim = CN::Dimension(type);
63
64 std::vector<int> sendcounts(pcomm->size());
65 std::vector<int> displs(pcomm->size());
66 std::vector<int> sendbuf(r.size());
67 if (pcomm->rank() == 0) {
68 for (auto p = 1; p != pcomm->size(); p++) {
69 auto part_ents = m_field.getInterface<CommInterface>()
70 ->getPartEntities(m_field.get_moab(), p)
71 .subset_by_dimension(SPACE_DIM);
72 Range faces;
73 CHKERR m_field.get_moab().get_adjacencies(part_ents, dim, true, faces,
74 moab::Interface::UNION);
75 faces = intersect(faces, r);
76 sendcounts[p] = faces.size();
77 displs[p] = sendbuf.size();
78 for (auto f : faces) {
79 auto id = id_from_handle(f);
80 sendbuf.push_back(id);
81 }
82 }
83 }
84
85 int recv_data;
86 MPI_Scatter(sendcounts.data(), 1, MPI_INT, &recv_data, 1, MPI_INT, 0,
87 pcomm->comm());
88 std::vector<int> recvbuf(recv_data);
89 MPI_Scatterv(sendbuf.data(), sendcounts.data(), displs.data(), MPI_INT,
90 recvbuf.data(), recv_data, MPI_INT, 0, pcomm->comm());
91
92 if (pcomm->rank() > 0) {
93 Range r;
94 for (auto &f : recvbuf) {
95 r.insert(ent_form_type_and_id(type, f));
96 }
97 return r;
98 }
99
100 return r;
101}
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
Managing BitRefLevels.