fixedValueConstraint.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2016-2021 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::fv::fixedValueConstraint
26 
27 Description
28  Constrain the field values within a specified region.
29 
30 Usage
31  For example to set the turbulence properties within a porous region:
32  \verbatim
33  porosityTurbulence
34  {
35  type fixedValueConstraint;
36 
37  selectionMode cellZone;
38  cellZone porosity;
39 
40  fieldValues
41  {
42  k 1;
43  epsilon 150;
44  }
45  }
46  \endverbatim
47 
48 SourceFiles
49  fixedValueConstraint.C
50 
51 \*---------------------------------------------------------------------------*/
52 
53 #ifndef fixedValueConstraint_H
54 #define fixedValueConstraint_H
55 
56 #include "fvConstraint.H"
57 #include "fvCellSet.H"
58 #include "objectFunction1.H"
59 #include "HashPtrTable.H"
60 
61 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
62 
63 namespace Foam
64 {
65 namespace fv
66 {
67 
68 /*---------------------------------------------------------------------------*\
69  Class fixedValueConstraint Declaration
70 \*---------------------------------------------------------------------------*/
71 
73 :
74  public fvConstraint
75 {
76  // Private Member Data
77 
78  //- The set of cells the fvConstraint applies to
79  fvCellSet set_;
80 
81  //- Field values
82  HashPtrTable<objectFunction1> fieldValues_;
83 
84 
85  // Private Member Functions
86 
87  //- Non-virtual read
88  void readCoeffs();
89 
90  //- Set value on a field
91  template<class Type>
92  bool constrainType(fvMatrix<Type>& eqn, const word& fieldName) const;
93 
94 
95 public:
96 
97  //- Runtime type information
98  TypeName("fixedValueConstraint");
99 
100 
101  // Constructors
102 
103  //- Construct from components
105  (
106  const word& name,
107  const word& modelType,
108  const dictionary& dict,
109  const fvMesh& mesh
110  );
111 
112 
113  // Member Functions
114 
115  //- Return the list of fields constrained by the fvConstraint
116  virtual wordList constrainedFields() const;
117 
118  //- Add a constraint to an equation
120 
121  //- Update for mesh changes
122  virtual void updateMesh(const mapPolyMesh&);
123 
124  //- Read source dictionary
125  virtual bool read(const dictionary& dict);
126 };
127 
128 
129 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 
131 } // End namespace fv
132 } // End namespace Foam
133 
134 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
135 
136 #endif
137 
138 // ************************************************************************* //
dictionary dict
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvConstraintI.H:34
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
Cell-set fvConstraint abstract base class. Provides a base set of controls regarding the location whe...
Constrain the field values within a specified region.
TypeName("fixedValueConstraint")
Runtime type information.
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:50
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual void updateMesh(const mapPolyMesh &)
Update for mesh changes.
virtual wordList constrainedFields() const
Return the list of fields constrained by the fvConstraint.
#define DEFINE_FV_CONSTRAINT_CONSTRAIN(Type, nullArg)
Definition: fvConstraintM.H:26
const word & name() const
Return const access to the source name.
Definition: fvConstraintI.H:28
virtual bool read(const dictionary &dict)
Read source dictionary.
A class for handling words, derived from string.
Definition: word.H:59
labelList fv(nPoints)
A special matrix type and solver, designed for finite volume solutions of scalar equations. Face addressing is used to make all matrix assembly and solution loops vectorise.
Definition: fvPatchField.H:72
fixedValueConstraint(const word &name, const word &modelType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
FOR_ALL_FIELD_TYPES(DEFINE_FV_CONSTRAINT_CONSTRAIN)
Add a constraint to an equation.
Finite volume options abstract base class.
Definition: fvConstraint.H:54
Namespace for OpenFOAM.