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-2023 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  select 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 "unknownTypeFunction1.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
83 
84  //- Fraction of the constraint to apply. Facilitates ramping, or
85  // pulsing, or deactivation after a time. Should take a value between
86  // 0 and 1. Defaults to 1 (i.e., apply all of the constraint).
87  autoPtr<Function1<scalar>> fraction_;
88 
89 
90  // Private Member Functions
91 
92  //- Non-virtual read
93  void readCoeffs();
94 
95  //- Set value on a field
96  template<class Type>
97  inline bool constrainType
98  (
99  fvMatrix<Type>& eqn,
100  const word& fieldName
101  ) const;
102 
103 
104 public:
105 
106  //- Runtime type information
107  TypeName("fixedValueConstraint");
108 
109 
110  // Constructors
111 
112  //- Construct from components
114  (
115  const word& name,
116  const word& modelType,
117  const fvMesh& mesh,
118  const dictionary& dict
119  );
120 
121 
122  // Member Functions
123 
124  //- Return the list of fields constrained by the fvConstraint
125  virtual wordList constrainedFields() const;
126 
127  //- Add a constraint to an equation
129 
130  //- Update for mesh motion
131  virtual bool movePoints();
132 
133  //- Update topology using the given map
134  virtual void topoChange(const polyTopoChangeMap&);
135 
136  //- Update from another mesh using the given map
137  virtual void mapMesh(const polyMeshMap&);
138 
139  //- Redistribute or update using the given distribution map
140  virtual void distribute(const polyDistributionMap&);
141 
142  //- Read source dictionary
143  virtual bool read(const dictionary& dict);
144 };
145 
146 
147 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
148 
149 } // End namespace fv
150 } // End namespace Foam
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #endif
155 
156 // ************************************************************************* //
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 keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:160
General run-time selected cell set selection class for fvMesh.
Definition: fvCellSet.H:88
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:101
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("fixedValueConstraint")
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