[MOAB-dev] r1937 - in MOAB/trunk: . tools/mbcoupler
tautges at mcs.anl.gov
tautges at mcs.anl.gov
Thu Jun 26 20:14:13 CDT 2008
Author: tautges
Date: 2008-06-26 20:14:12 -0500 (Thu, 26 Jun 2008)
New Revision: 1937
Modified:
MOAB/trunk/MBAdaptiveKDTree.cpp
MOAB/trunk/MBAdaptiveKDTree.hpp
MOAB/trunk/MBMatrix3.hpp
MOAB/trunk/tools/mbcoupler/MBCoupler.cpp
MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp
Log:
- adding some timing and kdtree data to coupler output
- adding function to get kdtree depth info
- adding include to MBMatrix3.hpp
Modified: MOAB/trunk/MBAdaptiveKDTree.cpp
===================================================================
--- MOAB/trunk/MBAdaptiveKDTree.cpp 2008-06-27 00:09:29 UTC (rev 1936)
+++ MOAB/trunk/MBAdaptiveKDTree.cpp 2008-06-27 01:14:12 UTC (rev 1937)
@@ -1897,3 +1897,18 @@
return MB_SUCCESS;
}
+MBErrorCode MBAdaptiveKDTree::get_info(MBEntityHandle root,
+ double min[3], double max[3],
+ unsigned int &dep)
+{
+ MBErrorCode result = get_tree_box(root, min, max);
+ if (MB_SUCCESS != result) return result;
+
+ MBAdaptiveKDTreeIter iter;
+ get_tree_iterator( root, iter );
+ iter.step_to_first_leaf(MBAdaptiveKDTreeIter::LEFT);
+ dep = iter.depth();
+
+ return MB_SUCCESS;
+}
+
Modified: MOAB/trunk/MBAdaptiveKDTree.hpp
===================================================================
--- MOAB/trunk/MBAdaptiveKDTree.hpp 2008-06-27 00:09:29 UTC (rev 1936)
+++ MOAB/trunk/MBAdaptiveKDTree.hpp 2008-06-27 01:14:12 UTC (rev 1937)
@@ -165,6 +165,11 @@
MBErrorCode build_tree( const MBRange& entities,
MBEntityHandle& root_set_out,
const Settings* settings = 0 );
+
+ //! get some information about the tree
+ MBErrorCode get_info(MBEntityHandle root,
+ double min[3], double max[3],
+ unsigned int &dep);
//! Find triangle closest to input position.
//!\param from_coords The input position to test against
Modified: MOAB/trunk/MBMatrix3.hpp
===================================================================
--- MOAB/trunk/MBMatrix3.hpp 2008-06-27 00:09:29 UTC (rev 1936)
+++ MOAB/trunk/MBMatrix3.hpp 2008-06-27 01:14:12 UTC (rev 1937)
@@ -24,6 +24,7 @@
#include "MBCartVect.hpp"
#include "MBTypes.h"
#include <iosfwd>
+#include <limits>
class MBMatrix3
{
Modified: MOAB/trunk/tools/mbcoupler/MBCoupler.cpp
===================================================================
--- MOAB/trunk/tools/mbcoupler/MBCoupler.cpp 2008-06-27 00:09:29 UTC (rev 1936)
+++ MOAB/trunk/tools/mbcoupler/MBCoupler.cpp 2008-06-27 01:14:12 UTC (rev 1937)
@@ -52,6 +52,7 @@
MBRange local_ents;
MBAdaptiveKDTree::Settings settings;
+ settings.candidatePlaneSet = MBAdaptiveKDTree::SUBDIVISION;
allBoxes.resize(6*myPc->proc_config().proc_size());
//get entities on the local part
@@ -78,6 +79,17 @@
int mpi_err = MPI_Allgather(&allBoxes[6*my_rank], 6, MPI_DOUBLE,
&allBoxes[0], 6, MPI_DOUBLE,
myPc->proc_config().proc_comm());
+
+#ifndef NDEBUG
+ double min[3] = {0,0,0}, max[3] = {0,0,0};
+ unsigned int dep;
+ myTree->get_info(localRoot, min, max, dep);
+ std::cout << "Proc " << my_rank << ": box min/max, tree depth = ("
+ << min[0] << "," << min[1] << "," << min[2] << "), ("
+ << max[0] << "," << max[1] << "," << max[2] << "), "
+ << dep << std::endl;
+#endif
+
if (MPI_SUCCESS == mpi_err) return MB_SUCCESS;
else return MB_FAILURE;
}
Modified: MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp
===================================================================
--- MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp 2008-06-27 00:09:29 UTC (rev 1936)
+++ MOAB/trunk/tools/mbcoupler/mbcoupler_test.cpp 2008-06-27 01:14:12 UTC (rev 1937)
@@ -34,7 +34,10 @@
MBErrorCode test_interpolation(MBInterface *mbImpl,
std::string &interp_tag,
std::vector<MBParallelComm *> &pcs,
- std::vector<ReadParallel *> rps);
+ std::vector<ReadParallel *> rps,
+ double &instant_time,
+ double &pointloc_time,
+ double &interp_time);
int main(int argc, char **argv)
{
@@ -94,16 +97,24 @@
PRINT_LAST_ERROR;
if (!interp_tag.empty()) {
+ double instant_time, pointloc_time, interp_time;
// test interpolation
- result = test_interpolation(mbImpl, interp_tag, pcs, rps);
+ result = test_interpolation(mbImpl, interp_tag, pcs, rps,
+ instant_time, pointloc_time, interp_time);
PRINT_LAST_ERROR;
+ std::cout << "Coupler instantiation/point location/interpolation times = "
+ << instant_time << ", "
+ << pointloc_time << ", "
+ << interp_time << std::endl;
}
// output mesh
- result = mbImpl->write_file("output.h5m", NULL, NULL,
+ const char *outfile = "output.h5m";
+ result = mbImpl->write_file(outfile, NULL, NULL,
pcs[1]->partition_sets());
PRINT_LAST_ERROR;
-
+ std::cout << "Wrote " << outfile << std::endl;
+
std::cout << "Success." << std::endl;
err = MPI_Finalize();
@@ -206,16 +217,23 @@
MBErrorCode test_interpolation(MBInterface *mbImpl,
std::string &interp_tag,
std::vector<MBParallelComm *> &pcs,
- std::vector<ReadParallel *> rps)
+ std::vector<ReadParallel *> rps,
+ double &instant_time,
+ double &pointloc_time,
+ double &interp_time)
{
// source is 1st mesh, target is 2nd
MBRange src_elems, targ_elems;
MBErrorCode result = pcs[0]->get_part_entities(src_elems, 3);
PRINT_LAST_ERROR;
+ double start_time = MPI_Wtime();
+
// instantiate a coupler, which also initializes the tree
MBCoupler mbc(mbImpl, pcs[0], src_elems, 0);
+ instant_time = MPI_Wtime();
+
// get points from the target mesh to interpolate
MBRange targ_verts, tmp_verts;
@@ -239,11 +257,19 @@
result = mbc.locate_points(&vpos[0], targ_verts.size());
PRINT_LAST_ERROR;
+ pointloc_time = MPI_Wtime();
+
// now interpolate tag onto target points
std::vector<double> field(targ_verts.size());
result = mbc.interpolate(MBCoupler::LINEAR_FE, interp_tag, &field[0]);
PRINT_LAST_ERROR;
+ interp_time = MPI_Wtime();
+
+ interp_time -= pointloc_time;
+ pointloc_time -= instant_time;
+ instant_time -= start_time;
+
// set field values as tag on target vertices
MBTag tag;
result = mbImpl->tag_get_handle(interp_tag.c_str(), tag); PRINT_LAST_ERROR;
More information about the moab-dev
mailing list