CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   specify temperature in cell (in solver) (https://www.cfd-online.com/Forums/openfoam/95807-specify-temperature-cell-solver.html)

newOFuser January 3, 2012 14:49

specify temperature in cell (in solver)
 
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::DimensionedField <double, Foam::volMesh>::<anonymous>.Foam::Field<double>::< anonymous>.Foam::List<double>::<anonymous>.Foam::U List<T>::operator[] [with T = double](ignCell)

Any idea on how to get rid of the error?

Many thanks,
amit

mturcios777 January 3, 2012 16:38

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.

adhiraj January 4, 2012 00:38

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

mturcios777 January 4, 2012 12:50

Quote:

Originally Posted by adhiraj (Post 337773)
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.

samiam1000 March 26, 2012 09:24

Have you succeded in fixing a temperature in a cell?

su_junwei March 28, 2012 01:41

Quote:

Originally Posted by samiam1000 (Post 351507)
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();

samiam1000 March 28, 2012 02:48

2 Attachment(s)
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


All times are GMT -4. The time now is 06:07.