MeshKit
1.0
|
00001 00007 #include "meshkit/MKCore.hpp" 00008 #include "meshkit/CAMALTetMesher.hpp" 00009 #include "meshkit/SizingFunction.hpp" 00010 #include "meshkit/ModelEnt.hpp" 00011 00012 using namespace MeshKit; 00013 00014 #include "TestUtil.hpp" 00015 00016 MKCore *mk = NULL; 00017 bool save_mesh = true; 00018 00019 void threeholecube_test(); 00020 void simpletet_test(); 00021 void mesh_test(std::string filebase, double size); 00022 00023 #ifdef HAVE_ACIS 00024 std::string extension = ".sat"; 00025 #elif HAVE_OCC 00026 std::string extension = ".stp"; 00027 #endif 00028 00029 int main(int argc, char **argv) 00030 { 00031 00032 // start up MK and load the geometry 00033 mk = new MKCore; 00034 int num_fail = 0; 00035 00036 if (argc == 2) save_mesh = true; 00037 // Test 1 00038 num_fail += RUN_TEST(simpletet_test); 00039 // delete all for running next test case 00040 mk->delete_all(); 00041 // Test 2 00042 num_fail += RUN_TEST(threeholecube_test); 00043 00044 return num_fail; 00045 } 00046 00047 void simpletet_test() 00048 { 00049 mesh_test("simpletet", 0.25); 00050 } 00051 00052 void threeholecube_test() 00053 { 00054 mesh_test("threeholecube", 0.05); 00055 } 00056 00057 void mesh_test(std::string filebase, double size) 00058 { 00059 std::string file_name = TestDir + "/" + filebase + extension; 00060 mk->load_geometry(file_name.c_str()); 00061 00062 // get the volume 00063 MEntVector dum, vols; 00064 mk->get_entities_by_dimension(3, dum); 00065 vols.push_back(*dum.rbegin()); 00066 mk->construct_meshop("CAMALTetMesher", vols); 00067 00068 // make a sizing function and set it on the surface 00069 SizingFunction esize(mk, -1, size); 00070 vols[0]->sizing_function_index(esize.core_index()); 00071 00072 // mesh the surface, by calling execute 00073 mk->setup_and_execute(); 00074 00075 // report the number of tets 00076 moab::Range tets; 00077 moab::ErrorCode rval = mk->moab_instance()->get_entities_by_dimension(0, 3, tets); 00078 CHECK_EQUAL(moab::MB_SUCCESS, rval); 00079 std::cout << tets.size() << " tets generated." << std::endl; 00080 00081 if (save_mesh) { 00082 // output mesh 00083 std::string outfile = filebase + std::string(".h5m"); 00084 moab::EntityHandle out_set = vols[0]->mesh_handle(); 00085 rval = mk->moab_instance()->write_file(outfile.c_str(), NULL, NULL, &out_set, 1); 00086 MBERRCHK(rval, mk->moab_instance()); 00087 } 00088 00089 mk->clear_graph(); 00090 } 00091