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 int main(int argc, char **argv) 
00031 {
00032   if (argc==1)
00033   {
00034 #if HAVE_OCC
00035     gfile_name = TestDir + "/brick.stp";
00036     mfile_name = TestDir + "/sf.h5m";
00037     index_source = 0; index_target = 1; mesh_intervals = 6;
00038 #else
00039     gfile_name = TestDir + "/multiconnected.cub";
00040     mfile_name = gfile_name;
00041     index_source = 2; index_target = 3; mesh_intervals = 10;
00042         
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   return num_fail;
00070   
00071 }
00072 
00073 void test_brick()
00074 {
00075 
00076   mk->load_geometry_mesh(gfile_name.c_str(), mfile_name.c_str());
00077 
00078         // get the volumes
00079         MEntVector vols, surfs, curves, vertices;
00080         mk->get_entities_by_dimension(3, vols);
00081         std::cout << "Volume size = " << vols.size() << std::endl;      
00082 
00083         ModelEnt *this_vol = (*vols.rbegin());
00084 
00085         //make a one-to-one sweeping
00086         OneToOneSwept *sw = (OneToOneSwept*) mk->construct_meshop("OneToOneSwept", vols);
00087 
00088         sw->SetSourceSurface(index_source);
00089         sw->SetTargetSurface(index_target);
00090 
00091         //set up the size
00092         SizingFunction swSize(mk, mesh_intervals, -1);
00093         this_vol->sizing_function_index(swSize.core_index());
00094 
00095         //set up for the sweeping and sweep
00096         mk->setup_and_execute();
00097 
00098         //check the number of cells after OneToOneSwept
00099         moab::Range hex;
00100   moab::ErrorCode rval = mk->moab_instance()->get_entities_by_dimension(0, 3, hex);
00101   CHECK_EQUAL(moab::MB_SUCCESS, rval);
00102   std::cout << " generated " << hex.size() << " hexahedrons\n";
00103 
00104         mk->save_mesh("OneToOneSwept.h5m");
00105         mk->save_mesh("OneToOneSwept.vtk");
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