Marie Rognes wrote:
> Garth N. Wells wrote:
>>
>>
>> Johan Hake wrote:
>>> On Thursday 02 July 2009 15:17:08 Garth N. Wells wrote:
>>>> Johan Hake wrote:
>>>>> On Thursday 02 July 2009 22:48:18 Marie Rognes wrote:
>>>>>> Johan Hake wrote:
>>>>>>> On Thursday 02 July 2009 13:24:28 Garth N. Wells wrote:
>>>>>>>> Johan Hake wrote:
>>>>>>>>> On Thursday 02 July 2009 13:07:47 Garth N. Wells wrote:
>>>>>>>>>> Marie Rognes wrote:
>>>>>>>>>>> Garth N. Wells wrote:
>>>>>>>>>>>> Marie Rognes wrote:
>>>>>>>>>>>>> The following code gives r = 0.0. It is not supposed to be.
>>>>>>>>>>>>>
>>>>>>>>>>>>> The problem seems to be that f's vector is still all zeros 
>>>>>>>>>>>>> at the
>>>>>>>>>>>>> call to interpolate. Could this be easily fixed?
>>>>>>>>>>>> This example should have led to an error message since f is 
>>>>>>>>>>>> not a
>>>>>>>>>>>> discrete function. I'll take a look.
>>>>>>>>>>> Ok, thanks!
>>>>>>>>>>>
>>>>>>>>>>> However,
>>>>>>>>>>>
>>>>>>>>>>> (a) Why is f not a discrete function? (It is defined on a finite
>>>>>>>>>>> element space?)
>>>>>>>>>> On second thought, it may be a discrete function. I think that 
>>>>>>>>>> this
>>>>>>>>>> is defined in the Python interface and not the C++ interface, so
>>>>>>>>>> I'll take a look.
>>>>>>>>> A user defined function is not a discrete function untill you 
>>>>>>>>> either
>>>>>>>>> call interpolate() or vector, also in python. The problem with the
>>>>>>>>> later is that you then create a vector which is initialized to 0.
>>>>>>>>>
>>>>>>>>> I think this has been discussed before, but should we populate the
>>>>>>>>> vector using f.interpolate() when vector is called on a 
>>>>>>>>> userdefined
>>>>>>>>> function?
>>>>>>>> Or perhaps Function::vector() should throw an error if the 
>>>>>>>> vector has
>>>>>>>> not already been allocated.
>>>>>>> I vote for this.
>>>>>>>
>>>>>>> The error message can include information about the user might 
>>>>>>> want to
>>>>>>> call interpolate?
>>>>>> What is wrong with actually populating the vector with the values one
>>>>>> expects it to have?
>>>>>> (When would one not want this?)
>>>>> Nothing is wrong with that. It just changes the state of the 
>>>>> userdefined
>>>>> function. The question is should this change be the implicit result 
>>>>> of a
>>>>> call to Function::vector() or should it be a result of an explicit
>>>>> action: a call to Function::interpolate().
>>>>>
>>>>>> Also note that it is not intuitive to me that one must call
>>>>>> f.interpolate() before
>>>>>>
>>>>>>     Pi_f = interpolate(f, Q_h)
>>>> I thought that I removed the above function from the C++ interface and
>>>> added
>>>>
>>>>      Pi_f = interpolate(f)
>>>
>>
>> Oops, I meant that I removed
>>
>>     Pi_f.interpolate(f, Q_h)
>>
>> and added
>>
>>     Pi_f.interpolate(f)
>>
>> I think that we should remove interpolate.py. It's now a wrapper for 
>> only two lines of code.
>>
> 
> 
> If so, if I want to interpolate f (defined on V_h) onto the space Q_h, I 
> should do ...?
>

Create the function f on V_h:

     Function f(V_h)
     # Do something to define f

     Function g(Q_h)
     g.interpolate(f)

If f is user-defined,

     Function f(V_h, "sin(x[0])")
     f.interpolate() # This will fill the vector. We could possibly make
                     # this step unnecessary

     Function g(Q_h)
     g.interpolate(f)

Garth



> 
> -- 
> Marie
> 
> 
> 


_______________________________________________
DOLFIN-dev mailing list
DOLFIN-dev@fenics.org
http://www.fenics.org/mailman/listinfo/dolfin-dev

Reply via email to