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 Block matrix insertion and retrieval tools.
29 Note: these will be obsolete since all of the functions are now member
30 functions in fvBlockMatrix class. All top level coupled solvers should
31 be rewritten using fvBlockMatrix - then we can get rid of this.
37 \*---------------------------------------------------------------------------*/
40 #ifndef blockMatrixTools_H
41 #define blockMatrixTools_H
43 #include "BlockLduSystem.H"
44 #include "fvMatrices.H"
45 #include "surfaceFieldsFwd.H"
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 /*---------------------------------------------------------------------------*\
53 Namespace blockMatrixTools functions Declaration
54 \*---------------------------------------------------------------------------*/
56 namespace blockMatrixTools
60 //- Insert field into block field
61 template<class BlockType>
66 Field<BlockType>& blockX
69 //- Add field into block field
70 template<class BlockType>
75 Field<BlockType>& blockX
78 //- Retrieve field from block field
79 template<class BlockType>
84 const Field<BlockType>& blockX
88 // Diagonal block operations
90 //- Insert matrix diagonal and source into the block system
91 template<class BlockType>
95 const fvScalarMatrix& m,
96 BlockLduMatrix<BlockType>& blockM,
97 Field<BlockType>& blockB
100 // Insert upper and lower coefficients matrix into the block system
101 template<class Type, class BlockType>
102 void insertUpperLower
105 const fvScalarMatrix& m,
106 BlockLduMatrix<BlockType>& blockM
109 // Insert matrix into the block system
110 template<class BlockType>
114 const fvScalarMatrix& m,
115 BlockLduMatrix<BlockType>& blockM,
116 Field<BlockType>& blockX,
117 Field<BlockType>& blockB
121 // Coupling block operations
123 //- Insert coupling matrix diagonal and source into the block system
124 template<class BlockType>
125 void insertCouplingDiagSource
127 const direction dirI,
128 const direction dirJ,
129 const fvScalarMatrix& m,
130 BlockLduMatrix<BlockType>& blockM,
131 Field<BlockType>& blockB
134 // Insert coupling matrix into the block system
135 template<class Type, class BlockType>
136 void insertCouplingUpperLower
138 const direction dirI,
139 const direction dirJ,
140 const fvScalarMatrix& m,
141 BlockLduMatrix<BlockType>& blockM
144 // Insert coupling matrix into the block system
145 template<class BlockType>
149 const fvScalarMatrix& m,
150 BlockLduMatrix<BlockType>& blockM,
151 Field<BlockType>& blockX,
152 Field<BlockType>& blockB
155 // Update coupling of block system
156 // Subtracts the block-coefficient coupling as specified by the user
157 // from the source, leaving the implicit update given by linearisation
158 template<class BlockType>
159 void updateSourceCoupling
161 BlockLduMatrix<BlockType>& blockM,
166 //- Tools specific to pU coupled block matrix
168 //- Insert field into block field to be solved for
169 template<class blockType, class fieldType>
170 void insertSolutionVector
173 const Field<fieldType>& xSingle,
174 Field<blockType>& xBlock
177 //- Retrieve solved field from block field
178 template<class blockType, class fieldType>
179 void retrieveSolution
182 Field<fieldType>& xSingle,
183 const Field<blockType>& xBlock
186 //- Insert matrix diagonal and source into the block system
187 template<class blockType, class matrixType>
188 void insertDiagSource
191 fvMatrix<matrixType>& matrix,
192 BlockLduMatrix<blockType>& A,
196 // Insert upper and lower part into the block system
197 template<class blockType, class matrixType>
198 void insertUpperLower
201 const fvMatrix<matrixType>& matrix,
202 BlockLduMatrix<blockType>& A
205 // Update coupling coefficients in the block matrix
206 template<class blockType, class matrixType>
207 void updateCouplingCoeffs
210 const fvMatrix<matrixType>& matrix,
211 BlockLduMatrix<blockType>& A
214 // Insert matrix into the block system
215 template<class blockType, class matrixType>
219 fvMatrix<matrixType>& matrix,
220 BlockLduMatrix<blockType>& A,
225 // Insert diagonal, lower and upper of blockMatrix into A
226 template<class blockType1, class fieldType, class blockType2>
231 const BlockLduSystem<blockType1, fieldType>& blockMatrix,
232 BlockLduMatrix<blockType2>& A,
236 // Insert source and coupling coeffs of block system into A and b
237 template<class blockType1, class blockType2, class fieldType>
238 void insertBoundaryContributions
242 const BlockLduSystem<blockType1, fieldType>& blockSystem,
243 BlockLduMatrix<blockType2>& A,
244 Field<blockType2>& b,
248 // Insert existing block system (obtained by implicit grad/div operator)
249 // into block system.
250 template<class blockType1, class blockType2, class fieldType>
251 void insertBlockCoupling
255 const BlockLduSystem<blockType1, fieldType>& blockSystem,
256 BlockLduMatrix<blockType2>& A,
257 Field<blockType2>& b,
261 // Insert scalar equation coupling. Not tested: VV, 9/May/2014
262 template<class blockType>
263 void insertEquationCoupling
267 fvScalarMatrix& matrix,
268 BlockLduMatrix<blockType>& A,
274 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
276 } // End namespace Foam
278 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
281 # include "blockMatrixTools.C"
284 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
288 // ************************************************************************* //