77 const scalar r6 = 1.0/6.0;
78 const scalar r24 = 1.0/24.0;
79 const scalar r60 = 1.0/60.0;
80 const scalar r120 = 1.0/120.0;
87 const triFace& tri(triFaces[i]);
100 scalar tmp0, tmp1, tmp2;
102 scalar f1x, f2x, f3x, g0x, g1x, g2x;
104 tmp0 = v0.
x() + v1.
x();
106 tmp1 = v0.x()*v0.x();
107 tmp2 = tmp1 + v1.
x()*tmp0;
108 f2x = tmp2 + v2.
x()*f1x;
109 f3x = v0.x()*tmp1 + v1.
x()*tmp2 + v2.
x()*f2x;
110 g0x = f2x + v0.x()*(f1x + v0.x());
111 g1x = f2x + v1.
x()*(f1x + v1.
x());
112 g2x = f2x + v2.
x()*(f1x + v2.
x());
114 scalar f1y, f2y, f3y, g0y, g1y, g2y;
116 tmp0 = v0.y() + v1.
y();
118 tmp1 = v0.y()*v0.y();
119 tmp2 = tmp1 + v1.
y()*tmp0;
120 f2y = tmp2 + v2.
y()*f1y;
121 f3y = v0.y()*tmp1 + v1.
y()*tmp2 + v2.
y()*f2y;
122 g0y = f2y + v0.y()*(f1y + v0.y());
123 g1y = f2y + v1.
y()*(f1y + v1.
y());
124 g2y = f2y + v2.
y()*(f1y + v2.
y());
126 scalar f1z, f2z, f3z, g0z, g1z, g2z;
128 tmp0 = v0.z() + v1.
z();
130 tmp1 = v0.z()*v0.z();
131 tmp2 = tmp1 + v1.
z()*tmp0;
132 f2z = tmp2 + v2.
z()*f1z;
133 f3z = v0.z()*tmp1 + v1.
z()*tmp2 + v2.
z()*f2z;
134 g0z = f2z + v0.z()*(f1z + v0.z());
135 g1z = f2z + v1.
z()*(f1z + v1.
z());
136 g2z = f2z + v2.
z()*(f1z + v2.
z());
139 integrals[0] += n.
x()*f1x;
140 integrals[1] += n.
x()*f2x;
141 integrals[2] += n.
y()*f2y;
142 integrals[3] += n.
z()*f2z;
143 integrals[4] += n.
x()*f3x;
144 integrals[5] += n.
y()*f3y;
145 integrals[6] += n.
z()*f3z;
146 integrals[7] += n.
x()*(v0.y()*g0x + v1.
y()*g1x + v2.
y()*g2x);
147 integrals[8] += n.
y()*(v0.z()*g0y + v1.
z()*g1y + v2.
z()*g2y);
148 integrals[9] += n.
z()*(v0.x()*g0z + v1.
x()*g1z + v2.
x()*g2z);
158 integrals[7] *= r120;
159 integrals[8] *= r120;
160 integrals[9] *= r120;
166 cM =
vector(integrals[1], integrals[2], integrals[3])/mass;
169 J.
xx() = integrals[5] + integrals[6];
170 J.
xy() = -integrals[7];
171 J.
xz() = -integrals[9];
173 J.
yy() = integrals[4] + integrals[6];
174 J.
yz() = -integrals[8];
177 J.
zz() = integrals[4] + integrals[5];
180 J -= mass*((cM & cM)*
I - cM*cM);
208 const triFace& tri(triFaces[i]);
217 scalar triMag = t.
mag();
232 const triFace& tri(triFaces[i]);
239 ).inertia(cM, density);
260 massPropertiesSolid(surf.
points(), faces, density, mass, cM, J);
280 massPropertiesShell(surf.
points(), faces, density, mass, cM, J);
298 return J + mass*((d & d)*
I - d*d);
313 tf[cI] = meshInertia(mesh, cI);
336 faces[cTI] = cellTets[cTI].faceTriIs(mesh);
343 massPropertiesSolid(mesh.
points(), faces, 1.0, m, cM, J);
#define forAll(list, i)
Loop across all elements in list.
A triangle primitive used to calculate face areas and swept volumes.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
scalar mag() const
Return scalar magnitude.
T & ref() const
Return non-const reference or generate a fatal error.
void size(const label)
Override size to be inconsistent with allocated storage.
static void massPropertiesSolid(const pointField &pts, const triFaceList &triFaces, scalar density, scalar &mass, vector &cM, tensor &J)
Vector< scalar > vector
A scalar version of the templated Vector.
virtual const pointField & points() const
Return raw points.
static void massPropertiesShell(const pointField &pts, const triFaceList &triFaces, scalar density, scalar &mass, vector &cM, tensor &J)
static const Identity< scalar > I
A triangular face using a FixedList of labels corresponding to mesh vertices.
const Field< PointType > & points() const
Return reference to global points.
Point centre() const
Return centre (centroid)
static tmp< tensorField > meshInertia(const polyMesh &mesh)
Field< tensor > tensorField
Specialisation of Field<T> for tensor.
static tensor applyParallelAxisTheorem(scalar mass, const vector &cM, const tensor &J, const vector &refPt)
triangle< point, const point & > triPointRef
Mesh consisting of general polyhedral cells.
A class for managing temporary objects.
Triangulated surface description with patch information.