Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
49d5364
[mask][surface tracking]
Joni32do Jan 14, 2024
9576bc5
Added features to Mask -> velocity update step for Surfaces
Joni32do Jan 16, 2024
96f2611
Added Tests for mask
Joni32do Jan 16, 2024
841e573
[Boundary][Mask] -> boundary_list, print ...
Joni32do Jan 18, 2024
50d127a
minor update
Joni32do Jan 18, 2024
9b674ac
[Boundary] works with lid-driven cavity
Joni32do Jan 22, 2024
9440d7b
"Working on velocity boundary conditions and boundary primitives
Joni32do Jan 22, 2024
37e6a9b
[Domain] update velocities via DOMAIN -- error is low but not 0 to li…
Joni32do Jan 22, 2024
03f2e86
[Bug Fixed] solves lid-driven cavity with no error
Joni32do Jan 23, 2024
30d3072
[Tests] added framework and first test ... TODO: MORE
Joni32do Jan 23, 2024
c6cb9fe
Merge pull request #26 from Joni32do/project_surface
Joni32do Jan 23, 2024
9f0a7ec
[FluidTracker] Fluid Tracking -> needs more testing
Joni32do Jan 23, 2024
80d72ef
[Init Distribution of Fluid Trace Cells]
Joni32do Jan 24, 2024
bfad093
Make Rect
Joni32do Jan 24, 2024
a129ac5
Fluid Tracker -> Animation for testing
Joni32do Jan 27, 2024
4fe497f
[tracing lid-driven] animation and bug fix cmake and distribution
Joni32do Jan 27, 2024
9c8984c
Fluid Tracking with source -> spiral animation
Joni32do Jan 28, 2024
d66a2e6
Rectangle physicalSize
Joni32do Jan 28, 2024
8c9426f
working main
Joni32do Jan 28, 2024
eb3c20e
Merge pull request #27 from Joni32do/project_surface
Joni32do Jan 28, 2024
2f2d804
added new setting for different domain BC
LHRaceIng Jan 28, 2024
d47a557
added settings paramter to mask
LHRaceIng Jan 28, 2024
fe9df50
added new function to specify domain boundary conditions
LHRaceIng Jan 30, 2024
52e089e
added boundary conditions obstacle fluid to mask
LHRaceIng Jan 30, 2024
c86e052
added functoin to read in Bitmaps
LHRaceIng Feb 2, 2024
82712f5
implemented boundary conditions
LHRaceIng Feb 2, 2024
d7730ea
fully implemented boundary conditions. However it is not working
LHRaceIng Feb 3, 2024
cbd700b
almost working version
LHRaceIng Feb 4, 2024
355d0d4
nothing new
LHRaceIng Feb 4, 2024
389628b
finally functional
LHRaceIng Feb 4, 2024
a110359
[Mask][Boundary Pressure] purged and Ctrl+C & Ctrl+V
Joni32do Feb 4, 2024
c75e621
[calculate F or G]
Joni32do Feb 4, 2024
3b10e91
[Test][PNG does complain -> of minor importance for now]
Joni32do Feb 4, 2024
394f7dd
[Velocity for Surfaces] needs testing
Joni32do Feb 4, 2024
1c832c3
Tests included
Joni32do Feb 4, 2024
6f11c8e
first interation of displaying mask in paraview
LHRaceIng Feb 4, 2024
de7ea7d
[FluidTracer][Test passing]
Joni32do Feb 4, 2024
fda7597
error checking
LHRaceIng Feb 4, 2024
9ad540c
juhuuu
LHRaceIng Feb 4, 2024
20f331f
fluidTracer seams to work AND doesnt destroy everything
Joni32do Feb 4, 2024
509e160
working mask in paraview
LHRaceIng Feb 4, 2024
7701b6f
Merge branch 'project_obstacle_boundary' into project_surface_merge
Joni32do Feb 4, 2024
1ef7dea
Merge pull request #28 from Joni32do/project_surface_merge
Joni32do Feb 4, 2024
49dddec
working again
LHRaceIng Feb 4, 2024
d3570e2
first iteration of implementing air into outputwriter
LHRaceIng Feb 4, 2024
582490a
path and fluid tracker
Joni32do Feb 4, 2024
b69ee1e
[surface(dt)] Deleted documentation
Joni32do Feb 5, 2024
efb95a3
[Outputwriter Particles] updated the boundary cell
Joni32do Feb 5, 2024
9684dc4
Validation with LidDrivenCavity
Joni32do Feb 5, 2024
8951662
[isINNERFluid bug]
Joni32do Feb 5, 2024
003b206
[isINNERFluid bug]
Joni32do Feb 5, 2024
ee14c5c
[ToDo fluidTracer Settings]
Joni32do Feb 5, 2024
b4e4102
tried without majority vote in fluidTracer
Joni32do Feb 5, 2024
1e7e11b
[update setVelocitySurfaceBC] prioritizes continuity
Joni32do Feb 6, 2024
ffab3c8
update SINGLE and DROPLET Vel before lunch
Joni32do Feb 6, 2024
409cc30
[read in settings FluidTracer]
Joni32do Feb 6, 2024
72d8ff6
[Correction BV for diag p]
Joni32do Feb 6, 2024
d53d3f7
fluidTracker tested for LidDrivenCavity
Joni32do Feb 7, 2024
ac577a7
added settings with bitmap
Joni32do Feb 7, 2024
23b2d14
juhuu its working again
LHRaceIng Feb 7, 2024
1768ae5
first iteration of documentation done. Fluid tracer still missing
LHRaceIng Feb 7, 2024
ca678fb
added readme docu
LHRaceIng Feb 7, 2024
fde41ea
added more documentation
LHRaceIng Feb 7, 2024
1e3265c
moooore stuff
LHRaceIng Feb 7, 2024
ba62e68
mooooooooore
LHRaceIng Feb 7, 2024
7282777
Adapted Bug in Obstacle init and FluidBorderTop
Joni32do Feb 8, 2024
426832b
[It works][Rocket debug]
Joni32do Feb 8, 2024
7246e8b
[README][input]
Joni32do Feb 8, 2024
d44244d
Update README and Doku
Joni32do Feb 8, 2024
d31ec7b
Nur noch einmal schlafen ...
Joni32do Feb 8, 2024
6575f0c
Update README
Joni32do Feb 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@ build/
resources/

sol/
input/bitmap/others
.vscode/
7 changes: 4 additions & 3 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"editor.formatOnSave": true,

"files.associations": {
"*.json": "jsonc",
"cctype": "cpp",
Expand Down Expand Up @@ -72,6 +71,8 @@
"typeindex": "cpp",
"typeinfo": "cpp",
"variant": "cpp",
"any": "cpp"
"any": "cpp",
"*.ipp": "cpp"
"*.txx": "cpp"
}
}
}
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ cmake_minimum_required(VERSION 3.8)

project(numsim)
add_subdirectory(src)
# add_subdirectory(tests)
add_subdirectory(tests)
138 changes: 134 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,142 @@ Project for the lecture Numerische Simulation at the University of Stuttgart. De
* `gcc`
* `cmake`
* `libvtk`
* `libpng`


## TODO
* Documentation with **doxygen**
* Testing
* Visualization with **Paraview**
## Run the simulation
We recommend to run the simulation using the provided bash script `build.sh`. In that file enter the path of the settings file you would like to use. You can uncomment the **doxygen** part to build the documentation. **Tests** using gtest can be executed by uncommenting the run_test line

## Adjust the settings file
For the user there is the settings.txt file that can be adjusted to
fit the specific simulation needs.

### General

* `physicalSizeX` and `physicalSizeY`: The domain size in meters. *If* bitmap has other ratio, will rescale `physicalSizeY` automatically.
* `endTime`: The endtime of the simulation in seconds.
* `re`: The reynolds number (specfies indirectly the viscosity of the fluid).
* `gX` and `gY`: Acceleration resulting from external forces.

### Domain Boundary Conditions

Subsequently the domain boundary conditions are specified. You can choose between Pressure and NoSlip.

* `BcTop`, `BcRight`, `BcBottom` and `BCLeft`: Type of boundary condition on either side of the domain. Can be either "NoSlip" or Pressure.

Then the specific values for the NoSlip domain boundary conditions follow.

* `NoSlipVelTopX/Y`: Noslip boundary velocities directly at the domain top in m/s.
* `NoSlipVelRightX/Y`: Noslip boundary velocities directly at the domain right in m/s.
* `NoSlipVelBottomX/Y`: Noslip boundary velocities directly at the domain bottom in m/s.
* `NoSlipVelLeftX/Y`: Noslip boundary velocities directly at the domain left in m/s.

Then the specific values for the Pressure domain boundary conditions follow.

* `PressureTop`: Pressure directly at the top of the domain in Pa
* `PressureRight`: Pressure directly at the right of the domain in Pa
* `PressureBottom`: Pressure directly at the bottom of the domain in Pa
* `PressureLeft`: Pressure directly at the left of the domain in Pa

### Geometry

If you want to put a rectangular object in the domain you can specfiy its location
and dimension with the following setting.

* `createRectangularObject`: Set to true if you want to add a rectangular object
* `obstaclePositionX/Y`: Position of the left lower corner of the rectangle in the domain in m
* `obstacleDimensionX/Y`: Dimension of the object in x and y direction in m

In the following you can specify wheter you want to load your domain from a bitmap.

* `createDomainfromBitmap`: Set to true if you want to load your domain from a bitmap

* `pathToBitmap`: path to the location of the bitmap saved as a png.

### Discretization

* `nCellsX/Y`: Number of cells in x and y direction as int, *if* bitmap is provided will be ignored
* `useDonorCell`: Set to true if you want to use the Donor Cell scheme
* `alpha`: Factor for donor-cell scheme between 0 and 1. 0 is equivalent to central differences
* `epsilon`: Tolerance of the 2-norm residual
* `maximumNumberOfIterations`: Maximum number of iterations of the pressure solver
* `printInterval` the time which shall pass between output vtk files

### Open surfaces

* `useFluidTracer`: Set to true if you want to simulate free surfaces
* `particlePerCell`: Number of fluid particles per cell as integer
* `useParticleSource`: Enables the creation of particle at a specified location
* `particleSourceX`, `particleSourceY`: specifies the location

Since it yielded the best results, the settings `fluidTracerMethod` is always *fixed* with `fluidTracerThreshold` of 1 as introduced in the lecture. This means that one virtual particle is enough for a cell to be declared fluid instead of e.g. $k$ or a *calculated* which aims at a constant number of fluid cells.


## Creating a domain using a bitmap
An easy way to introduce new obstacles into the domain, changing the domain
geometry or adding air cells to the domain for free surfaces simulation is to use
a bitmap. In gerneral you can use any program to create a bitmap however we recommend
[Pixilart](https://www.pixilart.com/). Here you can specify the number of pixels
in x and y direction when creating a new bitmap. These pixel numbers directly correlate to the number of cells **inside** the simulation domain. Use the Bucket
tool to fill your image with either white pixels (r:255, g:255, b:255) for air cells
or blue pixels (any color apart from white and black actually works) for fluid cells.
Then use the drawing tool to add black obstacle cells (r:0, g:0, b:0). When saving
the file, all pixels need to have a color value. If there are only black and white
pixels you will essentially simulate an empty space, so always add colored pixels
for fluid as well.

Safe the bitmap as a png, specify the path to that file in the settings.txt file
and set **createDomainfromBitmap** to true. In the input/ bitmap folder you can find
example files that you can simulate.


## Display simulation results in ParaView
You can display your simulation results using ParaView. The necessary vtk files
will be written to the `build/out` folder during simulation.

When the files are loaded into paraview you should apply a threshold to the mask
field to make obstacle visible in paraview (see image). Then use the threshold field to perform further visualizations.

![mask](media/mask.png)



## Results

### Quadrupel Lid-Driven Cavity

As an example, that there is no interaction through obstacles we implemented a somewhat circular Lid-Driven-Cavity. The settings and bitmap are provided in the `input` folder, [here](input/settings_quadruple_cavity.txt).


![Example_QuadLidDrivenCavity](media/Example_QuadLidDrivenCavity.png)

### Cavity with a step

Again the settings are provided [here](input/settings_cavity_with_a_step.txt)

![Cavity Step](media/CavityStep.png)

### Aerodynamic
With pressure Boundary Condition and a bitmap an aerodynamic shape can be simulated. The settings can be found [here](input/settings_aerodynamic_obstacle.txt).

![Aero with Glyphs](media/aero_vector.png)

### Water drop

A water drop falls with gravity in shallow fluid, where generated waves propagate.

![drop](media/drop.png)


### Dam break

A scenario which was also simulated with *OpenFOAM*. Our solver has yet to improve to achieve the same accuarcy.

<img src="media/damBreak1.png" width=200>
<img src="media/damBreak2.png" width=200>
<img src="media/damBreak3.png" width=200>

The simulation doesn't complete, since there are some mistakes in creating particles in the air, which violates the velocity condition.


## Contributors
Expand Down
37 changes: 13 additions & 24 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,26 @@ else
fi

make install -j4
# ./numsim ../input/settings_v3.txt

# run different resolution
# ./numsim ../input/different_resolutions/settings_01.txt
# ./numsim ../input/different_resolutions/settings_02.txt
# ./numsim ../input/different_resolutions/settings_03.txt
# ./numsim ../input/different_resolutions/settings_04.txt
# ./numsim ../input/different_resolutions/settings_05.txt
# ./numsim ../input/different_resolutions/settings_06.txt

# run different viscosity
# ./numsim ../input/different_re/100.txt
# ./numsim ../input/different_re/500.txt
# ./numsim ../input/different_re/2000.txt
# ./numsim ../input/different_re/10000.txt

cd ..

# directly open output in paraview
./numsim ../input/settings.txt
# ./numsim ../input/settings_aerodynamic_obstacle.txt
# ./numsim ../input/settings_damBreak.txt
# ./numsim ../input/settings_drop.txt
# ./numsim ../input/settings_quadruple_cavity.txt
# ./numsim ../input/settings_lid_driven_cavity_with_a_step.txt

# paraview out/output_*
# ./numsim ../input/settings_water_tap.txt

# for writing documentation

# cd ..
cd ..

# Documentation

# mkdir documentation
# cd documentation
# doxygen ../Doxyfile
# cd ..

# run tests
# build/tests/run_tests

zip -r submission.zip src/ CMakeLists.txt
# Tests
build/tests/run_tests
105 changes: 105 additions & 0 deletions documentation/html/annotated.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.10.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>NumSim: Class List</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
<tbody>
<tr id="projectrow">
<td id="projectalign">
<div id="projectname">NumSim<span id="projectnumber">&#160;1.0</span>
</div>
<div id="projectbrief">Numerical Simulation of fluid-flow</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.10.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
onmouseover="return searchBox.OnSearchSelectShow()"
onmouseout="return searchBox.OnSearchSelectHide()"
onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div class="header">
<div class="headertitle"><div class="title">Class List</div></div>
</div><!--header-->
<div class="contents">
<div class="textblock">Here are the classes, structs, unions and interfaces with brief descriptions:</div><div class="directory">
<div class="levels">[detail level <span onclick="javascript:dynsection.toggleLevel(1);">1</span><span onclick="javascript:dynsection.toggleLevel(2);">2</span>]</div><table class="directory">
<tr id="row_0_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classArray2D.html" target="_self">Array2D</a></td><td class="desc">This class represents a 2D array of double values </td></tr>
<tr id="row_1_" class="odd"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classBoundary.html" target="_self">Boundary</a></td><td class="desc">Class responsible to caluclate boundary conditions </td></tr>
<tr id="row_2_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classCentralDifferences.html" target="_self">CentralDifferences</a></td><td class="desc">Discretizes the problem using the central differences scheme </td></tr>
<tr id="row_3_" class="odd"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classComputation.html" target="_self">Computation</a></td><td class="desc"><a class="el" href="classComputation.html" title="Computation of Simulation.">Computation</a> of Simulation </td></tr>
<tr id="row_4_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classDiscretization.html" target="_self">Discretization</a></td><td class="desc">Computes derivatives included in governing equations </td></tr>
<tr id="row_5_" class="odd"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classDonorCell.html" target="_self">DonorCell</a></td><td class="desc">Discretizes the problem using the donor cell scheme </td></tr>
<tr id="row_6_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classFieldVariable.html" target="_self">FieldVariable</a></td><td class="desc"><a class="el" href="classDiscretization.html" title="Computes derivatives included in governing equations.">Discretization</a> of a scalar function </td></tr>
<tr id="row_7_" class="odd"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classFluidTracer.html" target="_self">FluidTracer</a></td><td class="desc"></td></tr>
<tr id="row_8_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classGaussSeidel.html" target="_self">GaussSeidel</a></td><td class="desc">Standard Gauss-Seidel solver </td></tr>
<tr id="row_9_" class="odd"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classMask.html" target="_self">Mask</a></td><td class="desc"></td></tr>
<tr id="row_10_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classOutputWriter.html" target="_self">OutputWriter</a></td><td class="desc">Inteface class for writing simulation data output </td></tr>
<tr id="row_11_" class="odd"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classOutputWriterParaview.html" target="_self">OutputWriterParaview</a></td><td class="desc">Write *.vti files that can be viewed with ParaView </td></tr>
<tr id="row_12_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classOutputWriterText.html" target="_self">OutputWriterText</a></td><td class="desc">Write *.txt files that are useful for debugging </td></tr>
<tr id="row_13_" class="odd"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classPressureSolver.html" target="_self">PressureSolver</a></td><td class="desc">Solves the Poisson problem for the pressure </td></tr>
<tr id="row_14_" class="even"><td class="entry"><span style="width:0px;display:inline-block;">&#160;</span><span id="arr_14_" class="arrow" onclick="dynsection.toggleFolder('14_')">&#9660;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="structSettings.html" target="_self">Settings</a></td><td class="desc">All settings that parametrize a simulation run </td></tr>
<tr id="row_14_0_" class="odd"><td class="entry"><span style="width:32px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="structSettings_1_1LineContent.html" target="_self">LineContent</a></td><td class="desc">Contains the content of a single line in a file </td></tr>
<tr id="row_15_" class="even"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classSOR.html" target="_self">SOR</a></td><td class="desc">Successive over-relaxation solver </td></tr>
<tr id="row_16_" class="odd"><td class="entry"><span style="width:16px;display:inline-block;">&#160;</span><span class="icona"><span class="icon">C</span></span><a class="el" href="classStaggeredGrid.html" target="_self">StaggeredGrid</a></td><td class="desc">Create field variables and define limits for the indices </td></tr>
</table>
</div><!-- directory -->
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.10.0
</small></address>
</body>
</html>
Loading