ENH: codedMotionSolver: motion solver with user-supplied coding
This commit is contained in:
parent
5474d161f2
commit
977a9894b4
115
etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.C
Normal file
115
etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.C
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) YEAR AUTHOR,AFFILIATION
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "codedPoints0MotionSolverTemplate.H"
|
||||||
|
#include "fvCFD.H"
|
||||||
|
#include "unitConversion.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
defineTypeNameAndDebug(${typeName}Points0MotionSolver, 0);
|
||||||
|
|
||||||
|
addRemovableToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
motionSolver,
|
||||||
|
${typeName}Points0MotionSolver,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
// dynamicCode:
|
||||||
|
// SHA1 = ${SHA1sum}
|
||||||
|
//
|
||||||
|
// unique function name that can be checked if the correct library version
|
||||||
|
// has been loaded
|
||||||
|
void ${typeName}_${SHA1sum}(bool load)
|
||||||
|
{
|
||||||
|
if (load)
|
||||||
|
{
|
||||||
|
// code that can be explicitly executed after loading
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// code that can be explicitly executed before unloading
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//{{{ begin localCode
|
||||||
|
${localCode}
|
||||||
|
//}}} end localCode
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
${typeName}Points0MotionSolver::${typeName}Points0MotionSolver
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const IOdictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
points0MotionSolver(mesh, dict, "${typeName}")
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
${typeName}Points0MotionSolver::~${typeName}Points0MotionSolver()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
tmp<pointField> ${typeName}Points0MotionSolver::curPoints() const
|
||||||
|
{
|
||||||
|
if (${verbose:-false})
|
||||||
|
{
|
||||||
|
Info<<"curPoints ${typeName} sha1: ${SHA1sum}\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
//{{{ begin code
|
||||||
|
${code}
|
||||||
|
//}}} end code
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
103
etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.H
Normal file
103
etc/codeTemplates/dynamicCode/codedPoints0MotionSolverTemplate.H
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) YEAR AUTHOR,AFFILIATION
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Description
|
||||||
|
Template for use with dynamic code generation of a
|
||||||
|
points0MotionSolver.
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
codedPoints0MotionSolverTemplate.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef codedPoints0MotionSolverTemplate_H
|
||||||
|
#define codedPoints0MotionSolverTemplate_H
|
||||||
|
|
||||||
|
#include "points0MotionSolver.H"
|
||||||
|
|
||||||
|
//{{{ begin codeInclude
|
||||||
|
${codeInclude}
|
||||||
|
//}}} end codeInclude
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
A templated codedPoints0MotionSolver
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class ${typeName}Points0MotionSolver
|
||||||
|
:
|
||||||
|
public points0MotionSolver
|
||||||
|
{
|
||||||
|
// Private Member Functions
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
${typeName}Points0MotionSolver(const ${typeName}Points0MotionSolver&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const ${typeName}Points0MotionSolver&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("${typeName}");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from mesh and dictionary
|
||||||
|
${typeName}Points0MotionSolver
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const IOdictionary&
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~${typeName}Points0MotionSolver();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Provide current points for motion. Uses current motion field
|
||||||
|
virtual tmp<pointField> curPoints() const;
|
||||||
|
|
||||||
|
//- Solve for motion
|
||||||
|
virtual void solve()
|
||||||
|
{};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
@ -112,6 +112,7 @@ motionSolvers/velocity/velocityDisplacement/velocityDisplacementMotionSolver.C
|
|||||||
motionSolvers/componentVelocity/componentVelocityMotionSolver.C
|
motionSolvers/componentVelocity/componentVelocityMotionSolver.C
|
||||||
motionSolvers/displacement/solidBody/solidBodyMotionSolver.C
|
motionSolvers/displacement/solidBody/solidBodyMotionSolver.C
|
||||||
motionSolvers/displacement/solidBody/multiSolidBodyMotionSolver.C
|
motionSolvers/displacement/solidBody/multiSolidBodyMotionSolver.C
|
||||||
|
motionSolvers/displacement/codedPoints0/codedPoints0MotionSolver.C
|
||||||
|
|
||||||
solidBodyMotionFunctions = motionSolvers/displacement/solidBody/solidBodyMotionFunctions
|
solidBodyMotionFunctions = motionSolvers/displacement/solidBody/solidBodyMotionFunctions
|
||||||
$(solidBodyMotionFunctions)/solidBodyMotionFunction/solidBodyMotionFunction.C
|
$(solidBodyMotionFunctions)/solidBodyMotionFunction/solidBodyMotionFunction.C
|
||||||
|
@ -0,0 +1,199 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#include "codedPoints0MotionSolver.H"
|
||||||
|
#include "dictionary.H"
|
||||||
|
#include "Time.H"
|
||||||
|
#include "SHA1Digest.H"
|
||||||
|
#include "dynamicCode.H"
|
||||||
|
#include "dynamicCodeContext.H"
|
||||||
|
#include "stringOps.H"
|
||||||
|
#include "addToRunTimeSelectionTable.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
defineTypeNameAndDebug(codedPoints0MotionSolver, 0);
|
||||||
|
|
||||||
|
addToRunTimeSelectionTable
|
||||||
|
(
|
||||||
|
motionSolver,
|
||||||
|
codedPoints0MotionSolver,
|
||||||
|
dictionary
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void Foam::codedPoints0MotionSolver::prepare
|
||||||
|
(
|
||||||
|
dynamicCode& dynCode,
|
||||||
|
const dynamicCodeContext& context
|
||||||
|
) const
|
||||||
|
{
|
||||||
|
// Set additional rewrite rules
|
||||||
|
dynCode.setFilterVariable("typeName", name_);
|
||||||
|
|
||||||
|
// Compile filtered C template
|
||||||
|
dynCode.addCompileFile("codedPoints0MotionSolverTemplate.C");
|
||||||
|
|
||||||
|
// Copy filtered H template
|
||||||
|
dynCode.addCopyFile("codedPoints0MotionSolverTemplate.H");
|
||||||
|
|
||||||
|
// Debugging: make BC verbose
|
||||||
|
// dynCode.setFilterVariable("verbose", "true");
|
||||||
|
// Info<<"compile " << name_ << " sha1: "
|
||||||
|
// << context.sha1() << endl;
|
||||||
|
|
||||||
|
// Define Make/options
|
||||||
|
dynCode.setMakeOptions
|
||||||
|
(
|
||||||
|
"EXE_INC = -g \\\n"
|
||||||
|
"-I$(LIB_SRC)/finiteVolume/lnInclude \\\n"
|
||||||
|
"-I$(LIB_SRC)/fvMotionSolvers/lnInclude \\\n"
|
||||||
|
"-I$(LIB_SRC)/dynamicMesh/lnInclude \\\n"
|
||||||
|
"-I$(LIB_SRC)/meshTools/lnInclude \\\n"
|
||||||
|
+ context.options()
|
||||||
|
+ "\n\nLIB_LIBS = \\\n"
|
||||||
|
+ " -lfvMotionSolvers \\\n"
|
||||||
|
+ context.libs()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::dlLibraryTable& Foam::codedPoints0MotionSolver::libs() const
|
||||||
|
{
|
||||||
|
return const_cast<Time&>(mesh().time()).libs();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::string Foam::codedPoints0MotionSolver::description() const
|
||||||
|
{
|
||||||
|
return "points0MotionSolver " + name();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::codedPoints0MotionSolver::clearRedirect() const
|
||||||
|
{
|
||||||
|
redirectMotionSolverPtr_.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const Foam::dictionary&
|
||||||
|
Foam::codedPoints0MotionSolver::codeDict() const
|
||||||
|
{
|
||||||
|
return coeffDict();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::codedPoints0MotionSolver::codedPoints0MotionSolver
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const IOdictionary& dict
|
||||||
|
)
|
||||||
|
:
|
||||||
|
motionSolver(mesh, dict, typeName),
|
||||||
|
codedBase()
|
||||||
|
{
|
||||||
|
// Backward compatibility
|
||||||
|
if (dict.found("redirectType"))
|
||||||
|
{
|
||||||
|
dict.lookup("redirectType") >> name_;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dict.lookup("name") >> name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateLibrary(name_);
|
||||||
|
redirectMotionSolver();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::codedPoints0MotionSolver::~codedPoints0MotionSolver()
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
Foam::motionSolver&
|
||||||
|
Foam::codedPoints0MotionSolver::redirectMotionSolver() const
|
||||||
|
{
|
||||||
|
if (!redirectMotionSolverPtr_.valid())
|
||||||
|
{
|
||||||
|
// Get the dictionary for the solver and override the
|
||||||
|
// solver name (in case it is not a subdictionary and contains
|
||||||
|
// the 'coded' as the motionSolver)
|
||||||
|
dictionary constructDict(coeffDict());
|
||||||
|
constructDict.set("solver", name_);
|
||||||
|
constructDict.set("motionSolver", name_);
|
||||||
|
|
||||||
|
IOobject io(*this);
|
||||||
|
io.readOpt() = IOobject::NO_READ;
|
||||||
|
|
||||||
|
redirectMotionSolverPtr_ = motionSolver::New
|
||||||
|
(
|
||||||
|
mesh(),
|
||||||
|
IOdictionary(io, constructDict)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return redirectMotionSolverPtr_();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Foam::tmp<Foam::pointField> Foam::codedPoints0MotionSolver::curPoints() const
|
||||||
|
{
|
||||||
|
updateLibrary(name_);
|
||||||
|
return redirectMotionSolver().curPoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::codedPoints0MotionSolver::solve()
|
||||||
|
{
|
||||||
|
updateLibrary(name_);
|
||||||
|
redirectMotionSolver().solve();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::codedPoints0MotionSolver::movePoints(const pointField& fld)
|
||||||
|
{
|
||||||
|
updateLibrary(name_);
|
||||||
|
return redirectMotionSolver().movePoints(fld);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Foam::codedPoints0MotionSolver::updateMesh(const mapPolyMesh& mpm)
|
||||||
|
{
|
||||||
|
updateLibrary(name_);
|
||||||
|
return redirectMotionSolver().updateMesh(mpm);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
@ -0,0 +1,176 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | Copyright (C) 2017 OpenCFD Ltd.
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM.
|
||||||
|
|
||||||
|
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||||
|
under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||||
|
for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Class
|
||||||
|
Foam::codedPoints0MotionSolver
|
||||||
|
|
||||||
|
Group
|
||||||
|
|
||||||
|
Description
|
||||||
|
Provides a general interface to enable dynamic code compilation of
|
||||||
|
mesh motion solvers.
|
||||||
|
|
||||||
|
The entries are:
|
||||||
|
\plaintable
|
||||||
|
codeInclude | include files
|
||||||
|
codeOptions | include paths; inserted into EXE_INC in Make/options
|
||||||
|
codeLibs | link line; inserted into LIB_LIBS in Make/options
|
||||||
|
localCode | c++; local static functions;
|
||||||
|
code | c++; upon motionSolver::curPoints();
|
||||||
|
\endplaintable
|
||||||
|
|
||||||
|
Note that the dynamically generated motionSolver is an points0MotionSolver,
|
||||||
|
i.e. it has access to the points0 (points from constant/polyMesh).
|
||||||
|
|
||||||
|
Usage
|
||||||
|
Example of simplistic specification:
|
||||||
|
\verbatim
|
||||||
|
difference
|
||||||
|
{
|
||||||
|
type coded;
|
||||||
|
// Name of on-the-fly generated motion solver
|
||||||
|
name myMotion;
|
||||||
|
code
|
||||||
|
#{
|
||||||
|
const pointField& p0 = points0();
|
||||||
|
const tensor rotT =
|
||||||
|
rotationTensor(vector(1, 0, 0), vector(0, 1, 0));
|
||||||
|
return transform(rotT, p0);
|
||||||
|
#};
|
||||||
|
}
|
||||||
|
\endverbatim
|
||||||
|
|
||||||
|
See also
|
||||||
|
Foam::motionSolver
|
||||||
|
Foam::codedBase
|
||||||
|
|
||||||
|
SourceFiles
|
||||||
|
codedPoints0MotionSolver.C
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifndef codedPoints0MotionSolver_H
|
||||||
|
#define codedPoints0MotionSolver_H
|
||||||
|
|
||||||
|
#include "motionSolver.H"
|
||||||
|
#include "codedBase.H"
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
namespace Foam
|
||||||
|
{
|
||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
Class codedPoints0MotionSolver Declaration
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
class codedPoints0MotionSolver
|
||||||
|
:
|
||||||
|
public motionSolver,
|
||||||
|
public codedBase
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
// Protected data
|
||||||
|
|
||||||
|
//- Name of redirected motion solver
|
||||||
|
word name_;
|
||||||
|
|
||||||
|
//- Underlying motionSolver
|
||||||
|
mutable autoPtr<motionSolver> redirectMotionSolverPtr_;
|
||||||
|
|
||||||
|
|
||||||
|
// Protected Member Functions
|
||||||
|
|
||||||
|
//- Get the loaded dynamic libraries
|
||||||
|
virtual dlLibraryTable& libs() const;
|
||||||
|
|
||||||
|
//- Adapt the context for the current object
|
||||||
|
virtual void prepare(dynamicCode&, const dynamicCodeContext&) const;
|
||||||
|
|
||||||
|
// Return a description (type + name) for the output
|
||||||
|
virtual string description() const;
|
||||||
|
|
||||||
|
// Clear any redirected objects
|
||||||
|
virtual void clearRedirect() const;
|
||||||
|
|
||||||
|
// Get the dictionary to initialize the codeContext
|
||||||
|
virtual const dictionary& codeDict() const;
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
|
||||||
|
//- Disallow default bitwise copy construct
|
||||||
|
codedPoints0MotionSolver(const codedPoints0MotionSolver&);
|
||||||
|
|
||||||
|
//- Disallow default bitwise assignment
|
||||||
|
void operator=(const codedPoints0MotionSolver&);
|
||||||
|
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
//- Runtime type information
|
||||||
|
TypeName("coded");
|
||||||
|
|
||||||
|
|
||||||
|
// Constructors
|
||||||
|
|
||||||
|
//- Construct from mesh and dictionary
|
||||||
|
codedPoints0MotionSolver
|
||||||
|
(
|
||||||
|
const polyMesh& mesh,
|
||||||
|
const IOdictionary& dict
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
//- Destructor
|
||||||
|
virtual ~codedPoints0MotionSolver();
|
||||||
|
|
||||||
|
|
||||||
|
// Member Functions
|
||||||
|
|
||||||
|
//- Dynamically compiled motionSolver
|
||||||
|
motionSolver& redirectMotionSolver() const;
|
||||||
|
|
||||||
|
//- Return point location obtained from the current motion field
|
||||||
|
virtual tmp<pointField> curPoints() const;
|
||||||
|
|
||||||
|
//- Solve for motion
|
||||||
|
virtual void solve();
|
||||||
|
|
||||||
|
//- Update local data for geometry changes
|
||||||
|
virtual void movePoints(const pointField&);
|
||||||
|
|
||||||
|
//- Update local data for topology changes
|
||||||
|
virtual void updateMesh(const mapPolyMesh&);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
} // End namespace Foam
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
@ -0,0 +1,77 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: plus |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
location "system";
|
||||||
|
object dynamicMeshDict;
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
dynamicFvMesh dynamicMotionSolverFvMesh;
|
||||||
|
|
||||||
|
motionSolver coded;
|
||||||
|
name myMotion;
|
||||||
|
|
||||||
|
codeInclude
|
||||||
|
#{
|
||||||
|
#include "transformField.H"
|
||||||
|
#};
|
||||||
|
|
||||||
|
localCode
|
||||||
|
#{
|
||||||
|
// Generate new set of points
|
||||||
|
tmp<pointField> twistColumn
|
||||||
|
(
|
||||||
|
const scalar& maxRotAngle,
|
||||||
|
const pointField& points
|
||||||
|
)
|
||||||
|
{
|
||||||
|
tmp<pointField> tnewPoints(new pointField(points));
|
||||||
|
pointField& newPoints = tnewPoints.ref();
|
||||||
|
|
||||||
|
const boundBox bb(points, true);
|
||||||
|
const scalar zMin = bb.min()[vector::Z];
|
||||||
|
const scalar zSpan = bb.span()[vector::Z];
|
||||||
|
|
||||||
|
forAll(points, pointI)
|
||||||
|
{
|
||||||
|
const scalar x = points[pointI].component(0);
|
||||||
|
const scalar y = points[pointI].component(1);
|
||||||
|
const scalar z = points[pointI].component(2);
|
||||||
|
|
||||||
|
// Scale the angle by height
|
||||||
|
const scalar localAngle = maxRotAngle*(z-zMin)/zSpan;
|
||||||
|
|
||||||
|
const scalar xr = x*cos(localAngle)-y*sin(localAngle);
|
||||||
|
const scalar yr = x*sin(localAngle)+y*cos(localAngle);
|
||||||
|
newPoints[pointI] = vector(xr, yr, z);
|
||||||
|
}
|
||||||
|
return tnewPoints;
|
||||||
|
}
|
||||||
|
#};
|
||||||
|
|
||||||
|
code
|
||||||
|
#{
|
||||||
|
const Time& tm = mesh().time();
|
||||||
|
const pointField& p0 = points0();
|
||||||
|
|
||||||
|
// Max twist pi at t=10
|
||||||
|
const scalar maxRotAngle =
|
||||||
|
constant::mathematical::pi*Foam::sin(degToRad(90.0/10.0*tm.value()));
|
||||||
|
|
||||||
|
tmp<pointField> tnewPoints(twistColumn(maxRotAngle, p0));
|
||||||
|
|
||||||
|
return tnewPoints;
|
||||||
|
#};
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
@ -0,0 +1,21 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: plus |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object transportProperties;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
transportModel Newtonian;
|
||||||
|
|
||||||
|
nu 1.5e-05;
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
@ -0,0 +1,72 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: plus |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object blockMeshDict;
|
||||||
|
}
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
scale 1;
|
||||||
|
|
||||||
|
vertices
|
||||||
|
(
|
||||||
|
(-0.5 -0.5 0)
|
||||||
|
(0.5 -0.5 0)
|
||||||
|
(0.5 0.5 0)
|
||||||
|
(-0.5 0.5 0)
|
||||||
|
(-0.5 -0.5 8)
|
||||||
|
(0.5 -0.5 8)
|
||||||
|
(0.5 0.5 8)
|
||||||
|
(-0.5 0.5 8)
|
||||||
|
);
|
||||||
|
|
||||||
|
blocks
|
||||||
|
(
|
||||||
|
hex (0 1 2 3 4 5 6 7) (2 2 8) simpleGrading (1 1 1)
|
||||||
|
);
|
||||||
|
|
||||||
|
edges
|
||||||
|
(
|
||||||
|
);
|
||||||
|
|
||||||
|
boundary
|
||||||
|
(
|
||||||
|
sides
|
||||||
|
{
|
||||||
|
type patch;
|
||||||
|
faces
|
||||||
|
(
|
||||||
|
(2 6 5 1)
|
||||||
|
(0 4 7 3)
|
||||||
|
(3 7 6 2)
|
||||||
|
(1 5 4 0)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
floor
|
||||||
|
{
|
||||||
|
type wall;
|
||||||
|
faces
|
||||||
|
(
|
||||||
|
(0 3 2 1)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
top
|
||||||
|
{
|
||||||
|
type patch;
|
||||||
|
faces
|
||||||
|
(
|
||||||
|
(4 5 6 7)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
@ -0,0 +1,48 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: plus |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
object controlDict;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
application moveDynamicMesh;
|
||||||
|
|
||||||
|
startFrom startTime;
|
||||||
|
|
||||||
|
startTime 0;
|
||||||
|
|
||||||
|
stopAt endTime;
|
||||||
|
|
||||||
|
endTime 40;
|
||||||
|
|
||||||
|
deltaT 1;
|
||||||
|
|
||||||
|
writeControl timeStep;
|
||||||
|
|
||||||
|
writeInterval 1;
|
||||||
|
|
||||||
|
purgeWrite 0;
|
||||||
|
|
||||||
|
writeFormat binary;
|
||||||
|
|
||||||
|
writePrecision 6;
|
||||||
|
|
||||||
|
writeCompression off;
|
||||||
|
|
||||||
|
timeFormat general;
|
||||||
|
|
||||||
|
timePrecision 6;
|
||||||
|
|
||||||
|
runTimeModifiable true;
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
@ -0,0 +1,24 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: plus |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
note "mesh decomposition control dictionary";
|
||||||
|
object decomposeParDict;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
//- The total number of domains (mandatory)
|
||||||
|
numberOfSubdomains 3;
|
||||||
|
|
||||||
|
//- The decomposition method (mandatory)
|
||||||
|
method random;
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
@ -0,0 +1,50 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: plus |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
location "system";
|
||||||
|
object fvSchemes;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
ddtSchemes
|
||||||
|
{
|
||||||
|
default Euler;
|
||||||
|
}
|
||||||
|
|
||||||
|
gradSchemes
|
||||||
|
{
|
||||||
|
default Gauss linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
divSchemes
|
||||||
|
{
|
||||||
|
default none;
|
||||||
|
div(phi,U) Gauss linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
laplacianSchemes
|
||||||
|
{
|
||||||
|
default Gauss linear corrected;
|
||||||
|
}
|
||||||
|
|
||||||
|
interpolationSchemes
|
||||||
|
{
|
||||||
|
default linear;
|
||||||
|
}
|
||||||
|
|
||||||
|
snGradSchemes
|
||||||
|
{
|
||||||
|
default corrected;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
@ -0,0 +1,56 @@
|
|||||||
|
/*--------------------------------*- C++ -*----------------------------------*\
|
||||||
|
| ========= | |
|
||||||
|
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||||
|
| \\ / O peration | Version: plus |
|
||||||
|
| \\ / A nd | Web: www.OpenFOAM.com |
|
||||||
|
| \\/ M anipulation | |
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
FoamFile
|
||||||
|
{
|
||||||
|
version 2.0;
|
||||||
|
format ascii;
|
||||||
|
class dictionary;
|
||||||
|
location "system";
|
||||||
|
object fvSolution;
|
||||||
|
}
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
solvers
|
||||||
|
{
|
||||||
|
p
|
||||||
|
{
|
||||||
|
solver PCG;
|
||||||
|
preconditioner DIC;
|
||||||
|
tolerance 1e-06;
|
||||||
|
relTol 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
U
|
||||||
|
{
|
||||||
|
solver PBiCGStab;
|
||||||
|
preconditioner DILU;
|
||||||
|
tolerance 1e-05;
|
||||||
|
relTol 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
"cellDisplacement.*"
|
||||||
|
{
|
||||||
|
solver GAMG;
|
||||||
|
tolerance 1e-08;
|
||||||
|
relTol 0;
|
||||||
|
smoother GaussSeidel;
|
||||||
|
}
|
||||||
|
|
||||||
|
"(cellMotionU|cellMotionUz)"
|
||||||
|
{
|
||||||
|
$p;
|
||||||
|
tolerance 1e-08;
|
||||||
|
relTol 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PIMPLE
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
Loading…
Reference in New Issue
Block a user