renumberMethod.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2018 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  << "Unknown renumberMethod "
58  << methodType << nl << nl
59  << "Valid renumberMethods are : " << endl
60  << dictionaryConstructorTablePtr_->sortedToc()
61  << exit(FatalError);
62  }
63 
64  return autoPtr<renumberMethod>(cstrIter()(renumberDict));
65 }
66 
67 
69 (
70  const polyMesh& mesh,
71  const pointField& points
72 ) const
73 {
74  CompactListList<label> cellCells;
76  (
77  mesh,
78  identity(mesh.nCells()),
79  mesh.nCells(),
80  false, // local only
81  cellCells
82  );
83 
84  // Renumber based on agglomerated points
85  return renumber(cellCells(), points);
86 }
87 
88 
90 (
91  const labelList& cellCells,
92  const labelList& offsets,
93  const pointField& cc
94 ) const
95 {
97  return labelList();
98 }
99 
100 
102 (
103  const polyMesh& mesh,
104  const labelList& fineToCoarse,
105  const pointField& coarsePoints
106 ) const
107 {
108  CompactListList<label> coarseCellCells;
110  (
111  mesh,
112  fineToCoarse,
113  coarsePoints.size(),
114  false, // local only
115  coarseCellCells
116  );
117 
118  // Renumber based on agglomerated points
119  labelList coarseDistribution
120  (
121  renumber
122  (
123  coarseCellCells(),
124  coarsePoints
125  )
126  );
127 
128  // Rework back into renumbering for original mesh_
129  labelList fineDistribution(fineToCoarse.size());
130 
131  forAll(fineDistribution, i)
132  {
133  fineDistribution[i] = coarseDistribution[fineToCoarse[i]];
134  }
135 
136  return fineDistribution;
137 }
138 
139 
140 // ************************************************************************* //
ListType renumber(const labelUList &oldToNew, const ListType &)
Renumber the values (not the indices) of a list.
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited, i.e.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
label nCells() const
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:256
static autoPtr< renumberMethod > New(const dictionary &renumberDict)
Return a reference to the selected renumbering method.
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.
A class for handling words, derived from string.
Definition: word.H:59
List< label > labelList
A List of labels.
Definition: labelList.H:56
A packed storage unstructured matrix of objects of type <T> using an offset table for access...
static const char nl
Definition: Ostream.H:265
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:366
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:583