MeshKit  1.0
test_tfimapping.cpp
Go to the documentation of this file.
00001 
00007 #include "meshkit/MKCore.hpp"
00008 #include "meshkit/TFIMapping.hpp"
00009 #include "meshkit/SizingFunction.hpp"
00010 #include "meshkit/ModelEnt.hpp"
00011 #include "meshkit/Matrix.hpp"
00012 #include "meshkit/EdgeMesher.hpp"
00013 
00014 using namespace MeshKit;
00015 
00016 #include "TestUtil.hpp"
00017 
00018 MKCore *mk = NULL;
00019 
00020 void test_TFImapping();
00021 void test_TFImappingcubit();
00022 
00023 int main(int argc, char **argv)
00024 {
00025 
00026   // start up MK and load the geometry
00027   int num_fail = 0;
00028 
00029   num_fail += RUN_TEST(test_TFImapping);
00030 
00031   //num_fail += RUN_TEST(test_TFImappingcubit);
00032 
00033   return num_fail;
00034 
00035 }
00036 
00037 void test_TFImappingcubit()
00038 {
00039   mk = new MKCore();
00040 
00041   std::string file_name = TestDir + "/SquareWithEdgesMeshed.cub";
00042   mk->load_geometry_mesh(file_name.c_str(), file_name.c_str());
00043 
00044   //check the number of geometrical edges
00045   MEntVector surfs, curves, loops;
00046   mk->get_entities_by_dimension(2, surfs);
00047   ModelEnt *this_surf = (*surfs.rbegin());
00048 
00049   this_surf->get_adjacencies(1, curves);
00050 
00051   CHECK_EQUAL(4, (int)curves.size());
00052 
00053   //check the number of mesh line segments
00054   moab::Range edges;
00055   moab::ErrorCode rval = mk->moab_instance()->get_entities_by_dimension(0, 1,
00056       edges);
00057   CHECK_EQUAL(moab::MB_SUCCESS, rval);
00058   CHECK_EQUAL(40, (int)edges.size());
00059 
00060   //now, do the TFIMapping
00061   TFIMapping *tm = (TFIMapping*) mk->construct_meshop("TFIMapping", surfs);
00062   mk->setup_and_execute();
00063 
00064   //check the number of quads
00065   moab::Range faces;
00066   rval = mk->moab_instance()->get_entities_by_dimension(0, 2, faces);
00067   CHECK_EQUAL(moab::MB_SUCCESS, rval);
00068   CHECK_EQUAL(100, (int)faces.size());
00069 
00070   mk->save_mesh("TFIMappingFromCubit.vtk");
00071 
00072   delete tm;
00073 
00074   delete mk;
00075 
00076 }
00077 
00078 void test_TFImapping()
00079 {
00080   mk = new MKCore();
00081 
00082 
00083 #if HAVE_OCC
00084   std::string file_name_geo = TestDir + "/square.stp";
00085   std::string file_name_edgeMeshOnly=TestDir + "/squareEdge.h5m";
00086   mk->load_geometry_mesh(file_name_geo.c_str(), file_name_edgeMeshOnly.c_str());
00087 #else
00088   std::string file_name = TestDir + "/SquareWithOneEdgeMeshed.cub";
00089   mk->load_geometry_mesh(file_name.c_str(), file_name.c_str());
00090 #endif
00091   // get the surface
00092   MEntVector surfs, curves, loops;
00093   mk->get_entities_by_dimension(2, surfs);
00094   CHECK_EQUAL(1, (int)surfs.size());
00095 
00096   // make an edge mesher
00097   mk->get_entities_by_dimension(1, curves);
00098   //test there are 4 edges bounding the surface
00099   CHECK_EQUAL(4, (int)curves.size());
00100 
00101   SizingFunction * esize = new SizingFunction(mk, 6, -1);
00102   surfs[0]->sizing_function_index(esize->core_index());
00103 
00104   /*TFIMapping *tm = (TFIMapping*) */mk->construct_meshop("TFIMapping", surfs);
00105   mk->setup_and_execute();
00106 
00107   //check whether we got the right number of quads after TFIMapping
00108   moab::Range faces;
00109   moab::ErrorCode rval = mk->moab_instance()->get_entities_by_dimension(0, 2,
00110       faces);
00111   CHECK_EQUAL(moab::MB_SUCCESS, rval);
00112 #if HAVE_OCC
00113   CHECK_EQUAL(100, (int)faces.size());
00114 #else
00115   CHECK_EQUAL(60, (int)faces.size());
00116 #endif
00117   //output the mesh to vtk file
00118   mk->save_mesh("TFIMapping.vtk");
00119   //delete mk->vertex_mesher();
00120   delete mk;
00121 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines