ryujin 2.1.1 revision ee5cbcbf2346c1299c942d0e1f13b46449973c18
Loading...
Searching...
No Matches
hyperbolic_system.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2023 - 2026 by the ryujin authors
4//
5
6#pragma once
7
8#include <compile_time_options.h>
9
10#include <convenience_macros.h>
11#include <discretization.h>
12#include <loop.h>
14#include <patterns_conversion.h>
15#include <simd.h>
16#include <state_vector.h>
17
18#include <deal.II/base/parameter_acceptor.h>
19#include <deal.II/base/tensor.h>
20
21#include <array>
22
23namespace ryujin
24{
25 namespace Skeleton
26 {
27 template <int dim, typename Number>
28 class HyperbolicSystemView;
29
35 class HyperbolicSystem final : public dealii::ParameterAcceptor
36 {
37 public:
41 static inline const std::string problem_name =
42 "Skeleton Hyperbolic System";
43
47 HyperbolicSystem(const std::string &subsection = "/HyperbolicSystem")
48 : ParameterAcceptor(subsection)
49 {
50 }
51
56 template <int dim, typename Number = double>
58
65 template <int dim, typename Number>
66 auto view() const
67 {
68 return View<dim, Number>{*this};
69 }
70
79 template <int dim, typename ScalarNumber>
81 const OfflineData<dim, ScalarNumber> & /*offline_data*/,
83 & /*state_vector*/,
84 const bool /*skip_constrained_dofs*/ = true) const
85 {
86 // nothing to do
87 }
88
89 private:
94
95 template <int dim, typename Number>
97
99 }; /* HyperbolicSystem */
100
101
109 template <int dim, typename Number>
111 {
112 public:
117
122
126 static constexpr unsigned int problem_dimension = 1;
127
131 using state_type = dealii::Tensor<1, problem_dimension, Number>;
132
136 using flux_type =
137 dealii::Tensor<1, problem_dimension, dealii::Tensor<1, dim, Number>>;
138
143
148 static inline const auto component_names =
149 []() -> std::array<std::string, problem_dimension> {
150 if constexpr (dim == 1)
151 return {"u"};
152 else if constexpr (dim == 2)
153 return {"u"};
154 else if constexpr (dim == 3)
155 return {"u"};
156 __builtin_trap();
157 }();
158
163 static inline const auto primitive_component_names =
164 []() -> std::array<std::string, problem_dimension> {
165 if constexpr (dim == 1)
166 return {"u"};
167 else if constexpr (dim == 2)
168 return {"u"};
169 else if constexpr (dim == 3)
170 return {"u"};
171 __builtin_trap();
172 }();
173
177 static constexpr unsigned int n_precomputed_values = 0;
178
182 using precomputed_type = std::array<Number, n_precomputed_values>;
183
187 static inline const auto precomputed_names =
188 std::array<std::string, n_precomputed_values>{};
189
193 static constexpr unsigned int n_initial_precomputed_values = 0;
194
199 std::array<Number, n_initial_precomputed_values>;
200
204 static inline const auto initial_precomputed_names =
205 std::array<std::string, n_initial_precomputed_values>{};
206
210 using StateVector = Vectors::
211 StateVector<ScalarNumber, problem_dimension, n_precomputed_values>;
212
218
224
232 dealii::VectorizedArray<ScalarNumber>::size(),
233 dealii::MemorySpace::Host,
234 /*writable=*/false>;
235
243
251 dealii::VectorizedArray<ScalarNumber>::size(),
252 dealii::MemorySpace::Host,
253 /*writable=*/false>;
254
256
260
265 HyperbolicSystemView(const HyperbolicSystem &hyperbolic_system)
266 : hyperbolic_system_(hyperbolic_system)
267 {
268 }
269
271
275
281 bool is_admissible(const state_type & /*U*/) const
282 {
283 return true;
284 }
285
287
291
295 template <typename Lambda>
297 const dealii::types::boundary_id /*id*/,
298 const state_type &U,
299 const dealii::Tensor<1, dim, Number> & /*normal*/,
300 const Lambda & /*get_dirichlet_data*/) const
301 {
302 return U;
303 }
304
306
310
332 const InitialPrecomputedVectorView & /*piv*/,
333 const unsigned int /*i*/,
334 const state_type & /*U_i*/) const
335 {
336 return flux_contribution_type{};
337 }
338
341 const InitialPrecomputedVectorView & /*piv*/,
342 const unsigned int * /*js*/,
343 const state_type & /*U_j*/) const
344 {
345 return flux_contribution_type{};
346 }
347
354 const flux_contribution_type &flux_j,
355 const dealii::Tensor<1, dim, Number> &c_ij) const
356 {
357 return -contract(add(flux_i, flux_j), c_ij);
358 }
359
363 static constexpr bool have_high_order_flux = false;
364
368 const dealii::Tensor<1, dim, Number> &) const = delete;
369
371
375
377 static constexpr bool have_source_terms = false;
378
380 const unsigned int /*i*/,
381 const state_type & /*U_i*/,
382 const ScalarNumber /*tau*/) const = delete;
383
385 const unsigned int * /*js*/,
386 const state_type & /*U_j*/,
387 const ScalarNumber /*tau*/) const = delete;
388
390
394
405 template <typename ST>
406 state_type expand_state(const ST &state) const
407 {
408 return state;
409 }
410
415 state_type from_primitive_state(const state_type &primitive_state) const
416 {
417 return primitive_state;
418 }
419
425 {
426 return state;
427 }
428
434 template <typename Lambda>
436 const Lambda & /*lambda*/) const
437 {
438 return state;
439 }
440
441 private:
443
447
448 const HyperbolicSystem &hyperbolic_system_;
449
451 }; /* HyperbolicSystemView */
452 } // namespace Skeleton
453} // namespace ryujin
std::array< Number, n_precomputed_values > precomputed_type
state_type apply_galilei_transform(const state_type &state, const Lambda &) const
bool is_admissible(const state_type &) const
static constexpr unsigned int n_precomputed_values
dealii::Tensor< 1, problem_dimension, Number > state_type
flux_contribution_type flux_contribution(const PrecomputedVectorView &, const InitialPrecomputedVectorView &, const unsigned int, const state_type &) const
HyperbolicSystemView(const HyperbolicSystem &hyperbolic_system)
state_type flux_divergence(const flux_contribution_type &flux_i, const flux_contribution_type &flux_j, const dealii::Tensor< 1, dim, Number > &c_ij) const
state_type expand_state(const ST &state) const
typename get_value_type< Number >::type ScalarNumber
dealii::Tensor< 1, problem_dimension, dealii::Tensor< 1, dim, Number > > flux_type
state_type apply_boundary_conditions(const dealii::types::boundary_id, const state_type &U, const dealii::Tensor< 1, dim, Number > &, const Lambda &) const
Vectors::StateVector< ScalarNumber, problem_dimension, n_precomputed_values > StateVector
state_type high_order_flux_divergence(const flux_contribution_type &, const flux_contribution_type &, const dealii::Tensor< 1, dim, Number > &) const =delete
state_type nodal_source(const PrecomputedVectorView &, const unsigned int *, const state_type &, const ScalarNumber) const =delete
static constexpr unsigned int problem_dimension
static constexpr unsigned int n_initial_precomputed_values
state_type to_primitive_state(const state_type &state) const
state_type from_primitive_state(const state_type &primitive_state) const
std::array< Number, n_initial_precomputed_values > initial_precomputed_type
flux_contribution_type flux_contribution(const PrecomputedVectorView &, const InitialPrecomputedVectorView &, const unsigned int *, const state_type &) const
state_type nodal_source(const PrecomputedVectorView &, const unsigned int, const state_type &, const ScalarNumber) const =delete
static const std::string problem_name
void fill_precomputed_values(const OfflineData< dim, ScalarNumber > &, typename HyperbolicSystemView< dim, ScalarNumber >::StateVector &, const bool=true) const
HyperbolicSystem(const std::string &subsection="/HyperbolicSystem")
DEAL_II_HOST_DEVICE_ALWAYS_INLINE dealii::Tensor< 1, problem_dim, T > contract(const FT &flux_ij, const TT &c_ij)
DEAL_II_HOST_DEVICE_ALWAYS_INLINE FT add(const FT &flux_left_ij, const FT &flux_right_ij)