00001 #include "globals.h"
00002 #include "boundary_functions_lib.h"
00003 #include "numericmethods.h"
00016 FCubeBoundaryCondition::FCubeBoundaryCondition(double xdim,double ydim,double zdim,double left,double right,double front,double back,double bottom,double top)
00017 {
00018 m_XDim = xdim;
00019 m_YDim = ydim;
00020 m_ZDim = zdim;
00021 m_left = left;
00022 m_right = right;
00023 m_top = top;
00024 m_bottom = bottom;
00025 m_front = front;
00026 m_back = back;
00027 _tol=fmin(fmin(m_XDim,m_YDim),m_ZDim)*1.e-07;
00028 }
00029
00030
00031
00039 double FCubeBoundaryCondition::operator() (const VecDouble &p, const unsigned int component) const
00040 {
00041 assert(component == 0);
00042 if (NumericMethods::a_equal(p(0),0 ,_tol) && m_left != INFINITY)
00043 {
00044 return m_left;
00045 }
00046 if (NumericMethods::a_equal(p(0),m_XDim,_tol) && m_right != INFINITY)
00047 {
00048 return m_right;
00049 }
00050 if (NumericMethods::a_equal(p(1),m_YDim,_tol) && m_back != INFINITY)
00051 {
00052 return m_back;
00053 }
00054 if (NumericMethods::a_equal(p(1),0 ,_tol) && m_front != INFINITY)
00055 {
00056 return m_front;
00057 }
00058 if (NumericMethods::a_equal(p(2),m_ZDim,_tol) && m_top != INFINITY)
00059 {
00060 return m_top;
00061 }
00062 if (NumericMethods::a_equal(p(2),0,_tol) && m_bottom != INFINITY)
00063 {
00064 return m_bottom;
00065 }
00066 assert(0);
00067
00068 throw new Exception("FCubeBoundary::value() The point <%g,%g,%g> passed doesnt belong to the boundary",p(0),p(1),p(2));
00069 return NAN;
00070 }
00071
00072
00073
00074
00081 bool FCubeBoundaryCondition::isInDomain(const VecDouble &p,unsigned int component) const
00082 {
00083 assert(component == 0);
00084 if (NumericMethods::a_equal(p(0),0 ,_tol) && m_left != INFINITY)
00085 {
00086 return true;
00087 }
00088 if (NumericMethods::a_equal(p(0),m_XDim,_tol) && m_right != INFINITY)
00089 {
00090 return true;
00091 }
00092 if (NumericMethods::a_equal(p(1),m_YDim,_tol) && m_back != INFINITY)
00093 {
00094 return true;
00095 }
00096 if (NumericMethods::a_equal(p(1),0 ,_tol) && m_front != INFINITY)
00097 {
00098 return true;
00099 }
00100 if (NumericMethods::a_equal(p(2),m_ZDim,_tol) && m_top != INFINITY)
00101 {
00102 return true;
00103 }
00104 if (NumericMethods::a_equal(p(2),0,_tol) && m_bottom != INFINITY)
00105 {
00106 return true;
00107 }
00108 return false;
00109 }