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_MESHSOURCE_H 00032 #define SUNDANCE_MESHSOURCE_H 00033 00034 #include "SundanceDefs.hpp" 00035 #include "SundanceMeshSourceBase.hpp" 00036 00037 #include "PlayaHandle.hpp" 00038 00039 namespace Sundance 00040 { 00041 /** 00042 * MeshSource is the user-level interface for objects such as 00043 * mesh generators and mesh file readers. A MeshSource can 00044 * create a mesh object with the <tt> getMesh() </tt> method, 00045 * and if node and element attributes are available, it can 00046 * access them with the getAttributes() method. 00047 * 00048 * Example: read input from a file celled "meshFile" 00049 * in Shewchuk's Triangle format, and 00050 * create a mesh of type BasicSimplicialMesh distributed over the 00051 * MPI communicator MPI_COMM_WORLD. 00052 * \code 00053 * MeshType meshType = new BasicSimplicialMeshType(); 00054 * MeshSource meshSrc = new TriangleMeshReader("meshFile", meshType, MPIComm::world()); 00055 * \endcode 00056 */ 00057 class MeshSource : public Playa::Handle<MeshSourceBase> 00058 { 00059 public: 00060 /** Construct an empty mesh source object */ 00061 MeshSource(); 00062 00063 /** Construct from a raw pointer to a mesh source subtype */ 00064 MeshSource(Playa::Handleable<MeshSourceBase>* rawPtr); 00065 00066 /** Construct from a smart pointer to a mesh source subtype */ 00067 MeshSource(const RCP<MeshSourceBase>& smartPtr); 00068 00069 /** Create and return a mesh */ 00070 Mesh getMesh() const ; 00071 00072 /** Get any attributes associated with the nodes and elements in the 00073 * mesh. If no attributes exist, the arrays are empty. If the mesh 00074 * does not exist, it will be created with a cell to getMesh(). */ 00075 void getAttributes(RCP<Array<Array<double> > >& nodeAttributes, 00076 RCP<Array<Array<double> > >& elemAttributes) const ; 00077 00078 /** Return the mesh type to be used by default if no MeshType 00079 * is given in a MeshSource subtype ctor. The default mesh type 00080 * can be set by including a specifer such as 00081 * <pre> 00082 * <DefaultMesh type="BasicSimplicial"/> 00083 * </pre> 00084 * as a child in the XML configuration file. 00085 */ 00086 static MeshType& defaultMeshType() ; 00087 00088 /** access to the MPI communicator */ 00089 const MPIComm& comm() const ; 00090 00091 static bool& staggerOutput() {static bool rtn=false; return rtn;} 00092 00093 private: 00094 }; 00095 } 00096 00097 #endif