Skip to content

Commit

Permalink
NEM_SLICE: convert x.data() to Data(x)
Browse files Browse the repository at this point in the history
  • Loading branch information
gsjaardema committed Feb 16, 2024
1 parent 390ba11 commit ae9b6f0
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 103 deletions.
33 changes: 17 additions & 16 deletions packages/seacas/applications/nem_slice/elb_elem.C
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright(C) 1999-2020, 2023 National Technology & Engineering Solutions
* Copyright(C) 1999-2020, 2023, 2024 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
Expand All @@ -9,9 +9,10 @@
#include "elb_elem.h"
#include "elb_err.h" // for error_report, Gen_Error
#include "elb_util.h" // for in_list
#include <cstddef> // for size_t
#include <cstdlib> // for exit
#include <cstring> // for strncasecmp
#include "vector_data.h"
#include <cstddef> // for size_t
#include <cstdlib> // for exit
#include <cstring> // for strncasecmp
#include <fmt/ostream.h>
#include <vector> // for vector

Expand Down Expand Up @@ -1439,10 +1440,10 @@ int get_side_id_hex_tet(const E_Type etype, /* The element type */
case TET8:
case TET14:
case TET15: {
auto il1 = in_list(1, lcnt, loc_node_ids.data()) >= 0;
auto il2 = in_list(2, lcnt, loc_node_ids.data()) >= 0;
auto il3 = in_list(3, lcnt, loc_node_ids.data()) >= 0;
auto il4 = in_list(4, lcnt, loc_node_ids.data()) >= 0;
auto il1 = in_list(1, lcnt, Data(loc_node_ids)) >= 0;
auto il2 = in_list(2, lcnt, Data(loc_node_ids)) >= 0;
auto il3 = in_list(3, lcnt, Data(loc_node_ids)) >= 0;
auto il4 = in_list(4, lcnt, Data(loc_node_ids)) >= 0;

if (il1 && il2 && il4) {
return 1;
Expand All @@ -1465,14 +1466,14 @@ int get_side_id_hex_tet(const E_Type etype, /* The element type */
case HEX16:
case HEX20:
case HEX27: {
auto il1 = in_list(1, lcnt, loc_node_ids.data()) >= 0 ? 1 : 0;
auto il2 = in_list(2, lcnt, loc_node_ids.data()) >= 0 ? 1 : 0;
auto il3 = in_list(3, lcnt, loc_node_ids.data()) >= 0 ? 1 : 0;
auto il4 = in_list(4, lcnt, loc_node_ids.data()) >= 0 ? 1 : 0;
auto il5 = in_list(5, lcnt, loc_node_ids.data()) >= 0 ? 1 : 0;
auto il6 = in_list(6, lcnt, loc_node_ids.data()) >= 0 ? 1 : 0;
auto il7 = in_list(7, lcnt, loc_node_ids.data()) >= 0 ? 1 : 0;
auto il8 = in_list(8, lcnt, loc_node_ids.data()) >= 0 ? 1 : 0;
auto il1 = in_list(1, lcnt, Data(loc_node_ids)) >= 0 ? 1 : 0;
auto il2 = in_list(2, lcnt, Data(loc_node_ids)) >= 0 ? 1 : 0;
auto il3 = in_list(3, lcnt, Data(loc_node_ids)) >= 0 ? 1 : 0;
auto il4 = in_list(4, lcnt, Data(loc_node_ids)) >= 0 ? 1 : 0;
auto il5 = in_list(5, lcnt, Data(loc_node_ids)) >= 0 ? 1 : 0;
auto il6 = in_list(6, lcnt, Data(loc_node_ids)) >= 0 ? 1 : 0;
auto il7 = in_list(7, lcnt, Data(loc_node_ids)) >= 0 ? 1 : 0;
auto il8 = in_list(8, lcnt, Data(loc_node_ids)) >= 0 ? 1 : 0;

if (il1 + il2 + il5 + il6 > 2) {
return 1;
Expand Down
17 changes: 9 additions & 8 deletions packages/seacas/applications/nem_slice/elb_exo_util.C
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright(C) 1999-2023 National Technology & Engineering Solutions
* Copyright(C) 1999-2024 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
Expand All @@ -25,6 +25,7 @@
#include "elb_exo.h"
#include "elb_groups.h" // for parse_groups
#include "elb_util.h" // for in_list, roundfloat
#include "vector_data.h"

/*****************************************************************************/
/*****************************************************************************/
Expand Down Expand Up @@ -67,7 +68,7 @@ int read_exo_weights(Problem_Description *prob, Weight_Description *weight, INT
weight->ow.resize(weight->nvals);
/* Read in the nodal values */
if (ex_get_var(exoid, weight->exo_tindx, EX_NODAL, weight->exo_vindx, 1, weight->nvals,
values.data()) < 0) {
Data(values)) < 0) {
Gen_Error(0, "fatal: unable to read nodal values");
ex_close(exoid);
return 0;
Expand All @@ -87,7 +88,7 @@ int read_exo_weights(Problem_Description *prob, Weight_Description *weight, INT
std::vector<INT> eblk_ids(neblks);
std::vector<INT> eblk_ecnts(neblks);

if (ex_get_ids(exoid, EX_ELEM_BLOCK, eblk_ids.data()) < 0) {
if (ex_get_ids(exoid, EX_ELEM_BLOCK, Data(eblk_ids)) < 0) {
Gen_Error(0, "fatal: unable to get element block IDs");
ex_close(exoid);
return 0;
Expand Down Expand Up @@ -190,7 +191,7 @@ int read_mesh_params(const std::string &exo_file, Problem_Description *problem,
mesh->eb_npe.resize(mesh->num_el_blks);
mesh->eb_type.resize(mesh->num_el_blks);

if (ex_get_ids(exoid, EX_ELEM_BLOCK, mesh->eb_ids.data()) < 0) {
if (ex_get_ids(exoid, EX_ELEM_BLOCK, Data(mesh->eb_ids)) < 0) {
Gen_Error(0, "fatal: unable to get element block IDs");
ex_close(exoid);
return 0;
Expand Down Expand Up @@ -305,9 +306,9 @@ int read_mesh(const std::string &exo_file, Problem_Description *problem,

if (problem->read_coords == ELB_TRUE) {
switch (mesh->num_dims) {
case 3: zptr = mesh->coords.data() + 2 * (mesh->num_nodes); FALL_THROUGH;
case 2: yptr = mesh->coords.data() + (mesh->num_nodes); FALL_THROUGH;
case 1: xptr = mesh->coords.data();
case 3: zptr = Data(mesh->coords) + 2 * (mesh->num_nodes); FALL_THROUGH;
case 2: yptr = Data(mesh->coords) + (mesh->num_nodes); FALL_THROUGH;
case 1: xptr = Data(mesh->coords);
}

if (ex_get_coord(exoid, xptr, yptr, zptr) < 0) {
Expand All @@ -327,7 +328,7 @@ int read_mesh(const std::string &exo_file, Problem_Description *problem,
std::vector<INT> blk_connect(mesh->eb_cnts[cnt] * mesh->eb_npe[cnt]);

/* Get the connectivity for this element block */
if (ex_get_conn(exoid, EX_ELEM_BLOCK, mesh->eb_ids[cnt], blk_connect.data(), nullptr, nullptr) <
if (ex_get_conn(exoid, EX_ELEM_BLOCK, mesh->eb_ids[cnt], Data(blk_connect), nullptr, nullptr) <
0) {
Gen_Error(0, "fatal: failed to get element connectivity");
return 0;
Expand Down
14 changes: 6 additions & 8 deletions packages/seacas/applications/nem_slice/elb_graph.C
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ template int generate_graph(Problem_Description *problem, Mesh_Description<int64

template <typename INT>
int generate_graph(Problem_Description *problem, Mesh_Description<INT> *mesh,
Graph_Description<INT> *graph, Weight_Description *weight,
Sphere_Info *sphere)
Graph_Description<INT> *graph, Weight_Description *weight, Sphere_Info *sphere)
{
double time1 = get_time();
/* Find the elements surrounding a node */
Expand Down Expand Up @@ -180,8 +179,7 @@ namespace {
*****************************************************************************/
template <typename INT>
int find_adjacency(Problem_Description *problem, Mesh_Description<INT> *mesh,
Graph_Description<INT> *graph, Weight_Description *weight,
Sphere_Info *sphere)
Graph_Description<INT> *graph, Weight_Description *weight, Sphere_Info *sphere)
{
std::vector<INT> pt_list;
std::vector<INT> hold_elem;
Expand Down Expand Up @@ -396,9 +394,9 @@ namespace {
}

for (int ncnt = 0; ncnt < nnodes; ncnt++) {
nelem = find_inter(
hold_elem.data(), &graph->sur_elem[side_nodes[(ncnt + 1)]][0], nhold,
graph->sur_elem[side_nodes[(ncnt + 1)]].size(), pt_list.data());
nelem = find_inter(Data(hold_elem), &graph->sur_elem[side_nodes[(ncnt + 1)]][0],
nhold, graph->sur_elem[side_nodes[(ncnt + 1)]].size(),
Data(pt_list));

/* If less than 2 ( 0 or 1 ) elements only
touch nodes 0 and ncnt+1 then try next side node, i.e.,
Expand Down Expand Up @@ -433,7 +431,7 @@ namespace {
find_inter(&graph->sur_elem[side_nodes[inode]][0],
&graph->sur_elem[side_nodes[(ncnt + 2)]][0],
graph->sur_elem[side_nodes[inode]].size(),
graph->sur_elem[side_nodes[(ncnt + 2)]].size(), pt_list.data());
graph->sur_elem[side_nodes[(ncnt + 2)]].size(), Data(pt_list));

/*
* If there are multiple elements in the intersection, then
Expand Down
5 changes: 3 additions & 2 deletions packages/seacas/applications/nem_slice/elb_groups.C
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions
* Copyright(C) 1999-2021, 2023, 2024 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
Expand All @@ -16,6 +16,7 @@
#include "elb_err.h" // for Gen_Error
#include "elb_groups.h"
#include "elb_util.h"
#include "vector_data.h"
#include <cstdio> // for sscanf, nullptr
#include <cstdlib> // for free, malloc
#include <cstring> // for strchr, strlen
Expand Down Expand Up @@ -80,7 +81,7 @@ template <typename INT> int parse_groups(Mesh_Description<INT> *mesh, Problem_De
if (*id == '/') {
id++;
}
scandescriptor(id, mesh->eb_ids.data(), i, mesh->num_el_blks, prob);
scandescriptor(id, Data(mesh->eb_ids), i, mesh->num_el_blks, prob);
id = strchr(id, '/');
i++;
} while (id != nullptr);
Expand Down
23 changes: 12 additions & 11 deletions packages/seacas/applications/nem_slice/elb_inp.C
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright(C) 1999-2023 National Technology & Engineering Solutions
* Copyright(C) 1999-2024 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
Expand All @@ -19,6 +19,7 @@
#include "elb_inp.h"
#include "elb_util.h" // for strip_string, token_compare, etc
#include "fmt/ostream.h"
#include "vector_data.h"
#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || \
defined(__MINGW32__) || defined(_WIN64) || defined(__MINGW64__)
#include "XGetopt.h"
Expand Down Expand Up @@ -69,15 +70,15 @@ template int cmd_line_arg_parse(int argc, char *argv[], std::string &exoII_inp_f
Weight_Description *weight);

template <typename INT>
int cmd_line_arg_parse(int argc, char *argv[], /* Args as passed by main() */
std::string &exoII_inp_file, /* The input ExodusII file name */
std::string &ascii_inp_file, /* The ASCII input file name */
std::string &nemI_out_file, /* Output NemesisI file name */
Machine_Description *machine, /* Structure for machine description */
LB_Description<INT> *lb, /* Structure for load balance description */
Problem_Description *prob, /* Structure for various problem params */
Solver_Description *solver, /* Structure for eigen solver params */
Weight_Description *weight /* Structure for weighting graph */
int cmd_line_arg_parse(int argc, char *argv[], /* Args as passed by main() */
std::string &exoII_inp_file, /* The input ExodusII file name */
std::string &ascii_inp_file, /* The ASCII input file name */
std::string &nemI_out_file, /* Output NemesisI file name */
Machine_Description *machine, /* Structure for machine description */
LB_Description<INT> *lb, /* Structure for load balance description */
Problem_Description *prob, /* Structure for various problem params */
Solver_Description *solver, /* Structure for eigen solver params */
Weight_Description *weight /* Structure for weighting graph */
)
{
int opt_let;
Expand Down Expand Up @@ -1696,7 +1697,7 @@ int check_inp_specs(std::string &exoII_inp_file, std::string &nemI_out_file,
if ((weight->type & EL_BLK) && (weight->ow_read)) {
if (weight->elemblk.size() > 1) {
/* start by sorting the two arrays by the element block number */
sort2(weight->elemblk.size(), weight->elemblk.data(), weight->elemblk_wgt.data());
sort2(weight->elemblk.size(), Data(weight->elemblk), Data(weight->elemblk_wgt));

/* now loop through, and make sure that we don't have multiple values */
for (int cnt = 1; cnt < (int)weight->elemblk.size(); cnt++) {
Expand Down
55 changes: 28 additions & 27 deletions packages/seacas/applications/nem_slice/elb_loadbal.C
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright(C) 1999-2021, 2023 National Technology & Engineering Solutions
* Copyright(C) 1999-2021, 2023, 2024 National Technology & Engineering Solutions
* of Sandia, LLC (NTESS). Under the terms of Contract DE-NA0003525 with
* NTESS, the U.S. Government retains certain rights in this software.
*
Expand Down Expand Up @@ -32,6 +32,7 @@
#include "elb_loadbal.h"
#include "elb_util.h" // for find_inter, etc
#include "fix_column_partitions.h"
#include "vector_data.h"

#ifndef M_PI
#define M_PI 3.14159265358979323846264338327
Expand Down Expand Up @@ -208,19 +209,19 @@ int generate_loadbal(Machine_Description *machine, Problem_Description *problem,

switch (mesh->num_dims) {
case 3:
x_node_ptr = mesh->coords.data();
y_node_ptr = mesh->coords.data() + (mesh->num_nodes);
z_node_ptr = mesh->coords.data() + 2 * (mesh->num_nodes);
x_node_ptr = Data(mesh->coords);
y_node_ptr = Data(mesh->coords) + (mesh->num_nodes);
z_node_ptr = Data(mesh->coords) + 2 * (mesh->num_nodes);
break;

case 2:
x_node_ptr = mesh->coords.data();
y_node_ptr = mesh->coords.data() + (mesh->num_nodes);
x_node_ptr = Data(mesh->coords);
y_node_ptr = Data(mesh->coords) + (mesh->num_nodes);
z_node_ptr = (float *)calloc(mesh->num_nodes, sizeof(float));
break;

case 1:
x_node_ptr = mesh->coords.data();
x_node_ptr = Data(mesh->coords);
y_node_ptr = (float *)calloc(mesh->num_nodes, sizeof(float));
z_node_ptr = (float *)calloc(mesh->num_nodes, sizeof(float));
break;
Expand Down Expand Up @@ -277,9 +278,9 @@ int generate_loadbal(Machine_Description *machine, Problem_Description *problem,
} /* End "for (cnt=0; cnt < mesh->num_elem; cnt++)" */

/* and use different pointers for Chaco */
x_ptr = x_elem_ptr.data();
y_ptr = y_elem_ptr.data();
z_ptr = z_elem_ptr.data();
x_ptr = Data(x_elem_ptr);
y_ptr = Data(y_elem_ptr);
z_ptr = Data(z_elem_ptr);

} /* End "if (problem->num_vertices > 0)" */
} /* End "if ((problem->type == ELEMENTAL) &&
Expand Down Expand Up @@ -368,8 +369,8 @@ int generate_loadbal(Machine_Description *machine, Problem_Description *problem,
nprocg.resize(problem->num_groups);
nelemg.resize(problem->num_groups);

if (!get_group_info(machine, problem, mesh, graph, lb->vertex2proc, nprocg.data(),
nelemg.data(), &max_vtx, &max_adj)) {
if (!get_group_info(machine, problem, mesh, graph, lb->vertex2proc, Data(nprocg), Data(nelemg),
&max_vtx, &max_adj)) {
Gen_Error(0, "fatal: Error obtaining group information.");
goto cleanup;
}
Expand Down Expand Up @@ -408,8 +409,8 @@ int generate_loadbal(Machine_Description *machine, Problem_Description *problem,
exit(-1);
}
else {
flag = INTER_FACE(problem->num_vertices, (int *)graph->start.data(), (int *)graph->adj.data(),
weight->vertices.data(), weight->edges.data(), x_ptr, y_ptr, z_ptr,
flag = INTER_FACE(problem->num_vertices, (int *)Data(graph->start), (int *)Data(graph->adj),
Data(weight->vertices), Data(weight->edges), x_ptr, y_ptr, z_ptr,
const_cast<char *>(assignfile), (char *)nullptr, lb->vertex2proc, tmp_arch,
tmp_lev, dim, goal, glob_method, refine, solve->rqi_flag, solve->vmax,
lb->num_sects, solve->tolerance, seed);
Expand Down Expand Up @@ -1098,7 +1099,7 @@ namespace {
}

size_t components =
extract_connected_lists(nrow, columns.data(), rows.data(), list.data(), list_ptr);
extract_connected_lists(nrow, Data(columns), Data(rows), Data(list), list_ptr);

if (components) {
fmt::print("There are {} connected components.\n", components);
Expand Down Expand Up @@ -1192,7 +1193,7 @@ namespace {
}

int components =
extract_connected_lists(nrow, columns.data(), rows.data(), list.data(), list_ptr);
extract_connected_lists(nrow, Data(columns), Data(rows), Data(list), list_ptr);

if (components > 0) {
fmt::print("For Processor {} there are {} connected components.\n", pcnt, components);
Expand Down Expand Up @@ -1320,18 +1321,18 @@ namespace {
ss_to_node_list(etype2, mesh->connect[el2], (cnt + 1), side_nodes2);

int nhold2 =
find_inter(graph->sur_elem[side_nodes2[0]].data(),
graph->sur_elem[side_nodes2[1]].data(),
find_inter(Data(graph->sur_elem[side_nodes2[0]]),
Data(graph->sur_elem[side_nodes2[1]]),
graph->sur_elem[side_nodes2[0]].size(),
graph->sur_elem[side_nodes2[1]].size(), pt_list.data());
graph->sur_elem[side_nodes2[1]].size(), Data(pt_list));

for (int i = 0; i < nhold2; i++) {
hold_elem[i] = graph->sur_elem[side_nodes2[0]][pt_list[i]];
}

size_t nelem = find_inter(
hold_elem.data(), graph->sur_elem[side_nodes2[2]].data(), nhold2,
graph->sur_elem[side_nodes2[2]].size(), pt_list.data());
size_t nelem =
find_inter(Data(hold_elem), Data(graph->sur_elem[side_nodes2[2]]), nhold2,
graph->sur_elem[side_nodes2[2]].size(), Data(pt_list));

if (nelem >= 1) {
count++;
Expand Down Expand Up @@ -1593,8 +1594,8 @@ namespace {
for (int ncnt = 0; ncnt < nnodes; ncnt++) {
/* Find elements connected to both node '0' and node 'ncnt+1' */
nelem =
find_inter(hold_elem.data(), graph->sur_elem[side_nodes[(ncnt + 1)]].data(),
nhold, graph->sur_elem[side_nodes[(ncnt + 1)]].size(), pt_list.data());
find_inter(Data(hold_elem), Data(graph->sur_elem[side_nodes[(ncnt + 1)]]), nhold,
graph->sur_elem[side_nodes[(ncnt + 1)]].size(), Data(pt_list));

if (nelem < 2) {
break;
Expand Down Expand Up @@ -1656,10 +1657,10 @@ namespace {
size_t nhold = 0;
for (int ncnt = 0; ncnt < nnodes; ncnt++) {
/* Find elements connected to both node 'inode' and node 'node' */
nelem = find_inter(graph->sur_elem[side_nodes[inode]].data(),
graph->sur_elem[side_nodes[node]].data(),
nelem = find_inter(Data(graph->sur_elem[side_nodes[inode]]),
Data(graph->sur_elem[side_nodes[node]]),
graph->sur_elem[side_nodes[inode]].size(),
graph->sur_elem[side_nodes[node]].size(), pt_list.data());
graph->sur_elem[side_nodes[node]].size(), Data(pt_list));

if (nelem > 1) {
if (ncnt == 0) {
Expand Down
Loading

0 comments on commit ae9b6f0

Please sign in to comment.