Skip to content

Commit

Permalink
Merge pull request Exawind#1 from mbkuhn/newcases_whfork
Browse files Browse the repository at this point in the history
Sloshing Tank case
  • Loading branch information
wjhorne authored Aug 15, 2023
2 parents 01b2cfb + bc27cfb commit 4460694
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 2 deletions.
47 changes: 47 additions & 0 deletions include/user_functions/SloshingTankVOFAuxFunction.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// 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 SloshingTankVOFAuxFunction_h
#define SloshingTankVOFAuxFunction_h

#include <AuxFunction.h>

#include <vector>

namespace sierra {
namespace nalu {

class SloshingTankVOFAuxFunction : public AuxFunction
{
public:
SloshingTankVOFAuxFunction(const std::vector<double>& params);

virtual ~SloshingTankVOFAuxFunction() {}

using AuxFunction::do_evaluate;
virtual 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;

double water_level_;
double amplitude_;
double kappa_;
double interface_thickness_;
};

} // namespace nalu
} // namespace sierra

#endif
2 changes: 2 additions & 0 deletions src/LowMachEquationSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,8 @@
#include <user_functions/PerturbedShearLayerAuxFunctions.h>
#include <user_functions/GaussJetVelocityAuxFunction.h>

#include <user_functions/DropletVelocityAuxFunction.h>

// deprecated

// stk_util
Expand Down
10 changes: 9 additions & 1 deletion src/VolumeOfFluidEquationSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include "user_functions/ZalesakDiskVOFAuxFunction.h"
#include "user_functions/ZalesakSphereVOFAuxFunction.h"
#include "user_functions/DropletVOFAuxFunction.h"
#include "user_functions/SloshingTankVOFAuxFunction.h"
#include "ngp_utils/NgpFieldBLAS.h"
#include "ngp_utils/NgpLoopUtils.h"
#include "ngp_utils/NgpFieldUtils.h"
Expand Down Expand Up @@ -466,7 +467,7 @@ void
VolumeOfFluidEquationSystem::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 */)
const std::map<std::string, std::vector<double>>& theParams)
{
// iterate map and check for name
const std::string dofName = "volume_of_fluid";
Expand Down Expand Up @@ -520,6 +521,13 @@ VolumeOfFluidEquationSystem::register_initial_condition_fcn(
}
} else if (fcnName == "droplet") {
theAuxFunc = new DropletVOFAuxFunction();
} else if (fcnName == "sloshing_tank") {
std::map<std::string, std::vector<double>>::const_iterator iterParams =
theParams.find(dofName);
std::vector<double> fcnParams = (iterParams != theParams.end())
? (*iterParams).second
: std::vector<double>();
theAuxFunc = new SloshingTankVOFAuxFunction(fcnParams);
} else {
throw std::runtime_error("VolumeOfFluidEquationSystem::register_initial_"
"condition_fcn: limited functions supported");
Expand Down
1 change: 1 addition & 0 deletions src/user_functions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ target_sources(nalu PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/ZalesakSphereMassFlowRateKernel.C
${CMAKE_CURRENT_SOURCE_DIR}/DropletVOFAuxFunction.C
${CMAKE_CURRENT_SOURCE_DIR}/DropletVelocityAuxFunction.C
${CMAKE_CURRENT_SOURCE_DIR}/SloshingTankVOFAuxFunction.C
)
2 changes: 1 addition & 1 deletion src/user_functions/DropletVOFAuxFunction.C
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ DropletVOFAuxFunction::do_evaluate(
fieldPtr[0] = 0.0;
//fieldPtr[0] += -0.5 * (std::erf(y / interface_thickness) + 1.0) + 1.0;

auto radius = std::sqrt(x * x + (y) * (y) + z * z) - 0.075;
auto radius = std::sqrt(x * x + y * y + z * z) - 0.075;
fieldPtr[0] += -0.5 * (std::erf(radius / interface_thickness) + 1.0) + 1.0;

fieldPtr += fieldSize;
Expand Down
71 changes: 71 additions & 0 deletions src/user_functions/SloshingTankVOFAuxFunction.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// 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.
//

#include <user_functions/SloshingTankVOFAuxFunction.h>
#include <algorithm>

// basic c++
#include <cmath>
#include <vector>
#include <stdexcept>
#include <iostream>

namespace sierra {
namespace nalu {

SloshingTankVOFAuxFunction::SloshingTankVOFAuxFunction(
const std::vector<double>& params)
: AuxFunction(0, 1),
water_level_(0.),
amplitude_(0.1),
kappa_(0.25),
interface_thickness_(0.1)
{
// check size and populate
if (params.size() != 4 && !params.empty())
throw std::runtime_error("Realm::setup_initial_conditions: "
"sloshing_tank requires 4 params: water level, "
"amplitude, kappa, and interface thickness");
if (!params.empty()) {
water_level_ = params[0];
amplitude_ = params[1];
kappa_ = params[2];
interface_thickness_ = params[3];
}
}

void
SloshingTankVOFAuxFunction::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
{
for (unsigned p = 0; p < numPoints; ++p) {

const double x = coords[0];
const double y = coords[1];
const double z = coords[2];

const double z0 =
water_level_ + amplitude_ * std::exp(-kappa_ * (x * x + y * y));
fieldPtr[0] =
-0.5 * (std::erf((z - z0) / interface_thickness_) + 1.0) + 1.0;

fieldPtr += fieldSize;
coords += spatialDimension;
}
}

} // namespace nalu
} // namespace sierra

0 comments on commit 4460694

Please sign in to comment.