-----Ursprüngliche Nachricht----- Von: firedrake-bounces@imperial.ac.uk [mailto:firedrake- bounces@imperial.ac.uk] Im Auftrag von Lawrence Mitchell Gesendet: 28 October 2015 15:06 An: firedrake@imperial.ac.uk Betreff: Re: [firedrake] Inverse of .dat.data
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 28/10/15 14:02, Buesing, Henrik wrote:
-----Ursprüngliche Nachricht----- Von: firedrake-bounces@imperial.ac.uk [mailto:firedrake- bounces@imperial.ac.uk] Im Auftrag von Lawrence Mitchell Gesendet: 28 October 2015 14:46 An: firedrake@imperial.ac.uk Betreff: Re: [firedrake] Inverse of .dat.data
On 28/10/15 13:20, Buesing, Henrik wrote:
Dear all,
Ok. Maybe this is the way to go:
As before, I have a function temp(p,h), which shall return temperature dependent on pressure and enthalpy. I insert UFL representations of p and h into temp(,).
Then I'm doing a
p = assemble(p).dat.data[0] h = assemble(h).dat.data[1]
Now, I execute some operations on the arrays. In the end I want to have the UFL representation of temp (the same as what I inserted as p and h).
So how do I get the UFL representation back from the array?
I'm not sure I understand what you mean by get the UFL representation back. Can you explain what you're trying to achieve? I am guessing here, but I suppose you have a term in your equation which is either an unknown or has some known value, depending on an equation of state. I think you should be able to write this using "conditional" to select one or the other depending on the value of the equation of state (if you can represent it using UFL.
[Buesing, Henrik] At the moment I have a numpy array in the end. However I want a function back to be able to use UFL again, e.g. doing
So if you just do:
p_coeff = assemble(p)
then you can use p_coeff in your forms, is that what you want?
[Buesing, Henrik] Not sure that we are on the same page here. I attached the code of calc_temp(p,h). DATA_temp is an array with 146,888 (602*244) entries. Of course, when doing gradtemp = (temp('+') - temp('-'))/Delta_h_facet I get TypeError: 'numpy.ndarray' object is not callable. Henrik
gradtemp = (temp('+') - temp('-'))/Delta_h_facet
Yes, you can think of the routine as an EOS. I tried to use UFL, but in my EOS code I have int(). I do not know how to represent this in UFL (see my previous mail "UFL statement for python int()"). Also I have an array of values DATA_temp[getD-1], which I then want to access with a UFL function getD, which probably makes no sense...
Well, if it's not spatially varying, then you could use a constant:
c = Constant(data_array)
and then index that constant in your expression:
c[0] == data_array[0]
[Buesing, Henrik] I think, that should work. Still the question remains how to get the int(). Henrik