Dear lammps users,
I’m computing total volume of triangulated mesh in my own angle (the
code of the routine is at the end of the message). Mesh is stored in
lammps using angles. For instance, I have cube made of 12 triangles.
Cube is 4x4 with the center in origin. Simulation domain is cube 6x6.
Cube vertices are frozen particles.
When I compute cube's volume on one processor, it works properly. But
when on 2 - I have weird triangles:
on the second processor I have a triangle constructed from one “real”
vertex and 2 “ghosts” with the following coordinates:
-2 -2 -4
2 - 2 -2
2 -2 -4
This triangle is not even similar to the original one which (to my mind) is
-2 -2 2
2 -2 -2
2 -2 2
Thus it’s area is different from what I would expect. Do you have an
idea about handling such situations? Do I need to get
domain->minimum_image from all triangular's points participating in
calculations(is this the only way)?
Code of the routine:
double computeTotalVolume(double** x, int** anglelist, int
nanglelist, Domain*& domain, MPI_Comm comm)
{
double volume = 0.0;
for (int n = 0; n < nanglelist; n++) {
int i1 = anglelist[n][0];
int i2 = anglelist[n][1];
int i3 = anglelist[n][2];
// 1st bond - 21
double x21[3];
MathExtra::sub3(x[i2], x[i1], x21);
// 3nd bond - 31
double x31[3];
MathExtra::sub3(x[i3], x[i1], x31);
// normal to the triangle
double normal[3];
MathExtra::cross3(x21, x31, normal);
double massCenter[3];
computeMassCenterTriangle(x, i1, i2, i3, massCenter);
domain->minimum_image(massCenter);
double mcOnNorm = MathExtra::dot3(massCenter, normal);
assert(mcOnNorm > 0.0); //if it is < 0 then mesh is not oriented properly
volume += mcOnNorm / 6.;
}
double totalVolume;
MPI_Allreduce(&volume, &totalVolume, 1, MPI_DOUBLE, MPI_SUM, comm);
assert(totalVolume > 0.); //check that mesh is positively oriented
return totalVolume;
}
the mesh:
Atoms
1 1 1 -2.0 2.0 -2.0
2 1 1 2.0 2.0 -2.0
3 1 1 2.0 -2.0 -2.0
4 1 1 -2.0 -2.0 -2.0
5 1 1 -2.0 2.0 2.0
6 1 1 2.0 2.0 2.0
7 1 1 2.0 -2.0 2.0
8 1 1 -2.0 -2.0 2.0
Angles
1 1 1 2 3
2 1 3 4 1
3 1 5 7 6
4 1 7 5 8
5 1 1 6 2.
6 1 6 1 5
7 1 2 7 3
8 1 7 2 6
9 1 8 3 7
10 1 3 8 4
11 1 4 8 5
12 1 4 5 1