CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Modifying Velocity Boundry Field (https://www.cfd-online.com/Forums/openfoam-programming-development/114262-modifying-velocity-boundry-field.html)

vbchris March 7, 2013 17:11

Modifying Velocity Boundry Field
 
Hi all,

I am looking for help with the following code problem.
I'd like the ability to adjust the boundary fields in code without using swak4foam.

I've added the following snippet of code to bubbleFoam (OF v2.0):
Code:

label outletPatchID = mesh.boundaryMesh().findPatchID("outletBottom"); 
Ua.boundaryField()[outletPatchID] = Uabar/
                    gSum(
                    mesh.magSf().boundaryField()[outletPatchID] *
                    alpha.boundaryField()[outletPatchID]) /
                    gSum(
                    mesh.magSf().boundaryField()[outletPatchID]
                    );


Info<< nl << "Corrected Boundry Velocity = " <<
                    Uabar/
                    gSum(
                    mesh.magSf().boundaryField()[outletPatchID] *
                    alpha.boundaryField()[outletPatchID]) /
                    gSum(
                    mesh.magSf().boundaryField()[outletPatchID]
                    )
                    << endl;

Info<< "Current Boundry Field = " << endl << Ua.boundaryField()[outletPatchID] << nl << endl;

However it runs with the following console output:
Code:

Courant Number mean: 0.00492361038 max: 0.025444501
deltaT = 0.01

Corrected Boundry Velocity = (0 -0.144231961 0)
Current Boundry Field =
type            fixedValue;
value          uniform (0 -0.05 0);

UaBar is a vector(0 -0.01 0)

I would have expected both the outputs for current/corrected boundary to be the same value. However, as the debug info shows Ua.boundryField[] doesn't change after I assign it a new value.

Any help would be appreciated.

vbchris March 7, 2013 17:21

Just as a follow-up

I was mimicking this snippet of code also found in bubbleFoam, which allows explicit declaration of boundry field values using the method .boundaryField()[patchi].

Code:

// PEqn.H snippit

    forAll(p.boundaryField(), patchi)
    {
        if (isA<zeroGradientFvPatchScalarField>(p.boundaryField()[patchi]))
        {
            phiDraga.boundaryField()[patchi] = 0.0;
            phiDragb.boundaryField()[patchi] = 0.0;
        }
    }



All times are GMT -4. The time now is 00:01.