v0.15.0
Loading...
Searching...
No Matches
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::EshelbianMonitor
 
struct  EshelbianPlasticity::SetUpSchurImpl
 
struct  EshelbianPlasticity::SetUpSchurImpl::P_MultiGridData
 
struct  EshelbianPlasticity::TSElasticPostStep
 
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 8 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 177 of file EshelbianPlasticity.cpp.

177 {
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};
#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 166 of file EshelbianPlasticity.cpp.

166 {
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};

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

145 {
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};
#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 194 of file EshelbianPlasticity.cpp.

195 {
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}
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 100 of file EshelbianPlasticity.cpp.

101 {
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};
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 122 of file EshelbianPlasticity.cpp.

123 {
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}

◆ get_skin()

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

Definition at line 187 of file EshelbianPlasticity.cpp.

187 {
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};

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

235 {
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}
#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 152 of file EshelbianPlasticity.cpp.

153 {}) {
155 auto out_meshset = get_temp_meshset_ptr(moab);
156 CHKERR moab.add_entities(*out_meshset, r);
157 if (r.size()) {
158 CHKERR moab.write_file(name.c_str(), "VTK", "", out_meshset->get_ptr(), 1,
159 tags.data(), tags.size());
160 } else {
161 MOFEM_LOG("SELF", Sev::warning) << "Empty range for " << name;
162 }
164};
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 54 of file EshelbianPlasticity.cpp.

55 {
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}
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.