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  Copyright (C) 2020-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "FixedValueConstraint.H"
30 #include "fvMesh.H"
31 #include "fvMatrices.H"
32 #include "DimensionedField.H"
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
36 template<class Type>
38 (
39  const word& name,
40  const word& modelType,
41  const dictionary& dict,
42  const fvMesh& mesh
43 )
44 :
45  fv::cellSetOption(name, modelType, dict, mesh)
46 {
47  read(dict);
48 }
49 
50 
51 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
52 
53 template<class Type>
55 {
57  {
58  const dictionary& fieldValuesDict = coeffs_.subDict("fieldValues");
59 
60  label count = fieldValuesDict.size();
61 
62  fieldNames_.resize(count);
63  fieldValues_.resize(count);
64 
65  fv::option::resetApplied();
66 
67  count = 0;
68  for (const entry& dEntry : fieldValuesDict)
69  {
70  fieldNames_[count] = dEntry.keyword();
71  dEntry.readEntry(fieldValues_[count]);
72 
73  ++count;
74  }
75 
76  return true;
77  }
78 
79  return false;
80 }
81 
82 
83 template<class Type>
85 (
86  fvMatrix<Type>& eqn,
87  const label fieldi
88 )
89 {
90  DebugInfo
91  << "FixedValueConstraint<"
93  << ">::constrain for source " << name_ << endl;
94 
95  eqn.setValues(cells_, fieldValues_[fieldi]);
96 }
97 
98 
99 // ************************************************************************* //
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:65
Foam::fv::cellSetOption
Intermediate abstract class for handling cell-set options for the derived fvOptions.
Definition: cellSetOption.H:163
DimensionedField.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::fv::FixedValueConstraint::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: FixedValueConstraint.C:54
fvMatrices.H
A special matrix type and solver, designed for finite volume solutions of scalar equations.
Foam::blockMeshTools::read
void read(Istream &, label &val, const dictionary &)
In-place read with dictionary lookup.
Definition: blockMeshTools.C:57
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:460
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:38
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:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
fvMesh.H
Foam::fvMatrix::setValues
void setValues(const labelUList &cellLabels, const Type &value)
Definition: fvMatrix.C:1059
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:382
Foam::BitOps::count
unsigned int count(const UList< bool > &bools, const bool val=true)
Count number of 'true' entries.
Definition: BitOps.H:77
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:56
Foam::fv::FixedValueConstraint::constrain
virtual void constrain(fvMatrix< Type > &eqn, const label fieldi)
Set value on field.
Definition: FixedValueConstraint.C:85
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:68
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59