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-2022 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 #include "dlLibraryTable.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(renumberMethod, 0);
38  defineRunTimeSelectionTable(renumberMethod, dictionary);
39 }
40 
41 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
42 
44 (
45  const dictionary& renumberDict
46 )
47 {
48  const word methodType(renumberDict.lookup("method"));
49 
50  Info<< "Selecting renumberMethod " << methodType << endl;
51 
52  libs.open
53  (
54  renumberDict,
55  "libs",
56  dictionaryConstructorTablePtr_
57  );
58 
59  dictionaryConstructorTable::iterator cstrIter =
60  dictionaryConstructorTablePtr_->find(methodType);
61 
62  if (cstrIter == dictionaryConstructorTablePtr_->end())
63  {
65  << "Unknown renumberMethod "
66  << methodType << nl << nl
67  << "Valid renumberMethods are : " << endl
68  << dictionaryConstructorTablePtr_->sortedToc()
69  << exit(FatalError);
70  }
71 
72  return autoPtr<renumberMethod>(cstrIter()(renumberDict));
73 }
74 
75 
77 (
78  const polyMesh& mesh,
79  const pointField& points
80 ) const
81 {
82  CompactListList<label> cellCells;
84  (
85  mesh,
86  identity(mesh.nCells()),
87  mesh.nCells(),
88  false, // local only
89  cellCells
90  );
91 
92  // Renumber based on agglomerated points
93  return renumber(cellCells.list(), points);
94 }
95 
96 
98 (
99  const labelList& cellCells,
100  const labelList& offsets,
101  const pointField& cc
102 ) const
103 {
105  return labelList();
106 }
107 
108 
110 (
111  const polyMesh& mesh,
112  const labelList& fineToCoarse,
113  const pointField& coarsePoints
114 ) const
115 {
116  CompactListList<label> coarseCellCells;
118  (
119  mesh,
120  fineToCoarse,
121  coarsePoints.size(),
122  false, // local only
123  coarseCellCells
124  );
125 
126  // Renumber based on agglomerated points
127  labelList coarseDistribution
128  (
129  renumber
130  (
131  coarseCellCells.list(),
132  coarsePoints
133  )
134  );
135 
136  // Rework back into renumbering for original mesh_
137  labelList fineDistribution(fineToCoarse.size());
138 
139  forAll(fineDistribution, i)
140  {
141  fineDistribution[i] = coarseDistribution[fineToCoarse[i]];
142  }
143 
144  return fineDistribution;
145 }
146 
147 
148 // ************************************************************************* //
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:156
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
label nCells() const
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
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
dlLibraryTable libs
Table of loaded dynamic libraries.
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.
List< Container > list() const
Convert to List<Container>
const pointField & points
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:260
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
bool open(const fileName &libName, const bool verbose=true)
Open the named library, optionally with warnings if problems occur.
messageStream Info
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:76
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:353
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864