On Tue, 12 Jun 2012, John Peterson wrote:
On Tue, Jun 12, 2012 at 9:58 AM, Roy Stogner <royst...@ices.utexas.edu> wrote:
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.
Backwards compatibility breakage issues aside, are we potentially
being guilty of premature optimization here?
We've got a class which ends up wrapping a bunch of containers of
Reals or RealGradients. And making efficient containers of arbitrary
unrelated datatypes is basically the whole reason why C++ templates
were invented.
But I can't reasonably sit back and demand that someone implement and
profile a complete polymorphic FE hierarchy either... any C++ expert
PECOS grad students there?
One, but he's way too busy to add this to his plate. Plus I think
he'd agree with me on the templates. ;-)
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.
OK, hopefully there won't be too much code duplication between the
different build() methods.
Nope. Although I'd like to do a factory method eventually, for now
it'll be the same ungodly huge switch statement design, except with
each rank of output type, and each FE type will only go in one of the
switches so if it's encountered by an object of the wrong rank then
it'll fall through to libmesh_error().
FEAbstract::build() can then just hand off to FEBase::build() of the
correct rank.
template <unsigned int Dim, FEFamily T, typename
OutputType=FEGenericBase<OutputOf<T>::type>
class FE : public FEGenericBase<OutputType> {...};
I see. So then the point is *not* to have two separate names, e.g.
template <unsigned int Dim, FEFamily T>
class FEScalar : public FEGenericBase<Real> {...};
template <unsigned int Dim, FEFamily T>
class FEVector : public FEGenericBase<RealGradient> {...};
but just one "FE" from which all (real and vector-valued) classes are
template specializations?
Right.
---
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