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 -------------------------------------------------------------------------------
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::codedPoints0MotionSolver
28 
29 Group
30 
31 Description
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 
47 Usage
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 
65 See also
66  Foam::motionSolver
67  Foam::codedBase
68 
69 SourceFiles
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 
82 namespace Foam
83 {
84 /*---------------------------------------------------------------------------*\
85  Class codedPoints0MotionSolver Declaration
86 \*---------------------------------------------------------------------------*/
87 
88 class codedPoints0MotionSolver
89 :
90  public motionSolver,
91  public codedBase
92 {
93 protected:
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;
117 
118  //- Adapt the context for the current object
119  virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
120 
121 
122  //- No copy construct
124 
125  //- No copy assignment
126  void operator=(const codedPoints0MotionSolver&) = delete;
127 
128 
129 public:
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 
145 
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);
176 };
177 
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
184 
185 #endif
186 
187 // ************************************************************************* //
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::dlLibraryTable
A table of dynamically loaded libraries.
Definition: dlLibraryTable.H:63
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::dynamicCode
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:59
motionSolver.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::codedPoints0MotionSolver::movePoints
virtual void movePoints(const pointField &fld)
Update local data for geometry changes.
Definition: codedPoints0MotionSolver.C:175
Foam::codedPoints0MotionSolver::codedPoints0MotionSolver
codedPoints0MotionSolver(const codedPoints0MotionSolver &)=delete
No copy construct.
Foam::codedPoints0MotionSolver::libs
virtual dlLibraryTable & libs() const
Mutable access to the loaded dynamic libraries.
Definition: codedPoints0MotionSolver.C:50
Foam::dynamicCodeContext
Encapsulation of dynamic code dictionaries.
Definition: dynamicCodeContext.H:53
Foam::codedBase
Base class for function objects and boundary conditions using dynamic code that provides methods for ...
Definition: codedBase.H:66
Foam::codedPoints0MotionSolver::operator=
void operator=(const codedPoints0MotionSolver &)=delete
No copy assignment.
Foam::codedPoints0MotionSolver::curPoints
virtual tmp< pointField > curPoints() const
Return point location obtained from the current motion field.
Definition: codedPoints0MotionSolver.C:161
Foam::codedPoints0MotionSolver::updateMesh
virtual void updateMesh(const mapPolyMesh &mpm)
Update local data for topology changes.
Definition: codedPoints0MotionSolver.C:182
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
Foam::codedPoints0MotionSolver::codeTemplateH
static constexpr const char *const codeTemplateH
Name of the H code template to be used.
Definition: codedPoints0MotionSolver.H:158
Foam::codedPoints0MotionSolver::codeDict
virtual const dictionary & codeDict() const
Definition: codedPoints0MotionSolver.C:69
Foam::Field< vector >
Foam::codedPoints0MotionSolver::solve
virtual void solve()
Solve for motion.
Definition: codedPoints0MotionSolver.C:168
Foam::codedPoints0MotionSolver::redirectMotionSolver
motionSolver & redirectMotionSolver() const
Dynamically compiled motionSolver.
Definition: codedPoints0MotionSolver.C:136
Foam::codedPoints0MotionSolver
Provides a general interface to enable dynamic code compilation of mesh motion solvers.
Definition: codedPoints0MotionSolver.H:107
fld
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< ' ';}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< ' ';}gmvFile<< nl;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
Definition: gmvOutputLagrangian.H:23
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::codedPoints0MotionSolver::description
virtual string description() const
Description (type + name) for the output.
Definition: codedPoints0MotionSolver.C:56
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::codedPoints0MotionSolver::prepare
virtual void prepare(dynamicCode &, const dynamicCodeContext &) const
Adapt the context for the current object.
Definition: codedPoints0MotionSolver.C:76
Foam::codedPoints0MotionSolver::clearRedirect
virtual void clearRedirect() const
Clear redirected object(s)
Definition: codedPoints0MotionSolver.C:62
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::motionSolver
Virtual base class for mesh motion solver.
Definition: motionSolver.H:58
Foam::codedPoints0MotionSolver::redirectMotionSolverPtr_
autoPtr< motionSolver > redirectMotionSolverPtr_
Underlying motionSolver.
Definition: codedPoints0MotionSolver.H:120
Foam::codedPoints0MotionSolver::codeTemplateC
static constexpr const char *const codeTemplateC
Name of the C code template to be used.
Definition: codedPoints0MotionSolver.H:154
Foam::codedPoints0MotionSolver::~codedPoints0MotionSolver
virtual ~codedPoints0MotionSolver()=default
Destructor.
Foam::motionSolver::mesh
const polyMesh & mesh() const
Return reference to mesh.
Definition: motionSolver.H:144
Foam::mapPolyMesh
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:161
codedBase.H
Foam::codedPoints0MotionSolver::TypeName
TypeName("coded")
Runtime type information.
Foam::codedPoints0MotionSolver::name_
word name_
Name of redirected motion solver.
Definition: codedPoints0MotionSolver.H:117