-
Notifications
You must be signed in to change notification settings - Fork 239
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'RefactorMeshLibElementRules' into 'master'
Refactor MeshLib element rules See merge request ogs/ogs!4675
- Loading branch information
Showing
44 changed files
with
1,023 additions
and
731 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,6 @@ | |
|
||
#include "Element.h" | ||
#include "FaceRule.h" | ||
#include "MeshLib/Node.h" | ||
|
||
namespace MeshLib | ||
{ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* \file | ||
* \copyright | ||
* Copyright (c) 2012-2023, 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 "HexRule.h" | ||
|
||
#include "MathLib/GeometricBasics.h" | ||
#include "MeshLib/Node.h" | ||
#include "Quad.h" | ||
|
||
namespace MeshLib | ||
{ | ||
double HexRule::computeVolume(Node const* const* element_nodes) | ||
{ | ||
return MathLib::calcTetrahedronVolume(*element_nodes[4], | ||
*element_nodes[7], | ||
*element_nodes[5], | ||
*element_nodes[0]) + | ||
MathLib::calcTetrahedronVolume(*element_nodes[5], | ||
*element_nodes[3], | ||
*element_nodes[1], | ||
*element_nodes[0]) + | ||
MathLib::calcTetrahedronVolume(*element_nodes[5], | ||
*element_nodes[7], | ||
*element_nodes[3], | ||
*element_nodes[0]) + | ||
MathLib::calcTetrahedronVolume(*element_nodes[5], | ||
*element_nodes[7], | ||
*element_nodes[6], | ||
*element_nodes[2]) + | ||
MathLib::calcTetrahedronVolume(*element_nodes[1], | ||
*element_nodes[3], | ||
*element_nodes[5], | ||
*element_nodes[2]) + | ||
MathLib::calcTetrahedronVolume(*element_nodes[3], | ||
*element_nodes[7], | ||
*element_nodes[5], | ||
*element_nodes[2]); | ||
} | ||
|
||
bool HexRule::isPntInElement(Node const* const* nodes, | ||
MathLib::Point3d const& pnt, | ||
double eps) | ||
{ | ||
return (MathLib::isPointInTetrahedron( | ||
pnt, *nodes[4], *nodes[7], *nodes[5], *nodes[0], eps) || | ||
MathLib::isPointInTetrahedron( | ||
pnt, *nodes[5], *nodes[3], *nodes[1], *nodes[0], eps) || | ||
MathLib::isPointInTetrahedron( | ||
pnt, *nodes[5], *nodes[7], *nodes[3], *nodes[0], eps) || | ||
MathLib::isPointInTetrahedron( | ||
pnt, *nodes[5], *nodes[7], *nodes[6], *nodes[2], eps) || | ||
MathLib::isPointInTetrahedron( | ||
pnt, *nodes[1], *nodes[3], *nodes[5], *nodes[2], eps) || | ||
MathLib::isPointInTetrahedron( | ||
pnt, *nodes[3], *nodes[7], *nodes[5], *nodes[2], eps)); | ||
} | ||
|
||
ElementErrorCode HexRule::validate(const Element* e) | ||
{ | ||
ElementErrorCode error_code; | ||
error_code[ElementErrorFlag::ZeroVolume] = hasZeroVolume(*e); | ||
|
||
for (unsigned i = 0; i < 6; ++i) | ||
{ | ||
if (error_code.all()) | ||
{ | ||
break; | ||
} | ||
|
||
const MeshLib::Element* quad(e->getFace(i)); | ||
error_code |= quad->validate(); | ||
delete quad; | ||
} | ||
error_code[ElementErrorFlag::NodeOrder] = !e->testElementNodeOrder(); | ||
return error_code; | ||
} | ||
|
||
} // end namespace MeshLib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/** | ||
* \file | ||
* \copyright | ||
* Copyright (c) 2012-2023, OpenGeoSys Community (http://www.opengeosys.org) | ||
* Distributed under a Modified BSD License. | ||
* See accompanying file LICENSE.txt or | ||
* http://www.opengeosys.org/project/license | ||
* | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "CellRule.h" | ||
#include "Element.h" | ||
#include "MeshLib/MeshEnums.h" | ||
|
||
namespace MeshLib | ||
{ | ||
class HexRule : public CellRule | ||
{ | ||
public: | ||
/// Constant: The number of base nodes for this element | ||
static const unsigned n_base_nodes = 8u; | ||
|
||
/// Constant: The geometric type of the element | ||
static const MeshElemType mesh_elem_type = MeshElemType::HEXAHEDRON; | ||
|
||
/// Constant: The number of faces | ||
static const unsigned n_faces = 6; | ||
|
||
/// Constant: The number of edges | ||
static const unsigned n_edges = 12; | ||
|
||
/// Constant: The number of neighbors | ||
static const unsigned n_neighbors = 6; | ||
|
||
/** | ||
* \copydoc MeshLib::Element::isPntInElement() | ||
* \param nodes the nodes of the element. | ||
*/ | ||
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); | ||
|
||
/// Calculates the volume of a convex hexahedron by partitioning it into six | ||
/// tetrahedra. | ||
static double computeVolume(Node const* const* element_nodes); | ||
}; | ||
} // namespace MeshLib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.