ExaDG
Loading...
Searching...
No Matches
particle_calculation.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2025 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef EXADG_POSTPROCESSOR_PARTICLE_CALCULATION_H_
23#define EXADG_POSTPROCESSOR_PARTICLE_CALCULATION_H_
24
25// deal.II
26#include <deal.II/matrix_free/matrix_free.h>
27#include <deal.II/particles/particle_handler.h>
28
29// ExaDG
30#include <exadg/matrix_free/integrators.h>
31#include <exadg/postprocessor/time_control.h>
32#include <exadg/utilities/print_functions.h>
33
34namespace ExaDG
35{
36struct ParticleData
37{
38 ParticleData() : directory("output/"), filename("particle")
39 {
40 }
41
42 void
43 print(dealii::ConditionalOStream & pcout)
44 {
45 if(time_control_data.is_active)
46 {
47 pcout << std::endl << " Trace particles:" << std::endl;
48
49 // only implemented for unsteady problem
50 time_control_data.print(pcout, true /*unsteady*/);
51
52 print_parameter(pcout, "Directory of output files", directory);
53 print_parameter(pcout, "Filename", filename);
54 }
55 }
56
57 TimeControlData time_control_data;
58
59 // directory and filename
60 std::string directory;
61 std::string filename;
62
63 // Starting points of particles
64 std::vector<dealii::Point<2>> starting_points_2d;
65 std::vector<dealii::Point<3>> starting_points_3d;
66};
67
68template<int dim, typename Number>
69class ParticleCalculator
70{
71public:
72 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
73
74 typedef dealii::VectorizedArray<Number> scalar;
75 typedef dealii::Tensor<1, dim, dealii::VectorizedArray<Number>> vector;
76 typedef dealii::Tensor<2, dim, dealii::VectorizedArray<Number>> tensor;
77
78 ParticleCalculator(MPI_Comm const & comm);
79
80 void
81 setup(dealii::DoFHandler<dim> const & dof_handler_in,
82 dealii::Mapping<dim> const & mapping_in,
83 ParticleData const & particle_data_in);
84
85 void
86 evaluate(VectorType const & velocity, double const time, bool const print_output);
87
88 TimeControl time_control;
89
90protected:
91 void
92 track_lost_particle(const typename dealii::Particles::ParticleIterator<dim> & particle,
93 const typename dealii::Triangulation<dim>::active_cell_iterator & cell);
94
95
96 MPI_Comm const mpi_comm;
97
98 dealii::ObserverPointer<dealii::DoFHandler<dim> const> dof_handler;
99 dealii::ObserverPointer<dealii::Mapping<dim> const> mapping;
100
101 ParticleData data;
102 double old_time;
103
104 unsigned int lost_paticles;
105 std::vector<std::vector<dealii::BoundingBox<dim>>> global_bounding_boxes;
106
107 dealii::Vector<Number> solution_values;
108 dealii::Particles::ParticleHandler<dim> particle_handler;
109};
110
111} // namespace ExaDG
112
113#endif /* EXADG_POSTPROCESSOR_PARTICLE_CALCULATION_H_ */
Definition time_control.h:64
Definition driver.cpp:33
Definition particle_calculation.h:37
Definition time_control.h:40