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  //
40  // Update all sets in memory
41  //
42 
43  const HashTable<const SetType*> sets
44  (
45  map.mesh().objectRegistry::lookupClass<const SetType>()
46  );
47 
48  for (const auto& iter : sets.csorted())
49  {
50  SetType& set = const_cast<SetType&>(*iter.val());
51  set.updateMesh(map);
52  set.sync(map.mesh());
53  }
54 
55  //
56  // Update all sets on disk
57  //
58 
59  IOobjectList objs
60  (
61  map.mesh().time(),
62  map.mesh().facesInstance(),
63  "polyMesh/sets"
64  );
65 
66  for (const IOobject& io : objs.csorted<SetType>())
67  {
68  if (!sets.contains(io.name()))
69  {
70  // Not in memory. Load it.
71  SetType set(io);
72  set.updateMesh(map);
73 
74  set.write();
75  }
76  }
77 }
78 
79 
80 template<class SetType>
81 void Foam::polyMeshFilter::copySets
82 (
83  const polyMesh& oldMesh,
84  const polyMesh& newMesh
85 )
86 {
87  for (const SetType& set : oldMesh.objectRegistry::csorted<SetType>())
88  {
89  auto* setPtr =
90  newMesh.objectRegistry::getObjectPtr<SetType>(set.name());
91 
92  if (setPtr)
93  {
94  (*setPtr) = set;
95  }
96  else
97  {
98  setPtr = new SetType(newMesh, set.name(), set, set.writeOpt());
99  setPtr->store();
100  }
101 
102  setPtr->sync(newMesh);
103  }
104 }
105 
106 
107 // ************************************************************************* //
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
Definition: exprTraits.C:127
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)