Nalu
Nalu: a generalized unstructured massively parallel low Mach flow code designed to support a variety of energy applications of interest (most notably Wind ECP) built on the Sierra Toolkit and Trilinos solver Tpetra/Epetra stack. The open source BSD, clause 3 license model has been chosen for the code base. See LICENSE for more information. http://NaluCFD.org
Kernel.h
Go to the documentation of this file.
1 /*------------------------------------------------------------------------*/
2 /* Copyright 2014 National Renewable Energy Laboratory. */
3 /* This software is released under the license detailed */
4 /* in the file, LICENSE, which is located in the top-level Nalu */
5 /* directory structure */
6 /*------------------------------------------------------------------------*/
7 
8 #ifndef KERNEL_H
9 #define KERNEL_H
10 
11 #include "KokkosInterface.h"
12 #include "SimdInterface.h"
13 #include "ScratchViews.h"
14 #include "AlgTraits.h"
15 
16 #include <stk_mesh/base/Entity.hpp>
17 
18 #include <array>
19 
20 namespace sierra {
21 namespace nalu {
22 
23 class TimeIntegrator;
24 class SolutionOptions;
25 
26 template<typename AlgTraits, typename LambdaFunction, typename ViewType>
27 void get_scv_shape_fn_data(LambdaFunction lambdaFunction, ViewType& shape_fn_view)
28 {
29  static_assert(ViewType::Rank == 2u, "2D View");
30  ThrowRequireMsg(shape_fn_view.extent_int(0) == AlgTraits::numScvIp_, "Inconsistent number of scv ips");
31  ThrowRequireMsg(shape_fn_view.extent_int(1) == AlgTraits::nodesPerElement_, "Inconsistent number of of nodes");
32 
33  double tmp_data[AlgTraits::numScvIp_*AlgTraits::nodesPerElement_];
34  lambdaFunction(tmp_data);
35 
36  DoubleType* data = &shape_fn_view(0,0);
37  for(int i=0; i<AlgTraits::numScvIp_*AlgTraits::nodesPerElement_; ++i) {
38  data[i] = tmp_data[i];
39  }
40 }
41 
42 template<typename AlgTraits, typename LambdaFunction, typename ViewType>
43 void get_scs_shape_fn_data(LambdaFunction lambdaFunction, ViewType& shape_fn_view)
44 {
45  static_assert(ViewType::Rank == 2u, "2D View");
46  ThrowRequireMsg(shape_fn_view.extent_int(0) == AlgTraits::numScsIp_, "Inconsistent number of scs ips");
47  ThrowRequireMsg(shape_fn_view.extent_int(1) == AlgTraits::nodesPerElement_, "Inconsistent number of of nodes");
48 
49  double tmp_data[AlgTraits::numScsIp_*AlgTraits::nodesPerElement_];
50  lambdaFunction(tmp_data);
51 
52  DoubleType* data = &shape_fn_view(0,0);
53  for(int i=0; i<AlgTraits::numScsIp_*AlgTraits::nodesPerElement_; ++i) {
54  data[i] = tmp_data[i];
55  }
56 }
57 
63 class Kernel
64 {
65 public:
66  Kernel() = default;
67 
68  virtual ~Kernel() {}
69 
72  virtual void setup(const TimeIntegrator&) {}
73 
77  virtual void execute(
81  {}
82 };
83 
84 } // nalu
85 } // sierra
86 
87 #endif /* KERNEL_H */
Definition: TimeIntegrator.h:26
Definition: ABLForcingAlgorithm.C:26
void get_scv_shape_fn_data(LambdaFunction lambdaFunction, ViewType &shape_fn_view)
Definition: Kernel.h:27
STK SIMD Interface.
virtual void setup(const TimeIntegrator &)
Perform pre-timestep work for the computational kernel.
Definition: Kernel.h:72
void get_scs_shape_fn_data(LambdaFunction lambdaFunction, ViewType &shape_fn_view)
Definition: Kernel.h:43
SimdDouble DoubleType
Definition: SimdInterface.h:27
Base class for computational kernels in Nalu.
Definition: Kernel.h:63
virtual void execute(SharedMemView< DoubleType ** > &, SharedMemView< DoubleType * > &, ScratchViews< DoubleType > &)
Execute the kernel within a Kokkos loop and populate the LHS and RHS for the linear solve...
Definition: Kernel.h:77
Kokkos::View< T, Kokkos::LayoutRight, DeviceShmem, Kokkos::MemoryUnmanaged > SharedMemView
Definition: KokkosInterface.h:25
virtual ~Kernel()
Definition: Kernel.h:68
Definition: ScratchViews.h:82