On Tue, 12 Jun 2012, John Peterson wrote:

>> template <typename OutputType>
>> class FEGenericBase {...};
>>
>> typedef FEGenericBase<Real> FEBase;
>> typedef FEGenericBase<RealGradient> FEVectorBase;
>
> Urk... I guess my own preference would have been for *fewer* templates
> in the FE hierarchy rather than more,

Mine too, trust me.  My first forays into libMesh were delayed by my
difficulty figuring out the FE templating tricks...

> but if you say this is a good design I trust your judgment.

I think it's the best we can do in C++.  We really want a ton of
common non-cut-n-pasted code between the vector and scalar FE classes,
we don't want the gross inefficiencies (and backwards compatibility
breakage) implied by a runtime polymorphic design, and so that leaves
us with templates.

> Also, it might be handy if we could keep using the equivalent of
> FEBase::build() in the new system... if the base class is templated,
> does this functionality become trickier to implement?

Slightly.  FEBase::build() will only work if you know you're asking
for a scalar FE type, likewise for FEVectorBase::build() and vector
types.  FEAbstract::build() will work for either, but will give a
higher-level base class without the output-type-specific
functionality.  And we'll have something like "bool
FEAbstract::rank()" (returning 0 for scalar, 1 for vector, etc) for
cases where your code really needs the output-type-specific
functionality but doesn't know a priori which output type code path
it's going to have to go down for a given FE type.

>> Which would then allow us to add a default template parameter to FE
>> giving something like
>>
>> template <unsigned int Dim, FEFamily T, typename 
>> OutputType=FEGenericBase<OutputOf<T>::type>
>> class FE : public FEBase {...};
>
> Hmm, so then FE is *not* derived from this new FEGenericBase class at
> all, but rather an untemplated FEBase class, similar to what we have
> now?

No, I was just typing too fast.  Trying again:

template <unsigned int Dim, FEFamily T, typename 
OutputType=FEGenericBase<OutputOf<T>::type>
class FE : public FEGenericBase<OutputType> {...};
---
Roy

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Libmesh-devel mailing list
Libmesh-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to