|
[Sponsors] |
October 19, 2017, 13:30 |
forAll does not loop over boundary cells
|
#1 |
Senior Member
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 16 |
Hi All
I coded something like this Code:
forAll(alfa, celli) { alfa[celli] = scalar(2); } and I get run-time error that it is divided by zero. I found out that boundary cells of alfa are set to zero. Do I have to do the second loop over boundary cells or there is a much finer solution to loop over internal and boundaryField in one loop?
__________________
best regards pblasiak |
|
October 30, 2017, 06:07 |
|
#2 | |
Member
|
Quote:
OpenFOAM treats internal and boundary fields separately. Generally, the boundary values are specified using an appropriate boundary condition in the '0' folder. However, you can still access and modify the boundary values within your solver. Code:
forAll(mesh.boundary(), patchID) { forAll (mesh.boundary()[patchID],facei) { alfa.boundaryField()[patchID][facei] = 2.0; } }
__________________
Jibran Haider |
||
October 30, 2017, 06:23 |
|
#3 |
Senior Member
Przemek
Join Date: Jun 2011
Posts: 249
Rep Power: 16 |
Hi Jibran,
Thank you for your reply. It means that I always has to do two loops, through internal and boundary field. Ok, thank you for explanations.
__________________
best regards pblasiak |
|
August 29, 2019, 18:09 |
|
#4 |
Member
Elwardi Fadeli
Join Date: Dec 2016
Location: Boumerdes, Algeria
Posts: 41
Rep Power: 10 |
Yes, you have to treat internalField and boundaryField differently in most cases (or at least use field.correctBoundaryConditions() after the loop on internalField) especially if using some macro (like forAll) which will certainly hide C++ syntax, and most new programmers will become confused.
Of course, there are some containers that aren't compatible with forAll even though applying it on them seems logical. Recent versions of OpenFOAM will accept volScalarField:perator[](int) for example to access "internalField" (either dimensioned or not, I don't remember ). More on this in this blog post of mine if you intend to dig a little deeper. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Out File does not show Imbalance in % | Mmaragann | CFX | 5 | January 20, 2017 11:20 |
An error has occurred in cfx5solve: | volo87 | CFX | 5 | June 14, 2013 18:44 |
[snappyHexMesh] external flow with snappyHexMesh | chelvistero | OpenFOAM Meshing & Mesh Conversion | 11 | January 15, 2010 20:43 |
physical boundary error!! | kris | Siemens | 2 | August 3, 2005 01:32 |
Convective Heat Transfer - Heat Exchanger | Mark | CFX | 6 | November 15, 2004 16:55 |