Skip to content

Commit

Permalink
[Mesh] check IDs of nonlinear nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Norihiro Watanabe committed Oct 21, 2016
1 parent 4086a35 commit cb4c507
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
25 changes: 25 additions & 0 deletions MeshLib/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Mesh::Mesh(const std::string &name,
assert(n_base_nodes <= nodes.size());
this->resetNodeIDs();
this->resetElementIDs();
if (isNonlinear())
this->checkNonlinearNodeIDs();
this->setDimension();
this->setElementsConnectedToNodes();
//this->setNodesConnectedByEdges();
Expand Down Expand Up @@ -253,6 +255,29 @@ void Mesh::setNodesConnectedByElements()
}
}

void Mesh::checkNonlinearNodeIDs() const
{
for (MeshLib::Element const* e : _elements)
{
for (unsigned i=0; i<e->getNumberOfBaseNodes(); i++)
{
if (!(e->getNodeIndex(i) < getNumberOfBaseNodes()))
OGS_FATAL(
"Node %d is a base/linear node, but the ID is not smaller "
"than the number of base nodes %d. Please renumber node IDs in the mesh.",
e->getNodeIndex(i), getNumberOfBaseNodes());
}
for (unsigned i=e->getNumberOfBaseNodes(); i<e->getNumberOfNodes(); i++)
{
if (!(e->getNodeIndex(i) >= getNumberOfBaseNodes()))
OGS_FATAL(
"Node %d is a non-linear node, but the ID is smaller "
"than the number of base nodes %d. Please renumber node IDs in the mesh.",
e->getNodeIndex(i), getNumberOfBaseNodes());
}
}
}

void scaleMeshPropertyVector(MeshLib::Mesh & mesh,
std::string const& property_name,
double factor)
Expand Down
3 changes: 3 additions & 0 deletions MeshLib/Mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ class Mesh : BaseLib::Counter<Mesh>
/// connected if they are shared by an element.
void setNodesConnectedByElements();

/// Check if all the nonlinear nodes are stored at the end of the node vector
void checkNonlinearNodeIDs() const;

std::size_t const _id;
unsigned _mesh_dimension;
/// The minimal and maximal edge length over all elements in the mesh
Expand Down

0 comments on commit cb4c507

Please sign in to comment.