displacementMethodvelocityLaplacian.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-2020 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 
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 defineTypeNameAndDebug(displacementMethodvelocityLaplacian, 1);
42 (
43  displacementMethod,
44  displacementMethodvelocityLaplacian,
45  dictionary
46 );
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
51 displacementMethodvelocityLaplacian::displacementMethodvelocityLaplacian
52 (
53  fvMesh& mesh,
54  const labelList& patchIDs
55 )
56 :
57  displacementMethod(mesh, patchIDs),
58  pointMotionU_
59  (
60  refCast<velocityLaplacianFvMotionSolver>(motionPtr_()).pointMotionU()
61  ),
62  cellMotionU_
63  (
64  refCast<velocityLaplacianFvMotionSolver>(motionPtr_()).cellMotionU()
65  ),
66  /*
67  // Getting a reference from the database is dangerous since multiple
68  // fields with the same name might be registered
69  pointMotionU_
70  (
71  const_cast<pointVectorField&>
72  (
73  mesh_.lookupObject<pointVectorField>("pointMotionU")
74  )
75  ),
76  cellMotionU_
77  (
78  const_cast<volVectorField&>
79  (
80  mesh_.lookupObject<volVectorField>("cellMotionU")
81  )
82  ),
83  */
84  resetFields_
85  (
87  (
88  IOobject
89  (
90  "dynamicMeshDict",
91  mesh.time().constant(),
92  mesh,
95  false
96  )
97  ).subDict("velocityLaplacianCoeffs").getOrDefault<bool>
98  (
99  "resetFields",
100  true
101  )
102  )
103 {}
104 
105 
106 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
107 
109 (
110  const pointVectorField& pointMovement
111 )
112 {
113  if (resetFields_)
114  {
115  pointMotionU_.primitiveFieldRef() = vector::zero;
116  cellMotionU_.primitiveFieldRef() = vector::zero;
117  cellMotionU_.correctBoundaryConditions();
118  }
119 
120  // Set boundary mesh movement and calculate
121  // max current boundary displacement
122  for (label patchI : patchIDs_)
123  {
124  // Set boundary field. Needed for the motionSolver class
125  pointMotionU_.boundaryFieldRef()[patchI] ==
126  pointMovement.boundaryField()[patchI].patchInternalField()();
127 
128  // Set boundary field values as seen from the internalField!
129  // Needed for determining the max displacement
130  pointMotionU_.boundaryFieldRef()[patchI].setInInternalField
131  (
132  pointMotionU_.primitiveFieldRef(),
133  pointMovement.boundaryField()[patchI].patchInternalField()()
134  );
135 
136  // Find max value
137  maxDisplacement_ =
138  max
139  (
140  maxDisplacement_,
141  gMax
142  (
143  mag
144  (
145  pointMotionU_.boundaryField()[patchI].
146  patchInternalField()
147  )
148  )
149  );
150  }
151 }
152 
153 
155 (
156  const volVectorField& cellMovement
157 )
158 {
160 
161  /*
162  // Set boundary mesh movement and calculate max current boundary
163  // displacement
164  forAll(patchIDs_, pI)
165  {
166  label patchI = patchIDs_[pI];
167  cellMotionU_.boundaryField()[patchI] ==
168  cellMovement.boundaryField()[patchI];
169 
170  // Find max value
171  maxDisplacement_ =
172  max
173  (
174  maxDisplacement_,
175  gMax
176  (
177  mag(cellMovement.boundaryField()[patchI])
178  )
179  );
180  }
181  */
182 }
183 
184 
186 (
187  const vectorField& controlField
188 )
189 {
191 }
192 
193 
195 (
196  const scalarField& controlField
197 )
198 {
200 }
201 
202 
203 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
204 
205 } // End namespace Foam
206 
207 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
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::IOobject::AUTO_WRITE
Definition: IOobject.H:129
Foam::displacementMethod
Abstract base class for displacement methods, which are a set or wrapper classes allowing to change t...
Definition: displacementMethod.H:59
displacementMethodvelocityLaplacian.H
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:445
velocityLaplacianFvMotionSolver.H
Foam::Field< vector >
Foam::dictionary::subDict
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:528
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::displacementMethodvelocityLaplacian::setControlField
void setControlField(const vectorField &controlField)
Definition: displacementMethodvelocityLaplacian.C:186
Foam::displacementMethodvelocityLaplacian::setMotionField
void setMotionField(const pointVectorField &pointMovement)
Set motion filed related to model based on given motion.
Definition: displacementMethodvelocityLaplacian.C:109
Foam::List< label >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:121
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:275
Foam::VectorSpace< Vector< Cmpt >, Cmpt, 3 >::zero
static const Vector< Cmpt > zero
Definition: VectorSpace.H:115
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePathsI.H:88
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:122
Foam::GeometricField< vector, pointPatchField, pointMesh >
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::gMax
Type gMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:592
Foam::GeometricField::boundaryField
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Definition: GeometricFieldI.H:62