SundanceBamgMeshReader.hpp
Go to the documentation of this file.
00001 /* @HEADER@ */
00002 // ************************************************************************
00003 // 
00004 //                             Sundance
00005 //                 Copyright 2011 Sandia Corporation
00006 // 
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00008 // the U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Kevin Long (kevin.long@ttu.edu)
00038 // 
00039 
00040 /* @HEADER@ */
00041 
00042 #ifndef SUNDANCE_BAMGMESHREADER_H
00043 #define SUNDANCE_BAMGMESHREADER_H
00044 
00045 #include "SundanceDefs.hpp"
00046 #include "SundanceMeshReaderBase.hpp"
00047 #include "SundanceMesh.hpp" //added for Mesh
00048 
00049 namespace Sundance
00050 {
00051 using namespace Teuchos;
00052   
00053 
00054 
00055 /**
00056  * BamgMeshReader reads a mesh stored in Frederic Hecht's g format.
00057  *
00058  *!!The description below is for TriangleMeshReader & needs modification!!
00059  *
00060  * This format is documented at 
00061  * <A HREF="http://www-2.cs.cmu.edu/~quake/triangle.html"> 
00062  * the Triangle homepage. 
00063  * </A>
00064  * This reader expects to find node information in <tt>.node</tt> files
00065  * and element information in <tt>.ele</tt> files. The <tt> filename </tt>
00066  * constructor argument is the stem of the filenames, and so that 
00067  * a reader constructed with filename <tt>joe</tt> will look for node and
00068  * element data in <tt>joe.node</tt> and <tt>joe.ele</tt> respectively.
00069  * Node and element
00070  * attributes are read if present, and can be accessed with the 
00071  * <tt>getAttributes()</tt> method of <tt>MeshSource.</tt>
00072  * 
00073  * <h4> Parallel extensions </h4>
00074  * We have extended the Triangle format to deal with distributed meshes.
00075  * A TriangleMeshReader is constructed with an MPIComm object, and if
00076  * that communicator has more than one processor the mesh is assumed
00077  * to be split into files, one for each processor. Data
00078  * on mesh "joe" for the <i>nnn</i>-th processor will be found in the files
00079  * <ul>
00080  * <li> <tt>joe.node.</tt><i>nnn</i>
00081  * <li> <tt>joe.ele.</tt><i>nnn</i>
00082  * <li> <tt>joe.par.</tt><i>nnn</i>
00083  * </ul>
00084  * The <tt>.node.</tt><i>nnn</i> and <tt>.ele.</tt><i>nnn</i> files contain the
00085  * node and element data for the part of the mesh seen 
00086  * by the <i>nnn</i>-th
00087  * processor. The node and element 
00088  * numberings given in those two files are <b>local</b> indexes.
00089  * The <tt>.par.</tt><i>nnn</i> contains node and element 
00090  * ownership information for the part of the mesh seen 
00091  * by the <i>nnn</i>-th
00092  * processor. 
00093  *
00094  * <br> 
00095  *
00096  * A <tt>.par</tt> file is formatted as follows:
00097  * <ul>
00098  * <li> First line: <tt> rank numProcs </tt>
00099  * <li> Second line: <tt> numPoints </tt>
00100  * <li> Next <i> nPoints </i> lines: <tt> ptLID ptGID ptOwnerRank </tt>
00101  * <li> Next line: <tt> numElems </tt>
00102  * <li> Next <i> nElems </i> lines: <tt> elemLID elemGID elemOwnerRank </tt>
00103  * </ul>
00104  * 
00105  */
00106 class BamgMeshReader : public MeshReaderBase
00107 {
00108 public:
00109   /** */
00110   BamgMeshReader(const std::string& filename, 
00111     const MeshType& meshType, const bool bbAttr, int verbosity=0,
00112     const MPIComm& comm = MPIComm::world());
00113 
00114   /** Construct from a ParameterList */
00115   BamgMeshReader(const ParameterList& params);
00116 
00117   /** virtual dtor */
00118   virtual ~BamgMeshReader(){;}
00119 
00120 
00121   /** Create a mesh */
00122   virtual Mesh fillMesh() const ;
00123 
00124   /** Print a short descriptive std::string */
00125   virtual std::string description() const 
00126     {return "BamgMeshReader[file=" + filename() + "]";}
00127 
00128   /** Method for reading a .bb file */
00129   //Array<double> getVelocityField(const std::string& bbFile) const ;
00130       
00131 
00132   /** Return a ref count pointer to self */
00133   virtual RCP<MeshSourceBase> getRcp() {return rcp(this);}
00134 
00135 private:
00136   /** */
00137   void readParallelInfo(Array<int>& ptGID, Array<int>& ptOwner,
00138     Array<int>& elemGID, Array<int>& elemOwner) const ;
00139 
00140   /** */
00141   Mesh readNodes(Array<int>& ptGID,
00142     Array<int>& ptOwner) const ;
00143 
00144   /** */
00145   void readElems(Mesh& mesh,
00146     const Array<int>& nodeGID,
00147     Array<int>& elemGID,
00148     Array<int>& elemOwner) const ;
00149 
00150   /** add method that reads both nodes and elements from a single file */
00151   Mesh readMesh(Array<int>& ptGID,
00152     Array<int>& ptOwner) const ;
00153 
00154   /** add method for reading a .bb file */
00155   //Array<double> getVelocityField(const std::string& bbFile) const ;
00156 
00157   /** */
00158   std::string nodeFilename_;
00159 
00160   /** */
00161   std::string elemFilename_;
00162 
00163   /** */
00164   std::string parFilename_;
00165 
00166   /** add a mesh filename */
00167   std::string meshFilename_;
00168 
00169   /** add a bb filename */
00170   std::string bbFilename_;
00171     
00172   /** number of bb Attributes */
00173   int bbAttr_;
00174 
00175 
00176 };
00177 }
00178 
00179 #endif

Site Contact