diff --git a/src/GridElements.cpp b/src/GridElements.cpp index 530d22b..abe4c7a 100644 --- a/src/GridElements.cpp +++ b/src/GridElements.cpp @@ -75,7 +75,9 @@ void Mesh::Clear() { /////////////////////////////////////////////////////////////////////////////// -void Mesh::ConstructEdgeMap(bool verbose) { +void Mesh::ConstructEdgeMap( + bool fVerbose +) { // Construct the edge map edgemap.clear(); @@ -99,7 +101,7 @@ void Mesh::ConstructEdgeMap(bool verbose) { } } - if (verbose) Announce("Mesh size: Edges [%i]", edgemap.size()); + if (fVerbose) Announce("Mesh size: Edges [%i]", edgemap.size()); } /////////////////////////////////////////////////////////////////////////////// @@ -258,7 +260,9 @@ void Mesh::ExchangeFirstAndSecondMesh() { /////////////////////////////////////////////////////////////////////////////// -void Mesh::RemoveCoincidentNodes() { +void Mesh::RemoveCoincidentNodes( + bool fVerbose +) { // Put nodes into a map, tagging uniques std::map mapNodes; @@ -285,7 +289,9 @@ void Mesh::RemoveCoincidentNodes() { return; } - Announce("%i duplicate nodes detected", nodes.size() - vecUniques.size()); + if(fVerbose) { + Announce("%i duplicate nodes detected", nodes.size() - vecUniques.size()); + } // Remove duplicates NodeVector nodesOld = nodes; @@ -1173,12 +1179,23 @@ void Mesh::Read(const std::string & strFile) { int nElementBlocks = dimElementBlocks->size(); // Total number of elements + int nTotalElementCount = 0; NcDim * dimElements = ncFile.get_dim("num_elem"); if (dimElements == NULL) { - _EXCEPTION1("Exodus Grid file \"%s\" is missing dimension " + for (unsigned ib = 1; ib <= nElementBlocks; ++ib) + { + std::string numelblk = std::string("num_el_in_blk"+std::to_string(ib)); + NcDim * dimElementBlockElems = ncFile.get_dim(numelblk.c_str()); + nTotalElementCount += (dimElementBlockElems != NULL ? dimElementBlockElems->size() : 0); + } + if (nTotalElementCount == 0) + _EXCEPTION1("Exodus Grid file \"%s\" is missing dimension " "\"num_elem\"", strFile.c_str()); } - int nTotalElementCount = dimElements->size(); + else + { + nTotalElementCount = dimElements->size(); + } // Output size Announce("Mesh size: Nodes [%i] Elements [%i]", diff --git a/src/GridElements.h b/src/GridElements.h index f6181e5..3c266ad 100644 --- a/src/GridElements.h +++ b/src/GridElements.h @@ -722,7 +722,9 @@ class Mesh { /// /// Construct the EdgeMap from the NodeVector and FaceVector. /// - void ConstructEdgeMap(bool verbose=true); + void ConstructEdgeMap( + bool fVerbose = true + ); /// /// Construct the ReverseNodeArray from the NodeVector and FaceVector. @@ -751,7 +753,9 @@ class Mesh { /// /// Remove coincident nodes from the Mesh and adjust indices in faces. /// - void RemoveCoincidentNodes(); + void RemoveCoincidentNodes( + bool fVerbose = true + ); /// /// Write the mesh to a NetCDF file in Exodus format. diff --git a/src/OfflineMap.cpp b/src/OfflineMap.cpp index e22724c..0ddaddd 100644 --- a/src/OfflineMap.cpp +++ b/src/OfflineMap.cpp @@ -337,23 +337,25 @@ void OfflineMap::InitializeCoordinatesFromMeshFV( DataArray1D & dCenterLat, DataArray2D & dVertexLon, DataArray2D & dVertexLat, - bool fLatLon + bool fLatLon, + int nNodesPerFace ) { - int nFaces = mesh.faces.size(); - - // Count maximum number of Nodes per Face - int nNodesPerFace = 0; - for (int i = 0; i < nFaces; i++) { - if (mesh.faces[i].edges.size() > nNodesPerFace) { - nNodesPerFace = mesh.faces[i].edges.size(); - } - } - // Check if already initialized if (dCenterLon.GetRows() != 0) { return; } + int nFaces = mesh.faces.size(); + + // Count maximum number of Nodes per Face + if (nNodesPerFace == 0) { + for (int i = 0; i < nFaces; i++) { + if (mesh.faces[i].edges.size() > nNodesPerFace) { + nNodesPerFace = mesh.faces[i].edges.size(); + } + } + } + dVertexLon.Allocate(nFaces, nNodesPerFace); dVertexLat.Allocate(nFaces, nNodesPerFace); diff --git a/src/OfflineMap.h b/src/OfflineMap.h index 364d47d..de12474 100644 --- a/src/OfflineMap.h +++ b/src/OfflineMap.h @@ -94,7 +94,7 @@ class OfflineMap { const std::vector& p_tgtDimSizes ); -private: +protected: /// /// Initialize the coordinate arrays for a finite-volume mesh. /// @@ -104,7 +104,8 @@ class OfflineMap { DataArray1D & dCenterLat, DataArray2D & dVertexLon, DataArray2D & dVertexLat, - bool fLatLon + bool fLatLon, + int nNodesPerFace = 0 ); ///