sphere.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-2019 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::sphere
26 
27 Description
28  Specialization of rigidBody to construct a sphere given the mass and radius.
29 
30 SourceFiles
31  sphereI.H
32  sphere.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef RBD_sphere_H
37 #define RBD_sphere_H
38 
39 #include "rigidBody.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 namespace RBD
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class sphere Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 class sphere
53 :
54  public rigidBody
55 {
56  // Private member data
57 
58  //- Radius
59  scalar r_;
60 
61 
62  // Private Member Functions
63 
64  // Calculate and return the inertia tensor
65  inline symmTensor I(const scalar m, const scalar r) const;
66 
67 
68 public:
69 
70  //- Runtime type information
71  TypeName("sphere");
72 
73 
74  // Constructors
75 
76  //- Construct from name, mass, centre of mass and radius
77  inline sphere
78  (
79  const word& name,
80  const scalar m,
81  const vector& c,
82  const scalar r
83  );
84 
85  //- Construct from dictionary
86  inline sphere
87  (
88  const word& name,
89  const dictionary& dict
90  );
91 
92  //- Return clone of this sphere
93  virtual autoPtr<rigidBody> clone() const;
94 
95 
96  //- Destructor
97  virtual ~sphere();
98 
99 
100  // Member Functions
101 
102  //- Return the radius of the sphere
103  inline scalar r() const;
104 
105  //- Write
106  virtual void write(Ostream&) const;
107 };
108 
109 
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 
112 } // End namespace RBD
113 } // End namespace Foam
114 
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116 
117 #include "sphereI.H"
118 
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 
121 #endif
122 
123 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
virtual autoPtr< rigidBody > clone() const
Return clone of this sphere.
Definition: sphere.C:49
const word & name() const
Return name.
Definition: rigidBodyI.H:65
scalar m() const
Return the mass of the rigid-body.
TypeName("sphere")
Runtime type information.
virtual void write(Ostream &) const
Write.
Definition: sphere.C:63
scalar r() const
Return the radius of the sphere.
Definition: sphereI.H:70
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
virtual ~sphere()
Destructor.
Definition: sphere.C:57
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
sphere(const word &name, const scalar m, const vector &c, const scalar r)
Construct from name, mass, centre of mass and radius.
Definition: sphereI.H:41
Specialization of rigidBody to construct a sphere given the mass and radius.
Definition: sphere.H:51
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
Namespace for OpenFOAM.