CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Modifying boundaryfield of a volscalar field (https://www.cfd-online.com/Forums/openfoam/113107-modifying-boundaryfield-volscalar-field.html)

hawkeye321 February 12, 2013 11:20

Modifying boundaryfield of a volscalar field
 
Hi FOAMERS
Can any one please let me know how can I modify the values of a volscalarfield (say variable) at boundaries? I have tried

forAll (variable.boundaryField(), facei)
{
variable.boundaryField()[facei] = modifiedvalue
}

but it does not modify all values at the boundary, and It is not clear for me which faces are modified by this loop.

nimasam February 13, 2013 08:48

im curious if it is on boundary, why dont you set it up from dictionary?

nlinder February 13, 2013 09:24

Hi Mahdi,

You need to tell on which patch you want to change the variables:
Code:

forAll (mesh.boundary(), patchI) {
    if (mesh.boundary()[patchI].name() == "desiredName") // Now it only searches for a name, maybe the type, e.g. wall or whatever, would be better
        {
            wallPatchID = patchI;
 
            forAll(variable.boundaryField()[wallPatchID], facei)
            {
                //do your stuff
            }
        }
}

BTW: You can also have a look at this thread... http://www.cfd-online.com/Forums/ope...next-wall.html

Hope it helps

greetings

hawkeye321 February 15, 2013 02:45

nimasam: I don't have any boundary condition for some of my variables

nlinder: Thanks for the answer.
By the way, do yo know the best way to set the values of a volScalarField (lets say, X) to the values interpolated from the adjacent cell centers?

nimasam February 15, 2013 03:18

however i think, if you define your field to construct from IO dictionay then, you can apply ur BC easier,
However somewhere i saw internalBoundaryField(),i guess it was in geometricField class which return cell values adjacent to BC

nlinder February 15, 2013 05:01

Why not just interpolate(). It will interpolated from the faces which "include" the information of the adjacent cells!? Or did I misunderstood what you are looking for?


All times are GMT -4. The time now is 07:47.