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 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);
43  (
44  option,
45  explicitPorositySource,
46  dictionary
47  );
48 }
49 }
50 
51 
52 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
53 
54 Foam::fv::explicitPorositySource::explicitPorositySource
55 (
56  const word& name,
57  const word& modelType,
58  const dictionary& dict,
59  const fvMesh& mesh
60 )
61 :
62  cellSetOption(name, modelType, dict, mesh),
63  porosityPtr_(nullptr)
64 {
65  read(dict);
66 
67  porosityPtr_.reset
68  (
70  (
71  name_,
72  mesh_,
73  coeffs_,
74  cellSetName_
75  ).ptr()
76  );
77 }
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
83 (
84  fvMatrix<vector>& eqn,
85  const label fieldi
86 )
87 {
88  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
89  porosityPtr_->addResistance(porosityEqn);
90  eqn -= porosityEqn;
91 }
92 
93 
95 (
96  const volScalarField& rho,
97  fvMatrix<vector>& eqn,
98  const label fieldi
99 )
100 {
101  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
102  porosityPtr_->addResistance(porosityEqn);
103  eqn -= porosityEqn;
104 }
105 
106 
108 (
109  const volScalarField& alpha,
110  const volScalarField& rho,
111  fvMatrix<vector>& eqn,
112  const label fieldi
113 )
114 {
115  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
116  porosityPtr_->addResistance(porosityEqn);
117  eqn -= alpha*porosityEqn;
118 }
119 
120 
122 {
124  {
125  if (!coeffs_.readIfPresent("UNames", fieldNames_))
126  {
127  fieldNames_.resize(1);
128  fieldNames_.first() = coeffs_.getOrDefault<word>("U", "U");
129  }
130 
131  applied_.setSize(fieldNames_.size(), false);
132 
133  return true;
134  }
135 
136  return false;
137 }
138 
139 
140 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fv::cellSetOption
Cell-set options abstract base class. Provides a base set of controls, e.g.:
Definition: cellSetOption.H:72
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:290
porosityModel.H
rho
rho
Definition: readInitialConditions.H:88
Foam::fvMatrix::psi
const GeometricField< Type, fvPatchField, volMesh > & psi() const
Definition: fvMatrix.H:285
fvMatrices.H
A special matrix type and solver, designed for finite volume solutions of scalar equations.
explicitPorositySource.H
Foam::fv::explicitPorositySource::addSup
virtual void addSup(fvMatrix< vector > &eqn, const label fieldi)
Add implicit contribution to momentum equation.
Definition: explicitPorositySource.C:83
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::fv::option::coeffs_
dictionary coeffs_
Dictionary containing source coefficients.
Definition: fvOption.H:88
Foam::fv::option::fieldNames_
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition: fvOption.H:94
Foam::fv::cellSetOption::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: cellSetOption.C:255
Foam::List::resize
void resize(const label newSize)
Adjust allocated size of list.
Definition: ListI.H:139
Foam::blockMeshTools::read
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:33
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
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:84
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:76
Foam::fv::explicitPorositySource::read
virtual bool read(const dictionary &dict)
Read dictionary.
Definition: explicitPorositySource.C:121
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(atmAmbientTurbSource, 0)
Foam::fv::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, atmAmbientTurbSource, dictionary)
Foam::fv::option::applied_
List< bool > applied_
Applied flag list - corresponds to each fieldNames_ entry.
Definition: fvOption.H:97
Foam::List::setSize
void setSize(const label newSize)
Alias for resize(const label)
Definition: ListI.H:146
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:122
Foam::GeometricField< scalar, fvPatchField, volMesh >
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:417