Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
10License
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
26Class
27 Foam::meshObjects::gravity
28
29Description
30 Gravitational acceleration vector
31 Although termed a \em MeshObject it is registered on Time only
32 and thus identical for all regions.
33
34SourceFiles
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
48namespace Foam
49{
50namespace meshObjects
51{
53/*---------------------------------------------------------------------------*\
54 Class gravity Declaration
55\*---------------------------------------------------------------------------*/
56
57class 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,
74 > MeshObject_type;
75
76public:
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
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.
124 return runTime.getObjectPtr<uniformDimensionedVectorField>("g");
125 }
126
127 //- Lookup and return const reference to the gravity "g" object field
130 {
131 return runTime.lookupObject<uniformDimensionedVectorField>("g");
132 }
134
135
136// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
137
138} // End namespace meshObjects
139} // End namespace Foam
140
141// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
143#endif
144
145// ************************************************************************* //
static FOAM_NO_DANGLING_REFERENCE const meshObjects::gravity & New(const Time &mesh, Args &&... args)
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition Time.H:75
TopologicalMeshObject(const word &objName, const objectRegistry &obr)
Construct from name and instance on registry.
Definition MeshObject.H:286
Gravitational acceleration vector Although termed a MeshObject it is registered on Time only and thus...
static const uniformDimensionedVectorField & lookupObject(const Time &runTime)
Lookup and return const reference to the gravity "g" object field.
static const uniformDimensionedVectorField * findObject(const Time &runTime)
Return const pointer to the gravity "g" object field.
static const gravity & New(const word &name, const Time &runTime)
Return named gravity field cached or construct on Time.
static const gravity & New(const Time &runTime)
Return gravity "g" field cached or construct on Time.
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.
virtual ~gravity()=default
Destructor.
gravity(const Time &runTime)
Construct "g" field on Time from constant (READ_MODIFIED).
gravity(const word &name, const Time &runTime)
Construct with given name on Time from constant (READ_MODIFIED).
A class for handling words, derived from Foam::string.
Definition word.H:66
engineTime & runTime
Namespace for OpenFOAM.
UniformDimensionedField< vector > uniformDimensionedVectorField
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition exprTraits.C:127
#define TypeNameNoDebug(TypeNameString)
Declare a ClassNameNoDebug() with extra virtual type info.
Definition typeInfo.H:61
Various UniformDimensionedField types.