SundanceBamgMeshReader.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                              Sundance
00005 //                 Copyright (2005) Sandia Corporation
00006 // 
00007 // Copyright (year first published) Sandia Corporation.  Under the terms 
00008 // of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 
00009 // retains certain rights in this software.
00010 // 
00011 // This library is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Lesser General Public License as
00013 // published by the Free Software Foundation; either version 2.1 of the
00014 // License, or (at your option) any later version.
00015 //  
00016 // This library is distributed in the hope that it will be useful, but
00017 // WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019 // Lesser General Public License for more details.
00020 //                                                                                 
00021 // You should have received a copy of the GNU Lesser General Public
00022 // License along with this library; if not, write to the Free Software
00023 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00024 // USA                                                                                
00025 // Questions? Contact Kevin Long (krlong@sandia.gov), 
00026 // Sandia National Laboratories, Livermore, California, USA
00027 // 
00028 // ************************************************************************
00029 /* @HEADER@ */
00030 
00031 #ifndef SUNDANCE_BAMGMESHREADER_H
00032 #define SUNDANCE_BAMGMESHREADER_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceMeshReaderBase.hpp"
00036 #include "SundanceMesh.hpp" //added for Mesh
00037 
00038 namespace Sundance
00039 {
00040 using namespace Teuchos;
00041   
00042 
00043 
00044 /**
00045  * BamgMeshReader reads a mesh stored in Frederic Hecht's g format.
00046  *
00047  *!!The description below is for TriangleMeshReader & needs modification!!
00048  *
00049  * This format is documented at 
00050  * <A HREF="http://www-2.cs.cmu.edu/~quake/triangle.html"> 
00051  * the Triangle homepage. 
00052  * </A>
00053  * This reader expects to find node information in <tt>.node</tt> files
00054  * and element information in <tt>.ele</tt> files. The <tt> filename </tt>
00055  * constructor argument is the stem of the filenames, and so that 
00056  * a reader constructed with filename <tt>joe</tt> will look for node and
00057  * element data in <tt>joe.node</tt> and <tt>joe.ele</tt> respectively.
00058  * Node and element
00059  * attributes are read if present, and can be accessed with the 
00060  * <tt>getAttributes()</tt> method of <tt>MeshSource.</tt>
00061  * 
00062  * <h4> Parallel extensions </h4>
00063  * We have extended the Triangle format to deal with distributed meshes.
00064  * A TriangleMeshReader is constructed with an MPIComm object, and if
00065  * that communicator has more than one processor the mesh is assumed
00066  * to be split into files, one for each processor. Data
00067  * on mesh "joe" for the <i>nnn</i>-th processor will be found in the files
00068  * <ul>
00069  * <li> <tt>joe.node.</tt><i>nnn</i>
00070  * <li> <tt>joe.ele.</tt><i>nnn</i>
00071  * <li> <tt>joe.par.</tt><i>nnn</i>
00072  * </ul>
00073  * The <tt>.node.</tt><i>nnn</i> and <tt>.ele.</tt><i>nnn</i> files contain the
00074  * node and element data for the part of the mesh seen 
00075  * by the <i>nnn</i>-th
00076  * processor. The node and element 
00077  * numberings given in those two files are <b>local</b> indexes.
00078  * The <tt>.par.</tt><i>nnn</i> contains node and element 
00079  * ownership information for the part of the mesh seen 
00080  * by the <i>nnn</i>-th
00081  * processor. 
00082  *
00083  * <br> 
00084  *
00085  * A <tt>.par</tt> file is formatted as follows:
00086  * <ul>
00087  * <li> First line: <tt> rank numProcs </tt>
00088  * <li> Second line: <tt> numPoints </tt>
00089  * <li> Next <i> nPoints </i> lines: <tt> ptLID ptGID ptOwnerRank </tt>
00090  * <li> Next line: <tt> numElems </tt>
00091  * <li> Next <i> nElems </i> lines: <tt> elemLID elemGID elemOwnerRank </tt>
00092  * </ul>
00093  * 
00094  */
00095 class BamgMeshReader : public MeshReaderBase
00096 {
00097 public:
00098   /** */
00099   BamgMeshReader(const std::string& filename, 
00100     const MeshType& meshType, const bool bbAttr, int verbosity=0,
00101     const MPIComm& comm = MPIComm::world());
00102 
00103   /** Construct from a ParameterList */
00104   BamgMeshReader(const ParameterList& params);
00105 
00106   /** virtual dtor */
00107   virtual ~BamgMeshReader(){;}
00108 
00109 
00110   /** Create a mesh */
00111   virtual Mesh fillMesh() const ;
00112 
00113   /** Print a short descriptive std::string */
00114   virtual std::string description() const 
00115     {return "BamgMeshReader[file=" + filename() + "]";}
00116 
00117   /** Method for reading a .bb file */
00118   //Array<double> getVelocityField(const std::string& bbFile) const ;
00119       
00120 
00121   /** Return a ref count pointer to self */
00122   virtual RCP<MeshSourceBase> getRcp() {return rcp(this);}
00123 
00124 private:
00125   /** */
00126   void readParallelInfo(Array<int>& ptGID, Array<int>& ptOwner,
00127     Array<int>& elemGID, Array<int>& elemOwner) const ;
00128 
00129   /** */
00130   Mesh readNodes(Array<int>& ptGID,
00131     Array<int>& ptOwner) const ;
00132 
00133   /** */
00134   void readElems(Mesh& mesh,
00135     const Array<int>& nodeGID,
00136     Array<int>& elemGID,
00137     Array<int>& elemOwner) const ;
00138 
00139   /** add method that reads both nodes and elements from a single file */
00140   Mesh readMesh(Array<int>& ptGID,
00141     Array<int>& ptOwner) const ;
00142 
00143   /** add method for reading a .bb file */
00144   //Array<double> getVelocityField(const std::string& bbFile) const ;
00145 
00146   /** */
00147   std::string nodeFilename_;
00148 
00149   /** */
00150   std::string elemFilename_;
00151 
00152   /** */
00153   std::string parFilename_;
00154 
00155   /** add a mesh filename */
00156   std::string meshFilename_;
00157 
00158   /** add a bb filename */
00159   std::string bbFilename_;
00160     
00161   /** number of bb Attributes */
00162   int bbAttr_;
00163 
00164 
00165 };
00166 }
00167 
00168 #endif

Site Contact