Adding cpp&MATLAB example - 2D imcompressible square cylinder flow#274
Adding cpp&MATLAB example - 2D imcompressible square cylinder flow#274yiyuef wants to merge 35 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.
examples/cpp/cylinder_flow_2D.cpp
Outdated
| 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 )
examples/cpp/cylinder_flow_2D.cpp
Outdated
| 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*/)
examples/cpp/cylinder_flow_2D.cpp
Outdated
| #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 )
examples/cpp/cylinder_flow_2D.cpp
Outdated
| #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?
examples/cpp/cylinder_flow_2D.cpp
Outdated
| 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
examples/cpp/cylinder_flow_2D.cpp
Outdated
| 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; |
examples/cpp/cylinder_flow_2D.cpp
Outdated
| 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. |
|
Hi @yiyuef , I know you have finals this week, but will you have a chance to review this after your finals? Thank you. |
|
Thank you for all the comments! I have final exams this week but I will definitely review them carefully and update my PR. Thanks again. |
Hi @yiyuef , I hope your exams went well. Do you have any updates for this PR? Thank you! |
|
@jbrzensk @mdumett @valeriabarra Hi all, I apologize for the late update, please check the latest version of the example code and documentation. I simplified a lot, and highlighted how I use mimetic operators in the documentation. |
|
Hi @yiyuef , I think you also need to add this example to the |
|
Hi @yiyuef thank you again for your contribution. In addition to my previous comments, it appears that the documentation file is failing. Have you tried to build the docs locally to test it? The two images are not rendered. Also the math typesetting is not formatted correctly. See the screenshots below of the docs preview. Thank you!
|
done. |
|
@valeriabarra Prof. Barra, |
You can see instructions on how to build the docs locally here https://github.com/csrc-sdsu/mole/tree/main/doc/sphinx Also, please see my comment regarding the GNUplot in my code review above. Thank you! |
|
@valeriabarra Prof. Barra, |
|
Hi @yiyuef , thank you very much for this terrific contribution! @mdumett and @jbrzensk , if you are satisfied with how Yiyue has addressed your comments, please resolve them. @yiyuef , if the others are satisfied with your changes, please reduce the number of commits in this PR. Use the interactive rebase with |






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.