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 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 motionSolverName(dynamicMeshDict.get<word>("solver"));
79  word modelType("displacementMethod" + motionSolverName);
80 
81  Info<< "displacementMethod type : " << modelType << endl;
82 
83  auto cstrIter = dictionaryConstructorTablePtr_->cfind(modelType);
84 
85  if (!cstrIter.found())
86  {
88  (
89  dynamicMeshDict,
90  "solver",
91  modelType,
92  *dictionaryConstructorTablePtr_
93  ) << exit(FatalError);
94  }
95  return autoPtr<displacementMethod>(cstrIter()(mesh, patchIDs));
96 }
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * //
100 
102 {
103  // Does nothing in base
104 }
105 
106 
108 {
109  return motionPtr_;
110 }
111 
112 
114 {
115  return maxDisplacement_;
116 }
117 
118 
120 {
121  scalar timeBef = mesh_.time().elapsedCpuTime();
122 
123  // Compute max mesh movement
124  tmp<pointField> tnewPoints = motionPtr_->newPoints();
125  Info<< "Max mesh movement magnitude "
126  << gMax(mag(tnewPoints() - mesh_.points())) << endl;
127 
128  // Update mesh as in dynamicFvMesh
129  mesh_.movePoints(tnewPoints());
130  scalar timeAft = mesh_.time().elapsedCpuTime();
131  Info<< "Mesh movement took " << timeAft - timeBef << " seconds" << endl;
132  mesh_.moving(false);
133 }
134 
135 
136 // ************************************************************************* //
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::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::displacementMethod::boundControlField
virtual void boundControlField(vectorField &controlField)
Definition: displacementMethod.C:101
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:81
Foam::displacementMethod::getMaxDisplacement
scalar getMaxDisplacement() const
Get max displacement.
Definition: displacementMethod.C:113
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:380
Foam::Field< vector >
Foam::Info
messageStream Info
Information stream (uses stdout - output is on the master only)
Foam::displacementMethod::getMotionSolver
autoPtr< motionSolver > & getMotionSolver()
Get access to motionSolver.
Definition: displacementMethod.C:107
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
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:119
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