escript  Revision_
ReferenceElementSets.h
Go to the documentation of this file.
00001 
00002 /*****************************************************************************
00003 *
00004 * Copyright (c) 2003-2014 by University of Queensland
00005 * http://www.uq.edu.au
00006 *
00007 * Primary Business: Queensland, Australia
00008 * Licensed under the Open Software License version 3.0
00009 * http://www.opensource.org/licenses/osl-3.0.php
00010 *
00011 * Development until 2012 by Earth Systems Science Computational Center (ESSCC)
00012 * Development 2012-2013 by School of Earth Sciences
00013 * Development from 2014 by Centre for Geoscience Computing (GeoComp)
00014 *
00015 *****************************************************************************/
00016 
00017 #ifndef __FINLEY_REFERENCEELEMENTSETS_H__
00018 #define __FINLEY_REFERENCEELEMENTSETS_H__
00019 
00020 #include "ReferenceElements.h"
00021 
00022 namespace finley {
00023 
00026 struct ReferenceElementSet {
00027     ReferenceElementSet(ElementTypeId id, int order, int reduced_order)
00028     {
00029         const ReferenceElementInfo* id_info = ReferenceElement::getInfo(id);
00030         const ShapeFunctionInfo* bf_info = ShapeFunction::getInfo(
00031                                                     id_info->BasisFunctions);
00032         if (!noError()) return;
00033 
00034         if (order<0)
00035             order=std::max(2*bf_info->numOrder, 0);
00036 
00037         referenceElement.reset(new ReferenceElement(id, order));
00038         if (noError()) {
00039             if (reduced_order<0)
00040                 reduced_order=std::max(2*(bf_info->numOrder-1), 0);
00041             referenceElementReducedQuadrature.reset(
00042                     new ReferenceElement(id, reduced_order));
00043         }
00044 
00045         if (noError()) {
00046             if (referenceElement->getNumNodes() != referenceElementReducedQuadrature->getNumNodes()) {
00047                 setError(VALUE_ERROR, "ReferenceElementSet: numNodes in referenceElement and referenceElementReducedQuadrature don't match.");
00048             }
00049         }
00050     }
00051 
00052     const_ShapeFunction_ptr borrowBasisFunctions(bool reducedShapefunction,
00053                                                  bool reducedIntegrationOrder) const
00054     {
00055         if (reducedShapefunction) {
00056             return (reducedIntegrationOrder ?
00057                     referenceElementReducedQuadrature->LinearBasisFunctions :
00058                     referenceElement->LinearBasisFunctions);
00059         }
00060         return (reducedIntegrationOrder ?
00061                 referenceElementReducedQuadrature->BasisFunctions :
00062                 referenceElement->BasisFunctions);
00063     }
00064 
00065     const_ShapeFunction_ptr borrowParametrization(bool reducedIntegrationOrder) const
00066     {
00067         return (reducedIntegrationOrder ?
00068                 referenceElementReducedQuadrature->Parametrization :
00069                 referenceElement->Parametrization);
00070     }
00071 
00072     const_ReferenceElement_ptr borrowReferenceElement(bool reducedIntOrder) const
00073     {
00074         return (reducedIntOrder ? referenceElementReducedQuadrature :
00075                                   referenceElement);
00076     }
00077 
00078     inline int getNumNodes() const { return referenceElement->getNumNodes(); }
00079 
00080     ReferenceElement_ptr referenceElementReducedQuadrature;
00081     ReferenceElement_ptr referenceElement;
00082 };
00083 
00084 
00085 typedef boost::shared_ptr<const ReferenceElementSet> const_ReferenceElementSet_ptr;
00086 
00087 
00088 } // namespace finley
00089 
00090 #endif // __FINLEY_REFERENCEELEMENTSETS_H__
00091