MeshKit  1.0
example_basic.cpp
Go to the documentation of this file.
00001 
00021 #include "meshkit/MKCore.hpp"
00022 #include "meshkit/MeshOp.hpp"
00023 #include "meshkit/MeshOpTemplate.hpp"
00024 #include "meshkit/TFIMapping.hpp"
00025 #include "meshkit/OneToOneSwept.hpp"
00026 
00027 using namespace MeshKit;
00028 
00029 MKCore *mk;
00030 bool save_mesh = true;
00031 
00032 void test_mesh_op_template();
00033 
00034 int main(int argc, char **argv)
00035 {
00036   mk = new MKCore();
00037   MEntVector all_curves, all_surfs, the_vol, tfi_surface;
00038   int source_surface = 0; // These are
00039   int target_surface = 1; //   chosen by magic!
00040 
00041   // Make the brick!
00042   MeshOpTemplate *mot = (MeshOpTemplate*) mk->construct_meshop("MeshOpTemplate", MEntVector());
00043   mot->set_name("MeshOpTemplate");
00044   mk->setup_and_execute();
00045   mk->populate_model_ents();
00046   mk->clear_graph();
00047 
00048   // Get entity data
00049   mk->get_entities_by_dimension(1, all_curves);
00050   mk->get_entities_by_dimension(2, all_surfs);
00051   mk->get_entities_by_dimension(3, the_vol);
00052 
00053   // Size some things!
00054   ModelEnt *some_vol = (*the_vol.rbegin());
00055   SizingFunction wsize(mk, 4, -1);
00056   some_vol->sizing_function_index(wsize.core_index());
00057 
00058   // Mesh Surface
00059   (tfi_surface = all_surfs).resize(1);
00060   TFIMapping *tfi = (TFIMapping*) mk->construct_meshop("TFIMapping", tfi_surface);
00061   tfi->set_name("TFI");
00062 
00063   // Sweep Surface to Surface
00064   OneToOneSwept *oto = (OneToOneSwept*) mk->construct_meshop("OneToOneSwept", the_vol);
00065   oto->set_name("OTO");
00066   oto->SetSourceSurface(source_surface);
00067   oto->SetTargetSurface(target_surface);
00068 
00069   // Do work!
00070   printf("Pre-Setup\n");
00071   mk->setup();
00072   printf("Pre-Execute\n");
00073   mk->execute();
00074   printf("Pre-Clear\n");
00075   mk->clear_graph();
00076 
00077   // Some declarations for tags
00078   moab::Interface *mb = mk->moab_instance();
00079   moab::Tag matTag, neuTag;
00080   moab::Range matEnts, neuEnts;
00081   moab::EntityHandle matEntSet, neuEntSet;
00082   int matVal = 2, neuVal = 4; // these values are arbitrary
00083 
00084   // Tag the material set
00085   // Collect the entites into a set
00086   mb->create_meshset(moab::MESHSET_SET, matEntSet);
00087   mb->get_entities_by_dimension(mb->get_root_set(), 3, matEnts, true);
00088   mb->add_entities(matEntSet, matEnts);
00089 
00090   // Grab a tag and attach it to the set
00091   mb->tag_get_handle("MATERIAL_SET", matTag);
00092   mb->tag_set_data(matTag, &matEntSet, 1, (void*) &matVal);
00093 
00094   // The same thing for the Neumann set!
00095   mb->create_meshset(moab::MESHSET_SET, neuEntSet);
00096   mb->get_entities_by_dimension(mb->get_root_set(), 2, neuEnts, true);
00097   mb->add_entities(neuEntSet, neuEnts);
00098 
00099   mb->tag_get_handle("NEUMANN_SET", neuTag);
00100   mb->tag_set_data(neuTag, &neuEntSet, 1, (void*) &neuVal);
00101 
00102   // Possibly output (as files) our hard work!
00103   if(save_mesh) {
00104 #ifdef HAVE_ACIS
00105       mk->save_geometry("un_meshed_brick.sat");
00106       mk->save_mesh("meshed_brick.exo");
00107 #elif defined(HAVE_OCC)
00108       mk->save_geometry("un_meshed_brick.stp");
00109       mk->save_mesh("meshed_brick.exo");
00110 #endif
00111     }
00112 
00113   return 0;
00114 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines