https://gitlab.opengeosys.org/ogs/ogs.git
Tip revision: 9cec3d89a8b11dbf8b4024380639c99bf20333fc authored by Tom Fischer on 08 March 2021, 06:22:48 UTC
Merge branch 'FixGrowingMemConsumption' into 'master'
Merge branch 'FixGrowingMemConsumption' into 'master'
Tip revision: 9cec3d8
TemplateElement-impl.h
/**
* \file
* \copyright
* Copyright (c) 2012-2021, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include <algorithm>
namespace MeshLib
{
template <class ELEMENT_RULE>
TemplateElement<ELEMENT_RULE>::TemplateElement(Node* nodes[n_all_nodes], std::size_t id)
: Element(id)
{
this->_nodes = nodes;
this->_neighbors = new Element*[getNumberOfNeighbors()];
std::fill(this->_neighbors, this->_neighbors + getNumberOfNeighbors(), nullptr);
this->_content = ELEMENT_RULE::computeVolume(this->_nodes);
}
template <class ELEMENT_RULE>
TemplateElement<ELEMENT_RULE>::TemplateElement(std::array<Node*, n_all_nodes> const& nodes, std::size_t id)
: Element(id)
{
this->_nodes = new Node*[n_all_nodes];
std::copy(nodes.begin(), nodes.end(), this->_nodes);
this->_neighbors = new Element*[getNumberOfNeighbors()];
std::fill(this->_neighbors, this->_neighbors + getNumberOfNeighbors(), nullptr);
this->_content = ELEMENT_RULE::computeVolume(this->_nodes);
}
template <class ELEMENT_RULE>
TemplateElement<ELEMENT_RULE>::TemplateElement(const TemplateElement &e)
: Element(e.getID())
{
this->_nodes = new Node*[n_all_nodes];
for (unsigned i = 0; i < n_all_nodes; i++)
{
this->_nodes[i] = e._nodes[i];
}
this->_neighbors = new Element*[getNumberOfNeighbors()];
for (unsigned i = 0; i < getNumberOfNeighbors(); i++)
{
this->_neighbors[i] = e._neighbors[i];
}
this->_content = e.getContent();
}
namespace details
{
template<unsigned N>
bool isEdge(unsigned const (&edge_nodes)[N], unsigned idx1, unsigned idx2)
{
if (edge_nodes[0] == idx1 && edge_nodes[1] == idx2)
{
return true;
}
if (edge_nodes[1] == idx1 && edge_nodes[0] == idx2)
{
return true;
}
return false;
}
inline bool
isEdge(unsigned const (&/*edge_nodes*/)[1], unsigned /*idx1*/, unsigned /*idx2*/)
{
return false;
}
} // namespace details
template <class ELEMENT_RULE>
bool TemplateElement<ELEMENT_RULE>::isEdge(unsigned idx1, unsigned idx2) const
{
for (unsigned i(0); i<getNumberOfEdges(); i++)
{
if (details::isEdge(ELEMENT_RULE::edge_nodes[i], idx1, idx2))
{
return true;
}
}
return false;
}
} // namespace MeshLib