GAMGSolverAgglomerateMatrix.C
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #include "GAMGSolver.H"
00028 #include "GAMGInterfaceField.H"
00029
00030
00031
00032 void Foam::GAMGSolver::agglomerateMatrix(const label fineLevelIndex)
00033 {
00034
00035 const lduMatrix& fineMatrix = matrixLevel(fineLevelIndex);
00036
00037
00038 matrixLevels_.set
00039 (
00040 fineLevelIndex,
00041 new lduMatrix(agglomeration_.meshLevel(fineLevelIndex + 1))
00042 );
00043 lduMatrix& coarseMatrix = matrixLevels_[fineLevelIndex];
00044
00045
00046 const labelList& faceRestrictAddr =
00047 agglomeration_.faceRestrictAddressing(fineLevelIndex);
00048
00049
00050 scalarField& coarseDiag = coarseMatrix.diag();
00051 agglomeration_.restrictField(coarseDiag, fineMatrix.diag(), fineLevelIndex);
00052
00053
00054 const lduInterfaceFieldPtrsList& fineInterfaces =
00055 interfaceLevel(fineLevelIndex);
00056
00057
00058 const FieldField<Field, scalar>& fineInterfaceBouCoeffs =
00059 interfaceBouCoeffsLevel(fineLevelIndex);
00060
00061
00062 const FieldField<Field, scalar>& fineInterfaceIntCoeffs =
00063 interfaceIntCoeffsLevel(fineLevelIndex);
00064
00065
00066
00067 interfaceLevels_.set
00068 (
00069 fineLevelIndex,
00070 new lduInterfaceFieldPtrsList(fineInterfaces.size())
00071 );
00072
00073 lduInterfaceFieldPtrsList& coarseInterfaces =
00074 interfaceLevels_[fineLevelIndex];
00075
00076
00077 interfaceLevelsBouCoeffs_.set
00078 (
00079 fineLevelIndex,
00080 new FieldField<Field, scalar>(fineInterfaces.size())
00081 );
00082 FieldField<Field, scalar>& coarseInterfaceBouCoeffs =
00083 interfaceLevelsBouCoeffs_[fineLevelIndex];
00084
00085
00086 interfaceLevelsIntCoeffs_.set
00087 (
00088 fineLevelIndex,
00089 new FieldField<Field, scalar>(fineInterfaces.size())
00090 );
00091 FieldField<Field, scalar>& coarseInterfaceIntCoeffs =
00092 interfaceLevelsIntCoeffs_[fineLevelIndex];
00093
00094
00095 forAll (fineInterfaces, inti)
00096 {
00097 if (fineInterfaces.set(inti))
00098 {
00099 const GAMGInterface& coarseInterface =
00100 refCast<const GAMGInterface>
00101 (
00102 agglomeration_.interfaceLevel(fineLevelIndex + 1)[inti]
00103 );
00104
00105 coarseInterfaces.set
00106 (
00107 inti,
00108 GAMGInterfaceField::New
00109 (
00110 coarseInterface,
00111 fineInterfaces[inti]
00112 ).ptr()
00113 );
00114
00115 coarseInterfaceBouCoeffs.set
00116 (
00117 inti,
00118 coarseInterface.agglomerateCoeffs(fineInterfaceBouCoeffs[inti])
00119 );
00120
00121 coarseInterfaceIntCoeffs.set
00122 (
00123 inti,
00124 coarseInterface.agglomerateCoeffs(fineInterfaceIntCoeffs[inti])
00125 );
00126 }
00127 }
00128
00129
00130
00131
00132 if (fineMatrix.hasLower())
00133 {
00134
00135 const scalarField& fineUpper = fineMatrix.upper();
00136 const scalarField& fineLower = fineMatrix.lower();
00137
00138
00139 scalarField& coarseUpper = coarseMatrix.upper();
00140 scalarField& coarseLower = coarseMatrix.lower();
00141
00142 const labelList& restrictAddr =
00143 agglomeration_.restrictAddressing(fineLevelIndex);
00144
00145 const unallocLabelList& l = fineMatrix.lduAddr().lowerAddr();
00146 const unallocLabelList& cl = coarseMatrix.lduAddr().lowerAddr();
00147 const unallocLabelList& cu = coarseMatrix.lduAddr().upperAddr();
00148
00149 forAll(faceRestrictAddr, fineFacei)
00150 {
00151 label cFace = faceRestrictAddr[fineFacei];
00152
00153 if (cFace >= 0)
00154 {
00155
00156
00157 if (cl[cFace] == restrictAddr[l[fineFacei]])
00158 {
00159 coarseUpper[cFace] += fineUpper[fineFacei];
00160 coarseLower[cFace] += fineLower[fineFacei];
00161 }
00162 else if (cu[cFace] == restrictAddr[l[fineFacei]])
00163 {
00164 coarseUpper[cFace] += fineLower[fineFacei];
00165 coarseLower[cFace] += fineUpper[fineFacei];
00166 }
00167 else
00168 {
00169 FatalErrorIn
00170 (
00171 "GAMGSolver::agglomerateMatrix(const label)"
00172 ) << "Inconsistent addressing between "
00173 "fine and coarse grids"
00174 << exit(FatalError);
00175 }
00176 }
00177 else
00178 {
00179
00180 coarseDiag[-1 - cFace] +=
00181 fineUpper[fineFacei] + fineLower[fineFacei];
00182 }
00183 }
00184 }
00185 else
00186 {
00187
00188 const scalarField& fineUpper = fineMatrix.upper();
00189
00190
00191 scalarField& coarseUpper = coarseMatrix.upper();
00192
00193 forAll(faceRestrictAddr, fineFacei)
00194 {
00195 label cFace = faceRestrictAddr[fineFacei];
00196
00197 if (cFace >= 0)
00198 {
00199 coarseUpper[cFace] += fineUpper[fineFacei];
00200 }
00201 else
00202 {
00203
00204 coarseDiag[-1 - cFace] += 2*fineUpper[fineFacei];
00205 }
00206 }
00207 }
00208 }
00209
00210
00211
Copyright © 2000-2009 OpenCFD Ltd