Skip to content

Commit 794f0b4

Browse files
author
Kloepfer
committed
merged fix to oversized controller and changed Element to use baseType
2 parents 4579d52 + 9d52a80 commit 794f0b4

File tree

8 files changed

+50
-45
lines changed

8 files changed

+50
-45
lines changed

.github/workflows/pr_comment_trigger_self_hosted.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
echo "workDir $workDir"
5151
5252
# kokkos
53-
git clone -b develop git@github.com:kokkos/kokkos.git ${workDir}/kokkos
53+
git clone -b develop https://github.com/kokkos/kokkos.git ${workDir}/kokkos
5454
kkbdir=${workDir}/build-kokkos
5555
cmake -S ${workDir}/kokkos -B $kkbdir \
5656
-DCMAKE_BUILD_TYPE=Release \
@@ -66,7 +66,7 @@ jobs:
6666
cmake --build $kkbdir --target install -j 4
6767
6868
##cabana
69-
git clone git@github.com:ECP-copa/Cabana.git ${workDir}/cabana
69+
git clone https://github.com/ECP-copa/Cabana.git ${workDir}/cabana
7070
cabbdir=${workDir}/build-cab
7171
cmake -S ${workDir}/cabana -B $cabbdir \
7272
-DCMAKE_BUILD_TYPE="Release" \
@@ -81,7 +81,7 @@ jobs:
8181
cmake --build $cabbdir -j 4 --target install
8282
8383
# omegah
84-
git clone git@github.com:SCOREC/omega_h.git ${workDir}/omegah
84+
git clone https://github.com/SCOREC/omega_h.git ${workDir}/omegah
8585
ohbdir=${workDir}/build-omegah
8686
cmake -S ${workDir}/omegah -B $ohbdir \
8787
-DCMAKE_INSTALL_PREFIX=$ohbdir/install \

src/MeshField.hpp

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,17 @@ MeshField::MeshInfo getMeshInfo(Omega_h::Mesh &mesh) {
3232
return meshInfo;
3333
}
3434

35-
template <typename ExecutionSpace, template <typename...> typename Controller =
36-
MeshField::KokkosController>
37-
decltype(MeshField::CreateCoordinateField<ExecutionSpace, Controller>(
35+
template <typename ExecutionSpace, size_t dim,
36+
template <typename...>
37+
typename Controller = MeshField::KokkosController>
38+
decltype(MeshField::CreateCoordinateField<ExecutionSpace, Controller, dim>(
3839
MeshField::MeshInfo()))
3940
createCoordinateField(const MeshField::MeshInfo &mesh_info,
4041
Omega_h::Reals coords) {
4142
const auto meshDim = mesh_info.dim;
4243
auto coordField =
43-
MeshField::CreateCoordinateField<ExecutionSpace, Controller>(mesh_info);
44+
MeshField::CreateCoordinateField<ExecutionSpace, Controller, dim>(
45+
mesh_info);
4446
auto setCoordField = KOKKOS_LAMBDA(const int &i) {
4547
coordField(i, 0, 0, MeshField::Vertex) = coords[i * meshDim];
4648
coordField(i, 0, 1, MeshField::Vertex) = coords[i * meshDim + 1];
@@ -167,23 +169,27 @@ template <int ShapeOrder> auto getTriangleElement(Omega_h::Mesh &mesh) {
167169

168170
} // namespace Omegah
169171

170-
template <typename ExecutionSpace, template <typename...> typename Controller =
171-
MeshField::KokkosController>
172+
template <typename ExecutionSpace, size_t dim,
173+
template <typename...> typename Controller =
174+
MeshField::KokkosController>
172175
class OmegahMeshField {
173176
private:
174177
Omega_h::Mesh &mesh;
175178
const MeshField::MeshInfo meshInfo;
176-
using CoordField = decltype(createCoordinateField<ExecutionSpace, Controller>(
177-
MeshField::MeshInfo(), Omega_h::Reals()));
179+
using CoordField =
180+
decltype(createCoordinateField<ExecutionSpace, dim, Controller>(
181+
MeshField::MeshInfo(), Omega_h::Reals()));
178182
CoordField coordField;
179183

180184
public:
181185
OmegahMeshField(Omega_h::Mesh &mesh_in)
182186
: mesh(mesh_in), meshInfo(getMeshInfo(mesh)),
183-
coordField(createCoordinateField<ExecutionSpace, Controller>(
184-
getMeshInfo(mesh_in), mesh_in.coords())) {}
187+
coordField(createCoordinateField<ExecutionSpace, dim, Controller>(
188+
getMeshInfo(mesh_in), mesh_in.coords())) {
189+
static_assert(dim == 1 || dim == 2 || dim == 3);
190+
}
185191

186-
template <typename DataType, size_t order, size_t dim>
192+
template <typename DataType, size_t order>
187193
// Ordering of field indexing changed to 'entity, node, component'
188194
auto CreateLagrangeField() {
189195
return MeshField::CreateLagrangeField<ExecutionSpace, Controller, DataType,

src/MeshField_Element.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,9 @@ struct FieldElement {
188188
return c;
189189
}
190190

191-
using NodeArray = Kokkos::Array<typename FieldAccessor::BaseType,
192-
ShapeType::meshEntDim * ShapeType::numNodes>;
191+
using NodeArray =
192+
Kokkos::Array<typename baseType<typename FieldAccessor::BaseType>::type,
193+
ShapeType::meshEntDim * ShapeType::numNodes>;
193194
KOKKOS_INLINE_FUNCTION NodeArray getNodeValues(int ent) const {
194195
NodeArray c;
195196
for (auto topo : elm2dof.getTopology()) { // element topology

src/MeshField_ShapeField.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,22 +267,23 @@ auto CreateLagrangeField(const MeshInfo &meshInfo) {
267267
* @return a linear ShapeField
268268
*/
269269

270-
template <typename ExecutionSpace, template <typename...> typename Controller =
271-
MeshField::KokkosController>
270+
template <typename ExecutionSpace,
271+
template <typename...>
272+
typename Controller = MeshField::KokkosController,
273+
size_t dim>
272274
auto CreateCoordinateField(const MeshInfo &meshInfo) {
273275
if (meshInfo.numVtx <= 0) {
274276
fail("mesh has no vertices\n");
275277
}
276278
using DataType = Real;
277279
using MemorySpace = typename ExecutionSpace::memory_space;
278280
const int numComp = meshInfo.dim;
279-
// FIXME Oversized cabana datatypes when numComp = 1|2, specialize controller template for dimension? //HERE
280281
#ifdef MESHFIELDS_ENABLE_CABANA
281282
using Ctrlr = std::conditional_t<
282283
std::is_same_v<
283284
Controller<ExecutionSpace, MemorySpace, DataType>,
284285
MeshField::CabanaController<ExecutionSpace, MemorySpace, DataType>>,
285-
Controller<ExecutionSpace, MemorySpace, DataType[1][3]>,
286+
Controller<ExecutionSpace, MemorySpace, DataType[1][dim]>,
286287
Controller<MemorySpace, ExecutionSpace, DataType ***>>;
287288
auto createController = [](const int numComp, auto numVtx) {
288289
if constexpr (std::is_same_v<

test/testCountIntegrator.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class CountIntegrator : public MeshField::Integrator {
5959

6060
template <template <typename...> typename Controller>
6161
void doRun(Omega_h::Mesh &mesh,
62-
MeshField::OmegahMeshField<ExecutionSpace, Controller> &omf) {
62+
MeshField::OmegahMeshField<ExecutionSpace, 2, Controller> &omf) {
6363
const auto ShapeOrder = 1;
6464
auto field = omf.getCoordField();
6565
const auto [shp, map] =
@@ -77,14 +77,14 @@ int main(int argc, char **argv) {
7777
auto mesh = createMeshTri18(lib);
7878
#ifdef MESHFIELDS_ENABLE_CABANA
7979
{
80-
MeshField::OmegahMeshField<ExecutionSpace, MeshField::CabanaController> omf(
81-
mesh);
80+
MeshField::OmegahMeshField<ExecutionSpace, 2, MeshField::CabanaController>
81+
omf(mesh);
8282
doRun<MeshField::CabanaController>(mesh, omf);
8383
}
8484
#endif
8585
{
86-
MeshField::OmegahMeshField<ExecutionSpace, MeshField::KokkosController> omf(
87-
mesh);
86+
MeshField::OmegahMeshField<ExecutionSpace, 2, MeshField::KokkosController>
87+
omf(mesh);
8888
doRun<MeshField::KokkosController>(mesh, omf);
8989
}
9090
return 0;

test/testElementJacobian1d.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,8 @@ void setEdgeCoords(size_t numVerts, Kokkos::View<MeshField::Real *> coords,
4444

4545
void edgeJacobian() {
4646
const MeshField::MeshInfo meshInfo{.numVtx = 2, .numEdge = 1, .dim = 1};
47-
auto coordField =
48-
MeshField::CreateCoordinateField<ExecutionSpace,
49-
MeshField::KokkosController>(meshInfo);
47+
auto coordField = MeshField::CreateCoordinateField<
48+
ExecutionSpace, MeshField::KokkosController, 1>(meshInfo);
5049
Kokkos::View<MeshField::Real *, Kokkos::HostSpace> coords_h("coords_h", 2);
5150
coords_h[0] = -1;
5251
coords_h[1] = 1;

test/testElementJacobian2d.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,8 @@ void setVtxCoords(size_t numVerts, size_t meshDim, TriangleTestCase testTri,
7272
void triJacobian() {
7373
const MeshField::MeshInfo meshInfo{
7474
.numVtx = 3, .numEdge = 3, .numTri = 1, .dim = 2};
75-
auto coordField =
76-
MeshField::CreateCoordinateField<ExecutionSpace,
77-
MeshField::KokkosController>(meshInfo);
78-
75+
auto coordField = MeshField::CreateCoordinateField<
76+
ExecutionSpace, MeshField::KokkosController, 2>(meshInfo);
7977
TriangleTestCase rightTriangle({0, 0, 1, 0, 0, 1}, {1, 0, 0, 1}, 1);
8078
TriangleTestCase skewedTriangle({0, 0, 5, 1, 3, 4}, {5, 1, 3, 4}, 17);
8179
for (auto testCase : {rightTriangle, skewedTriangle}) {

test/testOmegahElement.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ void doFail(std::string_view order, std::string_view function,
143143

144144
template <template <typename...> typename Controller>
145145
void doRun(Omega_h::Mesh &mesh,
146-
MeshField::OmegahMeshField<ExecutionSpace, Controller> &omf) {
146+
MeshField::OmegahMeshField<ExecutionSpace, 2, Controller> &omf) {
147147

148148
// setup field with values from the analytic function
149149
static const size_t OnePtPerElem = 1;
@@ -166,14 +166,14 @@ void doRun(Omega_h::Mesh &mesh,
166166
// clang-format on
167167

168168
auto coords = mesh.coords();
169-
const auto MeshDim = 2;
170169
for (auto testCase : cases) {
171170
using ViewType = decltype(testCase.coords);
172171
{
173172
const auto ShapeOrder = 1;
174-
auto field = omf.template CreateLagrangeField<MeshField::Real, ShapeOrder,
175-
MeshDim>();
176-
auto func = LinearFunction();
173+
174+
auto field =
175+
omf.template CreateLagrangeField<MeshField::Real, ShapeOrder>();
176+
LinearFunction func = LinearFunction();
177177
setVertices(mesh, func, field);
178178
using FieldType = decltype(field);
179179
auto result = omf.template triangleLocalPointEval<ViewType, FieldType>(
@@ -186,8 +186,8 @@ void doRun(Omega_h::Mesh &mesh,
186186

187187
{
188188
const auto ShapeOrder = 2;
189-
auto field = omf.template CreateLagrangeField<MeshField::Real, ShapeOrder,
190-
MeshDim>();
189+
auto field =
190+
omf.template CreateLagrangeField<MeshField::Real, ShapeOrder>();
191191
auto func = QuadraticFunction();
192192
setVertices(mesh, func, field);
193193
setEdges(mesh, func, field);
@@ -202,8 +202,8 @@ void doRun(Omega_h::Mesh &mesh,
202202

203203
{
204204
const auto ShapeOrder = 2;
205-
auto field = omf.template CreateLagrangeField<MeshField::Real, ShapeOrder,
206-
MeshDim>();
205+
auto field =
206+
omf.template CreateLagrangeField<MeshField::Real, ShapeOrder>();
207207
auto func = LinearFunction();
208208
setVertices(mesh, func, field);
209209
setEdges(mesh, func, field);
@@ -225,15 +225,15 @@ int main(int argc, char **argv) {
225225
#ifdef MESHFIELDS_ENABLE_CABANA
226226
{
227227
auto mesh = createMeshTri18(lib);
228-
MeshField::OmegahMeshField<ExecutionSpace, MeshField::CabanaController> omf(
229-
mesh);
228+
MeshField::OmegahMeshField<ExecutionSpace, 2, MeshField::CabanaController>
229+
omf(mesh);
230230
doRun<MeshField::CabanaController>(mesh, omf);
231231
}
232232
#endif
233233
{
234234
auto mesh = createMeshTri18(lib);
235-
MeshField::OmegahMeshField<ExecutionSpace, MeshField::KokkosController> omf(
236-
mesh);
235+
MeshField::OmegahMeshField<ExecutionSpace, 2, MeshField::KokkosController>
236+
omf(mesh);
237237
doRun<MeshField::KokkosController>(mesh, omf);
238238
}
239239
Kokkos::finalize();

0 commit comments

Comments
 (0)