limitMag.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::limitMag
26 
27 Description
28  Limits the magnitude of the specified field to the specified \c max value.
29 
30 Usage
31  Example usage:
32  \verbatim
33  limitU
34  {
35  type limitMag;
36 
37  select all;
38 
39  field U;
40 
41  max 100;
42  }
43  \endverbatim
44 
45 SourceFiles
46  limitMag.C
47 
48 \*---------------------------------------------------------------------------*/
49 
50 #ifndef limitMag_H
51 #define limitMag_H
52 
53 #include "fvConstraint.H"
54 #include "fvCellSet.H"
55 
56 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57 
58 namespace Foam
59 {
60 namespace fv
61 {
62 
63 /*---------------------------------------------------------------------------*\
64  Class limitMag Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class limitMag
68 :
69  public fvConstraint
70 {
71  // Private data
72 
73  //- The set of cells the fvConstraint applies to
74  fvCellSet set_;
75 
76  //- Field name
77  word fieldName_;
78 
79  //- Maximum velocity magnitude
80  scalar max_;
81 
82 
83  // Private Member Functions
84 
85  //- Non-virtual read
86  void readCoeffs();
87 
88  //- Limit the field
89  template<class Type>
90  inline bool constrainType
91  (
93  ) const;
94 
95 
96 public:
97 
98  //- Runtime type information
99  TypeName("limitMag");
100 
101 
102  // Constructors
103 
104  //- Construct from components
105  limitMag
106  (
107  const word& name,
108  const word& modelType,
109  const fvMesh& mesh,
110  const dictionary& dict
111  );
112 
113  //- Disallow default bitwise copy construction
114  limitMag(const limitMag&) = delete;
115 
116 
117  //- Destructor
118  virtual ~limitMag()
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 dictionary
143  virtual bool read(const dictionary& dict);
144 
145 
146  // Member Operators
147 
148  //- Disallow default bitwise assignment
149  void operator=(const limitMag&) = delete;
150 };
151 
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 } // End namespace fv
156 } // End namespace Foam
157 
158 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
159 
160 #endif
161 
162 // ************************************************************************* //
Generic GeometricField class.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
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
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
Limits the magnitude of the specified field to the specified max value.
Definition: limitMag.H:69
virtual bool movePoints()
Update for mesh motion.
Definition: limitMag.C:143
TypeName("limitMag")
Runtime type information.
void operator=(const limitMag &)=delete
Disallow default bitwise assignment.
virtual void topoChange(const polyTopoChangeMap &)
Update topology using the given map.
Definition: limitMag.C:150
virtual void distribute(const polyDistributionMap &)
Redistribute or update using the given distribution map.
Definition: limitMag.C:162
virtual bool read(const dictionary &dict)
Read dictionary.
Definition: limitMag.C:168
virtual ~limitMag()
Destructor.
Definition: limitMag.H:117
virtual void mapMesh(const polyMeshMap &)
Update from another mesh using the given map.
Definition: limitMag.C:156
limitMag(const word &name, const word &modelType, const fvMesh &mesh, const dictionary &dict)
Construct from components.
Definition: limitMag.C:112
virtual wordList constrainedFields() const
Return the list of fields constrained by the fvConstraint.
Definition: limitMag.C:130
FOR_ALL_FIELD_TYPES(DEFINE_FV_CONSTRAINT_CONSTRAIN_FIELD)
Add a constraint to an equation.
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_FIELD(Type, nullArg)
Definition: fvConstraintM.H:46
const volScalarField & psi
Namespace for OpenFOAM.
labelList fv(nPoints)
dictionary dict