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 // ************************************************************************* //
tabulatedAccelerationSource.H
Foam::tabulated6DoFAcceleration::acceleration
virtual Vector< vector > acceleration() const
Return the solid-body accelerations.
Definition: tabulated6DoFAcceleration.C:60
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
rho
rho
Definition: readInitialConditions.H:88
Foam::objectRegistry::foundObject
bool foundObject(const word &name, const bool recursive=false) const
Is the named Type found?
Definition: objectRegistryTemplates.C:379
Foam::fv::option::mesh_
const fvMesh & mesh_
Reference to the mesh database.
Definition: fvOption.H:139
Foam::dimensionedVector
dimensioned< vector > dimensionedVector
Dimensioned vector obtained from generic dimensioned type.
Definition: dimensionedVector.H:50
fvMatrices.H
A special matrix type and solver, designed for finite volume solutions of scalar equations.
Foam::cmptMag
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:400
Foam::fv::tabulatedAccelerationSource::g0_
dimensionedVector g0_
Gravitational accelaration.
Definition: tabulatedAccelerationSource.H:126
Foam::uniformDimensionedVectorField
UniformDimensionedField< vector > uniformDimensionedVectorField
Definition: uniformDimensionedFields.H:50
Foam::uniformDimensionedScalarField
UniformDimensionedField< scalar > uniformDimensionedScalarField
Definition: uniformDimensionedFields.H:49
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:42
Foam::volScalarField
GeometricField< scalar, fvPatchField, volMesh > volScalarField
Definition: volFieldsFwd.H:57
Foam::objectRegistry::lookupObject
const Type & lookupObject(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:434
Foam::fvMesh::C
const volVectorField & C() const
Return cell centres as volVectorField.
Definition: fvMeshGeometry.C:341
fvMesh.H
g
const uniformDimensionedVectorField & g
Definition: createFluidFields.H:26
Foam::dimAcceleration
const dimensionSet dimAcceleration
Foam::objectRegistry::lookupObjectRef
Type & lookupObjectRef(const word &name, const bool recursive=false) const
Definition: objectRegistryTemplates.C:478
uniformDimensionedFields.H
Foam::surfaceScalarField
GeometricField< scalar, fvsPatchField, surfaceMesh > surfaceScalarField
Definition: surfaceFieldsFwd.H:54
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::fvMesh::time
const Time & time() const
Return the top-level database.
Definition: fvMesh.H:280
Foam::fv::tabulatedAccelerationSource::motion_
tabulated6DoFAcceleration motion_
Run-time selectable acceleration model.
Definition: tabulatedAccelerationSource.H:120
Foam::fvMesh::Cf
const surfaceVectorField & Cf() const
Return face centres as surfaceVectorField.
Definition: fvMeshGeometry.C:352