|
[Sponsors] |
November 18, 2018, 19:31 |
Problem in Writing Field U
|
#1 |
New Member
Aria
Join Date: Jul 2018
Posts: 2
Rep Power: 0 |
Hi foamers,
I'm trying to write the velocity field with a different name in each time directory, then I write this code in creatFields.H of my solver (let's say mybuoyantBoussinesqPimpleFoam): Code:
Info<< "Calculating myName\n" << endl volVectorField myName ( IOobject ( "myName", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), U ); Code:
dimensions [0 1 -1 0 0 0 0]; internalField uniform (0 0 0); boundaryField { upperWall { type fixedValue; value uniform (0 0 0); } leftWall { type fixedValue; value uniform (0 0 0); } rightWall { type fixedValue; value uniform (0 0 0); } frontAndBack { type empty; } } Code:
Info<< "Reading field U\n" << endl; volVectorField U ( IOobject ( "U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); Thanks |
|
November 20, 2018, 10:07 |
|
#2 |
New Member
Amir
Join Date: Oct 2018
Posts: 17
Rep Power: 7 |
Hi,
can you please help me with this? I have the same problem with writing gradU! Wrong shear rate result with the existing code thanks |
|
November 21, 2018, 09:04 |
|
#3 |
Senior Member
Lucky
Join Date: Apr 2011
Location: Orlando, FL USA
Posts: 5,675
Rep Power: 66 |
createFields is called only at startup to initialize fields to make places for them in memory.
You defined myName = U in createFields. During startup your field myName will be set equal to the current values for U (if your startTime is 0 then then myName will take on the values of U at 0). If you do nothing else, the field myName never gets updated again ever and stays at the initial values. You need to go into your mybuoyantBoussinesqPimpleFoam.c and add a line that looks like this. The best place to put this is immediately before runTime.write(); Code:
volVectorField myName ( U ); runTime.write(); The reason U works is because there is more to a solver than createFields.H. There is a pEqn.H and UEqn.H where all the magic of foam happens and you calculate a new U. createFields only establishes whether a field is writable and initializes it. It doesn't do anything else. The fields are written when runTime.write() is called. The values of each field when runTime.write() is called is what gets written. Also instead of using IOobject::MUST_READ you can probably use the NO_READ option since there's never any point to reading the myName field from the disk. It's always equal to U isn't it? |
|
November 22, 2018, 17:36 |
|
#4 | |
New Member
Aria
Join Date: Jul 2018
Posts: 2
Rep Power: 0 |
Quote:
Hi LuckyTran, thanks for the tips. I tried adding your suggested code in time loop before runTime.write() : Code:
volVectorField myName ( U ); |
||
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Problem with cyclic boundaries in Openfoam 1.5 | fs82 | OpenFOAM | 36 | January 7, 2015 00:31 |
Moving mesh | Niklas Wikstrom (Wikstrom) | OpenFOAM Running, Solving & CFD | 122 | June 15, 2014 06:20 |
Problem in sampling data of custom field function in ANSYS FLUENT v14 | apek_great | ANSYS | 1 | February 26, 2014 05:10 |
Surface Vector Field Problem at Parallel | cwang5 | OpenFOAM Bugs | 6 | July 12, 2010 08:31 |
pressure field problem. | michal | FLUENT | 1 | March 18, 2004 14:45 |