explicitPorositySource.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2018 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  porosityPtr_.reset
65  (
67  (
68  name_,
69  mesh_,
70  coeffs_,
71  cellSetName_
72  ).ptr()
73  );
74 }
75 
76 
77 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
78 
80 (
81  fvMatrix<vector>& eqn,
82  const label fieldi
83 )
84 {
85  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
86  porosityPtr_->addResistance(porosityEqn);
87  eqn -= porosityEqn;
88 }
89 
90 
92 (
93  const volScalarField& rho,
94  fvMatrix<vector>& eqn,
95  const label fieldi
96 )
97 {
98  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
99  porosityPtr_->addResistance(porosityEqn);
100  eqn -= porosityEqn;
101 }
102 
103 
105 (
106  const volScalarField& alpha,
107  const volScalarField& rho,
108  fvMatrix<vector>& eqn,
109  const label fieldi
110 )
111 {
112  fvMatrix<vector> porosityEqn(eqn.psi(), eqn.dimensions());
113  porosityPtr_->addResistance(porosityEqn);
114  eqn -= alpha*porosityEqn;
115 }
116 
117 
119 {
120  if (cellSetOption::read(dict))
121  {
122  if (coeffs_.found("UNames"))
123  {
124  coeffs_.lookup("UNames") >> fieldNames_;
125  }
126  else if (coeffs_.found("U"))
127  {
128  word UName(coeffs_.lookup("U"));
129  fieldNames_ = wordList(1, UName);
130  }
131  else
132  {
133  fieldNames_ = wordList(1, "U");
134  }
135 
136  applied_.setSize(fieldNames_.size(), false);
137 
138  return true;
139  }
140  else
141  {
142  return false;
143  }
144 }
145 
146 
147 // ************************************************************************* //
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
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
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