v0.14.0
Classes | Public Member Functions | Static Public Attributes | List of all members
EshelbianPlasticity::SetIntegrationAtFrontVolume Struct Reference
Collaboration diagram for EshelbianPlasticity::SetIntegrationAtFrontVolume:
[legend]

Classes

struct  VolFe
 

Public Member Functions

 SetIntegrationAtFrontVolume ()=default
 
MoFEMErrorCode operator() (ForcesAndSourcesCore *fe_raw_ptr, int order_row, int order_col, int order_data)
 

Static Public Attributes

static constexpr int numNodes = 4
 
static constexpr int numEdges = 6
 
static constexpr int refinementLevels = 3
 
static boost::shared_ptr< RangefrontNodes
 
static boost::shared_ptr< RangefrontEdges
 
static std::map< long int, MatrixDouble > mapRefCoords
 

Detailed Description

Definition at line 103 of file EshelbianPlasticity.cpp.

Constructor & Destructor Documentation

◆ SetIntegrationAtFrontVolume()

EshelbianPlasticity::SetIntegrationAtFrontVolume::SetIntegrationAtFrontVolume ( )
default

Member Function Documentation

◆ operator()()

MoFEMErrorCode EshelbianPlasticity::SetIntegrationAtFrontVolume::operator() ( ForcesAndSourcesCore fe_raw_ptr,
int  order_row,
int  order_col,
int  order_data 
)
inline

Definition at line 107 of file EshelbianPlasticity.cpp.

108  {
110 
111  auto &m_field = fe_raw_ptr->mField;
112  auto vol_fe_ptr = dynamic_cast<VolFe *>(fe_raw_ptr);
113  auto fe_handle = vol_fe_ptr->getFEEntityHandle();
114 
115  auto set_base_quadrature = [&]() {
117  int rule = 2 * order_data + 1;
118  if (rule < QUAD_3D_TABLE_SIZE) {
119  if (QUAD_3D_TABLE[rule]->dim != 3) {
120  SETERRQ(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
121  "wrong dimension");
122  }
123  if (QUAD_3D_TABLE[rule]->order < rule) {
124  SETERRQ2(m_field.get_comm(), MOFEM_DATA_INCONSISTENCY,
125  "wrong order %d != %d", QUAD_3D_TABLE[rule]->order, rule);
126  }
127  const size_t nb_gauss_pts = QUAD_3D_TABLE[rule]->npoints;
128  auto &gauss_pts = vol_fe_ptr->gaussPts;
129  gauss_pts.resize(4, nb_gauss_pts, false);
130  cblas_dcopy(nb_gauss_pts, &QUAD_3D_TABLE[rule]->points[1], 4,
131  &gauss_pts(0, 0), 1);
132  cblas_dcopy(nb_gauss_pts, &QUAD_3D_TABLE[rule]->points[2], 4,
133  &gauss_pts(1, 0), 1);
134  cblas_dcopy(nb_gauss_pts, &QUAD_3D_TABLE[rule]->points[3], 4,
135  &gauss_pts(2, 0), 1);
136  cblas_dcopy(nb_gauss_pts, QUAD_3D_TABLE[rule]->weights, 1,
137  &gauss_pts(3, 0), 1);
138  auto &data = vol_fe_ptr->dataOnElement[H1];
139  data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 4,
140  false);
141  double *shape_ptr =
142  &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
143  cblas_dcopy(4 * nb_gauss_pts, QUAD_3D_TABLE[rule]->points, 1,
144  shape_ptr, 1);
145  } else {
146  SETERRQ2(PETSC_COMM_SELF, MOFEM_DATA_INCONSISTENCY,
147  "rule > quadrature order %d < %d", rule,
149  }
151  };
152 
153  CHKERR set_base_quadrature();
154 
155  if (frontNodes->size() && EshelbianCore::setSingularity) {
156 
157  auto get_singular_nodes = [&]() {
158  int num_nodes;
159  const EntityHandle *conn;
160  CHKERR m_field.get_moab().get_connectivity(fe_handle, conn, num_nodes,
161  true);
162  std::bitset<numNodes> singular_nodes;
163  for (auto nn = 0; nn != numNodes; ++nn) {
164  if (frontNodes->find(conn[nn]) != frontNodes->end()) {
165  singular_nodes.set(nn);
166  } else {
167  singular_nodes.reset(nn);
168  }
169  }
170  return singular_nodes;
171  };
172 
173  auto get_singular_edges = [&]() {
174  std::bitset<numEdges> singular_edges;
175  for (int ee = 0; ee != numEdges; ee++) {
176  EntityHandle edge;
177  CHKERR m_field.get_moab().side_element(fe_handle, 1, ee, edge);
178  if (frontEdges->find(edge) != frontEdges->end()) {
179  singular_edges.set(ee);
180  } else {
181  singular_edges.reset(ee);
182  }
183  }
184  return singular_edges;
185  };
186 
187  auto set_gauss_pts = [&](auto &ref_gauss_pts) {
189  vol_fe_ptr->gaussPts.swap(ref_gauss_pts);
190  const size_t nb_gauss_pts = vol_fe_ptr->gaussPts.size2();
191  // auto &dataH1 = vol_fe_ptr->dataOnElement[H1];
192  // data->dataOnEntities[MBVERTEX][0].getN(NOBASE).resize(nb_gauss_pts, 4);
193  // double *shape_ptr =
194  // &*data->dataOnEntities[MBVERTEX][0].getN(NOBASE).data().begin();
195  // CHKERR ShapeMBTET(shape_ptr, &vol_fe_ptr->gaussPts(0, 0),
196  // &vol_fe_ptr->gaussPts(1, 0), &gaussPts(2, 0),
197  // nb_gauss_pts);
199  };
200 
201  auto singular_nodes = get_singular_nodes();
202  if (singular_nodes.count()) {
203  auto it_map_ref_coords = mapRefCoords.find(singular_nodes.to_ulong());
204  if (it_map_ref_coords != mapRefCoords.end()) {
205  CHKERR set_gauss_pts(it_map_ref_coords->second);
207  } else {
208 
209  auto refine_quadrature = [&]() {
211 
212  const int max_level = refinementLevels;
213  EntityHandle tet;
214 
215  moab::Core moab_ref;
216  double base_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1};
217  EntityHandle nodes[4];
218  for (int nn = 0; nn != 4; nn++)
219  CHKERR moab_ref.create_vertex(&base_coords[3 * nn], nodes[nn]);
220  CHKERR moab_ref.create_element(MBTET, nodes, 4, tet);
221  MoFEM::CoreTmp<-1> mofem_ref_core(moab_ref, PETSC_COMM_SELF, -2);
222  MoFEM::Interface &m_field_ref = mofem_ref_core;
223  CHKERR m_field_ref.getInterface<BitRefManager>()
224  ->setBitRefLevelByDim(0, 3, BitRefLevel().set(0));
225 
226  Range nodes_at_front;
227  for (int nn = 0; nn != numNodes; nn++) {
228  if (singular_nodes[nn]) {
229  EntityHandle ent;
230  CHKERR moab_ref.side_element(tet, 0, nn, ent);
231  nodes_at_front.insert(ent);
232  }
233  }
234 
235  auto singular_edges = get_singular_edges();
236 
237  EntityHandle meshset;
238  CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
239  for (int ee = 0; ee != 6; ee++) {
240  if (singular_edges[ee]) {
241  EntityHandle ent;
242  CHKERR moab_ref.side_element(tet, 1, ee, ent);
243  CHKERR moab_ref.add_entities(meshset, &ent, 1);
244  }
245  }
246 
247  // refine mesh
248  auto *m_ref = m_field_ref.getInterface<MeshRefinement>();
249  for (int ll = 0; ll != max_level; ll++) {
250  Range edges;
251  CHKERR m_field_ref.getInterface<BitRefManager>()
252  ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(ll),
253  BitRefLevel().set(), MBEDGE,
254  edges);
255  Range ref_edges;
256  CHKERR moab_ref.get_adjacencies(
257  nodes_at_front, 1, true, ref_edges, moab::Interface::UNION);
258  ref_edges = intersect(ref_edges, edges);
259  Range ents;
260  CHKERR moab_ref.get_entities_by_type(meshset, MBEDGE, ents, true);
261  ref_edges = intersect(ref_edges, ents);
262  Range tets;
263  CHKERR m_field_ref.getInterface<BitRefManager>()
264  ->getEntitiesByTypeAndRefLevel(
265  BitRefLevel().set(ll), BitRefLevel().set(), MBTET, tets);
266  CHKERR m_ref->addVerticesInTheMiddleOfEdges(
267  ref_edges, BitRefLevel().set(ll + 1));
268  CHKERR m_ref->refineTets(tets, BitRefLevel().set(ll + 1));
269  CHKERR m_field_ref.getInterface<BitRefManager>()
270  ->updateMeshsetByEntitiesChildren(meshset,
271  BitRefLevel().set(ll + 1),
272  meshset, MBEDGE, true);
273  }
274 
275  // get ref coords
276  Range tets;
277  CHKERR m_field_ref.getInterface<BitRefManager>()
278  ->getEntitiesByTypeAndRefLevel(BitRefLevel().set(max_level),
279  BitRefLevel().set(), MBTET,
280  tets);
281  MatrixDouble ref_coords(tets.size(), 12, false);
282  int tt = 0;
283  for (Range::iterator tit = tets.begin(); tit != tets.end();
284  tit++, tt++) {
285  int num_nodes;
286  const EntityHandle *conn;
287  CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes, false);
288  CHKERR moab_ref.get_coords(conn, num_nodes, &ref_coords(tt, 0));
289  }
290 
291  auto &data = vol_fe_ptr->dataOnElement[H1];
292  const size_t nb_gauss_pts = vol_fe_ptr->gaussPts.size2();
293  MatrixDouble ref_gauss_pts(4, nb_gauss_pts * ref_coords.size1());
294  MatrixDouble &shape_n =
295  data->dataOnEntities[MBVERTEX][0].getN(NOBASE);
296  int gg = 0;
297  for (size_t tt = 0; tt != ref_coords.size1(); tt++) {
298  double *tet_coords = &ref_coords(tt, 0);
299  double det = Tools::tetVolume(tet_coords);
300  det *= 6;
301  for (size_t ggg = 0; ggg != nb_gauss_pts; ++ggg, ++gg) {
302  for (int dd = 0; dd != 3; dd++) {
303  ref_gauss_pts(dd, gg) =
304  shape_n(ggg, 0) * tet_coords[3 * 0 + dd] +
305  shape_n(ggg, 1) * tet_coords[3 * 1 + dd] +
306  shape_n(ggg, 2) * tet_coords[3 * 2 + dd] +
307  shape_n(ggg, 3) * tet_coords[3 * 3 + dd];
308  }
309  ref_gauss_pts(3, gg) = vol_fe_ptr->gaussPts(3, ggg) * det;
310  }
311  }
312 
313  mapRefCoords[singular_nodes.to_ulong()].swap(ref_gauss_pts);
314  CHKERR set_gauss_pts(mapRefCoords[singular_nodes.to_ulong()]);
315 
317  };
318  }
319  }
320  }
321 
323  }

Member Data Documentation

◆ frontEdges

boost::shared_ptr<Range> EshelbianPlasticity::SetIntegrationAtFrontVolume::frontEdges
inlinestatic

Definition at line 335 of file EshelbianPlasticity.cpp.

◆ frontNodes

boost::shared_ptr<Range> EshelbianPlasticity::SetIntegrationAtFrontVolume::frontNodes
inlinestatic

Definition at line 334 of file EshelbianPlasticity.cpp.

◆ mapRefCoords

std::map<long int, MatrixDouble> EshelbianPlasticity::SetIntegrationAtFrontVolume::mapRefCoords
inlinestatic

Definition at line 336 of file EshelbianPlasticity.cpp.

◆ numEdges

constexpr int EshelbianPlasticity::SetIntegrationAtFrontVolume::numEdges = 6
inlinestaticconstexpr

Definition at line 331 of file EshelbianPlasticity.cpp.

◆ numNodes

constexpr int EshelbianPlasticity::SetIntegrationAtFrontVolume::numNodes = 4
inlinestaticconstexpr

Definition at line 330 of file EshelbianPlasticity.cpp.

◆ refinementLevels

constexpr int EshelbianPlasticity::SetIntegrationAtFrontVolume::refinementLevels = 3
inlinestaticconstexpr

Definition at line 332 of file EshelbianPlasticity.cpp.


The documentation for this struct was generated from the following file:
MoFEMFunctionReturnHot
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:460
MoFEM::UnknownInterface::getInterface
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Definition: UnknownInterface.hpp:93
H1
@ H1
continuous field
Definition: definitions.h:85
EntityHandle
EshelbianPlasticity::SetIntegrationAtFrontVolume::mapRefCoords
static std::map< long int, MatrixDouble > mapRefCoords
Definition: EshelbianPlasticity.cpp:336
NOBASE
@ NOBASE
Definition: definitions.h:59
MoFEM::Types::MatrixDouble
UBlasMatrix< double > MatrixDouble
Definition: Types.hpp:77
QUAD_::order
int order
Definition: quad.h:28
order
constexpr int order
Definition: dg_projection.cpp:18
MoFEM::DeprecatedCoreInterface
Deprecated interface functions.
Definition: DeprecatedCoreInterface.hpp:16
CHKERR
#define CHKERR
Inline error check.
Definition: definitions.h:548
EshelbianPlasticity::SetIntegrationAtFrontVolume::refinementLevels
static constexpr int refinementLevels
Definition: EshelbianPlasticity.cpp:332
MoFEM::MeshRefinement
Mesh refinement interface.
Definition: MeshRefinement.hpp:26
MoFEM::CoreTmp
Definition: Core.hpp:36
QUAD_::npoints
int npoints
Definition: quad.h:29
EshelbianPlasticity::EshelbianCore::setSingularity
static PetscBool setSingularity
Definition: EshelbianPlasticity.hpp:900
QUAD_3D_TABLE
static QUAD *const QUAD_3D_TABLE[]
Definition: quad.h:187
EshelbianPlasticity::SetIntegrationAtFrontVolume::numEdges
static constexpr int numEdges
Definition: EshelbianPlasticity.cpp:331
QUAD_3D_TABLE_SIZE
#define QUAD_3D_TABLE_SIZE
Definition: quad.h:186
EshelbianPlasticity::SetIntegrationAtFrontVolume::numNodes
static constexpr int numNodes
Definition: EshelbianPlasticity.cpp:330
Range
FTensor::dd
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
Definition: ddTensor0.hpp:33
MoFEM::Core
CoreTmp< 0 > Core
Definition: Core.hpp:1148
MOFEM_DATA_INCONSISTENCY
@ MOFEM_DATA_INCONSISTENCY
Definition: definitions.h:31
MoFEM::BitRefManager
Managing BitRefLevels.
Definition: BitRefManager.hpp:21
MoFEM::Types::BitRefLevel
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:40
EshelbianPlasticity::SetIntegrationAtFrontVolume::frontNodes
static boost::shared_ptr< Range > frontNodes
Definition: EshelbianPlasticity.cpp:334
MoFEMFunctionReturn
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
Definition: definitions.h:429
EshelbianPlasticity::SetIntegrationAtFrontVolume::frontEdges
static boost::shared_ptr< Range > frontEdges
Definition: EshelbianPlasticity.cpp:335
MoFEMFunctionBegin
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Definition: definitions.h:359
MoFEM::ForcesAndSourcesCore::mField
Interface & mField
Definition: ForcesAndSourcesCore.hpp:24