displacementMethodpLaplacianMotionSolver.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) 2021 PCOpt/NTUA
9  Copyright (C) 2021 FOSS GP
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
30 #include "pLaplacianMotionSolver.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 defineTypeNameAndDebug(displacementMethodpLaplacianMotionSolver, 1);
41 (
42  displacementMethod,
43  displacementMethodpLaplacianMotionSolver,
45 );
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
49 displacementMethodpLaplacianMotionSolver::
50 displacementMethodpLaplacianMotionSolver
51 (
52  fvMesh& mesh,
53  const labelList& patchIDs
54 )
55 :
57  pointMotionU_(refCast<pLaplacianMotionSolver>(motionPtr_()).pointMotionU()),
58  cellMotionU_(refCast<pLaplacianMotionSolver>(motionPtr_()).cellMotionU()),
59  resetFields_
60  (
62  (
63  IOobject
64  (
65  "dynamicMeshDict",
66  mesh.time().constant(),
67  mesh,
68  IOobject::MUST_READ_IF_MODIFIED,
69  IOobject::AUTO_WRITE,
70  false
71  )
72  ).subDict("pLaplacianMotionSolverCoeffs").getOrDefault<bool>
73  (
74  "resetFields",
75  true
76  )
77  )
78 {}
79 
80 
81 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82 
84 {
85  return false;
86 }
87 
88 
90 (
91  const pointVectorField& pointMovement
92 )
93 {
94  if (resetFields_)
95  {
99  }
100 
101  maxDisplacement_ = SMALL;
102 
103  // Set boundary mesh movement and calculate
104  // max current boundary displacement
105  for (label patchI : patchIDs_)
106  {
107  // Set boundary field. Needed for the motionSolver class
108  pointMotionU_.boundaryFieldRef()[patchI] ==
109  pointMovement.boundaryField()[patchI].patchInternalField()();
110 
111  // Set boundary field values as seen from the internalField!
112  // Needed for determining the max displacement
113  pointMotionU_.boundaryFieldRef()[patchI].setInInternalField
114  (
116  pointMovement.boundaryField()[patchI].patchInternalField()()
117  );
118 
119  // Find max value
121  max
122  (
124  gMax
125  (
126  mag
127  (
128  pointMotionU_.boundaryField()[patchI].
129  patchInternalField()
130  )
131  )
132  );
133  }
134  // Transfer movement to cellMotionU
135  refCast<pLaplacianMotionSolver>(motionPtr_()).setBoundaryConditions();
136 }
137 
138 
140 (
141  const volVectorField& cellMovement
142 )
143 {
144  if (resetFields_)
145  {
149  }
150 
151  auto& cellMotionUbf = cellMotionU_.boundaryFieldRef();
152  // Set boundary mesh movement and calculate max current boundary
153  // displacement
154  for (const label patchI : patchIDs_)
155  {
156  cellMotionUbf[patchI] == cellMovement.boundaryField()[patchI];
157 
158  // Find max value
160  max
161  (
163  gMax(mag(cellMotionUbf[patchI]))
164  );
165  }
166 }
167 
168 
170 (
171  const vectorField& controlField
172 )
173 {
175 }
176 
177 
179 (
180  const scalarField& controlField
181 )
182 {
184 }
185 
186 
187 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
188 
189 } // End namespace Foam
190 
191 // ************************************************************************* //
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
Similar to velocityLaplacian but with a variable diffusivity, based on the gradient of the displaceme...
GeometricField< vector, fvPatchField, volMesh > volVectorField
Definition: volFieldsFwd.H:82
autoPtr< motionSolver > motionPtr_
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
Definition: IOdictionary.H:50
virtual bool preferPointField() const
Whether the motion solver prefers a point of a vol field as input.
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.
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.
void setMotionField(const pointVectorField &pointMovement)
Set motion filed related to model based on given motion.
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.
void setControlField(const vectorField &controlField)
Set control field as a vectorField. For methods working with parameters (RBF etc) ...
Namespace for OpenFOAM.
addToRunTimeSelectionTable(functionObject, pointHistory, dictionary)
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:127