TAPs 0.7.7.3
TAPsModelDefBasedOnFEMHex.hpp
Go to the documentation of this file.
00001 /******************************************************************************
00002 TAPsModelDefBasedOnFEMHex.hpp
00003 ******************************************************************************/
00007 /******************************************************************************
00008 SUKITTI PUNAK   (02/26/2010)
00009 UPDATE          (10/27/2010)
00010 ******************************************************************************/
00011 #ifndef TAPs_MODEL_DEF_BASED_ON_FEM_HEX_HPP
00012 #define TAPs_MODEL_DEF_BASED_ON_FEM_HEX_HPP
00013 
00014 #include "ModelDefBasedOnFEMSupport/TAPsModelDefBasedOnFEM.hpp"
00015 #include "../FEM/TAPsFEMMeshHexahedraGen.hpp"
00016 #include "ModelDefBasedOnFEMSupport/TAPsModelDefBasedOnFEMHex_CD.hpp"
00017 #include "../Core/TAPsException.hpp"
00018 
00019 BEGIN_NAMESPACE_TAPs
00020 //=============================================================================
00021 template <typename T, typename DATA>
00022 class ModelDefBasedOnFEMHex : public ModelDefBasedOnFEM<T,DATA> {
00023 //=============================================================================
00024 public:
00025     // Member Functions -------------------------------------------------------
00027     friend std::ostream & operator<< ( std::ostream &output, ModelDefBasedOnFEMHex<T,DATA> const &obj )
00028     {
00029         output << obj.StrInfo();
00030         return output;
00031     }
00032     //-------------------------------------------------------------------------
00034     ModelDefBasedOnFEMHex ( std::string const & modelFile );
00036     //ModelDefBasedOnFEMHex ( ModelDefBasedOnFEMHex<T,DATA> const &orig );
00038     virtual ~ModelDefBasedOnFEMHex ();
00039     //-------------------------------------------------------------------------
00041     virtual std::string StrInfo () const;
00042     //-------------------------------------------------------------------------
00044     bool GenerateGridsWithDimension (
00045         T iGridWidth,   
00046         T iGridHeight,  
00047         T iGridDepth,   
00048         T   mass = 1,                   
00049         T   YoungsModulus = 96,         
00050         T   PoissonsRatio = T(1)/T(3),  
00051         bool bGenElementsInsideVolume = true,       
00052         bool bRecordsElementsGridLocations = true   
00053     );
00057     bool GenerateGridsWithSize (
00058         int iNumOfXSlices,  
00059         int iNumOfYSlices,  
00060         int iNumOfZSlices,  
00061         T   mass = 1,                   
00062         T   YoungsModulus = 96,         
00063         T   PoissonsRatio = T(1)/T(3),  
00064         bool bGenElementsInsideVolume = true,       
00065         bool bRecordsElementsGridLocations = true   
00066     );
00067     //-------------------------------------------------------------------------
00069     //inline ModelDefBasedOnFEMHex<T,DATA> & operator= ( ModelDefBasedOnFEMHex<T,DATA> const &orig );
00070     //-------------------------------------------------------------------------
00071 
00072     unsigned int GetNumberOfElementsPerGridSize_X ()    { return m_NumOfElementsPerGridSize[0]; }
00073     unsigned int GetNumberOfElementsPerGridSize_Y ()    { return m_NumOfElementsPerGridSize[1]; }
00074     unsigned int GetNumberOfElementsPerGridSize_Z ()    { return m_NumOfElementsPerGridSize[2]; }
00075 
00077     FEM::MeshHexahedra<T> const &   RefToFEMMesh () const   { return m_FEMMesh; }
00079     FEM::MeshHexahedra<T> &         RefToFEMMesh ()         { return m_FEMMesh; }
00080 
00082     virtual FEM::Mesh<T> *  PtrToFEMMesh ()         { return &m_FEMMesh; }
00083 
00085     virtual bool    InitCD ();
00086 
00088     inline virtual FEM::ModelDefBasedOnFEMHex_CD<T> const & CDUnit () const { return m_CD; }
00090     inline virtual FEM::ModelDefBasedOnFEMHex_CD<T> &       CDUnit ()       { return m_CD; }
00091 
00095     inline virtual void AddConnectionForceInLocalCoordinates ( PointForce<T> * const ptrConnectionForce ) { m_FEMMesh.AddConnectionForceInLocalCoordinates( ptrConnectionForce ); }
00099     inline virtual void RemoveConnectionForce ( PointForce<T> * const ptrConnectionForce )  { m_FEMMesh.RemoveConnectionForce( ptrConnectionForce ); }
00103     inline virtual void ClearAllConnectionLoads ()  { m_FEMMesh.ClearAllConnectionLoads(); }
00104 
00106     inline virtual void UpdateSurfaceMeshNormals () { m_pHEModel->CalAndSetNormals(); }
00107 
00109     virtual void AdvanceSimulationStatic ();
00110 
00117     virtual void AdvanceSimulationStatic_woFixedDisplacementNodes ();
00118 
00120     void AllocateElementsGridLocations ( unsigned int xWidth, unsigned int yHeight, unsigned int zDepth ) throw(...);
00122     void DeallocateElementsGridLocations ();
00124     inline int GetElementIDFromGridLocation_wErrChk ( unsigned int xWidth, unsigned int yHeight, unsigned int zDepth ) const;
00126     inline int GetElementIDFromGridLocation ( unsigned int xWidth, unsigned int yHeight, unsigned int zDepth ) const;
00129     void ListAllElementIDsInGridLocationFormat_zYx () const;
00130 
00131 #ifdef  TAPs_SIM_DYNAMIC_SYSTEM
00132 
00133     virtual void AdvanceSimulationDynamic ();
00134 
00141     virtual void AdvanceSimulationDynamic_woFixedDisplacementNodes ();
00142 #endif//TAPs_SIM_DYNAMIC_SYSTEM
00143 
00145     inline virtual T GetTimeStep () const   { return m_FEMMesh.GetTimeStep(); }
00147     inline virtual void SetTimeStep ( T timestep )  { return m_FEMMesh.SetTimeStep( timestep ); }
00148 
00150     inline virtual TransformationSupport<T> const & RefToTransformationSupport () const { return m_FEMMesh.RefToTransformationSupport(); }
00152     inline virtual TransformationSupport<T> &       RefToTransformationSupport ()       { return m_FEMMesh.RefToTransformationSupport(); }
00153 
00161     virtual HEVertex<T> * AddExtraVertexInLocalSpace (
00162         Vector3<T> location,                    
00163         int elementID,                          
00164         FEM::Element<T> * elementPtr,           
00165         Vector3<unsigned int> gridLocations,    
00166         Vector3<T> coordinates                  
00167     );
00168 
00173     virtual bool FindElementThatContainsPointInLocalSpace (
00174         Vector3<T> const & point,               
00175         unsigned int & elementID,               
00176         Vector3<unsigned int> & gridLocations,  
00177         Vector3<T> & coordinates                
00178     );
00179 
00180     //-------------------------------------------------------------------------
00181     // FIX/UNFIX
00182 
00184     void FixOrUnfixNodesByRowColumnDepthRange (
00185         unsigned int x0,    
00186         unsigned int x1,    
00187         unsigned int y0,    
00188         unsigned int y1,    
00189         unsigned int z0,    
00190         unsigned int z1,    
00191         bool    doFix       
00192     );
00193 
00195     void FixNodesByRowColumnDepthRange (
00196         unsigned int x0,    
00197         unsigned int x1,    
00198         unsigned int y0,    
00199         unsigned int y1,    
00200         unsigned int z0,    
00201         unsigned int z1     
00202     )   { FixOrUnfixNodesByRowColumnDepthRange( x0, x1, y0, y1, z0, z1, true ); }
00203 
00205     void UnfixNodesByRowColumnDepthRange (
00206         unsigned int x0,    
00207         unsigned int x1,    
00208         unsigned int y0,    
00209         unsigned int y1,    
00210         unsigned int z0,    
00211         unsigned int z1     
00212     )   { FixOrUnfixNodesByRowColumnDepthRange( x0, x1, y0, y1, z0, z1, false ); }
00213 
00214     //-------------------------------------------------------------------------
00215     // Data Members -----------------------------------------------------------
00216 //=============================================================================
00217 protected:
00218     // Member Functions -------------------------------------------------------
00219 
00221     bool GenerateMeshFromGridGenerator (
00222         GridGenerator<T,DATA> & GridGen,    
00223         T   mass = 1,                       
00224         T   YoungsModulus = 96,             
00225         T   PoissonsRatio = T(1)/T(3),      
00226         bool bGenElementsInsideVolume = true,       
00227         bool bRecordsElementsGridLocations = true   
00228     );
00229 
00231     //bool GenerateBaryCoordsFromGridGenerator ( GridGenerator<T,DATA> & GridGen );
00232 
00234     //void RecordBarycentric ();
00236     //void RecordBarycentric ( OpenGL::XPolygonalModel<T> * pXPModel );
00238     //void RecordBarycentric ( OpenGL::HalfEdgeModel<T> * pHEModel );
00239 
00240     //-------------------------------------------------------------------------
00241 
00243     inline void LocateGrid ( T x, T y, T z, unsigned int &i, unsigned int &j, unsigned int &k );
00244 
00248     void SetHEVertexIDToElementLocation ();
00249 
00250     //-------------------------------------------------------------------------
00251     // Simulation
00252 
00254     inline virtual void UpdateSurfaceMesh ();
00255 
00256     // Data Members -----------------------------------------------------------
00257     FEM::MeshHexahedra<T>   m_FEMMesh;  
00258     std::vector< HexBarycentricCoordsForVertexRef<T,DATA> >     m_BaryCoords;   
00259     //std::vector< unsigned int >   m_ElementID;    //!< identify the element that the barycentric coordinates are embedded in
00260     GridGenerator<T,DATA>   m_GridGen;  
00261     FEM::ModelDefBasedOnFEMHex_CD<T>    m_CD;   
00262 
00263     // The element ID is ranging from 0 to the number of elements minus one.
00264     unsigned int m_NumOfElementsPerGridSize[3]; 
00265     int *** m_ElementsGridLocs; 
00266 
00267 //=============================================================================
00268 private:
00269     // Member Functions -------------------------------------------------------
00270     // Data Members -----------------------------------------------------------
00271 //=============================================================================
00272 
00273 #if defined(__gl_h_) || defined(__GL_H__)
00274 public:
00276     virtual void DrawUndeformedFEMMesh ();
00277 
00279     virtual void DrawDeformedFEMMesh ();
00280 
00282     virtual void DrawCollidedMeshParts ();
00283 #endif
00284 
00285 //=============================================================================
00286 }; // END CLASS ModelDefBasedOnFEMHex
00287 //=============================================================================
00288 END_NAMESPACE_TAPs
00289 //-----------------------------------------------------------------------------
00291 #include "TAPsModelDefBasedOnFEMHex.cpp"
00292 
00294 // Include definition if TAPs_USE_EXPORT is not defined
00295 //#if !defined( TAPs_USE_EXPORT )
00296 //  #include "TAPsModelDefBasedOnFEMHex.cpp"
00297 //#endif
00298 //-----------------------------------------------------------------------------
00299 #endif
00300 //34567890123456789012345678901234567890123456789012345678901234567890123456789
00301 //--+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines