Skip to content

Commit

Permalink
reintroduce flat surface to droplet vof user function, correct reg tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mbkuhn committed Jul 30, 2024
1 parent 2db405d commit 9eeaaae
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 22 deletions.
3 changes: 3 additions & 0 deletions include/user_functions/DropletVOFAuxFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,12 @@ class DropletVOFAuxFunction : public AuxFunction
const unsigned beginPos,
const unsigned endPos) const;

int surf_idx_;
double droppos_x_;
double droppos_y_;
double droppos_z_;
double surf_pos_;
double surf_idx_dbl_;
double radius_;
double interface_thickness_;
};
Expand Down
2 changes: 1 addition & 1 deletion reg_tests/test_files/VOFDroplet/VOFDroplet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ realms:
user_function_name:
volume_of_fluid: droplet
user_function_parameters:
volume_of_fluid: [0.0, 0.25, 0.0, 0.1, 0.0025]
volume_of_fluid: [0.0, 0.25, 0.0, 0.1, 0.0, 1, 0.0025]
- constant: ic_2
target_name: block_1
value:
Expand Down
14 changes: 7 additions & 7 deletions reg_tests/test_files/VOFInertialDroplet/VOFInertialDroplet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ realms:
volume_of_fluid: droplet
velocity: droplet
user_function_parameters:
volume_of_fluid: [0.0, 0.0, 0.0, 0.15, 0.001]
velocity: [0.0, 0.0, 0.0, 1.0, 1.0, 1.0, 0.15, 0.001]
volume_of_fluid: [0.0, 0.0, 0.0, 0.15, -100, 0, 0.01]
velocity: [0.0, 0.0, 0.0, 0.2, 0.2, 0.2, 0.15, 0.01]
- constant: ic_2
target_name: block_1
value:
Expand All @@ -82,15 +82,15 @@ realms:

boundary_conditions:
- periodic_boundary_condition: bc_1
target_name: [surface_1, surface_4]
target_name: [surface_1, surface_2]
periodic_user_data:
search_tolerance: 0.001
- periodic_boundary_condition: bc_2
target_name: [surface_2, surface_5]
target_name: [surface_3, surface_4]
periodic_user_data:
search_tolerance: 0.001
- periodic_boundary_condition: bc_3
target_name: [surface_3, surface_6]
target_name: [surface_5, surface_6]
periodic_user_data:
search_tolerance: 0.001

Expand Down Expand Up @@ -125,8 +125,8 @@ Time_Integrators:
- StandardTimeIntegrator:
name: ti_1
start_time: 0
termination_time: 0.0003
time_step: 0.0001
termination_time: 0.015
time_step: 0.005
time_stepping_type: fixed
time_step_count: 10
second_order_accuracy: yes
Expand Down
45 changes: 31 additions & 14 deletions src/user_functions/DropletVOFAuxFunction.C
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,36 @@ namespace nalu {

DropletVOFAuxFunction::DropletVOFAuxFunction(const std::vector<double>& params)
: AuxFunction(0, 1),
surf_idx_(1),
droppos_x_(0.0),
droppos_y_(0.0),
droppos_z_(0.0),
radius_(0.1),
surf_pos_(0.0),
surf_idx_dbl_(1.0),
interface_thickness_(0.0025)
{
// check size and populate
if (params.size() != 5 && !params.empty())
if (params.size() != 7 && !params.empty())
throw std::runtime_error("Realm::setup_initial_conditions: "
"droplet (volume_of_fluid) requires 5 params: 3 "
"droplet (volume_of_fluid) requires 7 params: 3 "
"components of droplet position, droplet "
"radius, and interface thickness");
"radius, surface position, surface coordinate "
"index, and interface thickness");
if (!params.empty()) {
droppos_x_ = params[0];
droppos_y_ = params[1];
droppos_z_ = params[2];
radius_ = params[3];
interface_thickness_ = params[4];
surf_pos_ = params[4];
surf_idx_dbl_ = params[5];
interface_thickness_ = params[6];
}

if (surf_idx_dbl_ < 0.5) {
surf_idx_ = 0;
} else if (surf_idx_dbl_ > 1.5) {
surf_idx_ = 2;
}
}

Expand All @@ -58,17 +70,22 @@ DropletVOFAuxFunction::do_evaluate(
const double y = coords[1];
const double z = coords[2];

// fieldPtr[0] = 0.0;
// fieldPtr[0] += -0.5 * (std::erf(y / interface_thickness) + 1.0) + 1.0;
// Flat surface
fieldPtr[0] =
-0.5 * (std::erf((coords[surf_idx_] - surf_pos_) / interface_thickness_) +
1.0) +
1.0;

// Droplet
auto rad_pos = std::sqrt(
(x - droppos_x_) * (x - droppos_x_) +
(y - droppos_y_) * (y - droppos_y_) +
(z - droppos_z_) * (z - droppos_z_)) -
radius_;
fieldPtr[0] +=
-0.5 * (std::erf(rad_pos / interface_thickness_) + 1.0) + 1.0;

auto rad_pos =
std::sqrt(
(x - droppos_x_) * (x - droppos_x_) + (y - droppos_y_) * (y - droppos_y_) +
(z - droppos_z_) * (z - droppos_z_)) -
radius_;
// fieldPtr[0] += -0.5 * (std::erf(radius / interface_thickness) + 1.0)
// + 1.0;
fieldPtr[0] = -0.5 * (std::erf(rad_pos / interface_thickness_) + 1.0) + 1.0;
fieldPtr[0] = std::max(0.0, std::min(1.0, fieldPtr[0]));

fieldPtr += fieldSize;
coords += spatialDimension;
Expand Down

0 comments on commit 9eeaaae

Please sign in to comment.