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

Getting internalField values from a patchField

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

Like Tree4Likes
  • 1 Post By fumiya
  • 1 Post By kmooney
  • 2 Post By fumiya

Reply
 
LinkBack Thread Tools Display Modes
Old   January 31, 2013, 13:50
Question Getting internalField values from a patchField
  #1
New Member
 
Ali Abbasi
Join Date: Apr 2012
Location: Delft, The Netherlands
Posts: 12
Rep Power: 4
aabbasi59 is on a distinguished road
Send a message via Skype™ to aabbasi59
Dear Foamers,

I am trying to develop a 1-D heat transfer model. I have a source term in Laplacian Equation. This term is a function of time. I have defined a volscalarField(R) in createFields. For each run time I need to put the internalField values of this volscalarField(R) equal to the its values in one of the boundary patch. I mean R values in the whole domain are equal to its value on the specific boundary patch.

I am looking forward hearing your advice.
Your advice is appreciated in advance.

Ali
aabbasi59 is offline   Reply With Quote

Old   February 1, 2013, 21:55
Default
  #2
Senior Member
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 163
Rep Power: 6
fumiya is on a distinguished road
Hi Ali,

You can use the following code if the boundary value of R is constant
on your specific boundary patch.

Code:
// find the patch label
label PatchID = mesh.boundaryMesh().findPatchID("your patch name"); 
label FaceID = 0;

forAll(R, cellI)
{
    R[cellI] = R.boundaryField()[PatchID][FaceID];
}
If the boundaryField of R on your patch is nonuniform, you need to
change the FaceID.

Hope that helps,
Fumiya
aabbasi59 likes this.
fumiya is offline   Reply With Quote

Old   February 8, 2013, 11:58
Default
  #3
New Member
 
Ali Abbasi
Join Date: Apr 2012
Location: Delft, The Netherlands
Posts: 12
Rep Power: 4
aabbasi59 is on a distinguished road
Send a message via Skype™ to aabbasi59
Dear fumiya,
Thank you so much for your post. It was very helpul.
But there is a problem:
I used the specfied code in my code. It works only for the first time step and It doesn't work for remaining time steps. I have put it in the time loop but unfortunately it works only for the first time step. It should be mentioned that there isn't any errors in compiling the code.
Any advice is appreciated.
Thanks,
Ali
aabbasi59 is offline   Reply With Quote

Old   February 15, 2013, 10:20
Default
  #4
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 267
Rep Power: 8
kmooney is on a distinguished road
Hi Ali,

Do you have any more information other than 'it didn't work'? Is the internal field not updating? Is it crashing?
aabbasi59 likes this.
kmooney is offline   Reply With Quote

Old   February 22, 2013, 12:48
Default This problem has been solved!!
  #5
New Member
 
Ali Abbasi
Join Date: Apr 2012
Location: Delft, The Netherlands
Posts: 12
Rep Power: 4
aabbasi59 is on a distinguished road
Send a message via Skype™ to aabbasi59
Dear kmooney,
Thanks for your post.
I solved this problem. I needed to read a variable from a text file(for example R) and then calculate a parameter in the domain in each point and in each time step. My model is a 1-D model and I thought the best way was to create a "volScalarField" and then put it equal to "R" in each time step because I wanted to calculate another parameter(for instance Rn) that is a function of "R". I have understood that this method hasn't been good and using the "interpolationTable" for time steps would be better. So I have used "interpolationTable" in my code and the mentioned problem was solved.

Regards,
Ali
aabbasi59 is offline   Reply With Quote

Old   April 12, 2013, 16:02
Default
  #6
New Member
 
Giancarlo
Join Date: Apr 2013
Location: Milan
Posts: 18
Rep Power: 3
Giancarlo_IngChimico is on a distinguished road
Hi all,
I have a similar problem.

I have a patch named "fluid_to solid" in my mesh. In order to copy the values of a field in correspondence to this specific patch I have written the following code:

Code:
    forAll( TFluid[j].boundaryField(), patchi)
    {
        label patchID = fluidRegions[j].boundaryMesh().findPatchID("fluid_to_solid"); 
        forAll( TFluid[j].boundaryField()[patchID], facei)
            {
                Tf[facei+1] = TFluid[j].boundaryField()[patchID][facei]; 
            }
                    
    }
Now I have to copy the values of TFluid[j].internalField() at the same patch "fluid_to_solid".

Can anyone help me?


Regards


Giancarlo
Giancarlo_IngChimico is offline   Reply With Quote

Old   April 13, 2013, 11:00
Default
  #7
Senior Member
 
kmooney's Avatar
 
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA - San Diego, CA USA
Posts: 267
Rep Power: 8
kmooney is on a distinguished road
Hi Giancarlo,

.internalField() returns cell centered values for any volume field. You might be mistaken if you are attempting to copy cell centered values to patch faces.


Quote:
Originally Posted by Giancarlo_IngChimico View Post
Hi all,
I have a similar problem.

I have a patch named "fluid_to solid" in my mesh. In order to copy the values of a field in correspondence to this specific patch I have written the following code:

Code:
    forAll( TFluid[j].boundaryField(), patchi)
    {
        label patchID = fluidRegions[j].boundaryMesh().findPatchID("fluid_to_solid"); 
        forAll( TFluid[j].boundaryField()[patchID], facei)
            {
                Tf[facei+1] = TFluid[j].boundaryField()[patchID][facei]; 
            }
                    
    }
Now I have to copy the values of TFluid[j].internalField() at the same patch "fluid_to_solid".

Can anyone help me?


Regards


Giancarlo
kmooney is offline   Reply With Quote

Old   April 13, 2013, 13:42
Post
  #8
New Member
 
Giancarlo
Join Date: Apr 2013
Location: Milan
Posts: 18
Rep Power: 3
Giancarlo_IngChimico is on a distinguished road
I kmooney I haven't been quite clear. I have a multi region mesh ( fluid and solid). The interface between these regions in named "fluid_to_solid".
I want to know the internalField value not for all cells in the fluid region, but only the value of cells located at interface. With the code that I post first I get the boundary value of a generic field for the cells of interest but my problem is the internal field.

I hope that I was more clear now.

Regards

Giancarlo
Giancarlo_IngChimico is offline   Reply With Quote

Old   April 13, 2013, 14:13
Default
  #9
Senior Member
 
immortality's Avatar
 
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,174
Rep Power: 16
immortality is on a distinguished road
hi where should add your first code?
immortality is offline   Reply With Quote

Old   November 30, 2013, 17:22
Question
  #10
Senior Member
 
Join Date: Nov 2012
Posts: 168
Rep Power: 4
hz283 is on a distinguished road
Dear fumiya,

I would like to store the wall heat flux from the wall boundary faces into the cell centers (the cell is the one the wall face belongs to) because I will use the wall heat flux as a source term in another governing equations. So the goal is to store the wall heat flux originally in the boundary Fields of the heat flux (volScalarField) to the internal Fields. In this case, non-zero heat flux should exist for those cells neighboring to solid walls but the internal cells should still be zero. Following the suggestions from you in the post, I get the following code. But using it I found that my goal is still not reached because I do not know why all the cell centers have the non-zero heat flux, which is not correct I think. Could you please me to have a look at the following lines, Thank you very much.


// calculate the wall heat flux
const surfaceScalarField::GeometricBoundaryField& patchHeatFlux =
heatFlux.boundaryField();

forAll(wallHeatFlux.boundaryField(), patchi)
{
if(patchi == mesh.boundary().findPatchID("WALL"))
{
wallHeatFlux.boundaryField()[patchi] = patchHeatFlux[patchi];

label FaceID = 0;
forAll(wallHeatFlux, cellI)
{
forAll(wallHeatFlux.boundaryField()[patchi], FaceID)
{
wallHeatFlux[cellI] = wallHeatFlux.boundaryField()[patchi][FaceID];
}
}
}
}


Quote:
Originally Posted by fumiya View Post
Hi Ali,

You can use the following code if the boundary value of R is constant
on your specific boundary patch.

Code:
// find the patch label
label PatchID = mesh.boundaryMesh().findPatchID("your patch name"); 
label FaceID = 0;

forAll(R, cellI)
{
    R[cellI] = R.boundaryField()[PatchID][FaceID];
}
If the boundaryField of R on your patch is nonuniform, you need to
change the FaceID.

Hope that helps,
Fumiya

Last edited by hz283; November 30, 2013 at 18:57.
hz283 is offline   Reply With Quote

Old   December 1, 2013, 02:45
Default
  #11
Senior Member
 
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 163
Rep Power: 6
fumiya is on a distinguished road
Hi hz283,

You might want to try the following code:

Code:
forAll(mesh.boundary(), patchI) // patch loop
{
    if(mesh.boundary()[patchI].name()=="WALL")
    {
        wallHeatFlux.boundaryField()[patchI] = patchHeatFlux[patchI];

        forAll(mesh.boundary()[patchI], faceI)
        {
            wallHeatFlux[mesh.boundary()[patchI].faceCells()[faceI]] =
                wallHeatFlux.boundaryField()[patchI][faceI];
        }
    }
}
You can use the "faceCells" function to get the cell label adjacent to a patch.

Hope this helps,
fumiya
snak and hz283 like this.
fumiya is offline   Reply With Quote

Reply

Tags
heat transfer, internalfields, laplacian

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
Elementwise multiplication operator johndeas OpenFOAM Running, Solving & CFD 2 May 14, 2012 09:45
max node values exceed max element values in contour plot jason_t FLUENT 0 August 19, 2009 11:32
exact face values RubenG Main CFD Forum 0 June 22, 2009 11:09
strange node values @ solid/fluid interface - help JB FLUENT 2 November 1, 2008 13:04
A stupid question luckyluke OpenFOAM Running, Solving & CFD 14 August 13, 2007 04:25


All times are GMT -4. The time now is 08:41.