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-2025 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  cellZone porosity;
38 
39  fieldValues
40  {
41  k 1;
42  epsilon 150;
43  }
44  }
45  \endverbatim
46 
47 SourceFiles
48  fixedValueConstraint.C
49 
50 \*---------------------------------------------------------------------------*/
51 
52 #ifndef fixedValueConstraint_H
53 #define fixedValueConstraint_H
54 
55 #include "fvConstraint.H"
56 #include "fvCellZone.H"
57 #include "unknownTypeFunction1.H"
58 #include "HashPtrTable.H"
59 
60 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
61 
62 namespace Foam
63 {
64 namespace fv
65 {
66 
67 /*---------------------------------------------------------------------------*\
68  Class fixedValueConstraint Declaration
69 \*---------------------------------------------------------------------------*/
70 
72 :
73  public fvConstraint
74 {
75  // Private Member Data
76 
77  //- The cellZone the fvConstraint applies to
78  fvCellZone zone_;
79 
80  //- Field values
82 
83  //- Fraction of the constraint to apply. Facilitates ramping, or
84  // pulsing, or deactivation after a time. Should take a value between
85  // 0 and 1. Defaults to 1 (i.e., apply all of the constraint).
86  autoPtr<Function1<scalar>> fraction_;
87 
88 
89  // Private Member Functions
90 
91  //- Non-virtual read
92  void readCoeffs(const dictionary& dict);
93 
94  //- Set value on a field
95  template<class Type>
96  inline bool constrainType
97  (
98  fvMatrix<Type>& eqn,
99  const word& fieldName
100  ) const;
101 
102 
103 public:
104 
105  //- Runtime type information
106  TypeName("fixedValue");
107 
108 
109  // Constructors
110 
111  //- Construct from components
113  (
114  const word& name,
115  const word& modelType,
116  const fvMesh& mesh,
117  const dictionary& dict
118  );
119 
120 
121  // Member Functions
122 
123  //- Return the list of fields constrained by the fvConstraint
124  virtual wordList constrainedFields() const;
125 
126  //- Add a constraint to an equation
128 
129  //- Update for mesh motion
130  virtual bool movePoints();
131 
132  //- Update topology using the given map
133  virtual void topoChange(const polyTopoChangeMap&);
134 
135  //- Update from another mesh using the given map
136  virtual void mapMesh(const polyMeshMap&);
137 
138  //- Redistribute or update using the given distribution map
139  virtual void distribute(const polyDistributionMap&);
140 
141  //- Read source dictionary
142  virtual bool read(const dictionary& dict);
143 };
144 
145 
146 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 
148 } // End namespace fv
149 } // End namespace Foam
150 
151 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
152 
153 #endif
154 
155 // ************************************************************************* //
A HashTable specialisation for hashing pointers.
Definition: HashPtrTable.H:67
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: autoPtr.H:51
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
cellZone selection or generation class with caching of zone volume
Definition: fvCellZone.H:94
Finite volume options abstract base class.
Definition: fvConstraint.H:57
const fvMesh & mesh() const
Return const access to the mesh database.
Definition: fvConstraintI.H:34
const word & name() const
Return const access to the source name.
Definition: fvConstraintI.H:28
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Definition: fvMatrix.H:118
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:96
Constrain the field values within a specified region.
virtual bool movePoints()
Update for mesh motion.
fixedValueConstraint(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from components.
TypeName("fixedValue")
Runtime type information.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
virtual bool read(const dictionary &dict)
Read source dictionary.
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
FOR_ALL_FIELD_TYPES(DEFINE_FV_CONSTRAINT_CONSTRAIN)
Add a constraint to an equation.
virtual wordList constrainedFields() const
Return the list of fields constrained by the fvConstraint.
Class containing mesh-to-mesh mapping information after a mesh distribution where we send parts of me...
Class containing mesh-to-mesh mapping information.
Definition: polyMeshMap.H:51
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
A class for handling words, derived from string.
Definition: word.H:62
#define DEFINE_FV_CONSTRAINT_CONSTRAIN(Type, nullArg)
Definition: fvConstraintM.H:26
Namespace for OpenFOAM.
labelList fv(nPoints)
dictionary dict