Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
EdgeSizeSimpleImplicit.cpp
Go to the documentation of this file.
00001 #include "EdgeSizeSimpleImplicit.hpp"
00002 
00003 namespace moab
00004 {
00005 
00006 EdgeSizeSimpleImplicit::EdgeSizeSimpleImplicit()
00007 {
00008     int i;
00009     // Default to the plane: x = 0.
00010     this->coeffC = 0.;
00011     for( i = 0; i < 3; ++i )
00012     {
00013         this->coeffB[i] = this->coeffA[i] = this->coeffA[i + 3] = 0.;
00014     }
00015     this->coeffB[0] = 1.;
00016     // Default to a scaling ratio of 1.
00017     this->ratio = 1.;
00018 }
00019 
00020 EdgeSizeSimpleImplicit::~EdgeSizeSimpleImplicit() {}
00021 
00022 bool EdgeSizeSimpleImplicit::evaluate_edge( const double* p0,
00023                                             const void* t0,
00024                                             double* p1,
00025                                             void* t1,
00026                                             const double* p2,
00027                                             const void* t2 )
00028 {
00029     (void)t0;
00030     (void)t1;
00031     (void)t2;
00032     double L2 = 0.;
00033     double delta;
00034     int i;
00035     for( i = 0; i < 3; ++i )
00036     {
00037         delta = p2[i + 3] - p0[i + 3];
00038         L2 += delta * delta;
00039     }
00040     // parametric coords in p1[{0,1,2}]
00041     double x  = p1[3];
00042     double y  = p1[4];
00043     double z  = p1[5];
00044     double F2 = this->coeffA[0] * x * x + 2. * this->coeffA[1] * x * y + 2. * this->coeffA[2] * x * z +
00045                 this->coeffA[3] * y * y + 2. * this->coeffA[4] * y * z + this->coeffA[5] * z * z + this->coeffB[0] * x +
00046                 this->coeffB[1] * y + this->coeffB[2] * z + this->coeffC;
00047     F2        = F2 * F2;  // square it
00048     double r2 = this->ratio * this->ratio;
00049     if( 4. * F2 / L2 < r2 ) return true;  // Midpoint is close to surface => split edge
00050 
00051     return false;  // Don't split edge
00052 }
00053 
00054 void EdgeSizeSimpleImplicit::set_implicit_function( double* coeffs )
00055 {
00056     int i;
00057     // Default to the plane: x = 0.
00058     for( i = 0; i < 3; ++i )
00059     {
00060         this->coeffA[i]     = coeffs[i];
00061         this->coeffA[i + 3] = coeffs[i + 3];
00062         this->coeffB[i]     = coeffs[i + 6];
00063     }
00064     this->coeffC = coeffs[9];
00065 }
00066 
00067 void EdgeSizeSimpleImplicit::get_implicit_function( double*& coeffs )
00068 {
00069     int i;
00070     // Default to the plane: x = 0.
00071     for( i = 0; i < 3; ++i )
00072     {
00073         coeffs[i]     = this->coeffA[i];
00074         coeffs[i + 3] = this->coeffA[i + 3];
00075         coeffs[i + 6] = this->coeffB[i];
00076     }
00077     coeffs[9] = this->coeffC;
00078 }
00079 
00080 }  // namespace moab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines