|
[Sponsors] |
writing modified U, but U was not change at all ? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
November 17, 2009, 22:37 |
writing modified U, but U file was not changed ?
|
#1 |
Senior Member
Jiang
Join Date: Oct 2009
Location: Japan
Posts: 186
Rep Power: 17 |
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 00:11. |
|
November 18, 2009, 01:37 |
|
#2 |
Senior Member
Kathrin Kissling
Join Date: Mar 2009
Location: Besigheim, Germany
Posts: 134
Rep Power: 17 |
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 |
|
November 18, 2009, 02:30 |
|
#3 | |
Senior Member
Jiang
Join Date: Oct 2009
Location: Japan
Posts: 186
Rep Power: 17 |
Quote:
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. |
||
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Solid/liquid phase change | fabian_roesler | OpenFOAM | 10 | December 24, 2012 06: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 02:33 |
Multicomponent fluid | Andrea | CFX | 2 | October 11, 2004 05:12 |