polyMeshFilterTemplates.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) 2013-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 \*---------------------------------------------------------------------------*/
25 
26 #include "polyMeshFilter.H"
27 #include "polyMesh.H"
28 #include "mapPolyMesh.H"
29 #include "IOobjectList.H"
30 
31 // * * * * * * * * * * * * * Public Member Functions * * * * * * * * * * * * //
32 
33 template<class SetType>
34 void Foam::polyMeshFilter::updateSets(const mapPolyMesh& map)
35 {
36  HashTable<const SetType*> sets =
37  map.mesh().objectRegistry::lookupClass<const SetType>();
38 
39  forAllIter(typename HashTable<const SetType*>, sets, iter)
40  {
41  SetType& set = const_cast<SetType&>(*iter());
42  set.updateMesh(map);
43  set.sync(map.mesh());
44  }
45 
46  IOobjectList Objects
47  (
48  map.mesh().time(),
49  map.mesh().facesInstance(),
50  "polyMesh/sets"
51  );
52 
53  IOobjectList fileSets(Objects.lookupClass(SetType::typeName));
54 
55  forAllConstIter(IOobjectList, fileSets, iter)
56  {
57  if (!sets.found(iter.key()))
58  {
59  // Not in memory. Load it.
60  SetType set(*iter());
61  set.updateMesh(map);
62 
63  set.write();
64  }
65  }
66 }
67 
68 
69 template<class SetType>
70 void Foam::polyMeshFilter::copySets
71 (
72  const polyMesh& oldMesh,
73  const polyMesh& newMesh
74 )
75 {
76  HashTable<const SetType*> sets =
77  oldMesh.objectRegistry::lookupClass<const SetType>();
78 
79  forAllConstIter(typename HashTable<const SetType*>, sets, iter)
80  {
81  const SetType& set = *iter();
82 
83  if (newMesh.objectRegistry::foundObject<SetType>(set.name()))
84  {
85  const SetType& origSet =
86  newMesh.objectRegistry::lookupObject<SetType>(set.name());
87 
88  const_cast<SetType&>(origSet) = set;
89  const_cast<SetType&>(origSet).sync(newMesh);
90  }
91  else
92  {
93  SetType* newSet
94  (
95  new SetType(newMesh, set.name(), set, set.writeOpt())
96  );
97 
98  newSet->store();
99  newSet->sync(newMesh);
100  }
101  }
102 }
103 
104 
105 // ************************************************************************* //
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:459
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
Definition: pEqn.H:29
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47