# How to read and change temperature results at each time step in buoyantPimpleFoam?

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

 July 28, 2011, 07:14 How to read and change temperature results at each time step in buoyantPimpleFoam? #1 New Member   Krzysztof Arendt Join Date: Feb 2011 Posts: 13 Rep Power: 6 Dear all, I am an inexperienced user of OpenFoam and C++. I am using buoyantPimpleFoam solver to simulate ventilation in a small building. My aim is to change temperature of wall patches at each time step. The temperature of the internal surfaces of walls will be calculated by a small piece of C++ code implementing the finite difference method. I cannot use timeVaryingFixedValue boundary condition, because the wall temperature at a given time step will depend also on the temperature of air near the wall. It must be calculated each time. At first, I wanted to create my own boundary condition to do this task, but the OpenFOAM's code intimidated me a little bit... Modifying the solver should be the easier way, so now I am trying to read the temperature at each time step directly in the solver and then modify it due to my finite difference calculations. However, I am able to read and change velocity U, pressure p and enthalpy h at each time step, but the temperature cannot be accessed directly. Should I change it indirectly by changing the enthalpy or there is a simpler solution? Can anyone give me a clue, how to start? I will appreciate any help. -- Krzysztof Last edited by kriztof; July 29, 2011 at 03:24.

 July 30, 2011, 10:02 #2 New Member   Krzysztof Arendt Join Date: Feb 2011 Posts: 13 Rep Power: 6 I understand - let me specify my question At each time step I want to change the temperature of a given boundary patch - let's say "myPatch". I would like to do this directly in the solver buoyantPimpleFoam. I figured out, that the probable procedure should look something like this: 1) find out the ID of "myPatch", what can be done by including the following code inside the solver code: Code: ` label myPatch_ID = mesh.boundaryMesh().findPatchID("myPatch");` 2) calculate the patch enthalpy for a desired temperature "myT" of type : Code: ``` // create a temperature scalarField for myPatch, which will be used to calculate the enthalpy scalarField T_myPatch = T.boundaryField()[myPatch]; forAll(myPatch, i) { T_myPatch[i] = myT; // whole patch will have the temperature "myT" } // calculate the enthalpy corresponding to the temperature "myT" scalarField h_new = thermo.h(myPatch, myPatch_ID);``` 3) change the enthalpy h on the patch "myPatch": Code: ``` forAll(h.boundaryField()[myPatch_ID], i) { h.boundaryField()[myPatch_ID][i] = h_new[i]; }``` The problem is, that the temperature boundary condition type of myPatch is set to "fixedValue", what results in constant temperatures of myPatch even though I change its enthalpy at each time step. How to force the solver to recalculate the temperature of this patch at each time step? Do I have to modify the BC?

 October 11, 2011, 02:55 #3 New Member   Krzysztof Arendt Join Date: Feb 2011 Posts: 13 Rep Power: 6 Ok, I have finally worked it out. The solution was easy, so I am sorry for cluttering up the forum. The patch temperature can be changed directly by usint const_cast: Code: ``` fvPatchScalarField& Tnew = const_cast (thermo.T().boundaryField()[patchi]]); forAll(Tnew, facei) { Tnew[facei] = your_new_temperature; }``` Maybe it will be useful for someone.

 Thread Tools Display Modes Linear Mode

 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 OffTrackbacks are On Pingbacks are On Refbacks are On Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post H.P.LIU Phoenics 7 July 13, 2010 04:31 Kushagra CFX 0 June 21, 2008 19:59 Mahyar FLUENT 0 May 29, 2008 05:24 dbxmcf OpenFOAM Running, Solving & CFD 4 November 4, 2007 15:21 özgür FLUENT 8 January 6, 2004 09:23

All times are GMT -4. The time now is 11:21.