Getting internalField values from a patchField
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 
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 change the FaceID. Hope that helps, Fumiya 
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 
Hi Ali,
Do you have any more information other than 'it didn't work'? Is the internal field not updating? Is it crashing? 
This problem has been solved!!
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 
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:
Can anyone help me? Regards Giancarlo 
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:

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 
hi where should add your first code?

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:

Hi hz283,
You might want to try the following code: Code:
forAll(mesh.boundary(), patchI) // patch loop Hope this helps, fumiya 
All times are GMT 4. The time now is 14:22. 