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-2016 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 
51 Foam::fv::explicitPorositySource::explicitPorositySource
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_(nullptr)
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 {
127  if (cellSetOption::read(dict))
128  {
129  if (coeffs_.found("UNames"))
130  {
131  coeffs_.lookup("UNames") >> fieldNames_;
132  }
133  else if (coeffs_.found("U"))
134  {
135  word UName(coeffs_.lookup("U"));
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 // ************************************************************************* //
defineTypeNameAndDebug(option, 0)
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
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
const GeometricField< Type, fvPatchField, volMesh > & psi() const
Definition: fvMatrix.H:284
addToRunTimeSelectionTable(option, fixedTemperatureConstraint, dictionary)
virtual bool read(const dictionary &dict)
Read source dictionary.
Macros for easy insertion into run-time selection tables.
bool read(const char *, int32_t &)
Definition: int32IO.C:85
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
virtual bool read(const dictionary &dict)
Read dictionary.
virtual void addSup(fvMatrix< vector > &eqn, const label fieldi)
Add implicit contribution to momentum equation.
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
List< word > wordList
A List of words.
Definition: fileName.H:54
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
A special matrix type and solver, designed for finite volume solutions of scalar equations.
Cell-set options abtract base class. Provides a base set of controls, e.g.:
Definition: cellSetOption.H:69
static autoPtr< porosityModel > New(const word &name, const fvMesh &mesh, const dictionary &dict, const word &cellZoneName=word::null)
Selector.
Namespace for OpenFOAM.
const dimensionSet & dimensions() const
Definition: fvMatrix.H:289