ExplicitSetValue.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) 2011-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 "ExplicitSetValue.H"
27 #include "fvMesh.H"
28 #include "fvMatrices.H"
29 #include "DimensionedField.H"
30 
31 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
32 
33 template<class Type>
35 {
36  fieldNames_.setSize(dict.toc().size());
37  injectionRate_.setSize(fieldNames_.size());
38 
39  applied_.setSize(fieldNames_.size(), false);
40 
41  label i = 0;
43  {
44  fieldNames_[i] = iter().keyword();
45  dict.lookup(iter().keyword()) >> injectionRate_[i];
46  i++;
47  }
48 }
49 
50 
51 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
52 
53 template<class Type>
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  injectionRate_()
64 {
65  read(dict);
66 }
67 
68 
69 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
70 
71 template<class Type>
73 (
74  fvMatrix<Type>& eqn,
75  const label fieldI
76 )
77 {
78  if (debug)
79  {
80  Info<< "ExplicitSetValue<"<< pTraits<Type>::typeName
81  << ">::constrain for source " << name_ << endl;
82  }
83 
84  List<Type> values(cells_.size(), injectionRate_[fieldI]);
85 
86  eqn.setValues(cells_, values);
87 }
88 
89 
90 // ************************************************************************* //
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::fv::cellSetOption
Cell-set options abtract base class. Provides a base set of controls, e.g.
Definition: cellSetOption.H:71
DimensionedField.H
Foam::read
bool read(const char *, int32_t &)
Definition: int32IO.C:87
ExplicitSetValue.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
forAllConstIter
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:39
fvMatrices.H
A special matrix type and solver, designed for finite volume solutions of scalar equations.
Foam::fvMatrix::setValues
void setValues(const labelUList &cells, const UList< Type > &values)
Set solution in given cells to the specified values.
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
Foam::fv::ExplicitSetValue::constrain
virtual void constrain(fvMatrix< Type > &eqn, const label fieldI)
Set value on field.
Definition: ExplicitSetValue.C:73
Foam::Info
messageStream Info
Foam::fv::ExplicitSetValue::setFieldData
void setFieldData(const dictionary &dict)
Set the local field data.
Definition: ExplicitSetValue.C:34
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
Foam::fv::ExplicitSetValue::ExplicitSetValue
ExplicitSetValue(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Definition: ExplicitSetValue.C:55
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
fvMesh.H
Foam::List< Type >
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:50
Foam::fvMatrix< Type >
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47