AMCAX Kernel 1.0.0.0
Loading...
Searching...
No Matches
Mesh Quality Example

Example Usage

AMCAX_API double ComputeQuality(const NMMeshElem &elem,
const QualityType qtye,
const CommercialSoftware cstye);

Parameter Type Descriptions

NMMeshElem

Element types include linear elements: triangles, quadrilaterals, tetrahedrons, pyramids, prisms, and hexahedrons.

Tri_3 Quad_4 Tet_4 Pyramid_5 Prism_6 Hex_8

QualityType

Quality metrics include most commercial software quality indicators:

MinLength Minimum Length MaxLength Maximum Length MinHeight Minimum Height MinNormalizedHeight

Minimum Normalized Height

CharacteristicLength Characteristic Length ElementQuality Element Quality (ANSYS) SkewnessByVolume Volume-based Skewness SkewnessByEquiangular

Angle-based Skewness

MaxAngle2d 2D Maximum Angle MinAngle2d 2D Minimum Angle JacobianRatioByCorner Corner-based Jacobian Ratio JacobianRatioByGauss

Gauss-point-based Jacobian Ratio

AspectRatio Aspect Ratio Collapse Collapse Value WarpingAngle Warping Angle WarpingFactor

Warping Factor

ChordalDeviation Chordal Deviation Taper Taper Ratio MaxDihedraAngle Maximum Dihedral Angle MinDihedraAngle Minimum Dihedral Angle

CommercialSoftware

Commercial software types with independent quality metric calculation methods: HyperMesh, ANSYS, Fluent, Nastran.

HyperMesh ANSYS Fluent Nastran

Metric Value Ranges

Optimal/worst values for each quality metric:

Quality Metric [worst, best]
Skewness (angle) [90°, 0°]
Skewness (value) [1, 0]
Jacobian [-1, 1]
Aspect Ratio [inf, 1]
Warping (angle) [pi, 0]
Warping factor (value) [inf, 0]
Interior Angles Tri:
Max angle: [180°, 60°]
Min angle: [0°, 60°]
Quad:
Max angle: [180°, 90°]
Min angle:[0°, 90°]
Collapse [0, 1]
Taper [1, 0]
Element Quality [0, 1]

Business Metrics Comparison Table

HyperMesh (Shells)
Aspect Ratio Skew Chordal Deviation Warpage Tri minimum angle Tri maximum angle Quad minimum angle Quad maximum angle Minimum length Maximum length


HyperMesh (Solid)
Aspect Ratio Skew Volumetric Skewness Jacobian Tet collapse Equia skew Minimum angle Maximum angle Minimum length


ANSYS (Shells)
Aspect Ratio Skewness Warping Jacobian Minimum angle Maximum angle Characteristic Length Minimum length Element Quality Parallel Deviation


ANSYS (Solid)
Aspect Ratio Warping Jacobian Collapse Characteristic Length Min Height Element Quality Parallel Deviation


Fluent (Shells)
Aspect Ratio Skewness Warp


Fluent (Solid)
Aspect Ratio Skewness Warp Dihedral Angle


Nastran (Shells)
Aspect Ratio Skewness Warping Taper Jacobian Minimum angle Maximum angle Characteristic Length Minimum length


Nastran (Solid)
Aspect Ratio Warping Jacobian Collapse Characteristic Length Min Height

Complete Example

A complete example demonstrating how to obtain area skewness for 2D triangular surface meshes and volume skewness for 3D tetrahedral volume meshes, analyzed using Fluent commercial software:

#include <fstream>
#include <nlohmann/json.hpp>
#include <set>
using namespace AMCAX::NextMesh;
void Quality()
{
const std::string jsonPath = "./data/test.json";
NMAPIModel nmapi;
AMCAX::OCCTIO::OCCTTool::Read(shape, "./data/test.brep");
std::vector<NMShape>shapes = { shape };
nmapi.ImportModel(shapes);
std::vector<NMEntity> ent_d2, ent_d3;
nmapi.GetEntities(ent_d2, DimType::D2);
nmapi.GetEntities(ent_d3, DimType::D3);
nlohmann::json paraJ = nlohmann::json::parse(std::ifstream(jsonPath));
nmapi.GenerateMesh(paraJ.dump());
auto meshapi = nmapi.GetMesh();
for (auto entf : ent_d2)
{
auto ec = meshapi.EntityGetElementCount(entf);
for (size_t i = 0; i < ec; i++)
{
auto elem = meshapi.EntityGetElementByIndex(entf, i);
double quality = 1.0;
if (meshapi.ElementGetType(elem) == ElemType::Tri_3)
{
quality = meshapi.ComputeQuality(
elem,
QualityType::SkewnessByVolume,
CommercialSoftware::Fluent
);
}
}
}
for (auto entf : ent_d3)
{
auto ec = meshapi.EntityGetElementCount(entf);
for (size_t i = 0; i < ec; i++)
{
auto elem = meshapi.EntityGetElementByIndex(entf, i);
double quality = 1.0;
if (meshapi.ElementGetType(elem) == ElemType::Tet_4)
{
quality = meshapi.ComputeQuality(
elem,
QualityType::SkewnessByVolume,
CommercialSoftware::Fluent
);
}
}
}
}
int main()
{
Quality();
}
Class of NextMesh Model.
Class of read and write shapes from OCCT BRep files.
Class of model in NextMesh.
Definition NMAPIModel.hpp:22
AMCAX_API void ImportModel(const std::vector< NMShape > &shapes, const bool replace=true)
Load a cad model represented by AMCAX TopoShape. Note: this import method does not specify any entity...
AMCAX_API void GenerateMesh(const std::string &configJson)
Generates the mesh for the current model based on provided configuration parameters.
AMCAX_API void GetEntities(std::vector< NMEntity > &ents, const DimType dim)
get all the entities in the specified dim
AMCAX_API NMMesh GetMesh()
Get the mesh handle. Note one model only holds a unique mesh.
static AMCAX_API void InitLogger(const std::string &logFileName="", const std::string &logPattern="[%Y-%m-%dT%X%z] [%l] %v", const int64_t logFileSize=20 *1024 *1024, const int maxLogFiles=100)
set the logger. the logger is closed by default, if this function is not called
static AMCAX_API bool Read(TopoShape &s, std::istream &is)
Read a shape from a stream.
Base class of shape, containing an underlying shape with a location and an orientation.
Definition TopoShape.hpp:15
Namespace of all interface in the AMCAX NextMesh module.
Definition misc.docu:42

Click here example04 to get the full source code of the Mesh Quality example, you can download it according to your learning needs.