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-2021 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 member 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  //- Write
107  virtual void write(Ostream&) const;
108 };
109 
110 
111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112 
113 } // End namespace RBD
114 } // End namespace Foam
115 
116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117 
118 #include "cuboidI.H"
119 
120 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
121 
122 #endif
123 
124 // ************************************************************************* //
dictionary dict
TypeName("cuboid")
Runtime type information.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
const word & name() const
Return name.
Definition: rigidBodyI.H:65
scalar m() const
Return the mass of the rigid-body.
virtual ~cuboid()
Destructor.
Definition: cuboid.C:57
const vector & c() const
Return the centre of mass of the rigid-body.
A class for handling words, derived from string.
Definition: word.H:59
Specialisation of rigidBody to construct a cuboid given the mass and lengths of the sides...
Definition: cuboid.H:52
virtual void write(Ostream &) const
Write.
Definition: cuboid.C:63
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
const vector & L() const
Return the lengths of the sides of the cuboid.
Definition: cuboidI.H:80
virtual autoPtr< rigidBody > clone() const
Return clone of this cuboid.
Definition: cuboid.C:49
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
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
Namespace for OpenFOAM.