35#include "core/array.h"
36#include "offLattice/triangularSurfaceMesh.hh"
37#include "offLattice/triangleBoundary3D.hh"
69 void write(plb_ofstream & meshFile);
71 void write() { plb_ofstream meshQualityFile((global::directories().getLogOutDir() +
"plbMeshQuality.log").c_str()); this->
write(meshQualityFile); } ;
98 TriangularSurfaceMesh<T>
const&
mesh;
128 minArea=std::numeric_limits<T>::max(); minLength=std::numeric_limits<T>::max();
129 minAngle=std::numeric_limits<T>::max(); minNn=std::numeric_limits<T>::max();
130 maxArea=0; maxLength=0; maxAngle=0; maxNn=0;
131 meanVertexPosition.resetToZero();
133 Nv = mesh.getNumVertices();
134 Nt = mesh.getNumTriangles();
135 plb::Array<T,2> xRange;
136 plb::Array<T,2> yRange;
137 plb::Array<T,2> zRange;
138 mesh.computeBoundingBox (xRange, yRange, zRange);
139 cellRadius = max(xRange[1] - xRange[0], yRange[1] - yRange[0]);
140 cellRadius = max(cellRadius , zRange[1] - zRange[0]) * 0.5;
142 Nn=0; Nn6=0; Nn5=0; Nn7=0;
143 area=0; length=0; angle=0;
144 T varArea=0, varLength=0, varAngle=0, varNn=0;
149 for (
int iV = 0; iV < Nv; ++iV) {
150 meanVertexPosition += mesh.getVertex(iV);
151 std::vector<plint> nvid = mesh.getNeighborVertexIds(iV);
152 T NumNeighbors = nvid.size();
154 minNn = minNn>NumNeighbors?NumNeighbors:minNn;
155 maxNn = maxNn<NumNeighbors?NumNeighbors:maxNn;
156 for (
int ijV = 0; ijV < NumNeighbors; ++ijV) {
158 tmp = mesh.computeEdgeLength(iV, jV);
159 minLength = minLength>tmp?tmp:minLength;
160 maxLength = maxLength<tmp?tmp:maxLength;
163 minAngle = minAngle>tmp?tmp:minAngle;
164 maxAngle = maxAngle<tmp?tmp:maxAngle;
168 if (NumNeighbors == 5) {
170 }
else if (NumNeighbors == 6) {
172 }
else if (NumNeighbors == 7) {
175 std::vector<plint> neighborTriangleIds = mesh.getNeighborTriangleIds(iV);
176 for (
pluint iB = 0; iB < neighborTriangleIds.size(); ++iB) {
177 plint iTriangle = neighborTriangleIds[iB];
182 crossProduct(v1, v2, tmp);
183 T triangleVolumeT6 = dot(v0,tmp);
184 volume += triangleVolumeT6/6.0/3.0;
187 Nn /= Nv; length /= NEdges; angle /= NEdges;
188 meanVertexPosition /= Nv;
191 for (
int iV = 0; iV < Nv; ++iV) {
192 std::vector<plint> nvid = mesh.getNeighborVertexIds(iV);
193 T NumNeighbors = nvid.size();
194 tmp = nvid.size()-Nn;
196 for (
int ijV = 0; ijV < NumNeighbors; ++ijV) {
198 tmp=(mesh.computeEdgeLength(iV, jV)-length);
199 varLength += tmp*tmp;
206 for (
int iT = 0; iT < Nt; ++iT) {
207 tmp = mesh.computeTriangleArea(iT);
208 minArea = minArea>tmp?tmp:minArea;
209 maxArea = maxArea<tmp?tmp:maxArea;
213 for (
int iT = 0; iT < Nt; ++iT) {
214 tmp = mesh.computeTriangleArea(iT) - area;
217 sigmaNn = sqrt(varNn/Nv);
218 sigmaArea = sqrt(varArea/Nt);
219 sigmaLength = sqrt(varLength/NEdges);
220 sigmaAngle = sqrt(varAngle/NEdges);
230 meshFile <<
"# Deviation in %, defined as 100*sigma(l)/mean(l), sl = 0" << std::endl;
232 meshFile <<
"Number of vertices, Nv = " << Nv << std::endl;
233 meshFile <<
"Number of triangles, Nt = " << Nt << std::endl;
234 meshFile <<
"Surface, S = " << getSurface() << std::endl;
235 meshFile <<
"Volume, V = " << getVolume() << std::endl;
236 meshFile << std::endl;
237 meshFile <<
"Mean Area per face, A = " << area << std::endl;
238 meshFile <<
"Deviation of Area %, sA = " << 100*sigmaArea/area << std::endl;
239 meshFile <<
"Max Area of face, maxA = " << maxArea << std::endl;
240 meshFile <<
"Min Area of face, minA = " << minArea << std::endl;
241 meshFile << std::endl;
242 meshFile <<
"Mean Length per vertex, L = " << length << std::endl;
243 meshFile <<
"Deviation of Length %, sL = " << 100*sigmaLength/length << std::endl;
244 meshFile <<
"Max Length of edge, maxA = " << maxLength << std::endl;
245 meshFile <<
"Min Length of edge, minA = " << minLength << std::endl;
246 meshFile << std::endl;
247 meshFile <<
"Mean Angle per vertex, theta = " << angle << std::endl;
248 meshFile <<
"Deviation of Angle %, sTheta = " << fabs(100*sigmaAngle/angle) << std::endl;
249 meshFile <<
"Max Angle of edge, maxA = " << maxAngle << std::endl;
250 meshFile <<
"Min Angle of edge, minA = " << minAngle << std::endl;
251 meshFile << std::endl;
252 meshFile <<
"Mean number of neighbours, Nn = " << Nn << std::endl;
253 meshFile <<
"Deviation for number of Neighbours %, sNn = " << 100*sigmaNn/Nn << std::endl;
254 meshFile <<
"Number of 5 neighbour in %, Nn5 = " << 100*Nn5/Nv << std::endl;
255 meshFile <<
"Number of 6 neighbour in %, Nn6 = " << 100*Nn6/Nv << std::endl;
256 meshFile <<
"Number of 7 neighbour in %, Nn7 = " << 100*Nn7/Nv << std::endl;
Definition meshMetrics.h:44
std::vector< plint > emanatingEdgeList
Definition meshMetrics.h:47
std::vector< Array< T, 3 > > vertexList
Definition meshMetrics.h:46
std::vector< Edge > edgeList
Definition meshMetrics.h:48
Definition meshMetrics.h:63
T angle
Definition meshMetrics.h:100
T Nn
Definition meshMetrics.h:99
T maxAngle
Definition meshMetrics.h:104
T getMinArea()
Definition meshMetrics.h:87
T getMeanLength()
Definition meshMetrics.h:77
T Nn7
Definition meshMetrics.h:99
hemo::Array< T, 3 > meanVertexPosition
Definition meshMetrics.h:101
void write()
Definition meshMetrics.h:71
TriangularSurfaceMesh< T > const & mesh
Definition meshMetrics.h:98
T getNumTriangles()
Definition meshMetrics.h:95
T Nt
Definition meshMetrics.h:99
T maxArea
Definition meshMetrics.h:104
T sigmaNn
Definition meshMetrics.h:102
T Nn5
Definition meshMetrics.h:99
T getMinLength()
Definition meshMetrics.h:79
TriangularSurfaceMesh< T > const & getMesh()
Definition meshMetrics.h:76
void set_dx(T dx_)
Definition meshMetrics.h:72
T sigmaArea
Definition meshMetrics.h:102
T getSurface()
Definition meshMetrics.h:90
T minNn
Definition meshMetrics.h:103
T dm
Definition meshMetrics.h:105
T getMeanAngle()
Definition meshMetrics.h:81
T getMinAngle()
Definition meshMetrics.h:83
hemo::Array< T, 3 > getMeanVertexPosition()
Definition meshMetrics.h:92
T dx
Definition meshMetrics.h:105
T sigmaAngle
Definition meshMetrics.h:102
T minLength
Definition meshMetrics.h:103
T getMaxLength()
Definition meshMetrics.h:78
void init()
Definition meshMetrics.h:127
MeshMetrics(MeshMetrics< T > const &rhs)
Definition meshMetrics.h:110
T getMeanArea()
Definition meshMetrics.h:85
T maxLength
Definition meshMetrics.h:104
T Nn6
Definition meshMetrics.h:99
T volume
Definition meshMetrics.h:100
void set_dxdtdm(T dx_, T dt_, T dm_)
Definition meshMetrics.h:75
T minArea
Definition meshMetrics.h:103
T getMaxAngle()
Definition meshMetrics.h:82
void set_dt(T dt_)
Definition meshMetrics.h:73
T getRadius()
Definition meshMetrics.h:89
T area
Definition meshMetrics.h:100
T getMaxArea()
Definition meshMetrics.h:86
T getNumVertices()
Definition meshMetrics.h:94
T sigmaLength
Definition meshMetrics.h:102
T length
Definition meshMetrics.h:100
T dt
Definition meshMetrics.h:105
T minAngle
Definition meshMetrics.h:103
void set_dm(T dm_)
Definition meshMetrics.h:74
T cellRadius
Definition meshMetrics.h:106
T maxNn
Definition meshMetrics.h:104
T Nv
Definition meshMetrics.h:99
T getVolume()
Definition meshMetrics.h:91
~MeshMetrics()
Definition meshMetrics.h:224
double T
Definition constant_defaults.h:118
long int plint
Definition constant_defaults.h:127
long unsigned int pluint
Definition constant_defaults.h:130
Definition meshGeneratingFunctions.cpp:28
void writeSurfaceMeshAsciiSTL(TriangularSurfaceMesh< T > const &mesh, std::string fname)
Definition meshMetrics.hh:83
T calculateSignedAngle(TriangularSurfaceMesh< T > const &mesh, plint iVertex, plint jVertex, plint &kVertex, plint &lVertex)
Definition meshMetrics.hh:36
TriangularSurfaceMesh< T > * copyTriangularSurfaceMesh(TriangularSurfaceMesh< T > const &mesh, ElementsOfTriangularSurfaceMesh< T > &emptyEoTSM)
Definition meshMetrics.h:52