Skip to content

Commit d4769b6

Browse files
authored
Merge pull request #65 from ClimateGlobalChange/vijaysm/num_elem_missing
If num_elem attribute is missing, compute it
2 parents 471ca3e + cce73e4 commit d4769b6

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/GridElements.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,12 +1179,23 @@ void Mesh::Read(const std::string & strFile) {
11791179
int nElementBlocks = dimElementBlocks->size();
11801180

11811181
// Total number of elements
1182+
int nTotalElementCount = 0;
11821183
NcDim * dimElements = ncFile.get_dim("num_elem");
11831184
if (dimElements == NULL) {
1184-
_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 "
11851193
"\"num_elem\"", strFile.c_str());
11861194
}
1187-
int nTotalElementCount = dimElements->size();
1195+
else
1196+
{
1197+
nTotalElementCount = dimElements->size();
1198+
}
11881199

11891200
// Output size
11901201
Announce("Mesh size: Nodes [%i] Elements [%i]",

0 commit comments

Comments
 (0)