hyper.deal
Loading...
Searching...
No Matches
velocity_field_view.h
1// ---------------------------------------------------------------------
2//
3// Copyright (C) 2020 by the hyper.deal authors
4//
5// This file is part of the hyper.deal library.
6//
7// The hyper.deal library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 3.0 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.MD at
12// the top level directory of hyper.deal.
13//
14// ---------------------------------------------------------------------
15
16#ifndef HYPERDEAL_FUNCTIONALITIES_VELOCITY_FIELD_VIEW
17#define HYPERDEAL_FUNCTIONALITIES_VELOCITY_FIELD_VIEW
18
19#include <hyper.deal/base/config.h>
20
21#include <hyper.deal/matrix_free/id.h>
22
23namespace hyperdeal
24{
25 namespace advection
26 {
27 template <int dim,
28 typename Number,
29 typename ID,
30 typename VectorizedArrayType,
31 int dim_x = dim,
32 int dim_v = dim>
34 {
35 public:
36 virtual ~VelocityFieldView() = default;
37
38 virtual void
39 reinit(ID id) = 0;
40
41 virtual void
42 reinit_face(ID id) = 0;
43
44 virtual void
45 reinit_face(ID id, unsigned int face) = 0;
46
47 virtual dealii::Tensor<1, dim_x, VectorizedArrayType>
48 evaluate_x(unsigned int q, unsigned int qx, unsigned int qv) const = 0;
49
50 virtual dealii::Tensor<1, dim_v, VectorizedArrayType>
51 evaluate_v(unsigned int q, unsigned int qx, unsigned int qv) const = 0;
52
53 virtual dealii::Tensor<1, dim_x, VectorizedArrayType>
54 evaluate_face_x(unsigned int q,
55 unsigned int qx,
56 unsigned int qv) const = 0;
57
58 virtual dealii::Tensor<1, dim_v, VectorizedArrayType>
59 evaluate_face_v(unsigned int q,
60 unsigned int qx,
61 unsigned int qv) const = 0;
62 };
63
64 template <int dim,
65 typename Number,
66 typename VectorizedArrayType,
67 int dim_x,
68 int dim_v>
70 : public VelocityFieldView<dim,
71 Number,
72 TensorID,
73 VectorizedArrayType,
74 dim_x,
75 dim_v>
76 {
77 public:
79 const dealii::Tensor<1, dim, VectorizedArrayType> &transport_direction)
80 : transport_direction(transport_direction)
81 , transport_direction_x(extract<dim_x>(transport_direction, 0))
82 , transport_direction_v(extract<dim_v>(transport_direction, dim_x))
83 {}
84
85 void reinit(TensorID /*id*/) override
86 {
87 // nothing to do
88 }
89
90 void reinit_face(TensorID /*id*/) override
91 {
92 // nothing to do
93 }
94
95
96
97 void
98 reinit_face(TensorID /*id*/, unsigned int /*face*/) override
99 {
100 // nothing to do
101 }
102
103
104
105 inline DEAL_II_ALWAYS_INLINE //
106 dealii::Tensor<1, dim_x, VectorizedArrayType>
107 evaluate_x(unsigned int /*q*/,
108 unsigned int /*qx*/,
109 unsigned int /*qv*/) const override
110 {
111 return transport_direction_x;
112 }
113
114
115
116 inline DEAL_II_ALWAYS_INLINE //
117 dealii::Tensor<1, dim_v, VectorizedArrayType>
118 evaluate_v(unsigned int /*q*/,
119 unsigned int /*qx*/,
120 unsigned int /*qv*/) const override
121 {
122 return transport_direction_v;
123 }
124
125
126
127 inline DEAL_II_ALWAYS_INLINE //
128 dealii::Tensor<1, dim_x, VectorizedArrayType>
129 evaluate_face_x(unsigned int /*q*/,
130 unsigned int /*qx*/,
131 unsigned int /*qv*/) const override
132 {
133 return transport_direction_x;
134 }
135
136
137
138 inline DEAL_II_ALWAYS_INLINE //
139 dealii::Tensor<1, dim_v, VectorizedArrayType>
140 evaluate_face_v(unsigned int /*q*/,
141 unsigned int /*qx*/,
142 unsigned int /*qv*/) const override
143 {
144 return transport_direction_v;
145 }
146
147
148
149 private:
150 template <int dim_>
151 static dealii::Tensor<1, dim_, VectorizedArrayType>
152 extract(dealii::Tensor<1, dim, VectorizedArrayType> input,
153 unsigned int offset)
154 {
155 dealii::Tensor<1, dim_, VectorizedArrayType> output;
156
157 for (auto i = 0u; i < dim_; i++)
158 output[i] = input[offset + i];
159
160 return output;
161 }
162
163 const dealii::Tensor<1, dim, VectorizedArrayType> transport_direction;
164 const dealii::Tensor<1, dim_x, VectorizedArrayType> transport_direction_x;
165 const dealii::Tensor<1, dim_v, VectorizedArrayType> transport_direction_v;
166 };
167
168 } // namespace advection
169} // namespace hyperdeal
170
171#endif
Definition velocity_field_view.h:76
Definition velocity_field_view.h:34
Definition id.h:27