1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
28 A storage mechanism which allows setting of the fixed value and
29 consequently recovering the equation for a single row of the matrix as
30 well as the source. The equation is taken out of the matrix using a
31 variant of compact matrix storage mechanism.
36 \*---------------------------------------------------------------------------*/
41 #include "labelList.H"
42 #include "scalarField.H"
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
53 Ostream& operator<<(Ostream&, const constraint<Type>&);
56 /*---------------------------------------------------------------------------*\
57 Class constraint Declaration
58 \*---------------------------------------------------------------------------*/
71 //- Fixed components (0-1) 1 = fixed, 0 = free
72 Type fixedComponents_;
74 //- Are matrix coefficients set?
75 bool matrixCoeffsSet_;
77 //- Diagonal coefficient
83 //- Upper coefficients
84 scalarField* upperCoeffsOwnerPtr_;
86 scalarField* upperCoeffsNeighbourPtr_;
88 //- Lower coefficients
89 scalarField* lowerCoeffsOwnerPtr_;
91 scalarField* lowerCoeffsNeighbourPtr_;
93 // Private Member Functions
95 //- Return scalar component of value. Used to simplify templating
96 scalar componentOfValue(const Type&, const direction) const;
104 //- Construct from components
109 const Type& fixedCmpts = pTraits<Type>::one
112 //- Construct from matrix and other components
113 template<template<class> class Matrix>
119 const Type& fixedCmpts = pTraits<Type>::one
122 //- Construct as copy
123 constraint(const constraint&);
125 //- Construct from Istream
126 constraint(Istream&);
136 //- Return matrix row ID
142 //- Return fixed value
148 //- Return map of fixed components
149 const Type& fixedComponents() const
151 return fixedComponents_;
154 //- Return diagonal coefficient
155 scalar diagCoeff() const;
160 //- Return off-diagonal coefficients
161 const scalarField& upperCoeffsOwner() const;
163 const scalarField& upperCoeffsNeighbour() const;
165 const scalarField& lowerCoeffsOwner() const;
167 const scalarField& lowerCoeffsNeighbour() const;
169 //- Combine with existing equation
170 void combine(const constraint&);
172 //- Set matrix coefficients
173 template<template<class> class Matrix>
174 void setMatrix(const Matrix<Type>&);
177 //- Eliminate equation
178 template<template<class> class Matrix>
179 static void eliminateEquation(Matrix<Type>&, const label, const Type&);
181 //- Eliminate equation
182 template<template<class> class Matrix>
183 void eliminateEquation(Matrix<Type>&) const;
185 //- Eliminate component equation with given direction and
187 template<template<class> class Matrix>
188 void eliminateEquation
196 //- Set source in eliminated equation
197 template<template<class> class Matrix>
198 static void setSource(Matrix<Type>&, const label, const Type&);
200 //- Set source in eliminated equation
201 template<template<class> class Matrix>
202 void setSource(Matrix<Type>&) const;
204 //- Set source and diagonal in eliminated equation
205 template<template<class> class Matrix>
210 scalarField& psiCmpt,
211 scalarField& sourceCmpt
215 //- Reconstruct matrix coefficients
216 template<template<class> class Matrix>
217 void reconstructMatrix(Matrix<Type>&) const;
219 //- Clear matrix coefficients
225 void operator=(const constraint<Type>&);
230 friend Ostream& operator<< <Type>
233 const constraint<Type>&
238 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
240 } // End namespace Foam
242 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
245 # include "constraint.C"
246 # include "constraintTools.C"
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 #include "scalarConstraint.H"
253 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
257 // ************************************************************************* //