setUpdaterTemplates.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) 2011 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 "setUpdater.H"
30 #include "polyMesh.H"
31 #include "Time.H"
32 #include "mapPolyMesh.H"
33 #include "IOobjectList.H"
34 
35 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
36 
37 template<class Type>
38 void Foam::setUpdater::updateSets(const mapPolyMesh& morphMap) const
39 {
40  //
41  // Update all sets in memory.
42  //
43 
44  HashTable<const Type*> memSets =
45  morphMap.mesh().objectRegistry::lookupClass<Type>();
46 
47  forAllIters(memSets, iter)
48  {
49  Type& set = const_cast<Type&>(*iter());
50 
51  DebugPout
52  << "Set:" << set.name() << " size:" << set.size()
53  << " updated in memory" << endl;
54 
55  set.updateMesh(morphMap);
56 
57  // Write or not? Debatable.
58  set.write();
59  }
60 
61 
62  //
63  // Update all sets on disk
64  //
65 
66  // Get last valid mesh (discard points-only change)
67  IOobjectList objs
68  (
69  morphMap.mesh().time(),
70  morphMap.mesh().facesInstance(),
71  "polyMesh/sets"
72  );
73 
74  IOobjectList fileSets(objs.lookupClass<Type>());
75 
76  forAllConstIters(fileSets, iter)
77  {
78  if (!memSets.found(iter.key()))
79  {
80  // Not in memory. Load it.
81  Type set(*iter());
82 
83  if (debug)
84  {
85  Pout<< "Set:" << set.name() << " size:" << set.size()
86  << " updated on disk" << endl;
87  }
88 
89  set.updateMesh(morphMap);
90 
91  set.write();
92  }
93  else
94  {
95  DebugPout
96  << "Set:" << iter.key() << " already updated from memory"
97  << endl;
98  }
99  }
100 }
101 
102 
103 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
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
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::Pout
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
polyMesh.H
forAllIters
#define forAllIters(container, iter)
Iterate across all elements in the container object.
Definition: stdFoam.H:223
DebugPout
#define DebugPout
Report an information message using Foam::Pout.
Definition: messageStream.H:393
Time.H
forAllConstIters
forAllConstIters(mixture.phases(), phase)
Definition: pEqn.H:28
setUpdater.H