explicitPorositySource.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) 2012-2018 OpenFOAM Foundation
9  Copyright (C) 2020-2021 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 
29 #include "explicitPorositySource.H"
30 #include "fvMesh.H"
31 #include "fvMatrices.H"
32 #include "porosityModel.H"
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39 namespace fv
40 {
41  defineTypeNameAndDebug(explicitPorositySource, 0);
42  addToRunTimeSelectionTable(option, explicitPorositySource, dictionary);
43 }
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
50 (
51  const word& name,
52  const word& modelType,
53  const dictionary& dict,
54  const fvMesh& mesh
55 )
56 :
57  fv::cellSetOption(name, modelType, dict, mesh),
58  porosityPtr_(nullptr)
59 {
60  read(dict);
61 
62  porosityPtr_.reset
63  (
65  (
66  name_,
67  mesh_,
68  coeffs_,
69  cellSetName_
70  ).ptr()
71  );
72 }
73 
74 
75 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
76 
78 (
79  fvMatrix<vector>& eqn,
80  const label fieldi
81 )
82 {
83  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
84  porosityPtr_->addResistance(porosityEqn);
85  eqn -= porosityEqn;
86 }
87 
88 
90 (
91  const volScalarField& rho,
92  fvMatrix<vector>& eqn,
93  const label fieldi
94 )
95 {
96  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
97  porosityPtr_->addResistance(porosityEqn);
98  eqn -= porosityEqn;
99 }
100 
101 
103 (
104  const volScalarField& alpha,
105  const volScalarField& rho,
106  fvMatrix<vector>& eqn,
107  const label fieldi
108 )
109 {
110  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
111  porosityPtr_->addResistance(porosityEqn);
112  eqn -= alpha*porosityEqn;
113 }
114 
115 
117 {
119  {
120  if (!coeffs_.readIfPresent("UNames", fieldNames_))
121  {
122  fieldNames_.resize(1);
123  fieldNames_.first() = coeffs_.getOrDefault<word>("U", "U");
124  }
125 
127 
128  return true;
129  }
130 
131  return false;
132 }
133 
134 
135 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fv::cellSetOption
Intermediate abstract class for handling cell-set options for the derived fvOptions.
Definition: cellSetOption.H:163
Foam::List::resize
void resize(const label len)
Adjust allocated size of list.
Definition: ListI.H:139
Foam::fv::option::resetApplied
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: fvOption.C:48
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:212
Foam::fvMatrix::dimensions
const dimensionSet & dimensions() const
Definition: fvMatrix.H:440
porosityModel.H
rho
rho
Definition: readInitialConditions.H:88
fvMatrices.H
A special matrix type and solver, designed for finite volume solutions of scalar equations.
Foam::blockMeshTools::read
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:57
explicitPorositySource.H
Foam::fv::explicitPorositySource::addSup
virtual void addSup(fvMatrix< vector > &eqn, const label fieldi)
Add implicit contribution to momentum equation.
Definition: explicitPorositySource.C:78
Foam::fv::option::coeffs_
dictionary coeffs_
Dictionary containing source coefficients.
Definition: fvOption.H:145
Foam::fv::option::fieldNames_
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition: fvOption.H:148
Foam::fv::cellSetOption::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: cellSetOption.C:255
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::fvMatrix::psi
const GeometricField< Type, fvPatchField, volMesh > & psi(const label i=0) const
Return psi.
Definition: fvMatrix.H:399
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
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
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
fv
labelList fv(nPoints)
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::fv::explicitPorositySource::read
virtual bool read(const dictionary &dict)
Read dictionary.
Definition: explicitPorositySource.C:116
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(atmAmbientTurbSource, 0)
Foam::fv::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, atmAmbientTurbSource, dictionary)
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:148
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::fv::explicitPorositySource::explicitPorositySource
explicitPorositySource(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Definition: explicitPorositySource.C:50
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:405