11 #ifndef AUX_MESH_TOPOLOGY_H_ 12 #define AUX_MESH_TOPOLOGY_H_ 30 return (sxyz[1][0]-sxyz[0][0]);
38 return 0.5*
cross(vec1, vec2);
48 return dot(cpvec, vec3)/6.0;
52 template<
typename BasicMesh>
54 template<
typename BasicMesh>
56 template<
typename BasicMesh>
175 template<
typename BasicMesh>
186 bool request_wedges =
true,
187 bool request_corners =
true) :
188 sides_requested_(request_sides || request_wedges || request_corners),
189 wedges_requested_(request_wedges || request_corners),
190 corners_requested_(request_corners) {
196 sides_requested_ =
true;
203 basicmesh_ptr_ =
static_cast<BasicMesh*
>(
this);
224 return num_sides_owned_;
231 return num_wedges_owned_;
238 return num_corners_owned_;
245 return num_sides_ghost_;
252 return num_wedges_ghost_;
259 return num_corners_ghost_;
271 case ALL:
return (basicmesh_ptr_->num_owned_cells() +
272 basicmesh_ptr_->num_ghost_cells());
279 case ALL:
return (basicmesh_ptr_->num_owned_faces() +
280 basicmesh_ptr_->num_ghost_faces());
287 case ALL:
return (basicmesh_ptr_->num_owned_nodes() +
288 basicmesh_ptr_->num_ghost_nodes());
343 std::vector<int> *adjcells)
const {
352 std::vector<int> cellnodes;
353 basicmesh_ptr_->cell_get_nodes(cellid, &cellnodes);
357 for (
auto const& n : cellnodes) {
358 std::vector<int> nodecells;
359 basicmesh_ptr_->node_get_cells(n, ptype, &nodecells);
361 for (
auto const& c : nodecells) {
362 if (c == cellid)
continue;
363 if (std::find(adjcells->begin(), adjcells->end(), c) == adjcells->end())
364 adjcells->push_back(c);
372 std::vector<int> *cells)
const {
374 int c0 = face_cell_ids_[faceid][0];
376 Entity_type ctype0 = basicmesh_ptr_->cell_get_type(c0);
378 cells->push_back(c0);
380 int c1 = face_cell_ids_[faceid][1];
382 Entity_type ctype1 = basicmesh_ptr_->cell_get_type(c1);
384 cells->push_back(c1);
396 std::vector<int> cellfaces;
398 int const nb_adj_cells = cellfaces.size();
401 if (nb_adj_cells == 2) {
402 int index = (cellfaces[0] == cell ? 1 : 0);
403 return cellfaces[index];
420 std::vector<int> *adjcells)
const {
424 std::vector<int> cellfaces, cfdirs;
425 basicmesh_ptr_->cell_get_faces_and_dirs(cellid, &cellfaces, &cfdirs);
428 for (
auto const& f : cellfaces) {
429 std::vector<int> facecells;
430 basicmesh_ptr_->face_get_cells(f, ptype, &facecells);
433 if (facecells.size() == 2) {
434 int iac = (facecells[0] == cellid) ? 1 : 0;
435 adjcells->push_back(facecells[iac]);
450 std::vector<int> *adjnodes)
const {
458 std::vector<int> nodecells;
463 for (
auto const& c : nodecells) {
464 std::vector<int> cellnodes;
465 basicmesh_ptr_->cell_get_nodes(c, &cellnodes);
467 for (
auto const& n : cellnodes) {
468 if (n == nodeid)
continue;
469 Entity_type ntype = basicmesh_ptr_->node_get_type(n);
471 if (std::find(adjnodes->begin(), adjnodes->end(), n) == adjnodes->end())
472 adjnodes->push_back(n);
483 return node_on_exterior_boundary_[entity_id];
485 return face_on_exterior_boundary_[entity_id];
487 return cell_on_exterior_boundary_[entity_id];
489 return cell_on_exterior_boundary_[side_cell_id_[entity_id]];
491 return cell_on_exterior_boundary_[corner_cell_id_[entity_id]];
511 for (
int d = 0; d < D; ++d)
512 (*ccen)[d] = cell_centroids_[cellid][d];
521 assert(sides_requested_);
522 return cell_volumes_[cellid];
533 for (
int d = 0; d < D; ++d)
534 (*fcen)[d] = face_centroids_[faceid][d];
551 assert(sides_requested_);
552 assert(inode == 0 || inode == 1);
553 return side_node_ids_[sideid][inode];
563 assert(sides_requested_);
564 return side_cell_id_[sideid];
574 assert(sides_requested_);
575 return side_face_id_[sideid];
590 assert(wedges_requested_);
591 return 2*sideid + iwedge;
606 assert(sides_requested_);
607 return side_opp_side_id_[sideid];
617 assert(sides_requested_);
618 csides->resize(cell_side_ids_[cellid].size());
619 std::copy(cell_side_ids_[cellid].
begin(), cell_side_ids_[cellid].
end(),
636 bool posvol_order =
false)
const;
651 bool posvol_order =
false)
const;
664 bool posvol_order =
false)
const;
673 assert(sides_requested_);
674 return side_volumes_[sideid];
683 assert(wedges_requested_);
684 return static_cast<int>(wedgeid/2);
694 assert(wedges_requested_);
695 int sideid =
static_cast<int>(wedgeid/2);
696 return side_cell_id_[sideid];
706 assert(wedges_requested_);
707 int sideid =
static_cast<int>(wedgeid/2);
708 return side_face_id_[sideid];
718 assert(corners_requested_);
719 return wedge_corner_id_[wedgeid];
729 assert(wedges_requested_);
730 int sideid =
static_cast<int>(wedgeid/2);
731 return wedgeid%2 ? side_node_ids_[sideid][1] : side_node_ids_[sideid][0];
746 assert(wedges_requested_);
747 int sideid =
static_cast<int>(wedgeid/2);
748 int oppsideid = side_opp_side_id_[sideid];
750 return (wedgeid%2 ? 2*oppsideid : 2*oppsideid + 1);
771 return (wedgeid%2 ? wedgeid - 1 : wedgeid + 1);
781 int sideid =
static_cast<int>(wedgeid/2);
782 return 0.5*side_volumes_[sideid];
799 bool posvol_order =
false)
const;
815 bool posvol_order =
false)
const;
829 bool posvol_order =
false)
const;
838 int nsides = cell_side_ids_[cellid].size();
839 wedgeids->resize(2*nsides);
841 for (
auto const& s : cell_side_ids_[cellid]) {
842 (*wedgeids)[iw++] = 2*s;
843 (*wedgeids)[iw++] = 2*s + 1;
851 std::vector<int> *wedgeids)
const {
855 assert(wedges_requested_ && corners_requested_);
857 for (
auto const& cn : node_corner_ids_[nodeid]) {
858 std::vector<int> cnwedges = corner_wedge_ids_[cn];
859 for (
auto const& w : cnwedges) {
860 int s =
static_cast<int>(w/2);
861 int c = side_cell_id_[s];
864 static_cast<int>(basicmesh_ptr_->cell_get_type(c)) == type)
865 wedgeids->push_back(w);
877 assert(corners_requested_);
878 return corner_node_id_[cornerid];
888 assert(corners_requested_);
889 return corner_cell_id_[cornerid];
899 assert(corners_requested_);
900 wedgeids->resize(corner_wedge_ids_[cornerid].size());
901 std::copy(corner_wedge_ids_[cornerid].
begin(),
902 corner_wedge_ids_[cornerid].
end(), wedgeids->begin());
909 std::vector<int> *cornerids)
const {
913 assert(corners_requested_);
915 cornerids->resize(node_corner_ids_[nodeid].size());
916 std::copy(node_corner_ids_[nodeid].
begin(),
917 node_corner_ids_[nodeid].
end(),
921 for (
auto const& cn : node_corner_ids_[nodeid]) {
922 int c = corner_cell_id_[cn];
923 if (static_cast<int>(basicmesh_ptr_->cell_get_type(c)) == type)
924 cornerids->push_back(cn);
936 assert(corners_requested_);
937 cornerids->resize(cell_corner_ids_[cellid].size());
938 std::copy(cell_corner_ids_[cellid].
begin(), cell_corner_ids_[cellid].
end(),
948 assert(corners_requested_);
949 for (
auto const& cn : cell_corner_ids_[cellid]) {
954 throw std::runtime_error(
"no corner found");
963 assert(corners_requested_);
965 for (
auto const& w : corner_wedge_ids_[cornerid])
987 const bool planar_hex)
const {
992 && basicmesh_ptr_->cell_get_element_type(cellid) ==
HEX) {
997 std::vector<Point<3>> coords;
998 basicmesh_ptr_->cell_get_coordinates(cellid, &coords);
1021 const int indexes[5][4] = {
1028 for (
unsigned int t = 0; t < 5; t++) {
1029 std::array<Wonton::Point<3>, 4> tmp;
1030 for (
int i = 0; i < 4; i++) {
1031 for (
int j = 0; j < 3; j++) {
1032 tmp[i][j] = coords[indexes[t][i]][j];
1035 tcoords->push_back(tmp);
1057 assert(basicmesh_ptr_->space_dimension() == 2);
1058 assert(wedges_requested_);
1060 int cornerid, wedgeid, wedgeid0;
1061 std::vector<int> cornerids, wedgeids;
1062 std::array<Point<2>, 3> wcoords;
1066 cornerid = cornerids[0];
1072 pplist->emplace_back(wcoords[2]);
1074 pplist->emplace_back(wcoords[1]);
1076 wedgeid0 = wedgeids[0];
1082 while (wedgeid != -1 && wedgeid != wedgeid0) {
1086 assert(wedgeids[0] == wedgeid);
1088 pplist->push_back(wcoords[2]);
1090 pplist->push_back(wcoords[1]);
1094 if (wedgeid == -1) {
1099 pplist->insert(pplist->begin(), wcoords[1]);
1104 while (wedgeid != -1) {
1108 assert(wedgeids[1] == wedgeid);
1111 pplist->insert(pplist->begin(), wcoords[2]);
1114 pplist->insert(pplist->begin(), wcoords[1]);
1119 pplist->insert(pplist->begin(), wcoords[0]);
1127 assert(wedges_requested_);
1128 assert(wedgeids->size() == 2);
1129 std::array<Point<2>, 3> wcoords;
1133 if (!
ccw(wcoords[0], wcoords[1], wcoords[2])) {
1134 std::swap((*wedgeids)[0], (*wedgeids)[1]);
1142 return (p2[0] - p1[0]) * (p3[1] - p1[1]) -
1143 (p2[1] - p1[1]) * (p3[0] - p1[0]) > 0;
1148 std::vector<Point<2>> cellPoints;
1149 basicmesh_ptr_->cell_get_coordinates(cellID, &cellPoints);
1157 assert(basicmesh_ptr_->space_dimension() == 3);
1158 assert(wedges_requested_);
1160 std::vector<int> wedges;
1162 int nwedges = wedges.size();
1164 wcoords->resize(nwedges);
1165 for (
int i = 0; i < nwedges; ++i)
1173 assert(basicmesh_ptr_->space_dimension() == 3);
1174 assert(sides_requested_);
1176 std::vector<int> sides;
1178 int nsides = sides.size();
1180 scoords->resize(nsides);
1181 for (
int i = 0; i < nsides; ++i)
1188 std::vector<int> *adjnodes)
const {
1192 basicmesh_ptr_->node_get_cell_adj_nodes(nodeid, ptype, adjnodes);
1206 assert(basicmesh_ptr_->space_dimension() == 3);
1207 assert(wedges_requested_);
1214 std::array<Point<3>, 4> wcoords;
1216 std::vector<int> wedgeids;
1219 std::vector<int> face_list, cell_list;
1220 std::vector<std::pair<int, int>> edge_list;
1222 for (
auto wedgeid : wedgeids) {
1228 if (n0 > n1) std::swap(n0, n1);
1229 std::pair<int, int> node_pair(n0, n1);
1230 if (std::find(edge_list.begin(), edge_list.end(), node_pair) ==
1235 edge_list.emplace_back(node_pair);
1236 pplist->emplace_back(wcoords[1]);
1240 if (std::find(face_list.begin(), face_list.end(), faceid) ==
1245 face_list.push_back(faceid);
1246 pplist->emplace_back(wcoords[2]);
1250 if (std::find(cell_list.begin(), cell_list.end(), cellid) ==
1255 cell_list.push_back(cellid);
1256 pplist->emplace_back(wcoords[3]);
1268 assert(wedges_requested_);
1269 std::vector<int> wedges;
1271 int nwedges = wedges.size();
1272 wcoords->resize(nwedges);
1274 for (
int i = 0; i < nwedges; ++i)
1287 assert(wedges_requested_);
1289 bool posvol_order =
true;
1290 std::vector<int> wedgeids;
1293 for (
int i = 0; i < D; i++) (*centroid)[i] = 0.0;
1295 for (
auto const wid : wedgeids) {
1299 std::array<Point<D>, D+1> wcoords;
1301 for (
int i = 0; i < D+1; i++)
1306 *centroid += wvol*wcen;
1310 if (vol > std::numeric_limits<double>::epsilon()) *centroid /= vol;
1311 else *centroid = geom_cen/wedgeids.size();
1320 assert(corners_requested_);
1321 std::vector<int> cornerids;
1324 for (
auto const cid : cornerids)
1332 int dim = basicmesh_ptr_->space_dimension();
1357 compute_approximate_face_centroids<1>();
1358 compute_approximate_cell_centroids<1>();
1360 if (sides_requested_)
1363 compute_face_centroids<1>();
1364 compute_cell_centroids<1>();
1366 if (sides_requested_)
1367 compute_side_volumes<1>();
1369 }
else if (dim == 2) {
1370 compute_approximate_face_centroids<2>();
1371 compute_approximate_cell_centroids<2>();
1373 if (sides_requested_)
1376 compute_face_centroids<2>();
1377 compute_cell_centroids<2>();
1379 if (sides_requested_)
1380 compute_side_volumes<2>();
1382 }
else if (dim == 3) {
1383 compute_approximate_face_centroids<3>();
1384 compute_approximate_cell_centroids<3>();
1386 if (sides_requested_)
1389 compute_face_centroids<3>();
1390 compute_cell_centroids<3>();
1392 if (sides_requested_)
1393 compute_side_volumes<3>();
1396 compute_cell_volumes();
1398 if (wedges_requested_) build_wedges();
1399 if (corners_requested_) build_corners();
1401 build_face_to_cell_adjacency();
1402 flag_entities_on_exterior_boundary();
1407 template<
int dim>
void compute_approximate_cell_centroids();
1408 template<
int dim>
void compute_approximate_face_centroids();
1409 template<
int dim>
void compute_cell_centroids();
1410 template<
int dim>
void compute_face_centroids();
1411 template<
int dim>
void compute_side_volumes();
1412 void compute_cell_volumes();
1414 void build_wedges();
1415 void build_corners();
1417 void build_face_to_cell_adjacency();
1418 void flag_entities_on_exterior_boundary();
1437 BasicMesh *basicmesh_ptr_ =
nullptr;
1438 bool sides_requested_ =
true;
1439 bool wedges_requested_ =
true;
1440 bool corners_requested_ =
true;
1442 std::vector<int> sideids_owned_, sideids_ghost_, sideids_all_;
1443 std::vector<int> wedgeids_owned_, wedgeids_ghost_, wedgeids_all_;
1444 std::vector<int> cornerids_owned_, cornerids_ghost_, cornerids_all_;
1446 int num_sides_owned_ = 0, num_sides_ghost_ = 0;
1447 int num_wedges_owned_ = 0, num_wedges_ghost_ = 0;
1448 int num_corners_owned_ = 0, num_corners_ghost_ = 0;
1451 std::vector<double> cell_volumes_;
1456 std::vector<std::vector<double>> cell_centroids_;
1459 std::vector<std::vector<double>> face_centroids_;
1464 std::vector<std::array<int, 2>> face_cell_ids_;
1467 std::vector<int> side_cell_id_;
1468 std::vector<int> side_face_id_;
1469 std::vector<std::array<int, 2>> side_node_ids_;
1470 std::vector<int> side_opp_side_id_;
1471 std::vector<double> side_volumes_;
1474 std::vector<int> wedge_corner_id_;
1479 std::vector<int> corner_node_id_;
1480 std::vector<int> corner_cell_id_;
1484 std::vector<std::vector<int>> cell_side_ids_;
1485 std::vector<std::vector<int>> cell_corner_ids_;
1486 std::vector<std::vector<int>> node_corner_ids_;
1487 std::vector<std::vector<int>> corner_wedge_ids_;
1490 std::vector<bool> cell_on_exterior_boundary_;
1491 std::vector<bool> face_on_exterior_boundary_;
1492 std::vector<bool> node_on_exterior_boundary_;
1498 template<
typename BasicMesh>
1504 std::array<int, 2> iniarr = {-1, -1};
1505 face_cell_ids_.assign(nfaces, iniarr);
1509 for (
int c = 0; c < ncells; c++) {
1510 std::vector<int> cfaces;
1511 std::vector<int> cfdirs;
1512 basicmesh_ptr_->cell_get_faces_and_dirs(c, &cfaces, &cfdirs);
1513 for (
auto const& f : cfaces) {
1514 if (face_cell_ids_[f][0] == -1)
1515 face_cell_ids_[f][0] = c;
1517 face_cell_ids_[f][1] = c;
1524 template <
typename BasicMesh>
1541 cell_on_exterior_boundary_.assign(ncells,
false);
1542 face_on_exterior_boundary_.assign(nfaces,
false);
1543 node_on_exterior_boundary_.assign(nnodes,
false);
1545 for (
int f = 0; f < nfaces; f++) {
1546 std::vector<int> fcells;
1549 if (fcells.size() == 1) {
1550 face_on_exterior_boundary_[f] =
true;
1551 cell_on_exterior_boundary_[fcells[0]] =
true;
1554 std::vector<int> fnodes;
1555 basicmesh_ptr_->face_get_nodes(f, &fnodes);
1556 for (
auto const &n : fnodes)
1557 node_on_exterior_boundary_[n] =
true;
1563 template<
typename BasicMesh>
1566 bool posvol_order)
const {
1567 int c = side_cell_id_[s];
1568 int n = side_node_ids_[s][0];
1570 basicmesh_ptr_->node_get_coordinates(n, &nxyz);
1579 if (posvol_order && s%2) {
1581 (*scoords)[1] = nxyz;
1583 (*scoords)[0] = nxyz;
1590 template<
typename BasicMesh>
1593 bool posvol_order)
const {
1594 int c = side_cell_id_[s];
1596 n[0] = side_node_ids_[s][0];
1597 n[1] = side_node_ids_[s][1];
1602 basicmesh_ptr_->node_get_coordinates(n[0], &((*scoords)[0]));
1603 basicmesh_ptr_->node_get_coordinates(n[1], &((*scoords)[1]));
1609 template<
typename BasicMesh>
1612 bool posvol_order)
const {
1613 int c = side_cell_id_[s];
1614 int f = side_face_id_[s];
1616 n[0] = side_node_ids_[s][0];
1617 n[1] = side_node_ids_[s][1];
1622 basicmesh_ptr_->node_get_coordinates(n[0], &((*scoords)[0]));
1623 basicmesh_ptr_->node_get_coordinates(n[1], &((*scoords)[1]));
1631 template<
typename BasicMesh>
1634 bool posvol_order)
const {
1636 int c = side_cell_id_[s];
1638 int n = side_node_ids_[s][iw];
1640 basicmesh_ptr_->node_get_coordinates(n, &nxyz);
1641 if (posvol_order && iw) {
1643 (*wcoords)[1] = nxyz;
1645 (*wcoords)[0] = nxyz;
1652 template<
typename BasicMesh>
1655 bool posvol_order)
const {
1657 int c = side_cell_id_[s];
1660 n[0] = side_node_ids_[s][0];
1661 n[1] = side_node_ids_[s][1];
1663 basicmesh_ptr_->node_get_coordinates(n[0], &nxyz[0]);
1664 basicmesh_ptr_->node_get_coordinates(n[1], &nxyz[1]);
1665 Point<2> exyz = (nxyz[0] + nxyz[1])/2;
1666 if (posvol_order && iw) {
1667 (*wcoords)[0] = nxyz[iw];
1669 (*wcoords)[2] = exyz;
1671 (*wcoords)[0] = nxyz[iw];
1672 (*wcoords)[1] = exyz;
1679 template<
typename BasicMesh>
1682 bool posvol_order)
const {
1684 int c = side_cell_id_[s];
1685 int f = side_face_id_[s];
1688 n[0] = side_node_ids_[s][0];
1689 n[1] = side_node_ids_[s][1];
1691 basicmesh_ptr_->node_get_coordinates(n[0], &nxyz[0]);
1692 basicmesh_ptr_->node_get_coordinates(n[1], &nxyz[1]);
1693 Point<3> exyz = (nxyz[0] + nxyz[1])/2.0;
1694 if (posvol_order && iw) {
1695 (*wcoords)[0] = nxyz[iw];
1697 (*wcoords)[2] = exyz;
1700 (*wcoords)[0] = nxyz[iw];
1701 (*wcoords)[1] = exyz;
1711 template<
typename BasicMesh>
1713 int ncells_owned = mesh.basicmesh_ptr_->num_owned_cells();
1714 int ncells_ghost = mesh.basicmesh_ptr_->num_ghost_cells();
1715 int ncells = ncells_owned + ncells_ghost;
1717 mesh.cell_side_ids_.clear();
1718 mesh.cell_side_ids_.resize(ncells);
1720 int num_sides_all = 2*ncells;
1721 mesh.num_sides_owned_ = 2*ncells_owned;
1722 mesh.num_sides_ghost_ = 2*ncells_ghost;
1724 for (
int c = 0; c < ncells; ++c)
1725 mesh.cell_side_ids_[c].reserve(2);
1727 mesh.sideids_owned_.resize(mesh.num_sides_owned_);
1728 mesh.sideids_ghost_.resize(mesh.num_sides_ghost_);
1729 mesh.sideids_all_.resize(num_sides_all);
1730 mesh.side_cell_id_.assign(num_sides_all, -1);
1731 mesh.side_face_id_.assign(num_sides_all, -1);
1732 mesh.side_opp_side_id_.assign(num_sides_all, -1);
1733 mesh.side_node_ids_.assign(num_sides_all, {{-1, -1}});
1735 int iall = 0, iown = 0, ighost = 0;
1736 for (
int c = 0; c < ncells; ++c) {
1739 std::vector<int> nodeids;
1740 mesh.basicmesh_ptr_->cell_get_nodes(c, &nodeids);
1742 mesh.cell_side_ids_[c].push_back(sideid);
1743 mesh.cell_side_ids_[c].push_back(sideid+1);
1744 mesh.sideids_all_[iall++] = sideid;
1745 mesh.sideids_all_[iall++] = sideid+1;
1747 mesh.sideids_owned_[iown++] = sideid;
1748 mesh.sideids_owned_[iown++] = sideid+1;
1749 }
else if (mesh.basicmesh_ptr_->cell_get_type(c) ==
PARALLEL_GHOST) {
1750 mesh.sideids_ghost_[ighost++] = sideid;
1751 mesh.sideids_ghost_[ighost++] = sideid+1;
1756 mesh.side_node_ids_[sideid][0] = nodeids[0];
1757 mesh.side_node_ids_[sideid][1] = nodeids[0];
1758 mesh.side_node_ids_[sideid+1][0] = nodeids[1];
1759 mesh.side_node_ids_[sideid+1][1] = nodeids[1];
1761 mesh.side_cell_id_[sideid ] = c;
1762 mesh.side_cell_id_[sideid+1] = c;
1765 mesh.side_face_id_[sideid ] = nodeids[0];
1766 mesh.side_face_id_[sideid+1] = nodeids[1];
1769 mesh.side_opp_side_id_[sideid ] = (sideid == 0) ? -1 : sideid-1;
1770 mesh.side_opp_side_id_[sideid+1] = (sideid+1 == num_sides_all-1) ?
1778 template<
typename BasicMesh>
1780 int ncells_owned = mesh.basicmesh_ptr_->num_owned_cells();
1781 int ncells_ghost = mesh.basicmesh_ptr_->num_ghost_cells();
1782 int ncells = ncells_owned + ncells_ghost;
1784 mesh.cell_side_ids_.clear();
1785 mesh.cell_side_ids_.resize(ncells);
1787 int nnodes_owned = mesh.basicmesh_ptr_->num_owned_nodes();
1788 int nnodes_ghost = mesh.basicmesh_ptr_->num_ghost_nodes();
1789 int nnodes = nnodes_owned + nnodes_ghost;
1791 int num_sides_all = 0;
1792 mesh.num_sides_owned_ = 0;
1793 mesh.num_sides_ghost_ = 0;
1795 for (
int c = 0; c < ncells; ++c) {
1796 std::vector<int> cfaces, cfdirs;
1797 mesh.basicmesh_ptr_->cell_get_faces_and_dirs(c, &cfaces, &cfdirs);
1799 int numsides_in_cell = cfaces.size();
1800 num_sides_all += numsides_in_cell;
1802 mesh.num_sides_owned_ += numsides_in_cell;
1803 else if (mesh.basicmesh_ptr_->cell_get_type(c) ==
PARALLEL_GHOST)
1804 mesh.num_sides_ghost_ += numsides_in_cell;
1806 mesh.cell_side_ids_[c].reserve(numsides_in_cell);
1809 mesh.sideids_owned_.resize(mesh.num_sides_owned_);
1810 mesh.sideids_ghost_.resize(mesh.num_sides_ghost_);
1811 mesh.sideids_all_.resize(num_sides_all);
1812 mesh.side_cell_id_.assign(num_sides_all, -1);
1813 mesh.side_face_id_.assign(num_sides_all, -1);
1814 mesh.side_opp_side_id_.clear();
1815 mesh.side_opp_side_id_.resize(num_sides_all, -1);
1816 mesh.side_node_ids_.resize(num_sides_all, {{-1, -1}});
1818 std::vector<std::vector<int>> sides_of_node(nnodes);
1821 int iall = 0, iown = 0, ighost = 0;
1822 for (
int c = 0; c < ncells; ++c) {
1823 std::vector<int> cfaces, cfdirs;
1824 mesh.basicmesh_ptr_->cell_get_faces_and_dirs(c, &cfaces, &cfdirs);
1826 int ncfaces = cfaces.size();
1827 for (
int i = 0; i < ncfaces; ++i) {
1829 int fdir = cfdirs[i];
1830 std::vector<int> fnodes;
1831 mesh.basicmesh_ptr_->face_get_nodes(f, &fnodes);
1832 int n0 = (fdir == 1) ? fnodes[0] : fnodes[1];
1833 int n1 = (fdir == 1) ? fnodes[1] : fnodes[0];
1834 mesh.side_node_ids_[sideid][0] = n0;
1835 mesh.side_node_ids_[sideid][1] = n1;
1837 mesh.side_cell_id_[sideid] = c;
1838 mesh.cell_side_ids_[c].push_back(sideid);
1840 mesh.side_face_id_[sideid] = f;
1842 mesh.sideids_all_[iall++] = sideid;
1844 mesh.sideids_owned_[iown++] = sideid;
1845 else if (mesh.basicmesh_ptr_->cell_get_type(c) ==
PARALLEL_GHOST)
1846 mesh.sideids_ghost_[ighost++] = sideid;
1852 for (
auto const& s2 : sides_of_node[n0]) {
1853 if (mesh.side_node_ids_[s2][0] == n1 && mesh.side_node_ids_[s2][1] == n0) {
1854 mesh.side_opp_side_id_[sideid] = s2;
1855 mesh.side_opp_side_id_[s2] = sideid;
1859 sides_of_node[n0].push_back(sideid);
1861 for (
auto const& s2 : sides_of_node[n1]) {
1862 if (mesh.side_node_ids_[s2][0] == n1 && mesh.side_node_ids_[s2][1] == n0) {
1863 mesh.side_opp_side_id_[sideid] = s2;
1864 mesh.side_opp_side_id_[s2] = sideid;
1868 sides_of_node[n1].push_back(sideid);
1877 template<
typename BasicMesh>
1879 int ncells_owned = mesh.basicmesh_ptr_->num_owned_cells();
1880 int ncells_ghost = mesh.basicmesh_ptr_->num_ghost_cells();
1881 int ncells = ncells_owned + ncells_ghost;
1883 mesh.cell_side_ids_.clear();
1884 mesh.cell_side_ids_.resize(ncells);
1886 int nnodes_owned = mesh.basicmesh_ptr_->num_owned_nodes();
1887 int nnodes_ghost = mesh.basicmesh_ptr_->num_ghost_nodes();
1888 int nnodes = nnodes_owned + nnodes_ghost;
1890 int num_sides_all = 0;
1891 mesh.num_sides_owned_ = 0;
1892 mesh.num_sides_ghost_ = 0;
1894 for (
int c = 0; c < ncells; ++c) {
1895 std::vector<int> cfaces, cfdirs;
1896 mesh.basicmesh_ptr_->cell_get_faces_and_dirs(c, &cfaces, &cfdirs);
1898 int numsides_in_cell = 0;
1899 for (
auto const & f : cfaces) {
1900 std::vector<int> fnodes;
1901 mesh.basicmesh_ptr_->face_get_nodes(f, &fnodes);
1903 int nfnodes = fnodes.size();
1904 num_sides_all += nfnodes;
1905 numsides_in_cell += nfnodes;
1908 mesh.num_sides_owned_ += nfnodes;
1909 else if (mesh.basicmesh_ptr_->cell_get_type(c) ==
PARALLEL_GHOST)
1910 mesh.num_sides_ghost_ += nfnodes;
1913 mesh.cell_side_ids_[c].reserve(numsides_in_cell);
1916 mesh.sideids_owned_.resize(mesh.num_sides_owned_);
1917 mesh.sideids_ghost_.resize(mesh.num_sides_ghost_);
1918 mesh.sideids_all_.resize(num_sides_all);
1919 mesh.side_cell_id_.assign(num_sides_all, -1);
1920 mesh.side_face_id_.assign(num_sides_all, -1);
1921 mesh.side_opp_side_id_.clear();
1922 mesh.side_opp_side_id_.assign(num_sides_all, -1);
1923 mesh.side_node_ids_.assign(num_sides_all, {{-1, -1}});
1925 std::vector<std::vector<int>> sides_of_node(nnodes);
1928 int iall = 0, iown = 0, ighost = 0;
1929 for (
int c = 0; c < ncells; ++c) {
1930 std::vector<int> cfaces;
1931 std::vector<int> cfdirs;
1932 mesh.basicmesh_ptr_->cell_get_faces_and_dirs(c, &cfaces, &cfdirs);
1934 std::vector<int>::iterator itf = cfaces.begin();
1935 std::vector<int>::iterator itfd = cfdirs.begin();
1936 while (itf != cfaces.end()) {
1940 std::vector<int> fnodes;
1941 mesh.basicmesh_ptr_->face_get_nodes(f, &fnodes);
1950 std::reverse(fnodes.begin(), fnodes.end());
1952 int nfnodes = fnodes.size();
1954 for (
int i = 0; i < nfnodes; ++i) {
1955 mesh.side_node_ids_[sideid][0] = fnodes[i];
1956 mesh.side_node_ids_[sideid][1] = fnodes[(i+1)%nfnodes];
1958 mesh.side_cell_id_[sideid] = c;
1959 mesh.cell_side_ids_[c].push_back(sideid);
1961 mesh.side_face_id_[sideid] = f;
1963 mesh.sideids_all_[iall++] = sideid;
1965 mesh.sideids_owned_[iown++] = sideid;
1966 else if (mesh.basicmesh_ptr_->cell_get_type(c) ==
PARALLEL_GHOST)
1967 mesh.sideids_ghost_[ighost++] = sideid;
1973 for (
auto const& s2 : sides_of_node[fnodes[i]]) {
1974 if ((mesh.side_node_ids_[s2][0] == fnodes[(i+1)%nfnodes] &&
1975 mesh.side_node_ids_[s2][1] == fnodes[i]) ||
1976 (mesh.side_node_ids_[s2][0] == fnodes[i] &&
1977 mesh.side_node_ids_[s2][1] == fnodes[(i+1)%nfnodes])) {
1978 if (mesh.side_face_id_[sideid] == mesh.side_face_id_[s2] &&
1979 mesh.side_cell_id_[sideid] != mesh.side_cell_id_[s2]) {
1980 mesh.side_opp_side_id_[sideid] = s2;
1981 mesh.side_opp_side_id_[s2] = sideid;
1986 sides_of_node[fnodes[i]].push_back(sideid);
1999 template<
typename BasicMesh>
2002 int nsides_owned = num_sides_owned_;
2003 int nsides_ghost = num_sides_ghost_;
2004 int nsides_all = nsides_owned + nsides_ghost;
2006 int num_wedges_all = 2*nsides_all;
2007 num_wedges_owned_ = 2*nsides_owned;
2008 num_wedges_ghost_ = 2*nsides_ghost;
2010 wedgeids_owned_.resize(num_wedges_owned_);
2011 wedgeids_ghost_.resize(num_wedges_ghost_);
2012 wedge_corner_id_.assign(num_wedges_all, -1);
2014 int iown = 0, ighost = 0;
2015 for (
int s = 0; s < nsides_all; ++s) {
2017 int wedgeid1 = 2*s + 1;
2018 int c = side_cell_id_[s];
2020 wedgeids_owned_[iown++] = wedgeid0;
2021 wedgeids_owned_[iown++] = wedgeid1;
2023 wedgeids_ghost_[ighost++] = wedgeid0;
2024 wedgeids_ghost_[ighost++] = wedgeid1;
2028 wedgeids_all_.reserve(num_wedges_all);
2029 wedgeids_all_ = wedgeids_owned_;
2030 wedgeids_all_.insert(wedgeids_all_.end(), wedgeids_ghost_.begin(),
2031 wedgeids_ghost_.end());
2038 template <
typename BasicMesh>
2040 int ncells_owned = basicmesh_ptr_->num_owned_cells();
2041 int ncells_ghost = basicmesh_ptr_->num_ghost_cells();
2042 int ncells = ncells_owned + ncells_ghost;
2044 int nnodes_owned = basicmesh_ptr_->num_owned_nodes();
2045 int nnodes_ghost = basicmesh_ptr_->num_ghost_nodes();
2046 int nnodes = nnodes_owned + nnodes_ghost;
2048 cell_corner_ids_.clear();
2049 cell_corner_ids_.resize(ncells);
2050 node_corner_ids_.clear();
2051 node_corner_ids_.resize(nnodes);
2053 int num_corners_all = 0;
2054 num_corners_owned_ = 0;
2055 num_corners_ghost_ = 0;
2057 for (
int c = 0; c < ncells; ++c) {
2058 std::vector<int> cnodes;
2059 basicmesh_ptr_->cell_get_nodes(c, &cnodes);
2060 cell_corner_ids_[c].reserve(cnodes.size());
2062 num_corners_all += cnodes.size();
2064 num_corners_owned_ += cnodes.size();
2066 num_corners_ghost_ += cnodes.size();
2069 cornerids_owned_.resize(num_corners_owned_);
2070 cornerids_ghost_.resize(num_corners_ghost_);
2071 corner_wedge_ids_.clear();
2072 corner_wedge_ids_.resize(num_corners_all);
2073 corner_cell_id_.resize(num_corners_all);
2074 corner_node_id_.resize(num_corners_all);
2077 int iown = 0, ighost = 0;
2078 for (
int c = 0; c < ncells; ++c) {
2079 std::vector<int> cnodes;
2080 basicmesh_ptr_->cell_get_nodes(c, &cnodes);
2082 std::vector<int> cwedges;
2085 for (
auto const& n : cnodes) {
2086 corner_cell_id_[cornerid] = c;
2087 cell_corner_ids_[c].push_back(cornerid);
2089 corner_node_id_[cornerid] = n;
2090 node_corner_ids_[n].push_back(cornerid);
2093 cornerids_owned_[iown++] = cornerid;
2095 cornerids_ghost_[ighost++] = cornerid;
2097 for (
auto const& w : cwedges) {
2100 corner_wedge_ids_[cornerid].push_back(w);
2101 wedge_corner_id_[w] = cornerid;
2109 cornerids_all_.reserve(num_corners_all);
2110 cornerids_all_ = cornerids_owned_;
2111 cornerids_all_.insert(cornerids_all_.end(), cornerids_ghost_.begin(),
2112 cornerids_ghost_.end());
2118 template<
typename BasicMesh>
2121 int nfaces = basicmesh_ptr_->num_owned_faces() +
2122 basicmesh_ptr_->num_ghost_faces();
2124 std::vector<double> pnt(dim, 0.0);
2125 face_centroids_.assign(nfaces, pnt);
2127 for (
int f = 0; f < nfaces; f++) {
2128 std::vector<int> fnodes;
2129 basicmesh_ptr_->face_get_nodes(f, &fnodes);
2130 int nfnodes = fnodes.size();
2134 for (
int n = 0; n < nfnodes; ++n) {
2135 basicmesh_ptr_->node_get_coordinates(fnodes[n], &ncoord);
2139 for (
int d = 0; d < dim; ++d)
2140 face_centroids_[f][d] = geomcen[d];
2149 template<
typename BasicMesh>
2152 int nfaces = basicmesh_ptr_->num_owned_faces() +
2153 basicmesh_ptr_->num_ghost_faces();
2157 face_centroids_.resize(nfaces);
2159 std::vector<bool> face_processed(nfaces,
false);
2161 int ncells = basicmesh_ptr_->num_owned_cells() +
2162 basicmesh_ptr_->num_ghost_cells();
2164 std::array<Point<dim>, dim+1> sxyz;
2165 bool posvol_order =
true;
2167 for (
int c = 0; c < ncells; c++) {
2168 std::vector<int> csides;
2171 std::vector<int> cfaces, cfdirs;
2172 basicmesh_ptr_->cell_get_faces_and_dirs(c, &cfaces, &cfdirs);
2174 std::vector<int> fsides;
2175 for (
auto const& f : cfaces) {
2176 if (face_processed[f])
continue;
2183 for (
auto const& s : csides) {
2190 for (
int j = 0; j < dim; j++)
2194 double fctarea = 0.0;
2197 else if (dim == 2) {
2199 fctarea = evec.
norm();
2201 else if (dim == 3) {
2202 Vector<3> vec0(sxyz[2][0]-sxyz[0][0], sxyz[2][1]-sxyz[0][1],
2203 sxyz[2][2]-sxyz[0][2]);
2204 Vector<3> vec1(sxyz[1][0]-sxyz[0][0], sxyz[1][1]-sxyz[0][1],
2205 sxyz[1][2]-sxyz[0][2]);
2207 fctarea = cpvec.
norm();
2211 fcen += fctcen*fctarea;
2215 if (farea > std::numeric_limits<double>::epsilon()) {
2217 for (
int d = 0; d < dim; d++)
2218 face_centroids_[f][d] = fcen[d];
2220 face_processed[f] =
true;
2228 template<
typename BasicMesh>
2231 int ncells = basicmesh_ptr_->num_owned_cells() +
2232 basicmesh_ptr_->num_ghost_cells();
2234 std::vector<double> pnt(dim, 0.0);
2235 cell_centroids_.assign(ncells, pnt);
2237 for (
int c = 0; c < ncells; ++c) {
2240 std::vector<int> cnodes;
2241 basicmesh_ptr_->cell_get_nodes(c, &cnodes);
2242 int ncnodes = cnodes.size();
2245 for (
int n = 0; n < ncnodes; ++n) {
2246 basicmesh_ptr_->node_get_coordinates(cnodes[n], &ncoord);
2250 for (
int d = 0; d < dim; ++d)
2251 cell_centroids_[c][d] = geomcen[d];
2260 template<
typename BasicMesh>
2263 int ncells = basicmesh_ptr_->num_owned_cells() +
2264 basicmesh_ptr_->num_ghost_cells();
2269 cell_centroids_.resize(ncells);
2271 std::array<Point<dim>, dim+1> sxyz;
2272 bool posvol_order =
true;
2273 for (
int c = 0; c < ncells; ++c) {
2277 std::vector<int> csides;
2278 basicmesh_ptr_->cell_get_sides(c, &csides);
2281 double cellvol = 0.0;
2282 for (
auto const& s : csides) {
2285 for (
int i = 0; i < dim+1; i++)
2296 if (cellvol > std::numeric_limits<double>::epsilon()) {
2298 for (
int d = 0; d < dim; d++)
2299 cell_centroids_[c][d] = ccen[d];
2305 template<
typename BasicMesh>
2308 int num_sides_all = num_sides_owned_ + num_sides_ghost_;
2309 side_volumes_.resize(num_sides_all);
2311 std::array<Point<dim>, dim+1> sxyz;
2312 bool posvol_order =
true;
2313 for (
int s = 0; s < num_sides_all; s++) {
2320 template<
typename BasicMesh>
2322 int ncells = basicmesh_ptr_->num_owned_cells() +
2323 basicmesh_ptr_->num_ghost_cells();
2325 cell_volumes_.clear();
2326 cell_volumes_.assign(ncells, 0.0);
2328 for (
int c = 0; c < ncells; ++c)
2329 for (
auto s : cell_side_ids_[c])
2330 cell_volumes_[c] += side_volumes_[s];
2334 template <
typename BasicMesh>
2338 std::vector<int> cnodes;
2339 basicmesh_ptr_->cell_get_nodes(cellid, &cnodes);
2341 int ncnodes = cnodes.size();
2342 pplist->resize(ncnodes);
2343 for (
int n = 0; n < ncnodes; ++n)
2344 basicmesh_ptr_->node_get_coordinates(cnodes[n], &((*pplist)[n]));
2361 template <
typename BasicMesh>
2365 facetpoints->clear();
2368 std::vector<int> cnodes;
2369 basicmesh_ptr_->cell_get_nodes(cellid, &cnodes);
2370 int ncnodes = cnodes.size();
2372 points->resize(ncnodes);
2373 for (
int n = 0; n < ncnodes; ++n)
2374 basicmesh_ptr_->node_get_coordinates(cnodes[n], &((*points)[n]));
2376 std::vector<int> cfaces, cfdirs;
2377 basicmesh_ptr_->cell_get_faces_and_dirs(cellid, &cfaces, &cfdirs);
2378 int ncfaces = cfaces.size();
2380 for (
int f = 0; f < ncfaces; f++) {
2381 std::vector<int> fnodes;
2382 basicmesh_ptr_->face_get_nodes(cfaces[f], &fnodes);
2383 int nfnodes = fnodes.size();
2386 std::vector<int> fnodes_local(nfnodes);
2387 for (
int n = 0; n < nfnodes; n++) {
2390 while (!found && i < ncnodes) {
2391 found = (fnodes[n] == cnodes[i]);
2395 fnodes_local[n] = i;
2399 if (cfdirs[f] != 1) {
2400 int tmp = fnodes_local[0];
2401 fnodes_local[0] = fnodes_local[1];
2402 fnodes_local[1] = tmp;
2404 facetpoints->emplace_back(fnodes_local);
2414 points->push_back(fcen);
2415 int icen = points->size() - 1;
2418 std::vector<int> fctpnts(3);
2419 for (
int n = 0; n < nfnodes; n++) {
2420 if (cfdirs[f] == 1) {
2421 fctpnts[0] = fnodes_local[n];
2422 fctpnts[1] = fnodes_local[(n+1)%nfnodes];
2424 fctpnts[0] = fnodes_local[(n+1)%nfnodes];
2425 fctpnts[1] = fnodes_local[n];
2428 facetpoints->push_back(fctpnts);
2437 template <
typename BasicMesh>
2441 int64_t factor = 1e10;
2443 facetpoints->clear();
2449 assert(wedges_requested_);
2450 std::vector<int> wedges;
2452 int nwedges = wedges.size();
2454 points->reserve(3*nwedges);
2455 facetpoints->reserve(3*nwedges);
2460 std::vector<int64_t> pntentids;
2461 std::vector<int> pntenttypes;
2463 pntentids.reserve(3*nwedges);
2464 pntenttypes.reserve(3*nwedges);
2466 int np = pntentids.size();
2467 for (
auto const &w : wedges) {
2469 int c = side_cell_id_[s];
2470 int f = side_face_id_[s];
2473 n[0] = side_node_ids_[s][0];
2474 n[1] = side_node_ids_[s][1];
2477 int64_t e = (n[0] < n[1]) ? n[0]*factor + n[1] : n[1]*factor + n[0];
2479 int64_t wpentid[2][3];
2484 wpentid[0][0] = e; wpentid[0][1] = c; wpentid[0][2] = f;
2485 wpenttyp[0][0] = 1; wpenttyp[0][1] = 3; wpenttyp[0][2] = 2;
2491 wpentid[1][0] = n[iw]; wpentid[1][1] = e; wpentid[1][2] = f;
2492 wpenttyp[1][0] = 0; wpenttyp[1][1] = 1; wpenttyp[1][2] = 2;
2497 wpentid[0][0] = e; wpentid[0][1] = f; wpentid[0][2] = c;
2498 wpenttyp[0][0] = 1; wpenttyp[0][1] = 2; wpenttyp[0][2] = 3;
2504 wpentid[1][0] = n[iw]; wpentid[1][1] = f; wpentid[1][2] = e;
2505 wpenttyp[1][0] = 0; wpenttyp[1][1] = 2; wpenttyp[1][2] = 1;
2511 for (
int i = 0; i < nfct; i++) {
2512 std::vector<int> fctpnts(3);
2513 for (
int j = 0; j < 3; j++) {
2515 if (wpenttyp[i][j] !=
FACE) {
2517 while (!found && k < np) {
2518 if (wpentid[i][j] == pntentids[k] &&
2519 wpenttyp[i][j] == pntenttypes[k]) {
2530 while (!found && k < np) {
2531 if (pntenttypes[k] ==
FACE) {
2534 if (
approxEq(fcen1, fcen2, 1.0e-14)) {
2543 pntentids.push_back(wpentid[i][j]);
2544 pntenttypes.push_back(wpenttyp[i][j]);
2548 facetpoints->push_back(fctpnts);
2552 for (
int i = 0; i < np; i++) {
2553 int64_t
id = pntentids[i];
2554 int type = pntenttypes[i];
2558 basicmesh_ptr_->node_get_coordinates(
id, &pxyz);
2562 int n0 = (
id-n1)/factor;
2564 basicmesh_ptr_->node_get_coordinates(n0, &nxyz0);
2565 basicmesh_ptr_->node_get_coordinates(n1, &nxyz1);
2566 pxyz = (nxyz0 + nxyz1)/2.0;
2570 basicmesh_ptr_->face_centroid(
id, &pxyz);
2573 basicmesh_ptr_->cell_centroid(
id, &pxyz);
2576 std::cerr <<
"Unknown type" << std::endl;
2578 points->push_back(pxyz);
2585 template<
size_t D,
class MeshWrapper>
2587 int const cellid,
double *radius) {
2589 wrapper.cell_centroid(cellid, ¢roid);
2590 std::vector<int> nodes;
2591 wrapper.cell_get_nodes(cellid, &nodes);
2595 for (
int & i : nodes) {
2596 wrapper.node_get_coordinates(i, &node);
2597 for (
int j = 0; j < dim; j++) arm[j] = node[j]-centroid[j];
2598 double distance = 0.0;
2599 for (
int j = 0; j < dim; j++) distance += arm[j]*arm[j];
2600 distance = sqrt(distance);
2601 if (distance > *radius) *radius = distance;
2608 template<
size_t D,
class MeshWrapper>
2610 int const nodeid,
double *radius) {
2611 std::vector<int> nodes;
2612 wrapper.node_get_cell_adj_nodes(nodeid,
ALL, &nodes);
2614 wrapper.node_get_coordinates(nodeid, ¢er);
2619 for (
int & i : nodes) {
2620 wrapper.node_get_coordinates(i, &node);
2621 for (
int j = 0; j < dim; j++) arm[j] = node[j]-center[j];
2622 double distance = 0.0;
2623 for (
int j = 0; j < dim; j++) distance += arm[j]*arm[j];
2624 distance = sqrt(distance);
2625 if (distance > *radius) *radius = distance;
2632 #endif // AUX_MESH_TOPOLOGY_H_ double wedge_volume(int const wedgeid) const
Volume of a wedge - half its side volume.
Definition: AuxMeshTopology.h:777
int num_entities(Entity_kind const entity, Entity_type const etype=Entity_type::ALL) const
Number of items of given entity.
Definition: AuxMeshTopology.h:264
void side_get_coordinates(int const sideid, std::array< Point< 3 >, 4 > *scoords, bool posvol_order=false) const
side coordinates in 3D
Definition: AuxMeshTopology.h:1610
int num_ghost_sides() const
Number of ghost sides in the mesh.
Definition: AuxMeshTopology.h:244
void sides_get_coordinates(int cellID, std::vector< std::array< Point< 3 >, 4 >> *scoords) const
Get coordinates of side in 3D.
Definition: AuxMeshTopology.h:1171
AuxMeshTopology(bool request_sides=true, bool request_wedges=true, bool request_corners=true)
Constructor indicating which entities are wanted.
Definition: AuxMeshTopology.h:185
void build_sides_2D(AuxMeshTopology< BasicMesh > &mesh)
Definition: AuxMeshTopology.h:1779
friend void build_sides_2D(AuxMeshTopology< BasicMesh > &mesh)
Definition: AuxMeshTopology.h:1779
int wedge_get_adjacent_wedge(const int wedgeid) const
Definition: AuxMeshTopology.h:762
int corner_get_node(const int cornerid) const
Get node of corner.
Definition: AuxMeshTopology.h:873
int num_owned_corners() const
Number of owned corners in the mesh.
Definition: AuxMeshTopology.h:237
Definition: AuxMeshTopology.h:51
WONTON_INLINE double cross(const Vector< 2 > &a, const Vector< 2 > &b)
Cross product operator for two 2d vectors, .
Definition: Vector.h:304
counting_iterator end(Entity_kind const entity, Entity_type const etype=Entity_type::ALL) const
Iterator on mesh entity - end.
Definition: AuxMeshTopology.h:325
WONTON_INLINE double norm(bool doSqrt=true) const
Calculate the norm of a Vector.
Definition: Vector.h:148
void wedge_get_coordinates(int const wedgeid, std::array< Point< 3 >, 4 > *wcoords, bool posvol_order=false) const
Wedge coordinates in 3D.
Definition: AuxMeshTopology.h:1680
int num_ghost_corners() const
Number of ghost corners in the mesh.
Definition: AuxMeshTopology.h:258
Factorize a number N into D equal (or nearly equal) factors.
Definition: adaptive_refinement_mesh.h:31
std::vector< T > vector
Definition: wonton.h:285
bool on_exterior_boundary(Entity_kind const entity, int const entity_id) const
if entity is on exterior boundary
Definition: AuxMeshTopology.h:480
void cell_get_coordinates(int const cellid, std::vector< Point< D >> *pplist) const
Coordinates of nodes of cell.
Definition: AuxMeshTopology.h:2336
void order_wedges_ccw(std::vector< int > *wedgeids) const
Order wedges around a node in ccw manner.
Definition: AuxMeshTopology.h:1126
double dual_cell_volume(int const nodeid) const
Get the volume of dual cell by finding the corners that attach to the node.
Definition: AuxMeshTopology.h:1316
void dual_cell_get_node_adj_cells(int const nodeid, Entity_type const ptype, std::vector< int > *adjnodes) const
Get adjacent "dual cells" of a given "dual cell".
Definition: AuxMeshTopology.h:1186
Entity_type
The parallel type of a given entity.
Definition: wonton.h:124
void corner_get_wedges(int const cornerid, std::vector< int > *wedgeids) const
Get wedges of a corner.
Definition: AuxMeshTopology.h:895
void decompose_cell_into_tets(int cellid, std::vector< std::array< Wonton::Point< 3 >, 4 >> *tcoords, const bool planar_hex) const
Get the simplest possible decomposition of a 3D cell into tets.
Definition: AuxMeshTopology.h:985
int side_get_wedge(int const sideid, int iwedge) const
Definition: AuxMeshTopology.h:586
void cell_get_facetization(int const cellid, std::vector< std::vector< int >> *facetpoints, std::vector< Point< 3 >> *points) const
Get a triangular facetization of polyhedral cell boundary.
Definition: AuxMeshTopology.h:2362
double cell_volume(int const cellid) const
Volume of a cell.
Definition: AuxMeshTopology.h:517
int wedge_get_side(int const wedgeid) const
Side of wedge.
Definition: AuxMeshTopology.h:679
boost::counting_iterator< int > counting_iterator
Definition: wonton.h:290
int side_get_opposite_side(int const sideid) const
Definition: AuxMeshTopology.h:602
void cell_get_node_adj_cells(int const cellid, Entity_type const ptype, std::vector< int > *adjcells) const
Get the list of cell IDs for all cells attached to a specific cell through its nodes.
Definition: AuxMeshTopology.h:341
int num_ghost_wedges() const
Number of ghost wedges in the mesh.
Definition: AuxMeshTopology.h:251
int side_get_face(int const sideid) const
Face of side.
Definition: AuxMeshTopology.h:570
void dual_cell_centroid(int nodeid, Point< D > *centroid) const
Centroid of a dual cell.
Definition: AuxMeshTopology.h:1283
double side_volume(int const sideid) const
Volume of a side.
Definition: AuxMeshTopology.h:669
Represents a point in an N-dimensional space.
Definition: Point.h:50
void cell_get_wedges(int const cellid, std::vector< int > *wedgeids) const
Get all the wedges in a cell.
Definition: AuxMeshTopology.h:834
void cell_radius(MeshWrapper &wrapper, int const cellid, double *radius)
Definition: AuxMeshTopology.h:2586
int wedge_get_opposite_wedge(const int wedgeid) const
Definition: AuxMeshTopology.h:742
void node_get_wedges(int const nodeid, Entity_type const type, std::vector< int > *wedgeids) const
Get wedges at a node.
Definition: AuxMeshTopology.h:850
int side_get_cell(int const sideid) const
Cell of side.
Definition: AuxMeshTopology.h:559
counting_iterator begin(Entity_kind const entity, Entity_type const etype=Entity_type::ALL) const
Iterators on mesh entity - begin.
Definition: AuxMeshTopology.h:318
friend void build_sides_3D(AuxMeshTopology< BasicMesh > &mesh)
Definition: AuxMeshTopology.h:1878
counting_iterator make_counting_iterator(int const i)
Definition: wonton.h:291
void dual_wedges_get_coordinates(int nodeid, std::vector< std::array< Point< 3 >, 4 >> *wcoords) const
Definition: AuxMeshTopology.h:1263
WONTON_INLINE bool approxEq(const Point< D > &p1, const Point< D > &p2, double tol=1.0e-8)
Definition: Point.h:274
int cell_get_corner_at_node(int const cellid, int const nodeid) const
Get a cell's corner at a particular node of the cell.
Definition: AuxMeshTopology.h:944
friend void build_sides_1D(AuxMeshTopology< BasicMesh > &mesh)
Definition: AuxMeshTopology.h:1712
int num_owned_sides() const
Number of owned sides in the mesh.
Definition: AuxMeshTopology.h:223
int wedge_get_corner(int const wedgeid) const
Corner of a wedge.
Definition: AuxMeshTopology.h:714
Entity_kind
The type of mesh entity.
Definition: wonton.h:81
int side_get_node(int const sideid, int const inode) const
Definition: AuxMeshTopology.h:547
int cell_get_face_adj_cell(int cell, int face) const
Retrieve the cell incident to a given face of a given cell.
Definition: AuxMeshTopology.h:395
void dual_cell_get_coordinates(int const nodeid, std::vector< Point< 2 >> *pplist) const
2D version of coords of nodes of a dual cell
Definition: AuxMeshTopology.h:1052
int wedge_get_node(int const wedgeid) const
node of a wedge
Definition: AuxMeshTopology.h:725
void build_aux_entities()
Definition: AuxMeshTopology.h:1331
int wedge_get_cell(int const wedgeid) const
Cell of wedge.
Definition: AuxMeshTopology.h:690
double corner_volume(int const cornerid) const
Volume of a corner.
Definition: AuxMeshTopology.h:959
void cell_centroid(int const cellid, Point< D > *ccen) const
Centroid of a cell.
Definition: AuxMeshTopology.h:507
void cell_get_corners(int const cellid, std::vector< int > *cornerids) const
Get corners in a cell.
Definition: AuxMeshTopology.h:932
void build_sides_1D(AuxMeshTopology< BasicMesh > &mesh)
Definition: AuxMeshTopology.h:1712
int corner_get_cell(int const cornerid) const
Get cell of corner.
Definition: AuxMeshTopology.h:884
void face_centroid(int const faceid, Point< D > *fcen) const
Centroid of a face.
Definition: AuxMeshTopology.h:529
void dual_cell_get_facetization(int const nodeid, std::vector< std::vector< int >> *facetpoints, std::vector< Point< 3 >> *points) const
Definition: AuxMeshTopology.h:2438
void node_get_cell_adj_nodes(int const nodeid, Entity_type const ptype, std::vector< int > *adjnodes) const
Get the list of node IDs for all nodes attached to all cells attached to a specific node...
Definition: AuxMeshTopology.h:448
void node_get_corners(int const nodeid, Entity_type const type, std::vector< int > *cornerids) const
Get corners connected to a node.
Definition: AuxMeshTopology.h:908
void node_radius(MeshWrapper &wrapper, int const nodeid, double *radius)
Definition: AuxMeshTopology.h:2609
void face_get_cells(int const faceid, Entity_type const etype, std::vector< int > *cells) const
Get cells of given Entity_type connected to face (in no particular order)
Definition: AuxMeshTopology.h:371
int wedge_get_face(int const wedgeid) const
Face of wedge.
Definition: AuxMeshTopology.h:702
void wedges_get_coordinates(int cellID, std::vector< std::array< Point< 3 >, 4 >> *wcoords) const
Get coordinates of wedge in 3D.
Definition: AuxMeshTopology.h:1155
int num_owned_wedges() const
Number of owned wedges in the mesh.
Definition: AuxMeshTopology.h:230
void cell_get_face_adj_cells(int const cellid, Entity_type const ptype, std::vector< int > *adjcells) const
Get the list of cell IDs for all cells attached to a specific cell through its faces.
Definition: AuxMeshTopology.h:418
bool ccw(Point< 2 > const &p1, Point< 2 > const &p2, Point< 2 > const &p3) const
Definition: AuxMeshTopology.h:1141
void dual_cell_get_coordinates(int const nodeid, std::vector< Point< 3 >> *pplist) const
3D version of coords of nodes of a dual cell
Definition: AuxMeshTopology.h:1201
double calc_side_volume(std::array< Point< 1 >, 2 > const &sxyz)
Compute volume of 1D side.
Definition: AuxMeshTopology.h:29
void build_sides_3D(AuxMeshTopology< BasicMesh > &mesh)
Definition: AuxMeshTopology.h:1878
std::vector< Point< 2 > > cellToXY(int cellID) const
Definition: AuxMeshTopology.h:1147
Represents a vector in N-dimensional space.
Definition: Vector.h:40
void cell_get_sides(int const cellid, std::vector< int > *csides) const
Get all the sides of a cell.
Definition: AuxMeshTopology.h:613
WONTON_INLINE double dot(const Vector< D > &a, const Vector< D > &b)
Dot product of two vectors, .
Definition: Vector.h:248