Skip to content

Adding cpp example - 2D imcompressible cylinder flow#274

Open
yiyuef wants to merge 10 commits intocsrc-sdsu:mainfrom
yiyuef:cylinder_branch
Open

Adding cpp example - 2D imcompressible cylinder flow#274
yiyuef wants to merge 10 commits intocsrc-sdsu:mainfrom
yiyuef:cylinder_branch

Conversation

@yiyuef
Copy link

@yiyuef yiyuef commented Feb 7, 2026

Description

This PR adds a new C++ example cylinder_flow_2D that solves 2D incompressible channel flow past a cylinder-like obstacle (implemented as a masked no-slip region) using a projection (pressure-correction) method built on MOLE mimetic operators.

It also adds Sphinx/MyST documentation for the example and includes a representative output figure.

Type of Change

  • New core functionality
  • New example
  • Documentation update
  • Bug fix
  • Performance improvement

Mathematical Details

Not applicable (no new operators added).
The example solves the incompressible Navier–Stokes equations with a fractional-step (projection) method and uses MOLE discrete operators (divergence, gradient, Laplacian) for the Helmholtz/Poisson solves.

Testing

  • Unit tests pass
  • Examples run successfully
  • Convergence studies completed (if applicable)
  • Cross-platform compatibility verified

Documentation

  • Code is well-commented
  • API documentation updated
  • Example documentation added (if applicable)
  • Mathematical background provided

Related Issues

#211

Additional Notes

  • Output image cylinder_flow_2D_output1.png is included alongside the documentation page.

- $$y \in [-1,1]$$
- $$t \in [0, t_{\text{final}}]$$ with $$t_{\text{final}} = \texttt{tspan}$$ (default in code: `tspan = 32.0`)

A “cylinder” is represented by a masked block of cells located near
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hi @yiyuef , thank you so much for your terrific contribution! I would specify that it is a "square cylinder" since it's not really the same as a round cylinder.

Suggested change
A “cylinder” is represented by a masked block of cells located near
A “square cylinder” is represented by a masked block of cells located near

std::cerr << "[warn] PNG conversion uses macOS 'sips'. Kept " << ppmFile << "\n";
#endif

std::cout << "Wrote U_final.csv, V_final.csv, p_final.csv, speed_final.png\n";
Copy link
Collaborator

Choose a reason for hiding this comment

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

This line gets printed also in the case of non-MAC-OS, but the file name should be consistent in the string. In case of non-MAC-OS it is not speed_final.png, but speed_final.ppm.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, any specific reason why the extension .ppm was chosen for non-MAC-OS users? It is a quite uncommon and unsupported file format.

@valeriabarra
Copy link
Collaborator

Thank you, @yiyuef for this terrific contribution!

I ran the example and can see the output figure is quite small. Can you please increase its size? Also, any specific reason why the extension .ppm was chosen for non-MAC-OS users? It is a quite uncommon and unsupported file format.

Finally, I thought we also wanted to include the MATLAB/octave version to the library. I thought you had completed that implementation, first? Thank you!

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