v0.15.5
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 <EshelbianCohesive.hpp>
#include <EshelbianTopologicalDerivative.hpp>
#include <TSElasticPostStep.hpp>
#include <phg-quadrule/quad.h>
#include <queue>
#include "impl/CGGUserPolynomialBase.cpp"
#include "impl/EshelbianMonitor.cpp"
#include "impl/SetUpSchurImpl.cpp"
#include <impl/EshelbianFracture.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_entities_by_handle (MoFEM::Interface &m_field, const std::string block_name)
 
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 12 of file EshelbianPlasticity.cpp.

Function Documentation

◆ filter_owners()

static auto filter_owners ( MoFEM::Interface m_field,
Range  skin 
)
static
Examples
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp.

Definition at line 201 of file EshelbianPlasticity.cpp.

201 {
202 Range owner_ents;
203 ParallelComm *pcomm =
204 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
205 CHK_MOAB_THROW(pcomm->filter_pstatus(skin, PSTATUS_NOT_OWNED, PSTATUS_NOT, -1,
206 &owner_ents),
207 "filter_pstatus");
208 return owner_ents;
209};
#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
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp, mofem/atom_tests/tensor_divergence_operator.cpp, mofem/tutorials/adv-0_plasticity/plastic.cpp, mofem/tutorials/adv-5_poroelasticity/seepage.cpp, mofem/users_modules/adolc-plasticity/adolc_plasticity.cpp, plastic.cpp, thermo_elastic.cpp, and thermoplastic.cpp.

Definition at line 190 of file EshelbianPlasticity.cpp.

190 {
191 Range boundary_ents;
192 ParallelComm *pcomm =
193 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
194 CHK_MOAB_THROW(pcomm->filter_pstatus(skin,
195 PSTATUS_SHARED | PSTATUS_MULTISHARED,
196 PSTATUS_NOT, -1, &boundary_ents),
197 "filter_pstatus");
198 return boundary_ents;
199};

◆ get_block_meshset()

static auto get_block_meshset ( MoFEM::Interface m_field,
const int  ms_id,
const unsigned int  cubit_bc_type 
)
static
Examples
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp.

Definition at line 168 of file EshelbianPlasticity.cpp.

169 {
170 auto mesh_mng = m_field.getInterface<MeshsetsManager>();
171 EntityHandle meshset;
172 CHKERR mesh_mng->getMeshset(ms_id, cubit_bc_type, meshset);
173 return meshset;
174};
#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
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp.

Definition at line 218 of file EshelbianPlasticity.cpp.

219 {
220 ParallelComm *pcomm =
221 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
222 auto &moab = m_field.get_moab();
223 Range crack_skin_without_bdy;
224 if (pcomm->rank() == 0) {
225 Range crack_edges;
226 CHKERR moab.get_adjacencies(crack_faces, 1, true, crack_edges,
227 moab::Interface::UNION);
228 auto crack_skin = get_skin(m_field, crack_faces);
229 Range body_ents;
231 m_field.get_moab().get_entities_by_dimension(0, SPACE_DIM, body_ents),
232 "get_entities_by_dimension");
233 auto body_skin = get_skin(m_field, body_ents);
234 Range body_skin_edges;
235 CHK_MOAB_THROW(moab.get_adjacencies(body_skin, 1, true, body_skin_edges,
236 moab::Interface::UNION),
237 "get_adjacencies");
238 crack_skin_without_bdy = subtract(crack_skin, body_skin_edges);
239 auto front_edges_map = get_range_from_block_map(m_field, "FRONT", 1);
240 for (auto &m : front_edges_map) {
241 auto add_front = subtract(m.second, crack_edges);
242 auto i = intersect(m.second, crack_edges);
243 if (i.empty()) {
244 crack_skin_without_bdy.merge(add_front);
245 } else {
246 auto i_skin = get_skin(m_field, i);
247 Range adj_i_skin;
248 CHKERR moab.get_adjacencies(i_skin, 1, true, adj_i_skin,
249 moab::Interface::UNION);
250 adj_i_skin = subtract(intersect(adj_i_skin, m.second), crack_edges);
251 crack_skin_without_bdy.merge(adj_i_skin);
252 }
253 }
254 }
255 return send_type(m_field, crack_skin_without_bdy, MBEDGE);
256}
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_entities_by_handle()

static auto get_entities_by_handle ( MoFEM::Interface m_field,
const std::string  block_name 
)
static
Examples
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp.

Definition at line 104 of file EshelbianPlasticity.cpp.

105 {
106 Range r;
107
108 auto mesh_mng = m_field.getInterface<MeshsetsManager>();
109 auto bcs = mesh_mng->getCubitMeshsetPtr(
110
111 std::regex((boost::format("%s(.*)") % block_name).str())
112
113 );
114
115 for (auto bc : bcs) {
116 auto meshset = bc->getMeshset();
117 CHK_MOAB_THROW(m_field.get_moab().get_entities_by_handle(meshset, r, true),
118 "get meshset ents");
119 }
120
121 return r;
122};
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:205

◆ 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 124 of file EshelbianPlasticity.cpp.

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

◆ 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
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp.

Definition at line 146 of file EshelbianPlasticity.cpp.

147 {
148 std::map<std::string, Range> r;
149
150 auto mesh_mng = m_field.getInterface<MeshsetsManager>();
151 auto bcs = mesh_mng->getCubitMeshsetPtr(
152
153 std::regex((boost::format("%s(.*)") % block_name).str())
154
155 );
156
157 for (auto bc : bcs) {
158 Range faces;
159 CHK_MOAB_THROW(bc->getMeshsetIdEntitiesByDimension(m_field.get_moab(), dim,
160 faces, true),
161 "get meshset ents");
162 r[bc->getName()] = faces;
163 }
164
165 return r;
166}

◆ get_skin()

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

Definition at line 211 of file EshelbianPlasticity.cpp.

211 {
212 Skinner skin(&m_field.get_moab());
213 Range skin_ents;
214 CHK_MOAB_THROW(skin.find_skin(0, body_ents, false, skin_ents), "find_skin");
215 return skin_ents;
216};

◆ get_two_sides_of_crack_surface()

static auto get_two_sides_of_crack_surface ( MoFEM::Interface m_field,
Range  crack_faces 
)
static
Examples
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp.

Definition at line 258 of file EshelbianPlasticity.cpp.

259 {
260
261 ParallelComm *pcomm =
262 ParallelComm::get_pcomm(&m_field.get_moab(), MYPCOMM_INDEX);
263
264 MOFEM_LOG("EP", Sev::noisy) << "get_two_sides_of_crack_surface";
265
266 if (!pcomm->rank()) {
267
268 auto impl = [&](auto &saids) {
270
271 auto &moab = m_field.get_moab();
272
273 auto get_adj = [&](auto e, auto dim) {
274 Range adj;
275 CHK_MOAB_THROW(m_field.get_moab().get_adjacencies(
276 e, dim, true, adj, moab::Interface::UNION),
277 "get adj");
278 return adj;
279 };
280
281 auto get_conn = [&](auto e) {
282 Range conn;
283 CHK_MOAB_THROW(m_field.get_moab().get_connectivity(e, conn, true),
284 "get connectivity");
285 return conn;
286 };
287
288 constexpr bool debug = false;
289 Range body_ents;
290 CHKERR m_field.get_moab().get_entities_by_dimension(0, SPACE_DIM,
291 body_ents);
292 auto body_skin = get_skin(m_field, body_ents);
293 auto body_skin_edges = get_adj(body_skin, 1);
294
295 auto crack_skin =
296 subtract(get_skin(m_field, crack_faces), body_skin_edges);
297 auto crack_skin_conn = get_conn(crack_skin);
298 auto crack_skin_conn_edges = get_adj(crack_skin_conn, 1);
299 auto crack_edges = get_adj(crack_faces, 1);
300 crack_edges = subtract(crack_edges, crack_skin);
301 auto all_tets = get_adj(crack_edges, 3);
302 crack_edges = subtract(crack_edges, crack_skin_conn_edges);
303 auto crack_conn = get_conn(crack_edges);
304 all_tets.merge(get_adj(crack_conn, 3));
305
306 if (debug) {
307 CHKERR save_range(m_field.get_moab(), "crack_faces.vtk", crack_faces);
308 CHKERR save_range(m_field.get_moab(), "all_crack_tets.vtk", all_tets);
309 CHKERR save_range(m_field.get_moab(), "crack_edges_all.vtk",
310 crack_edges);
311 }
312
313 if (crack_faces.size()) {
314 auto grow = [&](auto r) {
315 auto crack_faces_conn = get_conn(crack_faces);
316 Range v;
317 auto size_r = 0;
318 while (size_r != r.size() && r.size() > 0) {
319 size_r = r.size();
320 CHKERR moab.get_connectivity(r, v, true);
321 v = subtract(v, crack_faces_conn);
322 if (v.size()) {
323 CHKERR moab.get_adjacencies(v, SPACE_DIM, true, r,
324 moab::Interface::UNION);
325 r = intersect(r, all_tets);
326 }
327 if (r.empty()) {
328 break;
329 }
330 }
331 return r;
332 };
333
334 Range all_tets_ord = all_tets;
335 while (all_tets.size()) {
336 Range faces = get_adj(unite(saids.first, saids.second), 2);
337 faces = subtract(crack_faces, faces);
338 if (faces.size()) {
339 Range tets;
340 auto fit = faces.begin();
341 for (; fit != faces.end(); ++fit) {
342 tets = intersect(get_adj(Range(*fit, *fit), 3), all_tets);
343 if (tets.size() == 2) {
344 break;
345 }
346 }
347 if (tets.empty()) {
348 break;
349 } else {
350 saids.first.insert(tets[0]);
351 saids.first = grow(saids.first);
352 all_tets = subtract(all_tets, saids.first);
353 if (tets.size() == 2) {
354 saids.second.insert(tets[1]);
355 saids.second = grow(saids.second);
356 all_tets = subtract(all_tets, saids.second);
357 }
358 }
359 } else {
360 break;
361 }
362 }
363
364 saids.first = subtract(all_tets_ord, saids.second);
365 saids.second = subtract(all_tets_ord, saids.first);
366 }
367
369 };
370
371 std::pair<Range, Range> saids;
372 if (crack_faces.size())
373 CHK_THROW_MESSAGE(impl(saids), "get crack both sides");
374 return saids;
375 }
376
377 MOFEM_LOG("EP", Sev::noisy) << "get_two_sides_of_crack_surface <- done";
378
379 return std::pair<Range, Range>();
380}
#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 176 of file EshelbianPlasticity.cpp.

177 {}) {
179 auto out_meshset = get_temp_meshset_ptr(moab);
180 CHKERR moab.add_entities(*out_meshset, r);
181 if (r.size()) {
182 CHKERR moab.write_file(name.c_str(), "VTK", "", out_meshset->get_ptr(), 1,
183 tags.data(), tags.size());
184 } else {
185 MOFEM_LOG("SELF", Sev::warning) << "Empty range for " << name;
186 }
188};
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
/home/lk58p/mofem_install/vanilla_dev_release/mofem-cephas/mofem/users_modules/eshelbian_plasticity/src/impl/EshelbianPlasticity.cpp.

Definition at line 58 of file EshelbianPlasticity.cpp.

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