Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
36template<class SetType>
37void Foam::polyMeshFilter::updateSets(const mapPolyMesh& map)
38{
39 //
40 // Update all sets in memory
41 //
42
43 // Note: objectRegistry::lookupClass() instead of
44 // objectRegistry::csorted() since it is also used to check
45 // contains() in the next bit of code
46
47 const HashTable<const SetType*> sets
48 (
49 map.mesh().objectRegistry::lookupClass<const SetType>()
50 );
51
52 for (const auto& iter : sets.csorted())
53 {
54 SetType& set = const_cast<SetType&>(*iter.val());
55 set.updateMesh(map);
56 set.sync(map.mesh());
57 }
58
59 //
60 // Update all sets on disk
61 //
62
63 IOobjectList objs
64 (
65 map.mesh().time(),
66 map.mesh().facesInstance(),
67 "polyMesh/sets"
68 );
69
70 for (const IOobject& io : objs.csorted<SetType>())
71 {
72 if (!sets.contains(io.name()))
73 {
74 // Not in memory. Load it.
75 SetType set(io);
76 set.updateMesh(map);
77
78 set.write();
79 }
80 }
81}
82
83
84template<class SetType>
85void Foam::polyMeshFilter::copySets
86(
87 const polyMesh& oldMesh,
88 const polyMesh& newMesh
89)
90{
91 for (const SetType& set : oldMesh.objectRegistry::csorted<SetType>())
92 {
93 auto* setPtr =
94 newMesh.objectRegistry::getObjectPtr<SetType>(set.name());
95
96 if (setPtr)
97 {
98 (*setPtr) = set;
99 }
100 else
101 {
102 setPtr = new SetType(newMesh, set.name(), set, set.writeOpt());
103 setPtr->store();
104 }
105
106 setPtr->sync(newMesh);
107 }
108}
109
110
111// ************************************************************************* //
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
const auto & io
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
Definition BitOps.C:35