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();
115 auto set_base_quadrature = [&]() {
117 int rule = 2 * order_data + 1;
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);
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,
142 &*data->dataOnEntities[MBVERTEX][0].getN(
NOBASE).data().begin();
143 cblas_dcopy(4 * nb_gauss_pts,
QUAD_3D_TABLE[rule]->points, 1,
147 "rule > quadrature order %d < %d", rule,
153 CHKERR set_base_quadrature();
157 auto get_singular_nodes = [&]() {
160 CHKERR m_field.get_moab().get_connectivity(fe_handle, conn, num_nodes,
162 std::bitset<numNodes> singular_nodes;
163 for (
auto nn = 0; nn !=
numNodes; ++nn) {
165 singular_nodes.set(nn);
167 singular_nodes.reset(nn);
170 return singular_nodes;
173 auto get_singular_edges = [&]() {
174 std::bitset<numEdges> singular_edges;
175 for (
int ee = 0; ee !=
numEdges; ee++) {
177 CHKERR m_field.get_moab().side_element(fe_handle, 1, ee, edge);
179 singular_edges.set(ee);
181 singular_edges.reset(ee);
184 return singular_edges;
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();
201 auto singular_nodes = get_singular_nodes();
202 if (singular_nodes.count()) {
203 auto it_map_ref_coords =
mapRefCoords.find(singular_nodes.to_ulong());
205 CHKERR set_gauss_pts(it_map_ref_coords->second);
209 auto refine_quadrature = [&]() {
216 double base_coords[] = {0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1};
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);
226 Range nodes_at_front;
227 for (
int nn = 0; nn !=
numNodes; nn++) {
228 if (singular_nodes[nn]) {
230 CHKERR moab_ref.side_element(tet, 0, nn, ent);
231 nodes_at_front.insert(ent);
235 auto singular_edges = get_singular_edges();
238 CHKERR moab_ref.create_meshset(MESHSET_SET, meshset);
239 for (
int ee = 0; ee != 6; ee++) {
240 if (singular_edges[ee]) {
242 CHKERR moab_ref.side_element(tet, 1, ee, ent);
243 CHKERR moab_ref.add_entities(meshset, &ent, 1);
249 for (
int ll = 0; ll != max_level; ll++) {
252 ->getEntitiesByTypeAndRefLevel(
BitRefLevel().set(ll),
256 CHKERR moab_ref.get_adjacencies(
257 nodes_at_front, 1,
true, ref_edges, moab::Interface::UNION);
258 ref_edges = intersect(ref_edges, edges);
260 CHKERR moab_ref.get_entities_by_type(meshset, MBEDGE, ents,
true);
261 ref_edges = intersect(ref_edges, ents);
264 ->getEntitiesByTypeAndRefLevel(
266 CHKERR m_ref->addVerticesInTheMiddleOfEdges(
270 ->updateMeshsetByEntitiesChildren(meshset,
272 meshset, MBEDGE,
true);
278 ->getEntitiesByTypeAndRefLevel(
BitRefLevel().set(max_level),
283 for (Range::iterator tit = tets.begin(); tit != tets.end();
287 CHKERR moab_ref.get_connectivity(*tit, conn, num_nodes,
false);
288 CHKERR moab_ref.get_coords(conn, num_nodes, &ref_coords(tt, 0));
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());
295 data->dataOnEntities[MBVERTEX][0].getN(
NOBASE);
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);
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];
309 ref_gauss_pts(3, gg) = vol_fe_ptr->gaussPts(3, ggg) * det;
313 mapRefCoords[singular_nodes.to_ulong()].swap(ref_gauss_pts);