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-------------------------------------------------------------------------------
11License
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
30#include "fvMesh.H"
31#include "fvMatrices.H"
32#include "DimensionedField.H"
33
34// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35
36template<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
53template<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
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
83template<class Type>
85(
86 fvMatrix<Type>& eqn,
87 const label fieldi
88)
89{
91 << "FixedValueConstraint<"
93 << ">::constrain for source " << name_ << endl;
94
95 eqn.setValues(cells_, fieldValues_[fieldi]);
96}
97
98
99// ************************************************************************* //
virtual bool read()
Re-read model coefficients if they have changed.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition: dictionary.C:460
A keyword and a list of tokens is an 'entry'.
Definition: entry.H:70
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:121
void setValues(const labelUList &cellLabels, const Type &value)
Definition: fvMatrix.C:969
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Constrain values of given fields of Type with a given maximum value within a specified region,...
virtual bool read(const dictionary &dict)
Read source dictionary.
virtual void constrain(fvMatrix< Type > &eqn, const label fieldi)
Set value on field.
Intermediate abstract class for handling cell-set options for the derived fvOptions.
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition: fvOption.C:48
A traits class, which is primarily used for primitives.
Definition: pTraits.H:59
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
A special matrix type and solver, designed for finite volume solutions of scalar equations.
#define DebugInfo
Report an information message using Foam::Info.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
labelList fv(nPoints)
dictionary dict