Loading...
Searching...
No Matches
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{
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// ************************************************************************* //
label size() const noexcept
The number of elements in list.
Definition DLListBase.H:194
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
Definition dictionary.C:441
A keyword and a list of tokens is an 'entry'.
Definition entry.H:66
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition fvMatrix.H:118
void setValues(const labelUList &cellLabels, const Type &value)
Set solution in given cells to the specified value and eliminate the corresponding equations from the...
Definition fvMatrix.C:971
Mesh data needed to do the Finite Volume discretisation.
Definition fvMesh.H:85
FixedValueConstraint(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
virtual bool read(const dictionary &dict)
Read source dictionary.
virtual void constrain(fvMatrix< Type > &eqn, const label fieldi)
Set value on field.
labelList cells_
Set of cells to apply source to.
virtual bool read(const dictionary &dict)
Read source dictionary.
cellSetOption(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
const word & name() const noexcept
Return const access to the source name.
Definition fvOptionI.H:24
wordList fieldNames_
Field names to apply source to - populated by derived models.
Definition fvOption.H:157
dictionary coeffs_
Dictionary containing source coefficients.
Definition fvOption.H:152
void resetApplied()
Resize/reset applied flag list for all fieldNames_ entries.
Definition fvOption.C:41
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition fvOptionI.H:30
const word name_
Source name.
Definition fvOption.H:132
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
A class for handling words, derived from Foam::string.
Definition word.H:66
A special matrix type and solver, designed for finite volume solutions of scalar equations.
#define DebugInfo
Report an information message using Foam::Info.
Namespace for finite-volume.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
dictionary dict