// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // ============================================================================ // == == // == TU Dresden == // == == // == Institut für Wissenschaftliches Rechnen == // == Zellescher Weg 12-14 == // == 01069 Dresden == // == germany == // == == // ============================================================================ // == == // == https://gforge.zih.tu-dresden.de/projects/amdis/ == // == == // ============================================================================ /** \file ZeroOrderTerm.h */ #ifndef AMDIS_ZERO_ORDER_TERM_H #define AMDIS_ZERO_ORDER_TERM_H #include "AMDiS_fwd.h" #include "OperatorTerm.h" #include "AbstractFunction.h" namespace AMDiS { /** * \ingroup Assembler * * \brief * Describes zero order terms: \f$cu(\vec{x}) \f$. */ class ZeroOrderTerm : public OperatorTerm { public: /// Constructor. ZeroOrderTerm(int deg) : OperatorTerm(deg) {} /// Destructor. virtual ~ZeroOrderTerm() {} /// Evaluates \f$c \f$ virtual void getC(const ElInfo *elInfo, int nPoints, std::vector &C) = 0; }; /** * \ingroup Assembler * * \brief * Simple zero order term */ class Simple_ZOT : public ZeroOrderTerm { public: /// Constructor. Simple_ZOT(double f = 1.0) : ZeroOrderTerm(0), factor(f) {} /// Implements ZeroOrderTerm::getC(). inline void getC(const ElInfo *, int nPoints, std::vector &C) { for (int iq = 0; iq < nPoints; iq++) C[iq] += factor; } /// Implements ZeroOrderTerm::eval(). inline void eval(int nPoints, const double *uhAtQP, const WorldVector *, const WorldMatrix *, double *result, double fac) { for (int iq = 0; iq < nPoints; iq++) result[iq] += fac * factor * uhAtQP[iq]; } protected: /// Constant factor of zero order term. double factor; }; /** * \ingroup Assembler * * \brief * Zero order term: \f$f(v(\vec{x})) u(\vec{x})\f$ */ class VecAtQP_ZOT : public ZeroOrderTerm { public: /// Constructor. VecAtQP_ZOT(DOFVectorBase *dv, AbstractFunction *ab); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implementation of \ref OperatorTerm::initElement() for multilpe meshes. void initElement(const ElInfo* smallElInfo, const ElInfo* largeElInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// DOFVector to be evaluated at quadrature points. DOFVectorBase* vec; /// Vector v at quadrature points. double *vecAtQPs; /// Function for c. AbstractFunction *f; }; /** * \ingroup Assembler * * \brief * Zero order term: \f$f(v(\vec{x})) g(w(\vec{x})) u(\vec{x})\f$ */ class MultVecAtQP_ZOT : public ZeroOrderTerm { public: /// Constructor. MultVecAtQP_ZOT(DOFVectorBase *dv1, DOFVectorBase *dv2, AbstractFunction *f1, AbstractFunction *f2); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// DOFVectorBase to be evaluated at quadrature points. DOFVectorBase* vec1; DOFVectorBase* vec2; /// Vector v at quadrature points. double *vecAtQPs1; double *vecAtQPs2; /// Function for c. AbstractFunction *f1; AbstractFunction *f2; }; /** * \ingroup Assembler * * \brief * Zero order term: \f$f(v(\vec{x}), w(\vec{x})) u(\vec{x})\f$ */ class Vec2AtQP_ZOT : public ZeroOrderTerm { public: /// Constructor. Vec2AtQP_ZOT(DOFVectorBase *dv1, DOFVectorBase *dv2, BinaryAbstractFunction *f); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implementation of \ref OperatorTerm::initElement() for multilpe meshes. void initElement(const ElInfo* smallElInfo, const ElInfo* largeElInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// First DOFVector to be evaluated at quadrature points. DOFVectorBase* vec1; /// Second DOFVector to be evaluated at quadrature points. DOFVectorBase* vec2; /// Values of the first DOFVector at the quadrature points. double *vecAtQPs1; /// Values of the second DOFVector at the quadrature points. double *vecAtQPs2; /// Function for c. BinaryAbstractFunction *f; }; /** * \ingroup Assembler * * \brief * Zero order term: \f$f(v(\vec{x}), w(\vec{x})) u(\vec{x})\f$ */ class Vec3AtQP_ZOT : public ZeroOrderTerm { public: /// Constructor. Vec3AtQP_ZOT(DOFVectorBase *dv1, DOFVectorBase *dv2, DOFVectorBase *dv3, TertiaryAbstractFunction *f); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// DOFVectors to be evaluated at quadrature points. DOFVectorBase *vec1, *vec2, *vec3; /// Vectors at quadrature points. double *vecAtQPs1, *vecAtQPs2, *vecAtQPs3; /// Function for c. TertiaryAbstractFunction *f; }; /** * \ingroup Assembler * * \brief * */ class FctGradientCoords_ZOT : public ZeroOrderTerm { public: /// Constructor. FctGradientCoords_ZOT(DOFVectorBase *dv, BinaryAbstractFunction, WorldVector > *f); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements SecondOrderTerm::getC(). void getC(const ElInfo *elInfo, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: DOFVectorBase* vec; /// Function wich maps \ref gradAtQPs to a double. BinaryAbstractFunction, WorldVector > *f; /** \brief * Pointer to a WorldVector array containing the gradients of the DOFVector * at each quadrature point. */ WorldVector* gradAtQPs; WorldVector* coordsAtQPs; }; /** * \ingroup Assembler * * \brief */ class VecGradCoordsAtQP_ZOT : public ZeroOrderTerm { public: /// Constructor. VecGradCoordsAtQP_ZOT(DOFVectorBase *dv, TertiaryAbstractFunction, WorldVector > *f); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// DOFVector to be evaluated at quadrature points. DOFVectorBase* vec; /// Vector v at quadrature points. double *vecAtQPs; /// Gradient at quadrature points. WorldVector* gradAtQPs; WorldVector* coordsAtQPs; /// Function for c. TertiaryAbstractFunction, WorldVector > *f; }; /** * \ingroup Assembler * * \brief */ class VecAndCoordsAtQP_ZOT : public ZeroOrderTerm { public: /// Constructor. VecAndCoordsAtQP_ZOT(DOFVectorBase *dv, BinaryAbstractFunction > *f); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// DOFVector to be evaluated at quadrature points. DOFVectorBase* vec; /// Vector v at quadrature points. double *vecAtQPs; /// Gradient at quadrature points. WorldVector* coordsAtQPs; /// Function for c. BinaryAbstractFunction > *f; }; /** * \ingroup Assembler * * \brief */ class Vec2AndGradAtQP_ZOT : public ZeroOrderTerm { public: /// Constructor. Vec2AndGradAtQP_ZOT(DOFVectorBase *dv1, DOFVectorBase *dv2, TertiaryAbstractFunction, double > *af); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// DOFVector to be evaluated at quadrature points. DOFVectorBase* vec1; DOFVectorBase* vec2; /// Vector v at quadrature points. double *vecAtQPs1; double *vecAtQPs2; /// Gradient at quadrature points. WorldVector *gradAtQPs; /// Function for c. TertiaryAbstractFunction, double > *f; }; /** * \ingroup Assembler * * \brief * */ class FctGradient_ZOT : public ZeroOrderTerm { public: /// Constructor. FctGradient_ZOT(DOFVectorBase *dv, AbstractFunction > *f); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements SecondOrderTerm::getC(). void getC(const ElInfo *elInfo, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: DOFVectorBase* vec; /// Function wich maps \ref gradAtQPs to a double. AbstractFunction > *f; /** \brief * Pointer to a WorldVector array containing the gradients of the DOFVector * at each quadrature point. */ WorldVector* gradAtQPs; }; /** * \ingroup Assembler * * \brief */ class VecAndGradAtQP_ZOT : public ZeroOrderTerm { public: /// Constructor. VecAndGradAtQP_ZOT(DOFVectorBase *dv, BinaryAbstractFunction > *f); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// DOFVector to be evaluated at quadrature points. DOFVectorBase* vec; /// Vector v at quadrature points. double *vecAtQPs; /// Gradient at quadrature points. WorldVector *gradAtQPs; /// Function for c. BinaryAbstractFunction > *f; }; class VecAndGradVecAtQP_ZOT : public ZeroOrderTerm { public: /// Constructor. VecAndGradVecAtQP_ZOT(DOFVectorBase *dv, DOFVectorBase *dGrd, BinaryAbstractFunction > *f); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// DOFVector to be evaluated at quadrature points. DOFVectorBase* vec; /// Vector v at quadrature points. double *vecAtQPs; /// First DOFVector whose gradient is evaluated at quadrature points. DOFVectorBase* vecGrd; /// Gradient of first vector at quadrature points. WorldVector *gradAtQPs; /// Function for c. BinaryAbstractFunction > *f; }; class VecAndGradVec2AtQP_ZOT : public ZeroOrderTerm { public: /// Constructor. VecAndGradVec2AtQP_ZOT(DOFVectorBase *dv, DOFVectorBase *dGrd1, DOFVectorBase *dGrd2, TertiaryAbstractFunction, WorldVector > *af); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// DOFVector to be evaluated at quadrature points. DOFVectorBase* vec; /// Vector v at quadrature points. double *vecAtQPs; /// First DOFVector whose gradient is evaluated at quadrature points. DOFVectorBase* vecGrd1; /// Gradient of first vector at quadrature points. WorldVector *grad1AtQPs; /// Second DOFVector whose gradient is evaluated at quadrature points. DOFVectorBase* vecGrd2; /// Gradient of second vector at quadrature points. WorldVector *grad2AtQPs; /// Function for c. TertiaryAbstractFunction, WorldVector > *f; }; class VecOfDOFVecsAtQP_ZOT : public ZeroOrderTerm { public: /// Constructor. VecOfDOFVecsAtQP_ZOT(const std::vector*>& dv, AbstractFunction > *f); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// Vector of DOFVectors to be evaluated at quadrature points. std::vector*> vecs; /// Vectors at quadrature points. std::vector vecsAtQPs; /// Function for c. AbstractFunction > *f; }; class VecOfGradientsAtQP_ZOT : public ZeroOrderTerm { public: /// Constructor. VecOfGradientsAtQP_ZOT(const std::vector*>& dv, AbstractFunction*> > *af); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// Vector of DOFVectors to be evaluated at quadrature points. std::vector*> vecs; /// Vectors at quadrature points. std::vector*> gradsAtQPs; /// Function for c. AbstractFunction*> > *f; }; class VecDivergence_ZOT : public ZeroOrderTerm { public: /// Constructor. VecDivergence_ZOT(int nComponents, DOFVectorBase *vec0, DOFVectorBase *vec1 = NULL, DOFVectorBase *vec2 = NULL); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// Vector of DOFVectors to be evaluated at quadrature points. std::vector*> vecs; /// Vectors at quadrature points. std::vector*> gradsAtQPs; }; class VecAndVecOfGradientsAtQP_ZOT : public ZeroOrderTerm { public: /// Constructor. VecAndVecOfGradientsAtQP_ZOT(DOFVector *v, const std::vector*>& dv, BinaryAbstractFunction*> > *af); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// DOFVector to be evaluated at quadrature points. DOFVector* vec; /// Vector v at quadrature points. double *vecAtQPs; /// Vector of DOFVectors to be evaluated at quadrature points. std::vector*> vecs; /// Vectors at quadrature points. std::vector*> gradsAtQPs; /// Function for c. BinaryAbstractFunction*> > *f; }; class Vec2AndGrad2AtQP_ZOT : public ZeroOrderTerm { public: Vec2AndGrad2AtQP_ZOT(DOFVectorBase *dv1, DOFVectorBase *dv2, QuartAbstractFunction, WorldVector > *af); void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); void getC(const ElInfo *, int nPoints, std::vector &C); void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: DOFVectorBase *vec1, *vec2; double *vecAtQPs1, *vecAtQPs2; WorldVector *gradAtQPs1, *gradAtQPs2; QuartAbstractFunction,WorldVector > *f; }; class Vec2AndGradVecAtQP_ZOT : public ZeroOrderTerm { public: Vec2AndGradVecAtQP_ZOT(DOFVectorBase *dv1, DOFVectorBase *dv2, DOFVectorBase *dGrd, TertiaryAbstractFunction > *f); void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); void getC(const ElInfo *, int nPoints, std::vector &C); void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: DOFVectorBase* vec1; DOFVectorBase* vec2; double *vec1AtQPs; double *vec2AtQPs; DOFVectorBase* vecGrd; WorldVector *gradAtQPs; TertiaryAbstractFunction > *f; }; class General_ZOT : public ZeroOrderTerm { public: /// Constructor. General_ZOT(std::vector*> vecs, std::vector*> grads, TertiaryAbstractFunction, std::vector, std::vector > > *f); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: std::vector*> vecs_; std::vector*> grads_; TertiaryAbstractFunction, std::vector, std::vector > > *f_; WorldVector *coordsAtQPs_; std::vector vecsAtQPs_; std::vector*> gradsAtQPs_; std::vector vecsArg; std::vector > gradsArg; }; class GeneralParametric_ZOT : public ZeroOrderTerm { public: /// Constructor. GeneralParametric_ZOT(std::vector*> vecs, std::vector*> grads, QuartAbstractFunction, WorldVector, std::vector, std::vector > > *f); /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: std::vector*> vecs_; std::vector*> grads_; QuartAbstractFunction, WorldVector, std::vector, std::vector > > *f_; WorldVector *coordsAtQPs_; WorldVector elementNormal_; std::vector vecsAtQPs_; std::vector*> gradsAtQPs_; }; /* * \ingroup Assembler * * \brief * Zero order term: \f$f(\vec{x}) u(\vec{x})\f$ */ class CoordsAtQP_ZOT : public ZeroOrderTerm { public: /// Constructor. CoordsAtQP_ZOT(AbstractFunction > *af) : ZeroOrderTerm(af->getDegree()), g(af) {} /// Implementation of \ref OperatorTerm::initElement(). void initElement(const ElInfo* elInfo, SubAssembler* subAssembler, Quadrature *quad = NULL); /// Implements ZeroOrderTerm::getC(). void getC(const ElInfo *, int nPoints, std::vector &C); /// Implements ZeroOrderTerm::eval(). void eval(int nPoints, const double *uhAtQP, const WorldVector *grdUhAtQP, const WorldMatrix *D2UhAtQP, double *result, double fac); protected: /// Stores coordinates at quadrature points. Set in \ref initElement(). WorldVector* coordsAtQPs; /// Function for c. AbstractFunction > *g; }; } #endif