← Back to team overview

dolfin team mailing list archive

Re: ConstantFunction

 

Garth N. Wells wrote:
> Anders Logg wrote:
>> The idea was that one should be able to plot any Function.
>> This means that every Function must be defined on a Mesh.
>>
>> We didn't have this before which meant we needed to have things like
>> Function::attach(mesh), Function::attach(element) etc.
>>
>> So the need for a Mesh is to keep the code simpler, but I can see the
>> need for being able to do things like
>>
>>   Function f = 1.0;
>>
>> Would it be better to introduce a new class Constant, which does not
>> require a Mesh? (Constant would inherit from Function and replace the
>> constant Function backend.)
>>
>
> I don't think that it will take much to check if a mesh has been
> associated with a Function or not. This is probably simpler than adding
> a new class.

Yes, probably, but do we then need to have a function to attach a mesh
if it has not been attached?

I don't mind making things simpler (not needing to supply the mesh)
but having a lot of options for how to construct an object easily
leads to complications in handling the difference cases.

/Anders


> Garth
>
>> /Anders
>>
>>
>> Garth N. Wells wrote:
>>> Is there a reason why a ConstantFunction must be associated with a mesh,
>>>
>>>    Function(mesh, 1.0);
>>>
>>> It makes the initialisation of a ConstantFunction rather tedious
>>> since the mesh must be passed around. If it's not needed, I'll allow
>>> a constant function to be initialised without a mesh possible, and
>>> just return an error if a user tries to write the function to a VTK
>>> file.
>>>
>>> Garth
>>> _______________________________________________
>>> DOLFIN-dev mailing list
>>> DOLFIN-dev@xxxxxxxxxx
>>> http://www.fenics.org/mailman/listinfo/dolfin-dev
>>
>
>


References