Adding cpp&MATLAB example - 2D imcompressible square cylinder flow#274
Adding cpp&MATLAB example - 2D imcompressible square cylinder flow#274yiyuef wants to merge 19 commits intocsrc-sdsu:mainfrom
Conversation
|
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 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! |
Co-authored-by: Valeria Barra <39932030+valeriabarra@users.noreply.github.com> Signed-off-by: Yiyue Feng <79966731+yiyuef@users.noreply.github.com>
|
@valeriabarra Thanks for the careful review!
|
examples/cpp/cylinder_flow_2D.cpp
Outdated
| if ((step % plotEvery) == 0 || step == 1 || step == nSteps) { | ||
| const double maxU = arma::abs(U_new).max(); | ||
| const double maxV = arma::abs(V_new).max(); | ||
| const double umax = maxU; |
There was a problem hiding this comment.
umax is made twice? maxU and umax are the same.
| U.submat(1, ny - 1, nx - 1, ny - 1).zeros(); | ||
| V.submat(1, ny - 1, nx - 1, ny - 1).zeros(); | ||
|
|
||
| U(0, 0) = 0.0; U(0, ny - 1) = 0.0; |
There was a problem hiding this comment.
Split these onto their own separate lines. ( clang-format )
| return idx; | ||
| } | ||
|
|
||
| static uvec bc_bottom_indices(unsigned m, unsigned n) { |
There was a problem hiding this comment.
If n is void, then
c_bottom_indices(unsigned m, unsigned /*n*/)
| #include <armadillo> | ||
|
|
||
| // Optional Eigen (for reusable sparse factorization) | ||
| #if defined(__has_include) |
There was a problem hiding this comment.
nit: # directives are not indented ( so says clang-format )
| #endif | ||
|
|
||
| // Mimetic operator library (in ./cpp) | ||
| #include "mole.h" |
There was a problem hiding this comment.
I guess this should have armadillo down here, but maybe it doesn't work with EIGEN?
| static uvec bc_bottom_indices(unsigned m, unsigned n) { | ||
| (void)n; | ||
| uvec idx(m + 2); | ||
| for (unsigned i = 0; i < m + 2; ++i) idx(i) = i; |
There was a problem hiding this comment.
needs braces around the idx(i) = i
| uvec idx(m + 2); | ||
| const unsigned nx = m + 2; | ||
| const unsigned j = n + 1; | ||
| for (unsigned i = 0; i < m + 2; ++i) idx(i) = i + nx * j; |
| uvec rowsbc; | ||
| if (!pieces.empty()) { | ||
| rowsbc = pieces[0]; | ||
| for (size_t i = 1; i < pieces.size(); ++i) rowsbc = arma::join_cols(rowsbc, pieces[i]); |
|
This comment refers to the MATLAB implementation. This is a very interesting and complex example. My main suggestions are mainly with respect to its documentation.
From the code, it is not clear why the need to apply boundary conditions (applyVelocityBCAndMask) in a finite difference manner. If the code is more documented the user can appreciate the decision of the developer. This an important example from which many users can learn about how to deal with complicated geometries. Please, provide more documentation. |
Description
This PR adds a new C++ example
cylinder_flow_2Dthat 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
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
Documentation
Related Issues
#211
Additional Notes
cylinder_flow_2D_output1.pngis included alongside the documentation page.