MeshKit  1.0
test_scdmesh.cpp
Go to the documentation of this file.
00001 //-------------------------------------------------------------------------//
00007 
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 #include "TestUtil.hpp"
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 //---------------------------------------------------------------------------//
00029 // brief function definitions and core instance declaration
00030 MKCore *mk;
00031 
00032 void scd_test_1();
00033 void scd_test_2();
00034 void scd_test_3();
00035 
00036 //---------------------------------------------------------------------------//
00037 // main function
00038 int main(int argc, char **argv)
00039 {
00040   mk = new MKCore();
00041 
00042   int num_fail = 0;
00043 
00044   num_fail += RUN_TEST(scd_test_1);
00045   num_fail += RUN_TEST(scd_test_2);
00046   num_fail += RUN_TEST(scd_test_3);
00047 
00048   delete mk;
00049   return num_fail;
00050 }
00051 
00052 //---------------------------------------------------------------------------//
00053 // Test 1:
00054 // *: Full mesh representation
00055 // *: Cartesian bounding box
00056 // *: Coarse/fine grid sizing
00057 // *: All volumes meshed with a single grid
00058 // *: Should produce the same mesh as test 2
00059 void scd_test_1()
00060 {
00061   // load the test geometry
00062   std::string scd_geom = TestDir + "/" + DEFAULT_TEST_FILE_1;
00063   mk->load_geometry(scd_geom.c_str());
00064 
00065   // get the volumes
00066   MEntVector vols;
00067   mk->get_entities_by_dimension(3, vols);
00068 
00069   // make an SCD mesh instance with all volumes as separate model entities
00070   SCDMesh *scdmesh = (SCDMesh*) mk->construct_meshop("SCDMesh", vols);
00071 
00072   // provide the SCD mesh parameters for a cartesian grid
00073   scdmesh->set_interface_scheme(SCDMesh::full);
00074   scdmesh->set_grid_scheme(SCDMesh::cfMesh);
00075   scdmesh->set_axis_scheme(SCDMesh::cartesian);
00076   scdmesh->set_geometry_scheme(SCDMesh::all);
00077 
00078   // i direction parameters
00079   int ci_size = 5;
00080   std::vector<int> fine_i(ci_size);
00081   fine_i[0] = 2;
00082   fine_i[1] = 2;
00083   fine_i[2] = 10;
00084   fine_i[3] = 2;
00085   fine_i[4] = 2;
00086   scdmesh->set_coarse_i_grid(ci_size);
00087   scdmesh->set_fine_i_grid(fine_i);
00088 
00089   // j direction parameters
00090   int cj_size = 5;
00091   std::vector<int> fine_j(cj_size);
00092   fine_j[0] = 2;
00093   fine_j[1] = 2;
00094   fine_j[2] = 10;
00095   fine_j[3] = 2;
00096   fine_j[4] = 2;
00097   scdmesh->set_coarse_j_grid(cj_size);
00098   scdmesh->set_fine_j_grid(fine_j);
00099 
00100   // k direction parameters
00101   int ck_size = 5;
00102   std::vector<int> fine_k(ck_size);
00103   fine_k[0] = 2;
00104   fine_k[1] = 2;
00105   fine_k[2] = 10;
00106   fine_k[3] = 2;
00107   fine_k[4] = 2;
00108   scdmesh->set_coarse_k_grid(ck_size);
00109   scdmesh->set_fine_k_grid(fine_k);
00110 
00111   // execute and create the structured grid
00112   mk->setup_and_execute();
00113 
00114   // write the mesh to a file
00115   mk->save_mesh("SCDmesh1.vtk");
00116 
00117   // free memory
00118   delete scdmesh;
00119 }
00120 
00121 //---------------------------------------------------------------------------//
00122 // Test 2
00123 // *: Light-weight ScdInterface mesh representation
00124 // *: Cartesian bounding box
00125 // *: Coarse/fine grid sizing
00126 // *: All volumes meshed with a single grid
00127 // *: Should produce the same mesh as test 1
00128 void scd_test_2()
00129 {
00130   mk->delete_all();
00131   // load the test geometry
00132   std::string scd_geom = TestDir + "/" + DEFAULT_TEST_FILE_1;
00133   mk->load_geometry(scd_geom.c_str());
00134 
00135   // get the volumes
00136   MEntVector vols;
00137   mk->get_entities_by_dimension(3, vols);
00138 
00139   // make an SCD mesh instance with all volumes as separate model entities
00140   SCDMesh *scdmesh = (SCDMesh*) mk->construct_meshop("SCDMesh", vols);
00141 
00142   // provide the SCD mesh parameters for a cartesian grid
00143   scdmesh->set_interface_scheme(SCDMesh::scd);
00144   scdmesh->set_grid_scheme(SCDMesh::cfMesh);
00145   scdmesh->set_axis_scheme(SCDMesh::cartesian);
00146   scdmesh->set_geometry_scheme(SCDMesh::all);
00147 
00148   // i direction parameters
00149   int ci_size = 5;
00150   std::vector<int> fine_i(ci_size);
00151   fine_i[0] = 2;
00152   fine_i[1] = 2;
00153   fine_i[2] = 10;
00154   fine_i[3] = 2;
00155   fine_i[4] = 2;
00156   scdmesh->set_coarse_i_grid(ci_size);
00157   scdmesh->set_fine_i_grid(fine_i);
00158 
00159   // j direction parameters
00160   int cj_size = 5;
00161   std::vector<int> fine_j(cj_size);
00162   fine_j[0] = 2;
00163   fine_j[1] = 2;
00164   fine_j[2] = 10;
00165   fine_j[3] = 2;
00166   fine_j[4] = 2;
00167   scdmesh->set_coarse_j_grid(cj_size);
00168   scdmesh->set_fine_j_grid(fine_j);
00169 
00170   // k direction parameters
00171   int ck_size = 5;
00172   std::vector<int> fine_k(ck_size);
00173   fine_k[0] = 2;
00174   fine_k[1] = 2;
00175   fine_k[2] = 10;
00176   fine_k[3] = 2;
00177   fine_k[4] = 2;
00178   scdmesh->set_coarse_k_grid(ck_size);
00179   scdmesh->set_fine_k_grid(fine_k);
00180 
00181   // execute and create the structured grid
00182   mk->setup_and_execute();
00183 
00184   // write the mesh to a file
00185   mk->save_mesh("SCDmesh2.vtk");
00186 
00187   // free memory
00188   delete scdmesh;
00189 }
00190 
00191 //---------------------------------------------------------------------------//
00192 // Test 3
00193 // *: Full mesh representation
00194 // *: Cartesian bounding box
00195 // *: Coarse/fine grid sizing
00196 // *: Individual volumes meshed with their own grid
00197 void scd_test_3()
00198 {
00199     mk->delete_all();
00200   // load the test geometry
00201   std::string scd_geom = TestDir + "/" + DEFAULT_TEST_FILE_2;
00202   mk->load_geometry(scd_geom.c_str());
00203 
00204   // get the volumes
00205   MEntVector vols;
00206   mk->get_entities_by_dimension(3, vols);
00207 
00208   // make an SCD mesh instance with all volumes as separate model entities
00209   SCDMesh *scdmesh = (SCDMesh*) mk->construct_meshop("SCDMesh", vols);
00210 
00211   // provide the SCD mesh parameters for a cartesian grid
00212   scdmesh->set_interface_scheme(SCDMesh::full);
00213   scdmesh->set_grid_scheme(SCDMesh::cfMesh);
00214   scdmesh->set_axis_scheme(SCDMesh::cartesian);
00215   scdmesh->set_geometry_scheme(SCDMesh::individual);
00216 
00217   // i direction parameters
00218   int ci_size = 5;
00219   std::vector<int> fine_i(ci_size);
00220   fine_i[0] = 2;
00221   fine_i[1] = 2;
00222   fine_i[2] = 10;
00223   fine_i[3] = 2;
00224   fine_i[4] = 2;
00225   scdmesh->set_coarse_i_grid(ci_size);
00226   scdmesh->set_fine_i_grid(fine_i);
00227 
00228   // j direction parameters
00229   int cj_size = 5;
00230   std::vector<int> fine_j(cj_size);
00231   fine_j[0] = 2;
00232   fine_j[1] = 2;
00233   fine_j[2] = 10;
00234   fine_j[3] = 2;
00235   fine_j[4] = 2;
00236   scdmesh->set_coarse_j_grid(cj_size);
00237   scdmesh->set_fine_j_grid(fine_j);
00238 
00239   // k direction parameters
00240   int ck_size = 5;
00241   std::vector<int> fine_k(ck_size);
00242   fine_k[0] = 2;
00243   fine_k[1] = 2;
00244   fine_k[2] = 10;
00245   fine_k[3] = 2;
00246   fine_k[4] = 2;
00247   scdmesh->set_coarse_k_grid(ck_size);
00248   scdmesh->set_fine_k_grid(fine_k);
00249 
00250   // execute and create the structured grid
00251   mk->setup_and_execute();
00252 
00253   // write the mesh to a file
00254   mk->save_mesh("SCDmesh3.vtk");
00255 
00256   // free memory
00257   delete scdmesh;
00258 }
00259 
00260 
00261 //---------------------------------------------------------------------------//
00262 // end test_scdmesh.cpp
00263 //---------------------------------------------------------------------------//
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines