codedPoints0MotionSolver.C
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-2020 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 \*---------------------------------------------------------------------------*/
27 
29 #include "dictionary.H"
30 #include "Time.H"
31 #include "dynamicCode.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(codedPoints0MotionSolver, 0);
39 
41  (
42  motionSolver,
43  codedPoints0MotionSolver,
44  dictionary
45  );
46 }
47 
48 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
49 
51 (
52  dynamicCode& dynCode,
53  const dynamicCodeContext& context
54 ) const
55 {
56  // Set additional rewrite rules
57  dynCode.setFilterVariable("typeName", name_);
58 
59  // Compile filtered C template
60  dynCode.addCompileFile(codeTemplateC);
61 
62  // Copy filtered H template
63  dynCode.addCopyFile(codeTemplateH);
64 
65  // Debugging: make verbose
66  // dynCode.setFilterVariable("verbose", "true");
67  // DetailInfo
68  // <<"compile " << name_ << " sha1: "
69  // << context.sha1() << endl;
70 
71  // Define Make/options
72  dynCode.setMakeOptions
73  (
74  "EXE_INC = -g \\\n"
75  "-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
76  "-I$(LIB_SRC)/meshTools/lnInclude \\\n"
77  "-I$(LIB_SRC)/dynamicMesh/lnInclude \\\n"
78  "-I$(LIB_SRC)/fvMotionSolvers/lnInclude \\\n"
79  + context.options()
80  + "\n\nLIB_LIBS = \\\n"
81  " -lfiniteVolume \\\n"
82  " -lmeshTools \\\n"
83  " -ldynamicMesh \\\n"
84  " -lfvMotionSolvers \\\n"
85  + context.libs()
86  );
87 }
88 
89 
91 {
92  return mesh().time().libs();
93 }
94 
95 
97 {
98  return "points0MotionSolver " + name();
99 }
100 
101 
103 {
104  redirectMotionSolverPtr_.clear();
105 }
106 
107 
108 const Foam::dictionary&
110 {
111  return coeffDict();
112 }
113 
114 
115 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
116 
118 (
119  const polyMesh& mesh,
120  const IOdictionary& dict
121 )
122 :
123  motionSolver(mesh, dict, typeName),
124  codedBase()
125 {
126  dict.readCompat<word>("name", {{"redirectType", 1706}}, name_);
127 
128  updateLibrary(name_);
129  redirectMotionSolver();
130 }
131 
132 
133 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
134 
137 {
138  if (!redirectMotionSolverPtr_)
139  {
140  // Get the dictionary for the solver and override the
141  // solver name (in case it is not a subdictionary and contains
142  // the 'coded' as the motionSolver)
143  dictionary constructDict(coeffDict());
144  constructDict.set("solver", name_);
145  constructDict.set("motionSolver", name_);
146 
147  IOobject io(*this);
148  io.readOpt() = IOobject::NO_READ;
149 
150  redirectMotionSolverPtr_ = motionSolver::New
151  (
152  mesh(),
153  IOdictionary(io, constructDict)
154  );
155  }
156 
157  return *redirectMotionSolverPtr_;
158 }
159 
160 
162 {
163  updateLibrary(name_);
164  return redirectMotionSolver().curPoints();
165 }
166 
167 
169 {
170  updateLibrary(name_);
171  redirectMotionSolver().solve();
172 }
173 
174 
176 {
177  updateLibrary(name_);
178  return redirectMotionSolver().movePoints(fld);
179 }
180 
181 
183 {
184  updateLibrary(name_);
185  return redirectMotionSolver().updateMesh(mpm);
186 }
187 
188 
189 // ************************************************************************* //
Foam::dynamicCodeContext::libs
const string & libs() const
Return the code-libs.
Definition: dynamicCodeContext.H:146
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::motionSolver::New
static autoPtr< motionSolver > New(const polyMesh &)
Select constructed from polyMesh.
Definition: motionSolver.C:150
Foam::IOdictionary
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:54
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
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:62
Foam::dynamicCode
Tools for handling dynamic code compilation.
Definition: dynamicCode.H:59
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:90
Foam::dynamicCodeContext
Encapsulation of dynamic code dictionaries.
Definition: dynamicCodeContext.H:53
Foam::objectRegistry::time
const Time & time() const
Return time.
Definition: objectRegistry.H:186
Foam::codedBase
Base class for function objects and boundary conditions using dynamic code that provides methods for ...
Definition: codedBase.H:67
Foam::string
A class for handling character strings derived from std::string.
Definition: string.H:73
Foam::dictionary::set
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
Definition: dictionary.C:847
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::dynamicCode::addCopyFile
void addCopyFile(const fileName &name)
Add a file template name, which will be found and filtered.
Definition: dynamicCode.C:357
Foam::dynamicCode::addCompileFile
void addCompileFile(const fileName &name)
Add a file template name, which will be found and filtered.
Definition: dynamicCode.C:351
Foam::codedPoints0MotionSolver::codeDict
virtual const dictionary & codeDict() const
Definition: codedPoints0MotionSolver.C:109
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::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
dynamicCode.H
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:121
Foam::Time::libs
dlLibraryTable & libs() const
Mutable access to the loaded dynamic libraries.
Definition: Time.H:505
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::dynamicCodeContext::options
const string & options() const
Return the code-options.
Definition: dynamicCodeContext.H:140
Foam::codedPoints0MotionSolver::description
virtual string description() const
Return a description (type + name) for the output.
Definition: codedPoints0MotionSolver.C:96
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::dynamicCode::setFilterVariable
void setFilterVariable(const word &key, const std::string &value)
Define a filter variable.
Definition: dynamicCode.C:386
Foam::codedPoints0MotionSolver::prepare
virtual void prepare(dynamicCode &, const dynamicCodeContext &) const
Adapt the context for the current object.
Definition: codedPoints0MotionSolver.C:51
Foam::codedPoints0MotionSolver::clearRedirect
virtual void clearRedirect() const
Clear any redirected objects.
Definition: codedPoints0MotionSolver.C:102
Time.H
Foam::dynamicCode::setMakeOptions
void setMakeOptions(const std::string &content)
Define contents for Make/options.
Definition: dynamicCode.C:395
Foam::motionSolver
Virtual base class for mesh motion solver.
Definition: motionSolver.H:58
Foam::IOobject::readOpt
readOption readOpt() const
The read option.
Definition: IOobjectI.H:165
Foam::dictionary::readCompat
bool readCompat(const word &keyword, std::initializer_list< std::pair< const char *, int >> compat, T &val, enum keyType::option=keyType::REGEX, bool mandatory=true) const
Definition: dictionaryTemplates.C:384
dictionary.H
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
codedPoints0MotionSolver.H
Foam::IOobject::NO_READ
Definition: IOobject.H:123
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)