80 const scalar r6 = 1.0/6.0;
81 const scalar r24 = 1.0/24.0;
82 const scalar r60 = 1.0/60.0;
83 const scalar r120 = 1.0/120.0;
90 const triFace& tri(triFaces[i]);
103 scalar tmp0, tmp1, tmp2;
105 scalar f1x, f2x, f3x, g0x, g1x, g2x;
107 tmp0 = v0.x() + v1.x();
109 tmp1 = v0.x()*v0.x();
110 tmp2 = tmp1 + v1.x()*tmp0;
111 f2x = tmp2 + v2.x()*f1x;
112 f3x = v0.x()*tmp1 + v1.x()*tmp2 + v2.x()*f2x;
113 g0x = f2x + v0.x()*(f1x + v0.x());
114 g1x = f2x + v1.x()*(f1x + v1.x());
115 g2x = f2x + v2.x()*(f1x + v2.x());
117 scalar f1y, f2y, f3y, g0y, g1y, g2y;
119 tmp0 = v0.y() + v1.y();
121 tmp1 = v0.y()*v0.y();
122 tmp2 = tmp1 + v1.y()*tmp0;
123 f2y = tmp2 + v2.y()*f1y;
124 f3y = v0.y()*tmp1 + v1.y()*tmp2 + v2.y()*f2y;
125 g0y = f2y + v0.y()*(f1y + v0.y());
126 g1y = f2y + v1.y()*(f1y + v1.y());
127 g2y = f2y + v2.y()*(f1y + v2.y());
129 scalar f1z, f2z, f3z, g0z, g1z, g2z;
131 tmp0 = v0.z() + v1.z();
133 tmp1 = v0.z()*v0.z();
134 tmp2 = tmp1 + v1.z()*tmp0;
135 f2z = tmp2 + v2.z()*f1z;
136 f3z = v0.z()*tmp1 + v1.z()*tmp2 + v2.z()*f2z;
137 g0z = f2z + v0.z()*(f1z + v0.z());
138 g1z = f2z + v1.z()*(f1z + v1.z());
139 g2z = f2z + v2.z()*(f1z + v2.z());
142 integrals[0] +=
n.x()*f1x;
143 integrals[1] +=
n.x()*f2x;
144 integrals[2] +=
n.y()*f2y;
145 integrals[3] +=
n.z()*f2z;
146 integrals[4] +=
n.x()*f3x;
147 integrals[5] +=
n.y()*f3y;
148 integrals[6] +=
n.z()*f3z;
149 integrals[7] +=
n.x()*(v0.y()*g0x + v1.y()*g1x + v2.y()*g2x);
150 integrals[8] +=
n.y()*(v0.z()*g0y + v1.z()*g1y + v2.z()*g2y);
151 integrals[9] +=
n.z()*(v0.x()*g0z + v1.x()*g1z + v2.x()*g2z);
161 integrals[7] *= r120;
162 integrals[8] *= r120;
163 integrals[9] *= r120;
169 cM =
vector(integrals[1], integrals[2], integrals[3])/mass;
172 J.xx() = integrals[5] + integrals[6];
173 J.xy() = -integrals[7];
174 J.xz() = -integrals[9];
176 J.yy() = integrals[4] + integrals[6];
177 J.yz() = -integrals[8];
180 J.zz() = integrals[4] + integrals[5];
183 J -= mass*((cM & cM)*
I - cM*cM);
212 const triFace& tri(triFaces[i]);
221 scalar triMag = t.
mag();
230 reduce(cM, sumOp<vector>());
231 reduce(mass, sumOp<scalar>());
242 const triFace& tri(triFaces[i]);
249 ).inertia(cM, density);
261 const triSurface& surf,
275 massPropertiesSolid(surf.points(), faces, density, mass, cM, J);
281 const triSurface& surf,
296 massPropertiesShell(surf.points(), faces, density, mass, cM, J, doReduce);
310 DynamicList<triFace> faces(3*pp.size());
315 const face&
f = pp[faceI];
321 for (label i = 1; i <
f.
size() - 1; i++)
330 massPropertiesShell(pp.points(), triFaces, density, mass, cM, J, doReduce);
348 return J + mass*((d & d)*
I - d*d);
363 tf[cI] = meshInertia(
mesh, cI);
372 const polyMesh&
mesh,
386 faces[cTI] = cellTets[cTI].faceTriIs(
mesh);
393 massPropertiesSolid(
mesh.
points(), faces, 1.0, m, cM, J);
void size(const label n)
Older name for setAddressableSize.
A triangle primitive used to calculate face normals and swept volumes. Uses referred points...
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
scalar mag() const
The magnitude of the triangle area.
void append(const T &val)
Append an element at the end of the list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
static void massPropertiesSolid(const pointField &pts, const triFaceList &triFaces, scalar density, scalar &mass, vector &cM, tensor &J)
static List< tetIndices > cellTetIndices(const polyMesh &mesh, label cI)
Return the tet decomposition of the given cell, see.
virtual const pointField & points() const
Return raw points.
#define forAll(list, i)
Loop across all elements in list.
List< triFace > triFaceList
list of triFaces
static Point centre(const Point &p0, const Point &p1, const Point &p2)
The centre (centroid) of three points.
static const Identity< scalar > I
A triangular face using a FixedList of labels corresponding to mesh vertices.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
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)
label nCells() const noexcept
Number of mesh cells.
static void massPropertiesPatch(const polyPatch &pp, scalar density, scalar &mass, vector &cM, tensor &J, bool doReduce=false)
triangle< point, const point & > triPointRef
A triangle using referred points.
void reduce(const List< UPstream::commsStruct > &comms, T &value, const BinaryOp &bop, const int tag, const label comm)
Reduce inplace (cf. MPI Allreduce) using specified communication schedule.
Mesh consisting of general polyhedral cells.
A class for managing temporary objects.
Tensor of scalars, i.e. Tensor<scalar>.
static void massPropertiesShell(const pointField &pts, const triFaceList &triFaces, scalar density, scalar &mass, vector &cM, tensor &J, bool doReduce=false)
static constexpr const zero Zero
Global zero (0)