displacementMethodelasticityMotionSolver.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 "elasticityMotionSolver.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 defineTypeNameAndDebug(displacementMethodelasticityMotionSolver, 1);
43 (
44  displacementMethod,
45  displacementMethodelasticityMotionSolver,
47 );
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
51 displacementMethodelasticityMotionSolver::
52 displacementMethodelasticityMotionSolver
53 (
54  fvMesh& mesh,
55  const labelList& patchIDs
56 )
57 :
59  pointMotionU_(refCast<elasticityMotionSolver>(motionPtr_()).pointMotionU()),
60  cellMotionU_(refCast<elasticityMotionSolver>(motionPtr_()).cellMotionU()),
61  /*
62  // Getting a reference from the database is dangerous since multiple
63  // fields with the same name might be registered
64  pointMotionU_
65  (
66  const_cast<pointVectorField&>
67  (
68  mesh_.lookupObject<pointVectorField>("pointMotionU")
69  )
70  ),
71  cellMotionU_
72  (
73  const_cast<volVectorField&>
74  (
75  mesh_.lookupObject<volVectorField>("cellMotionU")
76  )
77  )
78  */
79  resetFields_
80  (
81  IOdictionary::readContents
82  (
83  IOobject
84  (
85  "dynamicMeshDict",
86  mesh.time().constant(),
87  mesh,
88  IOobject::MUST_READ
89  )
90  ).subDict("elasticityMotionSolverCoeffs").getOrDefault<bool>
91  (
92  "resetFields",
93  true
94  )
95  )
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
102 (
103  const pointVectorField& pointMovement
104 )
105 {
106  if (resetFields_)
107  {
108  pointMotionU_.primitiveFieldRef() = vector::zero;
109  cellMotionU_.primitiveFieldRef() = vector::zero;
111  }
112 
113  maxDisplacement_ = SMALL;
114 
115  // Update the boundary conditions of the pointField in order to make
116  // sure that the boundary will move according to the initial BCs
117  // without the interference of the volPointInterpolation in the elasticityMotionSolver
118  for (label patchI : patchIDs_)
119  {
120  // Set boundary field. Needed for the motionSolver class
121  pointMotionU_.boundaryFieldRef()[patchI] ==
122  pointMovement.boundaryField()[patchI].patchInternalField()();
123 
124  // Set boundary field values as seen from the internalField!
125  // Needed for determining the max displacement
126  pointMotionU_.boundaryFieldRef()[patchI].setInInternalField
127  (
129  pointMovement.boundaryField()[patchI].patchInternalField()()
130  );
131 
132  // Find max value
134  max
135  (
137  gMax
138  (
139  mag
140  (
141  pointMotionU_.boundaryField()[patchI].
142  patchInternalField()
143  )
144  )
145  );
146  }
147 
148  // update the volField boundary conditions, used for the elasticity PDEs solution
149  const pointField& points = mesh_.points();
150  for (label patchI : patchIDs_)
151  {
152  const polyPatch& patch = mesh_.boundaryMesh()[patchI];
154  forAll(patch, fI)
155  {
156  bField[fI] = patch[fI].average(points, pointMovement);
157  }
158  }
159 }
160 
161 
163 (
164  const volVectorField& cellMovement
165 )
166 {
167  auto cellMotionUbf = cellMotionU_.boundaryFieldRef();
168 
169  // Set boundary mesh movement and calculate
170  // max current boundary displacement
171  forAll(patchIDs_, pI)
172  {
173  label patchI = patchIDs_[pI];
174 
175  // Set boundary field. Needed for the motionSolver class
176  cellMotionUbf[patchI] == cellMovement.boundaryField()[patchI];
177 
178  // Find max value
180  max
181  (
183  gMax
184  (
185  mag(cellMotionUbf[patchI])
186  )
187  );
188  }
189 }
190 
191 
193 (
194  const vectorField& controlField
195 )
196 {
198 }
199 
200 
202 (
203  const scalarField& controlField
204 )
205 {
207 }
208 
209 
210 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
211 
212 } // End namespace Foam
213 
214 // ************************************************************************* //
const labelList patchIDs(pbm.patchSet(polyPatchNames, false, true).sortedToc())
fvPatchField< vector > fvPatchVectorField
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). 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
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
virtual const pointField & points() const
Return raw points.
Definition: polyMesh.C:1073
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:414
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
dynamicFvMesh & mesh
const pointField & points
const polyBoundaryMesh & boundaryMesh() const noexcept
Return boundary mesh.
Definition: polyMesh.H:584
const labelList & patchIDs_
IDs of the patches to be moved.
void setMotionField(const pointVectorField &pointMovement)
Set motion filed related to model based on given motion.
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.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:79
const std::string patch
OpenFOAM patch number as a std::string.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
void correctBoundaryConditions()
Correct boundary field.
Field< vector > vectorField
Specialisation of Field<T> for vector.
#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:171
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
Namespace for OpenFOAM.
Mesh deformation based on the linear elasticity equations. The boundary displacement is set as a boun...