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,
46  dictionary
47 );
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
51 displacementMethodelasticityMotionSolver::
52 displacementMethodelasticityMotionSolver
53 (
54  fvMesh& mesh,
55  const labelList& patchIDs
56 )
57 :
58  displacementMethod(mesh, patchIDs),
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  (
82  (
83  IOobject
84  (
85  "dynamicMeshDict",
86  mesh.time().constant(),
87  mesh,
90  false
91  )
92  ).subDict("elasticityMotionSolverCoeffs").getOrDefault<bool>
93  (
94  "resetFields",
95  true
96  )
97  )
98 {}
99 
100 
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 
104 (
105  const pointVectorField& pointMovement
106 )
107 {
108  if (resetFields_)
109  {
110  pointMotionU_.primitiveFieldRef() = vector::zero;
111  cellMotionU_.primitiveFieldRef() = vector::zero;
112  cellMotionU_.correctBoundaryConditions();
113  }
114 
115  maxDisplacement_ = SMALL;
116 
117  // Update the boundary conditions of the pointField in order to make
118  // sure that the boundary will move according to the initial BCs
119  // without the interference of the volPointInterpolation in the elasticityMotionSolver
120  for (label patchI : patchIDs_)
121  {
122  // Set boundary field. Needed for the motionSolver class
123  pointMotionU_.boundaryFieldRef()[patchI] ==
124  pointMovement.boundaryField()[patchI].patchInternalField()();
125 
126  // Set boundary field values as seen from the internalField!
127  // Needed for determining the max displacement
128  pointMotionU_.boundaryFieldRef()[patchI].setInInternalField
129  (
130  pointMotionU_.primitiveFieldRef(),
131  pointMovement.boundaryField()[patchI].patchInternalField()()
132  );
133 
134  // Find max value
135  maxDisplacement_ =
136  max
137  (
138  maxDisplacement_,
139  gMax
140  (
141  mag
142  (
143  pointMotionU_.boundaryField()[patchI].
144  patchInternalField()
145  )
146  )
147  );
148  }
149 
150  // update the volField boundary conditions, used for the elasticity PDEs solution
151  const pointField& points = mesh_.points();
152  for (label patchI : patchIDs_)
153  {
154  const polyPatch& patch = mesh_.boundaryMesh()[patchI];
155  fvPatchVectorField& bField = cellMotionU_.boundaryFieldRef()[patchI];
156  forAll(patch, fI)
157  {
158  bField[fI] = patch[fI].average(points, pointMovement);
159  }
160  }
161 }
162 
163 
165 (
166  const volVectorField& cellMovement
167 )
168 {
169  auto cellMotionUbf = cellMotionU_.boundaryFieldRef();
170 
171  // Set boundary mesh movement and calculate
172  // max current boundary displacement
173  forAll(patchIDs_, pI)
174  {
175  label patchI = patchIDs_[pI];
176 
177  // Set boundary field. Needed for the motionSolver class
178  cellMotionUbf[patchI] == cellMovement.boundaryField()[patchI];
179 
180  // Find max value
181  maxDisplacement_ =
182  max
183  (
184  maxDisplacement_,
185  gMax
186  (
187  mag(cellMotionUbf[patchI])
188  )
189  );
190  }
191 }
192 
193 
195 (
196  const vectorField& controlField
197 )
198 {
200 }
201 
202 
204 (
205  const scalarField& controlField
206 )
207 {
209 }
210 
211 
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
213 
214 } // End namespace Foam
215 
216 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::fvPatchField< vector >
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:169
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:194
displacementMethodelasticityMotionSolver.H
Foam::displacementMethod
Abstract base class for displacement methods, which are a set or wrapper classes allowing to change t...
Definition: displacementMethod.H:59
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::Field< vector >
Foam::polyPatch
A patch is a list of labels that address the faces in the global face list.
Definition: polyPatch.H:68
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:460
Foam::displacementMethodelasticityMotionSolver::setMotionField
void setMotionField(const pointVectorField &pointMovement)
Set motion filed related to model based on given motion.
Definition: displacementMethodelasticityMotionSolver.C:104
Foam::displacementMethodelasticityMotionSolver::setControlField
void setControlField(const vectorField &controlField)
Definition: displacementMethodelasticityMotionSolver.C:195
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
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::List< label >
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:186
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::VectorSpace< Vector< scalar >, scalar, 3 >::zero
static const Vector< scalar > zero
Definition: VectorSpace.H:115
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePathsI.H:96
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:148
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
elasticityMotionSolver.H