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);
37  defineRunTimeSelectionTable(displacementMethod, dictionary);
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,
73  IOobject::MUST_READ,
74  IOobject::NO_WRITE,
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  mesh_.moving(false);
132 }
133 
134 
135 // ************************************************************************* //
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:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::displacementMethod::boundControlField
virtual void boundControlField(vectorField &controlField)
Definition: displacementMethod.C:100
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
Foam::displacementMethod::getMaxDisplacement
scalar getMaxDisplacement() const
Get max displacement.
Definition: displacementMethod.C:112
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
Foam::Field< vector >
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::displacementMethod::getMotionSolver
autoPtr< motionSolver > & getMotionSolver()
Get access to motionSolver.
Definition: displacementMethod.C:106
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::autoPtr< Foam::displacementMethod >
displacementMethod.H
Foam::displacementMethod::update
void update()
Update mesh.
Definition: displacementMethod.C:118
Foam::List< label >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::displacementMethod::New
static autoPtr< displacementMethod > New(fvMesh &mesh, const labelList &patchIDs)
Return a reference to the selected turbulence model.
Definition: displacementMethod.C:59
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::gMax
Type gMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:592