Skip to content

Simplified fields - #180

Merged
jacobmerson merged 46 commits into
SCOREC:developfrom
joyal-mathew:simplified-fields
Oct 27, 2025
Merged

jacobmerson merged 46 commits into
SCOREC:developfrom
joyal-mathew:simplified-fields

Conversation

@joyal-mathew

Copy link
Copy Markdown
Contributor

This PR introduces the new simplified field interface.

@joyal-mathew
joyal-mathew marked this pull request as ready for review August 16, 2025 03:42
@jacobmerson
jacobmerson self-requested a review August 19, 2025 18:27
@jacobmerson

Copy link
Copy Markdown
Collaborator

I'm working through some issues with this pull request. Progress can be found here: https://github.com/jacobmerson/pcms/tree/simplified-field-cleanup


auto coords = mesh_.coords();

size_t offset = 0;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should somehow be getting this information from MeshFIelds.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread test/test_field_communication.cpp Outdated
auto channel =
rdv.CreateAdiosChannel("field2_chan1", params, redev::TransportType::BP4);

auto layout = pcms::OmegaHFieldLayout(mesh, layout_arr, 1);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the way we handle the field definition and layout is close, but not quite right. I expect we want a factory function that will create the field layout where the user would request for example a certain order field, or an integration point based field.

Some basic pseudo code with current thoughts, but we will probably want to iterate on this.

auto layout = CreateLagrangeLayout(mesh, order,  num_components, coordinate_system);
auto layout2 = CreateLagrangeIntegrationPointLayout(mesh, order,  num_components, coordinate_system);
auto layout3 = CreatePointCloudLayout(coordinates);

auto data = View(layout.GetNumOwnedDOFHolders());

// factory function can determine the appropriate field type based on the layout
auto field = CreateField(data, layout);

auto field2 = CreateField(layout2);
// helper to set field with a function. 
field2.SetDofHolders([&](coords){foo(coords);}

auto data3 = View(layout3.GetNumOwnedDOFHolders());
auto field3 = CreateField(layout3);
field3.SetDofHolders(data3);

Note that the fields adapter no longer needs a name. The reason that OmegaHFieldAdapter had a name is because it used that to access the backend tag storage.

- Handle dof holder data using Rank1View
- Make CreateField a method of FieldLayout
@jacobmerson

Copy link
Copy Markdown
Collaborator

@joyal-mathew Can you resolve the conflicts?

@joyal-mathew

Copy link
Copy Markdown
Contributor Author

Yes, I'll resolve these conflicts today.

@jacobmerson

Copy link
Copy Markdown
Collaborator

Thanks! @Sichao25 added modules on the SCOREC systems for clang-tidy and cmake-format

@joyal-mathew

Copy link
Copy Markdown
Contributor Author

It seems like there are some false positives from clang-tidy. It complains about these two cases being the same (error: switch has 2 consecutive identical branches):

pcms/src/pcms/adapter/omega_h/omega_h_field2.cpp:131

      switch (mesh_.dim()) {
        case 1:
          mesh_field_ = std::make_unique<MeshFieldBackendImpl<1, 1>>(mesh_);
          break;
        case 2:
          mesh_field_ = std::make_unique<MeshFieldBackendImpl<2, 1>>(mesh_);
          break;
      }

I think it may be getting confused by the template.

@Sichao25 Sichao25 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few minor questions and suggestions for consideration.

Omega_h::Mesh& mesh_;
std::unique_ptr<MeshFieldBackend> mesh_field_;
GridPointSearch search_;
Kokkos::View<Real*> dof_holder_data_;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that some Views are explicitly specified with HostMemorySpace while others are not. Looks like some features are intended to run on CPU only. Would it be helpful to ensure consistent memory space annotations?

owned_("", coords.extent(0)),
gids_("", coords.extent(0))
{
compoents_ = 1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is "compoents" intentional, or a typo?

Comment thread src/pcms/field_layout_communicator.h Outdated
GlobalIDView<HostMemorySpace> received_gids(
received_msg.data_handle() + offset + 5, length);

PCMS_ALWAYS_ASSERT(offset + 5 + length - 1 < received_msg.size());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value 5 appears multiple times throughout the code. Would it be helpful to extract this into a named constant?

CoordinateView<HostMemorySpace> coordinate_view) const override;

void Evaluate(LocalizationHint location,
FieldDataView<double, HostMemorySpace> results) const override;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would Real be preferred over double?

ts::ClassificationPartition cp;
std::map<redev::ClassPtn::ModelEnt, int> ent_to_rank;

for (int e = 0; e <= 0; ++e) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this mean that this block will only trigger once. If so,could this be simplified?

@jacobmerson
jacobmerson requested a review from Copilot October 3, 2025 15:30

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a new simplified field interface for PCMS, providing a more streamlined API for field operations and data management. The changes include new field abstractions, layout classes, and communication utilities to improve the handling of field data across different computational meshes.

  • Introduces new field interface classes (FieldT, FieldLayout, FieldDataView) with simplified APIs
  • Adds communication support for fields with layout-aware serialization/deserialization
  • Implements concrete field types for Omega_h meshes and point clouds with evaluation capabilities

Reviewed Changes

Copilot reviewed 38 out of 39 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
test/test_spline_interpolator.cpp Updates Kokkos extents syntax for consistency
test/test_field_*.cpp New test files for field evaluation, interpolation, copying, and communication
test/CMakeLists.txt Adds test configurations for new field functionality
src/pcms/field.h Core field interface definitions and data view classes
src/pcms/field_layout.h Abstract field layout interface for DOF management
src/pcms/transfer_field2.h Field transfer operations (copy and interpolate)
src/pcms/create_field.cpp Factory functions for creating Lagrange field layouts
src/pcms/coordinate_system.h Coordinate system abstractions and transformations
src/pcms/adapter/omega_h/ Omega_h-specific field implementations
src/pcms/adapter/point_cloud/ Point cloud field implementations
src/pcms/field_communicator.h Communication utilities for distributed field operations
Comments suppressed due to low confidence (2)

src/pcms/interpolator/adj_search.hpp:1

  • Removed unused variable nvertices_source which improves code clarity by eliminating dead code.
#ifndef ADJ_SEARCH_HPP

src/pcms/interpolator/adj_search.hpp:1

  • Removed unused variable nvertices_source which improves code clarity by eliminating dead code.
#ifndef ADJ_SEARCH_HPP

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


private:
int dim_;
int compoents_;

Copilot AI Oct 3, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'compoents_' to 'components_'.

Suggested change
int compoents_;
int components_;

Copilot uses AI. Check for mistakes.
@jacobmerson

Copy link
Copy Markdown
Collaborator

@joyal-mathew it looks like github actions is using the actions from this pull request. If you merge develop and push the updated CI from #206 should hopefully resolve the build issues.

@jacobmerson

Copy link
Copy Markdown
Collaborator

It looks like the integration of MeshFields in the cmake workflow is still not quite right. One good thing is that it looks like the workflow can be updated in this PR and doesn't need to be merged through from main.

@joyal-mathew

Copy link
Copy Markdown
Contributor Author

Yea, I'll get that fixed on this branch.

@jacobmerson

Copy link
Copy Markdown
Collaborator

0001-update-meshfields-workflow.patch

@joyal-mathew Can you give this patch a try?

@jacobmerson

Copy link
Copy Markdown
Collaborator

Looks like some minor clang-tidy issues, but the build/tests are back to passing.

@jacobmerson
jacobmerson merged commit 0711fbf into SCOREC:develop Oct 27, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants