Skip to content
Snippets Groups Projects
Commit ae03dd34 authored by Dmitri Naumov's avatar Dmitri Naumov Committed by Christoph Lehmann
Browse files

[ML] 0D Point element.

parent b9341fdd
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@
#include "MeshLib/Elements/Element.h"
#include "MeshLib/Elements/Line.h"
#include "MeshLib/Elements/Hex.h"
#include "MeshLib/Elements/Point.h"
#include "MeshLib/Elements/Prism.h"
#include "MeshLib/Elements/Pyramid.h"
#include "MeshLib/Elements/Quad.h"
......
/**
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef MESHLIB_POINT_H_
#define MESHLIB_POINT_H_
#include "TemplateElement.h"
#include "PointRule1.h"
extern template class MeshLib::TemplateElement<MeshLib::PointRule1>;
namespace MeshLib
{
using Point = TemplateElement<PointRule1>;
}
#endif // MESHLIB_POINT_H_
/**
* \copyright
* Copyright (c) 2012-2015, 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 "PointRule1.h"
#include "MathLib/Point3d.h"
#include "MeshLib/Node.h"
namespace MeshLib {
const unsigned PointRule1::edge_nodes[1][1] =
{
{0}
};
double PointRule1::computeVolume(Node const* const* _nodes)
{
return 0;
}
bool PointRule1::isPntInElement(Node const* const* _nodes, MathLib::Point3d const& pnt, double eps)
{
double const dist = MathLib::sqrDist(*_nodes[0], pnt);
return (dist < eps);
}
unsigned PointRule1::identifyFace(Node const* const* _nodes, Node* nodes[1])
{
if (nodes[0] == _nodes[0])
return 0;
return std::numeric_limits<unsigned>::max();
}
ElementErrorCode PointRule1::validate(const Element* e)
{
ElementErrorCode error_code;
error_code[ElementErrorFlag::ZeroVolume] = e->hasZeroVolume();
return error_code;
}
} // end namespace MeshLib
/**
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef MESHLIB_POINTRULE1_H_
#define MESHLIB_POINTRULE1_H_
#include "MeshLib/MeshEnums.h"
#include "Element.h"
#include "VertexRule.h"
#include "EdgeReturn.h"
namespace MeshLib
{
/// A 0d point element.
class PointRule1 : public VertexRule
{
public:
/// Constant: The number of base nodes for this element
static const unsigned n_base_nodes = 1u;
/// Constant: The number of all nodes for this element
static const unsigned n_all_nodes = 1u;
/// Constant: The geometric type of the element
static const MeshElemType mesh_elem_type = MeshElemType::POINT;
/// Constant: The FEM type of the element
static const CellType cell_type = CellType::POINT1;
/// Constant: The number of neighbors
static const unsigned n_neighbors = 2;
/// Constant: Local node index table for edge
static const unsigned edge_nodes[1][1];
/// Edge rule
typedef NoEdgeReturn EdgeReturn;
/// Checks if a point is inside the element.
/// \param pnt a 3D MathLib::Point3d object
/// \param eps tolerance for numerical algorithm used or computing the
/// property
/// \return true if the point is not outside the element, false otherwise
static bool isPntInElement(Node const* const* _nodes,
MathLib::Point3d const& pnt, double eps);
/// Tests if the element is geometrically valid.
static ElementErrorCode validate(const Element* e);
/// Returns the ID of a face given an array of nodes.
static unsigned identifyFace(Node const* const*, Node* nodes[1]);
/// Calculates the length of a line
static double computeVolume(Node const* const* _nodes);
};
}
#endif // MESHLIB_POINTRULE1_H_
......@@ -10,6 +10,7 @@
#include "TemplateElement.h"
#include "MeshLib/Elements/Hex.h"
#include "MeshLib/Elements/Point.h"
#include "MeshLib/Elements/Line.h"
#include "MeshLib/Elements/Prism.h"
#include "MeshLib/Elements/Pyramid.h"
......@@ -33,6 +34,7 @@ template class MeshLib::TemplateElement<MeshLib::HexRule20>;
template class MeshLib::TemplateElement<MeshLib::HexRule8>;
template class MeshLib::TemplateElement<MeshLib::LineRule2>;
template class MeshLib::TemplateElement<MeshLib::LineRule3>;
template class MeshLib::TemplateElement<MeshLib::PointRule1>;
template class MeshLib::TemplateElement<MeshLib::PrismRule15>;
template class MeshLib::TemplateElement<MeshLib::PrismRule6>;
template class MeshLib::TemplateElement<MeshLib::PyramidRule13>;
......
/**
* \copyright
* Copyright (c) 2012-2015, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#ifndef MESHLIB_VERTEX_RULE_H
#define MESHLIB_VERTEX_RULE_H
namespace MeshLib
{
class Element;
class VertexRule
{
public:
/// Constant: Dimension of this mesh element
static const unsigned dimension = 0u;
/// Constant: The number of faces
static const unsigned n_faces = 0;
/// Constant: The number of edges
static const unsigned n_edges = 0;
/// Get the number of nodes for face i.
static unsigned getNFaceNodes(unsigned /*i*/)
{
return 0;
}
/// Returns the i-th face of the element.
static const Element* getFace(const Element* /*e*/, unsigned /*i*/)
{
return nullptr;
}
/// Checks if the node order of an element is correct by testing surface
/// normals. For 0D elements this always returns true.
static bool testElementNodeOrder(const Element* /*e*/) { return true; }
};
}
#endif // MESHLIB_VERTEX_RULE_H
......@@ -18,6 +18,8 @@ namespace MeshLib {
const std::string MeshElemType2String(const MeshElemType t)
{
if (t == MeshElemType::POINT)
return "Point";
if (t == MeshElemType::LINE)
return "Line";
if (t == MeshElemType::QUAD)
......@@ -37,6 +39,8 @@ const std::string MeshElemType2String(const MeshElemType t)
const std::string MeshElemType2StringShort(const MeshElemType t)
{
if (t == MeshElemType::POINT)
return "point";
if (t == MeshElemType::LINE)
return "line";
if (t == MeshElemType::QUAD)
......@@ -56,6 +60,8 @@ const std::string MeshElemType2StringShort(const MeshElemType t)
MeshElemType String2MeshElemType(const std::string &s)
{
if ((s.compare("point") == 0) || (s.compare("Point") == 0))
return MeshElemType::POINT;
if ((s.compare("line") == 0) || (s.compare("Line") == 0))
return MeshElemType::LINE;
if ((s.compare("quad") == 0) || (s.compare("Quadrilateral") == 0))
......@@ -76,6 +82,7 @@ MeshElemType String2MeshElemType(const std::string &s)
std::vector<MeshElemType> getMeshElemTypes()
{
std::vector<MeshElemType> vec;
vec.push_back(MeshElemType::POINT);
vec.push_back(MeshElemType::LINE);
vec.push_back(MeshElemType::QUAD);
vec.push_back(MeshElemType::HEXAHEDRON);
......@@ -100,6 +107,7 @@ const std::string CellType2String(const CellType t)
if (t == CellType::type)\
return #type;
RETURN_CELL_TYPE_STR(t, POINT1);
RETURN_CELL_TYPE_STR(t, LINE2);
RETURN_CELL_TYPE_STR(t, LINE3);
RETURN_CELL_TYPE_STR(t, QUAD4);
......
......@@ -27,6 +27,7 @@ namespace MeshLib {
enum class MeshElemType
{
INVALID = 0,
POINT = 1,
LINE = 3,
QUAD = 9,
HEXAHEDRON = 12,
......@@ -42,6 +43,7 @@ enum class MeshElemType
enum class CellType
{
INVALID,
POINT1,
LINE2,
LINE3,
TRI3,
......
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