|
[Sponsors] |
July 7, 2023, 20:50 |
|
#21 |
Member
Anders Aamodt Resell
Join Date: Dec 2021
Location: Oslo, Norway
Posts: 64
Rep Power: 4 |
Ok, so you would extend the gradient and flux limiter containers to also contain the ghost cells, but set these values to zero, store boundary conditions defined at the faces in the ghost cells, and then only require one loop over all faces to evaluate the flux balance? I guess this is a tradeoff between memory usage and code complexity then.
I’ve also noticed that I need to need to use function pointers, inherited overloaded functions or something like this when implementing this stuff, when the given setting is read from a config file or similar and not known at compile time. (using C++ in my case, but I guess this need arise regardless of the language). Not sure how much slower this is compared to versions of the same code where the actual function used (for instance flux scheme or boundary condition) was known at compile time and could be inlined. |
|
July 10, 2023, 12:40 |
|
#22 | |
Senior Member
Matthew
Join Date: Mar 2022
Location: United Kingdom
Posts: 175
Rep Power: 4 |
Quote:
f_j=0.5*(f_(j-1)+f_(j+1)) If you have a condition which states that the velocity is zero at a boundary, you have that: 0=0.5*(f_(-1)+f_1) => f_(-1)=-f_1 That should keep the boundary condition into your conservation law. |
||
July 10, 2023, 14:32 |
|
#23 | |
Senior Member
|
Quote:
1 - loop over patches with faces sharing the same boundary conditions 2 - in the previous loop, use if statements to detect the patch bc and pass the relative bc function (fp) to another function that actually applies the bc (fb) 3 - fb does a loop on the faces of the current patch and uses the passed in fp to actually apply the bc fluxes 4 - loop over the remaining interior faces and just use the standard flux of the used scheme The day this is going to be my bottleneck I will reconsider it (not the specific approach I am using, this whole aspect independently from the specific implementation in use). But may I be damned if this will ever happen. There's much more around to keep under control: the actual convective scheme (say, Roe), the linear iterations for the implicit scheme and the gradient computations are typically much more costly |
||
July 18, 2023, 10:38 |
|
#24 |
Member
Anders Aamodt Resell
Join Date: Dec 2021
Location: Oslo, Norway
Posts: 64
Rep Power: 4 |
This approach seems conceptually quite similar to the approach I have chosen for my hobby code project then, the exception being that I have used ghost cells instead of direct flux computation.
Don't know what language you are using (I assume C++ or Fortran). I use C++ and chose virtual overloaded functions instead of function pointers for the purpose of calculating ghost values from a boundary condition. Not really sure if there is a performance gap between these two. I have used function pointers for the convective scheme though. My understanding is that it is beneficial to use inlined functions for functions called within a large loop performance wise, but this seems hard to to in general, when various solver settings are not known at compile time. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
CFX translational periodic boundaries problem | kveki | CFX | 5 | December 19, 2022 17:39 |
How to use "translation" in solidBodyMotionFunction in OpenFOAM | rupesh_w | OpenFOAM Running, Solving & CFD | 5 | August 16, 2016 04:27 |
2D Rotating Detonation Engine Periodic Boundaries | whitet86 | FLUENT | 2 | June 25, 2015 11:04 |
Setting Flow/Pressure Boundaries in Floworks | Eran | FloEFD, FloWorks & FloTHERM | 3 | August 11, 2009 04:23 |
mass flux correction at outflow boundaries | Subhra Datta | Main CFD Forum | 2 | November 24, 2003 13:11 |