cuboid.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2016-2026 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::RBD::cuboid
26 
27 Description
28  Specialisation of rigidBody to construct a cuboid given the mass and
29  lengths of the sides.
30 
31 SourceFiles
32  cuboidI.H
33  cuboid.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef RBD_cuboid_H
38 #define RBD_cuboid_H
39 
40 #include "rigidBody.H"
41 
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 
44 namespace Foam
45 {
46 namespace RBD
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class cuboid Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 class cuboid
54 :
55  public rigidBody
56 {
57  // Private Data
58 
59  //- Lengths of the sides
60  vector L_;
61 
62 
63  // Private Member Functions
64 
65  // Calculate and return the inertia tensor
66  inline symmTensor I(const scalar m, const vector& L) const;
67 
68 
69 public:
70 
71  //- Runtime type information
72  TypeName("cuboid");
73 
74 
75  // Constructors
76 
77  //- Construct from name, mass, centre of mass and lengths of the sides.
78  inline cuboid
79  (
80  const word& name,
81  const scalar m,
82  const vector& c,
83  const vector& L
84  );
85 
86  //- Construct from dictionary
87  inline cuboid
88  (
89  const word& name,
90  const dictionary& dict
91  );
92 
93  //- Return clone of this cuboid
94  virtual autoPtr<rigidBody> clone() const;
95 
96 
97  //- Destructor
98  virtual ~cuboid();
99 
100 
101  // Member Functions
102 
103  //- Return the lengths of the sides of the cuboid
104  inline const vector& L() const;
105 
106  //- Return the zeroth moments of the sections of the body between
107  // planes defined by distances along the given axis
109  (
110  const direction axis,
111  const scalarField& distances
112  ) const;
113 
114  //- Return the first moments of the sections of the body between
115  // planes defined by distances along the given axis
117  (
118  const direction axis,
119  const scalarField& distances
120  ) const;
121 
122  //- Return the second moments of the sections of the body between
123  // planes defined by distances along the given axis
125  (
126  const direction axis,
127  const scalarField& distances
128  ) const;
129 
130  //- Write
131  virtual void write(Ostream&) const;
132 };
133 
134 
135 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
136 
137 } // End namespace RBD
138 } // End namespace Foam
139 
140 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
141 
142 #include "cuboidI.H"
143 
144 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
145 
146 #endif
147 
148 // ************************************************************************* //
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Specialisation of rigidBody to construct a cuboid given the mass and lengths of the sides.
Definition: cuboid.H:55
virtual tmp< vectorField > sectionMu1s(const direction axis, const scalarField &distances) const
Return the first moments of the sections of the body between.
Definition: cuboid.C:88
virtual void write(Ostream &) const
Write.
Definition: cuboid.C:162
virtual ~cuboid()
Destructor.
Definition: cuboid.C:52
TypeName("cuboid")
Runtime type information.
virtual tmp< symmTensorField > sectionMu2s(const direction axis, const scalarField &distances) const
Return the second moments of the sections of the body between.
Definition: cuboid.C:117
virtual autoPtr< rigidBody > clone() const
Return clone of this cuboid.
Definition: cuboid.C:44
cuboid(const word &name, const scalar m, const vector &c, const vector &L)
Construct from name, mass, centre of mass and lengths of the sides.
Definition: cuboidI.H:51
virtual tmp< scalarField > sectionMu0s(const direction axis, const scalarField &distances) const
Return the zeroth moments of the sections of the body between.
Definition: cuboid.C:59
const vector & L() const
Return the lengths of the sides of the cuboid.
Definition: cuboidI.H:80
const vector & c() const
Return the centre of mass of the rigid-body.
scalar m() const
Return the mass of the rigid-body.
const word & name() const
Return name.
Definition: rigidBodyI.H:65
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:63
Namespace for OpenFOAM.
uint8_t direction
Definition: direction.H:45
dictionary dict