displacementMethod.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) 2007-2019 PCOpt/NTUA
9 Copyright (C) 2013-2019 FOSS GP
10 Copyright (C) 2019-2021 OpenCFD Ltd.
11-------------------------------------------------------------------------------
12License
13 This file is part of OpenFOAM.
14
15 OpenFOAM is free software: you can redistribute it and/or modify it
16 under the terms of the GNU General Public License as published by
17 the Free Software Foundation, either version 3 of the License, or
18 (at your option) any later version.
19
20 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 for more details.
24
25 You should have received a copy of the GNU General Public License
26 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27
28\*---------------------------------------------------------------------------*/
29
30#include "displacementMethod.H"
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace Foam
35{
38}
39
40
41// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42
44(
45 fvMesh& mesh,
46 const labelList& patchIDs
47)
48:
49 mesh_(mesh),
50 patchIDs_(patchIDs),
51 motionPtr_(motionSolver::New(mesh_)),
52 maxDisplacement_(SMALL)
53{}
54
55
56// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
57
59(
60 fvMesh& mesh,
61 const labelList& patchIDs
62)
63{
64 // To ensure that displacement method has the same
65 // type as the motion solver, construct it based on its name
66 IOdictionary dynamicMeshDict
67 (
69 (
70 "dynamicMeshDict",
71 mesh.time().constant(),
72 mesh,
75 false
76 )
77 );
78 word solverType(dynamicMeshDict.get<word>("solver"));
79
80 Info<< "displacementMethod type : " << solverType << endl;
81
82 auto* ctorPtr = dictionaryConstructorTable(solverType);
83
84 if (!ctorPtr)
85 {
87 (
88 dynamicMeshDict,
89 "solver",
90 solverType,
91 *dictionaryConstructorTablePtr_
92 ) << exit(FatalIOError);
93 }
94 return autoPtr<displacementMethod>(ctorPtr(mesh, patchIDs));
95}
96
97
98// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * //
99
101{
102 // Does nothing in base
103}
104
105
107{
108 return motionPtr_;
109}
110
111
113{
114 return maxDisplacement_;
115}
116
117
119{
120 scalar timeBef = mesh_.time().elapsedCpuTime();
121
122 // Compute max mesh movement
123 tmp<pointField> tnewPoints = motionPtr_->newPoints();
124 Info<< "Max mesh movement magnitude "
125 << gMax(mag(tnewPoints() - mesh_.points())) << endl;
126
127 // Update mesh as in dynamicFvMesh
128 mesh_.movePoints(tnewPoints());
129 scalar timeAft = mesh_.time().elapsedCpuTime();
130 Info<< "Mesh movement took " << timeAft - timeBef << " seconds" << endl;
131 if (!mesh_.steady())
132 {
133 mesh_.moving(false);
134 }
135}
136
137
138// ************************************************************************* //
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:57
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: autoPtr.H:66
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Abstract base class for displacement methods, which are a set or wrapper classes allowing to change t...
autoPtr< motionSolver > & getMotionSolver()
Get access to motionSolver.
virtual void boundControlField(vectorField &controlField)
scalar getMaxDisplacement() const
Get max displacement.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:290
Virtual base class for mesh motion solver.
Definition: motionSolver.H:61
A class for managing temporary objects.
Definition: tmp.H:65
A class for handling words, derived from Foam::string.
Definition: word.H:68
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
Namespace for OpenFOAM.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
IOerror FatalIOError
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Type gMax(const FieldField< Field, Type > &f)
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.