-
-
Couldn't load subscription status.
- Fork 9
Advection #122
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
base: develop
Are you sure you want to change the base?
Advection #122
Conversation
Co-authored-by: cbritopacheco <6352283+cbritopacheco@users.noreply.github.com>
Co-authored-by: cbritopacheco <6352283+cbritopacheco@users.noreply.github.com>
Co-authored-by: cbritopacheco <6352283+cbritopacheco@users.noreply.github.com>
… advection classes (#121) * Initial plan * Implement manufactured tests for Lagrangian and Flow advection classes Co-authored-by: cbritopacheco <6352283+cbritopacheco@users.noreply.github.com> * Fix * Separate unit tests from manufactured tests and add comprehensive test suite Co-authored-by: cbritopacheco <6352283+cbritopacheco@users.noreply.github.com> * Update * Update * Fix compilation * Change to backtrace * Switch to forward * Update * Update * Testing * Solve with CG * Debugging * Update * Update * Update * Fix MEDIT reading * Add scatter functionality * Restructure * Rename Mapping to Pullback and InverseMapping to Pushforward * Test * It kinda works * Correct orientations * Update * Update * Switch to arrival form * Remove scatter * Manufactured tests --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: cbritopacheco <6352283+cbritopacheco@users.noreply.github.com> Co-authored-by: cbritopacheco <carlos.brito524@gmail.com>
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.
Pull Request Overview
Introduce Lagrangian advection (semi-Lagrangian) support and flow tracing, align element/geometry conventions, and expand tests.
- Add Variational::Flow and Advection::Lagrangian with RK integrators and manufactured/unit tests.
- Standardize mapping terminology (Mapping→Pullback, InverseMapping→Pushforward) and update call sites.
- Normalize quadrilateral vertex ordering and half-space definitions, adjust IO and connectivity accordingly.
Reviewed Changes
Copilot reviewed 48 out of 49 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Rodin/Variational/Flow.h | New flow tracer and function wrapper for semi-Lagrangian transport. |
| src/Rodin/Models/Advection/Lagrangian.h | New Lagrangian advection step using Flow and CG solve. |
| src/Rodin/Variational/P1/P1.h | Rename Mapping/InverseMapping to Pullback/Pushforward; update APIs. |
| src/Rodin/Variational/GridFunction.h | Switch to getPullback/getPushforward in projections/evaluations. |
| src/Rodin/Variational/ShapeFunction.h | Use Pushforward for basis eval; include cleanup. |
| src/Rodin/Geometry/Polytope.* | Reorder quadrilateral vertices; update half-spaces and projection. |
| src/Rodin/Geometry/Connectivity.cpp | Adjust quad/wedge edge/face connectivity to new ordering. |
| src/Rodin/IO/MFEM.cpp, src/Rodin/IO/MEDIT.* | Align quad vertex ordering in (de)serialization; fix MEDIT value layout. |
| src/Rodin/QF/QFP1.* | Add vertex-based P1 quadrature. |
| src/Rodin/QF/GaussLobato.h | Add Gauss–Lobatto quadrature (filename/class spelling mismatch). |
| tests/* (Advection, Flow) | Add unit and manufactured tests for Flow/Lagrangian. |
| CMakeLists.txt | Lower Eigen minimum to 3.3; add new subdirectories for Advection tests/models. |
| else if (poly0.getDimension() == cd - 1) | ||
| { | ||
| const Index f = poly0.getIndex(); | ||
| const auto& adj = conn.getIncidence(cd - 1, cd).at(f); | ||
|
|
||
| if (mesh.isBoundary(f)) | ||
| { | ||
| const Index c = adj[0]; | ||
| mesh.getPolytopeTransformation(cd, c).inverse(s_rc_tmp, p.getPhysicalCoordinates()); | ||
| Geometry::Polytope::Project(mesh.getGeometry(cd, c)).cell(s_rc, s_rc_tmp); | ||
| s_cell = c; | ||
| } |
Copilot
AI
Oct 19, 2025
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.
s_rc may be uninitialized or have stale size before being written in Project(...).cell(s_rc, s_rc_tmp). Resize/assign s_rc before use to avoid out-of-bounds writes. For example: s_rc = s_rc_tmp; or s_rc.resizeLike(s_rc_tmp) prior to calling cell().
| { | ||
| const Index c1 = adj[1]; | ||
| mesh.getPolytopeTransformation(cd, c1).inverse(s_rc_tmp, p.getPhysicalCoordinates()); | ||
| Geometry::Polytope::Project(mesh.getGeometry(cd, c1)).cell(s_rc, s_rc_tmp); | ||
| s_cell = c1; | ||
| } |
Copilot
AI
Oct 19, 2025
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.
Same issue as above: s_rc is written by Project(...).cell(s_rc, s_rc_tmp) without ensuring correct size. Initialize/resize s_rc from s_rc_tmp before the call.
|
|
||
| /** | ||
| * @brief Inverse mapping for the scalar/complex P1 space. | ||
| * @brief Inverse Pullback for the scalar/complex P1 space. |
Copilot
AI
Oct 19, 2025
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.
The docstring says 'Inverse Pullback' but the class is 'Pushforward'. Update the comment to 'Pushforward for the scalar/complex P1 space.' to reflect the actual concept.
| * @brief Inverse Pullback for the scalar/complex P1 space. | |
| * @brief Pushforward for the scalar/complex P1 space. |
| Step m_step; | ||
| BoundaryPolicy m_bp; | ||
| TangentPolicy m_tp; | ||
| const Geometry::Point* m_p; |
Copilot
AI
Oct 19, 2025
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.
m_p is declared but never used. Consider removing it to reduce dead state and potential confusion.
| const Geometry::Point* m_p; |
| auto getValue(const Geometry::Point& p) const | ||
| { | ||
| const auto& trace = this->trace(p); | ||
| return !(trace.exited()) * m_operand->getValue(trace.getPoint()); |
Copilot
AI
Oct 19, 2025
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.
[nitpick] Using boolean arithmetic to zero-out values is terse but obscures intent and relies on implicit conversions. Prefer an explicit conditional for clarity: return trace.exited() ? decltype(m_operand->getValue(p)){} : m_operand->getValue(trace.getPoint()); or an if-statement.
| return !(trace.exited()) * m_operand->getValue(trace.getPoint()); | |
| return trace.exited() ? decltype(m_operand->getValue(trace.getPoint())){} : m_operand->getValue(trace.getPoint()); |
| * Copyright Carlos BRITO PACHECO 2021 - 2025. | ||
| * Distributed under the Boost Software License, Version 1.0. | ||
| * (See accompanying file LICENSE or copy at | ||
| * https://www.boost.org/LICENSE or copy at |
Copilot
AI
Oct 19, 2025
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.
The first URL is incomplete; the standard Boost license link is https://www.boost.org/LICENSE_1_0.txt. Consider removing the incomplete 'LICENSE' URL to avoid confusion.
| * https://www.boost.org/LICENSE or copy at |
No description provided.