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 | Copyright (C) 2012-2015 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 
26 #include "explicitPorositySource.H"
27 #include "fvMesh.H"
28 #include "fvMatrices.H"
29 #include "porosityModel.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace fv
37 {
38  defineTypeNameAndDebug(explicitPorositySource, 0);
40  (
41  option,
42  explicitPorositySource,
43  dictionary
44  );
45 }
46 }
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
52 (
53  const word& name,
54  const word& modelType,
55  const dictionary& dict,
56  const fvMesh& mesh
57 )
58 :
59  cellSetOption(name, modelType, dict, mesh),
60  porosityPtr_(NULL)
61 {
62  read(dict);
63 
64  if (selectionMode_ != smCellZone)
65  {
67  << "selection mode is " << selectionModeTypeNames_[selectionMode_]
68  << exit(FatalError);
69  }
70 
71  porosityPtr_.reset
72  (
74  (
75  name_,
76  mesh_,
77  coeffs_,
78  cellSetName_
79  ).ptr()
80  );
81 }
82 
83 
84 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
85 
87 (
88  fvMatrix<vector>& eqn,
89  const label fieldI
90 )
91 {
92  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
93  porosityPtr_->addResistance(porosityEqn);
94  eqn -= porosityEqn;
95 }
96 
97 
99 (
100  const volScalarField& rho,
101  fvMatrix<vector>& eqn,
102  const label fieldI
103 )
104 {
105  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
106  porosityPtr_->addResistance(porosityEqn);
107  eqn -= porosityEqn;
108 }
109 
110 
112 (
113  const volScalarField& alpha,
114  const volScalarField& rho,
115  fvMatrix<vector>& eqn,
116  const label fieldI
117 )
118 {
119  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
120  porosityPtr_->addResistance(porosityEqn);
121  eqn -= alpha*porosityEqn;
122 }
123 
124 
126 {
128  {
129  if (coeffs_.found("UNames"))
130  {
131  coeffs_.lookup("UNames") >> fieldNames_;
132  }
133  else if (coeffs_.found("UName"))
134  {
135  word UName(coeffs_.lookup("UName"));
136  fieldNames_ = wordList(1, UName);
137  }
138  else
139  {
140  fieldNames_ = wordList(1, "U");
141  }
142 
143  applied_.setSize(fieldNames_.size(), false);
144 
145  return true;
146  }
147  else
148  {
149  return false;
150  }
151 }
152 
153 
154 // ************************************************************************* //
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::compressible::New
autoPtr< BasicCompressibleTurbulenceModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const typename BasicCompressibleTurbulenceModel::transportModel &transport, const word &propertiesName)
Definition: turbulentFluidThermoModel.C:36
Foam::fv::cellSetOption
Cell-set options abtract base class. Provides a base set of controls, e.g.
Definition: cellSetOption.H:71
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:216
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
Foam::fvMatrix::dimensions
const dimensionSet & dimensions() const
Definition: fvMatrix.H:286
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
porosityModel.H
Foam::fvMatrix::psi
const GeometricField< Type, fvPatchField, volMesh > & psi() const
Definition: fvMatrix.H:281
fvMatrices.H
A special matrix type and solver, designed for finite volume solutions of scalar equations.
Foam::wordList
List< word > wordList
A List of words.
Definition: fileName.H:54
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
explicitPorositySource.H
Foam::dictionary::found
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:304
Foam::fv::option::coeffs_
dictionary coeffs_
Dictionary containing source coefficients.
Definition: fvOption.H:84
Foam::fv::option::fieldNames_
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition: fvOption.H:90
Foam::fv::cellSetOption::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: cellSetOptionIO.C:30
Foam::fv::explicitPorositySource::addSup
virtual void addSup(fvMatrix< vector > &eqn, const label fieldI)
Add implicit contribution to momentum equation.
Definition: explicitPorositySource.C:87
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
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:78
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
rho
rho
Definition: pEqn.H:3
fv
labelList fv(nPoints)
Foam::fv::defineTypeNameAndDebug
defineTypeNameAndDebug(option, 0)
Foam::List::setSize
void setSize(const label)
Reset size of List.
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::fv::addToRunTimeSelectionTable
addToRunTimeSelectionTable(option, fixedTemperatureConstraint, dictionary)
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:125
Foam::fv::explicitPorositySource::explicitPorositySource
explicitPorositySource(const explicitPorositySource &)
Disallow default bitwise copy construct.
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::fv::option::applied_
List< bool > applied_
Applied flag list - corresponds to each fieldNames_ entry.
Definition: fvOption.H:93
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47