vtf-logo

shells/driverCC/Checkpointer.h

Go to the documentation of this file.
00001 // -*- C++ -*- 
00002 //
00003 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00004 //
00005 //                                   Fehmi Cirak
00006 //                        California Institute of Technology
00007 //                           (C) 2004 All Rights Reserved
00008 //
00009 // <LicenseText>
00010 //
00011 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00012 //
00013 #ifndef CHECKPOINTER_H
00014 #define CHECKPOINTER_H
00015 #include "MShell.h"
00016 #include "SVertexFunctors.h"
00017 #include "SElementFunctors.h"
00018 #include "../fem/selement.h"
00019 
00020 
00021 #include <vector>
00022 #include <iterator>  
00023 #include <functional>
00024 #include <iosfwd>
00025 
00026 
00027 namespace shells {
00028     class CheckpointData;
00029     class CheckpointIFaceData;
00030     class CheckpointVertexData;
00031     class CheckpointElementData;
00032 }
00033 
00034 
00035 
00036 class shells::CheckpointElementData {
00037 public:
00038     CheckpointElementData(MShell *const mshell);
00039     ~CheckpointElementData();
00040     
00041     // dump/read element data
00042     template <typename INS>
00043     void dumpElementData(INS itb);
00044     template <typename IT>
00045     void readAndDistributeElementData(IT itb, IT ite);
00046 
00047 private:
00048     MShell      *_mshell;    
00049 };
00050 
00051 
00052 class shells::CheckpointVertexData {
00053 public:
00054     CheckpointVertexData(MShell * const mshell);
00055     ~CheckpointVertexData();
00056     
00057     // dump/read vertex data
00058     template <typename INS>
00059     void dumpVertexData(INS itb);
00060     template <typename IT>
00061     void readAndDistributeVertexData(IT itb, IT ite);
00062  
00063 private:
00064     MShell      *_mshell;  
00065 };
00066 
00067 
00068 
00069 class shells::CheckpointData {
00070 public:
00071     CheckpointData(MShell *const mshell):
00072         _cpVtxData(CheckpointVertexData(mshell)),
00073         _cpElemData(CheckpointElementData(mshell)){}
00074 
00075     void dumpData(std::ostream& ofs);
00076     void readAndDistributeData(std::istream& ifs);
00077 
00078 private:
00079     CheckpointVertexData     _cpVtxData;
00080     CheckpointElementData    _cpElemData;
00081 
00082     typedef std::vector<double>     _VecDCont; 
00083     _VecDCont     _bufferElem;
00084     _VecDCont     _bufferVtx;
00085 };
00086 
00087 
00088 
00089 // templated methods
00090 namespace shells {
00091     
00092     template <typename INS>
00093     void shells::CheckpointVertexData::dumpVertexData(INS itbs) 
00094     {
00095         // collect displacements
00096         SVertexCollector<INS, SVertexDisplacement> getDisp;
00097         _mshell->iterateOverVertices(std::bind2nd(getDisp, itbs));
00098         
00099         // collect velocities
00100         SVertexCollector<INS, SVertexVelocity> getVel;
00101         _mshell->iterateOverVertices(std::bind2nd(getVel, itbs));
00102         
00103         // collect accelerations
00104         SVertexCollector<INS, SVertexAcceleration> getAcc;
00105         _mshell->iterateOverVertices(std::bind2nd(getAcc, itbs));
00106         
00107         return;
00108     }    
00109 
00110 
00111     template <typename IT>
00112     void CheckpointVertexData::readAndDistributeVertexData(IT itb, IT ite) 
00113     {
00114         const unsigned size = std::distance(itb, ite);
00115         const unsigned dofPnode = SVertexDisplacement::numVar;
00116 
00117         //  size = (dofPnode+dofPnode+dofPnode)*nodes
00118         const unsigned nodes = size/(dofPnode+dofPnode+dofPnode);
00119 
00120         // displacements
00121         IT itBegin = itb;
00122         IT itEnd = itBegin;
00123         std::advance(itEnd, nodes*dofPnode);
00124         SVertexDistributor<IT, SVertexDisplacement> setDisp(itBegin, itEnd);
00125         _mshell->iterateOverVertices(setDisp);
00126 
00127         // velocities
00128         itBegin = itEnd;        
00129         itEnd = itBegin;
00130         std::advance(itEnd, nodes*dofPnode);
00131         SVertexDistributor<IT, SVertexVelocity> setVel(itBegin, itEnd);
00132         _mshell->iterateOverVertices(setVel);
00133 
00134         // accelerations
00135         itBegin = itEnd;
00136         itEnd = itBegin;
00137         std::advance(itEnd, nodes*dofPnode);
00138         SVertexDistributor<IT, SVertexAcceleration> setAcc(itBegin, itEnd);
00139         _mshell->iterateOverVertices(setAcc);
00140 
00141     }
00142     
00143     
00144     template <typename INS>
00145     void shells::CheckpointElementData::dumpElementData(INS itbs)
00146     {
00147         SELementInternalDataCollect<INS> getInternalData;
00148         
00149         _mshell->iterateOverElements(std::bind2nd(getInternalData, itbs), shells::MShell::active);
00150                 
00151         return;
00152     }
00153 
00154     
00155     
00156     template <typename IT>
00157     void CheckpointElementData::readAndDistributeElementData(IT itb, IT ite) 
00158     {
00159         SELementInternalDataDistrib<IT> setInternalData(itb, ite);
00160         
00161         _mshell->iterateOverElements(setInternalData, shells::MShell::active);
00162     }   
00163 }
00164 
00165 #endif

Generated on Fri Aug 24 13:00:24 2007 for SFC Thin-Shell Finite Element Solver by  doxygen 1.4.7