Skip to content

Commit

Permalink
Merge Pull Request #13547 from trilinos/Trilinos/stk-snapshot
Browse files Browse the repository at this point in the history
Automatically Merged using Trilinos Pull Request AutoTester
PR Title: b'STK: Snapshot 10-24-24 10:56 from Sierra 5.21.6-321-gf1c5a4d6'
PR Author: alanw0
  • Loading branch information
trilinos-autotester authored Oct 25, 2024
2 parents 1ff6055 + 46130d8 commit 6a7c62a
Show file tree
Hide file tree
Showing 117 changed files with 2,855 additions and 1,131 deletions.
6 changes: 6 additions & 0 deletions packages/stk/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
# CHANGELOG

5.21.6 (STK_VERSION 5210600) 10/25/2024
stk_search: fix build-error (instantiation error for morton_lbvh_search) for gcc 13.2
stk_util: added parallel/OutputStreams.hpp
- which includes the functions outputP0(), output(), output_flush(), set_outputP0(..), reset_default_output_streams().

5.21.5-2 (STK_VERSION 5210502) 10/07/2024
stk_search: Fixed HIP sort error.
stk_mesh: add multi-field NGP-FieldBLAS field_fill

5.21.5-1 (STK_VERSION 5210501) 9/27/2024
stk_mesh: deprecate BulkData::relation_exist

Expand Down
7 changes: 4 additions & 3 deletions packages/stk/stk_balance/stk_balance/balance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "stk_tools/transfer_utils/TransientFieldTransferById.hpp"
#include "stk_util/diag/StringUtil.hpp"
#include "stk_util/parallel/ParallelReduce.hpp"
#include "stk_util/parallel/OutputStreams.hpp"
#include "stk_util/util/ReportHandler.hpp" // for ThrowRequireMsg
#include <stk_balance/search_tolerance_algs/SecondShortestEdgeFaceSearchTolerance.hpp>
#include <stk_io/FillMesh.hpp>
Expand Down Expand Up @@ -252,7 +253,7 @@ bool balanceStkMesh(const BalanceSettings& balanceSettings, stk::mesh::BulkData&
const bool anyElementMovement = balancer.balance(mesh, selectors);

DiagnosticsPrinter diagPrinter(stkMeshBulkData.parallel(), stkMeshBulkData.parallel_size());
diagPrinter.print(sierra::Env::outputP0());
diagPrinter.print(stk::outputP0());

return anyElementMovement;
}
Expand All @@ -270,7 +271,7 @@ bool balanceStkMesh(const BalanceSettings& balanceSettings, stk::mesh::BulkData&
const bool anyElementMovement = balancer.balance(mesh);

DiagnosticsPrinter diagPrinter(stkMeshBulkData.parallel(), stkMeshBulkData.parallel_size());
diagPrinter.print(sierra::Env::outputP0());
diagPrinter.print(stk::outputP0());

return anyElementMovement;
}
Expand All @@ -290,7 +291,7 @@ bool balanceStkMeshNodes(const BalanceSettings& balanceSettings, stk::mesh::Bulk
balanceSettings.getNodeBalancerMaxIterations());

DiagnosticsPrinter diagPrinter(stkMeshBulkData.parallel(), stkMeshBulkData.parallel_size());
diagPrinter.print(sierra::Env::outputP0());
diagPrinter.print(stk::outputP0());

return anyChangedOwnership;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#include <stk_mesh/base/SkinMeshUtil.hpp>
#include <stk_util/environment/Env.hpp>
#include <stk_util/parallel/ParallelReduce.hpp>
#include <stk_util/parallel/OutputStreams.hpp>
#include <stk_util/util/SortAndUnique.hpp>
#include <algorithm>
#include <tuple>
Expand Down Expand Up @@ -792,7 +793,7 @@ void fill_output_subdomain_field(const stk::mesh::BulkData & bulk, const Balance

void logMessage(MPI_Comm communicator, const std::string &message)
{
stk::log_with_time_and_memory(communicator, message);
stk::log_with_time_and_memory(communicator, message, stk::outputP0());
}

void fill_zoltan2_graph(const BalanceSettings& balanceSettings,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
#include <stk_mesh/base/CreateFaces.hpp>
#include <stk_mesh/base/SkinMesh.hpp>
#include <stk_mesh/baseImpl/elementGraph/BulkDataIdMapper.hpp>
#include <stk_util/environment/Env.hpp>
#include <stk_util/parallel/OutputStreams.hpp>

#include <Teuchos_ParameterList.hpp>
#include <stk_balance/internal/StkMeshAdapterForZoltan2.hpp>
Expand Down Expand Up @@ -140,14 +140,11 @@ void print_zoltan_statistics(const ZoltanAdapter& stkMeshAdapter, Zoltan2::Evalu
double localsum = 0.;
for (size_t i = 0; i< stkMeshAdapter.getLocalNumIDs(); i++) localsum += kdd[i];

sierra::Env::outputP0() << parallel_rank
stk::outputP0() << parallel_rank
<< " PRINTING METRICS nObj " << stkMeshAdapter.getLocalNumIDs()
<< " nwgts " << stkMeshAdapter.getNumWeightsPerID()
<< " sumwgt " << localsum << std::endl;
zoltanEvaluateParition.printMetrics(sierra::Env::outputP0());
//sierra::Env::outputP0() << parallel_rank
// << " PRINTING GRAPH METRICS" << std::endl;
//zoltanEvaluateParition.printGraphMetrics(sierra::Env::outputP0());
zoltanEvaluateParition.printMetrics(stk::outputP0());
}

template <class ZoltanAdapter>
Expand Down
11 changes: 6 additions & 5 deletions packages/stk/stk_balance/stk_balance/m2n/m2nRebalance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <stk_mesh/base/MeshBuilder.hpp>
#include <stk_io/StkMeshIoBroker.hpp>
#include <stk_io/FillMesh.hpp>
#include "stk_util/parallel/OutputStreams.hpp"
#include "stk_util/environment/Env.hpp"
#include "stk_util/environment/EnvData.hpp"
#include "stk_util/environment/OutputLog.hpp"
Expand All @@ -52,18 +53,18 @@ void set_output_streams(MPI_Comm comm, const stk::balance::M2NBalanceSettings &
if (stk::parallel_machine_rank(comm) == 0) {
const std::string & logName = balanceSettings.get_log_filename();
if (logName == "cout" || logName == "cerr") {
stk::EnvData::instance().m_outputP0 = stk::get_log_ostream(logName);
stk::set_outputP0(stk::get_log_ostream(logName));
}
else {
stk::bind_output_streams("log=\"" + logName + "\"");
stk::EnvData::instance().m_outputP0 = stk::get_log_ostream("log");
stk::set_outputP0(stk::get_log_ostream("log"));
}
}
else {
stk::EnvData::instance().m_outputP0 = &stk::EnvData::instance().m_outputNull;
//stk::outputP0() is already a null output stream by default on other MPI ranks.
}

Ioss::Utils::set_output_stream(sierra::Env::outputP0());
Ioss::Utils::set_output_stream(stk::outputP0());
}

void print_running_message(const stk::balance::M2NBalanceSettings & balanceSettings, MPI_Comm comm)
Expand Down Expand Up @@ -120,7 +121,7 @@ void m2nRebalance(stk::io::StkMeshIoBroker& ioBroker, const stk::balance::M2NBal
void rebalance_m2n(stk::balance::M2NBalanceSettings &balanceSettings, MPI_Comm comm)
{
print_running_message(balanceSettings, comm);
print_banner(sierra::Env::outputP0());
print_banner(stk::outputP0());

std::shared_ptr<stk::mesh::BulkData> bulk = stk::mesh::MeshBuilder(comm).create();
stk::io::StkMeshIoBroker ioBroker;
Expand Down
14 changes: 9 additions & 5 deletions packages/stk/stk_balance/stk_balance/m2n_main/m2nMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,15 @@
#include <stk_balance/setup/M2NParser.hpp>
#include "stk_balance/internal/LogUtils.hpp"

#include <stk_util/environment/Env.hpp>
#include <stk_util/parallel/OutputStreams.hpp>
#include <stk_util/environment/memory_util.hpp>
#include <stk_util/util/human_bytes.hpp>

int main(int argc, const char**argv)
{
MPI_Init(&argc, const_cast<char***>(&argv));
Kokkos::initialize(argc, const_cast<char**>(argv));

MPI_Comm comm = MPI_COMM_WORLD;
stk::balance::initialize_environment(comm, argv);

Expand All @@ -58,10 +60,12 @@ int main(int argc, const char**argv)

size_t hwmMax = 0, hwmMin = 0, hwmAvg = 0;
stk::get_memory_high_water_mark_across_processors(comm, hwmMax, hwmMin, hwmAvg);
sierra::Env::outputP0() << "Memory HWM across procs, max/min/avg: "
<< stk::human_bytes(hwmMax) << " / "
<< stk::human_bytes(hwmMin) << " / "
<< stk::human_bytes(hwmAvg) << std::endl;
stk::outputP0() << "Memory HWM across procs, max/min/avg: "
<< stk::human_bytes(hwmMax) << " / "
<< stk::human_bytes(hwmMin) << " / "
<< stk::human_bytes(hwmAvg) << std::endl;

Kokkos::finalize();
MPI_Finalize();
return 0;
}
21 changes: 11 additions & 10 deletions packages/stk/stk_balance/stk_balance/setup/LifeCycle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@

#include "LifeCycle.hpp"

#include "stk_util/parallel/OutputStreams.hpp"
#include "stk_util/environment/Env.hpp"
#include "stk_util/environment/EnvData.hpp"
#include "stk_util/environment/OutputLog.hpp"
Expand Down Expand Up @@ -81,7 +82,7 @@ void LifeCycle::run()
}

print_running_message();
print_banner(sierra::Env::outputP0());
print_banner(stk::outputP0());

if (is_serial_no_op()) {
print_serial_no_op_message();
Expand Down Expand Up @@ -132,14 +133,14 @@ bool LifeCycle::rebalance_will_corrupt_data(const stk::io::StkMeshIoBroker & ioB
if (isRebalancing && sameInputAndOutputFile && sameInputAndOutputProcCount) {
if (hasTransientFieldData) {
willCorruptData = true;
sierra::Env::outputP0()
stk::outputP0()
<< "Aborting rebalance: Overwriting input files that contain transient fields will" << std::endl
<< "lead to data corruption. Please specify a different outputDirectory." << std::endl;
}

if (has64BitIds) {
willCorruptData = true;
sierra::Env::outputP0()
stk::outputP0()
<< "Aborting rebalance: Overwriting input files that contain 64-bit IDs will" << std::endl
<< "lead to data corruption. Please specify a different outputDirectory." << std::endl;
}
Expand All @@ -162,7 +163,7 @@ void LifeCycle::balance()
io.write(mesh);

DiagnosticsPrinter diagPrinter(m_comm, m_settings.get_num_output_processors());
diagPrinter.print(sierra::Env::outputP0());
diagPrinter.print(stk::outputP0());
}

void LifeCycle::rebalance()
Expand All @@ -187,26 +188,26 @@ void LifeCycle::rebalance()
stk::balance::rebalance(ioBroker, m_settings);

DiagnosticsPrinter diagPrinter(m_comm, m_settings.get_num_output_processors());
diagPrinter.print(sierra::Env::outputP0());
diagPrinter.print(stk::outputP0());
}

void LifeCycle::set_output_streams()
{
if (m_isProc0) {
const std::string & logName = m_settings.get_log_filename();
if (logName == "cout" || logName == "cerr") {
stk::EnvData::instance().m_outputP0 = stk::get_log_ostream(logName);
stk::set_outputP0(stk::get_log_ostream(logName));
}
else {
stk::bind_output_streams("log=\"" + logName + "\"");
stk::EnvData::instance().m_outputP0 = stk::get_log_ostream("log");
stk::set_outputP0(stk::get_log_ostream("log"));
}
}
else {
stk::EnvData::instance().m_outputP0 = &stk::EnvData::instance().m_outputNull;
//stk::outputP0() is already a null output stream by default on other MPI ranks.
}

Ioss::Utils::set_output_stream(sierra::Env::outputP0());
Ioss::Utils::set_output_stream(stk::outputP0());
}

void LifeCycle::print_parse_error(const char* what) const
Expand All @@ -225,7 +226,7 @@ void LifeCycle::print_balance_error(const char* what) const

void LifeCycle::print_serial_no_op_message() const
{
sierra::Env::outputP0()
stk::outputP0()
<< "Aborting balance: Rewriting the same input serial mesh file. Please specify" << std::endl
<< "a different outputDirectory if you wish to copy the input file to an output" << std::endl
<< "file of the same name." << std::endl;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ TEST(StkMeshIoBrokerHowTo, readInitialConditionNodalSubset)
stk::mesh::MetaData &meta_data = stkIo.meta_data();

// Declare the nodal "temperature" field. Exists on all nodes.
constexpr int numStates = 1;
stk::mesh::Field<double> &temperature =
stkIo.meta_data().declare_field<double>(stk::topology::NODE_RANK, appFieldName,1);
stkIo.meta_data().declare_field<double>(stk::topology::NODE_RANK, appFieldName,numStates);

// "NodeBlock_1" is the name of the node field on the input mesh.
stk::io::MeshField mf(temperature, dbFieldNameShell);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class CoincidentElems : public stk::unit_test_util::MeshFixture

TEST_F(CoincidentElems, balance_coincidentsNotSplit)
{
if (stk::parallel_machine_size(MPI_COMM_WORLD) != 2) { GTEST_SKIP(); }

setup_empty_mesh(stk::mesh::BulkData::NO_AUTO_AURA);
std::string meshDesc =
"0,1,HEX_8,1,2,3,4,5,6,7,8\n"
Expand Down
18 changes: 7 additions & 11 deletions packages/stk/stk_io/example/io_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
#include <stk_mesh/base/CreateFaces.hpp>
#include <stk_util/Version.hpp> // for versi...
#include <stk_util/command_line/CommandLineParserParallel.hpp> // for Comma...
#include <stk_util/environment/Env.hpp> // for outputP0
#include <stk_util/environment/EnvData.hpp> // for EnvData
#include <stk_util/parallel/OutputStreams.hpp>
#include <stk_util/environment/LogWithTimeAndMemory.hpp> // for log_w...
#include <stk_util/environment/memory_util.hpp> // for get_c...
#include <stk_util/parallel/Parallel.hpp> // for paral...
Expand Down Expand Up @@ -81,10 +80,7 @@

void set_output_streams(MPI_Comm comm)
{
if (stk::parallel_machine_rank(comm) != 0) {
stk::EnvData::instance().m_outputP0 = &stk::EnvData::instance().m_outputNull;
}
Ioss::Utils::set_output_stream(sierra::Env::outputP0());
Ioss::Utils::set_output_stream(stk::outputP0());
}

class IoMeshDriver
Expand Down Expand Up @@ -289,14 +285,14 @@ class IoMeshDriver
// For each global field name on the input database, determine the type of the field
// and define that same global field on the results, restart, history, and heartbeat outputs.
if (!global_fields.empty()) {
sierra::Env::outputP0() << "Adding " << global_fields.size() << " global fields:\n";
stk::outputP0() << "Adding " << global_fields.size() << " global fields:\n";
}

auto io_region = ioBroker.get_input_ioss_region();

for (size_t i=0; i < global_fields.size(); i++) {
const Ioss::Field &input_field = io_region->get_fieldref(global_fields[i]);
sierra::Env::outputP0() << "\t" << input_field.get_name() << " of type " << input_field.raw_storage()->name() << "\n";
stk::outputP0() << "\t" << input_field.get_name() << " of type " << input_field.raw_storage()->name() << "\n";

if (input_field.raw_storage()->component_count() == 1) {
double val = 0.0;
Expand Down Expand Up @@ -446,7 +442,7 @@ class IoMeshDriver
ioBroker.property_add(Ioss::Property("DECOMPOSITION_METHOD", decomp_method));
}
else {
sierra::Env::outputP0()<<"decomposition not specified, defaulting to file-per-processor mode for mesh-read."<<std::endl;
stk::outputP0()<<"decomposition not specified, defaulting to file-per-processor mode for mesh-read."<<std::endl;
}

if (compose_output) {
Expand Down Expand Up @@ -552,10 +548,10 @@ int main(int argc, const char** argv)
returnCode = 1;
break;
case stk::CommandLineParser::ParseHelpOnly:
sierra::Env::outputP0() << cmdLine.get_usage() << std::endl;
stk::outputP0() << cmdLine.get_usage() << std::endl;
break;
case stk::CommandLineParser::ParseVersionOnly:
sierra::Env::outputP0() << "STK Version: " << stk::version_string() << std::endl;
stk::outputP0() << "STK Version: " << stk::version_string() << std::endl;
break;
default: break;
}
Expand Down
8 changes: 3 additions & 5 deletions packages/stk/stk_io/stk_io/FillMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,9 @@ void fill_mesh_preexisting(stk::io::StkMeshIoBroker & stkIo,
stkIo.add_mesh_database(meshSpec, purpose);
stkIo.create_input_mesh();
stkIo.add_all_mesh_fields_as_input_fields();
stkIo.populate_bulk_data();

if(stkIo.check_integer_size_requirements() == 8) {
bulkData.set_large_ids_flag(true);
}
const bool delayFieldDataAllocation = true;
stkIo.populate_mesh(delayFieldDataAllocation);
stkIo.populate_field_data();
}

void fill_mesh_with_auto_decomp(const std::string &meshSpec, stk::mesh::BulkData &bulkData, stk::io::StkMeshIoBroker &stkIo)
Expand Down
18 changes: 13 additions & 5 deletions packages/stk/stk_io/stk_io/IOHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ void communicate_shared_side_entity_fields(const stk::mesh::BulkData& bulk,
}
}

stk::mesh::EntityRank get_side_rank(Ioss::Region* region, Ioss::SideBlock *block)
{
bool useShellAllFaceSides = region->property_exists("ENABLE_ALL_FACE_SIDES_SHELL");
int par_dimen = block->topology()->parametric_dimension();
stk::mesh::EntityRank side_rank = par_dimen == 1 ? stk::topology::EDGE_RANK : stk::topology::FACE_RANK;
return (block->parent_element_topology()->is_shell() && useShellAllFaceSides) ? stk::topology::FACE_RANK : side_rank;
}

template <typename INT>
void process_surface_entity_df(const Ioss::SideSet* sset, stk::mesh::BulkData & bulk)
{
Expand Down Expand Up @@ -215,7 +223,7 @@ void process_surface_entity_df(const Ioss::SideSet* sset, stk::mesh::BulkData &
// be the same and this could fail (a sideset of mixed edges and faces)
int par_dimen = block->topology()->parametric_dimension();

stk::mesh::EntityRank side_rank = par_dimen == 1 ? stk::topology::EDGE_RANK : stk::topology::FACE_RANK;
stk::mesh::EntityRank side_rank = get_side_rank(region, block);

// Would be nice to do:
// std::vector<stk::mesh::Entity> sides ;
Expand All @@ -242,15 +250,15 @@ void process_surface_entity_df(const Ioss::SideSet* sset, stk::mesh::BulkData &
stk::topology elemTopo = bulk.bucket(elem).topology();
if(par_dimen == 0)
{
stk::topology faceTopo = elemTopo.sub_topology(elemTopo.side_rank(), elemSide);
stk::topology sideTopo = elemTopo.sub_topology(elemTopo.side_rank(elemSide), elemSide);

Ioss::ElementTopology *ioss_topo = Ioss::ElementTopology::factory(faceTopo.name(), false);
Ioss::ElementTopology *ioss_topo = Ioss::ElementTopology::factory(sideTopo.name(), false);
par_dimen = ioss_topo->parametric_dimension();
side_rank = par_dimen == 1 ? stk::topology::EDGE_RANK : stk::topology::FACE_RANK;
side_rank = get_side_rank(region, block);
}
STKIORequire(par_dimen == 1 || par_dimen == 2);

if (par_dimen == 1) {
if (par_dimen == 1 && side_rank == stk::topology::EDGE_RANK) {
// conversion from face ordinal to edge ordinal for shells
if (elemTopo.is_shell()) {
elemSide -= elemTopo.num_faces();
Expand Down
Loading

0 comments on commit 6a7c62a

Please sign in to comment.