CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   writing modified U, but U was not change at all ? (http://www.cfd-online.com/Forums/openfoam/70227-writing-modified-u-but-u-not-change-all.html)

panda60 November 17, 2009 23:37

writing modified U, but U file was not changed ?
 
Dear all:
I want to use U inflow profile, so I write a utility. First time it is victory. But when I run another case, U was not changed at all.
Although the screen has display that: writing modified U
End
But U acctually was not modified. I don't khow why. Because some other case has victory, why this case was not change.

How can I do this ?
Thank you very much.

This is my U file:

FoamFile
{
version 2.0;
format ascii;
class volVectorField;
location "0";
object U;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

dimensions [0 1 -1 0 0 0 0];

internalField uniform (0.1 0 0);

boundaryField
{
GAS_INLET
{
type fixedValue;
value uniform (0 1.8 0);
}
INLET
{
type fixedValue;
value uniform (1 0 0);
}
OUTLET
{
type zeroGradient;
}
SYM_LEFT
{
type symmetryPlane;
}
SYM_RIGHT
{
type symmetryPlane;
}
SYM_TOP
{
type symmetryPlane;
}
GROUND
{
type fixedValue;
value uniform (0 0 0);
}
BUILDING
{
type fixedValue;
value uniform (0 0 0);
}
}


This my code:

#include "fvCFD.H"
#include "OSspecific.H"
#include "fixedValueFvPatchFields.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

int main(int argc, char *argv[])
{

# include "setRootCase.H"

# include "createTime.H"
# include "createMesh.H"
# include "createFields.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

volVectorField::GeometricBoundaryField& Upatches = U.boundaryField();

forAll(Upatches, patchI)
{
if
(
(typeid(Upatches[patchI]) == typeid(fixedValueFvPatchVectorField))
&&
(mesh.boundaryMesh()[patchI].name() == "INLET")
)

{
fixedValueFvPatchVectorField& Upatch =
refCast<fixedValueFvPatchVectorField>(Upatches[patchI]);

const vectorField& faceCentres =
mesh.Cf().boundaryField()[patchI];

forAll(faceCentres, facei)
{
scalar y = faceCentres[facei].y();
scalar Ux= 32.4*y+1.6;
scalar Uy=0.0;
scalar Uz=0.0;
Upatch[facei] = vector(Ux,Uy,Uz);
}
};

Info<< "Writing modified field U\n" << endl;
U.write();

Info<< "End\n" << endl;

return 0;
}

I have checked, if condition was not satisfied, so circle was not going on ,
I don't khow why "if( )" is not satisfied.

kathrin_kissling November 18, 2009 02:37

Hi Panda,

you need to go U[patchI] == vector(Ux, Uy, Uz).
In any other way the boundary conditions don't get overwritten.
== forces the field to be overwritten.
This has something to do with the inhereitance of the operators for the fixedValue boundary condition = does nothing, so you need == which actually overwrites.

Hope this helps

Best

Kathrin

panda60 November 18, 2009 03:30

Quote:

Originally Posted by kathrin_kissling (Post 236711)
Hi Panda,

you need to go U[patchI] == vector(Ux, Uy, Uz).
In any other way the boundary conditions don't get overwritten.
== forces the field to be overwritten.
This has something to do with the inhereitance of the operators for the fixedValue boundary condition = does nothing, so you need == which actually overwrites.

Hope this helps

Best

Kathrin

Dear Kathrin
the code internal of if() is not going on. Because I have checked that"(mesh.boundaryMesh()[patchI].name() == "INLET") " is not satisfied.
If it is because my grid have problem.


All times are GMT -4. The time now is 20:48.