@@ -55,10 +55,12 @@ struct MeshInfo {
5555 * @param meshInfoIn defines on-process mesh metadata
5656 * @param mixins object(s) needed to construct the Accessor
5757 */
58- template <typename MeshFieldType, typename Shape, typename ... Mixins>
58+ template <size_t numCompIn, typename MeshFieldType, typename Shape,
59+ typename ... Mixins>
5960struct ShapeField : public Mixins ... {
6061 MeshFieldType meshField;
6162 Shape shape;
63+ static const size_t numComp = numCompIn;
6264 const MeshInfo meshInfo;
6365 constexpr static auto Order = Shape::Order;
6466 ShapeField (MeshFieldType &meshFieldIn, const MeshInfo &meshInfoIn,
@@ -158,7 +160,7 @@ template <typename VtxAccessor> struct LinearAccessor {
158160template <typename ExecutionSpace,
159161 template <typename ...>
160162 typename Controller = MeshField::KokkosController,
161- typename DataType, size_t order, size_t dim>
163+ typename DataType, size_t order, size_t dim, size_t numComp >
162164auto CreateLagrangeField (const MeshInfo &meshInfo) {
163165 static_assert ((std::is_same_v<Real4, DataType> == true ||
164166 std::is_same_v<Real8, DataType> == true ),
@@ -179,10 +181,10 @@ auto CreateLagrangeField(const MeshInfo &meshInfo) {
179181 std::is_same_v<
180182 Controller<ExecutionSpace, MemorySpace, DataType>,
181183 MeshField::CabanaController<ExecutionSpace, MemorySpace, DataType>>,
182- Controller<ExecutionSpace, MemorySpace, DataType[1 ][1 ]>,
184+ Controller<ExecutionSpace, MemorySpace, DataType[1 ][numComp ]>,
183185 Controller<MemorySpace, ExecutionSpace, DataType ***>>;
184186 // 1 dof with 1 component per vtx
185- auto createController = [](const int numComp, auto numVtx) {
187+ auto createController = [](auto numVtx) {
186188 if constexpr (std::is_same_v<
187189 Controller<ExecutionSpace, MemorySpace, DataType>,
188190 MeshField::CabanaController<ExecutionSpace, MemorySpace,
@@ -192,14 +194,15 @@ auto CreateLagrangeField(const MeshInfo &meshInfo) {
192194 return Ctrlr ({/* field 0*/ numVtx, 1 , numComp});
193195 }
194196 };
195- Ctrlr kk_ctrl = createController (1 , meshInfo.numVtx );
197+ Ctrlr kk_ctrl = createController (meshInfo.numVtx );
196198#else
197199 using Ctrlr = Controller<MemorySpace, ExecutionSpace, DataType ***>;
198- Ctrlr kk_ctrl ({/* field 0*/ meshInfo.numVtx , 1 , 1 });
200+ Ctrlr kk_ctrl ({/* field 0*/ meshInfo.numVtx , 1 , numComp });
199201#endif
200202 auto vtxField = MeshField::makeField<Ctrlr, 0 >(kk_ctrl);
201203 using LA = LinearAccessor<decltype (vtxField)>;
202- using LinearLagrangeShapeField = ShapeField<Ctrlr, LinearTriangleShape, LA>;
204+ using LinearLagrangeShapeField =
205+ ShapeField<numComp, Ctrlr, LinearTriangleShape, LA>;
203206 LinearLagrangeShapeField llsf (kk_ctrl, meshInfo, {vtxField});
204207 return llsf;
205208 } else if constexpr (order == 2 && (dim == 2 || dim == 3 )) {
@@ -214,10 +217,11 @@ auto CreateLagrangeField(const MeshInfo &meshInfo) {
214217 std::is_same_v<
215218 Controller<ExecutionSpace, MemorySpace, DataType>,
216219 MeshField::CabanaController<ExecutionSpace, MemorySpace, DataType>>,
217- Controller<ExecutionSpace, MemorySpace, DataType[1 ][1 ], DataType[1 ][1 ]>,
220+ Controller<ExecutionSpace, MemorySpace, DataType[1 ][numComp],
221+ DataType[1 ][numComp]>,
218222 Controller<MemorySpace, ExecutionSpace, DataType ***, DataType ***>>;
219223 // 1 dof with 1 comp per vtx/edge
220- auto createController = [](const int numComp, auto numVtx, auto numEdge) {
224+ auto createController = [](auto numVtx, auto numEdge) {
221225 if constexpr (std::is_same_v<
222226 Controller<ExecutionSpace, MemorySpace, DataType>,
223227 MeshField::CabanaController<ExecutionSpace, MemorySpace,
@@ -228,18 +232,18 @@ auto CreateLagrangeField(const MeshInfo &meshInfo) {
228232 /* field 1*/ numEdge, 1 , numComp});
229233 }
230234 };
231- Ctrlr kk_ctrl = createController (1 , meshInfo.numVtx , meshInfo.numEdge );
235+ Ctrlr kk_ctrl = createController (meshInfo.numVtx , meshInfo.numEdge );
232236#else
233237 using Ctrlr =
234238 Controller<MemorySpace, ExecutionSpace, DataType ***, DataType ***>;
235- Ctrlr kk_ctrl ({/* field 0*/ meshInfo.numVtx , 1 , 1 ,
236- /* field 1*/ meshInfo.numEdge , 1 , 1 });
239+ Ctrlr kk_ctrl ({/* field 0*/ meshInfo.numVtx , 1 , numComp ,
240+ /* field 1*/ meshInfo.numEdge , 1 , numComp });
237241#endif
238242 auto vtxField = MeshField::makeField<Ctrlr, 0 >(kk_ctrl);
239243 auto edgeField = MeshField::makeField<Ctrlr, 1 >(kk_ctrl);
240244 using QA = QuadraticAccessor<decltype (vtxField), decltype (edgeField)>;
241245 using QuadraticLagrangeShapeField =
242- ShapeField<Ctrlr, QuadraticTriangleShape, QA>;
246+ ShapeField<numComp, Ctrlr, QuadraticTriangleShape, QA>;
243247 QuadraticLagrangeShapeField qlsf (kk_ctrl, meshInfo, {vtxField, edgeField});
244248 return qlsf;
245249 } else {
@@ -302,7 +306,8 @@ auto CreateCoordinateField(const MeshInfo &meshInfo) {
302306#endif
303307 auto vtxField = MeshField::makeField<Ctrlr, 0 >(kk_ctrl);
304308 using LA = LinearAccessor<decltype (vtxField)>;
305- using LinearLagrangeShapeField = ShapeField<Ctrlr, LinearTriangleShape, LA>;
309+ using LinearLagrangeShapeField =
310+ ShapeField<dim, Ctrlr, LinearTriangleShape, LA>;
306311 LinearLagrangeShapeField llsf (kk_ctrl, meshInfo, {vtxField});
307312 return llsf;
308313};
0 commit comments