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