
[Sponsors] 
January 31, 2013, 13:50 
Getting internalField values from a patchField

#1 
New Member

Dear Foamers,
I am trying to develop a 1D 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 

February 1, 2013, 21:55 

#2 
Senior Member
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 168
Rep Power: 7 
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]; } change the FaceID. Hope that helps, Fumiya 

February 8, 2013, 11:58 

#3 
New Member

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 

February 15, 2013, 10:20 

#4 
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA  San Diego, CA USA
Posts: 268
Rep Power: 8 
Hi Ali,
Do you have any more information other than 'it didn't work'? Is the internal field not updating? Is it crashing? 

February 22, 2013, 12:48 
This problem has been solved!!

#5 
New Member

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 1D 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 

April 12, 2013, 16:02 

#6 
New Member
Giancarlo
Join Date: Apr 2013
Location: Milan
Posts: 18
Rep Power: 4 
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]; } } Can anyone help me? Regards Giancarlo 

April 13, 2013, 11:00 

#7  
Senior Member
Kyle Mooney
Join Date: Jul 2009
Location: Amherst, MA USA  San Diego, CA USA
Posts: 268
Rep Power: 8 
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:


April 13, 2013, 13:42 

#8 
New Member
Giancarlo
Join Date: Apr 2013
Location: Milan
Posts: 18
Rep Power: 4 
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 

April 13, 2013, 14:13 

#9 
Senior Member
Ehsan
Join Date: Oct 2012
Location: Iran
Posts: 2,186
Rep Power: 16 
hi where should add your first code?


November 30, 2013, 17:22 

#10  
Senior Member
Join Date: Nov 2012
Posts: 168
Rep Power: 4 
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, nonzero 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 nonzero 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:
Last edited by hz283; November 30, 2013 at 18:57. 

December 1, 2013, 02:45 

#11 
Senior Member
Fumiya Nozaki
Join Date: Jun 2010
Location: Yokohama, Japan
Posts: 168
Rep Power: 7 
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]; } } } Hope this helps, fumiya 

Tags 
heat transfer, internalfields, laplacian 
Thread Tools  
Display Modes  


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 