-
Notifications
You must be signed in to change notification settings - Fork 47
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
Implement svFSI using C++ #19
Comments
I've written some Fortran code to prototype ways to interface the svFSI Fortran code to a c++ framework. I've implemented a Fortran The code below shows how to use the
The
|
I've integrated the C++ prototype code into svFSI, creating a C++
I've also added a |
@ktbolt I merged Chi's P2P1 stuff for fluid and FSI. There were some other modifications in which I extended P2P1 for non-Newtonian flows and weakly applied Dirichlet BCs. Please use the commit e258b9f |
@vvedula22 Great! I will get back to the conversion. |
I've redone the XML file format to mimic the layout and names currently used by svFSI
I also rewrote the XML reader to remove the jumble of parameter names and such. |
I've created an I'm now creating C++ classes that duplicate Fortran modules, retain the same names and such to make it easy to match the Fortran data. I also created a simple C++ I've converted the types in the
is converted to
I've stated to duplicate the Fortran subroutines to maintain a similar flow of control and calling sequence. |
I've added new XML elements to the parser to support fsi domains and more complicated BCs
I've added returning mesh data from the C++ to Fortran for comparison, nodal coordinates match fine but element connectivity was wrong, elements ordered differently, missed important step later where So now I've reorganized the C++ code to better replicate the Fortran organization and flow of control, replicating where Fortran subroutines are called from and their name. |
I've reorganized the code and have replicated the Fortran code I've come across so far as I track the control flow for a CFD simulation.
It's very easy to get mixed up here so I'm documenting all of this in https://github.com/ktbolt/svFSI/blob/Implement-svFSI-using-cpp_19/Code/Source/svFSI_cinterface/README.md. Even though a lot of the element code is screaming |
I've finished converting all the Fortran code called from Subtracting 1 from array and vector indices, etc. is totally error prone of course but have I've been adding
is similarly implemented like this in C++
And the award for the most obscure Fortran subroutine name (so far) goes to |
Ha ha! this refers to reading end (or boundary) nodes of a 1D fiber mesh from a file generated using the SV Purkinje plugin :) You will see many more later :) |
I've finished converting the Need to be careful with lines like this in Fortran
to get the indexing right in C++. I've added definitions to the
I've replaced using
Note that some Fortran functions like |
I've finished converting the 500 line I've converted solver .inp to .xml files and tested on the following svFSI-Tests
Fortran and C++ codes data seem to match so far. |
I'm converting And it finally dawned on me what the |
I've converted I've also added a bunch of
is implement in C++ like this
These enums are referenced using I've also converted more solver |
@vvedula22 I'm testing setting CMM parameters using https://github.com/SimVascular/svFSI-Tests/blob/master/07-fsi/cmm/01-pipe_RCR/02-deform-wall_inflate/01-inflate/svFSI.inp. The mesh is defined using
The Fortran code is calling
This is confusing because the name and implementation of |
@ktbolt This is a special case because we are loading the mesh as a shell surface where the triangulated wall surface is treated as a svFSI Regarding Internally, the To summarize, one can load a VTP file using |
@vvedula22 Thanks for the detailed reply! I implemented It's not clear why SV even uses vtp files to store mesh data, just overcomplicates processing mesh files, should use vtu for all mesh data. |
I've converted the 500 line It will be interesting to reimplement this code not just following the Fortran implementation but using C++ containers, maybe can simplify this code. Just using descriptive variable names and code decomposition would help a lot. |
@vvedula22 What is the format of the Fourier coefficients file used in |
OK I will. You also asked for another example during the last solver meeting. Could you remind me what was that test case we talked about then? Will upload both these cases. |
Hi @ktbolt, I saw you are creating templates for 2D/3D arrays. Is it possible to take advantage of existing libraries such as eigen3, boost etc to handle the matrix/vector operations for us? |
@vvedula22 During the solver meeting I asked for a test case for variable wall properties. |
@CZHU20 I wrote my own array and vector templates so I could easily reproduce Fortran arrays and debug indexing problems. I've been looking at Eigen and other packages for matrix/vector operations, would like to use something for the real svFSI implementation. I will probably use Eigen for the Python svZeroDSolver that I will help reimplement in C++. What is your experience with matrix/vector packages? Do you have a preference? |
Hi @ktbolt thanks for the explanation. I am only familiar with Eigen. Since it's just a bunch of header files, I think Eigen can also be easily packaged into svFSI for distribution. |
@ktbolt Added two cases in svFSI-Tests :
Also added README files to describe the problem for both these cases. Let me know if you have any questions on these. |
Thanks @vvedula22 ! |
The way svFSI currently preprocesses input mesh, face, and BC data for a simulation is not very efficient, especially for an HPC cluster
Maybe what we need to do is to preprocess the input data and write that to a file that is guaranteed to be valid. This file can then be used for the simulation. |
I discovered that I skipped converting the code that processes boundary conditions. This is probably important so I converted the 500 line |
I've converted the
I've tested |
I've now tested
found a bug in TET20 shape functions. Serial results MPI match. |
I've added the
I've now tested |
I've added
reproduced in C++ by adding an
I've also added several
I've tested |
I've now tested I've also tested |
I've tested The the
We can probably remove most of these parameters, need the path to the 0D solver shared library and the JSON file, would be good to not have to specify |
I've added writing/reading binary restart files and initialization from vtu and restart binary files. The restart binary file format is the same as the Fortran format. I also fixed a problem with not writing the last time step to a vtk file, issues trying to reproduce Fortran code that uses 0-size arrays. |
The last big task is to convert code for I will also need to restructure the C++ code a bit to loop over the initialization code, Fortran just does a |
@ktbolt The remeshing algorithm needs to be updated on the Fortran side too. I wrote this code during my earliest days as a postdoc and was still learning the code then. This part of the code is not optimized and I think the remeshing followed by projection could be better handled. Would it be possible for you to come back to this in a month or so, ideally in Dec? |
@vvedula22 I think it is fine for me to come back to this in Dec or even next year. I want to go through the code and determine if there are sections that have not been tested and increase the C++ solver performance. |
Sounds good. |
I've been reviewing The Ran the |
I found some problems testing
Serial and MPI results match. |
I've fixed a bug in the code that computes divergence for output, can now write out
The |
Computing |
I started testing with I added I tested |
I've added missing C++ xml files and ran simulations for a bunch of different mesh/element tests under
actually found a new indexing bug doing this. I've now run and compared simulation, serial and mpi, for all 68 tests (excluding shells). All results look good. I will now look at code coverage, maybe use @vvedula22 @CZHU20 Do you think |
I think you can also test code coverage with GitHub actions. Jakob implemented this recently (for a smaller scope project) and it’s summarized in the slides Martin sent out. Not sure if this applies here, but mentioning just in case!
From: Dave Parker ***@***.***>
Date: Monday, November 14, 2022 at 6:58 PM
To: SimVascular/svFSI ***@***.***>
Cc: Subscribed ***@***.***>
Subject: Re: [SimVascular/svFSI] Implement svFSI using C++ (#19)
I've added missing C++ xml files and ran simulations for a bunch of different mesh/element tests under
03-stokes/01-manufactured-solution
02-lelas/01-beam_Euler-Bernoulli
05-struct/01-block-compression
actually found a new indexing bug doing this.
I've now run and compared simulation, serial and mpi, for all 68 tests (excluding shells). All results look good.
I will now look at code coverage, maybe use gcov to do this, maybe just compare what's in svFSI_master.inp to the test .inp files.
@vvedula22<https://github.com/vvedula22> @CZHU20<https://github.com/CZHU20> Do you think svFSI-Tests tests all of the svFSI code?
—
Reply to this email directly, view it on GitHub<#19 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ADJGJZ7SCCOXXCJD26DBPUTWIL34FANCNFSM4V6FLA7Q>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
I've re-implemented parts of the |
I've finished filling in a bunch of holes in the new |
For
When not using a
The C++ svFSILS linear solver
which I reproduce in C++ by creating copies of sub-arrays, modifying them, and copying them back, for example
All this copying slows up the
Option 1) would require a lot of changes to all code that may uses these functions. Option 2) seems to be the best choice although this might produce some scary C++ code. |
I've implemented an I've modified the C++
which looks and behaves like the Fortran code. The time spent in the C++ |
I've been timing The time difference is primarily from the FS equation matrix assembly
I think the additional time in the C++ code is from creating millions of small Array objects used in the nonlinear solid mechanics construct lhs and material model code, the I've done some optimization for this and reduced the C++ code to 1.2 times slower, 55s slower for 10 time steps using four processors on my old Mac. We will need to keep this sort of thing in mind when implementing the next stage C++ code. |
I've tested the latest changes on Ubuntu, looks good. I also tested the XML parsing code that uses some new C++17 features (variants) on Windows, found a small problem, fixed it and now works. |
I'm now cleaning up the code, removing all of my I will leave in all of the conditionally compiled print statements useful for debugging. |
I have finished cleaning up the code. I will now have a look around the code to see if there is anything I might have missed or not implemented. |
I have created the https://github.com/SimVascular/svFSIplus repository for the C++ code, added a Both serial and MPI simulations work fine. I also added messages to better diagnose errors in the XML input file, for example
|
I've finished making changes to my svFSI branch https://github.com/ktbolt/svFSI/tree/Implement-svFSI-using-cpp_19, now moving all new development to https://github.com/SimVascular/svFSIplus. |
While Fortran is still used for scientific and engineering problems we feel that it would be better to implement the FSI solver using C++ to provide a more extensible framework (e.g. plugins for custom BCs) and better capabilities for text file processing (e.g. XML).
Although Fortran is easier to learn than C++ and has nice array support most students don't have any experience programming in Fortran.
We will perform the conversion in a series of steps. The first step is to implement a C++ framework providing a Fortran-callable interface used to store and retrieve data. Each Fortran module or other independent code sections will then be incrementally converted to C++.
incrementally converting sections of independent code.
The text was updated successfully, but these errors were encountered: