Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IOSS: Extend Text mesh for edgeset #445

Draft
wants to merge 61 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
f8c543e
IOSS: Extended TextMesh syntax to edgesets
tokusanya Mar 7, 2024
b6fb33c
IOSS: Partial conversion from vector.data() to Data(vector)
gsjaardema Feb 13, 2024
ad87b6c
IOSS: fix incorrect data macro uses
gsjaardema Feb 14, 2024
dfacd18
IOSS: More conversion .data() to Data(..); arrays valid now also
gsjaardema Feb 14, 2024
29e0945
IOSS: More conversion .data() to Data(..) -- cgns
gsjaardema Feb 14, 2024
13c26e1
IOSS: More conversion .data() to Data(..) -- exodus
gsjaardema Feb 14, 2024
d5ea99c
IOSS: More conversion .data() to Data(..)
gsjaardema Feb 14, 2024
50d59c5
IOSS: Fix a couple bad .data() to Data(..) conversions
gsjaardema Feb 14, 2024
bd1b310
IOSS: Fix bad data() -> Data(..) conversion
gsjaardema Feb 14, 2024
08a9a79
More conversion .data() to Data(..) -- applications
gsjaardema Feb 14, 2024
dcf366a
EXODIFF: Fix conversion to vector_data use...
gsjaardema Feb 14, 2024
fd036fc
SUPLIB: Add missing header
gsjaardema Feb 14, 2024
9f515ee
NEM_SLICE: Make function use vector; more Data conversion
gsjaardema Feb 14, 2024
e6c7156
EPU: More Data conversion
gsjaardema Feb 14, 2024
bd5247a
NEM_SLICE: Replace some functions with algorithms
gsjaardema Feb 14, 2024
96f78dc
More x.data() -> Data(x) conversions
gsjaardema Feb 14, 2024
99eacf5
NEM_SLICE: Use set_intersection algorithm
gsjaardema Feb 14, 2024
af7b8e2
NEM_SLICE: Clean up code style
gsjaardema Feb 14, 2024
09438f2
NEM_SLICE: Refactor to reduce Data use
gsjaardema Feb 15, 2024
12cd014
NEM_SLICE: Refactor to reduce Data use
gsjaardema Feb 15, 2024
db451bc
NEM_SLICE: Add missing header
gsjaardema Feb 15, 2024
79e72ad
NEM_SLICE: Better use of algorithm set_intersection
gdsjaar Feb 15, 2024
ab11e13
NEM_SLICE: Fix refactorings; add option to use variant of old method
gdsjaar Feb 16, 2024
cb9b93c
NEM_SLICE: Use old variant for now
gdsjaar Feb 16, 2024
38a8fa2
NEM_SLICE: Refactorings were slower; revert to original
gdsjaar Feb 16, 2024
85796e2
NEM_SLICE: convert x.data() to Data(x)
gsjaardema Feb 16, 2024
67eedc3
IOSS: Eliminte unused variable warning
gsjaardema Feb 19, 2024
330b743
IOSS: Eliminate duplicate non-overloaded function problem
gsjaardema Feb 19, 2024
aa10cf9
EXPLORE: Split iniseq into separate file; fixes strange oneapi behavior
gdsjaar Feb 20, 2024
d158a7c
IOSS: Fix sideset hang due to omitted element blocks
gdsjaar Feb 21, 2024
b4746dd
IOSS: Support block omissions
gdsjaar Feb 21, 2024
189f131
EJOIN: Better control over assemblies
gdsjaar Feb 21, 2024
f7ace20
IOSS: Only do some field comparisons if in io_shell compare mode
gdsjaar Feb 22, 2024
82de115
IOSS: Refactor flush logic
gdsjaar Feb 26, 2024
fd02517
IOSS: Output monotonically increasing time warning only on rank 0
gdsjaar Feb 22, 2024
720e90c
IOSS: Flush has no mpi calls for parallel build with rank==1 runs
gdsjaar Feb 28, 2024
d599de8
NEM_SPREAD: Fix problem with last refactor
gdsjaar Feb 28, 2024
d95fccf
IOSS: Fix field size in filed compare routine
gdsjaar Feb 28, 2024
142ac14
IOSS: Fix set default offset calculation in Ioss::Map
gdsjaar Feb 28, 2024
7cbe345
IOSS: Get parallel util before using it
gdsjaar Feb 28, 2024
49751bd
IOSS: Add capability to ignore entity maps on exodus input databases
gdsjaar Feb 28, 2024
5ad972b
clang-format
gsjaardema Feb 28, 2024
610ae7b
Spelling fixes [ci skip]
gsjaardema Feb 29, 2024
0348d68
Change from sierra [ci skip]
gdsjaar Feb 29, 2024
6670fac
IOSS: Fix parallel fpp qa output
gdsjaar Mar 1, 2024
8f9cfd9
IOSS: Fix questionable negation of size_t
gsjaardema Mar 2, 2024
2d8b83c
EXPLORE: More info on id map -- sequential or non-sequential
gsjaardema Mar 4, 2024
c42c52e
IOSS: Fix some minor issues
gdsjaar Mar 5, 2024
f925de6
IOSS: Fix handling of negative times with EXODUS_CALL_GET_ALL_TIMES p…
gdsjaar Mar 5, 2024
de43a1f
Address flang-new common block padding warnings
gdsjaar Mar 7, 2024
6f158f1
Support flang compiler
gdsjaar Mar 7, 2024
c81105b
Support shared exodus library on windows
gsjaardema Mar 6, 2024
4aecb87
Fix flake8 issue -- multiple spaces after operator
gsjaardema Mar 6, 2024
dceb46b
Minor style changes
gsjaardema Mar 6, 2024
04df5e1
IOSS: Add option to delete qa and/or info records from output
gsjaardema Mar 7, 2024
51385f6
EPU: Do not sort variable selection list -- messes up field suffix order
gdsjaar Mar 7, 2024
01d1590
IOSS: Change floor compare behavior
gsjaardema Mar 7, 2024
c052090
IOSS: Use c++-style cast
gsjaardema Mar 7, 2024
dec8743
EXODIFF: Fix so command_file parsing can handle arbitrarily long line
gsjaardema Mar 8, 2024
af7253e
EXODIFF: Fix so command_file parsing can handle arbitrarily long line
gsjaardema Mar 8, 2024
adca219
Merge remote-tracking branch 'upstream/master' into TextMeshEdgeset
tokusanya Mar 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion packages/seacas/libraries/ioss/src/main/shell_interface.C
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,19 @@ void IOShell::Interface::enroll_options()
options_.enroll("floor", Ioss::GetLongOption::MandatoryValue,
"Only compare values if `|a| > floor || |b| > floor`", nullptr);
options_.enroll("ignore_qa_info", Ioss::GetLongOption::NoValue,
"If comparing databases, do not compare the qa and info records.", nullptr,
"If comparing databases, do not compare the qa and info records.", nullptr, nullptr, true);

options_.enroll("ignore_node_map", Ioss::GetLongOption::NoValue,
"Do not read the global node id map (if any) from the input database.", nullptr,
nullptr);
options_.enroll("ignore_element_map", Ioss::GetLongOption::NoValue,
"Do not read the global element id map (if any) from the input database.",
nullptr, nullptr);
options_.enroll("ignore_edge_map", Ioss::GetLongOption::NoValue,
"Do not read the global edge id map (if any) from the input database.", nullptr,
nullptr);
options_.enroll("ignore_face_map", Ioss::GetLongOption::NoValue,
"Do not read the global face id map (if any) from the input database.", nullptr,
nullptr, true);

options_.enroll("ignore_node_map", Ioss::GetLongOption::NoValue,
Expand Down
205 changes: 205 additions & 0 deletions packages/seacas/libraries/ioss/src/text_mesh/Iotm_DatabaseIO.C
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
#include "Ioss_PropertyManager.h" // for PropertyManager
#include "Ioss_Region.h" // for Region
#include "Ioss_SideSet.h" // for SideSet
#include "Ioss_EdgeSet.h" // for EdgeSet
#include "Ioss_EdgeBlock.h" // for EdgeBlock
#include "Ioss_Utils.h"
#include "Ioss_VariableType.h" // for VariableType
#include "Iotm_TextMesh.h" // for TextMesh
Expand Down Expand Up @@ -175,6 +177,7 @@ namespace Iotm {
elementBlockCount = m_textMesh->block_count();
nodesetCount = m_textMesh->nodeset_count();
sidesetCount = m_textMesh->sideset_count();
edgesetCount = m_textMesh->edgeset_count();
assemblyCount = m_textMesh->assembly_count();

get_step_times_nl();
Expand All @@ -184,6 +187,7 @@ namespace Iotm {
get_elemblocks();
get_nodesets();
get_sidesets();
get_edgesets();
get_commsets();
get_assemblies();

Expand Down Expand Up @@ -598,6 +602,159 @@ namespace Iotm {
return num_to_get;
}

int64_t DatabaseIO::get_field_internal(const Ioss::EdgeSet *es, const Ioss::Field &field,
void *data, size_t data_size) const
{
size_t num_to_get = field.verify(data_size);
if (num_to_get > 0) {
int64_t id = es->get_property("id").get_int();
Ioss::Field::RoleType role = field.get_role();

if (role == Ioss::Field::MESH) {
if (field.get_name() == "ids" || field.get_name() == "ids_raw") {
// An edgeset has a list of elements and a corresponding local
// element edge (1-based) The edge id is: edge_id =
// 12*element_id + local_edge_number
std::vector<int64_t> elem_edge;
m_textMesh->edgeset_elem_edges(id, elem_edge);
if (field.is_type(Ioss::Field::INTEGER)) {
int *ids = static_cast<int *>(data);
for (size_t i = 0; i < num_to_get; i++) {
ids[i] = static_cast<int>(12 * elem_edge[2 * i + 0] + elem_edge[2 * i + 1]);
}
}
else {
auto *ids = static_cast<int64_t *>(data);
for (size_t i = 0; i < num_to_get; i++) {
ids[i] = 12 * elem_edge[2 * i + 0] + elem_edge[2 * i + 1];
}
}
}
else if (field.get_name() == "orientation") {
if (field.is_type(Ioss::Field::INTEGER)) {
int *orientation = static_cast<int *>(data);
for (size_t i = 0; i < num_to_get; i++) {
orientation[i] = 1;
}
}
else {
auto *orientation = static_cast<int64_t *>(data);
for (size_t i = 0; i < num_to_get; i++) {
orientation[i] = 1;
}
}
}
else if (field.get_name() == "distribution_factors") {
if (m_useVariableDf) {
const Ioss::Field &id_fld = es->get_fieldref("ids");
std::vector<char> ids(id_fld.get_size());
get_field_internal(es, id_fld, ids.data(), id_fld.get_size());
fill_transient_data(es, field, data, ids.data(), num_to_get);
}
else {
fill_constant_data(field, data, 1.0);
}
}
else {
num_to_get = Ioss::Utils::field_warning(es, field, "input");
}
}
else if (role == Ioss::Field::TRANSIENT) {
const Ioss::Field &id_fld = es->get_fieldref("ids");
std::vector<char> ids(id_fld.get_size());
get_field_internal(es, id_fld, ids.data(), id_fld.get_size());
fill_transient_data(es, field, data, ids.data(), num_to_get, currentTime);
}
}
return num_to_get;
}

int64_t DatabaseIO::get_field_internal(const Ioss::EdgeBlock *eb, const Ioss::Field &field,
void *data, size_t data_size) const
{
size_t num_to_get = field.verify(data_size);
if (num_to_get > 0) {
int64_t id = eb->get_property("id").get_int();
int64_t my_edge_count = eb->entity_count();
Ioss::Field::RoleType role = field.get_role();

if (role == Ioss::Field::MESH) {
if (field.get_name() == "connectivity" || field.get_name() == "connectivity_raw") {
assert(field.get_component_count(Ioss::Field::InOut::INPUT) == eb->topology()->number_nodes());

if (field.is_type(Ioss::Field::INTEGER)) {
int *connect = static_cast<int *>(data);
m_textMesh->edge_connectivity(eb->name(), connect);

map_global_to_local(get_node_map(),
my_edge_count * field.raw_storage()->component_count(), 1, connect);
}
else {
auto *connect = static_cast<int64_t *>(data);
m_textMesh->edge_connectivity(eb->name(), connect);

map_global_to_local(get_node_map(),
my_edge_count * field.raw_storage()->component_count(), 1, connect);
}
}
else if (field.get_name() == "element_edge" || field.get_name() == "element_edge_raw") {
// Since we only have a single array, we need to allocate an extra
// array to store all of the data. Note also that the element_id
// is the global id but only the local id is stored so we need to
// map from local_to_global prior to generating the side id...

std::vector<int64_t> elem_edge;
m_textMesh->edgeblock_elem_edges(id, eb->name(), elem_edge);
if (field.get_name() == "element_edge_raw") {
map_global_to_local(get_element_map(), elem_edge.size(), 2, Data(elem_edge));
}

if (field.is_type(Ioss::Field::INTEGER)) {
int *element_edge = static_cast<int *>(data);
for (size_t i = 0; i < num_to_get; i++) {
element_edge[2 * i + 0] = static_cast<int>(elem_edge[2 * i + 0]);
element_edge[2 * i + 1] = static_cast<int>(elem_edge[2 * i + 1]);
}
}
else {
auto *element_edge = static_cast<int64_t *>(data);
for (size_t i = 0; i < num_to_get; i++) {
element_edge[2 * i + 0] = elem_edge[2 * i + 0];
element_edge[2 * i + 1] = elem_edge[2 * i + 1];
}
}
}
else if (field.get_name() == "ids") {
// Map the local ids in this edge block to global edge ids.
std::vector<int64_t> elem_edge;
m_textMesh->edgeblock_elem_edges(id, eb->name(), elem_edge);
if (field.is_type(Ioss::Field::INTEGER)) {
int *ids = static_cast<int *>(data);
for (size_t i = 0; i < num_to_get; i++) {
ids[i] = static_cast<int>(12 * elem_edge[2 * i + 0] + elem_edge[2 * i + 1]);
}
}
else {
auto *ids = static_cast<int64_t *>(data);
for (size_t i = 0; i < num_to_get; i++) {
ids[i] = 12 * elem_edge[2 * i + 0] + elem_edge[2 * i + 1];
}
}
}
else {
num_to_get = Ioss::Utils::field_warning(eb, field, "input");
}
}
else if (role == Ioss::Field::TRANSIENT) {
const Ioss::Field &id_fld = eb->get_fieldref("ids");
std::vector<char> ids(id_fld.get_size());
get_field_internal(eb, id_fld, ids.data(), id_fld.get_size());
fill_transient_data(eb, field, data, ids.data(), num_to_get, currentTime);
}
}
return num_to_get;
}

const Ioss::Map &DatabaseIO::get_node_map() const
{
// Allocate space for node number map and read it in...
Expand Down Expand Up @@ -789,6 +946,54 @@ namespace Iotm {
}
}

void DatabaseIO::get_edgesets()
{
std::vector<std::string> edgesetNames = m_textMesh->get_edgeset_names();
for (const std::string &name : edgesetNames) {
int64_t id = m_textMesh->get_edgeset_id(name);
size_t numEdges = m_textMesh->edgeset_edge_count_proc(id);
auto edgeset = new Ioss::EdgeSet(this, name, numEdges);
edgeset->property_add(Ioss::Property("id", id));
edgeset->property_add(Ioss::Property("guid", util().generate_guid(id)));
get_region()->add(edgeset);

get_region()->add_alias(name, Ioss::Utils::encode_entity_name("edgeset", id), Ioss::EDGESET);

std::vector<EdgeBlockInfo> infoVec = m_textMesh->get_edge_block_info_for_edgeset(name);

for (const EdgeBlockInfo &info : infoVec) {
size_t edgeCount = m_textMesh->get_local_edge_block_indices(name, info).size();
auto edgeblock = new Ioss::EdgeBlock(this, info.name, info.edgeTopology, edgeCount);
assert(edgeblock != nullptr);
get_region()->add(edgeblock);

edgeblock->field_add(
Ioss::Field("element_edge", edgeblock->field_int_type(), "pair", Ioss::Field::MESH, edgeCount));

// Same as element_edge except that the element id are the local
// element position (1-based) and not the global element id.
edgeblock->field_add(
Ioss::Field("element_edge_raw", edgeblock->field_int_type(), "pair", Ioss::Field::MESH, edgeCount));

// Note that all edgeblocks within a specific
// edgeset might have the same id.
edgeblock->property_add(Ioss::Property("id", id));
edgeblock->property_add(Ioss::Property("guid", util().generate_guid(id)));

auto split_type = m_textMesh->get_edgeset_split_type(name);
if (split_type != text_mesh::SplitType::NO_SPLIT) {
std::string storage = "Real[";
storage += std::to_string(info.numNodesPerEdge);
storage += "]";
edgeblock->field_add(
Ioss::Field("distribution_factors", Ioss::Field::REAL, storage, Ioss::Field::MESH));
}

add_transient_fields(edgeblock);
}
}
}

void DatabaseIO::get_commsets()
{
if (util().parallel_size() > 1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ namespace Iotm {
void get_elemblocks();
void get_nodesets();
void get_sidesets();
void get_edgesets();
void get_commsets();
void get_assemblies();

Expand All @@ -117,17 +118,19 @@ namespace Iotm {
size_t data_size) const override;
int64_t get_field_internal(const Ioss::SideBlock *ef_blk, const Ioss::Field &field, void *data,
size_t data_size) const override;
int64_t get_field_internal(const Ioss::EdgeSet *ns, const Ioss::Field &field, void *data,
size_t data_size) const override;
int64_t get_field_internal(const Ioss::EdgeBlock *eb, const Ioss::Field &field, void *data,
size_t data_size) const override;
int64_t get_field_internal(const Ioss::NodeSet *ns, const Ioss::Field &field, void *data,
size_t data_size) const override;
int64_t get_field_internal(const Ioss::CommSet *cs, const Ioss::Field &field, void *data,
size_t data_size) const override;
int64_t get_field_internal(const Ioss::Assembly *assem, const Ioss::Field &field, void *data,
size_t data_size) const override;

IOSS_NOOP_GFI(Ioss::EdgeBlock)
IOSS_NOOP_GFI(Ioss::FaceBlock)
IOSS_NOOP_GFI(Ioss::StructuredBlock)
IOSS_NOOP_GFI(Ioss::EdgeSet)
IOSS_NOOP_GFI(Ioss::FaceSet)
IOSS_NOOP_GFI(Ioss::ElementSet)
IOSS_NOOP_GFI(Ioss::SideSet)
Expand Down Expand Up @@ -160,6 +163,7 @@ namespace Iotm {
int elementBlockCount{0};
int nodesetCount{0};
int sidesetCount{0};
int edgesetCount{0};
int assemblyCount{0};

bool m_useVariableDf{true};
Expand Down
Loading
Loading