Skip to content

Commit

Permalink
Merging develop into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Nightly Bot authored and cwsmith committed Aug 10, 2018
2 parents d2fbb26 + d783b19 commit e305d01
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 40 deletions.
148 changes: 109 additions & 39 deletions test/generate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include <pcu_util.h>
#include <cstdlib>

#include <iostream> //cout
#include <getopt.h> //option parser

#ifdef SIM_PARASOLID
#include "SimParasolidKrnl.h"
#endif
Expand All @@ -37,8 +40,12 @@ pAManager SModel_attManager(pModel model);

namespace {

int should_log = 0;
int disable_volume = 0;
int disable_surface = 0;
std::string modelFile;
std::string nativeModelFile;
std::string surfaceMeshFile;
std::string caseName;
std::string outMeshFile;

Expand Down Expand Up @@ -76,56 +83,118 @@ pParMesh generate(pGModel mdl, std::string meshCaseName) {
MS_processSimModelerAdvMeshingAtts(mcaseFile, mcase);
AttCase_setModel(mcase, mdl);

pParMesh pmesh = PM_new(0, mdl, PMU_size());
pParMesh pmesh;
if( ! surfaceMeshFile.empty() &&
disable_surface && !disable_volume ) {
//load the surface mesh instead of creating it
pmesh = PM_load(surfaceMeshFile.c_str(), mdl, NULL);
PM_setTotalNumParts(pmesh, PMU_size()); //enable parallel volume meshing
} else {
//create an empty surface mesh
pmesh = PM_new(0, mdl, PMU_size());
}

const double stime = MPI_Wtime();
if(0==PCU_Comm_Self()) {
printf("Meshing surface..."); fflush(stdout);
if( !disable_surface ) {
const double stime = MPI_Wtime();
if(0==PCU_Comm_Self()) {
printf("Meshing surface..."); fflush(stdout);
}
pSurfaceMesher surfaceMesher = SurfaceMesher_new(mcase, pmesh);
SurfaceMesher_execute(surfaceMesher, NULL);
SurfaceMesher_delete(surfaceMesher);
if(0==PCU_Comm_Self())
printf(" %f seconds\n", MPI_Wtime()-stime);
if( ! surfaceMeshFile.empty() ) {
if(0==PCU_Comm_Self())
printf(" writing surface mesh %s\n", surfaceMeshFile.c_str());
PM_write(pmesh, surfaceMeshFile.c_str(), NULL);
}
}
pSurfaceMesher surfaceMesher = SurfaceMesher_new(mcase, pmesh);
SurfaceMesher_execute(surfaceMesher, NULL);
SurfaceMesher_delete(surfaceMesher);
if(0==PCU_Comm_Self())
printf(" %f seconds\n", MPI_Wtime()-stime);

const double vtime = MPI_Wtime();
if(0==PCU_Comm_Self()) {
printf("Meshing volume..."); fflush(stdout);
if( !disable_volume ) {
const double vtime = MPI_Wtime();
if(0==PCU_Comm_Self()) {
printf("Meshing volume..."); fflush(stdout);
}
pVolumeMesher volumeMesher = VolumeMesher_new(mcase, pmesh);
VolumeMesher_execute(volumeMesher, NULL);
VolumeMesher_delete(volumeMesher);
if(0==PCU_Comm_Self())
printf(" %f seconds\n", MPI_Wtime()-vtime);
}
pVolumeMesher volumeMesher = VolumeMesher_new(mcase, pmesh);
VolumeMesher_execute(volumeMesher, NULL);
VolumeMesher_delete(volumeMesher);
if(0==PCU_Comm_Self())
printf(" %f seconds\n", MPI_Wtime()-vtime);

return pmesh;
}

void getConfig(int argc, char** argv)
{
if (argc < 3) {
if(0==PCU_Comm_Self()) {
printf("Usage: %s <GeomSim model (.smd)> <mesh case name> ", argv[0]);
printf(" to generate a mesh on a GeomSim model\n");
printf(" or: %s <SimModeler model (.smd)> <parasolid or acis native model> <mesh case name>\n", argv[0]);
printf(" to generate a mesh using the specified case name using the SimModeler"
"model which references the native parasolid or acis model\n");
void getConfig(int argc, char** argv) {
opterr = 0;

static struct option long_opts[] = {
{"enable-log", no_argument, &should_log, 1},
{"disable-volume", no_argument, &disable_volume, 1},
{"disable-surface", no_argument, &disable_surface, 1},
{"native-model", required_argument, 0, 'n'},
{"surface-mesh", required_argument, 0, 'm'},
{0, 0, 0, 0} // terminate the option array
};

const char* usage=""
"[options] <GeomSim model (.smd)> <mesh case name>\n"
"options:\n"
" --enable-log Enable Simmetrix logging\n"
" --disable-volume Disable volume mesh generation\n"
" --disable-surface Disable suface mesh generation\n"
" --native-model=/path/to/model Load the native Parasolid or ACIS model that the GeomSim model uses\n"
" --surface-mesh=/path/to/surfaceMesh read or write the surface mesh - depends on generation mode\n";

nativeModelFile = "";
surfaceMeshFile = "";
int option_index = 0;
while(1) {
int c = getopt_long(argc, argv, "", long_opts, &option_index);
if (c == -1) break; //end of options
switch (c) {
case 0: // enable-log|disable-volume|disable-surf
if (!PCU_Comm_Self())
printf ("read arg %d\n", c);
break;
case 'n':
nativeModelFile = std::string(optarg);
break;
case 'm':
surfaceMeshFile = std::string(optarg);
break;
case '?':
if (!PCU_Comm_Self())
printf ("warning: skipping unrecognized option\n");
break;
default:
if (!PCU_Comm_Self())
printf("Usage %s %s", argv[0], usage);
exit(EXIT_FAILURE);
}
MPI_Finalize();
exit(EXIT_SUCCESS);
}
modelFile = argv[1];
if (argc == 3) {
nativeModelFile = "";
outMeshFile = caseName = argv[2];
} else if (argc == 4) {
nativeModelFile = argv[2];
outMeshFile = caseName = argv[3];


if(argc-optind != 2) {
if (!PCU_Comm_Self())
printf("Usage %s %s", argv[0], usage);
exit(EXIT_FAILURE);
}
int i=optind;
modelFile = std::string(argv[i++]);
outMeshFile = caseName = std::string(argv[i++]);
outMeshFile.append("/");
if(0==PCU_Comm_Self()) {
printf("Inputs: model \'%s\' native model \'%s\' case \'%s\'\n",
modelFile.c_str(), nativeModelFile.c_str(), caseName.c_str());

if (!PCU_Comm_Self()) {
std::cout << "enable_log " << should_log <<
" disable_surface " << disable_surface <<
" disable_volume " << disable_volume <<
" native-model " << nativeModelFile <<
" model " << modelFile <<
" surface mesh " << surfaceMeshFile <<
" case name " << caseName <<
" output mesh" << outMeshFile << "\n";
}
}

Expand Down Expand Up @@ -193,6 +262,8 @@ pNativeModel loadNativeModel() {
void simStart() {
SimModel_start();
SimPartitionedMesh_start(NULL,NULL);
if(should_log)
Sim_logOn("generate_sim.log");
MS_init();
SimModel_start();
#ifdef SIM_PARASOLID
Expand Down Expand Up @@ -232,7 +303,6 @@ int main(int argc, char** argv)
getConfig(argc,argv);

simStart();
Sim_logOn("generate_sim.log");
pNativeModel nm = loadNativeModel();
pGModel simModel = GM_load(modelFile.c_str(), nm, NULL);

Expand Down
14 changes: 13 additions & 1 deletion test/testing.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,23 @@ if(ENABLE_SIMMETRIX)
./generate
"${MDIR}/upright.smd"
"67k")
mpi_test(parallel_meshgen_surf 4
./generate
"--disable-volume"
"--surface-mesh=${MDIR}/67k_surf.sms"
"${MDIR}/upright.smd"
"67k")
mpi_test(parallel_meshgen_vol 4
./generate
"--disable-surface"
"--surface-mesh=${MDIR}/67k_surf_ref.sms"
"${MDIR}/upright.smd"
"67k")
if(SIM_PARASOLID)
mpi_test(parallel_meshgen_para 4
./generate
"--native-model=${MDIR}/upright.x_t"
"${MDIR}/upright.smd"
"${MDIR}/upright.x_t"
"67k")
endif()
# adapt_meshgen uses the output of parallel_meshgen
Expand Down

0 comments on commit e305d01

Please sign in to comment.