Skip to content

Commit b7d1e56

Browse files
committed
2 parents e450cad + de48603 commit b7d1e56

File tree

4 files changed

+45
-21
lines changed

4 files changed

+45
-21
lines changed

src/GridElements.cpp

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ void Mesh::Clear() {
7575

7676
///////////////////////////////////////////////////////////////////////////////
7777

78-
void Mesh::ConstructEdgeMap(bool verbose) {
78+
void Mesh::ConstructEdgeMap(
79+
bool fVerbose
80+
) {
7981

8082
// Construct the edge map
8183
edgemap.clear();
@@ -99,7 +101,7 @@ void Mesh::ConstructEdgeMap(bool verbose) {
99101
}
100102
}
101103

102-
if (verbose) Announce("Mesh size: Edges [%i]", edgemap.size());
104+
if (fVerbose) Announce("Mesh size: Edges [%i]", edgemap.size());
103105
}
104106

105107
///////////////////////////////////////////////////////////////////////////////
@@ -258,7 +260,9 @@ void Mesh::ExchangeFirstAndSecondMesh() {
258260

259261
///////////////////////////////////////////////////////////////////////////////
260262

261-
void Mesh::RemoveCoincidentNodes() {
263+
void Mesh::RemoveCoincidentNodes(
264+
bool fVerbose
265+
) {
262266

263267
// Put nodes into a map, tagging uniques
264268
std::map<Node, int> mapNodes;
@@ -285,7 +289,9 @@ void Mesh::RemoveCoincidentNodes() {
285289
return;
286290
}
287291

288-
Announce("%i duplicate nodes detected", nodes.size() - vecUniques.size());
292+
if(fVerbose) {
293+
Announce("%i duplicate nodes detected", nodes.size() - vecUniques.size());
294+
}
289295

290296
// Remove duplicates
291297
NodeVector nodesOld = nodes;
@@ -1173,12 +1179,23 @@ void Mesh::Read(const std::string & strFile) {
11731179
int nElementBlocks = dimElementBlocks->size();
11741180

11751181
// Total number of elements
1182+
int nTotalElementCount = 0;
11761183
NcDim * dimElements = ncFile.get_dim("num_elem");
11771184
if (dimElements == NULL) {
1178-
_EXCEPTION1("Exodus Grid file \"%s\" is missing dimension "
1185+
for (unsigned ib = 1; ib <= nElementBlocks; ++ib)
1186+
{
1187+
std::string numelblk = std::string("num_el_in_blk"+std::to_string(ib));
1188+
NcDim * dimElementBlockElems = ncFile.get_dim(numelblk.c_str());
1189+
nTotalElementCount += (dimElementBlockElems != NULL ? dimElementBlockElems->size() : 0);
1190+
}
1191+
if (nTotalElementCount == 0)
1192+
_EXCEPTION1("Exodus Grid file \"%s\" is missing dimension "
11791193
"\"num_elem\"", strFile.c_str());
11801194
}
1181-
int nTotalElementCount = dimElements->size();
1195+
else
1196+
{
1197+
nTotalElementCount = dimElements->size();
1198+
}
11821199

11831200
// Output size
11841201
Announce("Mesh size: Nodes [%i] Elements [%i]",

src/GridElements.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,9 @@ class Mesh {
722722
/// <summary>
723723
/// Construct the EdgeMap from the NodeVector and FaceVector.
724724
/// </summary>
725-
void ConstructEdgeMap(bool verbose=true);
725+
void ConstructEdgeMap(
726+
bool fVerbose = true
727+
);
726728

727729
/// <summary>
728730
/// Construct the ReverseNodeArray from the NodeVector and FaceVector.
@@ -751,7 +753,9 @@ class Mesh {
751753
/// <summary>
752754
/// Remove coincident nodes from the Mesh and adjust indices in faces.
753755
/// </summary>
754-
void RemoveCoincidentNodes();
756+
void RemoveCoincidentNodes(
757+
bool fVerbose = true
758+
);
755759

756760
/// <summary>
757761
/// Write the mesh to a NetCDF file in Exodus format.

src/OfflineMap.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -337,23 +337,25 @@ void OfflineMap::InitializeCoordinatesFromMeshFV(
337337
DataArray1D<double> & dCenterLat,
338338
DataArray2D<double> & dVertexLon,
339339
DataArray2D<double> & dVertexLat,
340-
bool fLatLon
340+
bool fLatLon,
341+
int nNodesPerFace
341342
) {
342-
int nFaces = mesh.faces.size();
343-
344-
// Count maximum number of Nodes per Face
345-
int nNodesPerFace = 0;
346-
for (int i = 0; i < nFaces; i++) {
347-
if (mesh.faces[i].edges.size() > nNodesPerFace) {
348-
nNodesPerFace = mesh.faces[i].edges.size();
349-
}
350-
}
351-
352343
// Check if already initialized
353344
if (dCenterLon.GetRows() != 0) {
354345
return;
355346
}
356347

348+
int nFaces = mesh.faces.size();
349+
350+
// Count maximum number of Nodes per Face
351+
if (nNodesPerFace == 0) {
352+
for (int i = 0; i < nFaces; i++) {
353+
if (mesh.faces[i].edges.size() > nNodesPerFace) {
354+
nNodesPerFace = mesh.faces[i].edges.size();
355+
}
356+
}
357+
}
358+
357359
dVertexLon.Allocate(nFaces, nNodesPerFace);
358360
dVertexLat.Allocate(nFaces, nNodesPerFace);
359361

src/OfflineMap.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ class OfflineMap {
9494
const std::vector<int>& p_tgtDimSizes
9595
);
9696

97-
private:
97+
protected:
9898
/// <summary>
9999
/// Initialize the coordinate arrays for a finite-volume mesh.
100100
/// </summary>
@@ -104,7 +104,8 @@ class OfflineMap {
104104
DataArray1D<double> & dCenterLat,
105105
DataArray2D<double> & dVertexLon,
106106
DataArray2D<double> & dVertexLat,
107-
bool fLatLon
107+
bool fLatLon,
108+
int nNodesPerFace = 0
108109
);
109110

110111
/// <summary>

0 commit comments

Comments
 (0)