[MOAB-dev] r1415 - MOAB/trunk
dcthomp at mcs.anl.gov
dcthomp at mcs.anl.gov
Tue Nov 20 02:55:48 CST 2007
Author: dcthomp
Date: 2007-11-20 02:55:48 -0600 (Tue, 20 Nov 2007)
New Revision: 1415
Added:
MOAB/trunk/MBEdgeSizeSimpleImplicit.cpp
MOAB/trunk/MBEdgeSizeSimpleImplicit.hpp
MOAB/trunk/test_mesh_refiner.cpp
Modified:
MOAB/trunk/CMakeLists.txt
Log:
ENH: A concrete subclass of MBEdgeSizeEvaluator and a test for it
that will eventually test all of the refinement code, hence
the grandiose name.
Modified: MOAB/trunk/CMakeLists.txt
===================================================================
--- MOAB/trunk/CMakeLists.txt 2007-11-20 02:39:32 UTC (rev 1414)
+++ MOAB/trunk/CMakeLists.txt 2007-11-20 08:55:48 UTC (rev 1415)
@@ -121,6 +121,7 @@
MBMatrix3.cpp
MBCore.cpp
MBEdgeSizeEvaluator.cpp
+ MBEdgeSizeSimpleImplicit.cpp
MBFactory.cpp
MBGeomUtil.cpp
MBMeshSet.cpp
@@ -316,4 +317,10 @@
target_link_libraries( tqdcfr MOAB )
add_test( TestTQDCFR ${EXECUTABLE_OUTPUT_PATH}/tqdcfr )
+ add_executable( test_mesh_refiner test_mesh_refiner.cpp )
+ set_source_files_properties( test_mesh_refiner.cpp
+ COMPILE_FLAGS "-DTEST ${MOAB_DEFINES}" )
+ target_link_libraries( test_mesh_refiner MOAB )
+ add_test( TestMeshRefiner ${EXECUTABLE_OUTPUT_PATH}/test_mesh_refiner )
+
Added: MOAB/trunk/MBEdgeSizeSimpleImplicit.cpp
===================================================================
--- MOAB/trunk/MBEdgeSizeSimpleImplicit.cpp (rev 0)
+++ MOAB/trunk/MBEdgeSizeSimpleImplicit.cpp 2007-11-20 08:55:48 UTC (rev 1415)
@@ -0,0 +1,78 @@
+#include "MBEdgeSizeSimpleImplicit.hpp"
+
+MBEdgeSizeSimpleImplicit::MBEdgeSizeSimpleImplicit( MBInterface* parentMesh )
+ : MBEdgeSizeEvaluator( parentMesh )
+{
+ int i;
+ // Default to the plane: x = 0.
+ this->coeffC = 0.;
+ for ( i = 0; i < 3; ++i )
+ {
+ this->coeffB[i] = this->coeffA[i] = this->coeffA[i+3] = 0.;
+ }
+ this->coeffB[0] = 1.;
+ // Default to a scaling ratio of 1.
+ this->ratio = 1.;
+}
+
+MBEdgeSizeSimpleImplicit::~MBEdgeSizeSimpleImplicit()
+{
+}
+
+bool MBEdgeSizeSimpleImplicit::evaluate_edge(
+ const double* p0, const void* t0,
+ double* p1, void* t1,
+ const double* p2, const void* t2 )
+{
+ double L2 = 0.;
+ double delta;
+ int i;
+ for ( i = 0; i < 3; ++i )
+ {
+ delta = p2[i+3] - p0[i+3];
+ L2 += delta * delta;
+ }
+ // parametric coords in p1[{0,1,2}]
+ double x = p1[3];
+ double y = p1[4];
+ double z = p1[5];
+ double F2 =
+ this->coeffA[0] * x * x + 2. * this->coeffA[1] * x * y + 2. * this->coeffA[2] * x * z +
+ this->coeffA[3] * y * y + 2. * this->coeffA[4] * y * z +
+ this->coeffA[5] * z * z +
+ this->coeffB[0] * x + this->coeffB[1] * y + this->coeffB[2] * z +
+ this->coeffC;
+ F2 = F2 * F2; // square it
+ double r2 = this->ratio * this->ratio;
+ if ( 4. * F2 / L2 < r2 )
+ return true; // Midpoint is close to surface => split edge
+
+ return false; // Don't split edge
+}
+
+void MBEdgeSizeSimpleImplicit::set_implicit_function( double* coeffs )
+{
+ int i;
+ // Default to the plane: x = 0.
+ for ( i = 0; i < 3; ++i )
+ {
+ this->coeffA[i ] = coeffs[i];
+ this->coeffA[i+3] = coeffs[i + 3];
+ this->coeffB[i ] = coeffs[i + 6];
+ }
+ this->coeffC = coeffs[9];
+}
+
+void MBEdgeSizeSimpleImplicit::get_implicit_function( double*& coeffs )
+{
+ int i;
+ // Default to the plane: x = 0.
+ for ( i = 0; i < 3; ++i )
+ {
+ coeffs[i] = this->coeffA[i ];
+ coeffs[i + 3] = this->coeffA[i+3];
+ coeffs[i + 6] = this->coeffB[i ];
+ }
+ coeffs[9] = this->coeffC;
+}
+
Added: MOAB/trunk/MBEdgeSizeSimpleImplicit.hpp
===================================================================
--- MOAB/trunk/MBEdgeSizeSimpleImplicit.hpp (rev 0)
+++ MOAB/trunk/MBEdgeSizeSimpleImplicit.hpp 2007-11-20 08:55:48 UTC (rev 1415)
@@ -0,0 +1,67 @@
+/**
+ * MOAB, a Mesh-Oriented datABase, is a software component for creating,
+ * storing and accessing finite element mesh data.
+ *
+ * Copyright 2004 Sandia Corporation. Under the terms of Contract
+ * DE-AC04-94AL85000 with Sandia Coroporation, the U.S. Government
+ * retains certain rights in this software.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ */
+
+/** \class MBEdgeSizeSimpleImplicit
+ *
+ * This is an simple example edge evaluator tha subdivides edges based
+ * on their midpoint's distance to a simple, fixed-form implicit surface
+ * written as \f$ x^T A x + B x + C \f$ where \f$x\f$ is a column vector of
+ * holding the edge midpoint coordinates, \f$A\f$ is a symmetric 3x3 matrix,
+ * \f$B\f$ is a 1x3 row vector, and \f$C\f$ is a scalar.
+ * Whenever the implicit function divided by half of the edge length is smaller than
+ * some minimum ratio (which defaults to 1), the edge is marked for subdivision.
+ *
+ * \author David Thompson
+ *
+ * \date 19 November 2007
+ */
+#ifndef MB_EDGESIZESIMPLEIMPLICIT_H
+#define MB_EDGESIZESIMPLEIMPLICIT_H
+
+#include "MBEdgeSizeEvaluator.hpp"
+
+class MB_DLL_EXPORT MBEdgeSizeSimpleImplicit : public MBEdgeSizeEvaluator
+{
+public:
+ /// Construct an evaluator.
+ MBEdgeSizeSimpleImplicit( MBInterface* parentMesh );
+ /// Destruction is virtual so subclasses may clean up after refinement.
+ virtual ~MBEdgeSizeSimpleImplicit();
+
+ /** \brief Given an edge of length L, true when edge midpoint is within $\alpha^2$ of $\left(\frac{2f(x,y,z)}{L}\right)^2$.
+ */
+ virtual bool evaluate_edge(
+ const double* p0, const void* t0,
+ double* p1, void* t1,
+ const double* p2, const void* t2 );
+
+ /// Set the 9 coefficients of the implicit function. The vector contains the entries of A, followed by B, followed by C.
+ virtual void set_implicit_function( double* coeffs );
+ /// Get the 9 coefficients of the implicit function. The vector contains the entries of A, followed by B, followed by C.
+ void get_implicit_function( double*& coeffs );
+
+ /// Set the threshold ratio of function value to half-edge length that triggers subdivision.
+ virtual void set_ratio( double r ) { this->ratio = r; }
+ /// Get the threshold ratio of function value to half-edge length that triggers subdivision.
+ double get_ratio() { return this->ratio; }
+
+protected:
+ double coeffA[6];
+ double coeffB[3];
+ double coeffC;
+ double ratio;
+};
+
+#endif // MB_EDGESIZESIMPLEIMPLICIT_H
Added: MOAB/trunk/test_mesh_refiner.cpp
===================================================================
--- MOAB/trunk/test_mesh_refiner.cpp (rev 0)
+++ MOAB/trunk/test_mesh_refiner.cpp 2007-11-20 08:55:48 UTC (rev 1415)
@@ -0,0 +1,30 @@
+#include "MBCore.hpp"
+#include "MBEdgeSizeSimpleImplicit.hpp"
+#include "MBInterface.hpp"
+
+int TestMeshRefiner( int argc, char* argv[] )
+{
+ MBInterface* iface = new MBCore;
+ MBEdgeSizeSimpleImplicit eval( iface );
+ double p0[6] = { 0.1, 0.0, 0.0, 0.1, 0.0, 0.0 };
+ double p1[6] = { 0.6, 0.0, 0.0, 0.6, 0.0, 0.0 };
+ double p2[6] = { 1.1, 0.0, 0.0, 1.1, 0.0, 0.0 };
+ if ( eval.evaluate_edge( p0, 0, p1, 0, p2, 0 ) )
+ {
+ return 1;
+ }
+
+ eval.set_ratio( 2. );
+ if ( ! eval.evaluate_edge( p0, 0, p1, 0, p2, 0 ) )
+ {
+ return 1;
+ }
+
+ delete iface;
+ return 0;
+}
+
+int main( int argc, char* argv[] )
+{
+ return TestMeshRefiner( argc, argv );
+}
More information about the moab-dev
mailing list