CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > OpenFOAM

writing modified U, but U was not change at all ?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   November 17, 2009, 23:37
Default writing modified U, but U file was not changed ?
  #1
Senior Member
 
Jiang
Join Date: Oct 2009
Location: Japan
Posts: 186
Rep Power: 7
panda60 is on a distinguished road
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.

Last edited by panda60; November 18, 2009 at 01:11.
panda60 is offline   Reply With Quote

Old   November 18, 2009, 02:37
Default
  #2
Senior Member
 
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 8
kathrin_kissling is on a distinguished road
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
kathrin_kissling is offline   Reply With Quote

Old   November 18, 2009, 03:30
Default
  #3
Senior Member
 
Jiang
Join Date: Oct 2009
Location: Japan
Posts: 186
Rep Power: 7
panda60 is on a distinguished road
Quote:
Originally Posted by kathrin_kissling View Post
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.
panda60 is offline   Reply With Quote

Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solid/liquid phase change fabian_roesler OpenFOAM 10 December 24, 2012 07:37
Topo change doum OpenFOAM Running, Solving & CFD 0 June 22, 2007 16:26
Writing UDF for Unsteady Temperature change ? Baggi FLUENT 0 April 12, 2006 17:27
no enthalpy change across the momentum source Atit Koonsrisuk CFX 2 December 19, 2005 03:33
Multicomponent fluid Andrea CFX 2 October 11, 2004 05:12


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