CFD Online Discussion Forums

CFD Online Discussion Forums (
-   OpenFOAM Running, Solving & CFD (
-   -   Please give advice and help for the change the x y and z in U (

liugx212 December 17, 2005 17:21

Dear all: I want to modify
Dear all:

I want to modify the x, y and z value of U. What do I do? Could you please give help?

Thank you very much,

alberto December 18, 2005 09:35

If you mean the U components o
If you mean the U components of the initial condition, open the


directory and edit the U file according to your needs.


alberto December 18, 2005 09:38

Sorry, read "initial condition
Sorry, read "initial condition" as "initial or baoundary conditions".

liugx212 December 18, 2005 14:24

Dear Alberto Passalacqua: T
Dear Alberto Passalacqua:

Thanks a lot.
I have read the initial value. I mean I want to change them after read in icoFoam.C. And I have add the code. But some errors is here when I run it. Could you please give more help.

// modifying the value of the U
volScalarField Ux = U.component(vector::X);
volScalarField Uy = U.component(vector::Y);
volScalarField Uz = U.component(vector::Z);

const vectorField& centers = mesh.C().internalField();
forAll (centers, celli)
double angle = 180;
Ux = Ux*Foam::sin(angle);
Uy = Uy*Foam::cos(angle);
Uz = 0;


--> FOAM FATAL ERROR : Different dimensions for =
dimensions : [0 1 -1 0 0 0 0] = [0 0 0 0 0 0 0]

From function dimensionSet::operator=(const dimensionSet& ds) const
in file dimensionSet/dimensionSet.C at line 158.

FOAM aborting


Thank you very much.

niklas December 19, 2005 03:15

There are two major mistakes i
There are two major mistakes in the above code.
First, you are working on a copy of the U field.
what you probably want is to create a reference.
You should then use volScalarField& instead.

Second, you are looping over the cells which probably means that you want to get the cell values,i.e
Ux[celli] = U[celli].component(vector::X) etc...

third, Xian you have posted an identical question on another topic (under a really useles topic since it applies on every post in here), this is REALLY bad. Now we have 2 forums to talk about the same thing and you have done this before: I am begging you on my knees.
Please dont do it again or you will go on my ignore list.


liugx212 December 19, 2005 23:45

Dear Niklas Nordin: Thanks
Dear Niklas Nordin:

Thanks a lot.

You are right. But I only worry nobody to see. Since somebody were noticed, I surely do as you said.

Thanks again.

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