-
Notifications
You must be signed in to change notification settings - Fork 6
Jk/linear tet #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jk/linear tet #65
Conversation
|
/runtests |
|
|
||
| template <typename ViewType, typename ShapeField> | ||
| auto tetrahedronLocalPointEval(ViewType localCoords, size_t NumPtsPerElem, | ||
| ShapeField field) { |
Check notice
Code scanning / CodeQL
Large object passed by value Note
ShapeField<1UL, KokkosController<HostSpace, Serial, double ***>, LinearTetrahedronShape, LinearAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>>
This parameter of type
ShapeField<1UL, KokkosController<HostSpace, Serial, double ***, double ***>, QuadraticTetrahedronShape, QuadraticAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>, Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>>
This parameter of type ShapeField<2UL, KokkosController<HostSpace, Serial, double ***>, LinearTetrahedronShape, LinearAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>> is 200 bytes - consider passing a const pointer/reference instead.
This parameter of type ShapeField<3UL, KokkosController<HostSpace, Serial, double ***>, LinearTetrahedronShape, LinearAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>> is 200 bytes - consider passing a const pointer/reference instead.
This parameter of type ShapeField<2UL, KokkosController<HostSpace, Serial, double ***, double ***>, QuadraticTetrahedronShape, QuadraticAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>, Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>> is 344 bytes - consider passing a const pointer/reference instead.
This parameter of type ShapeField<3UL, KokkosController<HostSpace, Serial, double ***, double ***>, QuadraticTetrahedronShape, QuadraticAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>, Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>> is 344 bytes - consider passing a const pointer/reference instead.
This parameter of type ShapeField<1UL, KokkosController<HostSpace, Serial, double ***>, LinearTriangleShape, LinearAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>> is 200 bytes - consider passing a const pointer/reference instead.
This parameter of type ShapeField<1UL, KokkosController<HostSpace, Serial, double ***, double ***>, QuadraticTriangleShape, QuadraticAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>, Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>> is 344 bytes - consider passing a const pointer/reference instead.
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the problem, we should change the parameter type of field in the function tetrahedronLocalPointEval (lines 359–364) from being passed by value to being passed by const reference. This means changing the function signature from ShapeField field to const ShapeField& field. This change should be made in both the declaration and the definition of the function template. Since the function is a template, this change will not affect its usage elsewhere, as template argument deduction will still work. No other code changes are needed unless there are other overloads or calls that rely on the value semantics, but from the provided snippet, this is not the case.
-
Copy modified line R360
| @@ -359,3 +359,3 @@ | ||
| auto tetrahedronLocalPointEval(ViewType localCoords, size_t NumPtsPerElem, | ||
| ShapeField field) { | ||
| const ShapeField& field) { | ||
| auto offsets = createOffsets(meshInfo.numTet, NumPtsPerElem); |
|
|
||
| template <typename ViewType, typename ShapeField> | ||
| auto tetrahedronLocalPointEval(ViewType localCoords, | ||
| Kokkos::View<LO *> offsets, ShapeField field) { |
Check notice
Code scanning / CodeQL
Large object passed by value Note
ShapeField<3UL, KokkosController<HostSpace, Serial, double ***, double ***>, QuadraticTetrahedronShape, QuadraticAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>, Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>>
This parameter of type
ShapeField<2UL, KokkosController<HostSpace, Serial, double ***, double ***>, QuadraticTetrahedronShape, QuadraticAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>, Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>>
This parameter of type ShapeField<3UL, KokkosController<HostSpace, Serial, double ***>, LinearTetrahedronShape, LinearAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>> is 200 bytes - consider passing a const pointer/reference instead.
This parameter of type ShapeField<2UL, KokkosController<HostSpace, Serial, double ***>, LinearTetrahedronShape, LinearAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>> is 200 bytes - consider passing a const pointer/reference instead.
This parameter of type ShapeField<1UL, KokkosController<HostSpace, Serial, double ***, double ***>, QuadraticTetrahedronShape, QuadraticAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>, Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>> is 344 bytes - consider passing a const pointer/reference instead.
This parameter of type ShapeField<1UL, KokkosController<HostSpace, Serial, double ***>, LinearTetrahedronShape, LinearAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>> is 200 bytes - consider passing a const pointer/reference instead.
This parameter of type ShapeField<1UL, KokkosController<HostSpace, Serial, double ***, double ***>, QuadraticTriangleShape, QuadraticAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>, Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>> is 344 bytes - consider passing a const pointer/reference instead.
This parameter of type ShapeField<1UL, KokkosController<HostSpace, Serial, double ***>, LinearTriangleShape, LinearAccessor<Field<KokkosSliceWrapper<View<double ***, HostSpace>, double ***>>>> is 200 bytes - consider passing a const pointer/reference instead.
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the problem, we should change the field parameter in the relevant function templates from being passed by value to being passed by const reference. This means changing the parameter type from ShapeField field to const ShapeField& field in both overloads of tetrahedronLocalPointEval (lines 359 and 368). This change should be made in the function declarations and definitions within the shown code. No additional imports or definitions are needed, as this is standard C++ practice.
-
Copy modified line R360 -
Copy modified line R368
| @@ -359,3 +359,3 @@ | ||
| auto tetrahedronLocalPointEval(ViewType localCoords, size_t NumPtsPerElem, | ||
| ShapeField field) { | ||
| const ShapeField& field) { | ||
| auto offsets = createOffsets(meshInfo.numTet, NumPtsPerElem); | ||
| @@ -367,3 +367,3 @@ | ||
| auto tetrahedronLocalPointEval(ViewType localCoords, | ||
| Kokkos::View<LO *> offsets, ShapeField field) { | ||
| Kokkos::View<LO *> offsets, const ShapeField& field) { | ||
| const auto MeshDim = 3; |
|
Test Result: success (details) |
… to mfem ordering on quadratic tet
cwsmith
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thank you.
One small change is requested below for the name of the new test file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should rename this to testOmegahTet.cpp. In a subsequent PR/commit we can rename testOmegahElement.cpp to testOmegahTri.cpp for consistency.
Likewise, in another PR we should add tests for multiple components and the cabana backend.
| #include <MeshField.hpp> | ||
| #include <Omega_h_build.hpp> | ||
| #include <Omega_h_mesh.hpp> | ||
| template <size_t order> void runTest(Omega_h::Mesh mesh) { |
Check warning
Code scanning / CodeQL
Poorly documented large function Warning test
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix
AI 5 months ago
To fix the problem, we should add comments to the runTest function to document its purpose, parameters, and the main steps of its logic. This includes a function-level comment explaining what the function does, what its template parameter and arguments mean, and inline comments throughout the function to clarify non-obvious code sections. The changes should be made directly above and within the runTest function in test/testOmegahTet.cpp, without altering the function's logic or behavior.
-
Copy modified lines R5-R15 -
Copy modified line R17 -
Copy modified line R19 -
Copy modified line R22 -
Copy modified line R25 -
Copy modified line R29 -
Copy modified line R32 -
Copy modified line R40 -
Copy modified line R46 -
Copy modified line R55 -
Copy modified line R57 -
Copy modified line R59 -
Copy modified line R89 -
Copy modified line R94 -
Copy modified line R97
| @@ -4,8 +4,23 @@ | ||
| #include <Omega_h_mesh.hpp> | ||
| /** | ||
| * @brief Runs a test of Lagrange field interpolation and evaluation on a given mesh. | ||
| * | ||
| * This function creates a Lagrange field of the specified order on the input mesh, | ||
| * assigns values to the field at mesh vertices (and edges for quadratic order), | ||
| * evaluates the field at local points within each element, and checks the accuracy | ||
| * of the mapping between local and global coordinates. | ||
| * | ||
| * @tparam order The order of the Lagrange field (1 for linear, 2 for quadratic). | ||
| * @param mesh The Omega_h mesh on which to run the test. | ||
| */ | ||
| template <size_t order> void runTest(Omega_h::Mesh mesh) { | ||
| // Create a mesh field object for the given mesh. | ||
| MeshField::OmegahMeshField<Kokkos::DefaultExecutionSpace, 3> mesh_field(mesh); | ||
| // Create a Lagrange field of the specified order and scalar type. | ||
| auto shape_field = | ||
| mesh_field.template CreateLagrangeField<double, order, 1>(); | ||
| // Get mesh dimension and coordinates array. | ||
| auto dim = mesh.dim(); | ||
| auto coords = mesh.coords(); | ||
| // Define a test function to assign to the field: f(x, y, z) = 2x + 3y + 4z. | ||
| auto f = KOKKOS_LAMBDA(double x, double y, double z)->double { | ||
| @@ -13,4 +28,6 @@ | ||
| }; | ||
| // Get edge-to-vertex and element-to-edge connectivity. | ||
| auto edge2vtx = mesh.ask_down(1, 0).ab2b; | ||
| auto edgeMap = mesh.ask_down(dim, 1).ab2b; | ||
| // Assign field values at mesh vertices using the test function. | ||
| Kokkos::parallel_for( | ||
| @@ -22,2 +39,3 @@ | ||
| }); | ||
| // For quadratic (order 2) fields, assign values at edge midpoints. | ||
| if (order == 2) { | ||
| @@ -27,2 +45,3 @@ | ||
| const auto right = edge2vtx[edge * 2 + 1]; | ||
| // Compute midpoint coordinates of the edge. | ||
| const auto x = (coords[left * dim] + coords[right * dim]) / 2.0; | ||
| @@ -35,4 +54,7 @@ | ||
| } | ||
| // Set the number of nodes per element based on the field order. | ||
| const auto numNodesPerElem = order == 2 ? 10 : 4; | ||
| // Allocate a Kokkos view for local coordinates in each element. | ||
| Kokkos::View<double **> local_coords("", mesh.nelems() * numNodesPerElem, 4); | ||
| // Set local coordinates for each node in each element. | ||
| Kokkos::parallel_for( | ||
| @@ -66,2 +88,3 @@ | ||
| }); | ||
| // Evaluate the field at the specified local coordinates in each element. | ||
| auto eval_results = mesh_field.tetrahedronLocalPointEval( | ||
| @@ -70,4 +93,6 @@ | ||
| int errors = 0; | ||
| // Get element-to-vertex connectivity and the coordinate field. | ||
| const auto tetVerts = mesh.ask_elem_verts(); | ||
| const auto coordField = mesh_field.getCoordField(); | ||
| // Check that the mapping from local to global coordinates is accurate. | ||
| Kokkos::parallel_reduce( | ||
| @@ -121,5 +146,2 @@ | ||
| errors); | ||
| if (errors > 0) { | ||
| MeshField::fail("One or more mappings did not match\n"); | ||
| } | ||
| } |
cwsmith
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Added quadratic and linear tet as shape functions.