Skip to content

Commit

Permalink
Update max_size to take no arguments and more renaming of Throw funct…
Browse files Browse the repository at this point in the history
…ion names.
  • Loading branch information
jrood-nrel committed Apr 12, 2024
1 parent cb1aac5 commit a7e8966
Show file tree
Hide file tree
Showing 44 changed files with 95 additions and 94 deletions.
4 changes: 2 additions & 2 deletions include/aero/actuator/ActuatorGenericSearchFunctor.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ struct GenericLoopOverCoarseSearchResults
const int numIp = meSCV->num_integration_points();

// just allocate for largest expected size (hex27)
ThrowAssert(numIp <= 216);
ThrowAssert(numNodes <= 27);
STK_ThrowAssert(numIp <= 216);
STK_ThrowAssert(numNodes <= 27);

double scvip[216];
double elemcoords[27 * 3];
Expand Down
2 changes: 1 addition & 1 deletion include/aero/actuator/ActuatorScalingFLLC.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ scale_lift_force(
case (ActuatorType::ActLineFASTNGP):
case (ActuatorType::ActDiskFASTNGP): {
#ifndef NALU_USES_OPENFAST
ThrowErrorMsg("Actuator methods require OpenFAST");
STK_ThrowErrorMsg("Actuator methods require OpenFAST");
#if !defined(KOKKOS_ENABLE_GPU)
break;
#endif
Expand Down
6 changes: 3 additions & 3 deletions include/aero/actuator/UtilitiesActuator.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ template <typename T>
inline void
reduce_view_on_host(T view)
{
ThrowAssert(view.size() > 0);
ThrowAssert(view.data());
STK_ThrowAssert(view.size() > 0);
STK_ThrowAssert(view.data());
MPI_Datatype mpi_type;
if (std::is_same<typename T::value_type, double>::value) {
mpi_type = MPI_DOUBLE;
Expand All @@ -99,7 +99,7 @@ reduce_view_on_host(T view)
} else if (std::is_same<typename T::value_type, uint64_t>::value) {
mpi_type = MPI_LONG;
} else {
ThrowErrorMsg("unsupported type to reduce view on host");
STK_ThrowErrorMsg("unsupported type to reduce view on host");
}

MPI_Allreduce(
Expand Down
14 changes: 7 additions & 7 deletions include/master_element/MasterElementFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ generic_grad_op(
CoordViewType::rank == 2, "Coordinate view assumed to be rank 2");
static_assert(OutputViewType::rank == 3, "Weight view assumed to be rank 3");

ThrowAssert(AlgTraits::nodesPerElement_ == referenceGradWeights.extent(1));
ThrowAssert(AlgTraits::nDim_ == referenceGradWeights.extent(2));
STK_ThrowAssert(AlgTraits::nodesPerElement_ == referenceGradWeights.extent(1));
STK_ThrowAssert(AlgTraits::nDim_ == referenceGradWeights.extent(2));
for (int i = 0; i < dim; ++i)
ThrowAssert(weights.extent(i) == referenceGradWeights.extent(i));
STK_ThrowAssert(weights.extent(i) == referenceGradWeights.extent(i));

for (unsigned ip = 0; ip < referenceGradWeights.extent(0); ++ip) {
NALU_ALIGNED ftype jact[dim][dim];
Expand All @@ -111,7 +111,7 @@ generic_grad_op(
NALU_ALIGNED ftype det = ftype(0.0);
for (int i = 0; i < dim; ++i)
det += jact[i][0] * adjJac[i][0];
ThrowAssertMsg(
STK_ThrowAssertMsg(
stk::simd::are_any(det > tiny_positive_value()),
"Problem with Jacobian determinant");

Expand Down Expand Up @@ -598,10 +598,10 @@ generic_determinant_3d(
static_assert(OutputViewType::rank == 1, "Weight view assumed to be 1D");
static_assert(AlgTraits::nDim_ == 3, "3D method");

ThrowAssert(AlgTraits::nodesPerElement_ == referenceGradWeights.extent(1));
ThrowAssert(AlgTraits::nDim_ == referenceGradWeights.extent(2));
STK_ThrowAssert(AlgTraits::nodesPerElement_ == referenceGradWeights.extent(1));
STK_ThrowAssert(AlgTraits::nDim_ == referenceGradWeights.extent(2));

ThrowAssert(detj.extent(0) == referenceGradWeights.extent(0));
STK_ThrowAssert(detj.extent(0) == referenceGradWeights.extent(0));

for (unsigned ip = 0; ip < referenceGradWeights.extent(0); ++ip) {
NALU_ALIGNED ftype jac[3][3] = {
Expand Down
8 changes: 4 additions & 4 deletions src/Realm.C
Original file line number Diff line number Diff line change
Expand Up @@ -3792,10 +3792,10 @@ Realm::check_job(bool get_node_count)
unsigned nfields = fields.size();
for (unsigned ifld = 0; ifld < nfields; ++ifld) {
stk::mesh::FieldBase* field = fields[ifld];
unsigned fszNode = field->max_size(stk::topology::NODE_RANK);
unsigned fszEdge = field->max_size(stk::topology::EDGE_RANK);
unsigned fszFace = field->max_size(stk::topology::FACE_RANK);
unsigned fszElem = field->max_size(stk::topology::ELEM_RANK);
unsigned fszNode = field->max_size();
unsigned fszEdge = field->max_size();
unsigned fszFace = field->max_size();
unsigned fszElem = field->max_size();

memoryEstimateFields += (nodeCount * fszNode + edgeCount * fszEdge +
faceCount * fszFace + elemCount * fszElem) *
Expand Down
4 changes: 2 additions & 2 deletions src/SideWriter.C
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ put_data_on_node_block(
const stk::mesh::FieldBase& field)
{
STK_ThrowRequire(field.type_is<T>());
const int max_size = field.max_size(stk::topology::NODE_RANK);
const int max_size = field.max_size();
std::vector<T> flat_array(ids.size() * max_size, 0);
for (decltype(ids.size()) k = 0; k < ids.size(); ++k) {
const auto node = bulk.get_entity(stk::topology::NODE_RANK, ids[k]);
Expand Down Expand Up @@ -313,7 +313,7 @@ SideWriter::add_fields(std::vector<const stk::mesh::FieldBase*> fields)
STK_ThrowRequireMsg(
field->type_is<double>(), "only double fields supported");
const size_t nb_size = block->get_property("entity_count").get_int();
switch (field->max_size(stk::topology::NODE_RANK)) {
switch (field->max_size()) {
case 1: {
Ioss::Field ioss_field(
field->name(), Ioss::Field::DOUBLE, "scalar", Ioss::Field::TRANSIENT,
Expand Down
2 changes: 1 addition & 1 deletion src/SolutionNormPostProcessing.C
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ SolutionNormPostProcessing::setup()

// find the size; is there a better wat to determine a field size on a given
// part?
const int dofSize = dofField->max_size(stk::topology::NODE_RANK);
const int dofSize = dofField->max_size();

// increment total dof component size
totalDofCompSize_ += dofSize;
Expand Down
16 changes: 9 additions & 7 deletions src/TpetraLinearSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,8 @@ sum_into_row(
}

if (offset < length) {
ThrowAssertMsg(std::isfinite(input_values[perm_index]), "Inf or NAN lhs");
STK_ThrowAssertMsg(
std::isfinite(input_values[perm_index]), "Inf or NAN lhs");
if (forceAtomic) {
Kokkos::atomic_add(&(row_view.value(offset)), input_values[perm_index]);
} else {
Expand Down Expand Up @@ -1431,7 +1432,7 @@ sum_into(
const LocalOrdinal cur_perm_index = sortPermutation[r];
const double* const cur_lhs = &lhs(cur_perm_index, 0);
const double cur_rhs = rhs[cur_perm_index];
// ThrowAssertMsg(std::isfinite(cur_rhs), "Inf or NAN rhs");
// STK_ThrowAssertMsg(std::isfinite(cur_rhs), "Inf or NAN rhs");

if (rowLid < maxOwnedRowId) {
sum_into_row(
Expand Down Expand Up @@ -1595,10 +1596,11 @@ TpetraLinearSystem::sumInto(
const SharedMemView<int*, DeviceShmem>& sortPermutation,
const char* /* trace_tag */)
{
ThrowAssertMsg(lhs.span_is_contiguous(), "LHS assumed contiguous");
ThrowAssertMsg(rhs.span_is_contiguous(), "RHS assumed contiguous");
ThrowAssertMsg(localIds.span_is_contiguous(), "localIds assumed contiguous");
ThrowAssertMsg(
STK_ThrowAssertMsg(lhs.span_is_contiguous(), "LHS assumed contiguous");
STK_ThrowAssertMsg(rhs.span_is_contiguous(), "RHS assumed contiguous");
STK_ThrowAssertMsg(
localIds.span_is_contiguous(), "localIds assumed contiguous");
STK_ThrowAssertMsg(
sortPermutation.span_is_contiguous(), "sortPermutation assumed contiguous");

sum_into(
Expand Down Expand Up @@ -1648,7 +1650,7 @@ TpetraLinearSystem::sumInto(
const LocalOrdinal cur_perm_index = sortPermutation_[r];
const double* const cur_lhs = &lhs[cur_perm_index * numRows];
const double cur_rhs = rhs[cur_perm_index];
ThrowAssertMsg(std::isfinite(cur_rhs), "Invalid rhs");
STK_ThrowAssertMsg(std::isfinite(cur_rhs), "Invalid rhs");

if (rowLid < maxOwnedRowId_) {
sum_into_row(
Expand Down
15 changes: 8 additions & 7 deletions src/TpetraSegregatedLinearSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,7 @@ segregated_sum_into_row(
}

if (offset < length) {
ThrowAssertMsg(
STK_ThrowAssertMsg(
std::isfinite(input_values[perm_index * numDof]), "Inf or NAN lhs");
if (forceAtomic) {
Kokkos::atomic_add(
Expand Down Expand Up @@ -1371,10 +1371,11 @@ TpetraSegregatedLinearSystem::sumInto(
const SharedMemView<int*, DeviceShmem>& sortPermutation,
const char* /* trace_tag */)
{
ThrowAssertMsg(lhs.span_is_contiguous(), "LHS assumed contiguous");
ThrowAssertMsg(rhs.span_is_contiguous(), "RHS assumed contiguous");
ThrowAssertMsg(localIds.span_is_contiguous(), "localIds assumed contiguous");
ThrowAssertMsg(
STK_ThrowAssertMsg(lhs.span_is_contiguous(), "LHS assumed contiguous");
STK_ThrowAssertMsg(rhs.span_is_contiguous(), "RHS assumed contiguous");
STK_ThrowAssertMsg(
localIds.span_is_contiguous(), "localIds assumed contiguous");
STK_ThrowAssertMsg(
sortPermutation.span_is_contiguous(), "sortPermutation assumed contiguous");

segregated_sum_into(
Expand Down Expand Up @@ -1422,7 +1423,7 @@ TpetraSegregatedLinearSystem::sumInto(

for (unsigned dofIdx = 0; dofIdx < numDof_; ++dofIdx) {
const double cur_rhs = rhs[cur_perm_index * numDof_ + dofIdx];
ThrowAssertMsg(std::isfinite(cur_rhs), "Invalid rhs");
STK_ThrowAssertMsg(std::isfinite(cur_rhs), "Invalid rhs");
getOwnedLocalRhs()(rowLid, dofIdx) += cur_rhs;
}
} else if (rowLid < maxSharedNotOwnedRowId_) {
Expand All @@ -1433,7 +1434,7 @@ TpetraSegregatedLinearSystem::sumInto(

for (unsigned dofIdx = 0; dofIdx < numDof_; ++dofIdx) {
const double cur_rhs = rhs[cur_perm_index * numDof_ + dofIdx];
ThrowAssertMsg(std::isfinite(cur_rhs), "Invalid rhs");
STK_ThrowAssertMsg(std::isfinite(cur_rhs), "Invalid rhs");
getSharedNotOwnedLocalRhs()(actualLocalId, dofIdx) += cur_rhs;
}
}
Expand Down
6 changes: 2 additions & 4 deletions src/TurbulenceAveragingPostProcessing.C
Original file line number Diff line number Diff line change
Expand Up @@ -522,8 +522,7 @@ TurbulenceAveragingPostProcessing::register_field_from_primitive(
primitiveName);

// extract size (would love to do this by part), however, not yet a use case
const unsigned fieldSizePrimitive =
primitiveField->max_size(stk::topology::NODE_RANK);
const unsigned fieldSizePrimitive = primitiveField->max_size();

// register the averaged field with this size; treat velocity as a special
// case to retain the vector aspect
Expand Down Expand Up @@ -564,8 +563,7 @@ TurbulenceAveragingPostProcessing::construct_pair(
metaData.get_field(stk::topology::NODE_RANK, averagedName);

// the size; guaranteed to be the same based on the field registration
const unsigned fieldSizeAveraged =
averagedField->max_size(stk::topology::NODE_RANK);
const unsigned fieldSizeAveraged = averagedField->max_size();
fieldSizeVec.push_back(fieldSizeAveraged);

// construct pairs
Expand Down
2 changes: 1 addition & 1 deletion src/aero/actuator/ActuatorBulkDiskFAST.C
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ActuatorBulkDiskFAST::ActuatorBulkDiskFAST(
"numSweptOffset", actMeta.numberOfActuators_, actMeta.maxNumPntsPerBlade_)
{

ThrowErrorIf(!actMeta.is_disk());
STK_ThrowErrorIf(!actMeta.is_disk());
compute_swept_point_count(actMeta);
resize_arrays(actMeta);
Kokkos::parallel_for(
Expand Down
6 changes: 3 additions & 3 deletions src/aero/actuator/ActuatorBulkFAST.C
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ActuatorBulkFAST::init_openfast(
const int remainder = actMeta.numberOfActuators_ % nProcs;
const int nOffset = intDivision * nProcs;

ThrowErrorMsgIf(
STK_ThrowErrorMsgIf(
remainder && intDivision,
"nalu-wind can't process more turbines than ranks.");

Expand Down Expand Up @@ -120,7 +120,7 @@ ActuatorBulkFAST::init_openfast(

for (int i = 0; i < nTurb; ++i) {
if (localTurbineId_ == openFast_.get_procNo(i)) {
ThrowErrorMsgIf(
STK_ThrowErrorMsgIf(
actMeta.nBlades_(i) != openFast_.get_numBlades(i),
"Mismatch in number of blades between OpenFAST and input deck."
" InputDeck: " +
Expand Down Expand Up @@ -216,7 +216,7 @@ ActuatorBulkFAST::init_epsilon(const ActuatorMetaFAST& actMeta)
}

for (int i = 0; i < 3; ++i) {
ThrowAssertMsg(
STK_ThrowAssertMsg(
epsilonLocal(i) > 0.0,
"Epsilon zero for point: " + std::to_string(np) + " index " +
std::to_string(i));
Expand Down
2 changes: 1 addition & 1 deletion src/aero/actuator/ActuatorFunctorsSimple.C
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ ActSimpleWriteToFile(

if (actBulk.localTurbineId_ == NaluEnv::self().parallel_rank()) {
std::ofstream outFile;
// ThrowErrorIf(NaluEnv::self().parallel_rank()!=0);
// STK_ThrowErrorIf(NaluEnv::self().parallel_rank()!=0);

outFile.open(filename, std::ios_base::app);
const int stop =
Expand Down
12 changes: 6 additions & 6 deletions src/aero/actuator/ActuatorModel.C
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ ActuatorModel::setup(double timeStep, stk::mesh::BulkData& stkBulk)
return;

// hack to surpress Wunused-parameter on non-openfast builds
ThrowErrorIf(timeStep <= 0.0);
STK_ThrowErrorIf(timeStep <= 0.0);

switch (actMeta_->actuatorType_) {
case (ActuatorType::ActLineFASTNGP): {
#ifndef NALU_USES_OPENFAST
ThrowErrorMsg("Actuator methods require OpenFAST");
STK_ThrowErrorMsg("Actuator methods require OpenFAST");
#if !defined(KOKKOS_ENABLE_GPU)
break;
#endif
Expand All @@ -94,7 +94,7 @@ ActuatorModel::setup(double timeStep, stk::mesh::BulkData& stkBulk)
}
case (ActuatorType::ActDiskFASTNGP): {
#ifndef NALU_USES_OPENFAST
ThrowErrorMsg("Actuator methods require OpenFAST");
STK_ThrowErrorMsg("Actuator methods require OpenFAST");
#if !defined(KOKKOS_ENABLE_GPU)
break;
#endif
Expand Down Expand Up @@ -122,7 +122,7 @@ ActuatorModel::setup(double timeStep, stk::mesh::BulkData& stkBulk)
break;
}
default: {
ThrowErrorMsg("Unsupported actuator type");
STK_ThrowErrorMsg("Unsupported actuator type");
}
}
}
Expand All @@ -140,7 +140,7 @@ ActuatorModel::init(stk::mesh::BulkData& stkBulk)
case (ActuatorType::ActLineFASTNGP):
case (ActuatorType::ActDiskFASTNGP): {
#ifndef NALU_USES_OPENFAST
ThrowErrorMsg("Actuator methods require OpenFAST");
STK_ThrowErrorMsg("Actuator methods require OpenFAST");
#if !defined(KOKKOS_ENABLE_GPU)
break;
#endif
Expand All @@ -154,7 +154,7 @@ ActuatorModel::init(stk::mesh::BulkData& stkBulk)
break;
}
default: {
ThrowErrorMsg("Unsupported actuator type");
STK_ThrowErrorMsg("Unsupported actuator type");
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/aero/actuator/ActuatorParsing.C
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ ActuatorMeta
actuator_parse(const YAML::Node& y_node)
{
const YAML::Node y_actuator = y_node["actuator"];
ThrowErrorMsgIf(
STK_ThrowErrorMsgIf(
!y_actuator, "actuator argument is "
"missing from yaml node passed to actuator_parse");
int nTurbines = 0;
Expand Down
6 changes: 3 additions & 3 deletions src/aero/actuator/ActuatorParsingFAST.C
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ readTurbineData(int iTurb, ActuatorMetaFAST& actMetaFAST, YAML::Node turbNode)
int* numBlades = &(actMetaFAST.nBlades_(iTurb));
*numBlades = 3;
get_if_present_no_default(turbNode, "num_blades", *numBlades);
ThrowErrorMsgIf(
STK_ThrowErrorMsgIf(
*numBlades != 3 && *numBlades != 2,
"ERROR::ActuatorParsingFAST::Currently only 2 and 3 bladed turbines are "
"supported.");
Expand All @@ -120,7 +120,7 @@ readTurbineData(int iTurb, ActuatorMetaFAST& actMetaFAST, YAML::Node turbNode)
turbNode, "num_swept_pts", actMetaFAST.nPointsSwept_(iTurb));
actMetaFAST.useUniformAziSampling_(iTurb) =
actMetaFAST.nPointsSwept_(iTurb) != 0;
ThrowErrorMsgIf(
STK_ThrowErrorMsgIf(
*numBlades != 3, "The ActuatorDisk model requires a base 3 bladed "
"turbine, but a 2 bladed turbine was supplied.");
}
Expand All @@ -142,7 +142,7 @@ actuator_FAST_parse(const YAML::Node& y_node, const ActuatorMeta& actMeta)
fi.nTurbinesGlob = actMetaFAST.numberOfActuators_;

const YAML::Node y_actuator = y_node["actuator"];
ThrowErrorMsgIf(
STK_ThrowErrorMsgIf(
!y_actuator, "actuator argument is "
"missing from yaml node passed to actuator_FAST_parse");
if (fi.nTurbinesGlob > 0) {
Expand Down
2 changes: 1 addition & 1 deletion src/aero/actuator/ActuatorParsingSimple.C
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ actuator_Simple_parse(const YAML::Node& y_node, const ActuatorMeta& actMeta)
<< "In actuator_Simple_parse() " << std::endl; // LCCOUT

const YAML::Node y_actuator = y_node["actuator"];
ThrowErrorMsgIf(
STK_ThrowErrorMsgIf(
!y_actuator, "actuator argument is "
"missing from yaml node passed to actuator_Simple_parse");

Expand Down
2 changes: 1 addition & 1 deletion src/aero/actuator/UtilitiesActuator.C
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ get_fast_point_index(
break;
}
default: {
ThrowErrorMsg("Invalid fast type");
STK_ThrowErrorMsg("Invalid fast type");
return -1;
break;
}
Expand Down
2 changes: 1 addition & 1 deletion src/aero/fsi/FSIturbine.C
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fsiTurbine::fsiTurbine(int iTurb, const YAML::Node& node)
// Displacement Ramping
// --------------------------------------------------------------------------
const YAML::Node defNode = node["deflection_ramping"];
ThrowErrorMsgIf(
STK_ThrowErrorMsgIf(
!defNode,
"defleciton_ramping inputs are required for FSI Turbines with blades");
DeflectionRampingParams& defParams = deflectionRampParams_;
Expand Down
Loading

0 comments on commit a7e8966

Please sign in to comment.