Cabana 0.8.0-dev
 
Loading...
Searching...
No Matches
Cabana_Grid_LocalMesh.hpp
Go to the documentation of this file.
1/****************************************************************************
2 * Copyright (c) 2018-2023 by the Cabana authors *
3 * All rights reserved. *
4 * *
5 * This file is part of the Cabana library. Cabana is distributed under a *
6 * BSD 3-clause license. For the licensing terms see the LICENSE file in *
7 * the top-level directory. *
8 * *
9 * SPDX-License-Identifier: BSD-3-Clause *
10 ****************************************************************************/
11
16#ifndef CABANA_GRID_LOCALMESH_HPP
17#define CABANA_GRID_LOCALMESH_HPP
18
20#include <Cabana_Grid_Types.hpp>
21
22#include <Cabana_Utils.hpp> // FIXME: remove after next release.
23
24#include <Kokkos_Core.hpp>
25
26namespace Cabana
27{
28namespace Grid
29{
30//---------------------------------------------------------------------------//
31// Forward declaration of local mesh.
32template <class MemorySpace, class MeshType>
34
35//---------------------------------------------------------------------------//
37template <class Scalar, class MemorySpace, std::size_t NumSpaceDim>
38class LocalMesh<MemorySpace, UniformMesh<Scalar, NumSpaceDim>>
39{
40 public:
43
45 using scalar_type = Scalar;
46
48 static constexpr std::size_t num_space_dim = NumSpaceDim;
49
50 // FIXME: extracting the self type for backwards compatibility with previous
51 // template on DeviceType. Should simply be MemorySpace after next release.
53 using memory_space = typename MemorySpace::memory_space;
54 // FIXME: replace warning with memory space assert after next release.
55 static_assert(
56 Cabana::Impl::deprecated( Kokkos::is_device<MemorySpace>() ) );
57
59 using device_type [[deprecated]] = typename memory_space::device_type;
61 using execution_space = typename memory_space::execution_space;
62
64 LocalMesh() = default;
65
68 {
69 const auto& global_grid = local_grid.globalGrid();
70 const auto& global_mesh = global_grid.globalMesh();
71
72 // Get the cell size.
73 for ( std::size_t d = 0; d < num_space_dim; ++d )
74 _cell_size[d] = global_mesh.cellSize( d );
75
76 // Compute face area.
77 if ( 3 == num_space_dim )
78 {
79 _face_area[Dim::I] = _cell_size[Dim::J] * _cell_size[Dim::K];
80 _face_area[Dim::J] = _cell_size[Dim::I] * _cell_size[Dim::K];
81 _face_area[Dim::K] = _cell_size[Dim::I] * _cell_size[Dim::J];
82 }
83 else if ( 2 == num_space_dim )
84 {
85 _face_area[Dim::I] = _cell_size[Dim::J];
86 _face_area[Dim::J] = _cell_size[Dim::I];
87 }
88
89 // Compute cell volume.
90 _cell_volume = 1.0;
91 for ( std::size_t d = 0; d < num_space_dim; ++d )
92 _cell_volume *= _cell_size[d];
93
94 // Compute the owned low corner
95 for ( std::size_t d = 0; d < num_space_dim; ++d )
96 _own_low_corner[d] = global_mesh.lowCorner( d ) +
97 _cell_size[d] * global_grid.globalOffset( d );
98
99 // Compute the owned high corner
100 for ( std::size_t d = 0; d < num_space_dim; ++d )
101 _own_high_corner[d] =
102 global_mesh.lowCorner( d ) +
103 _cell_size[d] * ( global_grid.globalOffset( d ) +
104 global_grid.ownedNumCell( d ) );
105
106 // Compute the ghosted low corner
107 for ( std::size_t d = 0; d < num_space_dim; ++d )
108 _ghost_low_corner[d] = lowCorner( Own(), d ) -
109 local_grid.haloCellWidth() * _cell_size[d];
110
111 // Compute the ghosted high corner
112 for ( std::size_t d = 0; d < num_space_dim; ++d )
113 _ghost_high_corner[d] = highCorner( Own(), d ) +
114 local_grid.haloCellWidth() * _cell_size[d];
115
116 // Periodicity
117 for ( std::size_t d = 0; d < num_space_dim; ++d )
118 _periodic[d] = global_grid.isPeriodic( d );
119
120 // Determine if a block is on the low or high boundaries.
121 for ( std::size_t d = 0; d < num_space_dim; ++d )
122 {
123 _boundary_lo[d] = global_grid.onLowBoundary( d );
124 _boundary_hi[d] = global_grid.onHighBoundary( d );
125 }
126 }
127
129 KOKKOS_INLINE_FUNCTION
130 bool isPeriodic( const int dim ) const { return _periodic[dim]; }
131
133 KOKKOS_INLINE_FUNCTION
134 bool onLowBoundary( const int dim ) const { return _boundary_lo[dim]; }
135
137 KOKKOS_INLINE_FUNCTION
138 bool onHighBoundary( const int dim ) const { return _boundary_hi[dim]; }
139
142 KOKKOS_INLINE_FUNCTION
143 Scalar lowCorner( Own, const int dim ) const
144 {
145 return _own_low_corner[dim];
146 }
147
151 KOKKOS_INLINE_FUNCTION
152 Scalar lowCorner( Ghost, const int dim ) const
153 {
154 return _ghost_low_corner[dim];
155 }
156
159 KOKKOS_INLINE_FUNCTION
160 Scalar highCorner( Own, const int dim ) const
161 {
162 return _own_high_corner[dim];
163 }
164
168 KOKKOS_INLINE_FUNCTION
169 Scalar highCorner( Ghost, const int dim ) const
170 {
171 return _ghost_high_corner[dim];
172 }
173
175 template <typename Decomposition>
176 KOKKOS_FUNCTION Scalar extent( Decomposition d, const int dim ) const
177 {
178 return highCorner( d, dim ) - lowCorner( d, dim );
179 }
180
185 template <class Integer>
186 KOKKOS_INLINE_FUNCTION void coordinates( Cell,
187 const Integer index[num_space_dim],
188 Scalar x[num_space_dim] ) const
189 {
190 for ( std::size_t d = 0; d < num_space_dim; ++d )
191 x[d] = _ghost_low_corner[d] +
192 ( Scalar( index[d] ) + Scalar( 0.5 ) ) * _cell_size[d];
193 }
194
199 template <class Integer>
200 KOKKOS_INLINE_FUNCTION void coordinates( Node,
201 const Integer index[num_space_dim],
202 Scalar x[num_space_dim] ) const
203 {
204 for ( std::size_t d = 0; d < num_space_dim; ++d )
205 x[d] = _ghost_low_corner[d] + Scalar( index[d] ) * _cell_size[d];
206 }
207
212 template <int Dir, class Integer>
213 KOKKOS_INLINE_FUNCTION void coordinates( Face<Dir>,
214 const Integer index[num_space_dim],
215 Scalar x[num_space_dim] ) const
216 {
217 static_assert( Dir < num_space_dim, "Face dimension out of bounds" );
218 for ( std::size_t d = 0; d < num_space_dim; ++d )
219 if ( Dir == d )
220 x[d] =
221 _ghost_low_corner[d] + Scalar( index[d] ) * _cell_size[d];
222 else
223 x[d] = _ghost_low_corner[d] +
224 ( Scalar( index[d] ) + Scalar( 0.5 ) ) * _cell_size[d];
225 }
226
231 template <int Dir, class Integer, std::size_t NSD = num_space_dim>
232 KOKKOS_INLINE_FUNCTION std::enable_if_t<3 == NSD, void>
233 coordinates( Edge<Dir>, const Integer index[3], Scalar x[3] ) const
234 {
235 for ( std::size_t d = 0; d < 3; ++d )
236 if ( Dir == d )
237 x[d] = _ghost_low_corner[d] +
238 ( Scalar( index[d] ) + Scalar( 0.5 ) ) * _cell_size[d];
239 else
240 x[d] =
241 _ghost_low_corner[d] + Scalar( index[d] ) * _cell_size[d];
242 }
243
248 template <class Integer>
249 KOKKOS_INLINE_FUNCTION Scalar measure( Node,
250 const Integer[num_space_dim] ) const
251 {
252 return 0.0;
253 }
254
259 template <int Dir, class Integer, std::size_t NSD = num_space_dim>
260 KOKKOS_INLINE_FUNCTION std::enable_if_t<3 == NSD, Scalar>
261 measure( Edge<Dir>, const Integer[3] ) const
262 {
263 return _cell_size[Dir];
264 }
265
270 template <int Dir, class Integer>
271 KOKKOS_INLINE_FUNCTION Scalar measure( Face<Dir>,
272 const Integer[num_space_dim] ) const
273 {
274 static_assert( Dir < num_space_dim, "Face dimension out of bounds" );
275 return _face_area[Dir];
276 }
277
282 template <class Integer>
283 KOKKOS_INLINE_FUNCTION Scalar measure( Cell,
284 const Integer[num_space_dim] ) const
285 {
286 return _cell_volume;
287 }
288
289 private:
290 Kokkos::Array<Scalar, num_space_dim> _cell_size;
291 Kokkos::Array<Scalar, num_space_dim> _face_area;
292 Scalar _cell_volume;
293 Kokkos::Array<Scalar, num_space_dim> _own_low_corner;
294 Kokkos::Array<Scalar, num_space_dim> _own_high_corner;
295 Kokkos::Array<Scalar, num_space_dim> _ghost_low_corner;
296 Kokkos::Array<Scalar, num_space_dim> _ghost_high_corner;
297 Kokkos::Array<bool, num_space_dim> _periodic;
298 Kokkos::Array<bool, num_space_dim> _boundary_lo;
299 Kokkos::Array<bool, num_space_dim> _boundary_hi;
300};
301
302//---------------------------------------------------------------------------//
304template <class Scalar, class MemorySpace, std::size_t NumSpaceDim>
305class LocalMesh<MemorySpace, NonUniformMesh<Scalar, NumSpaceDim>>
306{
307 public:
310
312 using scalar_type = Scalar;
313
315 static constexpr std::size_t num_space_dim = NumSpaceDim;
316
317 // FIXME: extracting the self type for backwards compatibility with previous
318 // template on DeviceType. Should simply be MemorySpace after next release.
320 using memory_space = typename MemorySpace::memory_space;
321 // FIXME: replace warning with memory space assert after next release.
322 static_assert(
323 Cabana::Impl::deprecated( Kokkos::is_device<MemorySpace>() ) );
324
326 using device_type [[deprecated]] = typename memory_space::device_type;
328 using execution_space = typename memory_space::execution_space;
329
333 {
334 const auto& global_grid = local_grid.globalGrid();
335 const auto& global_mesh = global_grid.globalMesh();
336
337 // Compute the owned low corner.
338 for ( std::size_t d = 0; d < num_space_dim; ++d )
339 _own_low_corner[d] =
340 global_mesh.nonUniformEdge( d )[global_grid.globalOffset( d )];
341
342 // Compute the owned high corner
343 for ( std::size_t d = 0; d < num_space_dim; ++d )
344 _own_high_corner[d] =
345 global_mesh.nonUniformEdge( d )[global_grid.globalOffset( d ) +
346 global_grid.ownedNumCell( d )];
347
348 // Compute the ghosted low corner
349 for ( std::size_t d = 0; d < num_space_dim; ++d )
350 {
351 // Interior domain case.
352 if ( !global_grid.onLowBoundary( d ) )
353 {
354 _ghost_low_corner[d] = global_mesh.nonUniformEdge(
355 d )[global_grid.globalOffset( d ) -
356 local_grid.haloCellWidth()];
357 }
358
359 // Periodic boundary. Use cells on other side of boundary to
360 // generate geometry.
361 else if ( global_grid.isPeriodic( d ) )
362 {
363 int nedge = global_mesh.nonUniformEdge( d ).size();
364 _ghost_low_corner[d] =
365 global_mesh.nonUniformEdge( d ).front() -
366 ( global_mesh.nonUniformEdge( d ).back() -
367 global_mesh.nonUniformEdge(
368 d )[nedge - local_grid.haloCellWidth() - 1] );
369 }
370
371 // In the non-periodic boundary case we extrapolate halo cells to
372 // have the same width as the boundary cell.
373 else
374 {
375 Scalar dx = global_mesh.nonUniformEdge( d )[1] -
376 global_mesh.nonUniformEdge( d )[0];
377 _ghost_low_corner[d] = global_mesh.nonUniformEdge( d ).front() -
378 dx * local_grid.haloCellWidth();
379 }
380 }
381
382 // Compute the ghosted high corner
383 for ( std::size_t d = 0; d < num_space_dim; ++d )
384 {
385 // Interior domain case.
386 if ( !global_grid.onHighBoundary( d ) )
387 {
388 _ghost_high_corner[d] = global_mesh.nonUniformEdge(
389 d )[global_grid.globalOffset( d ) +
390 global_grid.ownedNumCell( d ) +
391 local_grid.haloCellWidth()];
392 }
393
394 // Periodic boundary. Use cells on other side of boundary to
395 // generate geometry.
396 else if ( global_grid.isPeriodic( d ) )
397 {
398 _ghost_high_corner[d] =
399 global_mesh.nonUniformEdge( d ).back() +
400 ( global_mesh.nonUniformEdge(
401 d )[local_grid.haloCellWidth()] -
402 global_mesh.nonUniformEdge( d ).front() );
403 }
404
405 // In the non-periodic boundary case we extrapolate halo cells to
406 // have the same width as the boundary cell.
407 else
408 {
409 int nedge = global_mesh.nonUniformEdge( d ).size();
410 Scalar dx = global_mesh.nonUniformEdge( d )[nedge - 1] -
411 global_mesh.nonUniformEdge( d )[nedge - 2];
412 _ghost_high_corner[d] = global_mesh.nonUniformEdge( d ).back() +
413 dx * local_grid.haloCellWidth();
414 }
415 }
416
417 // Get the node index spaces.
418 auto owned_nodes_local =
419 local_grid.indexSpace( Own(), Node(), Local() );
420 auto ghosted_nodes_local =
421 local_grid.indexSpace( Ghost(), Node(), Local() );
422 auto owned_nodes_global =
423 local_grid.indexSpace( Own(), Node(), Global() );
424 for ( std::size_t d = 0; d < num_space_dim; ++d )
425 {
426 // Allocate edges on the device for this dimension.
427 const auto& global_edge = global_mesh.nonUniformEdge( d );
428 int nedge = ghosted_nodes_local.extent( d );
429 int nedge_global = global_edge.size();
430 _local_edges[d] = Kokkos::View<Scalar*, MemorySpace>(
431 Kokkos::ViewAllocateWithoutInitializing( "local_edges" ),
432 nedge );
433
434 // Compute edges on the host.
435 auto edge_mirror = Kokkos::create_mirror_view( Kokkos::HostSpace(),
436 _local_edges[d] );
437
438 // Compute the owned edges.
439 for ( int n = owned_nodes_local.min( d );
440 n < owned_nodes_local.max( d ); ++n )
441 {
442 edge_mirror( n ) = global_edge[owned_nodes_global.min( d ) + n -
443 owned_nodes_local.min( d )];
444 }
445
446 // Compute the lower boundary edges.
447 if ( !global_grid.onLowBoundary( d ) )
448 {
449 // Interior block gets edges from neighbors.
450 for ( int n = 0; n < owned_nodes_local.min( d ); ++n )
451 {
452 edge_mirror( n ) =
453 global_edge[owned_nodes_global.min( d ) + n -
454 owned_nodes_local.min( d )];
455 }
456 }
457 else if ( global_grid.isPeriodic( d ) )
458 {
459 // Periodic boundary block gets edges from neighbor on
460 // opposite side of boundary.
461 for ( int n = 0; n < owned_nodes_local.min( d ); ++n )
462 {
463 edge_mirror( n ) =
464 global_edge.front() - global_edge.back() +
465 global_edge[global_edge.size() - 1 -
466 local_grid.haloCellWidth() + n];
467 }
468 }
469 else
470 {
471 // Non-periodic boundary block extrapolates edges using
472 // boundary cell width.
473 for ( int n = 0; n < owned_nodes_local.min( d ); ++n )
474 {
475 Scalar dx = global_edge[1] - global_edge[0];
476 edge_mirror( n ) = global_edge.front() -
477 ( owned_nodes_local.min( d ) - n ) * dx;
478 }
479 }
480
481 // Compute the upper boundary edges.
482 if ( !global_grid.onHighBoundary( d ) )
483 {
484 // Interior block gets edges from neighbors.
485 for ( int n = owned_nodes_local.max( d );
486 n < ghosted_nodes_local.max( d ); ++n )
487 {
488 edge_mirror( n ) =
489 global_edge[owned_nodes_global.min( d ) + n -
490 owned_nodes_local.min( d )];
491 }
492 }
493 else if ( global_grid.isPeriodic( d ) )
494 {
495 // Periodic boundary block gets edges from neighbor on
496 // opposite side of boundary.
497 for ( int n = 0; n < ghosted_nodes_local.max( d ) -
498 owned_nodes_local.max( d );
499 ++n )
500 {
501 edge_mirror( owned_nodes_local.max( d ) + n ) =
502 global_edge.back() + global_edge[n] -
503 global_edge.front();
504 }
505 }
506 else
507 {
508 // Non-periodic boundary block extrapolates edges using
509 // boundary cell width.
510 for ( int n = owned_nodes_local.max( d );
511 n < ghosted_nodes_local.max( d ); ++n )
512 {
513 Scalar dx = global_edge[nedge_global - 1] -
514 global_edge[nedge_global - 2];
515 edge_mirror( n ) =
516 global_edge.back() +
517 ( n - owned_nodes_local.max( d ) + 1 ) * dx;
518 }
519 }
520
521 // Copy edges to the device.
522 Kokkos::deep_copy( _local_edges[d], edge_mirror );
523 }
524
525 // Periodicity
526 for ( std::size_t d = 0; d < num_space_dim; ++d )
527 _periodic[d] = global_grid.isPeriodic( d );
528
529 // Determine if a block is on the low or high boundaries.
530 for ( std::size_t d = 0; d < num_space_dim; ++d )
531 {
532 _boundary_lo[d] = global_grid.onLowBoundary( d );
533 _boundary_hi[d] = global_grid.onHighBoundary( d );
534 }
535 }
536
539 KOKKOS_INLINE_FUNCTION
540 bool isPeriodic( const int dim ) const { return _periodic[dim]; }
541
544 KOKKOS_INLINE_FUNCTION
545 bool onLowBoundary( const int dim ) const { return _boundary_lo[dim]; }
546
549 KOKKOS_INLINE_FUNCTION
550 bool onHighBoundary( const int dim ) const { return _boundary_hi[dim]; }
551
554 KOKKOS_INLINE_FUNCTION
555 Scalar lowCorner( Own, const int dim ) const
556 {
557 return _own_low_corner[dim];
558 }
559
563 KOKKOS_INLINE_FUNCTION
564 Scalar lowCorner( Ghost, const int dim ) const
565 {
566 return _ghost_low_corner[dim];
567 }
568
571 KOKKOS_INLINE_FUNCTION
572 Scalar highCorner( Own, const int dim ) const
573 {
574 return _own_high_corner[dim];
575 }
576
580 KOKKOS_INLINE_FUNCTION
581 Scalar highCorner( Ghost, const int dim ) const
582 {
583 return _ghost_high_corner[dim];
584 }
585
589 template <typename Decomposition>
590 KOKKOS_FUNCTION Scalar extent( Decomposition d, const int dim ) const
591 {
592 return highCorner( d, dim ) - lowCorner( d, dim );
593 }
594
602 template <class Integer>
603 KOKKOS_INLINE_FUNCTION void coordinates( Cell,
604 const Integer index[num_space_dim],
605 Scalar x[num_space_dim] ) const
606 {
607 for ( std::size_t d = 0; d < num_space_dim; ++d )
608 x[d] = ( _local_edges[d]( index[d] + 1 ) +
609 _local_edges[d]( index[d] ) ) /
610 Scalar( 2.0 );
611 }
612
619 template <class Integer>
620 KOKKOS_INLINE_FUNCTION void coordinates( Node,
621 const Integer index[num_space_dim],
622 Scalar x[num_space_dim] ) const
623 {
624 for ( std::size_t d = 0; d < num_space_dim; ++d )
625 x[d] = _local_edges[d]( index[d] );
626 }
627
634 template <int Dir, class Integer>
635 KOKKOS_INLINE_FUNCTION void coordinates( Face<Dir>,
636 const Integer index[num_space_dim],
637 Scalar x[num_space_dim] ) const
638 {
639 static_assert( Dir < num_space_dim, "Face dimension out of bounds" );
640
641 for ( std::size_t d = 0; d < num_space_dim; ++d )
642 if ( Dir == d )
643 x[d] = _local_edges[d]( index[d] );
644 else
645 x[d] = ( _local_edges[d]( index[d] + 1 ) +
646 _local_edges[d]( index[d] ) ) /
647 Scalar( 2.0 );
648 }
649
656 template <int Dir, class Integer, std::size_t NSD = num_space_dim>
657 KOKKOS_INLINE_FUNCTION std::enable_if_t<3 == NSD, void>
658 coordinates( Edge<Dir>, const Integer index[3], Scalar x[3] ) const
659 {
660 for ( std::size_t d = 0; d < 3; ++d )
661 if ( Dir == d )
662 x[d] = ( _local_edges[d]( index[d] + 1 ) +
663 _local_edges[d]( index[d] ) ) /
664 Scalar( 2.0 );
665 else
666 x[d] = _local_edges[d]( index[d] );
667 }
668
672 template <class Integer>
673 KOKKOS_INLINE_FUNCTION Scalar measure( Node,
674 const Integer[num_space_dim] ) const
675 {
676 return 0.0;
677 }
678
684 template <int Dir, class Integer, std::size_t NSD = num_space_dim>
685 KOKKOS_INLINE_FUNCTION std::enable_if_t<3 == NSD, Scalar>
686 measure( Edge<Dir>, const Integer index[3] ) const
687 {
688 return _local_edges[Dir][index[Dir] + 1] -
689 _local_edges[Dir][index[Dir]];
690 }
691
697 template <class Integer, std::size_t NSD = num_space_dim>
698 KOKKOS_INLINE_FUNCTION std::enable_if_t<3 == NSD, Scalar>
699 measure( Face<Dim::I>, const Integer index[3] ) const
700 {
701 return measure( Edge<Dim::J>(), index ) *
702 measure( Edge<Dim::K>(), index );
703 }
704
710 template <class Integer, std::size_t NSD = num_space_dim>
711 KOKKOS_INLINE_FUNCTION std::enable_if_t<3 == NSD, Scalar>
712 measure( Face<Dim::J>, const Integer index[3] ) const
713 {
714 return measure( Edge<Dim::I>(), index ) *
715 measure( Edge<Dim::K>(), index );
716 }
717
723 template <class Integer, std::size_t NSD = num_space_dim>
724 KOKKOS_INLINE_FUNCTION std::enable_if_t<3 == NSD, Scalar>
725 measure( Face<Dim::K>, const Integer index[3] ) const
726 {
727 return measure( Edge<Dim::I>(), index ) *
728 measure( Edge<Dim::J>(), index );
729 }
730
736 template <class Integer, std::size_t NSD = num_space_dim>
737 KOKKOS_INLINE_FUNCTION std::enable_if_t<2 == NSD, Scalar>
738 measure( Face<Dim::I>, const Integer index[2] ) const
739 {
740 return _local_edges[Dim::J][index[Dim::J] + 1] -
741 _local_edges[Dim::J][index[Dim::J]];
742 }
743
749 template <class Integer, std::size_t NSD = num_space_dim>
750 KOKKOS_INLINE_FUNCTION std::enable_if_t<2 == NSD, Scalar>
751 measure( Face<Dim::J>, const Integer index[2] ) const
752 {
753 return _local_edges[Dim::I][index[Dim::I] + 1] -
754 _local_edges[Dim::I][index[Dim::I]];
755 }
756
762 template <class Integer>
763 KOKKOS_INLINE_FUNCTION Scalar
764 measure( Cell, const Integer index[num_space_dim] ) const
765 {
766 Scalar m = 1.0;
767 for ( std::size_t d = 0; d < num_space_dim; ++d )
768 m *= _local_edges[d][index[d] + 1] - _local_edges[d][index[d]];
769 return m;
770 }
771
772 private:
773 Kokkos::Array<Scalar, num_space_dim> _own_low_corner;
774 Kokkos::Array<Scalar, num_space_dim> _own_high_corner;
775 Kokkos::Array<Scalar, num_space_dim> _ghost_low_corner;
776 Kokkos::Array<Scalar, num_space_dim> _ghost_high_corner;
777 Kokkos::Array<Kokkos::View<Scalar*, MemorySpace>, num_space_dim>
778 _local_edges;
779 Kokkos::Array<bool, num_space_dim> _periodic;
780 Kokkos::Array<bool, num_space_dim> _boundary_lo;
781 Kokkos::Array<bool, num_space_dim> _boundary_hi;
782};
783
784//---------------------------------------------------------------------------//
789template <class MemorySpace, class MeshType>
790LocalMesh<MemorySpace, MeshType>
792{
793 return LocalMesh<MemorySpace, MeshType>( local_grid );
794}
795
796//---------------------------------------------------------------------------//
797
798} // namespace Grid
799} // namespace Cabana
800
801#endif // end CABANA_GRID_LOCALMESH_HPP
LocalMesh< MemorySpace, MeshType > createLocalMesh(const LocalGrid< MeshType > &local_grid)
Creation function for local mesh.
Definition Cabana_Grid_LocalMesh.hpp:791
Grid type tags.
Cabana utilities.
Local logical grid.
Definition Cabana_Grid_LocalGrid.hpp:39
KOKKOS_INLINE_FUNCTION bool onHighBoundary(const int dim) const
Definition Cabana_Grid_LocalMesh.hpp:550
typename memory_space::execution_space execution_space
Default execution space.
Definition Cabana_Grid_LocalMesh.hpp:328
KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==NSD, Scalar > measure(Edge< Dir >, const Integer index[3]) const
Definition Cabana_Grid_LocalMesh.hpp:686
Scalar scalar_type
Scalar type for geometric operations.
Definition Cabana_Grid_LocalMesh.hpp:312
KOKKOS_INLINE_FUNCTION void coordinates(Node, const Integer index[num_space_dim], Scalar x[num_space_dim]) const
Definition Cabana_Grid_LocalMesh.hpp:620
KOKKOS_INLINE_FUNCTION Scalar lowCorner(Own, const int dim) const
Definition Cabana_Grid_LocalMesh.hpp:555
KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==NSD, Scalar > measure(Face< Dim::K >, const Integer index[3]) const
Definition Cabana_Grid_LocalMesh.hpp:725
LocalMesh(const LocalGrid< NonUniformMesh< Scalar, num_space_dim > > &local_grid)
Constructor.
Definition Cabana_Grid_LocalMesh.hpp:331
KOKKOS_INLINE_FUNCTION Scalar measure(Node, const Integer[num_space_dim]) const
Definition Cabana_Grid_LocalMesh.hpp:673
KOKKOS_INLINE_FUNCTION std::enable_if_t< 2==NSD, Scalar > measure(Face< Dim::J >, const Integer index[2]) const
Definition Cabana_Grid_LocalMesh.hpp:751
KOKKOS_INLINE_FUNCTION void coordinates(Cell, const Integer index[num_space_dim], Scalar x[num_space_dim]) const
Definition Cabana_Grid_LocalMesh.hpp:603
NonUniformMesh< Scalar, NumSpaceDim > mesh_type
Mesh type.
Definition Cabana_Grid_LocalMesh.hpp:309
KOKKOS_FUNCTION Scalar extent(Decomposition d, const int dim) const
Definition Cabana_Grid_LocalMesh.hpp:590
KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==NSD, void > coordinates(Edge< Dir >, const Integer index[3], Scalar x[3]) const
Definition Cabana_Grid_LocalMesh.hpp:658
static constexpr std::size_t num_space_dim
Spatial dimension.
Definition Cabana_Grid_LocalMesh.hpp:315
KOKKOS_INLINE_FUNCTION Scalar highCorner(Ghost, const int dim) const
Definition Cabana_Grid_LocalMesh.hpp:581
KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==NSD, Scalar > measure(Face< Dim::J >, const Integer index[3]) const
Definition Cabana_Grid_LocalMesh.hpp:712
typename MemorySpace::memory_space memory_space
Memory space.
Definition Cabana_Grid_LocalMesh.hpp:320
KOKKOS_INLINE_FUNCTION Scalar measure(Cell, const Integer index[num_space_dim]) const
Definition Cabana_Grid_LocalMesh.hpp:764
KOKKOS_INLINE_FUNCTION bool onLowBoundary(const int dim) const
Definition Cabana_Grid_LocalMesh.hpp:545
KOKKOS_INLINE_FUNCTION void coordinates(Face< Dir >, const Integer index[num_space_dim], Scalar x[num_space_dim]) const
Definition Cabana_Grid_LocalMesh.hpp:635
KOKKOS_INLINE_FUNCTION Scalar highCorner(Own, const int dim) const
Definition Cabana_Grid_LocalMesh.hpp:572
KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==NSD, Scalar > measure(Face< Dim::I >, const Integer index[3]) const
Definition Cabana_Grid_LocalMesh.hpp:699
KOKKOS_INLINE_FUNCTION std::enable_if_t< 2==NSD, Scalar > measure(Face< Dim::I >, const Integer index[2]) const
Definition Cabana_Grid_LocalMesh.hpp:738
KOKKOS_INLINE_FUNCTION Scalar lowCorner(Ghost, const int dim) const
Definition Cabana_Grid_LocalMesh.hpp:564
KOKKOS_INLINE_FUNCTION bool isPeriodic(const int dim) const
Definition Cabana_Grid_LocalMesh.hpp:540
UniformMesh< Scalar, NumSpaceDim > mesh_type
Mesh type.
Definition Cabana_Grid_LocalMesh.hpp:42
Scalar scalar_type
Scalar type for geometric operations.
Definition Cabana_Grid_LocalMesh.hpp:45
KOKKOS_INLINE_FUNCTION Scalar measure(Cell, const Integer[num_space_dim]) const
Definition Cabana_Grid_LocalMesh.hpp:283
KOKKOS_INLINE_FUNCTION Scalar measure(Face< Dir >, const Integer[num_space_dim]) const
Definition Cabana_Grid_LocalMesh.hpp:271
KOKKOS_INLINE_FUNCTION Scalar measure(Node, const Integer[num_space_dim]) const
Definition Cabana_Grid_LocalMesh.hpp:249
KOKKOS_INLINE_FUNCTION Scalar highCorner(Own, const int dim) const
Definition Cabana_Grid_LocalMesh.hpp:160
KOKKOS_INLINE_FUNCTION void coordinates(Node, const Integer index[num_space_dim], Scalar x[num_space_dim]) const
Definition Cabana_Grid_LocalMesh.hpp:200
KOKKOS_INLINE_FUNCTION Scalar lowCorner(Ghost, const int dim) const
Definition Cabana_Grid_LocalMesh.hpp:152
KOKKOS_INLINE_FUNCTION bool onLowBoundary(const int dim) const
Determine if this block is on a low boundary in the given dimension.
Definition Cabana_Grid_LocalMesh.hpp:134
KOKKOS_INLINE_FUNCTION void coordinates(Cell, const Integer index[num_space_dim], Scalar x[num_space_dim]) const
Definition Cabana_Grid_LocalMesh.hpp:186
KOKKOS_INLINE_FUNCTION Scalar lowCorner(Own, const int dim) const
Definition Cabana_Grid_LocalMesh.hpp:143
KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==NSD, Scalar > measure(Edge< Dir >, const Integer[3]) const
Definition Cabana_Grid_LocalMesh.hpp:261
KOKKOS_INLINE_FUNCTION std::enable_if_t< 3==NSD, void > coordinates(Edge< Dir >, const Integer index[3], Scalar x[3]) const
Definition Cabana_Grid_LocalMesh.hpp:233
typename memory_space::execution_space execution_space
Default execution space.
Definition Cabana_Grid_LocalMesh.hpp:61
KOKKOS_FUNCTION Scalar extent(Decomposition d, const int dim) const
Get the extent of a given dimension.
Definition Cabana_Grid_LocalMesh.hpp:176
KOKKOS_INLINE_FUNCTION bool isPeriodic(const int dim) const
Determine if the mesh is periodic in the given dimension.
Definition Cabana_Grid_LocalMesh.hpp:130
static constexpr std::size_t num_space_dim
Spatial dimension.
Definition Cabana_Grid_LocalMesh.hpp:48
KOKKOS_INLINE_FUNCTION void coordinates(Face< Dir >, const Integer index[num_space_dim], Scalar x[num_space_dim]) const
Definition Cabana_Grid_LocalMesh.hpp:213
KOKKOS_INLINE_FUNCTION Scalar highCorner(Ghost, const int dim) const
Definition Cabana_Grid_LocalMesh.hpp:169
typename MemorySpace::memory_space memory_space
Memory space.
Definition Cabana_Grid_LocalMesh.hpp:53
LocalMesh(const LocalGrid< UniformMesh< Scalar, num_space_dim > > &local_grid)
Constructor.
Definition Cabana_Grid_LocalMesh.hpp:67
KOKKOS_INLINE_FUNCTION bool onHighBoundary(const int dim) const
Determine if this block is on a high boundary in the given dimension.
Definition Cabana_Grid_LocalMesh.hpp:138
Definition Cabana_Grid_LocalMesh.hpp:33
Core: particle data structures and algorithms.
Definition Cabana_AoSoA.hpp:36
Mesh cell tag.
Definition Cabana_Grid_Types.hpp:49
Mesh edge tag.
Definition Cabana_Grid_Types.hpp:95
Mesh face tag.
Definition Cabana_Grid_Types.hpp:64
Ghosted decomposition tag.
Definition Cabana_Grid_Types.hpp:197
Global index tag.
Definition Cabana_Grid_Types.hpp:215
Local index tag.
Definition Cabana_Grid_Types.hpp:208
Mesh node tag.
Definition Cabana_Grid_Types.hpp:56
Non-uniform mesh tag.
Definition Cabana_Grid_Types.hpp:240
Owned decomposition tag.
Definition Cabana_Grid_Types.hpp:190
Uniform mesh tag.
Definition Cabana_Grid_Types.hpp:227