FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 \*---------------------------------------------------------------------------*/
00025 
00026 #include "setUpdater.H"
00027 #include <OpenFOAM/polyMesh.H>
00028 #include <OpenFOAM/Time.H>
00029 #include <OpenFOAM/mapPolyMesh.H>
00030 #include <OpenFOAM/IOobjectList.H>
00031 
00032 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00033 
00034 namespace Foam
00035 {
00036 
00037 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00038 
00039 template<class Type>
00040 void setUpdater::updateSets(const mapPolyMesh& morphMap) const
00041 {
00042     //
00043     // Update all sets in memory.
00044     //
00045 
00046     HashTable<const Type*> memSets = 
00047         morphMap.mesh().objectRegistry::lookupClass<Type>();
00048 
00049     for
00050     (
00051         typename HashTable<const Type*>::iterator iter = memSets.begin();
00052         iter != memSets.end();
00053         ++iter
00054     )
00055     {
00056         Type& set = const_cast<Type&>(*iter());
00057 
00058         if (debug)
00059         {
00060             Pout<< "Set:" << set.name() << " size:" << set.size()
00061                 << " updated in memory" << endl;
00062         }
00063 
00064         set.updateMesh(morphMap);
00065 
00066         // Write or not? Debatable.
00067         set.write();
00068     }
00069 
00070 
00071     //
00072     // Update all sets on disk
00073     //
00074 
00075     // Get last valid mesh (discard points-only change)
00076     IOobjectList Objects
00077     (
00078         morphMap.mesh().time(),
00079         morphMap.mesh().time().findInstance
00080         (
00081             morphMap.mesh().meshDir(),
00082             "faces"
00083         ),
00084         "polyMesh/sets"
00085     );
00086 
00087     IOobjectList fileSets(Objects.lookupClass(Type::typeName));
00088 
00089     for
00090     (
00091         IOobjectList::const_iterator iter = fileSets.begin();
00092         iter != fileSets.end();
00093         ++iter
00094     )
00095     {
00096         if (!memSets.found(iter.key()))
00097         {
00098             // Not in memory. Load it.
00099             Type set(*iter());
00100 
00101             if (debug)
00102             {
00103                 Pout<< "Set:" << set.name() << " size:" << set.size()
00104                     << " updated on disk" << endl;
00105             }
00106 
00107             set.updateMesh(morphMap);
00108 
00109             set.write();
00110         }
00111         else
00112         {
00113             if (debug)
00114             {
00115                 Pout<< "Set:" << iter.key() << " already updated from memory"
00116                     << endl;
00117             }
00118         }
00119     }
00120 }
00121 
00122 
00123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00124 
00125 } // End namespace Foam
00126 
00127 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines