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]);
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++)
348 return J + mass*((d & d)*
I - d*d);
358 auto& tf = tTf.ref();
371 const polyMesh&
mesh,
385 faces[cTI] = cellTets[cTI].faceTriIs(
mesh);
392 massPropertiesSolid(
mesh.
points(), faces, 1.0, m, cM, J);
uindirectPrimitivePatch pp(UIndirectList< face >(mesh.faces(), faceLabels), mesh.points())
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
void append(const T &val)
Copy append an element to the end of this list.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void transfer(List< T > &list)
Transfer the contents of the argument List into this list and annul the argument list.
const Field< point_type > & points() const noexcept
Return reference to global points.
const Cmpt & yy() const noexcept
const Cmpt & zy() const noexcept
const Cmpt & yx() const noexcept
const Cmpt & xx() const noexcept
const Cmpt & yz() const noexcept
const Cmpt & zz() const noexcept
const Cmpt & xy() const noexcept
const Cmpt & xz() const noexcept
const Cmpt & zx() const noexcept
void size(const label n)
Older name for setAddressableSize.
const Cmpt & x() const noexcept
Access to the vector x component.
const Cmpt & z() const noexcept
Access to the vector z component.
const Cmpt & y() const noexcept
Access to the vector y component.
A face is a list of labels corresponding to mesh vertices.
static void massPropertiesShell(const pointField &pts, const triFaceList &triFaces, scalar density, scalar &mass, vector &cM, tensor &J, bool doReduce=false)
static tensor applyParallelAxisTheorem(scalar mass, const vector &cM, const tensor &J, const vector &refPt)
static tmp< tensorField > meshInertia(const polyMesh &mesh)
static void massPropertiesPatch(const polyPatch &pp, scalar density, scalar &mass, vector &cM, tensor &J, bool doReduce=false)
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.
Mesh consisting of general polyhedral cells.
virtual const pointField & points() const
Return raw points.
A patch is a list of labels that address the faces in the global face list.
Tensor of scalars, i.e. Tensor<scalar>.
A class for managing temporary objects.
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
A triangular face using a FixedList of labels corresponding to mesh vertices.
Triangulated surface description with patch information.
static Point centre(const Point &p0, const Point &p1, const Point &p2)
The centre (centroid) of three points.
tensor inertia(PointRef refPt=Zero, scalar density=1.0) const
Return the inertia tensor, with optional reference.
scalar mag() const
The magnitude of the triangle area.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
static const Identity< scalar > I
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void reduce(T &value, BinaryOp bop, const int tag=UPstream::msgType(), const int communicator=UPstream::worldComm)
Reduce inplace (cf. MPI Allreduce).
static constexpr const zero Zero
Global zero (0).
triangle< point, const point & > triPointRef
A triangle using referred points.
List< triFace > triFaceList
List of triFace.
vectorField pointField
pointField is a vectorField.
#define forAll(list, i)
Loop across all elements in list.