Loading...
Searching...
No Matches
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\*---------------------------------------------------------------------------*/
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace Foam
35{
36 defineTypeNameAndDebug(displacementMethod, 0);
37 defineRunTimeSelectionTable(displacementMethod, dictionary);
38}
39
40
41// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42
43Foam::displacementMethod::displacementMethod
44(
45 fvMesh& mesh,
46 const labelList& patchIDs
47)
48:
49 mesh_(mesh),
50 patchIDs_(patchIDs),
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,
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 }
95}
96
97
98// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * //
101{
102 return true;
103}
104
107{
108 // Does nothing in base
109}
110
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// ************************************************************************* //
labelList patchIDs
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
Abstract base class for displacement methods, which are a set or wrapper classes allowing to change t...
autoPtr< motionSolver > motionPtr_
autoPtr< motionSolver > & getMotionSolver()
Get access to motionSolver.
virtual void boundControlField(vectorField &controlField)
Bound control field in certain directions etc. For methods working with parameters (RBF etc) does not...
virtual bool preferPointField() const
Whether the motion solver prefers a point of a vol field as input.
static autoPtr< displacementMethod > New(fvMesh &mesh, const labelList &patchIDs)
Return a reference to the selected turbulence model.
scalar getMaxDisplacement() const
Get max displacement.
labelList patchIDs_
IDs of the patches to be moved.
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
Virtual base class for mesh motion solver.
A class for managing temporary objects.
Definition tmp.H:75
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition error.H:637
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Field< vector > vectorField
Specialisation of Field<T> for vector.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
Type gMax(const FieldField< Field, Type > &f)
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.