MeshKit  1.0
example_volice.cpp
Go to the documentation of this file.
00001 
00010 #include "meshkit/MKCore.hpp"
00011 #include "meshkit/OneToOneSwept.hpp"
00012 #include "meshkit/SizingFunction.hpp"
00013 #include "meshkit/ModelEnt.hpp"
00014 #include "meshkit/Matrix.hpp"
00015 #include "meshkit/VertexMesher.hpp"
00016 #include "meshkit/CAMALPaver.hpp"
00017 #include "meshkit/FBiGeom.hpp"
00018 
00019 
00020 using namespace MeshKit;
00021 
00022 MKCore *mk = NULL;
00023 
00024 void test_ice();
00025 
00026 
00027 int main(int argc, char **argv) 
00028 {
00029     // start up MK and load the geometry
00030     mk = new MKCore();
00031     int num_fail = 0;\
00032     test_ice();
00033     return num_fail;
00034 }
00035 
00036 void test_ice()
00037 {
00038     std::string file_name = (std::string) MESH_DIR +  "/volIce.h5m";
00039 
00040     FBiGeom * fbiGeom = new FBiGeom(); // true for smooth, false for linear
00041     int ix = mk->add_igeom_instance(fbiGeom);
00042 
00043     iRel::PairHandle * pair;
00044     mk->irel_instance()->createPair (
00045                 fbiGeom->instance(), iRel::ENTITY, iRel::FBIGEOM_IFACE, iRel::ACTIVE,
00046                 mk->imesh_instance()->instance(), iRel::SET, iRel::IMESH_IFACE, iRel::ACTIVE, pair);
00047 
00048     int ixrel = mk->add_irel_pair(pair);
00049     char opts[]="SMOOTH;";                                  // relate , populate
00050     mk->load_geometry(file_name.c_str(), opts, ix, 0, ixrel, false, true);
00051     // get the volumes
00052     MEntVector vols, surfs, curves, vertices;
00053     mk->get_entities_by_dimension(3, vols);
00054     std::cout << "Volume size = " << vols.size() << std::endl;
00055 
00056     ModelEnt *this_vol = (*vols.rbegin());
00057 
00058     // test getting surfaces
00059     this_vol->get_adjacencies(2, surfs);
00060 
00061     // test getting edges
00062     this_vol->get_adjacencies(1, curves);
00063 
00064     // test getting vertices
00065     this_vol->get_adjacencies(0, vertices);
00066 
00067     MEntVector s1;
00068     s1.push_back(surfs[0]);
00069     (CAMALPaver*)mk->construct_meshop("CAMALPaver", s1);
00070     //set up the size
00071     SizingFunction * pavSize = new SizingFunction(mk, -1, 600);
00072 
00073     s1[0]->sizing_function_index(pavSize->core_index());
00074 
00075     mk->setup_and_execute();
00076 
00077     //make a one-to-one sweeping
00078     OneToOneSwept *sw = (OneToOneSwept*) mk->construct_meshop("OneToOneSwept", vols);
00079 
00080     sw->SetSourceSurface(0);
00081     sw->SetTargetSurface(1);
00082     SizingFunction swSize(mk, 5, -1);
00083 
00084     this_vol->sizing_function_index(swSize.core_index());
00085 
00086     //mk->add_arc( cmp, sw);// it means paver will be setup first?
00087     //set up for the sweeping and sweep
00088     mk->setup_and_execute();
00089 
00090     //check the number of cells after OneToOneSwept
00091     moab::Range hex;
00092     mk->moab_instance()->get_entities_by_dimension(0, 3, hex);
00093     mk->save_mesh("OneToOneSwept.vtk");
00094 
00095     //delete sw;
00096     delete mk->vertex_mesher();
00097     mk->clear_graph();
00098 
00099 }
00100 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines