[MOAB-dev] commit/MOAB: iulian07: MPAS reader padding
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Fri Oct 25 22:54:53 CDT 2013
1 new commit in MOAB:
https://bitbucket.org/fathomteam/moab/commits/795d74feaeff/
Changeset: 795d74feaeff
Branch: master
User: iulian07
Date: 2013-10-26 05:48:59
Summary: MPAS reader padding
when reading padded polygons from file, correct the last edges and vertices
from local connectivity arrays. Otherwise the local mapping structures
(AKA localXGids) will contain non-existing vertices and edges, which cause
much grief later.
The bug showed up even when we were using padded option (NO_MIXED_ELEMENTS),
because the local vertices and edges were processed anyway
Affected #: 2 files
diff --git a/src/io/NCHelperMPAS.cpp b/src/io/NCHelperMPAS.cpp
index 207fb7d..8d94e3d 100644
--- a/src/io/NCHelperMPAS.cpp
+++ b/src/io/NCHelperMPAS.cpp
@@ -377,6 +377,18 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
ERRORS(success, "Failed on wait_all.");
#endif
+ // correct the connectivity array, replace the padded vertices with the last vertices in the
+ // corresponding elements; sometimes the padded vertices are 0, sometimes a big vertex id
+ // make sure they are consistent to our padded option
+ for (int i=0; i<nLocalCells; i++)
+ {
+ int nVertsInCell=num_edges_on_local_cells[i];
+ int indxInConn=i*maxEdgesPerCell;
+ for (int j=nVertsInCell; j<maxEdgesPerCell; j++)
+ {
+ vertices_on_local_cells[indxInConn+j]=vertices_on_local_cells[indxInConn+nVertsInCell-1];
+ }
+ }
// Create local vertices
EntityHandle start_vertex;
ErrorCode rval = create_local_vertices(vertices_on_local_cells, start_vertex);
@@ -384,7 +396,7 @@ ErrorCode NCHelperMPAS::create_mesh(Range& faces)
// Create local edges (unless NO_EDGES read option is set)
if (!noEdges) {
- rval = create_local_edges(start_vertex);
+ rval = create_local_edges(start_vertex, num_edges_on_local_cells);
ERRORR(rval, "Failed to create local edges for MPAS mesh.");
}
@@ -1170,7 +1182,8 @@ ErrorCode NCHelperMPAS::create_local_vertices(const std::vector<int>& vertices_o
return MB_SUCCESS;
}
-ErrorCode NCHelperMPAS::create_local_edges(EntityHandle start_vertex)
+ErrorCode NCHelperMPAS::create_local_edges(EntityHandle start_vertex,
+ const std::vector<int>& num_edges_on_local_cells)
{
Interface*& mbImpl = _readNC->mbImpl;
Tag& mGlobalIdTag = _readNC->mGlobalIdTag;
@@ -1219,6 +1232,16 @@ ErrorCode NCHelperMPAS::create_local_edges(EntityHandle start_vertex)
ERRORS(success, "Failed on wait_all.");
#endif
+ // correct local edges in the same way as padded polygons, pad list with last edges in connectivity
+ for (int i=0; i<nLocalCells; i++)
+ {
+ int nEdgesInCell=num_edges_on_local_cells[i];
+ int indxInConn=i*maxEdgesPerCell;
+ for (int j=nEdgesInCell; j<maxEdgesPerCell; j++)
+ {
+ edges_on_local_cells[indxInConn+j]=edges_on_local_cells[indxInConn+nEdgesInCell-1];
+ }
+ }
// Collect local edges
std::sort(edges_on_local_cells.begin(), edges_on_local_cells.end());
std::copy(edges_on_local_cells.rbegin(), edges_on_local_cells.rend(), range_inserter(localGidEdges));
diff --git a/src/io/NCHelperMPAS.hpp b/src/io/NCHelperMPAS.hpp
index 5c751a0..aa8e972 100644
--- a/src/io/NCHelperMPAS.hpp
+++ b/src/io/NCHelperMPAS.hpp
@@ -55,7 +55,7 @@ private:
ErrorCode create_local_vertices(const std::vector<int>& vertices_on_local_cells, EntityHandle& start_vertex);
//! Create local edges (optional)
- ErrorCode create_local_edges(EntityHandle start_vertex);
+ ErrorCode create_local_edges(EntityHandle start_vertex, const std::vector<int>& num_edges_on_local_cells);
//! Create local cells without padding (cells are divided into groups based on the number of edges)
ErrorCode create_local_cells(const std::vector<int>& vertices_on_local_cells,
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