Skip to content

Commit

Permalink
sloshing tank case, can change parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
mbkuhn committed Aug 15, 2023
1 parent 559d9c6 commit bc27cfb
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 19 deletions.
7 changes: 6 additions & 1 deletion include/user_functions/SloshingTankVOFAuxFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace nalu {
class SloshingTankVOFAuxFunction : public AuxFunction
{
public:
SloshingTankVOFAuxFunction();
SloshingTankVOFAuxFunction(const std::vector<double>& params);

virtual ~SloshingTankVOFAuxFunction() {}

Expand All @@ -34,6 +34,11 @@ class SloshingTankVOFAuxFunction : public AuxFunction
const unsigned fieldSize,
const unsigned beginPos,
const unsigned endPos) const;

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

} // namespace nalu
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
39 changes: 22 additions & 17 deletions src/user_functions/SloshingTankVOFAuxFunction.C
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,30 @@
#include <cmath>
#include <vector>
#include <stdexcept>
#include <iostream>

namespace sierra {
namespace nalu {

SloshingTankVOFAuxFunction::SloshingTankVOFAuxFunction() : AuxFunction(0, 1)
SloshingTankVOFAuxFunction::SloshingTankVOFAuxFunction(
const std::vector<double>& params)
: AuxFunction(0, 1),
water_level_(0.),
amplitude_(0.1),
kappa_(0.25),
interface_thickness_(0.1)
{
// does nothing
// 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
Expand All @@ -39,23 +56,11 @@ SloshingTankVOFAuxFunction::do_evaluate(
const double x = coords[0];
const double y = coords[1];
const double z = coords[2];
const double interface_thickness = 0.025;

const double water_level = 0.;
const double Amp = 0.1;
const double kappa = 0.25;
const double Lx = 20.;
const double Ly = 20.;

const double z0 =
water_level +
Amp * std::exp(
-kappa * (std::pow(x - 0.5 * Lx, 2) +
std::pow(y - 0.5 * Ly, 2)));
fieldPtr[0] = z0 - z;

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;
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;
Expand Down

0 comments on commit bc27cfb

Please sign in to comment.