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