SundanceDomainDefinition.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 
00043 /*
00044  * SundanceDomainDefinition.hpp
00045  *
00046  *  Created on: Apr 30, 2010
00047  *      Author: benk
00048  */
00049 
00050 #ifndef SUNDANCEDOMAINDEFINITION_HPP_
00051 #define SUNDANCEDOMAINDEFINITION_HPP_
00052 
00053 #include "SundanceDefs.hpp"
00054 #include "PlayaHandleable.hpp"
00055 #include "PlayaHandle.hpp"
00056 #include "SundancePoint.hpp"
00057 
00058 #include "SundanceParametrizedCurve.hpp"
00059 
00060 namespace Sundance {
00061 
00062 using namespace Teuchos;
00063 
00064 /** define the predicate also with estimation */
00065 #define MESH_DOMAIN_(name, code) \
00066   class name : public MeshDomainBase, \
00067                public Playa::Handleable<MeshDomainBase> \
00068   { \
00069   public:\
00070     name() : MeshDomainBase(){;}            \
00071   virtual bool isInsideComputationalDomain(const Point& x) const code \
00072     GET_RCP(MeshDomainBase);\
00073   }
00074 
00075 #define MESH_DOMAIN(name, code) MESH_DOMAIN_(name, code);
00076 
00077 
00078 /** Base class for mesh refinement , but also to define computational domain
00079  * (which must not be the same as the mesh domain)*/
00080 class MeshDomainBase  {
00081 
00082 public:
00083 
00084   MeshDomainBase() {;}
00085 
00086   virtual ~MeshDomainBase() {;}
00087 
00088   /** Function to answer if the domain is inside the computational domain <br>
00089    * The strategy should be that if one point of a cell is inside the domain, then the whole
00090    * cell should be considered as in the computational domain.
00091    * @param x [in] coordinate of the point
00092    * @return true if the point is inside the domain, false otherwise */
00093   virtual bool isInsideComputationalDomain(const Point& x) const { return true;}
00094 };
00095 
00096 // ---------------
00097 
00098 /**  Class defines mesh domain based on parametrized curve */
00099 class CurveDomain : public MeshDomainBase ,
00100                     public Playa::Handleable<MeshDomainBase>{
00101 public:
00102 
00103   /** Ctor with the 2 necessary input arguments */
00104   CurveDomain(const ParametrizedCurve& curve ,
00105           CurveCellFilterMode mode) :
00106     MeshDomainBase() , curve_(curve) , mode_(mode){;}
00107     /** empty Dtor */
00108   virtual ~CurveDomain() {;}
00109 
00110   /**  in or outside the domain */
00111   virtual bool isInsideComputationalDomain(const Point& x) const {
00112     if (mode_ == Outside_Curve){
00113             return (curve_.curveEquation(x) >= -1e-16 );
00114     }
00115     else{
00116       return (curve_.curveEquation(x) <= 1e-16 );
00117     }
00118   }
00119 
00120   GET_RCP(MeshDomainBase);
00121 
00122 private:
00123 
00124   const ParametrizedCurve& curve_;
00125 
00126   const CurveCellFilterMode mode_;
00127 };
00128 
00129 // ---------------
00130 
00131 class MeshDomainDef : public Playa::Handle<MeshDomainBase> {
00132 public:
00133 
00134   /* Handle constructors */
00135   HANDLE_CTORS(MeshDomainDef, MeshDomainBase);
00136 
00137   /** see MeshDomainBase for Docu */
00138   bool isInsideComputationalDomain(const Point& x) const {
00139     return ptr()->isInsideComputationalDomain(x);
00140   }
00141 
00142 private:
00143 
00144 };
00145 
00146 
00147 }
00148 
00149 #endif /* SUNDANCEDOMAINDEFINITION_HPP_ */

Site Contact