2#include <deal.II/base/bounding_box.h>
3#include <deal.II/base/exceptions.h>
4#include <deal.II/base/function.h>
5#include <deal.II/base/function_parser.h>
6#include <deal.II/base/function_signed_distance.h>
7#include <deal.II/base/mpi.h>
8#include <deal.II/base/parameter_handler.h>
9#include <deal.II/base/point.h>
10#include <deal.II/base/tensor.h>
11#include <deal.II/base/types.h>
12#include <deal.II/base/utilities.h>
14#include <deal.II/distributed/shared_tria.h>
15#include <deal.II/distributed/tria.h>
17#include <deal.II/grid/grid_generator.h>
18#include <deal.II/grid/grid_refinement.h>
19#include <deal.II/grid/grid_tools.h>
20#include <deal.II/grid/manifold_lib.h>
31#include "../../melt_pool_case.hpp"
55 value(
const dealii::Point<dim> &p,
const unsigned int )
const override
70 template <
int dim,
typename number>
94 dealii::parallel::distributed::Triangulation<2, 3>
tria_slice;
95 mutable std::shared_ptr<PostProcessingTools::SliceCreator<3, double>>
slice;
124 prm.add_parameter(
"domain x min",
domain_x_min,
"minimum x coordinate of simulation domain");
125 prm.add_parameter(
"domain y min",
domain_y_min,
"minimum y coordinate of simulation domain");
126 prm.add_parameter(
"domain x max",
domain_x_max,
"maximum x coordinate of simulation domain");
127 prm.add_parameter(
"domain y max",
domain_y_max,
"maximum y coordinate of simulation domain");
128 prm.add_parameter(
"cell repetitions",
130 "cell repetitions per dim applied before global refinement or amr");
131 prm.add_parameter(
"n local refinement",
133 "number of (additional to the global) refinements for local region.");
134 prm.add_parameter(
"local refinement 1 bottom left",
136 "Bottom left point of locally refined region.");
137 prm.add_parameter(
"local refinement 1 top right",
139 "Bottom left point of locally refined region.");
140 prm.add_parameter(
"local refinement 2 bottom left",
142 "Bottom left point of locally refined region.");
143 prm.add_parameter(
"local refinement 2 top right",
145 "Bottom left point of locally refined region.");
149 "Set this parameter to true if the domain should be periodic in x direction.");
151 "evaporation boundary",
153 "Set this Parameter to true if the upper boundary of the domain should be open "
154 "to enable an outward mass flow.");
155 prm.add_parameter(
"outlet pressure",
157 "If evaporation boundary is enabled, set the outlet pressure.");
161 "Set this Parameter to true if the outer boundaries should be slip boundaries instead of no-slip.");
162 prm.enter_subsection(
"initial temperature");
164 prm.add_parameter(
"top",
T_initial_top,
"Set the initial temperature on the top boundary.");
165 prm.add_parameter(
"bottom",
167 "Set the initial temperature on the bottom boundary.");
169 prm.leave_subsection();
170 prm.enter_subsection(
"bc temperature");
172 prm.add_parameter(
"top",
T_bc_top,
"Set the initial temperature on the top boundary.");
173 prm.add_parameter(
"bottom",
175 "Set the initial temperature on the bottom boundary.");
177 prm.leave_subsection();
178 prm.enter_subsection(
"output slice");
180 prm.add_parameter(
"enable",
182 "Set this parameter to true, if a slice output should be"
184 prm.add_parameter(
"output variables",
186 "Specify variables that you request to output for the slice."
187 "In the default case, the one specified within the output "
188 "section will be adopted.");
189 prm.add_parameter(
"n global refinement",
191 "Set the maximum (global) refinement level.");
192 prm.add_parameter(
"coord",
194 "Set the x/y coordinate where the slice should take place.");
195 prm.enter_subsection(
"refined region");
197 prm.add_parameter(
"n local refinement",
199 "Set the additional refinements of the locally refined region.");
200 prm.add_parameter(
"bottom left",
202 "Coordinates of the bottom left point of the refined domain");
203 prm.add_parameter(
"top right",
205 "Coordinates of the top right point of the refined domain");
207 prm.leave_subsection();
209 prm.leave_subsection();
211 return this->
parameters.base.do_print_parameters;
222 if (this->
parameters.base.fe.type == FiniteElementType::FE_SimplexP || dim == 1)
224#ifdef DEAL_II_WITH_METIS
225 this->
triangulation = std::make_shared<dealii::parallel::shared::Triangulation<dim>>(
227 dealii::Triangulation<dim>::MeshSmoothing::none,
229 dealii::parallel::shared::Triangulation<dim>::Settings::partition_metis);
234 "Missing Metis support of the deal.II installation. "
235 "Configure deal.II with -D DEAL_II_WITH_METIS='ON' to execute this example."));
240 this->
triangulation = std::make_shared<dealii::parallel::distributed::Triangulation<dim>>(
251 const dealii::Point<dim> bottom_left = dim == 1 ? dealii::Point<dim>(y_min) :
252 dim == 2 ? dealii::Point<dim>(x_min, y_min) :
253 dealii::Point<dim>(x_min, x_min, y_min);
254 const dealii::Point<dim> top_right = dim == 1 ? dealii::Point<dim>(y_max) :
255 dim == 2 ? dealii::Point<dim>(x_max, y_max) :
256 dealii::Point<dim>(x_max, x_max, y_max);
258 if (this->
parameters.base.fe.type == FiniteElementType::FE_SimplexP)
260 std::vector<unsigned int> subdivisions(
261 dim, 5 * dealii::Utilities::pow(2, this->
parameters.base.global_refinements));
262 subdivisions[dim - 1] *= 2;
263 for (
int d = 0; d < dim; d++)
266 dealii::GridGenerator::subdivided_hyper_rectangle_with_simplices(
267 *this->
triangulation, subdivisions, bottom_left, top_right,
true );
271 dealii::GridGenerator::subdivided_hyper_rectangle(
272 *this->
triangulation, cell_repetitions, bottom_left, top_right,
true );
276 if constexpr (dim == 3)
280 dealii::GridGenerator::subdivided_hyper_rectangle(
286 dealii::GridTools::rotate(dealii::Point<3>::unit_vector(0),
287 0.5 * dealii::numbers::PI,
290 dealii::GridTools::shift(dealii::Point<3>::unit_vector(1) *
slice_data.
coord,
299 const auto slice_refined = dealii::BoundingBox<3>(
304 for (
auto &cell :
tria_slice.active_cell_iterators())
306 if (cell->is_locally_owned())
308 for (
unsigned int i = 0; i < cell->n_vertices(); ++i)
309 if (slice_refined.point_inside(cell->vertex(i)))
311 cell->set_refine_flag();
316 tria_slice.execute_coarsening_and_refinement();
412 const auto [lower_bc, upper_bc, left_bc, right_bc, front_bc, back_bc] =
413 get_colorized_rectangle_boundary_ids<dim>();
426 const auto add_slip_or_no_slip_boundary = [&](
const dealii::types::boundary_id bc) {
433 add_slip_or_no_slip_boundary(lower_bc);
437 {upper_bc, std::make_shared<dealii::Functions::ConstantFunction<dim>>(
outlet_pressure)},
459 add_slip_or_no_slip_boundary(upper_bc);
464 add_slip_or_no_slip_boundary(left_bc);
465 add_slip_or_no_slip_boundary(right_bc);
469 add_slip_or_no_slip_boundary(front_bc);
470 add_slip_or_no_slip_boundary(back_bc);
478 if (this->
parameters.laser.model != Heat::LaserModelType::analytical_temperature)
484 std::shared_ptr<dealii::Function<dim>> T_1;
485 std::shared_ptr<dealii::Function<dim>> T_2;
489 T_1 = std::make_shared<dealii::FunctionParser<dim>>(
T_bc_top);
490 T_2 = std::make_shared<dealii::FunctionParser<dim>>(
T_bc_bottom);
494 T_1 = std::make_shared<dealii::Functions::ConstantFunction<dim>>(
T_initial_top);
496 std::make_shared<dealii::Functions::ConstantFunction<dim>>(
T_initial_bottom);
504 if (this->
parameters.laser.model == Heat::LaserModelType::RTE)
505 this->
parameters.laser.rte_boundary_id = upper_bc;
507 if (this->
parameters.base.fe.type != FiniteElementType::FE_SimplexP)
529 if (n_local_refinement > 0)
531 if constexpr (dim == 2)
534 const auto refinement_region = dealii::BoundingBox<dim>(
538 const auto refinement_region_2 = dealii::BoundingBox<dim>(
543 for (
auto &cell : this->
triangulation->active_cell_iterators())
545 if (cell->is_locally_owned())
547 for (
unsigned int i = 0; i < cell->n_vertices(); ++i)
548 if (refinement_region.point_inside(cell->vertex(i)) ||
549 refinement_region_2.point_inside(cell->vertex(i)))
551 cell->set_refine_flag();
560 AssertThrow(
false, dealii::ExcNotImplemented());
568 std::make_shared<dealii::Functions::SignedDistance::Plane<dim>>(
569 dealii::Point<dim>::unit_vector(dim - 1) *
570 this->
parameters.laser.template get_starting_position<dim>()[dim - 1],
571 -dealii::Point<dim>::unit_vector(dim - 1)),
575 if (this->
parameters.laser.model != Heat::LaserModelType::analytical_temperature)
581 if (this->
parameters.laser.model == Heat::LaserModelType::RTE)
594 if constexpr (dim == 3)
598 slice = std::make_shared<PostProcessingTools::SliceCreator<3, double>>(
603 slice->reinit(generic_data_out);
A generic utility for managing simulation output data in the MeltPoolDG context.
Definition generic_data_out.hpp:32
Definition melt_pool_case.hpp:290
MeltPoolCaseParameters< number > parameters
Definition melt_pool_case.hpp:292
void attach_boundary_condition(std::pair< const dealii::types::boundary_id, const std::shared_ptr< dealii::Function< dim > > > id_and_function, const std::string &type, const std::string &operation_name)
Attach a boundary condition for a specific operation.
Definition simulation_case_base.hpp:345
std::shared_ptr< dealii::Triangulation< dim, spacedim > > triangulation
Definition simulation_case_base.hpp:49
const std::string parameter_file
Definition simulation_case_base.hpp:52
void attach_periodic_boundary_condition(const dealii::types::boundary_id id_in, const dealii::types::boundary_id id_out, const int direction)
Definition simulation_case_base.hpp:384
void attach_initial_condition(std::shared_ptr< dealii::Function< dim > > initial_function, const std::string &operation_name)
Definition simulation_case_base.hpp:327
const MPI_Comm mpi_communicator
Definition simulation_case_base.hpp:56
Definition recoil_pressure.hpp:41
const double y_min
Definition recoil_pressure.hpp:66
InitialConditionTemperature(const double T_initial_bottom, const double T_initial_top, const double y_min, const double y_max)
Definition recoil_pressure.hpp:43
double value(const dealii::Point< dim > &p, const unsigned int) const override
Definition recoil_pressure.hpp:55
const double T_initial_top
Definition recoil_pressure.hpp:65
const double grad_T
Definition recoil_pressure.hpp:67
const double T_initial_bottom
Definition recoil_pressure.hpp:64
Definition recoil_pressure.hpp:72
void set_boundary_conditions() override
Pure virtual function to set the boundary conditions.
Definition recoil_pressure.hpp:324
void do_postprocessing(const GenericDataOut< dim, double > &generic_data_out) const final
Definition recoil_pressure.hpp:587
void set_field_conditions() override
Pure virtual function to set the field conditions.
Definition recoil_pressure.hpp:565
struct MeltPoolDG::Simulation::RecoilPressure::SimulationRecoilPressure::SliceData slice_data
double domain_x_max
Definition recoil_pressure.hpp:75
std::vector< unsigned int > cell_repetitions
Definition recoil_pressure.hpp:78
void create_spatial_discretization() override
Pure virtual function to create the spatial discretization.
Definition recoil_pressure.hpp:215
bool slip_boundary
Definition recoil_pressure.hpp:83
double domain_x_min
Definition recoil_pressure.hpp:74
unsigned int n_written_time_step_slice
Definition recoil_pressure.hpp:96
bool add_case_specific_parameters(dealii::ParameterHandler &prm) override
Add simulation-specific parameters (can be overridden).
Definition recoil_pressure.hpp:122
dealii::Point< dim > local_refinement_1_top_right
Definition recoil_pressure.hpp:89
bool evaporation_boundary
Definition recoil_pressure.hpp:81
SimulationRecoilPressure(std::string parameter_file, const MPI_Comm mpi_communicator)
Definition recoil_pressure.hpp:115
dealii::parallel::distributed::Triangulation< 2, 3 > tria_slice
Definition recoil_pressure.hpp:94
double domain_y_min
Definition recoil_pressure.hpp:76
double outlet_pressure
Definition recoil_pressure.hpp:82
dealii::Point< dim > local_refinement_1_bottom_left
Definition recoil_pressure.hpp:88
bool periodic_boundary
Definition recoil_pressure.hpp:80
double T_initial_bottom
Definition recoil_pressure.hpp:86
dealii::Point< dim > local_refinement_2_bottom_left
Definition recoil_pressure.hpp:90
unsigned int n_local_refinement
Definition recoil_pressure.hpp:84
std::shared_ptr< PostProcessingTools::SliceCreator< 3, double > > slice
Definition recoil_pressure.hpp:95
double T_initial_top
Definition recoil_pressure.hpp:85
double domain_y_max
Definition recoil_pressure.hpp:77
dealii::Point< dim > local_refinement_2_top_right
Definition recoil_pressure.hpp:91
Definition recoil_pressure.cpp:6
static std::string T_bc_bottom
Definition recoil_pressure.hpp:36
static std::string T_bc_top
Definition recoil_pressure.hpp:35
Definition dealii_tensor.hpp:10
Definition recoil_pressure.hpp:106
dealii::Point< 3 > bottom_left
Definition recoil_pressure.hpp:108
dealii::Point< 3 > top_right
Definition recoil_pressure.hpp:109
unsigned int n_local_refinement
Definition recoil_pressure.hpp:107
Definition recoil_pressure.hpp:99
bool enable
Definition recoil_pressure.hpp:100
struct MeltPoolDG::Simulation::RecoilPressure::SimulationRecoilPressure::SliceData::RefinedRegion refined_region
int n_global_refinement
Definition recoil_pressure.hpp:101
std::vector< std::string > output_variables
Definition recoil_pressure.hpp:103
double coord
Definition recoil_pressure.hpp:102