Skip to content

Commit

Permalink
Merge branch 'master' into discontinuous-galerkin
Browse files Browse the repository at this point in the history
  • Loading branch information
gdsjaar committed May 21, 2024
2 parents 4775e7c + 4f7ce20 commit 954856b
Show file tree
Hide file tree
Showing 26 changed files with 865 additions and 134 deletions.
4 changes: 2 additions & 2 deletions packages/seacas/libraries/aprepro_lib/apr_aprepro.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
#endif

namespace {
const std::string version_short{"6.31"};
const std::string version_date{"(2024/05/13)"};
const std::string version_short{"6.32"};
const std::string version_date{"(2024/05/20)"};
const std::string version_string = version_short + " " + version_date;

void output_copyright();
Expand Down
10 changes: 1 addition & 9 deletions packages/seacas/libraries/aprepro_lib/apr_parser.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

// Skeleton implementation for Bison LALR(1) parsers in C++

// Copyright (C) 2002-2015, 2018-2021 Free Software Foundation, Inc.
// Copyright (C) 2002-2015, 2018-2021, 2024 Free Software Foundation, Inc.

// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -749,15 +749,11 @@ namespace SEAMS {
case 44: // bool: exp EQ sexp
{
(yylhs.value.val) = false;
yyerror(aprepro, "Comparison of arithmetic with string not defined");
yyerrok;
} break;

case 45: // bool: exp NE sexp
{
(yylhs.value.val) = true;
yyerror(aprepro, "Comparison of arithmetic with string not defined");
yyerrok;
} break;

case 46: // bool: sexp LT exp
Expand Down Expand Up @@ -791,15 +787,11 @@ namespace SEAMS {
case 50: // bool: sexp EQ exp
{
(yylhs.value.val) = false;
yyerror(aprepro, "Comparison of string with arithmetic not defined");
yyerrok;
} break;

case 51: // bool: sexp NE exp
{
(yylhs.value.val) = true;
yyerror(aprepro, "Comparison of string with arithmetic not defined");
yyerrok;
} break;

case 52: // bool: UNDVAR LT sexp
Expand Down
8 changes: 4 additions & 4 deletions packages/seacas/libraries/aprepro_lib/aprepro.yy
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ bool: sexp LT sexp { $$ = (strcmp($1,$3) < 0 ? 1 : 0); }
| exp GT sexp { $$ = false; yyerror(aprepro, "Comparison of arithmetic with string not defined"); yyerrok;}
| exp LE sexp { $$ = false; yyerror(aprepro, "Comparison of arithmetic with string not defined"); yyerrok;}
| exp GE sexp { $$ = false; yyerror(aprepro, "Comparison of arithmetic with string not defined"); yyerrok;}
| exp EQ sexp { $$ = false; yyerror(aprepro, "Comparison of arithmetic with string not defined"); yyerrok;}
| exp NE sexp { $$ = true; yyerror(aprepro, "Comparison of arithmetic with string not defined"); yyerrok;}
| exp EQ sexp { $$ = false; }
| exp NE sexp { $$ = true; }

| sexp LT exp { $$ = false; yyerror(aprepro, "Comparison of string with arithmetic not defined"); yyerrok;}
| sexp GT exp { $$ = false; yyerror(aprepro, "Comparison of string with arithmetic not defined"); yyerrok;}
| sexp LE exp { $$ = false; yyerror(aprepro, "Comparison of string with arithmetic not defined"); yyerrok;}
| sexp GE exp { $$ = false; yyerror(aprepro, "Comparison of string with arithmetic not defined"); yyerrok;}
| sexp EQ exp { $$ = false; yyerror(aprepro, "Comparison of string with arithmetic not defined"); yyerrok;}
| sexp NE exp { $$ = true; yyerror(aprepro, "Comparison of string with arithmetic not defined"); yyerrok;}
| sexp EQ exp { $$ = false; }
| sexp NE exp { $$ = true; }

| UNDVAR LT sexp { $$ = (strcmp("",$3) < 0 ? 1 : 0); undefined_error(aprepro, $1->name); }
| UNDVAR GT sexp { $$ = (strcmp("",$3) > 0 ? 1 : 0); undefined_error(aprepro, $1->name); }
Expand Down
13 changes: 13 additions & 0 deletions packages/seacas/libraries/ioss/src/Ioss_CopyDatabase.C
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,19 @@ namespace {
fmt::print(Ioss::DebugOut(), " Number of Nodes = {:14}\n",
fmt::group_digits(num_nodes));
}

if (options.omitted_blocks) {
size_t isize = inb->get_field("node_connectivity_status").get_size();
pool.data.resize(isize);
inb->get_field_data("node_connectivity_status", pool.data.data(), isize);

// Count number of "active" nodes
size_t active =
std::count_if(pool.data.begin(), pool.data.end(), [](auto &val) { return val >= 2; });
fmt::print(Ioss::DebugOut(), " Number of Active Nodes = {:14}\n",
fmt::group_digits(active));
}

auto *nb = new Ioss::NodeBlock(*inb);
output_region.add(nb);

Expand Down
1 change: 1 addition & 0 deletions packages/seacas/libraries/ioss/src/Ioss_MeshCopyOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace Ioss {
bool reverse{false}; // Used for testing CGNS
bool add_proc_id{false}; // CGNS: Add proc_id field.
bool boundary_sideset{false}; // Output a sideset of the boundary faces of the model
bool omitted_blocks{false};

// only used by Catalyst calls to `copy_database`; if false the
// copy process skips the defining of the mesh geometry and the
Expand Down
7 changes: 5 additions & 2 deletions packages/seacas/libraries/ioss/src/Ioss_StructuredBlock.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@
#include "Ioss_NodeBlock.h"
#include "Ioss_Property.h"
#include "Ioss_ZoneConnectivity.h"
#if !defined BUILT_IN_SIERRA
#include <fmt/ostream.h>
#endif
#include <array>
#include <cassert>
#include <fmt/core.h>
#include <fmt/ostream.h>
#include <iosfwd>
#include <stddef.h>
#include <stdint.h>
Expand Down Expand Up @@ -370,10 +371,12 @@ namespace Ioss {
};
} // namespace Ioss

#if !defined BUILT_IN_SIERRA
#if FMT_VERSION >= 90000
namespace fmt {
template <> struct formatter<Ioss::BoundaryCondition> : ostream_formatter
{
};
} // namespace fmt
#endif
#endif
4 changes: 4 additions & 0 deletions packages/seacas/libraries/ioss/src/Ioss_ZoneConnectivity.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
#include <array>
#include <cassert>
#include <cmath>
#if !defined BUILT_IN_SIERRA
#include <fmt/core.h>
#include <fmt/ostream.h>
#endif
#include <iosfwd>
#include <stdlib.h>
#include <string>
Expand Down Expand Up @@ -154,10 +156,12 @@ namespace Ioss {
IOSS_EXPORT std::ostream &operator<<(std::ostream &os, const ZoneConnectivity &zgc);
} // namespace Ioss

#if !defined BUILT_IN_SIERRA
#if FMT_VERSION >= 90000
namespace fmt {
template <> struct formatter<Ioss::ZoneConnectivity> : ostream_formatter
{
};
} // namespace fmt
#endif
#endif
116 changes: 100 additions & 16 deletions packages/seacas/libraries/ioss/src/catalyst/Iocatalyst_DatabaseIO.C
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#include <cstddef>
#include <tokenize.h>

#include "Ioss_CommSet.h" // for CommSet
#include "Ioss_DBUsage.h" // for DatabaseUsage, etc
#include "Ioss_DatabaseIO.h"
#include "Ioss_CommSet.h" // for CommSet
#include "Ioss_CodeTypes.h" // for IOSS_SCALAR()
#include "Ioss_DBUsage.h" // for DatabaseUsage, etc
#include "Ioss_DatabaseIO.h" // for DatabaseIO
#include "Ioss_EdgeBlock.h" // for EdgeBlock
#include "Ioss_EdgeSet.h" // for EdgeSet
#include "Ioss_ElementBlock.h" // for ElementBlock
Expand Down Expand Up @@ -141,6 +142,8 @@ namespace Iocatalyst {
inline static const std::string RANGEEND = "m_rangeEnd";
inline static const std::string FACE = "m_face";

inline static const std::string SURFACESPLITTYPE = "surface_split_type";

std::string getValuePath(const std::string &prop)
{
return detail::PROPERTIES + detail::FS + prop + detail::FS + detail::VALUE;
Expand Down Expand Up @@ -305,12 +308,17 @@ namespace Iocatalyst {

bool defineModel(Ioss::Region *region)
{
assert(region->model_defined());
if(!region->model_defined()) {
std::ostringstream errmsg;
errmsg << "Catalyst Write in defineModel(): model isn't defined in region"<<"\n";
IOSS_ERROR(errmsg);
}

auto &node = this->DBNode;
node = conduit_cpp::Node();

node[detail::getAPISizePath()].set_int8(region->get_database()->int_byte_size_api());
node[detail::SURFACESPLITTYPE].set_int8(region->get_database()->get_surface_split_type());
RegionContainer rc;
rc.push_back(region);
this->defineEntityGroup(node[detail::REGION], rc);
Expand Down Expand Up @@ -810,6 +818,24 @@ namespace Iocatalyst {
template <typename GroupingEntityT>
bool readFields(const conduit_cpp::Node &&parent, GroupingEntityT *block) const
{
//Assumption: count = entity_count (in block)
Ioss::DatabaseIO *dbase = block->get_database();
Ioss::EntityType b_t = block->type();
bool is_entity_block = false;
if(b_t == Ioss::EntityType::ELEMENTBLOCK ||
b_t == Ioss::EntityType::EDGEBLOCK ||
b_t == Ioss::EntityType::FACEBLOCK ||
b_t == Ioss::EntityType::NODEBLOCK ||
b_t == Ioss::EntityType::SIDEBLOCK ||
b_t == Ioss::EntityType::STRUCTUREDBLOCK) {
is_entity_block = true;
}
const int FNAME_MAX_LENGTH = 255;
size_t field_count = 0;
char **field_names =
Ioss::Utils::get_name_array(parent.number_of_children(), FNAME_MAX_LENGTH);
size_t entity_count = 0;

for (conduit_index_t idx = 0, max = parent.number_of_children(); idx < max; ++idx) {
auto &&child = parent[idx];
const auto name = child.name();
Expand All @@ -819,17 +845,43 @@ namespace Iocatalyst {
const auto index = child[detail::INDEX].as_int64();
const auto storage = child[detail::STORAGE].as_string();
if (!block->field_exists(name)) {
block->field_add(
if(storage == IOSS_SCALAR() && role==Ioss::Field::TRANSIENT && is_entity_block) {
//Add to get_fields() call
char field_name[FNAME_MAX_LENGTH + 1];
Ioss::Utils::copy_string(field_name, name, FNAME_MAX_LENGTH + 1);
Ioss::Utils::copy_string(field_names[field_count++], field_name, FNAME_MAX_LENGTH + 1);
if(entity_count == 0)
entity_count = count;
}
else {
block->field_add(
Ioss::Field(name, type, storage, role, count, index).set_zero_copy_enabled());
}
}
else {
// TODO verify field details.
auto field = block->get_fieldref(name);
if (!field.has_transform()) {
// Verify field details.
auto field_block = block->get_fieldref(name);
if (!field_block.has_transform()) {
block->get_fieldref(name).set_zero_copy_enabled();
}
assert(field.get_type() == type);
auto f = block->get_fieldref(name);
auto field_conduit = Ioss::Field(name, type, storage, role, count, index).set_zero_copy_enabled();
if(field_block != field_conduit) {
std::ostringstream errmsg;
errmsg << "Catalyst Read: Field '"<<name<<"' from conduit "<<
"already exists in block '"<<block->name().c_str()<<
"' of type '"<<block->type_string()<<"' and differs from it\n";
IOSS_ERROR(errmsg);
}
}
}

//Apply Exodus Properties to Scalar Fields in Entity Blocks
if(field_count > 0) {
std::vector<Ioss::Field> fields;
Ioss::Utils::get_fields(entity_count, field_names, field_count, Ioss::Field::TRANSIENT,
dbase, nullptr, fields);
for (const auto &field : fields) {
block->field_add(field.set_zero_copy_enabled());
}
}

Expand Down Expand Up @@ -1039,6 +1091,12 @@ namespace Iocatalyst {
auto &node = this->DBNode;
region->get_database()->set_int_byte_size_api(
static_cast<Ioss::DataSize>(node[detail::getAPISizePath()].as_int8()));
const auto write_split_type =
static_cast<Ioss::SurfaceSplitType>(node[detail::SURFACESPLITTYPE].as_int8());
if(write_split_type != region->get_database()->get_surface_split_type()) {
static_cast<DatabaseIO*>(region->get_database())->set_split_type_changed(true);
}

auto tpath = detail::REGION + detail::FS + detail::TIME;
if (node.has_path(tpath)) {
region->add_state(node[tpath].to_float64());
Expand All @@ -1048,8 +1106,14 @@ namespace Iocatalyst {
this->readEntityGroup<Ioss::ElementBlock>(node[detail::ELEMENTBLOCKS], region);
this->readEntityGroup<Ioss::EdgeBlock>(node[detail::EDGEBLOCKS], region);
this->readEntityGroup<Ioss::FaceBlock>(node[detail::FACEBLOCKS], region);
this->readEntityGroup<Ioss::SideBlock>(node[detail::SIDEBLOCKS], region);
this->readEntityGroup<Ioss::SideSet>(node[detail::SIDESETS], region);

bool surface_split_changed =
static_cast<DatabaseIO*>(region->get_database())->split_type_changed();
if(!surface_split_changed) {
this->readEntityGroup<Ioss::SideBlock>(node[detail::SIDEBLOCKS], region);
this->readEntityGroup<Ioss::SideSet>(node[detail::SIDESETS], region);
}

this->readEntityGroup<Ioss::NodeSet>(node[detail::NODESETS], region);
this->readEntityGroup<Ioss::EdgeSet>(node[detail::EDGESETS], region);
this->readEntityGroup<Ioss::FaceSet>(node[detail::FACESETS], region);
Expand Down Expand Up @@ -1116,11 +1180,19 @@ namespace Iocatalyst {

bool DatabaseIO::end_nl(Ioss::State state)
{
assert(this->dbState == state);
if(this->dbState != state) {
std::ostringstream errmsg;
errmsg << "Catalyst: dbState != state in end_nl"<<"\n";
IOSS_ERROR(errmsg);
}

if (!is_input()) {
auto region = this->get_region();
assert(region != nullptr);
if(region == nullptr) {
std::ostringstream errmsg;
errmsg << "Catalyst: region is nullptr in end_nl"<<"\n";
IOSS_ERROR(errmsg);
}

auto &impl = (*this->Impl.get());
switch (state) {
Expand Down Expand Up @@ -1180,7 +1252,11 @@ namespace Iocatalyst {
void DatabaseIO::read_meta_data_nl()
{
auto region = this->get_region();
assert(region != nullptr);
if(region == nullptr) {
std::ostringstream errmsg;
errmsg << "Catalyst: region is nullptr in read_meta_data_nl()"<<"\n";
IOSS_ERROR(errmsg);
}

auto &impl = (*this->Impl.get());
impl.readModel(region);
Expand All @@ -1189,7 +1265,11 @@ namespace Iocatalyst {
void DatabaseIO::get_step_times_nl()
{
auto region = this->get_region();
assert(region != nullptr);
if(region == nullptr) {
std::ostringstream errmsg;
errmsg << "Catalyst: region is nullptr in get_step_times_nl()"<<"\n";
IOSS_ERROR(errmsg);
}

auto &impl = (*this->Impl.get());
impl.readTime(region);
Expand Down Expand Up @@ -1420,6 +1500,7 @@ namespace Iocatalyst {
int64_t DatabaseIO::get_field_internal(const Ioss::SideBlock *sb, const Ioss::Field &field,
void *data, size_t data_size) const
{
if(split_type_changed()) { return -1; }
auto &impl = (*this->Impl.get());
return impl.getField(detail::SIDEBLOCKS, sb, field, data, data_size);
}
Expand Down Expand Up @@ -1450,6 +1531,7 @@ namespace Iocatalyst {
int64_t DatabaseIO::get_field_internal(const Ioss::SideSet *ss, const Ioss::Field &field,
void *data, size_t data_size) const
{
if(split_type_changed()) { return -1; }
auto &impl = (*this->Impl.get());
return impl.getField(detail::SIDESETS, ss, field, data, data_size);
}
Expand Down Expand Up @@ -1531,6 +1613,7 @@ namespace Iocatalyst {
int64_t DatabaseIO::get_zc_field_internal(const Ioss::SideBlock *sb, const Ioss::Field &field,
void **data, size_t *data_size) const
{
if(split_type_changed()) { return -1; }
auto &impl = (*this->Impl.get());
return impl.getFieldZeroCopy(detail::SIDEBLOCKS, sb, field, data, data_size);
}
Expand Down Expand Up @@ -1561,6 +1644,7 @@ namespace Iocatalyst {
int64_t DatabaseIO::get_zc_field_internal(const Ioss::SideSet *ss, const Ioss::Field &field,
void **data, size_t *data_size) const
{
if(split_type_changed()) { return -1; }
auto &impl = (*this->Impl.get());
return impl.getFieldZeroCopy(detail::SIDESETS, ss, field, data, data_size);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ namespace Iocatalyst {

std::string get_catalyst_dump_dir() const;

void set_split_type_changed(bool split_type_changed) { split_type_c = split_type_changed; }
IOSS_NODISCARD bool split_type_changed() const { return split_type_c; }

private:
bool open_group_nl(const std::string & /* group_name */) override { return false; }
bool create_subgroup_nl(const std::string & /* group_name */) override { return false; }
Expand Down Expand Up @@ -202,5 +205,6 @@ namespace Iocatalyst {
class ImplementationT;
std::unique_ptr<ImplementationT> Impl;
bool useDeepCopy;
bool split_type_c{false};
};
} // namespace Iocatalyst
Loading

0 comments on commit 954856b

Please sign in to comment.