WARPXM v1.10.0
Loading...
Searching...
No Matches
phase_space_dg_geometry.h
Go to the documentation of this file.
1#ifndef geometry_phase_space_dg_geometry_h
2#define geometry_phase_space_dg_geometry_h
3
4// WARPXM includes
5#include "warpxm/warpxm_config.h"
9
10// STL includes
11#include <vector>
12#include <string>
13#include <array>
14
15namespace geometry
16{
17namespace phase_space
18{
19
39{
40public:
45 PhaseSpaceDGGeometry(const std::string basis_set_name,
46 const std::string phase_space_order,
47 const std::vector<int> vspace_nelems,
48 const std::vector<real> vspace_minimums,
49 const std::vector<real> vspace_dv);
50
56
61 void setupBases(const WmUnstructuredPatch& patch);
62
73 const std::vector<std::string>& boundary_names,
74 const bool has_fluxes);
75
76 // /**
77 // * Setup:
78 // * 1. phase space position coordinates for each phase space node in
79 // * physical_element_scope_range range given of physical elements
80 // * 2. matching global physical space node indexes for each phase space node in
81 // * physical_element_scope_range
82 // * @param physical_element_scope_range
83 // *
84 // */
85 // void setupPhaseSpaceDGGeometry(const WxRange& physical_element_scope_range);
86
94 int getFlattenedVelocitySpaceElementIndex(const int vx_element_index,
95 const int vy_element_index,
96 const int vz_element_index) const;
97
107 const int velocity_space_element_indexes[3],
108 real velocity_element_corner_coordinates[3]) const;
109
120 const int physical_element_index,
121 std::vector<std::vector<real>>& inverse_jacobian_phase_space) const;
122
123 // /**
124 // * Calculate all phase space position coordinates for a physical element scope range
125 // * and write into _phase_space_coordinates
126 // * @param physical_element_scope_range
127 // *
128 // */
129 // void setAllPhaseSpacePositionCoordinates(const WxRange& physical_element_scope_range);
130
131 // /**
132 // * Calculate the phase space position coordinate at a particular phase space node
133 // * @param phase_space_element_local_node_index phase space local node index where we
134 // * are calculating the phase space position
135 // * @param physical_element_index physical element index
136 // * @param phase_space_element_base_velocity_coordinates phase space element corder
137 // * coordinates
138 // * @return position phase space position at this phase_space_element_local_node_index
139 // * {x, y, z, vx, vy, vz}
140 // *
141 // */
142 // void setPhaseSpaceCoords(const int phase_space_element_local_node_index,
143 // const int physical_element_index,
144 // const real phase_space_element_base_velocity_coordinates[3],
145 // real position[6]);
146
147 // /**
148 // * Calculate the matching physical space node index for each phase space node index,
149 // * writing into _matching_global_physical_space_indexes
150 // * @param physical_element_scope_range
151 // *
152 // */
153 // void
154 // setMatchingGlobalPhysicalSpaceIndexes(const WxRange& physical_element_scope_range);
155
161 {
162 return _physical_space_dg_geometry.get();
163 }
164
170 {
171 return _physical_space_basis_set.get();
172 }
173
179 {
180 return _phase_space_basis_set.get();
181 }
182
187 int getVspaceNdims() const
188 {
189 return _vspace_ndims;
190 }
191
196 const std::vector<int>& getVspaceNelems() const
197 {
198 return _vspace_nelems;
199 }
200
206 const std::vector<real>& getVspaceDv() const
207 {
208 return _vspace_dv;
209 }
210
216 {
217 return _vspace_n_vx_elems;
218 }
219
225 {
226 return _vspace_n_vy_elems;
227 }
228
234 {
235 return _vspace_n_vz_elems;
236 }
237
242 const std::vector<real>& getVspaceMinimums() const
243 {
244 return _vspace_minimums;
245 }
246
251 const std::vector<real>& getVspaceMaximums() const
252 {
253 return _vspace_maximums;
254 }
255
263 const int physical_element_index,
264 const int phase_space_element_local_node_index) const
265 {
266 // Phase space local nodes should line up with physical space such that the
267 // modulus operator should just map the phase space node to the physical space
268 // node, and then add the total nodes up to the physical element to get the global
269 // node index of the physical space node.
270 const int N_p = _physical_space_basis_set->getNumTotalNodes();
271 return physical_element_index * N_p + phase_space_element_local_node_index % N_p;
272 }
273
281 // const std::vector<real>&
282 // getPhaseSpaceCoordinatesOld(const int physical_element_index,
283 // const int flattened_velocity_space_element_index,
284 // const int phase_space_element_local_node_index) const
285 // {
286 // return _phase_space_coordinates[physical_element_index]
287 // [flattened_velocity_space_element_index]
288 // [phase_space_element_local_node_index];
289 // }
290
299 void getPhaseSpaceCoordinates(const int physical_element_index,
300 const int velocity_space_element_indexes[3],
301 const int phase_space_element_local_node_index,
302 std::array<real, 6>& position) const;
303
312 int getGlobalPhaseSpaceElementIndex(const int physical_element_index,
313 const int vx_element_index,
314 const int vy_element_index,
315 const int vz_element_index);
316
326 int getGlobalPhaseSpaceNodeIndex(const int physical_element_index,
327 const int vx_element_index,
328 const int vy_element_index,
329 const int vz_element_index,
330 const int local_phase_space_element_node_index);
331
337 const std::array<int, 18>& getVfaceLookupTable()
338 {
339 return _vface_lookup;
340 }
341
342protected:
343private:
344 // To hold phase space information, we wan to hold both:
345 // -> physical space information
346 // -> velocity space information
347
348 // physical space information:
349
350 // Spatial basis set name
351 std::string _basis_set_name;
352
353 // Spatial basis set
354 std::unique_ptr<WmBasisArraySet> _physical_space_basis_set;
355
356 // WmUDGGeometry
357 std::unique_ptr<WmUDGGeometry> _physical_space_dg_geometry;
358
359 // velocity space information
360
361 std::vector<int> _vspace_nelems;
362 int _vspace_ndims;
363
364 std::vector<real> _vspace_minimums;
365 std::vector<real> _vspace_maximums;
366
367 std::vector<real> _vspace_dv;
368
369 // number of velocity elements (will be minimum 1)
370 int _vspace_n_vx_elems;
371 int _vspace_n_vy_elems;
372 int _vspace_n_vz_elems;
373
374 // Then we can hold the phase space
375 // Phase space basis set
376 std::string _phase_space_order;
377 std::unique_ptr<WmBasisArraySet> _phase_space_basis_set;
378
379 // lookup table for neighboring velocity face phase space elements
380 // there should be up to 6 velocity faces and vx, vy, or vz neighbors are +-1,
381 // depending on the face
382 // faces 0, 1 are -+ vx respectively
383 // faces 2, 3 are -+ vy respectively
384 // faces 4, 5 are -+ vz respectively
385 // The lookup table should thus be a 6x3 array looking like:
386 // [[-1, 0, 0],
387 // [+1, 0, 0],
388 // [0, -1, 0],
389 // [0, +1, 0],
390 // [0, 0, -1],
391 // [0, 0, +1]]
392 // but is flattened c-style row-wise
393 std::array<int, 18> _vface_lookup;
394};
395
396} // namespace phase_space
397} // namespace geometry
398
399#endif
Definition: wmbasisarrayset.h:13
Definition: wmudggeometry.h:108
Definition: wmunstructuredpatch.h:22
Defines the global nodal DG phase space geometry at the patch level, given a WmUDGGeometry object tha...
Definition: phase_space_dg_geometry.h:39
int getVspaceNVyElems() const
Get number of vy elements.
Definition: phase_space_dg_geometry.h:224
int getFlattenedVelocitySpaceElementIndex(const int vx_element_index, const int vy_element_index, const int vz_element_index) const
Get the flattened velocity space element index.
int getGlobalPhaseSpaceNodeIndex(const int physical_element_index, const int vx_element_index, const int vy_element_index, const int vz_element_index, const int local_phase_space_element_node_index)
Get global phase space node index given:
WmBasisArraySet const * getPhysicalSpaceBasisArraySet() const
Get the pointer to the physical space basis set object.
Definition: phase_space_dg_geometry.h:169
void calcPhaseSpaceInverseJacobian(const int physical_element_index, std::vector< std::vector< real > > &inverse_jacobian_phase_space) const
Calculate the Inverse Jacobian of the phase space element Assumes it is same for all phase space elem...
int getMatchingGlobalPhysicalSpaceNodeIndex(const int physical_element_index, const int phase_space_element_local_node_index) const
Get the matching global physical space node index from the physical element index and local phase spa...
Definition: phase_space_dg_geometry.h:262
int getVspaceNVzElems() const
Get number of vz elements.
Definition: phase_space_dg_geometry.h:233
const std::vector< real > & getVspaceMinimums() const
Get the minimum velocity space coordinates.
Definition: phase_space_dg_geometry.h:242
WmUDGGeometry const * getWmUDGGeometry() const
Get the pointer to the WmUDGGeometry object.
Definition: phase_space_dg_geometry.h:160
int getVspaceNdims() const
Get number of velocity space dimensions.
Definition: phase_space_dg_geometry.h:187
PhaseSpaceDGGeometry(const std::string basis_set_name, const std::string phase_space_order, const std::vector< int > vspace_nelems, const std::vector< real > vspace_minimums, const std::vector< real > vspace_dv)
Constructor.
const std::vector< real > & getVspaceDv() const
Get dv in each velocity space dimension {dvx, dvy, dvz}.
Definition: phase_space_dg_geometry.h:206
WmBasisArraySet const * getPhaseSpaceBasisArraySet() const
Get the pointer to the phase space basis set object.
Definition: phase_space_dg_geometry.h:178
void setupBases(const WmUnstructuredPatch &patch)
Setup physical space and phase space bases.
int getVspaceNVxElems() const
Get number of vx elements.
Definition: phase_space_dg_geometry.h:215
const std::array< int, 18 > & getVfaceLookupTable()
Get the velocity face lookup table.
Definition: phase_space_dg_geometry.h:337
int getGlobalPhaseSpaceElementIndex(const int physical_element_index, const int vx_element_index, const int vy_element_index, const int vz_element_index)
Get global phase space element index given:
const std::vector< real > & getVspaceMaximums() const
Get the maximum velocity space coordinates.
Definition: phase_space_dg_geometry.h:251
void getVelocityElementCornerCoordinates(const int velocity_space_element_indexes[3], real velocity_element_corner_coordinates[3]) const
Get the velocity element corner coordinates This is the velocity coordinate at the minimum corner of ...
void setupWmUDGGeometry(const WmUnstructuredPatch &patch, const std::vector< std::string > &boundary_names, const bool has_fluxes)
Setup physical space unstructured dg geometry.
const std::vector< int > & getVspaceNelems() const
Get number of velocity space elements in each velocity space dimension.
Definition: phase_space_dg_geometry.h:196
void getPhaseSpaceCoordinates(const int physical_element_index, const int velocity_space_element_indexes[3], const int phase_space_element_local_node_index, std::array< real, 6 > &position) const
Get phase space coordinates from _phase_space_coordinates.
Definition: phase_space_34duoprism.h:9
#define real
Definition: wmoclunstructuredreconstruction.h:11