fvConstraint.C
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) 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 \*---------------------------------------------------------------------------*/
25 
26 #include "fvConstraint.H"
27 #include "volFields.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  defineTypeNameAndDebug(fvConstraint, 0);
34  defineRunTimeSelectionTable(fvConstraint, dictionary);
35 }
36 
37 
38 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
39 
40 template<class Type>
41 bool Foam::fvConstraint::constrainType
42 (
43  fvMatrix<Type>& eqn,
44  const word& fieldName
45 ) const
46 {
47  return false;
48 }
49 
50 
51 template<class Type>
52 bool Foam::fvConstraint::constrainType(VolField<Type>& field) const
53 {
54  return false;
55 }
56 
57 
58 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59 
61 (
62  const word& name,
63  const word& constraintType,
64  const dictionary& dict,
65  const fvMesh& mesh
66 )
67 :
68  name_(name),
69  constraintType_(constraintType),
70  mesh_(mesh),
71  dict_(dict),
72  coeffs_(dict.optionalSubDict(constraintType + "Coeffs"))
73 {
74  Info<< incrIndent << indent << "Name: " << name_
75  << endl << decrIndent;
76 }
77 
78 
79 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
80 
82 (
83  const word& name,
84  const dictionary& coeffs,
85  const fvMesh& mesh
86 )
87 {
88  const word constraintType(coeffs.lookup("type"));
89 
90  Info<< indent
91  << "Selecting finite volume constraint type " << constraintType << endl;
92 
93  libs.open
94  (
95  coeffs,
96  "libs",
97  dictionaryConstructorTablePtr_
98  );
99 
100  dictionaryConstructorTable::iterator cstrIter =
101  dictionaryConstructorTablePtr_->find(constraintType);
102 
103  if (cstrIter == dictionaryConstructorTablePtr_->end())
104  {
105  FatalIOErrorInFunction(coeffs)
106  << "Unknown fvConstraint " << constraintType << nl << nl
107  << "Valid fvConstraints are:" << nl
108  << dictionaryConstructorTablePtr_->sortedToc()
109  << exit(FatalIOError);
110  }
111 
112  return autoPtr<fvConstraint>
113  (
114  cstrIter()(name, constraintType, coeffs, mesh)
115  );
116 }
117 
118 
120 {}
121 
122 
123 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
124 
126 {
127  return wordList::null();
128 }
129 
130 
131 bool Foam::fvConstraint::constrainsField(const word& fieldName) const
132 {
133  return findIndex(constrainedFields(), fieldName) != -1;
134 }
135 
136 
138 
139 
141 
142 
144 {
145  coeffs_ = dict.optionalSubDict(constraintType_ + "Coeffs");
146 
147  return true;
148 }
149 
150 
152 {}
153 
154 
156 {
157  return true;
158 }
159 
160 
161 // ************************************************************************* //
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual void updateMesh(const mapPolyMesh &)
Update for mesh changes.
Definition: fvConstraint.C:151
static autoPtr< fvConstraint > New(const word &name, const dictionary &dict, const fvMesh &mesh)
Return a reference to the selected fvConstraint.
Definition: fvConstraint.C:82
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
virtual wordList constrainedFields() const
Return the list of constrained fields.
Definition: fvConstraint.C:125
FOR_ALL_FIELD_TYPES(IMPLEMENT_FV_CONSTRAINT_CONSTRAIN, fvConstraint)
static const List< word > & null()
Return a null List.
Definition: ListI.H:118
dlLibraryTable libs
Table of loaded dynamic libraries.
Class containing mesh-to-mesh mapping information after a change in polyMesh topology.
Definition: mapPolyMesh.H:158
virtual bool constrainsField(const word &fieldName) const
Return true if the given field is constrained.
Definition: fvConstraint.C:131
dynamicFvMesh & mesh
fvConstraint(const word &name, const word &constraintType, const dictionary &dict, const fvMesh &mesh)
Construct from components.
Definition: fvConstraint.C:61
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Definition: dictionary.C:1040
#define IMPLEMENT_FV_CONSTRAINT_CONSTRAIN(Type, constraintType)
Definition: fvConstraintM.H:33
A class for handling words, derived from string.
Definition: word.H:59
#define IMPLEMENT_FV_CONSTRAINT_CONSTRAIN_FIELD(Type, constraintType)
Definition: fvConstraintM.H:49
virtual bool movePoints()
Update for mesh motion.
Definition: fvConstraint.C:155
static const char nl
Definition: Ostream.H:260
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:335
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
messageStream Info
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
virtual bool read(const dictionary &dict)
Read source dictionary.
Definition: fvConstraint.C:143
rDeltaTY field()
virtual ~fvConstraint()
Destructor.
Definition: fvConstraint.C:119
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
Finite volume options abstract base class.
Definition: fvConstraint.H:54
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:844
IOerror FatalIOError