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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "FixedValueConstraint.H"
29 #include "fvMesh.H"
30 #include "fvMatrices.H"
31 #include "DimensionedField.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template<class Type>
37 (
38  const word& name,
39  const word& modelType,
40  const dictionary& dict,
41  const fvMesh& mesh
42 )
43 :
44  cellSetOption(name, modelType, dict, mesh)
45 {
46  read(dict);
47 }
48 
49 
50 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
51 
52 template<class Type>
54 {
56  {
57  const dictionary& fieldValuesDict = coeffs_.subDict("fieldValues");
58 
59  label count = fieldValuesDict.size();
60 
61  fieldNames_.setSize(count);
62  fieldValues_.setSize(count);
63  applied_.setSize(count, false);
64 
65  count = 0;
66  for (const entry& dEntry : fieldValuesDict)
67  {
68  fieldNames_[count] = dEntry.keyword();
69  dEntry.readEntry(fieldValues_[count]);
70 
71  ++count;
72  }
73 
74  return true;
75  }
76 
77  return false;
78 }
79 
80 
81 template<class Type>
83 (
84  fvMatrix<Type>& eqn,
85  const label fieldi
86 )
87 {
88  DebugInfo
89  << "FixedValueConstraint<"
91  << ">::constrain for source " << name_ << endl;
92 
93  eqn.setValues(cells_, List<Type>(cells_.size(), fieldValues_[fieldi]));
94 }
95 
96 
97 // ************************************************************************* //
Foam::entry
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:67
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fv::cellSetOption
Cell-set options abtract base class. Provides a base set of controls, e.g.:
Definition: cellSetOption.H:72
DimensionedField.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::fv::FixedValueConstraint::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: FixedValueConstraint.C:53
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.
Definition: fvMatrix.C:487
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:62
Foam::name
word name(const complex &c)
Return string representation of complex.
Definition: complex.C:76
Foam::dictionary::subDict
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:523
FixedValueConstraint.H
Foam::fv::FixedValueConstraint::FixedValueConstraint
FixedValueConstraint(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Definition: FixedValueConstraint.C:37
Foam::blockMeshTools::read
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:33
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:84
fvMesh.H
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:350
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:74
Foam::List< Type >
Foam::pTraits
Traits class for primitives.
Definition: pTraits.H:52
Foam::fv::FixedValueConstraint::constrain
virtual void constrain(fvMatrix< Type > &eqn, const label fieldi)
Set value on field.
Definition: FixedValueConstraint.C:83
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:76