SundanceMeshTransformationBase.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_MESHFILTERBASE_H
00032 #define SUNDANCE_MESHFILTERBASE_H
00033 
00034 #include "SundanceDefs.hpp"
00035 #include "SundanceMesh.hpp"
00036 #include "SundanceMeshType.hpp"
00037 #include "PlayaHandleable.hpp"
00038 #include "Teuchos_Describable.hpp"
00039 #include "PlayaPrintable.hpp"
00040 #include "SundanceNoncopyable.hpp"
00041 #include "SundanceObjectWithVerbosity.hpp"
00042 #include "SundanceIncrementallyCreatableMesh.hpp"
00043 
00044 namespace Sundance
00045 {
00046 /**
00047  * MeshSourceBase provides the internal interface for mesh filters, i.e.,
00048  * objects that take an input mesh and produce a new mesh. Examples
00049  * of filter operations are refinement, load balancing,
00050  * and extrusion from 2D to 3D. 
00051  * The action of a mesh filter should be independent
00052  * of the internal mesh representation used. To allow user-level
00053  * specification of the type of internal mesh representation to be
00054  * used, a MeshTransformationBase is constructed with a MeshType object
00055  * which acts as a factory to produce empty output meshes.
00056  *
00057  * If the
00058  * communicator has more than one processor, the mesh created will
00059  * be distributed.
00060  *
00061  * <h4> Writing your own MeshTransformationBase subtype </h4>
00062  *
00063  * The only method you will need to override is
00064  * <ul>
00065  * <li> <tt>virtual Mesh apply(const Mesh& inputMesh) const = 0 </tt> 
00066  * </ul>
00067  * which is where you do the filter action and return an output
00068  * mesh. This method
00069  * should usually physically create the mesh with a call to createMesh(),
00070  * ensuring that the correct mesh representation type is created
00071  * using the MeshType factory with which the filter was constructed.
00072  *
00073  * See the ExtrustionMeshTransformation source code for a very simple
00074  * example of how to write a mesh filter subtype. 
00075  *
00076  * Optionally, you can override the description() method to 
00077  * provide more informative descriptive output than the std::string
00078  * <tt>"MeshTransformationBase[unknown subtype]".</tt>
00079  */
00080 class MeshTransformationBase : public Playa::Handleable<MeshTransformationBase>,
00081                                public Playa::Printable,
00082                                public Teuchos::Describable,
00083                                public Noncopyable,
00084                                public ObjectWithClassVerbosity<MeshTransformationBase>
00085 {
00086 public:
00087   /** Construct with a mesh type, which specifies
00088    *  the type of mesh to be built when the filter is applied. */
00089   MeshTransformationBase(const MeshType& meshType)
00090     : meshType_(meshType) {;}
00091 
00092   /** virtual dtor */
00093   virtual ~MeshTransformationBase(){;}
00094 
00095       
00096   /** Apply the filter to the given input mesh, 
00097    *  producing an output mesh */
00098   virtual Mesh apply(const Mesh& inputMesh) const = 0 ;
00099 
00100   /** \name Printable interface */
00101   //@{
00102   /** Print to a stream */
00103   virtual void print(std::ostream& os) const {os << description();}
00104   //@}
00105 
00106   /** \name Describable interface */
00107   //@{
00108   /** Print to a stream */
00109   virtual std::string description() const 
00110     {return "MeshTransformationBase[unknown subtype]";}
00111   //@}
00112       
00113 protected:
00114 
00115   /** createMesh() allocates the mesh object with a call to 
00116    * meshType's createMesh() method. */
00117   Mesh createMesh(int dim, const MPIComm& comm) const ;
00118 
00119 private:
00120   /** */
00121   MeshType meshType_;
00122 
00123 
00124 };
00125 
00126 }
00127 
00128 
00129 #endif

Site Contact