1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
29 A storage mechanism which allows setting of the fixed value and
30 consequently recovering the equation for a single row of the matrix as
31 well as the source. The equation is taken out of the matrix using a
32 variant of compact matrix storage mechanism.
37 \*---------------------------------------------------------------------------*/
42 #include "labelList.H"
43 #include "scalarField.H"
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
54 Ostream& operator<<(Ostream&, const constraint<Type>&);
57 /*---------------------------------------------------------------------------*\
58 Class constraint Declaration
59 \*---------------------------------------------------------------------------*/
72 //- Fixed components (0-1) 1 = fixed, 0 = free
73 Type fixedComponents_;
75 //- Are matrix coefficients set?
76 bool matrixCoeffsSet_;
78 //- Diagonal coefficient
84 //- Upper coefficients
85 scalarField* upperCoeffsOwnerPtr_;
87 scalarField* upperCoeffsNeighbourPtr_;
89 //- Lower coefficients
90 scalarField* lowerCoeffsOwnerPtr_;
92 scalarField* lowerCoeffsNeighbourPtr_;
94 // Private Member Functions
96 //- Return scalar component of value. Used to simplify templating
97 scalar componentOfValue(const Type&, const direction) const;
105 //- Construct from components
110 const Type& fixedCmpts = pTraits<Type>::one
113 //- Construct from matrix and other components
114 template<template<class> class Matrix>
120 const Type& fixedCmpts = pTraits<Type>::one
123 //- Construct as copy
124 constraint(const constraint&);
126 //- Construct from Istream
127 constraint(Istream&);
137 //- Return matrix row ID
143 //- Return fixed value
149 //- Return map of fixed components
150 const Type& fixedComponents() const
152 return fixedComponents_;
155 //- Return diagonal coefficient
156 scalar diagCoeff() const;
161 //- Return off-diagonal coefficients
162 const scalarField& upperCoeffsOwner() const;
164 const scalarField& upperCoeffsNeighbour() const;
166 const scalarField& lowerCoeffsOwner() const;
168 const scalarField& lowerCoeffsNeighbour() const;
170 //- Combine with existing equation
171 void combine(const constraint&);
173 //- Set matrix coefficients
174 template<template<class> class Matrix>
175 void setMatrix(const Matrix<Type>&);
178 //- Eliminate equation
179 template<template<class> class Matrix>
180 static void eliminateEquation(Matrix<Type>&, const label, const Type&);
182 //- Eliminate equation
183 template<template<class> class Matrix>
184 void eliminateEquation(Matrix<Type>&) const;
186 //- Eliminate component equation with given direction and
188 template<template<class> class Matrix>
189 void eliminateEquation
197 //- Set source in eliminated equation
198 template<template<class> class Matrix>
199 static void setSource(Matrix<Type>&, const label, const Type&);
201 //- Set source in eliminated equation
202 template<template<class> class Matrix>
203 void setSource(Matrix<Type>&) const;
205 //- Set source and diagonal in eliminated equation
206 template<template<class> class Matrix>
211 scalarField& psiCmpt,
212 scalarField& sourceCmpt
216 //- Reconstruct matrix coefficients
217 template<template<class> class Matrix>
218 void reconstructMatrix(Matrix<Type>&) const;
220 //- Clear matrix coefficients
226 void operator=(const constraint<Type>&);
231 friend Ostream& operator<< <Type>
234 const constraint<Type>&
239 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
241 } // End namespace Foam
243 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
246 # include "constraint.C"
247 # include "constraintTools.C"
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 #include "scalarConstraint.H"
254 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
258 // ************************************************************************* //