renumberMethod.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 InClass
25  renumberMethod
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "renumberMethod.H"
30 #include "decompositionMethod.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(renumberMethod, 0);
37  defineRunTimeSelectionTable(renumberMethod, dictionary);
38 }
39 
40 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
41 
43 (
44  const dictionary& renumberDict
45 )
46 {
47  const word methodType(renumberDict.lookup("method"));
48 
49  //Info<< "Selecting renumberMethod " << methodType << endl;
50 
51  dictionaryConstructorTable::iterator cstrIter =
52  dictionaryConstructorTablePtr_->find(methodType);
53 
54  if (cstrIter == dictionaryConstructorTablePtr_->end())
55  {
57  (
58  "renumberMethod::New"
59  "(const dictionary& renumberDict)"
60  ) << "Unknown renumberMethod "
61  << methodType << nl << nl
62  << "Valid renumberMethods are : " << endl
63  << dictionaryConstructorTablePtr_->sortedToc()
64  << exit(FatalError);
65  }
66 
67  return autoPtr<renumberMethod>(cstrIter()(renumberDict));
68 }
69 
70 
72 (
73  const polyMesh& mesh,
74  const pointField& points
75 ) const
76 {
77  CompactListList<label> cellCells;
79  (
80  mesh,
81  identity(mesh.nCells()),
82  mesh.nCells(),
83  false, // local only
84  cellCells
85  );
86 
87  // Renumber based on agglomerated points
88  return renumber(cellCells(), points);
89 }
90 
91 
93 (
94  const labelList& cellCells,
95  const labelList& offsets,
96  const pointField& cc
97 ) const
98 {
100  (
101  "renumberMethod::renumber\n"
102  "(\n"
103  " const labelList&,\n"
104  " const labelList&,\n"
105  " const pointField&\n"
106  ") const"
107  );
108  return labelList();
109 }
110 
111 
113 (
114  const polyMesh& mesh,
115  const labelList& fineToCoarse,
116  const pointField& coarsePoints
117 ) const
118 {
119  CompactListList<label> coarseCellCells;
121  (
122  mesh,
123  fineToCoarse,
124  coarsePoints.size(),
125  false, // local only
126  coarseCellCells
127  );
128 
129  // Renumber based on agglomerated points
130  labelList coarseDistribution
131  (
132  renumber
133  (
134  coarseCellCells(),
135  coarsePoints
136  )
137  );
138 
139  // Rework back into renumbering for original mesh_
140  labelList fineDistribution(fineToCoarse.size());
141 
142  forAll(fineDistribution, i)
143  {
144  fineDistribution[i] = coarseDistribution[fineToCoarse[i]];
145  }
146 
147  return fineDistribution;
148 }
149 
150 
151 // ************************************************************************* //
static autoPtr< renumberMethod > New(const dictionary &renumberDict)
Return a reference to the selected renumbering method.
A class for handling words, derived from string.
Definition: word.H:59
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
label nCells() const
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
Namespace for OpenFOAM.
static const char nl
Definition: Ostream.H:260
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
#define forAll(list, i)
Definition: UList.H:421
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Definition: ListOps.C:104
static void calcCellCells(const polyMesh &mesh, const labelList &agglom, const label nLocalCoarse, const bool global, CompactListList< label > &cellCells)
Helper: determine (local or global) cellCells from mesh.
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:314
A packed storage unstructured matrix of objects of type <T> using an offset table for access...
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:452
error FatalError
List< label > labelList
A List of labels.
Definition: labelList.H:56
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited, i.e.
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:356
defineTypeNameAndDebug(combustionModel, 0)