Skip to content

NURBS surface interpolation minapp #4841

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

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

NURBS surface interpolation minapp #4841

wants to merge 29 commits into from

Conversation

dylan-copeland
Copy link
Member

@dylan-copeland dylan-copeland commented Apr 29, 2025

The new miniapp in this PR takes an input structured 2D array of 3D points, interpolates the points with a NURBS surface of arbitrary order, and outputs a linear surface mesh with arbitrarily many points in each direction (possible finer or coarser than the initial grid). Three surface meshes are output, representing the initial grid, the NURBS surface, and the output grid.

There is intermediate computation of 3D volume NURBS meshes for each of the 3 coordinates of the surface points. It seems that this 3D mesh is excessive, and that a 2D NURBS mesh should work, but I think MFEM needs more generalization in order to enable using a 2D NURBS mesh for this purpose. A 2D NURBSPatch with 3D coordinates can be defined, but using it in a NURBSExtension and constructing a Mesh object does not work, since it uses NURBSExtension::Set2DSolutionVector and expects patch.GetNC() to be 2. This is something we could generalize in the future, but for now this miniapp uses a 3D NURBS mesh for the 2D surface in 3D, with a single element in the third dimension.

Note that this issue is only for an intermediate 3D mesh not written out. The output mesh nurbs-surf.mesh is a 2D NURBS mesh with a 3D nodes GridFunction, which is written to file but not constructed in the code. A generalization of Mesh::Print enables writing a 2D NURBS mesh with a 3D GridFunction.
nurbs_surface

PR Author Editor Reviewers Assignment Approval Merge
#4841 @dylan-copeland @tzanio @justinlaughlin + @vladotomov + @tzanio + @kmittal2 + @v-dobrev 5/2/25 ⌛due 5/16/25 ⌛due 5/23/25
PR Checklist
  • Code builds.
  • Code passes make style.
  • Update CHANGELOG:
    • Is this a new feature users need to be aware of? New or updated example or miniapp?
    • Does it make sense to create a new section in the CHANGELOG to group with other related features?
  • Update INSTALL:
    • Had a new optional library been added? If so, what range of versions of this library are required? (Make sure the external library is compatible with our BSD license, e.g. it is not licensed under GPL!)
    • Have the version ranges for any required or optional libraries changed?
    • Does make or cmake have a new target?
    • Did the requirements or the installation process change? (rare)
  • Update continuous integration server configurations if necessary (e.g. with new version requirements for each of MFEM's dependencies)
    • .github
    • .appveyor.yml
  • Update .gitignore:
    • Check if make distclean; git status shows any files that were generated from the source by the project (not an IDE) but we don't want to track in the repository.
    • Add new patterns (just for the new files above) and re-run the above test.
  • New examples:
    • All sample runs at the top of the example source file work.
    • Update examples/makefile:
      • Add the example code to the appropriate SEQ_EXAMPLES and PAR_EXAMPLES variables.
      • Add any files generated by it to the clean target.
      • Add the example binary and any files generated by it to the top-level .gitignore file.
    • Update examples/CMakeLists.txt:
      • Add the example code to the ALL_EXE_SRCS variable.
      • Make sure THIS_TEST_OPTIONS is set correctly for the new example.
    • List the new example in doc/CodeDocumentation.dox.
    • If new examples directory (e.g.examples/pumi), list it in doc/CodeDocumentation.conf.in
    • Companion pull request for documentation in mfem/web repo:
      • Update or add example-specific documentation, see e.g. the src/examples.md.
      • Add the description, labels and screenshots in src/examples.md and src/img.
      • In examples.md, list the example under the appropriate categories, add new categories if necessary.
      • Add a short description of the example in the "Extensive Examples" section of features.md.
  • New miniapps:
    • All sample runs at the top of the miniapp source file work.
    • Update top-level makefile and makefile in corresponding miniapp directory.
    • Add the miniapp binary and any files generated by it to the top-level .gitignore file.
    • Update CMake build system:
      • Update the CMakeLists.txt file in the miniapps directory, if the new miniapp is in a new directory.
      • Add/update the CMakeLists.txt file in the new miniapp directory.
      • Consider adding a new test for the new miniapp.
    • List the new miniapp in doc/CodeDocumentation.dox
    • If new miniapps directory (e.g.miniapps/nurbs), add it to MINIAPP_SUBDIRS in the makefile.
    • If new miniapps directory (e.g.miniapps/nurbs), list it in doc/CodeDocumentation.conf.in
    • Companion pull request for documentation in mfem/web repo:
      • Update or add miniapp-specific documentation, see e.g. the src/meshing.md and src/electromagnetics.md files.
      • Add the description, labels and screenshots in src/examples.md and src/img.
      • The miniapps go at the end of the page, and are usually listed only under a specific "Application (PDE)" category.
      • Add a short description of the miniapp in the "Extensive Examples" section of features.md.
  • New capability:
    • All new public, protected, and private classes, methods, data members, and functions have full Doxygen-style documentation in source comments. Documentation should include descriptions of member data, function arguments and return values, template parameters, and prerequisites for calling new functions.
    • Pointer arguments and return values must specify whether ownership is being transferred or lent with the call.
    • Any new functions should include descriptions of their intended use e.g. for internal use only, user-facing, etc., along with references to example code whenever possible/appropriate.
    • Consider adding new sample runs in existing examples to highlight the new capability.
    • Consider saving cool simulation pictures with the new capability in the Confluence gallery (LLNL only) or submitting them, via pull request, to the gallery section of the mfem/web repo.
    • If this is a major new feature, consider mentioning it in the short summary inside README (rare).
    • List major new classes in doc/CodeDocumentation.dox (rare).
  • Update this checklist, if the new pull request affects it.
  • Run make unittest to make sure all unit tests pass.
  • Run the tests in tests/scripts.
  • (LLNL only) After merging:
    • Update internal tests to include the new features.

@dylan-copeland dylan-copeland added WIP Work in Progress mesh labels Apr 29, 2025
@tzanio tzanio requested a review from Copilot May 1, 2025 13:50
Copy link

@Copilot Copilot AI left a comment

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 updates several mesh and NURBS routines to enhance functionality and efficiency. Key changes include:

  • Updating Print/Printer functions across mesh header and source files to accept an optional GridFunction pointer.
  • Modifying NURBS routines by adding a reuse_inverse flag in FindInterpolant and refining the collocation matrix assembly with optional LAPACK banded solvers.
  • Adding new LAPACK routines for banded matrix solving in the linalg module.

Reviewed Changes

Copilot reviewed 10 out of 11 changed files in this pull request and generated 3 comments.

File Description
mesh/pmesh.hpp, mesh/pmesh.cpp Updated Print function signature to include an optional GridFunction pointer for node output.
mesh/nurbs.hpp, mesh/nurbs.cpp Modified NURBS routines: added a reuse_inverse parameter and updated collocation matrix assembly.
mesh/mesh.hpp, mesh/mesh.cpp Revised Printer/Print signatures to accept an optional GridFunction pointer for node saving.
linalg/lapack.hpp, densemat.hpp, densemat.cpp Introduced new LAPACK routines for banded matrix solving to support efficient operations.
Files not reviewed (1)
  • miniapps/nurbs/CMakeLists.txt: Language not supported
Comments suppressed due to low confidence (1)

mesh/nurbs.cpp:595

  • Consider clarifying in the comment that, under MFEM_USE_LAPACK, the collocation matrix is assembled in a banded format to take advantage of efficient LAPACK banded solvers.
/* Assemble collocation matrix (banded with order + 1 nonzeros per row). */

@tzanio tzanio self-assigned this May 1, 2025
@tzanio tzanio self-requested a review May 1, 2025 13:54
Copy link
Member

@tzanio tzanio left a comment

Choose a reason for hiding this comment

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

Nice work @dylan-copeland!

Here are some comments and suggestions:

  • Update CHANGELOG
  • Check all items under "New miniapps" in the PR checklist
  • I would keep only three outputs: "initial-surf.mesh", "final-surf.mesh", "nurbs-surf.mesh"
  • Add a sample run where the final mesh is coarser than the initial one?
  • Simplify the user API to just a few simple NURBS-agnostic functions? Maybe Create(nx, ny, vpos, order) and Resample(NX, NY, VPOS)?
  • This could be extended to initial and final meshes that are high-order. We don't have to do it here, but this will be useful to have in the future

@dylan-copeland dylan-copeland added ready-for-review and removed WIP Work in Progress labels May 2, 2025
@tzanio
Copy link
Member

tzanio commented May 2, 2025

This PR is now under review (see the table in the PR description). To help with the review process, please do not force push to the branch.

Copy link
Member

@tzanio tzanio left a comment

Choose a reason for hiding this comment

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

Thanks @dylan-copeland !

@tzanio
Copy link
Member

tzanio commented May 4, 2025

Saved results from some of the example runs can be found at https://github.com/tzanio/data/tree/main/nurbs-surf.

Screenshot 2025-05-04 at 11 35 35 AM

@tzanio
Copy link
Member

tzanio commented Jun 13, 2025

@justinlaughlin, @vladotomov, @kmittal2 and @v-dobrev -- can we get another approval please?

@tzanio
Copy link
Member

tzanio commented Jun 13, 2025

@dylan-copeland , can you please resolve conflicts?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Review Now
Development

Successfully merging this pull request may close these issues.

6 participants