gravityMeshObject.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2018-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::meshObjects::gravity
28 
29 Description
30  Gravitational acceleration vector
31  Although termed a \em MeshObject it is registered on Time only
32  and thus identical for all regions.
33 
34 SourceFiles
35  gravityMeshObject.C
36 
37 \*---------------------------------------------------------------------------*/
38 
39 #ifndef Foam_meshObjects_gravity_H
40 #define Foam_meshObjects_gravity_H
41 
43 #include "MeshObject.H"
44 #include "Time.H"
45 
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
47 
48 namespace Foam
49 {
50 namespace meshObjects
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class gravity Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 class gravity
58 :
59  public MeshObject
60  <
61  Time,
62  TopologicalMeshObject,
63  gravity
64  >,
66 {
67 public:
68 
69  //- Run-time type information
70  TypeNameNoDebug("g");
71 
72 
73  // Constructors
74 
75  //- Construct with given name on Time from \c constant
76  //- (MUST_READ_IF_MODIFIED)
77  gravity(const word& name, const Time& runTime);
78 
79  //- Construct "g" field on Time from \c constant
80  //- (MUST_READ_IF_MODIFIED)
81  explicit gravity(const Time& runTime)
82  :
83  gravity("g", runTime)
84  {}
85 
86  //- Return named gravity field cached or construct on Time
87  static const gravity& New(const word& name, const Time& runTime)
88  {
90  (
91  name,
92  runTime
93  );
94  }
95 
96  //- Return gravity "g" field cached or construct on Time
97  static const gravity& New(const Time& runTime)
98  {
100  (
101  runTime
102  );
103  }
104 
105 
106  //- Destructor
107  virtual ~gravity() = default;
108 
109 
110  // Static Lookups
111 
112  //- Return const pointer to the gravity "g" object field
113  static const uniformDimensionedVectorField*
114  findObject(const Time& runTime)
115  {
116  return runTime.findObject<uniformDimensionedVectorField>("g");
117  }
118 
119  //- Return non-const pointer to the gravity "g" object field
120  //- using a const-cast to have it behave like a mutable.
122  getObjectPtr(const Time& runTime)
123  {
124  return runTime.getObjectPtr<uniformDimensionedVectorField>("g");
125  }
126 
127  //- Lookup and return const reference to the gravity "g" object field
128  static const uniformDimensionedVectorField&
129  lookupObject(const Time& runTime)
130  {
131  return runTime.lookupObject<uniformDimensionedVectorField>("g");
132  }
133 };
134 
135 
136 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137 
138 } // End namespace meshObjects
139 } // End namespace Foam
140 
141 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143 #endif
144 
145 // ************************************************************************* //
Gravitational acceleration vector Although termed a MeshObject it is registered on Time only and thus...
static const Type & New(const Mesh &mesh, Args &&... args)
Get existing or create a new MeshObject. Registered with typeName.
Definition: MeshObject.C:53
Various UniformDimensionedField types.
engineTime & runTime
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:69
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:85
virtual ~gravity()=default
Destructor.
A class for handling words, derived from Foam::string.
Definition: word.H:63
gravity(const word &name, const Time &runTime)
Construct with given name on Time from constant (MUST_READ_IF_MODIFIED)
static uniformDimensionedVectorField * getObjectPtr(const Time &runTime)
Return non-const pointer to the gravity "g" object field using a const-cast to have it behave like a ...
TypeNameNoDebug("g")
Run-time type information.
static const gravity & New(const word &name, const Time &runTime)
Return named gravity field cached or construct on Time.
static const uniformDimensionedVectorField * findObject(const Time &runTime)
Return const pointer to the gravity "g" object field.
virtual const word & name() const
Use name from dimensioned<Type>, not from regIOobject.
static const uniformDimensionedVectorField & lookupObject(const Time &runTime)
Lookup and return const reference to the gravity "g" object field.
Namespace for OpenFOAM.