FixedValueConstraint.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) 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 "FixedValueConstraint.H"
27 #include "fvMesh.H"
28 #include "fvMatrices.H"
29 #include "DimensionedField.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const word& name,
37  const word& modelType,
38  const dictionary& dict,
39  const fvMesh& mesh
40 )
41 :
42  cellSetOption(name, modelType, dict, mesh)
43 {
44  read(dict);
45 }
46 
47 
48 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
49 
50 template<class Type>
52 {
53  if (cellSetOption::read(dict))
54  {
55  const dictionary& fieldValuesDict = coeffs_.subDict("fieldValues");
56 
57  fieldNames_.setSize(fieldValuesDict.size());
58  fieldValues_.setSize(fieldNames_.size());
59 
60  label i = 0;
61  forAllConstIter(dictionary, fieldValuesDict, iter)
62  {
63  fieldNames_[i] = iter().keyword();
64  fieldValuesDict.lookup(iter().keyword()) >> fieldValues_[i];
65  i++;
66  }
67 
68  applied_.setSize(fieldNames_.size(), false);
69 
70  return true;
71  }
72  else
73  {
74  return false;
75  }
76 }
77 
78 
79 template<class Type>
81 (
82  fvMatrix<Type>& eqn,
83  const label fieldi
84 )
85 {
86  DebugInfo
87  << "FixedValueConstraint<"
89  << ">::constrain for source " << name_ << endl;
90 
91  eqn.setValues(cells_, List<Type>(cells_.size(), fieldValues_[fieldi]));
92 }
93 
94 
95 // ************************************************************************* //
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 dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:633
FixedValueConstraint(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
Traits class for primitives.
Definition: pTraits.H:50
virtual void constrain(fvMatrix< Type > &eqn, const label fieldi)
Set value on field.
label size() const
Return number of elements in list.
Definition: DLListBaseI.H:77
bool read(const char *, int32_t &)
Definition: int32IO.C:85
A class for handling words, derived from string.
Definition: word.H:59
void setValues(const labelUList &cells, const UList< Type > &values)
Set solution in given cells to the specified values.
Definition: fvMatrix.C:474
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:71
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
#define DebugInfo
Report an information message using Foam::Info.
void setSize(const label)
Reset size of List.
Definition: List.C:295
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:72
virtual bool read(const dictionary &dict)
Read source dictionary.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:451