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 -------------------------------------------------------------------------------
12 License
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 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(displacementMethod, 0);
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
43 Foam::displacementMethod::displacementMethod
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  (
68  IOobject
69  (
70  "dynamicMeshDict",
71  mesh.time().constant(),
72  mesh,
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  return true;
103 }
104 
107 {
108  // Does nothing in base
109 }
110 
113 {
114  return motionPtr_;
115 }
116 
119 {
120  return maxDisplacement_;
121 }
122 
123 
125 {
126  scalar timeBef = mesh_.time().elapsedCpuTime();
127 
128  // Compute max mesh movement
129  tmp<pointField> tnewPoints = motionPtr_->newPoints();
130  Info<< "Max mesh movement magnitude "
131  << gMax(mag(tnewPoints() - mesh_.points())) << endl;
132 
133  // Update mesh as in dynamicFvMesh
134  mesh_.movePoints(tnewPoints());
135  scalar timeAft = mesh_.time().elapsedCpuTime();
136  Info<< "Mesh movement took " << timeAft - timeBef << " seconds" << endl;
137  if (!mesh_.steady())
138  {
139  mesh_.moving(false);
140  }
141 }
142 
143 
144 // ************************************************************************* //
const labelList patchIDs(pbm.indices(polyPatchNames, true))
void update()
Update mesh.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
Virtual base class for mesh motion solver.
Definition: motionSolver.H:54
Ignore writing from objectRegistry::writeObject()
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
dynamicFvMesh & mesh
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void boundControlField(vectorField &controlField)
Bound control field in certain directions etc. For methods working with parameters (RBF etc) does not...
Abstract base class for displacement methods, which are a set or wrapper classes allowing to change t...
static autoPtr< displacementMethod > New(fvMesh &mesh, const labelList &patchIDs)
Return a reference to the selected turbulence model.
autoPtr< motionSolver > & getMotionSolver()
Get access to motionSolver.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Type gMax(const FieldField< Field, Type > &f)
defineTypeNameAndDebug(combustionModel, 0)
scalar getMaxDisplacement() const
Get max displacement.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
messageStream Info
Information stream (stdout output on master, null elsewhere)
A class for managing temporary objects.
Definition: HashPtrTable.H:50
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:635
virtual bool preferPointField() const
Whether the motion solver prefers a point of a vol field as input.
Do not request registration (bool: false)
Namespace for OpenFOAM.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...