Skip to content

Some global L2 projection refactoring - #872

Closed
kmokstad wants to merge 10 commits into
OPM:masterfrom
kmokstad:glb2-refact
Closed

Some global L2 projection refactoring#872
kmokstad wants to merge 10 commits into
OPM:masterfrom
kmokstad:glb2-refact

Conversation

@kmokstad

Copy link
Copy Markdown
Collaborator

The classes for handling version 1 of the global L2 projection is now placed in anonymous namespace in the file GlbL2projection.C to stress that these are purely internal items and are not supposed to be exposed to the outside apps.
Then account for possibly element age when doing the projection (omitting elements not born yet) , and skip entirely patches which have no activated elements.

@kmokstad

Copy link
Copy Markdown
Collaborator Author

jenkins build this with downstreams please

Copilot AI left a comment

Copy link
Copy Markdown

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 refactors the global L2 projection implementation by encapsulating the legacy (version 1) projection machinery within GlbL2projector.C, and extends projection assembly to account for element activation time (skipping elements not yet “born” and omitting fully inactive patches).

Changes:

  • Refactors global L2 projection internals (moves legacy v1 integrand/container classes into an anonymous namespace; centralizes global solver controls under namespace GlbL2).
  • Adds element-age awareness to L2 matrix assembly (skip inactive elements; reject “separate projection basis” when element activation is enabled).
  • Skips inactive/empty patches during projection and adds a gl2 option alias for continuous global L2 projection.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/SIM/SIMoptions.C Adds parsing support for gl2 as a projection method option.
src/SIM/SIMbase.C Skips inactive patches during projection and refactors patch iteration/printing behavior.
src/ASM/GlbL2projector.h Removes legacy v1 class declarations from the header; introduces namespace GlbL2 globals and time level plumbing in L2Integrand.
src/ASM/GlbL2projector.C Implements the new structure (v1 internals hidden in anonymous namespace) and threads time into L2 integrands.
src/ASM/ASMs3Drecovery.C Skips not-yet-active elements during L2 assembly and disallows separate projection basis with activation.
src/ASM/ASMs3DLag.C Same as above for Lag-based 3D assembly; minor integration loop refactor.
src/ASM/ASMs2Drecovery.C Skips inactive elements during L2 assembly; refactors monomial evaluation helper.
src/ASM/ASMs2DLag.C Same as above for Lag-based 2D assembly.
src/ASM/ASMs1D.C Skips inactive elements during L2 assembly and disallows separate projection basis with activation.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/SIM/SIMbase.C Outdated
Comment thread src/ASM/GlbL2projector.C
Comment thread src/ASM/ASMs3DLag.C Outdated
Comment thread src/ASM/ASMs2DLag.C Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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

Comments suppressed due to low confidence (1)

src/SIM/SIMbase.C:2444

  • In the SIMoptions::CGL2 (version 1) branch, on success the code assigns values = loc_values and then continues, which skips the injection/interleaving logic used by other projection methods. In multi-patch models this will overwrite values per patch and return with only the last patch’s data. Consider either (a) disallowing CGL2 for multi-patch explicitly, or (b) removing the continue and using injectPatchSolution(...) so each patch contributes to the final values.
    case SIMoptions::CGL2:
      // Continuous global L2-projection (version 1)
      if (myModel.size() > 1 && pch->separateProjectionBasis())
        std::cerr <<" *** L2 projection of explicit functions onto a separate"
                  <<" basis is not available for multi-patch models."
                  << std::endl;
      else if (pch->globalL2projection(ftmp,
                                       L2FuncIntegrand(*pch,*f,adm,time),true))
      {
        values = loc_values;
        continue;
      }
      return false;

Comment thread src/SIM/SIMbase.C
@kmokstad

Copy link
Copy Markdown
Collaborator Author

jenkins build this with downstreams please

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Comment thread src/SIM/SIMbase.C Outdated
Comment thread src/SIM/SIMbase.C
@kmokstad

kmokstad commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

jenkins build this with downstreams please

@kmokstad

kmokstad commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

jenkins build this with downstreams ifem-stokes=348 ifem-navierstokes=273 ifem-fsi=102 ifem-boussinesq=164 ifem-shellex=52 please

@kmokstad

kmokstad commented Jun 9, 2026

Copy link
Copy Markdown
Collaborator Author

jenkins build this with downstreams ifem-stokes=348 ifem-navierstokes=273 ifem-fsi=102 ifem-boussinesq=164 ifem-shellex=52 ifem-printconcrete=2 please

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread src/ASM/ASMbase.C
Comment thread src/ASM/ASMs1D.C Outdated
Comment thread src/SIM/SIMbase.C
Comment thread src/SIM/SIMbase.C Outdated
Comment thread src/SIM/SIMbase.C
Comment thread src/ASM/ASMbase.C Outdated
Comment thread src/LinAlg/SystemMatrix.C
Comment thread src/LinAlg/PETScMatrix.C Outdated
Comment thread src/ASM/ASMbase.h Outdated
Comment thread src/SIM/SIMbase.C Outdated
kmokstad added 2 commits June 10, 2026 07:39
to anonymous namespace of the GlbL2projector.C file, to
clarify that these classes are not meant for outside usage.
Added: Current time as a member in class L2Integrand.
Changed: Use a pointer in the (new) GlbL2 namespace to pass
the right ProcessAdm object to PETSc when doing L2-projection
instead of passing it through the L2Integrand objects,
which do not need to know about this.
and flag the non-zero contributions in the projection matrix
kmokstad added 2 commits June 10, 2026 07:40
Changed: Allow CGL2 version 1 when projecting functions.
…node.

Added: Another ASMbase::injectNodalVec() doing it for a single node only.
@kmokstad
kmokstad force-pushed the glb2-refact branch 3 times, most recently from 1a9997a to 5d85c3e Compare June 10, 2026 08:28
@kmokstad

Copy link
Copy Markdown
Collaborator Author

jenkins build this with downstreams ifem-stokes=348 ifem-navierstokes=273 ifem-fsi=102 ifem-boussinesq=164 ifem-shellex=52 ifem-printconcrete=2 please

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Comment thread src/ASM/ASMbase.C
Comment thread src/ASM/ASMbase.C Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 17 out of 17 changed files in this pull request and generated 4 comments.

Comment thread src/ASM/ASMbase.C
Comment thread src/ASM/GlbL2projector.C Outdated
Comment thread src/ASM/GlbL2projector.C
Comment thread src/SIM/SIMbase.C
kmokstad added 3 commits June 10, 2026 16:56
patch-level element activation is used), initialize the control/nodal
point values for non-active elements which are connected to active
elements based on the average values. This is then used to enhance
the global L2-projection.
This is used in the getAge() method, which now optionally can
return 0.0 for unborn elements directly coupled to born elements.
Added: ASMbase::inActiveElement() returning true if the element
is not active yet, and not connected to active elements either.
Changed: Use std::accumulate to calculate number of elements.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

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

Comment thread src/LinAlg/PETScMatrix.C Outdated
kmokstad added 2 commits June 10, 2026 17:54
and replace PETScMatrix::solveMultipleRhs() by an override.
For use in the global L2-projection.
Added: Some debug print in ASMs?D::evalSolution().
was added in commit 6252350, to
facilitate checking the real effect of it on various models.
@kmokstad

Copy link
Copy Markdown
Collaborator Author

Replaced by #885

@kmokstad kmokstad closed this Jun 15, 2026
@kmokstad
kmokstad deleted the glb2-refact branch June 16, 2026 08:03
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.

2 participants