polyMeshFilterTemplates.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2013-2016 OpenFOAM Foundation
9  Copyright (C) 2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "polyMeshFilter.H"
30 #include "polyMesh.H"
31 #include "mapPolyMesh.H"
32 #include "IOobjectList.H"
33 
34 // * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * //
35 
36 template<class SetType>
37 void Foam::polyMeshFilter::updateSets(const mapPolyMesh& map)
38 {
39  HashTable<const SetType*> sets =
40  map.mesh().objectRegistry::lookupClass<const SetType>();
41 
42  forAllIters(sets, iter)
43  {
44  SetType& set = const_cast<SetType&>(*iter());
45  set.updateMesh(map);
46  set.sync(map.mesh());
47  }
48 
49  IOobjectList objs
50  (
51  map.mesh().time(),
52  map.mesh().facesInstance(),
53  "polyMesh/sets"
54  );
55 
56  IOobjectList fileSets(objs.lookupClass<SetType>());
57 
58  forAllConstIters(fileSets, iter)
59  {
60  if (!sets.found(iter.key()))
61  {
62  // Not in memory. Load it.
63  SetType set(*iter());
64  set.updateMesh(map);
65 
66  set.write();
67  }
68  }
69 }
70 
71 
72 template<class SetType>
73 void Foam::polyMeshFilter::copySets
74 (
75  const polyMesh& oldMesh,
76  const polyMesh& newMesh
77 )
78 {
79  HashTable<const SetType*> sets =
80  oldMesh.objectRegistry::lookupClass<const SetType>();
81 
82  forAllConstIters(sets, iter)
83  {
84  const SetType& set = *iter();
85 
86  SetType* origSet =
87  newMesh.objectRegistry::getObjectPtr<SetType>(set.name());
88 
89  if (origSet)
90  {
91  (*origSet) = set;
92  (*origSet).sync(newMesh);
93  }
94  else
95  {
96  SetType* newSet
97  (
98  new SetType(newMesh, set.name(), set, set.writeOpt())
99  );
100 
101  newSet->store();
102  newSet->sync(newMesh);
103  }
104  }
105 }
106 
107 
108 // ************************************************************************* //
Foam::BitOps::set
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
Definition: BitOps.C:37
mapPolyMesh.H
IOobjectList.H
polyMesh.H
forAllIters
#define forAllIters(container, iter)
Iterate across all elements in the container object.
Definition: stdFoam.H:223
polyMeshFilter.H
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28