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-2015 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 // Symbol to force loading at runtime
35 extern "C"
37 {}
38 
39 
40 namespace Foam
41 {
42  defineTypeNameAndDebug(renumberMethod, 0);
43  defineRunTimeSelectionTable(renumberMethod, dictionary);
44 }
45 
46 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
47 
49 (
50  const dictionary& renumberDict
51 )
52 {
53  const word methodType(renumberDict.lookup("method"));
54 
55  //Info<< "Selecting renumberMethod " << methodType << endl;
56 
57  dictionaryConstructorTable::iterator cstrIter =
58  dictionaryConstructorTablePtr_->find(methodType);
59 
60  if (cstrIter == dictionaryConstructorTablePtr_->end())
61  {
63  << "Unknown renumberMethod "
64  << methodType << nl << nl
65  << "Valid renumberMethods are : " << endl
66  << dictionaryConstructorTablePtr_->sortedToc()
67  << exit(FatalError);
68  }
69 
70  return autoPtr<renumberMethod>(cstrIter()(renumberDict));
71 }
72 
73 
75 (
76  const polyMesh& mesh,
77  const pointField& points
78 ) const
79 {
80  CompactListList<label> cellCells;
81  decompositionMethod::calcCellCells
82  (
83  mesh,
84  identity(mesh.nCells()),
85  mesh.nCells(),
86  false, // local only
87  cellCells
88  );
89 
90  // Renumber based on agglomerated points
91  return renumber(cellCells(), points);
92 }
93 
94 
96 (
97  const labelList& cellCells,
98  const labelList& offsets,
99  const pointField& cc
100 ) const
101 {
103  return labelList();
104 }
105 
106 
108 (
109  const polyMesh& mesh,
110  const labelList& fineToCoarse,
111  const pointField& coarsePoints
112 ) const
113 {
114  CompactListList<label> coarseCellCells;
115  decompositionMethod::calcCellCells
116  (
117  mesh,
118  fineToCoarse,
119  coarsePoints.size(),
120  false, // local only
121  coarseCellCells
122  );
123 
124  // Renumber based on agglomerated points
125  labelList coarseDistribution
126  (
127  renumber
128  (
129  coarseCellCells(),
130  coarsePoints
131  )
132  );
133 
134  // Rework back into renumbering for original mesh_
135  labelList fineDistribution(fineToCoarse.size());
136 
137  forAll(fineDistribution, i)
138  {
139  fineDistribution[i] = coarseDistribution[fineToCoarse[i]];
140  }
141 
142  return fineDistribution;
143 }
144 
145 
146 // ************************************************************************* //
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::labelList
List< label > labelList
A List of labels.
Definition: labelList.H:56
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::CompactListList
A packed storage unstructured matrix of objects of type <T> using an offset table for access.
Definition: polyTopoChange.H:91
Foam::dictionary::lookup
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:449
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
decompositionMethod.H
renumberMethodsLoad
void renumberMethodsLoad()
Definition: renumberMethod.C:36
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::renumberMethod::renumber
virtual labelList renumber(const pointField &) const
Return the order in which cells need to be visited, i.e.
Definition: renumberMethod.H:114
renumberMethod.H
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::identity
labelList identity(const label len)
Create identity map (map[i] == i) of given length.
Definition: ListOps.C:104
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Foam::autoPtr< Foam::renumberMethod >
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::renumberMethod::New
static autoPtr< renumberMethod > New(const dictionary &renumberDict)
Return a reference to the selected renumbering method.
Definition: renumberMethod.C:49
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
renumber
static void renumber(const labelList &map, labelList &elems)
Definition: reconstructParMesh.C:61