[MOAB-dev] commit/MOAB: danwu: Minor changes to some error handling code in NC reader classes.
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Mar 25 11:13:51 CDT 2014
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/7094995cc2e2/
Changeset: 7094995cc2e2
Branch: error_handling_enhancement
User: danwu
Date: 2014-03-25 17:13:34
Summary: Minor changes to some error handling code in NC reader classes.
Affected #: 5 files
diff --git a/src/io/NCHelper.cpp b/src/io/NCHelper.cpp
index eccb43f..8124098 100644
--- a/src/io/NCHelper.cpp
+++ b/src/io/NCHelper.cpp
@@ -938,7 +938,7 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
tmp_range.insert(scd_box->start_element(), scd_box->start_element() + scd_box->num_elements() - 1);
tmp_range.insert(scd_box->box_set());
rval = mbImpl->add_entities(_fileSet, tmp_range); \
- CHK_ERR1(rval, "Couldn't add new vertices to file set");
+ CHK_ERR1(rval, "Couldn't add new vertices to current file set");
dbgOut.tprintf(1, "scdbox %d quads, %d vertices\n", scd_box->num_elements(), scd_box->num_vertices());
@@ -972,7 +972,7 @@ ErrorCode ScdNCHelper::create_mesh(Range& faces)
std::vector<int> gids(num_verts);
Range verts(scd_box->start_vertex(), scd_box->start_vertex() + scd_box->num_vertices() - 1);
rval = mbImpl->tag_get_data(mGlobalIdTag, verts, &gids[0]); \
- CHK_ERR1(rval, "Trouble getting gid values");
+ CHK_ERR1(rval, "Trouble getting local gid values of vertices");
int vmin = *(std::min_element(gids.begin(), gids.end())), vmax = *(std::max_element(gids.begin(), gids.end()));
dbgOut.tprintf(1, "Vertex gids %d-%d\n", vmin, vmax);
#endif
@@ -1037,18 +1037,14 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset_allocate(std::vector<ReadNC:
// Get vertices in set
Range verts;
rval = mbImpl->get_entities_by_dimension(_fileSet, 0, verts); \
- CHK_ERR1(rval, "Trouble getting vertices in set");
+ CHK_ERR1(rval, "Trouble getting vertices in current file set");
assert("Should only have a single vertex subrange, since they were read in one shot" &&
verts.psize() == 1);
- Range edges;
- rval = mbImpl->get_entities_by_dimension(_fileSet, 1, edges); \
- CHK_ERR1(rval, "Trouble getting edges in set");
-
// Get faces in set
Range faces;
rval = mbImpl->get_entities_by_dimension(_fileSet, 2, faces); \
- CHK_ERR1(rval, "Trouble getting faces in set");
+ CHK_ERR1(rval, "Trouble getting faces in current file set");
assert("Should only have a single face subrange, since they were read in one shot" &&
faces.psize() == 1);
@@ -1058,7 +1054,7 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset_allocate(std::vector<ReadNC:
if (isParallel) {
ParallelComm*& myPcomm = _readNC->myPcomm;
rval = myPcomm->filter_pstatus(faces, PSTATUS_NOT_OWNED, PSTATUS_NOT, -1, &faces_owned); \
- CHK_ERR1(rval, "Trouble getting owned faces in set");
+ CHK_ERR1(rval, "Trouble getting owned faces in current file set");
}
else
faces_owned = faces; // Not running in parallel, but still with MPI
@@ -1095,6 +1091,7 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset_allocate(std::vector<ReadNC:
break;
case ReadNC::ENTLOCNSEDGE:
case ReadNC::ENTLOCEWEDGE:
+ case ReadNC::ENTLOCEDGE:
SET_GLB_ERR(MB_NOT_IMPLEMENTED, "Reading edge data is not implemented yet");
case ReadNC::ENTLOCFACE:
// Faces
@@ -1108,18 +1105,15 @@ ErrorCode ScdNCHelper::read_scd_variables_to_nonset_allocate(std::vector<ReadNC:
range = &faces;
#endif
break;
- case ReadNC::ENTLOCSET:
- // Set
- break;
default:
- SET_ERR_STR(MB_FAILURE, "Unrecognized entity location type for non-set variable " << vdatas[i].varName);
+ SET_ERR_STR(MB_FAILURE, "Unexpected entity location type for non-set variable " << vdatas[i].varName);
}
for (unsigned int t = 0; t < tstep_nums.size(); t++) {
dbgOut.tprintf(2, "Reading non-set variable %s, time step %d\n", vdatas[i].varName.c_str(), tstep_nums[t]);
if (tstep_nums[t] >= dimLens[tDim]) {
- SET_ERR_STR(MB_INDEX_OUT_OF_RANGE, "Wrong value for a timestep number " << tstep_nums[t]);
+ SET_ERR_STR(MB_INDEX_OUT_OF_RANGE, "Wrong value for timestep number " << tstep_nums[t]);
}
// Get the tag to read into
diff --git a/src/io/NCHelper.hpp b/src/io/NCHelper.hpp
index 25103a3..12e3b0e 100644
--- a/src/io/NCHelper.hpp
+++ b/src/io/NCHelper.hpp
@@ -134,7 +134,7 @@ private:
//! Create COORDS tag for quads coordinate
ErrorCode create_quad_coordinate_tag();
- template <typename T> ErrorCode kji_to_jik(size_t ni, size_t nj, size_t nk, void* dest, T* source)
+ template <typename T> void kji_to_jik(size_t ni, size_t nj, size_t nk, void* dest, T* source)
{
size_t nik = ni * nk, nij = ni * nj;
T* tmp_data = reinterpret_cast<T*>(dest);
@@ -142,7 +142,6 @@ private:
for (std::size_t i = 0; i != ni; i++)
for (std::size_t k = 0; k != nk; k++)
tmp_data[j*nik + i*nk + k] = source[k*nij + j*ni + i];
- return MB_SUCCESS;
}
protected:
@@ -207,7 +206,7 @@ private:
protected:
//! This version takes as input the moab range, from which we actually need just the
//! size of each sequence, for a proper transpose of the data
- template <typename T> ErrorCode kji_to_jik_stride(size_t , size_t nj, size_t nk, void* dest, T* source, Range& localGid)
+ template <typename T> void kji_to_jik_stride(size_t , size_t nj, size_t nk, void* dest, T* source, Range& localGid)
{
std::size_t idxInSource = 0; // Position of the start of the stride
// For each subrange, we will transpose a matrix of size
@@ -223,7 +222,6 @@ protected:
tmp_data[idxInSource + j*nik + i*nk + k] = source[idxInSource + k*nij + j*size_range + i];
idxInSource += (size_range*nj*nk);
}
- return MB_SUCCESS;
}
//! Dimensions of global grid in file
diff --git a/src/io/NCHelperHOMME.cpp b/src/io/NCHelperHOMME.cpp
index 8da3e60..7f650fd 100644
--- a/src/io/NCHelperHOMME.cpp
+++ b/src/io/NCHelperHOMME.cpp
@@ -384,7 +384,7 @@ ErrorCode NCHelperHOMME::create_mesh(Range& faces)
MBQUAD, 0, start_quad, conn_arr,
// Might have to create gather mesh later
(create_gathers ? num_coarse_quads + num_quads : num_coarse_quads)); \
- CHK_ERR1(rval, "Failed to create quads");
+ CHK_ERR1(rval, "Failed to create local quads");
tmp_range.insert(start_quad, start_quad + num_coarse_quads - 1);
std::copy(&tmp_conn[start_idx], &tmp_conn[start_idx + 4 * num_fine_quads], conn_arr);
std::copy(conn_arr, conn_arr + 4 * num_fine_quads, range_inserter(localGidVerts));
@@ -406,7 +406,7 @@ ErrorCode NCHelperHOMME::create_mesh(Range& faces)
rval = _readNC->readMeshIface->get_node_coords(3, nLocalVertices, 0, start_vertex, arrays,
// Might have to create gather mesh later
(create_gathers ? nLocalVertices + nVertices : nLocalVertices)); \
- CHK_ERR1(rval, "Failed to create vertices");
+ CHK_ERR1(rval, "Failed to create local vertices");
// Set vertex coordinates
Range::iterator rit;
diff --git a/src/io/NCHelperMPAS.cpp b/src/io/NCHelperMPAS.cpp
index 3d777c2..305257e 100644
--- a/src/io/NCHelperMPAS.cpp
+++ b/src/io/NCHelperMPAS.cpp
@@ -217,17 +217,15 @@ ErrorCode NCHelperMPAS::check_existing_mesh()
if (localGidVerts.empty()) {
// Get all vertices from tmp_set (it is the input set in no_mesh scenario)
Range local_verts;
- rval = mbImpl->get_entities_by_dimension(_fileSet, 0, local_verts);
- if (MB_FAILURE == rval)
- return rval;
+ rval = mbImpl->get_entities_by_dimension(_fileSet, 0, local_verts); \
+ CHK_ERR1(rval, "Trouble getting local vertices in current file set");
if (!local_verts.empty()) {
std::vector<int> gids(local_verts.size());
// !IMPORTANT : this has to be the GLOBAL_ID tag
- rval = mbImpl->tag_get_data(mGlobalIdTag, local_verts, &gids[0]);
- if (MB_FAILURE == rval)
- return rval;
+ rval = mbImpl->tag_get_data(mGlobalIdTag, local_verts, &gids[0]); \
+ CHK_ERR1(rval, "Trouble getting local gid values of vertices");
// Restore localGidVerts
std::copy(gids.rbegin(), gids.rend(), range_inserter(localGidVerts));
@@ -238,17 +236,15 @@ ErrorCode NCHelperMPAS::check_existing_mesh()
if (localGidEdges.empty()) {
// Get all edges from _fileSet (it is the input set in no_mesh scenario)
Range local_edges;
- rval = mbImpl->get_entities_by_dimension(_fileSet, 1, local_edges);
- if (MB_FAILURE == rval)
- return rval;
+ rval = mbImpl->get_entities_by_dimension(_fileSet, 1, local_edges); \
+ CHK_ERR1(rval, "Trouble getting local edges in current file set");
if (!local_edges.empty()) {
std::vector<int> gids(local_edges.size());
// !IMPORTANT : this has to be the GLOBAL_ID tag
- rval = mbImpl->tag_get_data(mGlobalIdTag, local_edges, &gids[0]);
- if (MB_FAILURE == rval)
- return rval;
+ rval = mbImpl->tag_get_data(mGlobalIdTag, local_edges, &gids[0]); \
+ CHK_ERR1(rval, "Trouble getting local gid values of edges");
// Restore localGidEdges
std::copy(gids.rbegin(), gids.rend(), range_inserter(localGidEdges));
@@ -257,19 +253,17 @@ ErrorCode NCHelperMPAS::check_existing_mesh()
}
if (localGidCells.empty()) {
- // Get all cells from tmp_set (it is the input set in no_mesh scenario)
+ // Get all cells from current file set (it is the input set in no_mesh scenario)
Range local_cells;
rval = mbImpl->get_entities_by_dimension(_fileSet, 2, local_cells);
- if (MB_FAILURE == rval)
- return rval;
+ CHK_ERR1(rval, "Trouble getting local cells in current file set");
if (!local_cells.empty()) {
std::vector<int> gids(local_cells.size());
// !IMPORTANT : this has to be the GLOBAL_ID tag
- rval = mbImpl->tag_get_data(mGlobalIdTag, local_cells, &gids[0]);
- if (MB_FAILURE == rval)
- return rval;
+ rval = mbImpl->tag_get_data(mGlobalIdTag, local_cells, &gids[0]); \
+ CHK_ERR1(rval, "Trouble getting local gid values of cells");
// Restore localGidCells
std::copy(gids.rbegin(), gids.rend(), range_inserter(localGidCells));
@@ -1245,7 +1239,7 @@ ErrorCode NCHelperMPAS::create_local_edges(EntityHandle start_vertex, const std:
ErrorCode rval = _readNC->readMeshIface->get_element_connect(nLocalEdges, 2, MBEDGE, 0, start_edge, conn_arr_edges,
// Might have to create gather mesh later
(createGatherSet ? nLocalEdges + nEdges : nLocalEdges)); \
- CHK_ERR1(rval, "Failed to create edges");
+ CHK_ERR1(rval, "Failed to create local edges");
// Add local edges to current file set
Range local_edges_range(start_edge, start_edge + nLocalEdges - 1);
@@ -1351,7 +1345,7 @@ ErrorCode NCHelperMPAS::create_local_cells(const std::vector<int>& vertices_on_l
EntityHandle start_element;
ErrorCode rval = _readNC->readMeshIface->get_element_connect(num_group_cells, num_edges_per_cell, MBPOLYGON, 0, start_element,
conn_arr_local_cells_with_n_edges[num_edges_per_cell], num_group_cells); \
- CHK_ERR1(rval, "Failed to create cells");
+ CHK_ERR1(rval, "Failed to create local cells");
faces.insert(start_element, start_element + num_group_cells - 1);
// Add local cells to current file set
@@ -1449,7 +1443,7 @@ ErrorCode NCHelperMPAS::create_gather_set_vertices(EntityHandle gather_set, Enti
std::vector<double*> arrays;
// Don't need to specify allocation number here, because we know enough vertices were created before
ErrorCode rval = _readNC->readMeshIface->get_node_coords(3, nVertices, 0, gather_set_start_vertex, arrays); \
- CHK_ERR1(rval, "Failed to create vertices");
+ CHK_ERR1(rval, "Failed to create gather set vertices");
// Add vertices to the gather set
Range gather_set_verts_range(gather_set_start_vertex, gather_set_start_vertex + nVertices - 1);
@@ -1559,7 +1553,7 @@ ErrorCode NCHelperMPAS::create_gather_set_edges(EntityHandle gather_set, EntityH
EntityHandle* conn_arr_gather_set_edges = NULL;
// Don't need to specify allocation number here, because we know enough edges were created before
ErrorCode rval = _readNC->readMeshIface->get_element_connect(nEdges, 2, MBEDGE, 0, start_edge, conn_arr_gather_set_edges); \
- CHK_ERR1(rval, "Failed to create edges");
+ CHK_ERR1(rval, "Failed to create gather set edges");
// Add edges to the gather set
Range gather_set_edges_range(start_edge, start_edge + nEdges - 1);
@@ -1675,7 +1669,7 @@ ErrorCode NCHelperMPAS::create_gather_set_cells(EntityHandle gather_set, EntityH
EntityHandle start_element;
ErrorCode rval = _readNC->readMeshIface->get_element_connect(num_group_cells, num_edges_per_cell, MBPOLYGON, 0, start_element,
conn_arr_gather_set_cells_with_n_edges[num_edges_per_cell], num_group_cells); \
- CHK_ERR1(rval, "Failed to create cells");
+ CHK_ERR1(rval, "Failed to create gather set cells");
// Add cells to the gather set
Range gather_set_cells_range(start_element, start_element + num_group_cells - 1);
diff --git a/src/io/ReadNC.cpp b/src/io/ReadNC.cpp
index 53b4dd7..fba9bce 100644
--- a/src/io/ReadNC.cpp
+++ b/src/io/ReadNC.cpp
@@ -132,9 +132,7 @@ ErrorCode ReadNC::load_file(const char* file_name, const EntityHandle* file_set,
}
if (!dim_var_names.empty()) {
- rval = myHelper->read_variables(dim_var_names, tstep_nums);
- if (MB_FAILURE == rval)
- return rval;
+ rval = myHelper->read_variables(dim_var_names, tstep_nums);CHK_ERR(rval);
}
}
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