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-2023 PCOpt/NTUA
9  Copyright (C) 2013-2023 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 :
58  pointMotionU_(refCast<laplacianMotionSolver>(motionPtr_()).pointMotionU()),
59  cellMotionU_(refCast<laplacianMotionSolver>(motionPtr_()).cellMotionU()),
60  resetFields_
61  (
62  IOdictionary::readContents
63  (
64  IOobject
65  (
66  "dynamicMeshDict",
67  mesh.time().constant(),
68  mesh,
69  IOobject::MUST_READ
70  )
71  ).subDict("laplacianMotionSolverCoeffs").getOrDefault<bool>
72  (
73  "resetFields",
74  true
75  )
76  )
77 {}
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
83 {
84  return false;
85 }
86 
87 
89 (
90  const pointVectorField& pointMovement
91 )
92 {
93  if (resetFields_)
94  {
98  }
99 
100  maxDisplacement_ = SMALL;
101 
102  // Set boundary mesh movement and calculate
103  // max current boundary displacement
104  for (const label patchI : patchIDs_)
105  {
106  // Set boundary field. Needed for the motionSolver class
107  pointMotionU_.boundaryFieldRef()[patchI] ==
108  pointMovement.boundaryField()[patchI].patchInternalField()();
109 
110  // Set boundary field values as seen from the internalField!
111  // Needed for determining the max displacement
112  pointMotionU_.boundaryFieldRef()[patchI].setInInternalField
113  (
115  pointMovement.boundaryField()[patchI].patchInternalField()()
116  );
117 
118  // Find max value
120  max
121  (
123  gMax
124  (
125  mag
126  (
127  pointMotionU_.boundaryField()[patchI].
128  patchInternalField()
129  )
130  )
131  );
132  }
133  // Transfer movement to cellMotionU
134  refCast<laplacianMotionSolver>(motionPtr_()).setBoundaryConditions();
135 }
136 
137 
139 (
140  const volVectorField& cellMovement
141 )
142 {
143  if (resetFields_)
144  {
148  }
149 
150  auto& cellMotionUbf = cellMotionU_.boundaryFieldRef();
151  // Set boundary mesh movement and calculate max current boundary
152  // displacement
153  for (const label patchI : patchIDs_)
154  {
155  cellMotionUbf[patchI] == cellMovement.boundaryField()[patchI];
156 
157  // Find max value
159  max
160  (
162  gMax(mag(cellMotionUbf[patchI]))
163  );
164  }
165 }
166 
167 
169 (
170  const vectorField& controlField
171 )
172 {
174 }
175 
176 
178 (
179  const scalarField& controlField
180 )
181 {
183 }
184 
185 
186 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
187 
188 } // End namespace Foam
189 
190 // ************************************************************************* //
const labelList patchIDs(pbm.indices(polyPatchNames, true))
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:129
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). Generates a FatalError on failed casts and uses the virtual type() m...
Definition: typeInfo.H:159
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:82
Similar to velocityLaplacian but iteratively solves the mesh displacement PDEs to account for non-ort...
autoPtr< motionSolver > motionPtr_
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
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)
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:78
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
void correctBoundaryConditions()
Correct boundary field.
labelList patchIDs_
IDs of the patches to be moved.
Field< vector > vectorField
Specialisation of Field<T> for vector.
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:686
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
virtual bool preferPointField() const
Whether the motion solver prefers a point of a vol field as input.
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127