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

writing the boundary information using U.write()

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

Reply
 
LinkBack Thread Tools Display Modes
Old   June 6, 2014, 12:06
Question writing the boundary information using U.write()
  #1
Senior Member
 
Join Date: Jan 2013
Posts: 252
Rep Power: 6
openfoammaofnepo is on a distinguished road
Dear All,

I used the following to write out a new variable:
Code:
U_new=U;
U_new.write();
However, I found that in the U_new file, for the boundary conditions, their types are all "calculated", not the original ones, like:

Code:
wall
{
    type calculated;
    value uniform (0 0 0); 
}
Originally, it should be like:

Code:
wall
{
    type fixedValue;
    value uniform (0 0 0); 
}
Does anybody know how to write out the boundary type information correctly? Thank you in advance.

OFFO
openfoammaofnepo is offline   Reply With Quote

Old   June 6, 2014, 22:49
Default
  #2
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Pennsylvania, United States
Posts: 101
Rep Power: 7
adhiraj is on a distinguished road
Does this work?
Code:
volVectorField U_new
                    (
                     IOobject(
                              "U_new",
                              mesh.time().timeName(),
                              mesh,
                              IOobject::NO_READ,
                              IOobject::NO_WRITE
                             ),
                      mesh,   
                      dimensionedVector("zero",dimensionSet(0,1,-1,0,0,0,0),Foam::vector(0,0,0) ),
                      U.boundaryField().types()                       
                    )
Then you can assign like this:
Code:
U_new=U;
U_new.write();
adhiraj is offline   Reply With Quote

Old   June 7, 2014, 05:22
Default
  #3
Senior Member
 
Join Date: Jan 2013
Posts: 252
Rep Power: 6
openfoammaofnepo is on a distinguished road
It works well. Thank you very much!
openfoammaofnepo is offline   Reply With Quote

Old   June 7, 2014, 19:29
Default
  #4
Senior Member
 
Join Date: Jan 2013
Posts: 252
Rep Power: 6
openfoammaofnepo is on a distinguished road
Dear Adhiraj,

I found that when I use the above lines to write out the U_new, the values at the boundaries are still not correct, although the boundary type is correct now. for example:

about the turbulentInlet BC:

Code:
type turbulentInlet
value nonuniform<List>
(100e+100 100e+200 100d+200
...
...)
Here the values of the BCs are not reasonable, they are correctly given from U. Do you have any comments about this?Thank you.
OFFO
openfoammaofnepo is offline   Reply With Quote

Old   June 8, 2014, 06:49
Default
  #5
Senior Member
 
Join Date: Jan 2013
Posts: 252
Rep Power: 6
openfoammaofnepo is on a distinguished road
Hello,

it seems I still have some difficulty in writing out the new fields. The task is like: I have a old field, called U, and then did some treatment in the interalFields of U. I will try to write out the new internalField but old boundaryField into a new field, called U_c.

The code is as follows:
Code:
            volVectorField U_c
            (
                IOobject
                (
                    "U_c",
                    runTime.timeName(),
                    mesh,
                    IOobject::NO_READ,
                    IOobject::AUTO_WRITE
                ),
                mesh,
                dimensionedVector
                (
                 "U_c",
                 U.dimensions(),
                 vector(0,0,0)
                ),
                U.boundaryField().types()
            );

            vectorField& Ucell = U.internalField();
            vectorField& U_ccell = U_c.internalField();
            forAll(cellcentre,celli)
            {
                U_ccell[celli] = Ucell[celli];
                //.................some operations here. 
            }

            forAll(U.boundaryField(), patchi)
            {
                fvPatchVectorField& pU   = U.boundaryField()[patchi];
                fvPatchVectorField& pU_c = U_c.boundaryField()[patchi];

                forAll(pU, facei)
                {
                    pU_c[facei] = pU[facei];
                }
            }

            U_c.write();
The problem is:
The boundary type is correct written out. However, the values on the patches are not correctly output. The values on some patches are random numbers-very small or large numbers.

Could anyone tell me what I am missing in the above code?
openfoammaofnepo is offline   Reply With Quote

Old   August 16, 2014, 07:49
Default
  #6
Super Moderator
 
Bruno Santos
Join Date: Mar 2009
Location: Lisbon, Portugal
Posts: 9,219
Blog Entries: 35
Rep Power: 94
wyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nicewyldckat is just really nice
Greetings to all!

@OFFO:
Quote:
Originally Posted by openfoammaofnepo View Post
Could anyone tell me what I am missing in the above code?
Have you been able to solve this issue?

If you haven't, are you certain you're providing the complete code that you are using for manipulating "U_c"?
I ask this because "U_c" is created with the option "IOobject::AUTO_WRITE", which means that at the end of an iteration, it will also write the field once again. This could mean that the "U_c" field is being altered between the time it was written with the explicit call to ".write()" and the end of the run time loop.

Best regards,
Bruno
wyldckat 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
Implementation of boundary conditions for FVM Tom Main CFD Forum 7 August 26, 2014 05:58
Radiation interface hinca CFX 15 January 26, 2014 18:11
Concentric tube heat exchanger (Air-Water) Young CFX 5 October 6, 2008 23:17
Multicomponent fluid Andrea CFX 2 October 11, 2004 05:12
Boundary conditions? Tom Main CFD Forum 0 November 5, 2002 02:54


All times are GMT -4. The time now is 00:56.