Skip to content

Commit

Permalink
Merge branch 'master' into ams
Browse files Browse the repository at this point in the history
  • Loading branch information
psakievich authored Dec 4, 2023
2 parents c4186b5 + a67ced4 commit 5e8f453
Show file tree
Hide file tree
Showing 34 changed files with 701 additions and 139 deletions.
10 changes: 7 additions & 3 deletions include/EnthalpyEquationSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,14 @@ class EnthalpyEquationSystem : public EquationSystem
void initialize();
void reinitialize_linear_system();

virtual void register_initial_condition_fcn(
void register_initial_condition_fcn(
stk::mesh::Part* /* part */,
const std::map<std::string, std::string>& /* theNames */,
const std::map<std::string, std::vector<double>>& /* theParams */) final;

void register_initial_condition_string_function(
stk::mesh::Part* part,
const std::map<std::string, std::string>& theNames,
const std::map<std::string, std::vector<double>>& theParams);
const std::map<std::string, std::string>& func) final;

void predict_state();

Expand Down
1 change: 1 addition & 0 deletions include/Enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ enum UserDataType {
CONSTANT_UD = 0,
FUNCTION_UD = 1,
USER_SUB_UD = 2,
STRING_FUNCTION_UD = 3,
UserDataType_END
};

Expand Down
6 changes: 6 additions & 0 deletions include/EquationSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,12 @@ class EquationSystem
{
}

virtual void register_initial_condition_string_function(
stk::mesh::Part* /*part*/,
const std::map<std::string, std::string>& /*func*/)
{
}

// rip through the propertyAlg_
virtual void evaluate_properties();

Expand Down
3 changes: 3 additions & 0 deletions include/EquationSystems.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ class EquationSystems
void register_initial_condition_fcn(
stk::mesh::Part* part, const UserFunctionInitialConditionData& fcnIC);

void register_initial_condition_string_function(
stk::mesh::Part* part, const std::map<std::string, std::string>& func);

void initialize();
void reinitialize_linear_system();
void populate_derived_quantities();
Expand Down
4 changes: 2 additions & 2 deletions include/FieldRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ class FieldRegistry
if (fieldDefIter == db->end()) {
std::string message = "Attempting to access an undefined field: '" +
name + "' with spatial dimension " +
to_string(numDim) + " and number of states " +
to_string(numStates);
std::to_string(numDim) + " and number of states " +
std::to_string(numStates);
throw std::runtime_error(message);
}
return fieldDefIter->second;
Expand Down
9 changes: 9 additions & 0 deletions include/NaluParsing.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ struct UserData
std::map<std::string, std::string> userFunctionMap_;
std::map<std::string, std::vector<double>> functionParams_;
std::map<std::string, std::vector<std::string>> functionStringParams_;
std::map<std::string, std::string> functions;

// FIXME: must elevate temperature due to the temperature_bc_setup method
Temperature temperature_;
Expand Down Expand Up @@ -112,6 +113,7 @@ struct InflowUserData : public UserData
bool mixFracSpec_;
bool massFractionSpec_;
bool gammaSpec_;

InflowUserData()
: UserData(),
uSpec_(false),
Expand Down Expand Up @@ -362,6 +364,11 @@ struct UserFunctionInitialConditionData : public InitialCondition
std::map<std::string, std::vector<double>> functionParams_;
};

struct StringFunctionInitialConditionData : public InitialCondition
{
std::map<std::string, std::string> functions_;
};

inline bool
string_represents_positive_integer(std::string v)
{
Expand Down Expand Up @@ -477,6 +484,8 @@ void operator>>(const YAML::Node& node, NonConformalBoundaryConditionData& rhs);
void operator>>(const YAML::Node& node, ConstantInitialConditionData& rhs);

void operator>>(const YAML::Node& node, UserFunctionInitialConditionData& rhs);
void
operator>>(const YAML::Node& node, StringFunctionInitialConditionData& rhs);

void operator>>(const YAML::Node& node, std::map<std::string, bool>& mapName);
void operator>>(const YAML::Node& node, std::map<std::string, double>& mapName);
Expand Down
4 changes: 3 additions & 1 deletion include/aero/AeroContainer.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ class AeroContainer
void register_nodal_fields(
stk::mesh::MetaData& meta, const stk::mesh::PartVector& part_vec);
void update_displacements(
const double currentTime, const bool updateCurCoords = true);
const double currentTime,
const bool updateCurCoords = true,
const bool predict = true);
void predict_model_time_step(const double /*currentTime*/);
void advance_model_time_step(const double /*currentTime*/);
void compute_div_mesh_velocity();
Expand Down
6 changes: 3 additions & 3 deletions include/aero/fsi/FSIturbine.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ struct DeflectionRampingParams
double thetaRampSpan_{10.0};
double startTimeTemporalRamp_{0.0};
double endTimeTemporalRamp_{0.0};
bool enableSpanRamping_{true};
bool enableThetaRamping_{true};
bool enableTemporalRamping_{true};
bool enableSpanRamping_{false};
bool enableThetaRamping_{false};
bool enableTemporalRamping_{false};
};

// TODO(psakiev) find a better place for this
Expand Down
30 changes: 15 additions & 15 deletions include/master_element/MasterElementFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ generic_grad_op(
static_assert(
std::is_same<ftype, typename OutputViewType::value_type>::value,
"Incompatiable value type for views");
static_assert(GradViewType::Rank == 3, "grad view assumed to be rank 3");
static_assert(GradViewType::rank == 3, "grad view assumed to be rank 3");
static_assert(
CoordViewType::Rank == 2, "Coordinate view assumed to be rank 2");
static_assert(OutputViewType::Rank == 3, "Weight view assumed to be rank 3");
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));
Expand Down Expand Up @@ -148,9 +148,9 @@ generic_gij_3d(
static_assert(
std::is_same<ftype, typename OutputViewType::value_type>::value,
"Incompatiable value type for views");
static_assert(GradViewType::Rank == 3, "grad view assumed to be 3D");
static_assert(CoordViewType::Rank == 2, "Coordinate view assumed to be 2D");
static_assert(OutputViewType::Rank == 3, "gij view assumed to be 3D");
static_assert(GradViewType::rank == 3, "grad view assumed to be 3D");
static_assert(CoordViewType::rank == 2, "Coordinate view assumed to be 2D");
static_assert(OutputViewType::rank == 3, "gij view assumed to be 3D");
static_assert(AlgTraits::nDim_ == 3, "3D method");

for (unsigned ip = 0; ip < referenceGradWeights.extent(0); ++ip) {
Expand Down Expand Up @@ -331,9 +331,9 @@ generic_Mij_2d(
static_assert(
std::is_same<ftype, typename OutputViewType::value_type>::value,
"Incompatiable value type for views");
static_assert(GradViewType::Rank == 3, "grad view assumed to be 3D");
static_assert(CoordViewType::Rank == 2, "Coordinate view assumed to be 2D");
static_assert(OutputViewType::Rank == 3, "Mij view assumed to be 3D");
static_assert(GradViewType::rank == 3, "grad view assumed to be 3D");
static_assert(CoordViewType::rank == 2, "Coordinate view assumed to be 2D");
static_assert(OutputViewType::rank == 3, "Mij view assumed to be 3D");
static_assert(AlgTraits::nDim_ == 2, "2D method");

const int npe = AlgTraits::nodesPerElement_;
Expand Down Expand Up @@ -514,9 +514,9 @@ generic_Mij_3d(
static_assert(
std::is_same<ftype, typename OutputViewType::value_type>::value,
"Incompatiable value type for views");
static_assert(GradViewType::Rank == 3, "grad view assumed to be 3D");
static_assert(CoordViewType::Rank == 2, "Coordinate view assumed to be 2D");
static_assert(OutputViewType::Rank == 3, "Mij view assumed to be 3D");
static_assert(GradViewType::rank == 3, "grad view assumed to be 3D");
static_assert(CoordViewType::rank == 2, "Coordinate view assumed to be 2D");
static_assert(OutputViewType::rank == 3, "Mij view assumed to be 3D");
static_assert(AlgTraits::nDim_ == 3, "3D method");

for (unsigned ip = 0; ip < referenceGradWeights.extent(0); ++ip) {
Expand Down Expand Up @@ -593,9 +593,9 @@ generic_determinant_3d(
static_assert(
std::is_same<ftype, typename OutputViewType::value_type>::value,
"Incompatiable value type for views");
static_assert(GradViewType::Rank == 3, "grad view assumed to be 3D");
static_assert(CoordViewType::Rank == 2, "Coordinate view assumed to be 2D");
static_assert(OutputViewType::Rank == 1, "Weight view assumed to be 1D");
static_assert(GradViewType::rank == 3, "grad view assumed to be 3D");
static_assert(CoordViewType::rank == 2, "Coordinate view assumed to be 2D");
static_assert(OutputViewType::rank == 1, "Weight view assumed to be 1D");
static_assert(AlgTraits::nDim_ == 3, "3D method");

ThrowAssert(AlgTraits::nodesPerElement_ == referenceGradWeights.extent(1));
Expand Down
61 changes: 61 additions & 0 deletions include/user_functions/StringTimeCoordFunction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
// Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC
// (NTESS), National Renewable Energy Laboratory, University of Texas Austin,
// Northwest Research Associates. Under the terms of Contract DE-NA0003525
// with NTESS, the U.S. Government retains certain rights in this software.
//
// This software is released under the BSD 3-clause license. See LICENSE file
// for more details.
//

#ifndef StringTimeCoordFunction_h
#define StringTimeCoordFunction_h

#include "stk_expreval/Evaluator.hpp"

#include "Kokkos_Core.hpp"

#include <string>

namespace sierra::nalu {

namespace fcn {
inline constexpr int UNMAPPED_INDEX = -1;
}

class StringTimeCoordFunction
{
public:
StringTimeCoordFunction(std::string fcn);
KOKKOS_FUNCTION double
operator()(double t, double x, double y, double z) const;
[[nodiscard]] KOKKOS_FUNCTION bool is_constant() const { return constant; }

KOKKOS_FUNCTION int spatial_dim() const
{
if (z_index != fcn::UNMAPPED_INDEX) {
return 3;
} else if (y_index != fcn::UNMAPPED_INDEX) {
return 2;
} else if (x_index != fcn::UNMAPPED_INDEX) {
return 1;
}
return 0;
}

[[nodiscard]] KOKKOS_FUNCTION bool is_spatial() const
{
return spatial_dim() != 0;
}

private:
stk::expreval::ParsedEval<> parsed_eval;
bool constant = false;
int t_index = fcn::UNMAPPED_INDEX;
int x_index = fcn::UNMAPPED_INDEX;
int y_index = fcn::UNMAPPED_INDEX;
int z_index = fcn::UNMAPPED_INDEX;
};

} // namespace sierra::nalu

#endif
41 changes: 41 additions & 0 deletions include/user_functions/StringTimeCoordTemperatureAuxFunction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright 2017 National Technology & Engineering Solutions of Sandia, LLC
// (NTESS), National Renewable Energy Laboratory, University of Texas Austin,
// Northwest Research Associates. Under the terms of Contract DE-NA0003525
// with NTESS, the U.S. Government retains certain rights in this software.
//
// This software is released under the BSD 3-clause license. See LICENSE file
// for more details.
//

#ifndef StringTimeCoordTemperatureAuxFunction_h
#define StringTimeCoordTemperatureAuxFunction_h

#include "AuxFunction.h"
#include "StringTimeCoordFunction.h"

#include <vector>

namespace sierra::nalu {

class StringTimeCoordTemperatureAuxFunction final : public AuxFunction
{
public:
StringTimeCoordTemperatureAuxFunction(std::string fcn);

void do_evaluate(
const double* coords,
const double time,
const unsigned spatialDimension,
const unsigned numPoints,
double* fieldPtr,
const unsigned fieldSize,
const unsigned beginPos,
const unsigned endPos) const final;

private:
const StringTimeCoordFunction f_;
};

} // namespace sierra::nalu

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -14,29 +14,29 @@

#include <vector>

namespace sierra {
namespace nalu {
namespace sierra::nalu {

class CappingInversionTemperatureAuxFunction : public AuxFunction
class TabulatedTemperatureAuxFunction final : public AuxFunction
{
public:
CappingInversionTemperatureAuxFunction();
TabulatedTemperatureAuxFunction(
std::vector<double> heights, std::vector<double> temperatures);

virtual ~CappingInversionTemperatureAuxFunction() {}

using AuxFunction::do_evaluate;
virtual void do_evaluate(
void do_evaluate(
const double* coords,
const double time,
const unsigned spatialDimension,
const unsigned numPoints,
double* fieldPtr,
const unsigned fieldSize,
const unsigned beginPos,
const unsigned endPos) const;
const unsigned endPos) const final;

private:
std::vector<double> heights_;
std::vector<double> temperatures_;
};

} // namespace nalu
} // namespace sierra
} // namespace sierra::nalu

#endif
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
1.994475350611083e-05 1 0.02
1.245775182965687e-05 2 0.04
4.162417946007383e-06 3 0.06
1.630724817616641e-07 4 0.08
1.300056783839082e-08 5 0.1
0.0001340341715347378 1 0.02
7.668636308766615e-05 2 0.04
3.862864631832822e-05 3 0.06
2.872666841740503e-05 4 0.08
2.453914784048959e-05 5 0.1
Loading

0 comments on commit 5e8f453

Please sign in to comment.