fvConstraintsTemplates.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 // * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
27 
28 template<class Type>
30 {
31  checkApplied();
32 
33  const PtrListDictionary<fvConstraint>& constraintList(*this);
34 
35  bool constrained = false;
36 
37  forAll(constraintList, i)
38  {
39  const fvConstraint& constraint = constraintList[i];
40 
41  if (constraint.constrainsField(eqn.psi().name()))
42  {
43  constrainedFields_[i].insert(eqn.psi().name());
44 
45  if (debug)
46  {
47  Info<< "Applying constraint " << constraint.name()
48  << " to field " << eqn.psi().name() << endl;
49  }
50 
51  constrained =
52  constraint.constrain(eqn, eqn.psi().name()) || constrained;
53  }
54  }
55 
56  return constrained;
57 }
58 
59 
60 template<class Type>
62 (
64 ) const
65 {
66  const word& fieldName = field.name();
67 
68  const PtrListDictionary<fvConstraint>& constraintList(*this);
69 
70  bool constrained = false;
71 
72  forAll(constraintList, i)
73  {
74  const fvConstraint& constraint = constraintList[i];
75 
76  if (constraint.constrainsField(fieldName))
77  {
78  constrainedFields_[i].insert(fieldName);
79 
80  if (debug)
81  {
82  Info<< "Applying constraint " << constraint.name()
83  << " for field " << fieldName << endl;
84  }
85 
86  constrained =
87  constraint.constrain(field) || constrained;
88  }
89  }
90 
91  return constrained;
92 }
93 
94 
95 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
const word & name() const
Return name.
Definition: IOobject.H:315
const GeometricField< Type, fvPatchField, volMesh > & psi() const
Definition: fvMatrix.H:290
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Generic GeometricField class.
virtual bool constrainsField(const word &fieldName) const
Return true if the given field is constrained.
Definition: fvConstraint.C:131
const word & name() const
Return const access to the source name.
Definition: fvConstraintI.H:28
A class for handling words, derived from string.
Definition: word.H:59
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
const bool constrained
Definition: pEqn.H:108
bool constrain(fvMatrix< Type > &eqn) const
Apply constraints to an equation.
messageStream Info
Finite volume options abstract base class.
Definition: fvConstraint.H:56