include/meltpooldg/compressible_flow/multiphase_level_set_advection.hpp Source File

Developer Documentation: include/meltpooldg/compressible_flow/multiphase_level_set_advection.hpp Source File
Developer Documentation
multiphase_level_set_advection.hpp
Go to the documentation of this file.
1
7// TODO: remove/restructure, when level-set advection and reinitialization (and velocity field
8// extrapolation) are incorporated
9
10#pragma once
11
12#include <deal.II/base/function.h>
13#include <deal.II/base/mpi.h>
14#include <deal.II/base/point.h>
15#include <deal.II/base/utilities.h>
16
17#include <deal.II/numerics/vector_tools_interpolate.h>
18
19#include <numeric>
20
22{
28 template <int dim, typename number>
29 class LevelSetOscillatingWaterColumn : public dealii::Function<dim, number>
30 {
31 public:
36 : dealii::Function<dim, number>(1)
37 {}
38
49 void
50 update_interface_positions(const number &time_step,
51 const std::vector<number> &interface_velocity)
52 {
53 for (unsigned int i = 0; i < 2; ++i)
54 interface_coordinates[i] += time_step * interface_velocity[i];
55 }
56
62 number
63 value(const dealii::Point<dim, number> &p, const unsigned int /*component*/) const final
64 {
65 return std::min(p[0] - interface_coordinates[0], -(p[0] - interface_coordinates[1]));
66 }
67
68 private:
70 // Note that the initial interface coordinates are aligned to the data in the case file
71 // "oscillating_water_column.hpp".
72 std::vector<number> interface_coordinates = {0.100156487, 0.800156487};
73 };
74
80 template <int dim, typename number>
82 {
83 public:
88
91
107 void
108 move_level_set(auto &level_set,
109 const number &time_step,
110 const std::string &case_name,
111 const auto &scratch_data,
112 const int level_set_dof_idx)
113 {
114 if (case_name == "oscillating_water_column")
115 {
116 // two phase boundaries
117 level_set_oscillating_water_column.update_interface_positions(time_step,
119 level_set.zero_out_ghost_values();
120 dealii::VectorTools::interpolate(scratch_data->get_mapping(),
121 scratch_data->get_dof_handler(level_set_dof_idx),
123 level_set);
124 level_set.update_ghost_values();
125 }
126 else if (case_name == "two_phase" or case_name == "shell")
127 {
128 // one phase boundary
129
130 // TODO: This is a current work-around, since the level-set advection is not yet fully
131 // implemented. The mean value of the interface velocity is used to advect the level-set
132 // field. In the future, a full level-set advection should be implemented, which uses the
133 // full velocity field to advect the level-set field.
134 const number local_sum =
135 std::accumulate(interface_velocity.begin(), interface_velocity.end(), 0.);
136
137 const unsigned int local_size = interface_velocity.size();
138
139 const number global_sum =
140 dealii::Utilities::MPI::sum(local_sum, scratch_data->get_mpi_comm(level_set_dof_idx));
141
142 const unsigned int global_size =
143 dealii::Utilities::MPI::sum(local_size, scratch_data->get_mpi_comm(level_set_dof_idx));
144
145 const number velocity = global_sum / global_size;
146
147 for (unsigned int i = 0; i < level_set.locally_owned_size(); ++i)
148 level_set.local_element(i) += time_step * velocity;
149
150 level_set.update_ghost_values();
151 }
152 else
153 AssertThrow(false,
154 dealii::ExcMessage(
155 "Analytical function for level-set advection is "
156 "only supported for the cases 'oscillating_water_column', 'two_phase', "
157 "and 'shell'."));
158 }
159
165 void
166 set_interface_velocity(const number &interface_velocity_in)
167 {
168 interface_velocity.push_back(interface_velocity_in);
169 }
170
174 void
179
180 private:
183 static std::vector<number> interface_velocity;
184 };
185
186 template <int dim, typename number>
188
189 template <int dim, typename number>
191
192 template <int dim, typename number>
195} // namespace MeltPoolDG::Multiphase
Class for the analytical advection of a 1D test case.
Definition multiphase_level_set_advection.hpp:82
static LevelSetOscillatingWaterColumn< dim, number > level_set_oscillating_water_column
Object for the oscillating water column test case.
Definition multiphase_level_set_advection.hpp:90
void clear_interface_velocity()
Clear current interface velocity field.
Definition multiphase_level_set_advection.hpp:175
void move_level_set(auto &level_set, const number &time_step, const std::string &case_name, const auto &scratch_data, const int level_set_dof_idx)
Function for analytical advection of a level-set field according to computed interface velocities for...
Definition multiphase_level_set_advection.hpp:108
void set_interface_velocity(const number &interface_velocity_in)
Setter function for the computed interface velocity.
Definition multiphase_level_set_advection.hpp:166
static std::vector< number > interface_velocity
Definition multiphase_level_set_advection.hpp:183
Class for the analytical advection of a 1D test case with two phase interfaces.
Definition multiphase_level_set_advection.hpp:30
std::vector< number > interface_coordinates
Vector of interface coordinates.
Definition multiphase_level_set_advection.hpp:72
void update_interface_positions(const number &time_step, const std::vector< number > &interface_velocity)
Function to update the two interface coordinates for the case that two phase interfaces exist.
Definition multiphase_level_set_advection.hpp:50
number value(const dealii::Point< dim, number > &p, const unsigned int) const final
Analytical function for the level-set field for the "oscillating_water_column" case.
Definition multiphase_level_set_advection.hpp:63
LevelSetOscillatingWaterColumn()
Constructor.
Definition multiphase_level_set_advection.hpp:35
A collection of functions for the computation of the interface terms for compressible two-phase flows...
Definition multiphase_interface_kernels.hpp:32
Definition dealii_tensor.hpp:10