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 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  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_.setSize(count);
63  fieldValues_.setSize(count);
64  applied_.setSize(count, false);
65 
66  count = 0;
67  for (const entry& dEntry : fieldValuesDict)
68  {
69  fieldNames_[count] = dEntry.keyword();
70  dEntry.readEntry(fieldValues_[count]);
71 
72  ++count;
73  }
74 
75  return true;
76  }
77 
78  return false;
79 }
80 
81 
82 template<class Type>
84 (
85  fvMatrix<Type>& eqn,
86  const label fieldi
87 )
88 {
89  DebugInfo
90  << "FixedValueConstraint<"
92  << ">::constrain for source " << name_ << endl;
93 
94  eqn.setValues(cells_, fieldValues_[fieldi]);
95 }
96 
97 
98 // ************************************************************************* //
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
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:350
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::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:528
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
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:83
fvMesh.H
Foam::fvMatrix::setValues
void setValues(const labelUList &cellLabels, const Type &value)
Definition: fvMatrix.C:465
DebugInfo
#define DebugInfo
Report an information message using Foam::Info.
Definition: messageStream.H:359
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
Traits class for primitives.
Definition: pTraits.H:54
Foam::fv::FixedValueConstraint::constrain
virtual void constrain(fvMatrix< Type > &eqn, const label fieldi)
Set value on field.
Definition: FixedValueConstraint.C:84
Foam::fvMatrix
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvPatchField.H:76