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

specify temperature in cell (in solver)

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

Like Tree1Likes
  • 1 Post By adhiraj

Reply
 
LinkBack Thread Tools Display Modes
Old   January 3, 2012, 14:49
Default specify temperature in cell (in solver)
  #1
Member
 
ak
Join Date: May 2011
Posts: 71
Rep Power: 6
newOFuser is on a distinguished road
Hi

I'd like to modify the ignition file and specify temperature in the cell (in place of enthalpy). I tried to do so, but got the following error on compilation:

ignite.H:16: error: assignment of read-only location ((const Foam::volScalarField*)T)->Foam::GeometricField<double, Foam::fvPatchField, Foam::volMesh>::<anonymous>.Foam:imensionedField <double, Foam::volMesh>::<anonymous>.Foam::Field<double>::< anonymous>.Foam::List<double>::<anonymous>.Foam::U List<T>:perator[] [with T = double](ignCell)

Any idea on how to get rid of the error?

Many thanks,
amit
newOFuser is offline   Reply With Quote

Old   January 3, 2012, 16:38
Default
  #2
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 727
Rep Power: 18
mturcios777 will become famous soon enough
Temperature is a protected (or private, can't remember exactly offhand) member of thermo, and as such cannot be changed directly (not be default anyway). Implementing an ignition source via temperature depends on the solver you are using.

I see that OF2.1 has the ability to use sources through a dictionary. Have a look at the release notes for OF2.1, under the heading "Numerical Methods" which may be useful to you.
mturcios777 is offline   Reply With Quote

Old   January 4, 2012, 00:38
Default
  #3
Senior Member
 
Adhiraj
Join Date: Sep 2010
Location: Pennsylvania, United States
Posts: 101
Rep Power: 6
adhiraj is on a distinguished road
Just my 2 cents.
In the file createFields.H you will find
Quote:
const volScalarField& T = thermo.T();
So basically T is nothing but a reference to whatever the function T() in the class 'thermo' returns. This function is defined in the class basicThermo and it returns a constant access to the actual temperature variable T_. To modify the temperature from within the solver you need to define a similar function to return non constant access to T_ in the same class.
Then add to your createFields.H
Quote:
volScalarField Tmodifiable=thermo.Tmodifiable();// new function you wrote
When you need to change the temperature just do
Quote:
Tmodifiable[celli]=f;//some value
wenxu likes this.

Last edited by adhiraj; January 4, 2012 at 00:40. Reason: typo
adhiraj is offline   Reply With Quote

Old   January 4, 2012, 12:50
Default
  #4
Senior Member
 
mturcios777's Avatar
 
Marco A. Turcios
Join Date: Mar 2009
Location: Vancouver, BC, Canada
Posts: 727
Rep Power: 18
mturcios777 will become famous soon enough
Quote:
Originally Posted by adhiraj View Post
To modify the temperature from within the solver you need to define a similar function to return non constant access to T_ in the same class.
What adhiraj suggests is correct. This is what I meant that temperature isn't editable by default. In my experience, the success of directly altering temperature is strongly dependent on what kind of simulation you are running.

You might also try using swak4Foam first; this would allow you test the temperature change before mucking about in the source code.
mturcios777 is offline   Reply With Quote

Old   March 26, 2012, 09:24
Default
  #5
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 490
Rep Power: 9
samiam1000 is on a distinguished road
Have you succeded in fixing a temperature in a cell?
samiam1000 is offline   Reply With Quote

Old   March 28, 2012, 01:41
Default
  #6
Senior Member
 
su_junwei's Avatar
 
su junwei
Join Date: Mar 2009
Location: Xi'an China
Posts: 151
Rep Power: 10
su_junwei is on a distinguished road
Send a message via MSN to su_junwei
Quote:
Originally Posted by samiam1000 View Post
Have you succeded in fixing a temperature in a cell?
Just use the setValues of fvMatrix

fvScalarMatrix TEqn
(.....);

//list is the cell id list (labelList) that you want to fixed the temperature, the the valueList is the value of the temperature you want to set
TEqn.setValue(list, valuelist);

TEqn.solve();
su_junwei is offline   Reply With Quote

Old   March 28, 2012, 02:48
Default
  #7
Senior Member
 
Samuele Z
Join Date: Oct 2009
Location: Mozzate - Co - Italy
Posts: 490
Rep Power: 9
samiam1000 is on a distinguished road
Dear Su,

thanks for answering.

Actually, I und what you mean, but there is a problem: in the buoyantSimpleFoam (and buoyantPimpleFoam) solver I do not have the TEqn.H file.

What I did is to impose the enthalpy.

The point is that what I did works for the buoyantSimpleFoam, but it doesn't for the buoyantPimpleFoam.

I attach both the solvers (modified): could you check them, please? Also, if you think that your advice is smarter, could you explain me what to do?

Thanks in advance.

Samuele
Attached Files
File Type: gz buoyantPimpleFoam_Epta.tar.gz (3.0 KB, 4 views)
File Type: gz buoyantSimpleFoam_Epta.tar.gz (2.8 KB, 4 views)
samiam1000 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
thobois class engineTopoChangerMesh error Peter_600 OpenFOAM 4 August 2, 2014 09:52
temperature limited warning in 1 cell Shamoon Jamshed FLUENT 1 April 3, 2014 04:00
Which solver for temperature fred OpenFOAM Running, Solving & CFD 7 December 5, 2006 10:56
Divergencr in AMG solver: temperature shashikant FLUENT 1 July 10, 2006 12:38
drastic increase of temperature in one cell ravi FLUENT 7 August 30, 2004 22:58


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