initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / dynamicMesh / setUpdater / setUpdaterTemplates.C
blob668c4be5be2ea8a2a43f3501f683b802b6a03b60
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "setUpdater.H"
28 #include "polyMesh.H"
29 #include "Time.H"
30 #include "mapPolyMesh.H"
31 #include "IOobjectList.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 namespace Foam
38 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
40 template<class Type>
41 void setUpdater::updateSets(const mapPolyMesh& morphMap) const
43     //
44     // Update all sets in memory.
45     //
47     HashTable<const Type*> memSets = 
48         morphMap.mesh().objectRegistry::lookupClass<Type>();
50     for
51     (
52         typename HashTable<const Type*>::iterator iter = memSets.begin();
53         iter != memSets.end();
54         ++iter
55     )
56     {
57         Type& set = const_cast<Type&>(*iter());
59         if (debug)
60         {
61             Pout<< "Set:" << set.name() << " size:" << set.size()
62                 << " updated in memory" << endl;
63         }
65         set.updateMesh(morphMap);
67         // Write or not? Debatable.
68         set.write();
69     }
72     //
73     // Update all sets on disk
74     //
76     // Get last valid mesh (discard points-only change)
77     IOobjectList Objects
78     (
79         morphMap.mesh().time(),
80         morphMap.mesh().time().findInstance
81         (
82             morphMap.mesh().meshDir(),
83             "faces"
84         ),
85         "polyMesh/sets"
86     );
88     IOobjectList fileSets(Objects.lookupClass(Type::typeName));
90     for
91     (
92         IOobjectList::const_iterator iter = fileSets.begin();
93         iter != fileSets.end();
94         ++iter
95     )
96     {
97         if (!memSets.found(iter.key()))
98         {
99             // Not in memory. Load it.
100             Type set(*iter());
102             if (debug)
103             {
104                 Pout<< "Set:" << set.name() << " size:" << set.size()
105                     << " updated on disk" << endl;
106             }
108             set.updateMesh(morphMap);
110             set.write();
111         }
112         else
113         {
114             if (debug)
115             {
116                 Pout<< "Set:" << iter.key() << " already updated from memory"
117                     << endl;
118             }
119         }
120     }
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 } // End namespace Foam
128 // ************************************************************************* //