sixDoFAccelerationSourceTemplates.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
27 #include "fvMesh.H"
28 #include "fvMatrices.H"
30 
31 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
32 
33 template<class AlphaFieldType, class RhoFieldType>
34 void Foam::fv::sixDoFAccelerationSource::addForce
35 (
36  const AlphaFieldType& alpha,
37  const RhoFieldType& rho,
38  fvMatrix<vector>& eqn,
39  const word& fieldName
40 ) const
41 {
42  const Vector<vector> accelerations
43  (
44  accelerations_->value(mesh().time().userTimeValue())
45  );
46 
47  // If gravitational force is present combine with the linear acceleration
48  if (mesh().foundObject<uniformDimensionedVectorField>("g"))
49  {
52 
53  const uniformDimensionedScalarField& hRef =
55 
56  g = g_ - dimensionedVector("a", dimAcceleration, accelerations.x());
57 
58  dimensionedScalar ghRef(- mag(g)*hRef);
59 
60  mesh().lookupObjectRef<volScalarField>("gh") = (g & mesh().C()) - ghRef;
61 
63  (g & mesh().Cf()) - ghRef;
64  }
65  // ... otherwise include explicitly in the momentum equation
66  else
67  {
68  const dimensionedVector a("a", dimAcceleration, accelerations.x());
69  eqn -= alpha*rho*a;
70  }
71 
72  dimensionedVector Omega
73  (
74  "Omega",
75  dimensionSet(0, 0, -1, 0, 0),
76  accelerations.y()
77  );
78 
79  dimensionedVector dOmegaDT
80  (
81  "dOmegaDT",
82  dimensionSet(0, 0, -2, 0, 0),
83  accelerations.z()
84  );
85 
86  eqn -=
87  (
88  alpha*rho*(2*Omega ^ eqn.psi()) // Coriolis force
89  + alpha*rho*(Omega ^ (Omega ^ mesh().C())) // Centrifugal force
90  + alpha*rho*(dOmegaDT ^ mesh().C()) // Angular acceleration force
91  );
92 }
93 
94 
95 // ************************************************************************* //
static const Foam::dimensionedScalar C("C", Foam::dimTemperature, 234.5)
const volVectorField & C() const
Return cell centres.
const surfaceVectorField & Cf() const
Return face centres.
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvModelI.H:34
Type & lookupObjectRef(const word &name) const
Lookup and return the object reference of the given Type.
const Type & lookupObject(const word &name) const
Lookup and return the object of the given Type and name.
A special matrix type and solver, designed for finite volume solutions of scalar equations.
volScalarField alpha(IOobject("alpha", runTime.name(), mesh, IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE), lambda *max(Ua &U, zeroSensitivity))
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
UniformDimensionedField< scalar > uniformDimensionedScalarField
SurfaceField< scalar > surfaceScalarField
const dimensionSet dimAcceleration
UniformDimensionedField< vector > uniformDimensionedVectorField
VolField< scalar > volScalarField
Definition: volFieldsFwd.H:61
dimensioned< scalar > mag(const dimensioned< Type > &)
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.