tabulatedAccelerationSourceTemplates.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) 2015 OpenFOAM Foundation
9  Copyright (C) 2020 OpenCFD Ltd.
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 "fvMesh.H"
31 #include "fvMatrices.H"
33 
34 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
35 
36 template<class RhoFieldType>
37 void Foam::fv::tabulatedAccelerationSource::addSup
38 (
39  const RhoFieldType& rho,
40  fvMatrix<vector>& eqn,
41  const label fieldi
42 )
43 {
44  Vector<vector> acceleration(motion_.acceleration());
45 
46  // If gravitational force is present combine with the linear acceleration
48  {
49  auto& g =
51 
52  const auto& hRef =
54 
55  g = g0_ - dimensionedVector("a", dimAcceleration, acceleration.x());
56 
57  dimensionedScalar ghRef
58  (
59  mag(g.value()) > SMALL
60  ? g & (cmptMag(g.value())/mag(g.value()))*hRef
61  : dimensionedScalar("ghRef", g.dimensions()*dimLength, 0)
62  );
63 
65  = (g & mesh_.C()) - ghRef;
66 
68  = (g & mesh_.Cf()) - ghRef;
69  }
70  // ... otherwise include explicitly in the momentum equation
71  else
72  {
73  eqn -= rho*dimensionedVector("a", dimAcceleration, acceleration.x());
74  }
75 
76  dimensionedVector Omega
77  (
78  "Omega",
79  dimensionSet(0, 0, -1, 0, 0),
80  acceleration.y()
81  );
82 
83  dimensionedVector dOmegaDT
84  (
85  "dOmegaDT",
86  dimensionSet(0, 0, -2, 0, 0),
87  acceleration.z()
88  );
89 
90  eqn -=
91  (
92  rho*(2*Omega ^ eqn.psi()) // Coriolis force
93  + rho*(Omega ^ (Omega ^ mesh_.C())) // Centrifugal force
94  + rho*(dOmegaDT ^ mesh_.C()) // Angular tabulatedAcceleration force
95  );
96 }
97 
98 
99 // ************************************************************************* //
const Type & lookupObject(const word &name, const bool recursive=false) const
Lookup and return const reference to the object of the given Type. Fatal if not found or the wrong ty...
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Type & lookupObjectRef(const word &name, const bool recursive=false) const
Lookup and return non-const reference to the object of the given Type. Fatal if not found or the wron...
UniformDimensionedField< vector > uniformDimensionedVectorField
const surfaceVectorField & Cf() const
Return face centres as surfaceVectorField.
const fvMesh & mesh_
Reference to the mesh database.
Definition: fvOption.H:141
Various UniformDimensionedField types.
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:362
UniformDimensionedField< scalar > uniformDimensionedScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:81
const dimensionSet dimAcceleration
virtual Vector< vector > acceleration() const
Return the solid-body accelerations.
dimensionedVector g0_
Gravitational accelaration.
tabulated6DoFAcceleration motion_
Run-time selectable acceleration model.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
const uniformDimensionedVectorField & g
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
A special matrix type and solver, designed for finite volume solutions of scalar equations.
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
const volVectorField & C() const
Return cell centres as volVectorField.
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField