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 #include <decompositionMethods/decompositionMethod.H>
00030
00031
00032
00033 namespace Foam
00034 {
00035 defineTypeNameAndDebug(decompositionMethod, 0);
00036 defineRunTimeSelectionTable(decompositionMethod, dictionary);
00037 defineRunTimeSelectionTable(decompositionMethod, dictionaryMesh);
00038 }
00039
00040
00041
00042 Foam::autoPtr<Foam::decompositionMethod> Foam::decompositionMethod::New
00043 (
00044 const dictionary& decompositionDict
00045 )
00046 {
00047 word decompositionMethodTypeName(decompositionDict.lookup("method"));
00048
00049 Info<< "Selecting decompositionMethod "
00050 << decompositionMethodTypeName << endl;
00051
00052 dictionaryConstructorTable::iterator cstrIter =
00053 dictionaryConstructorTablePtr_->find(decompositionMethodTypeName);
00054
00055 if (cstrIter == dictionaryConstructorTablePtr_->end())
00056 {
00057 FatalErrorIn
00058 (
00059 "decompositionMethod::New"
00060 "(const dictionary& decompositionDict)"
00061 ) << "Unknown decompositionMethod "
00062 << decompositionMethodTypeName << endl << endl
00063 << "Valid decompositionMethods are : " << endl
00064 << dictionaryConstructorTablePtr_->toc()
00065 << exit(FatalError);
00066 }
00067
00068 return autoPtr<decompositionMethod>(cstrIter()(decompositionDict));
00069 }
00070
00071
00072 Foam::autoPtr<Foam::decompositionMethod> Foam::decompositionMethod::New
00073 (
00074 const dictionary& decompositionDict,
00075 const polyMesh& mesh
00076 )
00077 {
00078 word decompositionMethodTypeName(decompositionDict.lookup("method"));
00079
00080 Info<< "Selecting decompositionMethod "
00081 << decompositionMethodTypeName << endl;
00082
00083 dictionaryMeshConstructorTable::iterator cstrIter =
00084 dictionaryMeshConstructorTablePtr_->find(decompositionMethodTypeName);
00085
00086 if (cstrIter == dictionaryMeshConstructorTablePtr_->end())
00087 {
00088 FatalErrorIn
00089 (
00090 "decompositionMethod::New"
00091 "(const dictionary& decompositionDict, "
00092 "const polyMesh& mesh)"
00093 ) << "Unknown decompositionMethod "
00094 << decompositionMethodTypeName << endl << endl
00095 << "Valid decompositionMethods are : " << endl
00096 << dictionaryMeshConstructorTablePtr_->toc()
00097 << exit(FatalError);
00098 }
00099
00100 return autoPtr<decompositionMethod>(cstrIter()(decompositionDict, mesh));
00101 }
00102
00103
00104 Foam::labelList Foam::decompositionMethod::decompose
00105 (
00106 const pointField& points
00107 )
00108 {
00109 scalarField weights(0);
00110
00111 return decompose(points, weights);
00112 }
00113
00114
00115 Foam::labelList Foam::decompositionMethod::decompose
00116 (
00117 const labelList& fineToCoarse,
00118 const pointField& coarsePoints,
00119 const scalarField& coarseWeights
00120 )
00121 {
00122
00123 labelList coarseDistribution(decompose(coarsePoints, coarseWeights));
00124
00125
00126 labelList fineDistribution(fineToCoarse.size());
00127
00128 forAll(fineDistribution, i)
00129 {
00130 fineDistribution[i] = coarseDistribution[fineToCoarse[i]];
00131 }
00132
00133 return fineDistribution;
00134 }
00135
00136
00137 Foam::labelList Foam::decompositionMethod::decompose
00138 (
00139 const labelList& fineToCoarse,
00140 const pointField& coarsePoints
00141 )
00142 {
00143
00144 labelList coarseDistribution(decompose(coarsePoints));
00145
00146
00147 labelList fineDistribution(fineToCoarse.size());
00148
00149 forAll(fineDistribution, i)
00150 {
00151 fineDistribution[i] = coarseDistribution[fineToCoarse[i]];
00152 }
00153
00154 return fineDistribution;
00155 }
00156
00157
00158 void Foam::decompositionMethod::calcCellCells
00159 (
00160 const polyMesh& mesh,
00161 const labelList& fineToCoarse,
00162 const label nCoarse,
00163 labelListList& cellCells
00164 )
00165 {
00166 if (fineToCoarse.size() != mesh.nCells())
00167 {
00168 FatalErrorIn
00169 (
00170 "decompositionMethod::calcCellCells"
00171 "(const labelList&, labelListList&) const"
00172 ) << "Only valid for mesh agglomeration." << exit(FatalError);
00173 }
00174
00175 List<DynamicList<label> > dynCellCells(nCoarse);
00176
00177 forAll(mesh.faceNeighbour(), faceI)
00178 {
00179 label own = fineToCoarse[mesh.faceOwner()[faceI]];
00180 label nei = fineToCoarse[mesh.faceNeighbour()[faceI]];
00181
00182 if (own != nei)
00183 {
00184 if (findIndex(dynCellCells[own], nei) == -1)
00185 {
00186 dynCellCells[own].append(nei);
00187 }
00188 if (findIndex(dynCellCells[nei], own) == -1)
00189 {
00190 dynCellCells[nei].append(own);
00191 }
00192 }
00193 }
00194
00195 cellCells.setSize(dynCellCells.size());
00196 forAll(dynCellCells, coarseI)
00197 {
00198 cellCells[coarseI].transfer(dynCellCells[coarseI]);
00199 }
00200 }
00201
00202
00203 Foam::labelList Foam::decompositionMethod::decompose
00204 (
00205 const labelListList& globalCellCells,
00206 const pointField& cc
00207 )
00208 {
00209 scalarField cWeights(0);
00210
00211 return decompose(globalCellCells, cc, cWeights);
00212 }
00213
00214
00215