MeshKit  1.0
example_scdmesh.cpp
Go to the documentation of this file.
00001 
00008 #include "meshkit/MKCore.hpp"
00009 #include "meshkit/SCDMesh.hpp"
00010 #include "meshkit/SizingFunction.hpp"
00011 #include "meshkit/ModelEnt.hpp"
00012 #include "meshkit/VertexMesher.hpp"
00013 #include "meshkit/EdgeMesher.hpp"
00014 #include <vector>
00015 
00016 using namespace MeshKit;
00017 
00018 
00019 
00020 #ifdef HAVE_ACIS
00021 #define DEFAULT_TEST_FILE_1 "holycyl.sat"
00022 #define DEFAULT_TEST_FILE_2 "three_bricks.sat"
00023 #elif defined(HAVE_OCC)
00024 #define DEFAULT_TEST_FILE_1 "holycyl.stp"
00025 #define DEFAULT_TEST_FILE_2 "three_bricks.stp"
00026 #endif
00027 
00028 MKCore *mk;
00029 
00030 //---------------------------------------------------------------------------//
00031 // main function
00032 int main(int argc, char **argv)
00033 {
00034   mk = new MKCore();
00035 
00036   //---------------------------------------------------------------------------//
00037   // *: Full mesh representation
00038   // *: Cartesian bounding box
00039   // *: Coarse/fine grid sizing
00040   // *: All volumes meshed with a single grid
00041   // load the test geometry
00042 
00043   std::string scd_geom = (std::string) MESH_DIR + "/" + DEFAULT_TEST_FILE_1;
00044   mk->load_geometry(scd_geom.c_str());
00045 
00046   // get the volumes
00047   MEntVector vols;
00048   mk->get_entities_by_dimension(3, vols);
00049 
00050   // make an SCD mesh instance with all volumes as separate model entities
00051   SCDMesh *scdmesh = (SCDMesh*) mk->construct_meshop("SCDMesh", vols);
00052 
00053   // provide the SCD mesh parameters for a cartesian grid
00054   scdmesh->set_interface_scheme(SCDMesh::full);
00055   scdmesh->set_grid_scheme(SCDMesh::cfMesh);
00056   scdmesh->set_axis_scheme(SCDMesh::cartesian);
00057   scdmesh->set_geometry_scheme(SCDMesh::all);
00058 
00059   // i direction parameters
00060   int ci_size = 5;
00061   std::vector<int> fine_i(ci_size);
00062   fine_i[0] = 2;
00063   fine_i[1] = 2;
00064   fine_i[2] = 10;
00065   fine_i[3] = 2;
00066   fine_i[4] = 2;
00067   scdmesh->set_coarse_i_grid(ci_size);
00068   scdmesh->set_fine_i_grid(fine_i);
00069 
00070   // j direction parameters
00071   int cj_size = 5;
00072   std::vector<int> fine_j(cj_size);
00073   fine_j[0] = 2;
00074   fine_j[1] = 2;
00075   fine_j[2] = 10;
00076   fine_j[3] = 2;
00077   fine_j[4] = 2;
00078   scdmesh->set_coarse_j_grid(cj_size);
00079   scdmesh->set_fine_j_grid(fine_j);
00080 
00081   // k direction parameters
00082   int ck_size = 5;
00083   std::vector<int> fine_k(ck_size);
00084   fine_k[0] = 2;
00085   fine_k[1] = 2;
00086   fine_k[2] = 10;
00087   fine_k[3] = 2;
00088   fine_k[4] = 2;
00089   scdmesh->set_coarse_k_grid(ck_size);
00090   scdmesh->set_fine_k_grid(fine_k);
00091 
00092   // execute and create the structured grid
00093   mk->setup_and_execute();
00094 
00095   // write the mesh to a file
00096   mk->save_mesh("SCDmesh1.vtk");
00097 
00098   // free memory
00099   delete scdmesh;
00100   delete mk;
00101   return 0;
00102 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines