displacementMethodlaplacianMotionSolver.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 
31 #include "laplacianMotionSolver.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 defineTypeNameAndDebug(displacementMethodlaplacianMotionSolver, 1);
43 (
44  displacementMethod,
47 );
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
51 displacementMethodlaplacianMotionSolver::displacementMethodlaplacianMotionSolver
52 (
53  fvMesh& mesh,
54  const labelList& patchIDs
55 )
56 :
57  displacementMethod(mesh, patchIDs),
58  pointMotionU_(refCast<laplacianMotionSolver>(motionPtr_()).pointMotionU()),
59  cellMotionU_(refCast<laplacianMotionSolver>(motionPtr_()).cellMotionU()),
60  /*
61  // getting a reference from the database is dangerous since multiple
62  // fields with the same name might be registered
63  pointMotionU_
64  (
65  const_cast<pointVectorField&>
66  (
67  mesh_.lookupObject<pointVectorField>("pointMotionU")
68  )
69  ),
70  cellMotionU_
71  (
72  const_cast<volVectorField&>
73  (
74  mesh_.lookupObject<volVectorField>("cellMotionU")
75  )
76  ),
77  */
78  resetFields_
79  (
81  (
82  IOobject
83  (
84  "dynamicMeshDict",
85  mesh.time().constant(),
86  mesh,
87  IOobject::MUST_READ_IF_MODIFIED,
88  IOobject::AUTO_WRITE,
89  false
90  )
91  ).subDict("laplacianMotionSolverCoeffs").getOrDefault<bool>
92  (
93  "resetFields",
94  true
95  )
96  )
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
103 (
104  const pointVectorField& pointMovement
105 )
106 {
107  if (resetFields_)
108  {
109  pointMotionU_.primitiveFieldRef() = vector::zero;
110  cellMotionU_.primitiveFieldRef() = vector::zero;
112  }
113 
114  // Set boundary mesh movement and calculate
115  // max current boundary displacement
116  for (label patchI : patchIDs_)
117  {
118  // Set boundary field. Needed for the motionSolver class
119  pointMotionU_.boundaryFieldRef()[patchI] ==
120  pointMovement.boundaryField()[patchI].patchInternalField()();
121 
122  // Set boundary field values as seen from the internalField!
123  // Needed for determining the max displacement
124  pointMotionU_.boundaryFieldRef()[patchI].setInInternalField
125  (
127  pointMovement.boundaryField()[patchI].patchInternalField()()
128  );
129 
130  // Find max value
132  max
133  (
135  gMax
136  (
137  mag
138  (
139  pointMotionU_.boundaryField()[patchI].
140  patchInternalField()
141  )
142  )
143  );
144  }
145 }
146 
147 
149 (
150  const volVectorField& cellMovement
151 )
152 {
154  /*
155  // Set boundary mesh movement and calculate max current boundary
156  // displacement
157  forAll(patchIDs_, pI)
158  {
159  label patchI = patchIDs_[pI];
160  cellMotionU_.boundaryField()[patchI] ==
161  cellMovement.boundaryField()[patchI];
162 
163  // Find max value
164  maxDisplacement_ =
165  max
166  (
167  maxDisplacement_,
168  gMax
169  (
170  mag(cellMovement.boundaryField()[patchI])
171  )
172  );
173  }
174  */
175 }
176 
177 
179 (
180  const vectorField& controlField
181 )
182 {
184 }
185 
186 
188 (
189  const scalarField& controlField
190 )
191 {
193 }
194 
195 
196 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
197 
198 } // End namespace Foam
199 
200 // ************************************************************************* //
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:120
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
Type & refCast(U &obj)
A dynamic_cast (for references) that generates FatalError on failed casts, uses the virtual type() me...
Definition: typeInfo.H:151
void setControlField(const vectorField &controlField)
Set control field as a vectorField. For methods working with parameters (RBF etc) ...
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:85
Similar to velocityLaplacian but iteratively solves the mesh displacement PDEs to account for non-ort...
Macros for easy insertion into run-time selection tables.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
void setMotionField(const pointVectorField &pointMovement)
Set motion filed related to model based on given motion.
dynamicFvMesh & mesh
const labelList & patchIDs_
IDs of the patches to be moved.
Abstract base class for displacement methods, which are a set or wrapper classes allowing to change t...
Type gMax(const FieldField< Field, Type > &f)
defineTypeNameAndDebug(combustionModel, 0)
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field values.
Wrapper class for the velocityLaplacian motion solver.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
void correctBoundaryConditions()
Correct boundary field.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:666
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:166
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
Namespace for OpenFOAM.