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"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 defineTypeNameAndDebug(displacementMethodelasticityMotionSolver, 1);
42 (
43  displacementMethod,
44  displacementMethodelasticityMotionSolver,
45  dictionary
46 );
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
50 displacementMethodelasticityMotionSolver::
51 displacementMethodelasticityMotionSolver
52 (
53  fvMesh& mesh,
54  const labelList& patchIDs
55 )
56 :
57  displacementMethod(mesh, patchIDs),
58  pointMotionU_(refCast<elasticityMotionSolver>(motionPtr_()).pointMotionU()),
59  cellMotionU_(refCast<elasticityMotionSolver>(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,
89  false
90  )
91  ).subDict("elasticityMotionSolverCoeffs").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;
111  cellMotionU_.correctBoundaryConditions();
112  }
113 
114  maxDisplacement_ = SMALL;
115 
116  // Update the boundary conditions of the pointField in order to make
117  // sure that the boundary will move according to the initial BCs
118  // without the interference of the volPointInterpolation in the elasticityMotionSolver
119  for (label patchI : patchIDs_)
120  {
121  // Set boundary field. Needed for the motionSolver class
122  pointMotionU_.boundaryFieldRef()[patchI] ==
123  pointMovement.boundaryField()[patchI].patchInternalField()();
124 
125  // Set boundary field values as seen from the internalField!
126  // Needed for determining the max displacement
127  pointMotionU_.boundaryFieldRef()[patchI].setInInternalField
128  (
129  pointMotionU_.primitiveFieldRef(),
130  pointMovement.boundaryField()[patchI].patchInternalField()()
131  );
132 
133  // Find max value
134  maxDisplacement_ =
135  max
136  (
137  maxDisplacement_,
138  gMax
139  (
140  mag
141  (
142  pointMotionU_.boundaryField()[patchI].
143  patchInternalField()
144  )
145  )
146  );
147  }
148 
149  // update the volField boundary conditions, used for the elasticity PDEs solution
150  const pointField& points = mesh_.points();
151  for (label patchI : patchIDs_)
152  {
153  const polyPatch& patch = mesh_.boundaryMesh()[patchI];
154  fvPatchVectorField& bField = cellMotionU_.boundaryFieldRef()[patchI];
155  forAll(patch, fI)
156  {
157  bField[fI] = patch[fI].average(points, pointMovement);
158  }
159  }
160 }
161 
162 
164 (
165  const volVectorField& cellMovement
166 )
167 {
168  auto cellMotionUbf = cellMotionU_.boundaryFieldRef();
169 
170  // Set boundary mesh movement and calculate
171  // max current boundary displacement
172  forAll(patchIDs_, pI)
173  {
174  label patchI = patchIDs_[pI];
175 
176  // Set boundary field. Needed for the motionSolver class
177  cellMotionUbf[patchI] == cellMovement.boundaryField()[patchI];
178 
179  // Find max value
180  maxDisplacement_ =
181  max
182  (
183  maxDisplacement_,
184  gMax
185  (
186  mag(cellMotionUbf[patchI])
187  )
188  );
189  }
190 }
191 
192 
194 (
195  const vectorField& controlField
196 )
197 {
199 }
200 
201 
203 (
204  const scalarField& controlField
205 )
206 {
208 }
209 
210 
211 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
212 
213 } // End namespace Foam
214 
215 // ************************************************************************* //
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:104
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:129
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:445
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:528
Foam::displacementMethodelasticityMotionSolver::setMotionField
void setMotionField(const pointVectorField &pointMovement)
Set motion filed related to model based on given motion.
Definition: displacementMethodelasticityMotionSolver.C:103
Foam::displacementMethodelasticityMotionSolver::setControlField
void setControlField(const vectorField &controlField)
Definition: displacementMethodelasticityMotionSolver.C:194
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
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:83
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:121
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:275
Foam::VectorSpace< Vector< Cmpt >, Cmpt, 3 >::zero
static const Vector< Cmpt > zero
Definition: VectorSpace.H:115
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePathsI.H:88
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:122
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