void test_coregen_default(int argc, char **argv)
{
    // serial process
    int nrank = 0, nprocs =1;

    //Initialize MPI
#ifdef HAVE_PARALLEL_MOAB
    MPI::Init(argc, argv);
    nprocs = MPI::COMM_WORLD.Get_size();
    nrank = MPI::COMM_WORLD.Get_rank();
#endif

    MKCore *mk;
    mk = new MKCore();
    // create a model entity vector for construting coregen meshop, note that NO model entities are required.
    MEntVector nullMEntVec;

    // construct the meshop and set name
    CoreGen *cg = (CoreGen*) mk->construct_meshop("CoreGen", nullMEntVec);
    cg->set_name("coregen");

    // setup input/output files for creating the 'Reactor Core' model
    cg->prepareIO(argc, argv, nrank, nprocs, std::string(MESH_DIR));
    mk->setup_and_execute();
    mk->save_mesh("cgd.h5m");
#ifdef HAVE_PARALLEL_MOAB
    MPI::COMM_WORLD.Barrier();
    MPI::Finalize();
#endif

    delete mk;
}
Exemple #2
0
int load_and_mesh(const char *input_filename,
                  const char *output_filename,
                  int whole_geom, int* n_interval, int mesh_based_geom,
                  double box_increase, int vol_frac_res)
{
    bool result;
    time_t start_time, load_time, mesh_time, vol_frac_time,
            export_time, query_time_techX, query_time;

    // start up MK and load the geometry
    MKCore mk;
    time(&start_time);
    mk.load_mesh(input_filename, NULL, 0, 0, 0, true);
    time(&load_time);

    if (debug_EBMesher) {
        mk.save_mesh("input.vtk");
    }

    // get the volumes
    MEntVector vols;
    mk.get_entities_by_dimension(3, vols);

    // make EBMesher
    EBMesher *ebm = (EBMesher*) mk.construct_meshop("EBMesher", vols);
    ebm->use_whole_geom(whole_geom);
    ebm->use_mesh_geometry(mesh_based_geom);
    ebm->set_num_interval(n_interval);
    ebm->increase_box(box_increase);
    if (mesh_based_geom) ebm->set_obb_tree_box_dimension();

    // mesh embedded boundary mesh, by calling execute
    mk.setup_and_execute();
    time(&mesh_time);

    // caculate volume fraction, only for geometry input
    if (vol_frac_res > 0) {
        result = ebm->get_volume_fraction(vol_frac_res);
        if (!result) {
            std::cerr << "Couldn't get volume fraction." << std::endl;
            return 1;
        }
    }
    time(&vol_frac_time);

    // export mesh
    if (output_filename != NULL) {
        ebm->export_mesh(output_filename);
    }
    time(&export_time);

    if (whole_geom && debug_EBMesher) {
        // techX query function test
        double boxMin[3], boxMax[3];
        int nDiv[3];
        std::map< CutCellSurfEdgeKey, std::vector<double>, LessThan > mdCutCellSurfEdge;
        std::vector<int> vnInsideCellTechX;

        ebm->get_grid_and_edges_techX(boxMin, boxMax, nDiv,
                                      mdCutCellSurfEdge, vnInsideCellTechX);
        time(&query_time_techX);

        // multiple intersection EBMesh_cpp_fraction query test
        std::map< CutCellSurfEdgeKey, std::vector<double>, LessThan > mdCutCellEdge;
        std::vector<int> vnInsideCell;
        result = ebm->get_grid_and_edges(boxMin, boxMax, nDiv,
                                         mdCutCellEdge, vnInsideCell);
        if (!result) {
            std::cerr << "Couldn't get mesh information." << std::endl;
            return 1;
        }
        time(&query_time);
        std::cout << "# of TechX cut-cell surfaces: " << mdCutCellSurfEdge.size()
        << ", # of nInsideCell: " << vnInsideCell.size()/3 << std::endl;
    }

    std::cout << "EBMesh is succesfully finished." << std::endl;
    std::cout << "Time including loading: "
    << difftime(mesh_time, start_time)
    << " secs, Time excluding loading: "
    << difftime(mesh_time, load_time)
    << " secs, Time volume fraction: "
    << difftime(vol_frac_time, mesh_time) << " secs";

    if (output_filename != NULL) {
        std::cout << ", Time export mesh: "
        << difftime(export_time, vol_frac_time) << " secs";
    }

    if (whole_geom && debug_EBMesher) {
        std::cout << ", TechX query time: "
        << difftime(query_time_techX, export_time)
        << " secs, multiple intersection EBMesh_cpp_fraction query (elems, edge-cut fractions): "
        << difftime(query_time, query_time_techX) << " secs.";
    }

    std::cout << std::endl;
    mk.clear_graph();

    return 0;
}