|
[Sponsors] |
Can I avoid loop over boundaries in forAll loop? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
September 6, 2021, 05:30 |
Can I avoid loop over boundaries in forAll loop?
|
#1 |
Senior Member
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15 |
Hi
I have a volScalarField defined in standard manner: Code:
rho ( IOobject ( "rho", U.mesh().time().timeName(), U.mesh(), IOobject::NO_READ, IOobject::NO_WRITE ), U.mesh(), dimensionedScalar("rho", dimDensity, 0.0) ) However, in the program I get divide error because the forAll loop sets values only in cells and at the boundaries the 0 is left. I solved it by applying the second forAll loop over boundary patches but it slows down the calculations remarkably. Is there any method to avoid the second loop over patches?
__________________
best regards pblasiak |
|
September 7, 2021, 00:09 |
|
#2 |
Member
Francisco T
Join Date: Nov 2011
Location: Melbourne, Australia
Posts: 64
Blog Entries: 1
Rep Power: 14 |
This reminded me a case where div by zero is fixed.
To prevent that code blows up due to a division by zero in a viscosity calculation, it is advised to add SMALL. SMALL is a static constant scalar included in https://www.openfoam.com/documentati...8H_source.html for example return nu0_/scalar(1) + pow(k_* strainRate() + SMALL, (1-n)); perhaps you can try a similar approach? ................... (also, I just edited my response) You can also write Zero this is done in BC initialization new Field<Type>(this->size(), Zero) https://develop.openfoam.com/Develop...FvPatchField.C Last edited by frantov; September 7, 2021 at 05:24. |
|
September 7, 2021, 08:13 |
|
#3 | |
Senior Member
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 15 |
Quote:
Hi Frantov, Thank you very much for your hint. It is good solution however it does not solve my problem. I need to set the values at the boundaries in each iteration the same as in the cells that adhere to the boundaries. A while ago I found the solution: 1) added the line at the end of rho constructor Code:
"zeroGradient" Code:
rho.correctBoundaryConditions(); I hope it is correct and gives the same results
__________________
best regards pblasiak Last edited by gaza; September 7, 2021 at 11:16. |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Glyph: how to avoid the plot of vectors perpendicular to boundaries? | serena | OpenFOAM Post-Processing | 6 | October 22, 2019 04:37 |
Need help setting up chtMultiRegion | OskarT | OpenFOAM Pre-Processing | 1 | September 25, 2019 15:51 |
[Gmsh] Problem with Gmsh | nishant_hull | OpenFOAM Meshing & Mesh Conversion | 23 | August 5, 2015 02:09 |
[ICEM] How to avoid single edges at boundaries in 2D models? | Gandin | ANSYS Meshing & Geometry | 12 | October 16, 2014 06:00 |
lid-driven cavity in matlab using BiCGStab | Don456 | Main CFD Forum | 1 | January 19, 2012 15:00 |