Skip to content
Snippets Groups Projects
Commit 71de76f6 authored by Tom Fischer's avatar Tom Fischer
Browse files

[MeL/Elements] Calculate content on the fly.

The getContent() method is used only on very few
places. Especially, it isn't used in the computation
of any THMC processes. So the content doesn't need
to be stored which saves memory. Furthermore, the time
time for reading / initializing a mesh is reduced.

In a hex mesh with 100x100x100 elements this saves
2.6% of storage and circa 25% time.
parent deb816da
No related branches found
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@
namespace MeshLib
{
Element::Element(std::size_t id)
: _nodes(nullptr), _id(id), _content(-1.0), _neighbors(nullptr)
: _nodes(nullptr), _id(id), _neighbors(nullptr)
{
}
......
......@@ -43,7 +43,7 @@ public:
std::optional<unsigned> addNeighbor(Element* e);
/// Returns the length, area or volume of a 1D, 2D or 3D element
double getContent() const { return _content; }
virtual double getContent() const = 0;
/**
* Get node with local index i where i should be at most the number
......@@ -194,8 +194,6 @@ protected:
Node** _nodes;
std::size_t _id;
/// Content corresponds to length for 1D, area for 2D, and volume for 3D elements
double _content;
Element** _neighbors;
/// Sets the neighbor over the face with \c face_id to the given \c
......
......@@ -20,7 +20,6 @@ TemplateElement<ELEMENT_RULE>::TemplateElement(Node* nodes[n_all_nodes], std::si
this->_nodes = nodes;
this->_neighbors = new Element*[getNumberOfNeighbors()];
std::fill(this->_neighbors, this->_neighbors + getNumberOfNeighbors(), nullptr);
this->_content = ELEMENT_RULE::computeVolume(this->_nodes);
this->space_dimension_ = ELEMENT_RULE::dimension;
}
......@@ -33,7 +32,6 @@ TemplateElement<ELEMENT_RULE>::TemplateElement(std::array<Node*, n_all_nodes> co
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);
this->space_dimension_ = ELEMENT_RULE::dimension;
}
......@@ -52,11 +50,15 @@ TemplateElement<ELEMENT_RULE>::TemplateElement(const TemplateElement &e)
{
this->_neighbors[i] = e._neighbors[i];
}
this->_content = e.getContent();
this->space_dimension_ = e.space_dimension_;
}
template <class ELEMENT_RULE>
double TemplateElement<ELEMENT_RULE>::getContent() const
{
return ELEMENT_RULE::computeVolume(this->_nodes);
}
namespace details
{
......
......@@ -209,6 +209,7 @@ public:
return ELEMENT_RULE::testElementNodeOrder(*this);
}
double getContent() const override final;
};
} // namespace MeshLib
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment