OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

setUpdaterTemplates.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 \*---------------------------------------------------------------------------*/
00026 
00027 #include "setUpdater.H"
00028 #include "polyMesh.H"
00029 #include "Time.H"
00030 #include "mapPolyMesh.H"
00031 #include "IOobjectList.H"
00032 
00033 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00034 
00035 namespace Foam
00036 {
00037 
00038 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00039 
00040 template<class Type>
00041 void setUpdater::updateSets(const mapPolyMesh& morphMap) const
00042 {
00043     //
00044     // Update all sets in memory.
00045     //
00046 
00047     HashTable<const Type*> memSets = 
00048         morphMap.mesh().objectRegistry::lookupClass<Type>();
00049 
00050     for
00051     (
00052         typename HashTable<const Type*>::iterator iter = memSets.begin();
00053         iter != memSets.end();
00054         ++iter
00055     )
00056     {
00057         Type& set = const_cast<Type&>(*iter());
00058 
00059         if (debug)
00060         {
00061             Pout<< "Set:" << set.name() << " size:" << set.size()
00062                 << " updated in memory" << endl;
00063         }
00064 
00065         set.updateMesh(morphMap);
00066 
00067         // Write or not? Debatable.
00068         set.write();
00069     }
00070 
00071 
00072     //
00073     // Update all sets on disk
00074     //
00075 
00076     // Get last valid mesh (discard points-only change)
00077     IOobjectList Objects
00078     (
00079         morphMap.mesh().time(),
00080         morphMap.mesh().time().findInstance
00081         (
00082             morphMap.mesh().meshDir(),
00083             "faces"
00084         ),
00085         "polyMesh/sets"
00086     );
00087 
00088     IOobjectList fileSets(Objects.lookupClass(Type::typeName));
00089 
00090     for
00091     (
00092         IOobjectList::const_iterator iter = fileSets.begin();
00093         iter != fileSets.end();
00094         ++iter
00095     )
00096     {
00097         if (!memSets.found(iter.key()))
00098         {
00099             // Not in memory. Load it.
00100             Type set(*iter());
00101 
00102             if (debug)
00103             {
00104                 Pout<< "Set:" << set.name() << " size:" << set.size()
00105                     << " updated on disk" << endl;
00106             }
00107 
00108             set.updateMesh(morphMap);
00109 
00110             set.write();
00111         }
00112         else
00113         {
00114             if (debug)
00115             {
00116                 Pout<< "Set:" << iter.key() << " already updated from memory"
00117                     << endl;
00118             }
00119         }
00120     }
00121 }
00122 
00123 
00124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00125 
00126 } // End namespace Foam
00127 
00128 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd