OGS
EdgeReturn.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) OpenGeoSys Community (opengeosys.org)
2// SPDX-License-Identifier: BSD-3-Clause
3
4#include "EdgeReturn.h"
5
6#include "BaseLib/Logging.h"
7#include "Element.h"
8#include "Line.h"
9#include "MeshLib/Node.h"
10
11namespace MeshLib
12{
13const Element* LinearEdgeReturn::getEdge(const Element* e, unsigned i)
14{
15 if (i < e->getNumberOfEdges())
16 {
17 auto** nodes = new Node*[2];
18 nodes[0] = const_cast<Node*>(e->getEdgeNode(i, 0));
19 nodes[1] = const_cast<Node*>(e->getEdgeNode(i, 1));
20 return new Line(nodes, e->getID());
21 }
22 ERR("Error in MeshLib::Element::getEdge() - Index does not exist.");
23 return nullptr;
24}
25
26const Element* QuadraticEdgeReturn::getEdge(const Element* e, unsigned i)
27{
28 if (i < e->getNumberOfEdges())
29 {
30 auto** nodes = new Node*[3];
31 nodes[0] = const_cast<Node*>(e->getEdgeNode(i, 0));
32 nodes[1] = const_cast<Node*>(e->getEdgeNode(i, 1));
33 nodes[2] = const_cast<Node*>(e->getEdgeNode(i, 2));
34 return new Line3(nodes, e->getID());
35 }
36 ERR("Error in MeshLib::Element::getEdge() - Index does not exist.");
37 return nullptr;
38}
39
40} // namespace MeshLib
void ERR(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:40
std::size_t getID() const
Returns the ID of the element.
Definition Element.h:80
virtual Node * getEdgeNode(unsigned edge_id, unsigned node_id) const =0
Return a specific edge node.
static const Element * getEdge(const Element *e, unsigned i)
Returns i-th edge of the given element.
static const Element * getEdge(const Element *e, unsigned i)
Returns i-th edge of the given element.
TemplateElement< MeshLib::LineRule2 > Line
Definition Line.h:14
TemplateElement< MeshLib::LineRule3 > Line3
Definition Line.h:15