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

implemented Tri::reviseElement()

parent 3633182d
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@
*/
#include "Tri.h"
#include "Edge.h"
#include "Node.h"
#include "MathTools.h"
......@@ -76,5 +77,19 @@ double Tri::computeArea()
return MathLib::calcTriangleArea(_nodes[0]->getCoords(), _nodes[1]->getCoords(), _nodes[2]->getCoords());
}
Element* Tri::reviseElement() const
{
// try to create an edge
if (_nodes[0] == _nodes[1] || _nodes[1] == _nodes[2]) {
return new Edge(_nodes[0], _nodes[2], _value);
}
if (_nodes[0] == _nodes[2]) {
return new Edge(_nodes[0], _nodes[1], _value);
}
return NULL;
}
}
......@@ -18,18 +18,19 @@
namespace MeshLib {
/**
* A 2d Triangle Element.
* This class represents a 2d triangle element. The following sketch shows the node and edge numbering.
* @anchor TriNodeAndEdgeNumbering
* @code
*
* Tri: 2
* 2
* o
* / \
* / \
* / \
* 2/ \1
* / \
* / \
* o-----------o
* 0 1
* 0-----------1
* 0
*
* @endcode
*/
......@@ -69,6 +70,16 @@ public:
*/
virtual Element* clone() const;
/**
* This method should be called after at least two nodes of the triangle
* element are collapsed. As a consequence of the node collapsing an edge
* of the triangle will be collapsed. If one of the edges is collapsed we
* obtain an edge. In this case the method will create the appropriate
* object of class Edge.
* @return an Edge object or NULL
*/
virtual Element* reviseElement() const;
protected:
/// Calculates the area of the triangle by returning half of the area of the corresponding parallelogram.
double computeArea();
......
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