forAll does not loop over boundary cells
Hi All
I coded something like this Code:
forAll(alfa, celli) 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? |
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) |
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. |
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::operator[](int) for example to access "internalField" (either dimensioned or not, I don't remember :eek:). More on this in this blog post of mine if you intend to dig a little deeper. |
All times are GMT -4. The time now is 23:00. |