[MOAB-dev] r1656 - MOAB/trunk/tools/iMesh
tautges at mcs.anl.gov
tautges at mcs.anl.gov
Thu Mar 13 16:27:32 CDT 2008
Author: tautges
Date: 2008-03-13 16:27:32 -0500 (Thu, 13 Mar 2008)
New Revision: 1656
Modified:
MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
MOAB/trunk/tools/iMesh/partest.cpp
Log:
Adding option string to newMesh call in partest to tell it to initialize in parallel; also adding parsing of that option in iMesh implementation.
Modified: MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp
===================================================================
--- MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp 2008-03-13 20:47:33 UTC (rev 1655)
+++ MOAB/trunk/tools/iMesh/iMesh_MOAB.cpp 2008-03-13 21:27:32 UTC (rev 1656)
@@ -3,7 +3,12 @@
#include "MBRange.hpp"
#include "MBCN.hpp"
#include "MeshTopoUtil.hpp"
+#include "FileOptions.hpp"
+#ifdef USE_MPI
+#include "mpi.h"
+#endif
+
#include <iostream>
#define MIN(a,b) (a < b ? a : b)
@@ -12,7 +17,10 @@
private:
bool haveDeletedEntities;
public:
- MBiMesh() : haveDeletedEntities(false) {}
+ MBiMesh(int proc_rank = 0, int proc_size = 0)
+ : MBCore(proc_rank, proc_size), haveDeletedEntities(false)
+ {}
+
virtual ~MBiMesh();
bool have_deleted_ents( bool reset ) {
bool result = haveDeletedEntities;
@@ -232,7 +240,27 @@
void iMesh_newMesh(const char *options,
iMesh_Instance *instance, int *err, int options_len)
{
- MBInterface* core = new MBiMesh();
+ std::string tmp_options(options, options_len);
+ FileOptions opts(tmp_options.c_str());
+
+ MBInterface* core;
+
+ MBErrorCode result = opts.get_null_option("PARALLEL");
+ if (MB_SUCCESS == result) {
+#ifdef USE_MPI
+ int rank, size;
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ core = new MBiMesh(rank, size);
+#else
+ mError->set_last_error( "PARALLEL option not valid, this instance"
+ " compiled for serial execution.\n" );
+ *err = MB_NOT_IMPLEMENTED;
+ return;
+#endif
+ }
+ else core = new MBiMesh();
+
*instance = reinterpret_cast<iMesh_Instance>(core);
if (0 == *instance) {
iMesh_processError(iBase_FAILURE, "Failed to instantiate mesh instance.");
Modified: MOAB/trunk/tools/iMesh/partest.cpp
===================================================================
--- MOAB/trunk/tools/iMesh/partest.cpp 2008-03-13 20:47:33 UTC (rev 1655)
+++ MOAB/trunk/tools/iMesh/partest.cpp 2008-03-13 21:27:32 UTC (rev 1656)
@@ -4,7 +4,7 @@
#include "iMesh.h"
-#define IMESH_ASSERT(ierr) if (ierr!=0) printf("imesh asser\n");
+#define IMESH_ASSERT(ierr) if (ierr!=0) printf("imesh assert\n");
#define IMESH_NULL 0
int main(int argc, char* argv[]){
@@ -16,7 +16,7 @@
imesh = IMESH_NULL;
- iMesh_newMesh("", &imesh, &ierr, 0);
+ iMesh_newMesh("PARALLEL", &imesh, &ierr, 8);
IMESH_ASSERT(ierr);
More information about the moab-dev
mailing list