MGridGenGAMGAgglomerate.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
00028
00029
00030 #include "MGridGenGAMGAgglomeration.H"
00031 #include "fvMesh.H"
00032 #include "syncTools.H"
00033
00034
00035
00036
00037
00038
00039
00040
00041 void Foam::MGridGenGAMGAgglomeration::
00042 makeCompactCellFaceAddressingAndFaceWeights
00043 (
00044 const lduAddressing& fineAddressing,
00045 List<idxtype>& cellCells,
00046 List<idxtype>& cellCellOffsets,
00047 const vectorField& Si,
00048 List<scalar>& faceWeights
00049 )
00050 {
00051 const label nFineCells = fineAddressing.size();
00052 const label nFineFaces = fineAddressing.upperAddr().size();
00053
00054 const unallocLabelList& upperAddr = fineAddressing.upperAddr();
00055 const unallocLabelList& lowerAddr = fineAddressing.lowerAddr();
00056
00057
00058 labelList nNbrs(nFineCells, 0);
00059
00060 forAll (upperAddr, facei)
00061 {
00062 nNbrs[upperAddr[facei]]++;
00063 }
00064
00065 forAll (lowerAddr, facei)
00066 {
00067 nNbrs[lowerAddr[facei]]++;
00068 }
00069
00070
00071 cellCellOffsets.setSize(nFineCells + 1);
00072 cellCells.setSize(2*nFineFaces);
00073 faceWeights.setSize(2*nFineFaces);
00074
00075
00076 cellCellOffsets[0] = 0;
00077 forAll (nNbrs, celli)
00078 {
00079 cellCellOffsets[celli+1] = cellCellOffsets[celli] + nNbrs[celli];
00080 }
00081
00082
00083 nNbrs = 0;
00084
00085 forAll (upperAddr, facei)
00086 {
00087 label own = upperAddr[facei];
00088 label nei = lowerAddr[facei];
00089
00090 label l1 = cellCellOffsets[own] + nNbrs[own]++;
00091 label l2 = cellCellOffsets[nei] + nNbrs[nei]++;
00092
00093 cellCells[l1] = nei;
00094 cellCells[l2] = own;
00095
00096 faceWeights[l1] = mag(Si[facei]);
00097 faceWeights[l2] = mag(Si[facei]);
00098 }
00099 }
00100
00101
00102 Foam::tmp<Foam::labelField> Foam::MGridGenGAMGAgglomeration::agglomerate
00103 (
00104 label& nCoarseCells,
00105 const label minSize,
00106 const label maxSize,
00107 const lduAddressing& fineAddressing,
00108 const scalarField& V,
00109 const vectorField& Sf,
00110 const scalarField& Sb
00111 )
00112 {
00113 const label nFineCells = fineAddressing.size();
00114
00115
00116 List<idxtype> cellCells;
00117 List<idxtype> cellCellOffsets;
00118
00119
00120 List<scalar> faceWeights;
00121
00122
00123 makeCompactCellFaceAddressingAndFaceWeights
00124 (
00125 fineAddressing,
00126 cellCells,
00127 cellCellOffsets,
00128 Sf,
00129 faceWeights
00130 );
00131
00132
00133 List<int> options(4, 0);
00134 options[0] = 4;
00135 options[1] = 6;
00136 options[2] = 128;
00137 options[3] = fvMesh_.nGeometricD();
00138
00139
00140
00141 List<int> finalAgglom(nFineCells);
00142 int nMoves = -1;
00143
00144 MGridGen
00145 (
00146 nFineCells,
00147 cellCellOffsets.begin(),
00148 const_cast<scalar*>(V.begin()),
00149 const_cast<scalar*>(Sb.begin()),
00150 cellCells.begin(),
00151 faceWeights.begin(),
00152 minSize,
00153 maxSize,
00154 options.begin(),
00155 &nMoves,
00156 &nCoarseCells,
00157 finalAgglom.begin()
00158 );
00159
00160 return tmp<labelField>(new labelField(finalAgglom));
00161 }
00162
00163
00164
Copyright © 2000-2009 OpenCFD Ltd