MeshKit  1.0
test_onetooneswept.cpp
Go to the documentation of this file.
00001 
00007 #include "meshkit/MKCore.hpp"
00008 #include "meshkit/OneToOneSwept.hpp"
00009 #include "meshkit/SizingFunction.hpp"
00010 #include "meshkit/ModelEnt.hpp"
00011 #include "meshkit/Matrix.hpp"
00012 #include "meshkit/VertexMesher.hpp"
00013 
00014 
00015 using namespace MeshKit;
00016 
00017 #include "TestUtil.hpp"
00018 
00019 std::string gfile_name;
00020 std::string mfile_name;
00021 
00022 // these are indices in the volume for source and target surfaces
00023 int index_source, index_target;
00024 int mesh_intervals;
00025 
00026 MKCore *mk = NULL;
00027 
00028 void test_brick();
00029 
00030 
00031 int main(int argc, char **argv) 
00032 {
00033   if (argc==1)
00034   {
00035 #if HAVE_OCC
00036     gfile_name = TestDir + "/brick.stp";
00037     mfile_name = TestDir + "/sf.h5m";
00038     index_source = 0; index_target = 1; mesh_intervals = 6;
00039 #else
00040     gfile_name = TestDir + "/BrickWithSrcMeshed.cub";
00041     mfile_name = gfile_name;
00042     index_source = 1; index_target = 0; mesh_intervals = 6;
00043 #endif
00044     std::cout<<"using default arguments: ";
00045   }
00046   else if (argc==6)
00047   {
00048     gfile_name = argv[1];
00049     mfile_name = argv[2];
00050     index_source = atoi(argv[3]);
00051     index_target = atoi(argv[4]);
00052     mesh_intervals = atoi(argv[5]);
00053     std::cout << "Using arguments: ";
00054   }
00055   else
00056   {
00057     std::cout<<"Usage: " << argv[0] << " <geo_file> <mesh_file> <index_src> <index_tar> <mesh_intervals>\n";
00058     return 1; // error
00059   }
00060   std::cout << argv[0] << " " << gfile_name << " "
00061          << mfile_name << " " << index_source << " " << index_target << " " << mesh_intervals <<
00062          "\n";
00063   // start up MK and load the geometry
00064   mk = new MKCore();
00065 
00066   int num_fail = 0;
00067   
00068   num_fail += RUN_TEST(test_brick);
00069 
00070   return num_fail;
00071   
00072 }
00073 
00074 void test_brick()
00075 {
00076 
00077   mk->load_geometry_mesh(gfile_name.c_str(), mfile_name.c_str());
00078 
00079         // get the volumes
00080         MEntVector vols, surfs, curves, vertices;
00081         mk->get_entities_by_dimension(3, vols);
00082         std::cout << "Volume size = " << vols.size() << std::endl;      
00083 
00084         ModelEnt *this_vol = (*vols.rbegin());
00085 
00086         //make a one-to-one sweeping
00087         OneToOneSwept *sw = (OneToOneSwept*) mk->construct_meshop("OneToOneSwept", vols);
00088 
00089         sw->SetSourceSurface(index_source);
00090         sw->SetTargetSurface(index_target);
00091 
00092         //set up the size
00093         SizingFunction swSize(mk, mesh_intervals, -1);
00094         this_vol->sizing_function_index(swSize.core_index());
00095 
00096         //set up for the sweeping and sweep
00097         mk->setup_and_execute();
00098 
00099         //check the number of cells after OneToOneSwept
00100         moab::Range hex;
00101   moab::ErrorCode rval = mk->moab_instance()->get_entities_by_dimension(0, 3, hex);
00102   CHECK_EQUAL(moab::MB_SUCCESS, rval);
00103   std::cout << " generated " << hex.size() << " hexahedrons\n";
00104 
00105         mk->save_mesh("OneToOneSwept.h5m");
00106 
00107         delete sw;
00108         delete mk->vertex_mesher();
00109         mk->clear_graph();
00110                 
00111 }
00112 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines