[MOAB-dev] commit/MOAB: iulian07: enable mbcslam should work in serial builds too
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Wed Mar 12 21:55:00 CDT 2014
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/6694ba1ab8f8/
Changeset: 6694ba1ab8f8
Branch: master
User: iulian07
Date: 2014-03-13 03:52:37
Summary: enable mbcslam should work in serial builds too
the parallel tests are disabled, and USE_MPI define is
used as a guard for parallel specific code
some rearranging was needed
Affected #: 4 files
diff --git a/tools/mbcslam/Intx2Mesh.cpp b/tools/mbcslam/Intx2Mesh.cpp
index e055beb..b17cc33 100644
--- a/tools/mbcslam/Intx2Mesh.cpp
+++ b/tools/mbcslam/Intx2Mesh.cpp
@@ -5,8 +5,9 @@
*/
#include "Intx2Mesh.hpp"
-//#include "Coupler.hpp"
+#ifdef USE_MPI
#include "moab/ParallelComm.hpp"
+#endif /* USE_MPI */
#include "moab/AdaptiveKDTree.hpp"
#include "MBParallelConventions.h"
#include "MBTagConventions.hpp"
@@ -18,7 +19,10 @@
namespace moab {
-Intx2Mesh::Intx2Mesh(Interface * mbimpl): mb(mbimpl), parcomm(NULL), remote_cells(NULL)
+Intx2Mesh::Intx2Mesh(Interface * mbimpl): mb(mbimpl)
+#ifdef USE_MPI
+ , parcomm(NULL), remote_cells(NULL)
+#endif
{
dbg_1=0;
box_error=0;
@@ -33,11 +37,13 @@ Intx2Mesh::Intx2Mesh(Interface * mbimpl): mb(mbimpl), parcomm(NULL), remote_cell
Intx2Mesh::~Intx2Mesh()
{
// TODO Auto-generated destructor stub
+#ifdef USE_MPI
if (remote_cells)
{
delete remote_cells;
remote_cells=NULL;
}
+#endif
}
void Intx2Mesh::createTags()
{
@@ -404,11 +410,13 @@ ErrorCode Intx2Mesh::intersect_meshes(EntityHandle mbset1, EntityHandle mbset2,
// before cleaning up , we need to settle the position of the intersection points
// on the boundary edges
// this needs to be collective, so we should maybe wait something
+#ifdef USE_MPI
rval = correct_intersection_points_positions();
if (rval!=MB_SUCCESS)
{
std::cout << "can't correct position, Intx2Mesh.cpp \n";
}
+#endif
clean();
return MB_SUCCESS;
}
@@ -438,7 +446,38 @@ void Intx2Mesh::clean()
localEnts.clear();*/
}
-
+// this method will reduce number of nodes, collapse edges that are of length 0
+ // so a polygon like 428 431 431 will become a line 428 431
+ // or something like 428 431 431 531 -> 428 431 531
+void Intx2Mesh::correct_polygon(EntityHandle * nodes, int & nP)
+{
+ int i = 0;
+ while(i<nP)
+ {
+ int nextIndex = (i+1)%nP;
+ if (nodes[i]==nodes[nextIndex])
+ {
+ // we need to reduce nP, and collapse nodes
+ if (dbg_1)
+ {
+ std::cout<<" nodes duplicated in list: " ;
+ for (int j=0; j<nP; j++)
+ std::cout<<nodes[j] << " " ;
+ std::cout<<"\n";
+ std::cout<<" node " << nodes[i] << " at index " << i << " is duplicated" << "\n";
+ }
+ // this will work even if we start from 1 2 3 1; when i is 3, we find nextIndex is 0, then next thing does nothing
+ // (nP-1 is 3, so k is already >= nP-1); it will result in nodes -> 1, 2, 3
+ for (int k=i; k<nP-1; k++)
+ nodes[k] = nodes[k+1];
+ nP--; // decrease the number of nodes; also, decrease i, just if we may need to check again
+ i--;
+ }
+ i++;
+ }
+ return;
+}
+#if USE_MPI
ErrorCode Intx2Mesh::build_processor_euler_boxes(EntityHandle euler_set, Range & local_verts)
{
localEnts.clear();
@@ -1119,37 +1158,6 @@ ErrorCode Intx2Mesh::create_departure_mesh_3rd_alg(EntityHandle & lagr_set,
return MB_SUCCESS;
//end copy
}
-// this method will reduce number of nodes, collapse edges that are of length 0
- // so a polygon like 428 431 431 will become a line 428 431
- // or something like 428 431 431 531 -> 428 431 531
-void Intx2Mesh::correct_polygon(EntityHandle * nodes, int & nP)
-{
- int i = 0;
- while(i<nP)
- {
- int nextIndex = (i+1)%nP;
- if (nodes[i]==nodes[nextIndex])
- {
- // we need to reduce nP, and collapse nodes
- if (dbg_1)
- {
- std::cout<<" nodes duplicated in list: " ;
- for (int j=0; j<nP; j++)
- std::cout<<nodes[j] << " " ;
- std::cout<<"\n";
- std::cout<<" node " << nodes[i] << " at index " << i << " is duplicated" << "\n";
- }
- // this will work even if we start from 1 2 3 1; when i is 3, we find nextIndex is 0, then next thing does nothing
- // (nP-1 is 3, so k is already >= nP-1); it will result in nodes -> 1, 2, 3
- for (int k=i; k<nP-1; k++)
- nodes[k] = nodes[k+1];
- nP--; // decrease the number of nodes; also, decrease i, just if we may need to check again
- i--;
- }
- i++;
- }
- return;
-}
ErrorCode Intx2Mesh::correct_intersection_points_positions()
{
@@ -1169,4 +1177,5 @@ ErrorCode Intx2Mesh::correct_intersection_points_positions()
}
return MB_SUCCESS;
}
+#endif /* USE_MPI */
} /* namespace moab */
diff --git a/tools/mbcslam/Intx2Mesh.hpp b/tools/mbcslam/Intx2Mesh.hpp
index d54b0b5..528ab7e 100644
--- a/tools/mbcslam/Intx2Mesh.hpp
+++ b/tools/mbcslam/Intx2Mesh.hpp
@@ -32,9 +32,11 @@ namespace moab {
#define ERRORV(rval, str) \
if (MB_SUCCESS != rval) {std::cout << str << "\n"; return ;}
+#ifdef USE_MPI
// forward declarations
class ParallelComm;
class TupleList;
+#endif
class Intx2Mesh
{
@@ -93,9 +95,9 @@ public:
ErrorCode build_processor_euler_boxes(EntityHandle euler_set, Range & local_verts);
void correct_polygon(EntityHandle * foundIds, int & nP);
-
+#ifdef USE_MPI
ErrorCode correct_intersection_points_positions();
-
+#endif
void enable_debug() {dbg_1 = 1;}
void disable_debug() {dbg_1 = 0;}
protected: // so it can be accessed in derived classes, InPlane and OnSphere
@@ -141,20 +143,21 @@ protected: // so it can be accessed in derived classes, InPlane and OnSphere
double epsilon_1;
double epsilon_area;
- ParallelComm * parcomm;
-
std::vector<double> allBoxes;
double box_error;
/* \brief Local root of the kdtree */
EntityHandle localRoot;
Range localEnts;// this range is for local elements of interest, euler cells
-
unsigned int my_rank;
- int max_edges; // maximum number of edges in the euler set
-
+#ifdef USE_MPI
+ ParallelComm * parcomm;
TupleList * remote_cells;
std::map<int, EntityHandle> globalID_to_eh;// needed for parallel, mostly
+#endif
+ int max_edges; // maximum number of edges in the euler set
+
+
};
diff --git a/tools/mbcslam/Intx2MeshOnSphere.cpp b/tools/mbcslam/Intx2MeshOnSphere.cpp
index ac33e91..5b7a88a 100644
--- a/tools/mbcslam/Intx2MeshOnSphere.cpp
+++ b/tools/mbcslam/Intx2MeshOnSphere.cpp
@@ -7,8 +7,10 @@
#include "Intx2MeshOnSphere.hpp"
#include "moab/GeomUtil.hpp"
#include "MBTagConventions.hpp"
-#include "moab/ParallelComm.hpp"
#include <queue>
+#ifdef USE_MPI
+#include "moab/ParallelComm.hpp"
+#endif
namespace moab {
@@ -481,6 +483,7 @@ ErrorCode Intx2MeshOnSphere::update_tracer_data(EntityHandle out_set, Tag & tagE
rval = mb->tag_get_data(corrTag, &blue, 1, &redArr);
if (0==redArr || MB_TAG_NOT_FOUND==rval)
{
+#ifdef USE_MPI
if (!remote_cells)
ERRORR( MB_FAILURE, "no remote cells, failure\n");
// maybe the element is remote, from another processor
@@ -492,6 +495,7 @@ ErrorCode Intx2MeshOnSphere::update_tracer_data(EntityHandle out_set, Tag & tagE
if (index_in_remote==-1)
ERRORR( MB_FAILURE, "can't find the global id element in remote cells\n");
remote_cells->vr_wr[index_in_remote] += currentVals[redIndex]*areap;
+#endif
}
else if (MB_SUCCESS==rval)
{
@@ -506,6 +510,7 @@ ErrorCode Intx2MeshOnSphere::update_tracer_data(EntityHandle out_set, Tag & tagE
}
// now, send back the remote_cells to the processors they came from, with the updated values for
// the tracer mass in a cell
+#ifdef USE_MPI
if (remote_cells)
{
// so this means that some cells will be sent back with tracer info to the procs they were sent from
@@ -522,7 +527,7 @@ ErrorCode Intx2MeshOnSphere::update_tracer_data(EntityHandle out_set, Tag & tagE
newValues[arrRedIndex] += remote_cells->vr_rd[j];
}
}
-
+#endif /* USE_MPI */
// now divide by red area (current)
int j=0;
Range::iterator iter = rs2.begin();
@@ -543,6 +548,8 @@ ErrorCode Intx2MeshOnSphere::update_tracer_data(EntityHandle out_set, Tag & tagE
rval = mb->tag_set_data(tagElem, rs2, &newValues[0]);
ERRORR(rval, "can't set new values tag");
+
+#ifdef USE_MPI
double total_mass=0.;
double total_intx_area =0;
int mpi_err = MPI_Reduce(&total_mass_local, &total_mass, 1, MPI_DOUBLE, MPI_SUM, 0, MPI_COMM_WORLD);
@@ -553,7 +560,7 @@ ErrorCode Intx2MeshOnSphere::update_tracer_data(EntityHandle out_set, Tag & tagE
if (my_rank==0)
{
std::cout <<"total mass now:" << total_mass << "\n";
- std::cout <<"check: total intersection area: (4 * M_PI * R^2): " << total_intx_area << "\n";
+ std::cout <<"check: total intersection area: (4 * M_PI * R^2): " << 4 * M_PI * R*R << " " << total_intx_area << "\n";
}
if (remote_cells)
@@ -561,6 +568,10 @@ ErrorCode Intx2MeshOnSphere::update_tracer_data(EntityHandle out_set, Tag & tagE
delete remote_cells;
remote_cells=NULL;
}
+#else
+ std::cout <<"total mass now:" << total_mass_local << "\n";
+ std::cout <<"check: total intersection area: (4 * M_PI * R^2): " << 4 * M_PI * R*R << " " << check_intx_area << "\n";
+#endif
return MB_SUCCESS;
}
} /* namespace moab */
diff --git a/tools/mbcslam/Makefile.am b/tools/mbcslam/Makefile.am
index 0dac164..ffc3dff 100644
--- a/tools/mbcslam/Makefile.am
+++ b/tools/mbcslam/Makefile.am
@@ -24,7 +24,11 @@ LDADD = libmbcslam.la $(top_builddir)/src/libMOAB.la
libmbcslam_la_SOURCES = \
Intx2Mesh.cpp Intx2Mesh.hpp Intx2MeshOnSphere.cpp Intx2MeshOnSphere.hpp \
- CslamUtils.cpp CslamUtils.hpp Intx2MeshInPlane.cpp Intx2MeshInPlane.hpp wrap_intx.cpp
+ CslamUtils.cpp CslamUtils.hpp Intx2MeshInPlane.cpp Intx2MeshInPlane.hpp
+
+if PARALLEL
+ libmbcslam_la_SOURCES += wrap_intx.cpp
+endif
# these will be installed
libmbcslam_la_include_HEADERS =
@@ -38,24 +42,36 @@ libmbcslam_la_includedir = $(includedir)
cfgdir = $(libdir)
TESTS = intx_on_sphere_test intx_in_plane_test spherical_area_test \
- case1_test intx_mpas
-noinst_PROGRAMS = cslam_par_test diffusion proj1 intx_imesh create_dp advection
+ case1_test
+if PARALLEL
+ TESTS+=intx_mpas
+endif
+
+noinst_PROGRAMS = proj1 create_dp
+if PARALLEL
+ noinst_PROGRAMS +=cslam_par_test diffusion intx_imesh advection
+endif
check_PROGRAMS = $(TESTS)
+
intx_on_sphere_test_SOURCES = intx_on_sphere_test.cpp
-diffusion_SOURCES = diffusion.cpp
+
intx_in_plane_test_SOURCES = intx_in_plane_test.cpp
# spec_visu_test_SOURCES = spec_visu_test.cpp
spherical_area_test_SOURCES = spherical_area_test.cpp
case1_test_SOURCES = case1_test.cpp
-intx_mpas_SOURCES = intx_mpas.cpp
-cslam_par_test_SOURCES = cslam_par_test.cpp
proj1_SOURCES = proj1.cpp
-intx_imesh_SOURCES = intx_imesh.cpp
-intx_imesh_LDADD = $(LDADD) $(top_builddir)/itaps/imesh/libiMesh.la
create_dp_SOURCES = create_dp.cpp
-advection_SOURCES = advection.F90
-advection_LDADD = $(LDADD) $(top_builddir)/itaps/imesh/libiMesh.la
+
+if PARALLEL
+ diffusion_SOURCES = diffusion.cpp
+ intx_imesh_SOURCES = intx_imesh.cpp
+ intx_imesh_LDADD = $(LDADD) $(top_builddir)/itaps/imesh/libiMesh.la
+ cslam_par_test_SOURCES = cslam_par_test.cpp
+ intx_mpas_SOURCES = intx_mpas.cpp
+ advection_SOURCES = advection.F90
+ advection_LDADD = $(LDADD) $(top_builddir)/itaps/imesh/libiMesh.la
+endif
EXTRA_DIST = lagrangeHomme.vtk \
eulerHomme.vtk \
Repository URL: https://bitbucket.org/fathomteam/moab/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the moab-dev
mailing list