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  meshObjects::gravity
64  >,
66 {
67  // Private Typedefs
68 
69  typedef MeshObject
70  <
71  Time,
75 
76 public:
77 
78  //- Run-time type information
79  TypeNameNoDebug("g");
80 
81 
82  // Constructors
83 
84  //- Construct with given name on Time from \c constant (READ_MODIFIED)
85  gravity(const word& name, const Time& runTime);
86 
87  //- Construct "g" field on Time from \c constant (READ_MODIFIED)
88  explicit gravity(const Time& runTime)
89  :
90  gravity("g", runTime)
91  {}
92 
93  //- Return named gravity field cached or construct on Time
94  static const gravity& New(const word& name, const Time& runTime)
95  {
97  }
98 
99  //- Return gravity "g" field cached or construct on Time
100  static const gravity& New(const Time& runTime)
101  {
103  }
104 
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 meshObjects::gravity & New(const Time &mesh, Args &&... args)
Get existing or create 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
TopologicalMeshObject(const word &objName, const objectRegistry &obr)
Construct from name and instance on registry.
Definition: MeshObject.H:284
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:152
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 (READ_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.