32 #include <boost/property_tree/ptree.hpp>
58 MeshCheck::MeshCheck(
const Mesh& mesh)
87 for (
const auto& c: m_mesh.
GetCells()) {
92 const auto status = (delta < 1.0e-7);
93 assert( status &&
"Sum of cell areas disagrees with boundary polygon area!");
101 for (
const auto& node : m_mesh.
GetNodes()) {
107 assert( status &&
"Nodes and boundary_polgon disagree on at_boundary status!");
114 list<Cell*> bw_cells;
117 for (
auto cell : m_mesh.
GetCells()) {
119 bw_cells.push_back(cell);
125 for (
auto cell : bw_cells) {
126 auto is_bw = [
this](
Wall* w) {
129 const auto& walls = cell->GetWalls();
132 const auto it = find_if(walls.begin(), walls.end(), is_bw);
133 if (it == walls.end()) {
138 const Node* start = bw->GetN1();
139 const Node* stop = bw->GetN2();
140 if (cell == bw->GetC2()) {
143 auto& nodes = cell->GetNodes();
144 const auto start_it = find(nodes.begin(), nodes.end(), start);
145 auto c_it =
make_circular(nodes.begin(), nodes.end(), start_it);
151 }
while(*(++c_it) != stop);
157 assert( status &&
"Boundary walls have nodes not on boundary!");
164 if (m_mesh.
GetCells().size() > 1U) {
165 for (
auto cell : m_mesh.
GetCells()) {
172 assert( status &&
"Node and wall criteria disagree in at_boundary status!");
181 for(
unsigned int i = 0; i < cells.size(); ++i) {
182 if (static_cast<unsigned int>(cells[i]->GetIndex()) != i) {
188 assert( status &&
"Cell Ids not in sequence.");
196 for (
const auto& c1: m_mesh.
GetCells()) {
197 for (
const auto& c2: m_mesh.
GetCells()) {
198 if (c1->GetIndex() == c2->GetIndex() && c1 != c2) {
203 if (status ==
false) {
208 assert( status &&
"Cell Ids not unique.");
214 for (
auto cell : m_mesh.
GetCells()) {
215 const auto& nodes = cell->GetNodes();
216 const auto& walls = cell->GetWalls();
217 for (
const auto& wall : walls) {
218 const auto cit1 = find(nodes.begin(), nodes.end(), wall->GetN1());
219 const auto cit2 = find(nodes.begin(), nodes.end(), wall->GetN2());
220 const auto cit_start = (wall->GetC1() == cell) ? cit1 : cit2;
221 const auto cit_stop = (wall->GetC1() == cell) ? cit2 : cit1;
222 const auto nghb_cell = (wall->GetC1() == cell) ? wall->GetC2() : wall->GetC1();
228 status = cell->HasEdge(e) && nghb_cell->HasEdge(e);
229 status = status && (edge_owners.size() == 4 );
230 for (
const auto& owner : edge_owners) {
232 (owner.GetCell() == cell || owner.GetCell() == nghb_cell);
237 }
while(++cit != cit_stop);
248 assert( status &&
"EdgeOwners relation not OK!");
255 for (
auto cell1 : m_mesh.
GetCells()) {
256 for (
auto cell2 : m_mesh.
GetCells()) {
257 if (cell1->IsWallNeighbor(cell2) != cell2->IsWallNeighbor(cell1)) {
264 assert( status &&
"Neighbor relation is not symmetric!");
272 const auto& nodes = m_mesh.
GetNodes();
273 for(
unsigned int i = 0; i < nodes.size(); ++i) {
274 if (static_cast<unsigned int>(nodes[i]->GetIndex()) != i) {
280 assert( status &&
"Cell Ids not in sequence.");
287 for (
const auto& n1: m_mesh.
GetNodes()) {
288 for (
const auto& n2: m_mesh.
GetNodes()) {
289 if (n1->GetIndex() == n2->GetIndex() && n1 != n2) {
294 if (status ==
false) {
299 assert( status &&
"Node Ids not unique.");
306 for (
auto cell : m_mesh.
GetCells()) {
307 const auto& nodes = cell->GetNodes();
312 const auto owner_it = find(owner.begin(), owner.end(), nn);
313 const auto owner_it2 = find(
next(owner_it), owner.end(), nn);
314 status = status && (owner_it != owner.end()) && (owner_it2 == owner.end());
315 }
while(++cit_node != nodes.begin());
318 assert( status &&
"NodeOwningNeighbors relation inconsistent!");
328 auto n_o_w_copy = m_mesh.m_node_owning_walls;
329 for (
const auto& wall : m_mesh.
GetWalls()) {
330 const auto& nodes = wall->GetC1()->GetNodes();
335 assert(from != nodes.end() &&
"Couldn't find N1 in C1, wall inconsistent");
336 assert(to != nodes.end() &&
"Couldn't find N2 in C1, wall inconsistent");
337 if (from == nodes.end() || to == nodes.end()) {
344 auto& owning_walls = n_o_w_copy[*from];
345 const auto it = std::find(owning_walls.begin(), owning_walls.end(), wall);
346 if (it == owning_walls.end()) {
349 owning_walls.erase(it);
351 }
while (from++ != to);
354 assert(status &&
"Not every wall is associated with all its nodes");
357 for (
const auto& pair : n_o_w_copy) {
358 if (!pair.second.empty()) {
363 assert(status &&
"Some node has an owning walls of which it is not part");
371 const auto& walls = m_mesh.
GetWalls();
372 for(
unsigned int i = 0; i < walls.size(); ++i) {
373 if (static_cast<unsigned int>(walls[i]->GetIndex()) != i) {
379 assert( status &&
"Wall Ids not in sequence.");
386 for (
const auto& w1: m_mesh.
GetNodes()) {
387 for (
const auto& w2: m_mesh.
GetNodes()) {
388 if (w1->GetIndex() == w2->GetIndex() && w1 != w2) {
393 if (status ==
false) {
398 assert( status &&
"Wall Ids not unique.");
405 for (
auto cell1 : m_mesh.
GetCells()) {
406 for (
auto cell2 : m_mesh.
GetCells()) {
407 if (cell1->IsWallNeighbor(cell2)) {
408 if (m_mesh.m_wall_neighbors.count(cell1) != 1) {
412 const auto& nb_list = m_mesh.m_wall_neighbors.at(cell1);
413 const auto it = find(nb_list.begin(), nb_list.end(), cell2);
414 if (it == nb_list.end()) {
422 assert( status &&
"Wall_neighbor list in mesh has inconsistent info!");
bool CheckNodeIdsSequence() const
Verifies that node ids correspond to storage sequence.
bool IsAtBoundary(const Edge *e) const
True iff the edge is on the mesh boundary.
bool CheckCellBoundaryWalls() const
Verifies that for all cells the Cell::HasBoundaryWall agrees with Mesh::IsWallNeighbor for boundary p...
bool CheckAll() const
Runs all of the of checks to verify consistency of the mesh.
Interface for NeighborNodes.
bool CheckNodeIdsUnique() const
Verifies that node identifiers are unique.
const std::vector< Cell * > & GetCells() const
The cells of this mesh, EXCLUDING the boundary polygon.
bool CheckMutuallyNeighbors() const
Verifies that Cell::IsWallNeighbor is a symmetric relationship.
bool CheckWallIdsUnique() const
Verifies that wall identifiers are unique.
CircularIterator< typename T::iterator > make_circular(T &c)
Helper produces non-const circular iterator whose range corresponds to the begin and end iterators of...
bool CheckAtBoundaryNodes() const
Verifies Node::IsAtBoundary is true iff node is part of boundary polygon, for every node in the mesh...
Namespace for the core simulator.
An Edge connects two nodes and is ambidextrous.
bool CheckCellIdsUnique() const
Verifies that cell identifiers are unique.
std::vector< NeighborNodes > GetEdgeOwners(const Edge &edge) const
Find the intersecting neighbors of the end points of the edge.
Namespace for container related classes.
Macro defs for debug and logging.
bool CheckAreas() const
Verifies that sum of all cell areas equals the area of the boundary polygon.
bool CheckWallNeighborsList() const
Verifies whether every cell has exactly one entry in the wall neighbor list (except when there is onl...
Structure of neighboring nodes: two neighboring nodes from standpoint of a given cell with an orderin...
Cell * GetBoundaryPolygon() const
Get the boundary polygon of the mesh.
bool IsInBoundaryPolygon(Node *n) const
True iff the node is one of the nodes of the boundary polygon.
ConstCircularIterator class and helper functions.
const std::vector< Node * > & GetNodes() const
The nodes of the mesh.
std::list< NeighborNodes > & GetNodeOwningNeighbors(Node *n)
Get the neighbors associated with this node.
Structure of cells; key data structure.
CircularIterator< T > next(CircularIterator< T > i)
Helper yields the position the iterator would have if moved forward (in circular fashion) by 1 positi...
ConstCircularIterator< typename T::const_iterator > make_const_circular(const T &c)
Helper produces const circular iterator whose range corresponds to the begin and end iterators of a c...
const std::vector< Wall * > & GetWalls() const
The walls of this mesh.
bool CheckCellBoundaryWallNodes() const
Verifies that for each cell, each boundary wall (other cell owning the wall is the boundary polygon) ...
CircularIterator< T > prev(CircularIterator< T > i)
Helper yields the position the iterator would have if moved backward (in circular fashion) by 1 posit...
CircularIterator class and helper functions.
bool CheckCellIdsSequence() const
Verifies that cell ids correspond to storage sequence.
bool CheckNodeOwningNeighbors() const
Verifies that for each node its NeighborNodes constructs appear once and only once in the NodeOwningN...
bool CheckWallIdsSequence() const
Verifies that wall ids correspond to storage sequence.
bool CheckNodeOwningWalls() const
Verifies that the owning walls of every node are exactly those walls to which the node belongs...
bool CheckEdgeOwners() const
Verifies that every edge has exactly two neighbor cells by using Mesh::GetEdgeOwners.
double GetArea() const
Return the area of the cell.
A cell wall, runs between cell corner points and consists of wall elements.