00001 /* 00002 * SundanceDomainDefinition.hpp 00003 * 00004 * Created on: Apr 30, 2010 00005 * Author: benk 00006 */ 00007 00008 #ifndef SUNDANCEDOMAINDEFINITION_HPP_ 00009 #define SUNDANCEDOMAINDEFINITION_HPP_ 00010 00011 #include "SundanceDefs.hpp" 00012 #include "PlayaHandleable.hpp" 00013 #include "PlayaHandle.hpp" 00014 #include "SundancePoint.hpp" 00015 00016 #include "SundanceParametrizedCurve.hpp" 00017 00018 namespace Sundance { 00019 00020 using namespace Teuchos; 00021 00022 /** define the predicate also with estimation */ 00023 #define MESH_DOMAIN_(name, code) \ 00024 class name : public MeshDomainBase, \ 00025 public Playa::Handleable<MeshDomainBase> \ 00026 { \ 00027 public:\ 00028 name() : MeshDomainBase(){;} \ 00029 virtual bool isInsideComputationalDomain(const Point& x) const code \ 00030 GET_RCP(MeshDomainBase);\ 00031 } 00032 00033 #define MESH_DOMAIN(name, code) MESH_DOMAIN_(name, code); 00034 00035 00036 /** Base class for mesh refinement , but also to define computational domain 00037 * (which must not be the same as the mesh domain)*/ 00038 class MeshDomainBase { 00039 00040 public: 00041 00042 MeshDomainBase() {;} 00043 00044 virtual ~MeshDomainBase() {;} 00045 00046 /** Function to answer if the domain is inside the computational domain <br> 00047 * The strategy should be that if one point of a cell is inside the domain, then the whole 00048 * cell should be considered as in the computational domain. 00049 * @param x [in] coordinate of the point 00050 * @return true if the point is inside the domain, false otherwise */ 00051 virtual bool isInsideComputationalDomain(const Point& x) const { return true;} 00052 }; 00053 00054 // --------------- 00055 00056 /** Class defines mesh domain based on parametrized curve */ 00057 class CurveDomain : public MeshDomainBase , 00058 public Playa::Handleable<MeshDomainBase>{ 00059 public: 00060 00061 /** Ctor with the 2 necessary input arguments */ 00062 CurveDomain(const ParametrizedCurve& curve , 00063 CurveCellFilterMode mode) : 00064 MeshDomainBase() , curve_(curve) , mode_(mode){;} 00065 /** empty Dtor */ 00066 virtual ~CurveDomain() {;} 00067 00068 /** in or outside the domain */ 00069 virtual bool isInsideComputationalDomain(const Point& x) const { 00070 if (mode_ == Outside_Curve){ 00071 return (curve_.curveEquation(x) >= -1e-16 ); 00072 } 00073 else{ 00074 return (curve_.curveEquation(x) <= 1e-16 ); 00075 } 00076 } 00077 00078 GET_RCP(MeshDomainBase); 00079 00080 private: 00081 00082 const ParametrizedCurve& curve_; 00083 00084 const CurveCellFilterMode mode_; 00085 }; 00086 00087 // --------------- 00088 00089 class MeshDomainDef : public Playa::Handle<MeshDomainBase> { 00090 public: 00091 00092 /* Handle constructors */ 00093 HANDLE_CTORS(MeshDomainDef, MeshDomainBase); 00094 00095 /** see MeshDomainBase for Docu */ 00096 bool isInsideComputationalDomain(const Point& x) const { 00097 return ptr()->isInsideComputationalDomain(x); 00098 } 00099 00100 private: 00101 00102 }; 00103 00104 00105 } 00106 00107 #endif /* SUNDANCEDOMAINDEFINITION_HPP_ */