Skip to content

Commit

Permalink
support cab controller WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
cwsmith committed Sep 27, 2024
1 parent e118072 commit 141e212
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
10 changes: 8 additions & 2 deletions src/MeshField_ShapeField.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define MESHFIELD_SHAPEFIELD_HPP

#include "KokkosController.hpp"
#include "CabanaController.hpp"
#include "MeshField.hpp"
#include "MeshField_Shape.hpp"
#include <type_traits> //decltype
Expand Down Expand Up @@ -65,7 +66,7 @@ template <typename VtxAccessor> struct LinearAccessor {
}
};

template <typename ExecutionSpace, typename DataType, size_t order, size_t dim>
template <typename ExecutionSpace, class CtrlrType, typename DataType, size_t order, size_t dim>
auto CreateLagrangeField(MeshInfo &meshInfo) {
static_assert((std::is_same_v<Real4, DataType> == true ||
std::is_same_v<Real8, DataType> == true),
Expand All @@ -74,13 +75,18 @@ auto CreateLagrangeField(MeshInfo &meshInfo) {
static_assert(
(order == 1 || order == 2),
"CreateLagrangeField only supports linear and quadratic fields\n");
// https://godbolt.org/z/b8TEG8M8E - static_assert for templated type
static_assert(
( std::is_same_v<CtrlrType,Controller::KokkosController> ||
std::is_same_v<CtrlrType,Controller::CabanaController> ),
"CreateLagrangeField only supports field storage using Kokkos or Cabana\n");
static_assert((dim == 1 || dim == 2 || dim == 3),
"CreateLagrangeField only supports 1d, 2d, and 3d meshes\n");
using MemorySpace = typename ExecutionSpace::memory_space;
if constexpr (order == 1 && (dim == 1 || dim == 2)) {
assert(meshInfo.numVtx > 0);
using Ctrlr =
Controller::KokkosController<MemorySpace, ExecutionSpace, DataType ***>;
CtrlrType<MemorySpace, ExecutionSpace, DataType ***>;
// 1 dof with 1 component per vtx
Ctrlr kk_ctrl({/*field 0*/ 1, 1, meshInfo.numVtx});
MeshField<Ctrlr> kokkosMeshField(kk_ctrl);
Expand Down
16 changes: 8 additions & 8 deletions test/testElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ void triangleLocalPointEval() {
meshInfo.numVtx = 5;
meshInfo.numTri = 3;
auto field =
MeshField::CreateLagrangeField<ExecutionSpace, MeshField::Real, 1, 2>(
meshInfo);
MeshField::CreateLagrangeField<ExecutionSpace,
Controller::KokkosController, MeshField::Real, 1, 2>(meshInfo);

MeshField::Element elm{MeshField::LinearTriangleShape(),
LinearTriangleToVertexField()};
Expand Down Expand Up @@ -84,8 +84,8 @@ void edgeLocalPointEval() {
meshInfo.numVtx = 5;
meshInfo.numEdge = 7;
auto field =
MeshField::CreateLagrangeField<ExecutionSpace, MeshField::Real, 1, 1>(
meshInfo);
MeshField::CreateLagrangeField<ExecutionSpace,
Controller::KokkosController, MeshField::Real, 1, 1>(meshInfo);

MeshField::Element elm{MeshField::LinearEdgeShape(),
LinearEdgeToVertexField()};
Expand Down Expand Up @@ -136,8 +136,8 @@ void quadraticTriangleLocalPointEval() {
meshInfo.numEdge = 3;
meshInfo.numTri = 1;
auto field =
MeshField::CreateLagrangeField<ExecutionSpace, MeshField::Real, 2, 2>(
meshInfo);
MeshField::CreateLagrangeField<ExecutionSpace,
Controller::KokkosController, MeshField::Real, 2, 2>(meshInfo);

MeshField::Element elm{MeshField::QuadraticTriangleShape(),
QuadraticTriangleToField()};
Expand Down Expand Up @@ -188,8 +188,8 @@ void quadraticTetrahedronLocalPointEval() {
meshInfo.numTri = 4;
meshInfo.numTet = 1;
auto field =
MeshField::CreateLagrangeField<ExecutionSpace, MeshField::Real, 2, 3>(
meshInfo);
MeshField::CreateLagrangeField<ExecutionSpace,
Controller::KokkosController, MeshField::Real, 2, 3>(meshInfo);

MeshField::Element elm{MeshField::QuadraticTetrahedronShape(),
QuadraticTetrahedronToField()};
Expand Down

0 comments on commit 141e212

Please sign in to comment.