Skip to content

fix: boundary conditions for 3d case#441

Open
gouarin wants to merge 4 commits into
hpc-maths:mainfrom
gouarin:fix-bc-in-3D
Open

fix: boundary conditions for 3d case#441
gouarin wants to merge 4 commits into
hpc-maths:mainfrom
gouarin:fix-bc-in-3D

Conversation

@gouarin
Copy link
Copy Markdown
Contributor

@gouarin gouarin commented May 4, 2026

  • I have installed pre-commit locally and use it to validate my commits.
  • The PR title follows the conventional commits convention.
    Available tags: 'build', 'chore', 'ci', 'docs', 'feat', 'fix', 'perf', 'refactor', 'revert', 'style', 'test'
  • This new PR is documented.
  • This new PR is tested.

Description

Related issue

How has this been tested?

Code of Conduct

By submitting this PR, you agree to follow our Code of Conduct

  • I agree to follow this project's Code of Conduct

@codacy-production
Copy link
Copy Markdown

codacy-production Bot commented May 4, 2026

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 30 complexity · 5 duplication

Metric Results
Complexity 30
Duplication 5

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Copy link
Copy Markdown
Contributor

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 aims to fix incorrect boundary/corner handling in 3D by updating how corner/edge subsets are constructed on the mesh and how outer corner ghost cells are filled/projected during boundary-condition updates.

Changes:

  • Update mesh corner subset construction to handle directions with zero components (3D edge directions).
  • Rework outer-corner ghost filling to populate diagonal layers and then fill off-diagonal ghosts via sweeps.
  • Adjust corner projection logic and periodic-direction skipping during outer ghost updates.

Reviewed changes

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

File Description
include/samurai/mesh.hpp Updates corner subset construction to account for nonzero direction components (3D edges/corners).
include/samurai/bc/apply_field_bc.hpp Reworks polynomial extrapolation logic for outer corners, adding multi-layer diagonal fill + off-diagonal sweeps.
include/samurai/algorithm/update.hpp Adjusts corner projection behavior and periodic-direction filtering for corner ghost updates.

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

Comment thread include/samurai/mesh.hpp
Comment thread include/samurai/bc/apply_field_bc.hpp
Comment thread include/samurai/algorithm/update.hpp
Comment thread include/samurai/algorithm/update.hpp
Comment on lines 318 to +333
void update_outer_corners_by_polynomial_extrapolation(std::size_t level, const DirectionVector<Field::dim>& direction, Field& field)
{
if constexpr (Field::dim == 1)
{
return; // No outer corners in 1D
}

static constexpr std::size_t extrap_stencil_size = 2;
static constexpr std::size_t max_stencil_size_PE = PolynomialExtrapolation<Field, 2>::max_stencil_size_implemented_PE;

auto& domain = detail::get_mesh(field.mesh());
PolynomialExtrapolation<Field, extrap_stencil_size> bc(domain, ConstantBc<Field>(), true);
int ghost_width = field.mesh().ghost_width();
const auto& domain = detail::get_mesh(field.mesh());
const auto& corner_lca = field.mesh().corner(direction);

auto corner = self(field.mesh().corner(direction)).on(level);
// Step 1: Fill the diagonal ghost cells layer by layer using stencil sizes 2, 4, ..., 2*ghost_width
for (int ghost_layer = 1; ghost_layer <= ghost_width; ++ghost_layer)
{
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