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/)
-   -   Accessing boudaryField (https://www.cfd-online.com/Forums/openfoam-programming-development/188549-accessing-boudaryfield.html)

Sugajen June 1, 2017 15:29

Accessing boundaryField
 
Hi all,

I am trying to access the boundaryField of velocity and modify that and use it for the next time step calculations. I read in the post https://www.cfd-online.com/Forums/op...read-only.html that we have to use boundaryFieldRef inorder to access it, else it throws an error saying the field is read only. I did as suggested but still the values are not reflected on the output. Are Ref fields only for reference and not for next time step or post-processing?

Below is my piece of code in the solver that converts a scalarField'Jw' into a vectorField 'U'.
Code:

label upMem = mesh.boundaryMesh().findPatchID("upperMembrane");
forAll( U.boundaryFieldRef()[upMem], i)
{
        U.boundaryFieldRef()[upMem][i].component(vector::X) = 0;
        U.boundaryFieldRef()[upMem][i].component(vector::Y) = 0;
        U.boundaryFieldRef()[upMem][i].component(vector::Z) = Jw.boundaryFieldRef()[upMem][i];

}


Sugajen June 2, 2017 14:17

Solved
 
I was using noSlip boundary condition for U on the patches where I wanted to change the values. When I changed it to fixed Value (0,0,0), the code that I wrote in the solver was implemented. Hope that helps anyone else with similar issue!


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