FixedValueConstraint.H
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-2017 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 Class
28  Foam::fv::FixedValueConstraint
29 
30 Group
31  grpFvOptionsConstraints
32 
33 Description
34  Constrain values of given fields of \c Type with
35  a given maximum value within a specified region,
36  where \c <Type>=Scalar/Vector/SphericalTensor/SymmTensor/Tensor.
37 
38 Usage
39  Minimal example by using \c constant/fvOptions:
40  \verbatim
41  <Type>FixedValueConstraint1
42  {
43  // Mandatory entries (unmodifiable)
44  type <Type>FixedValueConstraint;
45 
46  // Mandatory entries (runtime modifiable)
47  fieldValues
48  {
49  <fieldName1> <value1>;
50  <fieldName2> <value2>;
51  ...
52  <fieldNameN> <valueN>;
53  }
54 
55  // Mandatory/Optional (inherited) entries
56  ...
57  }
58  \endverbatim
59 
60  where the entries mean:
61  \table
62  Property | Description | Type | Reqd | Dflt
63  type | Type name: <Type>FixedValueConstraint | word | yes | -
64  fieldValues | Dictionary containing pairs of names and maximum <!--
65  --> values of operand fields of <Type> | dictionary | yes | -
66  \endtable
67 
68  The inherited entries are elaborated in:
69  - \link fvOption.H \endlink
70  - \link cellSetOption.H \endlink
71 
72 
73  For example to set the turbulence properties within a porous region:
74  \verbatim
75  porosityTurbulence
76  {
77  type scalarFixedValueConstraint;
78  active yes;
79 
80  selectionMode cellZone;
81  cellZone porosity;
82  fieldValues
83  {
84  k 1;
85  epsilon 150;
86  }
87  }
88  \endverbatim
89 
90 See also
91  - Foam::fv::fixedTemperatureConstraint
92  - Foam::fv::velocityDampingConstraint
93 
94 SourceFiles
95  FixedValueConstraint.C
96  fixedValueConstraints.C
97 
98 \*---------------------------------------------------------------------------*/
99 
100 #ifndef FixedValueConstraint_H
101 #define FixedValueConstraint_H
102 
103 #include "cellSetOption.H"
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 namespace Foam
108 {
109 namespace fv
110 {
111 
112 /*---------------------------------------------------------------------------*\
113  Class FixedValueConstraint Declaration
114 \*---------------------------------------------------------------------------*/
115 
116 template<class Type>
117 class FixedValueConstraint
118 :
119  public fv::cellSetOption
120 {
121  // Private Data
122 
123  //- Field values
124  List<Type> fieldValues_;
125 
126 
127 public:
128 
129  //- Runtime type information
130  TypeName("FixedValueConstraint");
131 
132 
133  // Constructors
134 
135  //- Construct from components
137  (
138  const word& name,
139  const word& modelType,
140  const dictionary& dict,
141  const fvMesh& mesh
142  );
143 
144  //- No copy construct
146 
147  //- No copy assignment
148  void operator=(const FixedValueConstraint&) = delete;
149 
150 
151  //- Destructor
152  virtual ~FixedValueConstraint() = default;
153 
154 
155  // Member Functions
156 
157  //- Read source dictionary
158  virtual bool read(const dictionary& dict);
159 
160  //- Set value on field
161  virtual void constrain(fvMatrix<Type>& eqn, const label fieldi);
162 };
163 
164 
165 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 
167 } // End namespace fv
168 } // End namespace Foam
169 
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
171 
172 #ifdef NoRepository
173  #include "FixedValueConstraint.C"
174 #endif
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 #endif
179 
180 // ************************************************************************* //
Foam::fv::option::name
const word & name() const noexcept
Return const access to the source name.
Definition: fvOptionI.H:31
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
Foam::fv::FixedValueConstraint
Constrain values of given fields of Type with a given maximum value within a specified region,...
Definition: FixedValueConstraint.H:136
Foam::fv::FixedValueConstraint::read
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: FixedValueConstraint.C:54
cellSetOption.H
Foam::fv::FixedValueConstraint::operator=
void operator=(const FixedValueConstraint &)=delete
No copy assignment.
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
FixedValueConstraint.C
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fv::FixedValueConstraint::TypeName
TypeName("FixedValueConstraint")
Runtime type information.
fv
labelList fv(nPoints)
Foam::fv::option::mesh
const fvMesh & mesh() const noexcept
Return const access to the mesh database.
Definition: fvOptionI.H:37
Foam::List< Type >
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::fv::FixedValueConstraint::~FixedValueConstraint
virtual ~FixedValueConstraint()=default
Destructor.