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