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