codedPoints0MotionSolver.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) 2017-2021 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::codedPoints0MotionSolver
28
29Group
30
31Description
32 Provides a general interface to enable dynamic code compilation of
33 mesh motion solvers.
34
35 The entries are:
36 \plaintable
37 codeInclude | include files
38 codeOptions | compiler line: added to EXE_INC (Make/options)
39 codeLibs | linker line: added to LIB_LIBS (Make/options)
40 localCode | c++; local static functions
41 code | c++; upon motionSolver::curPoints()
42 \endplaintable
43
44 Note that the dynamically generated motionSolver is an points0MotionSolver,
45 i.e. it has access to the points0 (points from constant/polyMesh).
46
47Usage
48 Example of simplistic specification:
49 \verbatim
50 difference
51 {
52 type coded;
53 // Name of on-the-fly generated motion solver
54 name myMotion;
55 code
56 #{
57 const pointField& p0 = points0();
58 const tensor rotT =
59 rotationTensor(vector(1, 0, 0), vector(0, 1, 0));
60 return transform(rotT, p0);
61 #};
62 }
63 \endverbatim
64
65See also
66 Foam::motionSolver
67 Foam::codedBase
68
69SourceFiles
70 codedPoints0MotionSolver.C
71
72\*---------------------------------------------------------------------------*/
73
74#ifndef codedPoints0MotionSolver_H
75#define codedPoints0MotionSolver_H
76
77#include "motionSolver.H"
78#include "codedBase.H"
79
80// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
81
82namespace Foam
83{
84/*---------------------------------------------------------------------------*\
85 Class codedPoints0MotionSolver Declaration
86\*---------------------------------------------------------------------------*/
87
88class codedPoints0MotionSolver
89:
90 public motionSolver,
91 public codedBase
92{
93protected:
94
95 // Protected Data
96
97 //- Name of redirected motion solver
98 word name_;
99
100 //- Underlying motionSolver
101 mutable autoPtr<motionSolver> redirectMotionSolverPtr_;
102
103
104 // Protected Member Functions
105
106 //- Mutable access to the loaded dynamic libraries
107 virtual dlLibraryTable& libs() const;
108
109 //- Description (type + name) for the output
110 virtual string description() const;
111
112 //- Clear redirected object(s)
113 virtual void clearRedirect() const;
114
115 // The dictionary to initialize the codeContext
116 virtual const dictionary& codeDict() const;
118 //- Adapt the context for the current object
119 virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
121
122 //- No copy construct
124
125 //- No copy assignment
126 void operator=(const codedPoints0MotionSolver&) = delete;
127
128
129public:
130
131 // Static Data Members
132
133 //- Name of the C code template to be used
134 static constexpr const char* const codeTemplateC
135 = "codedPoints0MotionSolverTemplate.C";
136
137 //- Name of the H code template to be used
138 static constexpr const char* const codeTemplateH
139 = "codedPoints0MotionSolverTemplate.H";
140
141
142 //- Runtime type information
143 TypeName("coded");
144
146 // Constructors
147
148 //- Construct from mesh and dictionary
150 (
151 const polyMesh& mesh,
152 const IOdictionary& dict
153 );
154
155
156 //- Destructor
157 virtual ~codedPoints0MotionSolver() = default;
158
159
160 // Member Functions
161
162 //- Dynamically compiled motionSolver
164
165 //- Return point location obtained from the current motion field
166 virtual tmp<pointField> curPoints() const;
167
168 //- Solve for motion
169 virtual void solve();
170
171 //- Update local data for geometry changes
172 virtual void movePoints(const pointField& fld);
173
174 //- Update local data for topology changes
175 virtual void updateMesh(const mapPolyMesh& mpm);
177
178
179// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180
181} // End namespace Foam
182
183// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184
185#endif
186
187// ************************************************************************* //
Info<< nl<< "Wrote faMesh in vtk format: "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.mesh().time().globalPath()/"finiteArea-edges"));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
Base class for function objects and boundary conditions using dynamic code that provides methods for ...
Definition: codedBase.H:67
Provides a general interface to enable dynamic code compilation of mesh motion solvers.
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
codedPoints0MotionSolver(const codedPoints0MotionSolver &)=delete
No copy construct.
void operator=(const codedPoints0MotionSolver &)=delete
No copy assignment.
virtual void prepare(dynamicCode &, const dynamicCodeContext &) const
Adapt the context for the current object.
virtual ~codedPoints0MotionSolver()=default
Destructor.
word name_
Name of redirected motion solver.
virtual void movePoints(const pointField &fld)
Update local data for geometry changes.
motionSolver & redirectMotionSolver() const
Dynamically compiled motionSolver.
TypeName("coded")
Runtime type information.
autoPtr< motionSolver > redirectMotionSolverPtr_
Underlying motionSolver.
virtual void updateMesh(const mapPolyMesh &mpm)
Update local data for topology changes.
static constexpr const char *const codeTemplateC
Name of the C code template to be used.
virtual const dictionary & codeDict() const
virtual void clearRedirect() const
Clear redirected object(s)
static constexpr const char *const codeTemplateH
Name of the H code template to be used.
virtual dlLibraryTable & libs() const
Mutable access to the loaded dynamic libraries.
virtual void solve()
Solve for motion.
virtual string description() const
Description (type + name) for the output.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A table of dynamically loaded libraries.
Encapsulation of dynamic code dictionaries.
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:60
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:162
Virtual base class for mesh motion solver.
Definition: motionSolver.H:61
const polyMesh & mesh() const
Return reference to mesh.
Definition: motionSolver.H:144
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:81
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
Namespace for OpenFOAM.
dictionary dict
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition: typeInfo.H:73