MFEM v2.0
bilininteg.hpp
Go to the documentation of this file.
00001 // Copyright (c) 2010, Lawrence Livermore National Security, LLC. Produced at
00002 // the Lawrence Livermore National Laboratory. LLNL-CODE-443211. All Rights
00003 // reserved. See file COPYRIGHT for details.
00004 //
00005 // This file is part of the MFEM library. For more information and source code
00006 // availability see http://mfem.googlecode.com.
00007 //
00008 // MFEM is free software; you can redistribute it and/or modify it under the
00009 // terms of the GNU Lesser General Public License (as published by the Free
00010 // Software Foundation) version 2.1 dated February 1999.
00011 
00012 #ifndef MFEM_BILININTEG
00013 #define MFEM_BILININTEG
00014 
00016 class BilinearFormIntegrator
00017 {
00018 public:
00020    virtual void AssembleElementMatrix(const FiniteElement &el,
00021                                       ElementTransformation &Trans,
00022                                       DenseMatrix &elmat);
00027    virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
00028                                        const FiniteElement &test_fe,
00029                                        ElementTransformation &Trans,
00030                                        DenseMatrix &elmat);
00031    virtual void AssembleFaceMatrix(const FiniteElement &el1,
00032                                    const FiniteElement &el2,
00033                                    FaceElementTransformations &Trans,
00034                                    DenseMatrix &elmat);
00035    virtual void ComputeElementFlux(const FiniteElement &el,
00036                                    ElementTransformation &Trans,
00037                                    Vector &u,
00038                                    const FiniteElement &fluxelem,
00039                                    Vector &flux, int wcoef = 1) { }
00040    virtual double ComputeFluxEnergy(const FiniteElement &fluxelem,
00041                                     ElementTransformation &Trans,
00042                                     Vector &flux) { return 0.0; }
00043    virtual ~BilinearFormIntegrator() { }
00044 };
00045 
00046 class TransposeIntegrator : public BilinearFormIntegrator
00047 {
00048 private:
00049    int own_bfi;
00050    BilinearFormIntegrator *bfi;
00051 
00052    DenseMatrix bfi_elmat;
00053 
00054 public:
00055    TransposeIntegrator (BilinearFormIntegrator *_bfi, int _own_bfi = 1)
00056    { bfi = _bfi; own_bfi = _own_bfi; }
00057 
00058    virtual void AssembleElementMatrix(const FiniteElement &el,
00059                                       ElementTransformation &Trans,
00060                                       DenseMatrix &elmat);
00061    virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
00062                                        const FiniteElement &test_fe,
00063                                        ElementTransformation &Trans,
00064                                        DenseMatrix &elmat);
00065    virtual ~TransposeIntegrator() { if (own_bfi) delete bfi; }
00066 };
00067 
00068 class LumpedIntegrator : public BilinearFormIntegrator
00069 {
00070 private:
00071    int own_bfi;
00072    BilinearFormIntegrator *bfi;
00073 
00074 public:
00075    LumpedIntegrator (BilinearFormIntegrator *_bfi, int _own_bfi = 1)
00076    { bfi = _bfi; own_bfi = _own_bfi; }
00077 
00078    virtual void AssembleElementMatrix(const FiniteElement &el,
00079                                       ElementTransformation &Trans,
00080                                       DenseMatrix &elmat);
00081 
00082    virtual ~LumpedIntegrator() { if (own_bfi) delete bfi; }
00083 };
00084 
00087 class DiffusionIntegrator: public BilinearFormIntegrator
00088 {
00089 private:
00090    Vector vec, pointflux, shape;
00091 #ifndef MFEM_USE_OPENMP
00092    DenseMatrix dshape, dshapedxt, invdfdx;
00093 #endif
00094    Coefficient *Q;
00095    MatrixCoefficient *MQ;
00096 
00097 public:
00099    DiffusionIntegrator (Coefficient &q) : Q(&q) { MQ = NULL; }
00100 
00102    DiffusionIntegrator (MatrixCoefficient &q) : MQ(&q) { Q = NULL; }
00103 
00106    virtual void AssembleElementMatrix(const FiniteElement &el,
00107                                       ElementTransformation &Trans,
00108                                       DenseMatrix &elmat);
00109    virtual void ComputeElementFlux(const FiniteElement &el,
00110                                    ElementTransformation &Trans,
00111                                    Vector &u,
00112                                    const FiniteElement &fluxelem,
00113                                    Vector &flux, int wcoef);
00114    virtual double ComputeFluxEnergy(const FiniteElement &fluxelem,
00115                                     ElementTransformation &Trans,
00116                                     Vector &flux);
00117 };
00118 
00120 class MassIntegrator: public BilinearFormIntegrator
00121 {
00122 private:
00123    Vector shape, te_shape;
00124    Coefficient *Q;
00125    const IntegrationRule *IntRule;
00126 
00127 public:
00128    MassIntegrator(const IntegrationRule *ir = NULL)
00129    { Q = NULL; IntRule = ir; }
00131    MassIntegrator(Coefficient &q, const IntegrationRule *ir = NULL)
00132       : Q(&q) { IntRule = ir; }
00133 
00136    virtual void AssembleElementMatrix(const FiniteElement &el,
00137                                       ElementTransformation &Trans,
00138                                       DenseMatrix &elmat);
00139    virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
00140                                        const FiniteElement &test_fe,
00141                                        ElementTransformation &Trans,
00142                                        DenseMatrix &elmat);
00143 };
00144 
00145 class BoundaryMassIntegrator : public MassIntegrator
00146 {
00147 public:
00148    BoundaryMassIntegrator(Coefficient &q) : MassIntegrator(q) { }
00149 };
00150 
00152 class ConvectionIntegrator : public BilinearFormIntegrator
00153 {
00154 private:
00155    DenseMatrix dshape;
00156    DenseMatrix invdfdx;
00157    Vector shape, vec1, vec2;
00158    Vector BdFidxT;
00159    VectorCoefficient &Q;
00160 public:
00161    ConvectionIntegrator(VectorCoefficient &q) : Q(q) { }
00162    virtual void AssembleElementMatrix(const FiniteElement &,
00163                                       ElementTransformation &,
00164                                       DenseMatrix &);
00165 };
00166 
00170 class VectorMassIntegrator: public BilinearFormIntegrator
00171 {
00172 private:
00173    Vector shape, vec;
00174    DenseMatrix partelmat;
00175    DenseMatrix mcoeff;
00176    Coefficient *Q;
00177    VectorCoefficient *VQ;
00178    MatrixCoefficient *MQ;
00179 
00180    const IntegrationRule *IntRule;
00181    int Q_order;
00182 
00183 public:
00185    VectorMassIntegrator()
00186    { Q = NULL; VQ = NULL; MQ = NULL; IntRule = NULL; Q_order = 0; }
00191    VectorMassIntegrator(Coefficient &q, int qo = 0)
00192       : Q(&q) { VQ = NULL; MQ = NULL; IntRule = NULL; Q_order = qo; }
00193    VectorMassIntegrator(Coefficient &q, const IntegrationRule *ir)
00194       : Q(&q) { VQ = NULL; MQ = NULL; IntRule = ir; Q_order = 0; }
00196    VectorMassIntegrator(VectorCoefficient &q, int qo = 0)
00197       : VQ(&q) { Q = NULL; MQ = NULL; IntRule = NULL; Q_order = qo; }
00199    VectorMassIntegrator(MatrixCoefficient &q, int qo = 0)
00200       : MQ(&q) { Q = NULL; VQ = NULL; IntRule = NULL; Q_order = qo; }
00201 
00202    virtual void AssembleElementMatrix(const FiniteElement &el,
00203                                       ElementTransformation &Trans,
00204                                       DenseMatrix &elmat);
00205 };
00206 
00207 
00215 class VectorFEDivergenceIntegrator : public BilinearFormIntegrator
00216 {
00217 private:
00218    Coefficient *Q;
00219 #ifndef MFEM_USE_OPENMP
00220    Vector divshape, shape;
00221 #endif
00222 public:
00223    VectorFEDivergenceIntegrator() { Q = NULL; }
00224    VectorFEDivergenceIntegrator(Coefficient &q) { Q = &q; }
00225    virtual void AssembleElementMatrix(const FiniteElement &el,
00226                                       ElementTransformation &Trans,
00227                                       DenseMatrix &elmat) { }
00228    virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
00229                                        const FiniteElement &test_fe,
00230                                        ElementTransformation &Trans,
00231                                        DenseMatrix &elmat);
00232 };
00233 
00234 
00236 class VectorFECurlIntegrator: public BilinearFormIntegrator
00237 {
00238 private:
00239    Coefficient *Q;
00240 #ifndef MFEM_USE_OPENMP
00241    DenseMatrix curlshapeTrial;
00242    DenseMatrix vshapeTest;
00243    DenseMatrix curlshapeTrial_dFT;
00244 #endif
00245 public:
00246    VectorFECurlIntegrator() { Q = NULL; }
00247    VectorFECurlIntegrator(Coefficient &q) { Q = &q; }
00248    virtual void AssembleElementMatrix(const FiniteElement &el,
00249                                       ElementTransformation &Trans,
00250                                       DenseMatrix &elmat) { }
00251    virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
00252                                        const FiniteElement &test_fe,
00253                                        ElementTransformation &Trans,
00254                                        DenseMatrix &elmat);
00255 };
00256 
00257 
00259 class DerivativeIntegrator : public BilinearFormIntegrator
00260 {
00261 private:
00262    Coefficient & Q;
00263    int xi;
00264    DenseMatrix dshape, dshapedxt, invdfdx;
00265    Vector shape, dshapedxi;
00266 public:
00267    DerivativeIntegrator(Coefficient &q, int i) : Q(q), xi(i) { }
00268    virtual void AssembleElementMatrix(const FiniteElement &el,
00269                                       ElementTransformation &Trans,
00270                                       DenseMatrix &elmat)
00271    { AssembleElementMatrix2(el,el,Trans,elmat); }
00272    virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
00273                                        const FiniteElement &test_fe,
00274                                        ElementTransformation &Trans,
00275                                        DenseMatrix &elmat);
00276 };
00277 
00279 class CurlCurlIntegrator: public BilinearFormIntegrator
00280 {
00281 private:
00282 #ifndef MFEM_USE_OPENMP
00283    DenseMatrix Curlshape, Curlshape_dFt;
00284 #endif
00285    Coefficient *Q;
00286 
00287 public:
00288    CurlCurlIntegrator() { Q = NULL; }
00290    CurlCurlIntegrator(Coefficient &q) : Q(&q) { }
00291 
00292    /* Given a particular Finite Element, compute the
00293       element curl-curl matrix elmat */
00294    virtual void AssembleElementMatrix(const FiniteElement &el,
00295                                       ElementTransformation &Trans,
00296                                       DenseMatrix &elmat);
00297 };
00298 
00300 class VectorFEMassIntegrator: public BilinearFormIntegrator
00301 {
00302 private:
00303    Coefficient *Q;
00304    VectorCoefficient *VQ;
00305 
00306 #ifndef MFEM_USE_OPENMP
00307    Vector shape;
00308    Vector D;
00309    DenseMatrix vshape;
00310 #endif
00311 
00312 public:
00313    VectorFEMassIntegrator() { Q = NULL; VQ= NULL; }
00314    VectorFEMassIntegrator(Coefficient *_q) { Q = _q; VQ= NULL; }
00315    VectorFEMassIntegrator(Coefficient &q) { Q = &q; VQ= NULL; }
00316    VectorFEMassIntegrator(VectorCoefficient *_vq) { VQ = _vq; Q = NULL; }
00317    VectorFEMassIntegrator(VectorCoefficient &vq) { VQ = &vq; Q = NULL; }
00318 
00319    virtual void AssembleElementMatrix(const FiniteElement &el,
00320                                       ElementTransformation &Trans,
00321                                       DenseMatrix &elmat);
00322    virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
00323                                        const FiniteElement &test_fe,
00324                                        ElementTransformation &Trans,
00325                                        DenseMatrix &elmat);
00326 };
00327 
00331 class VectorDivergenceIntegrator : public BilinearFormIntegrator
00332 {
00333 private:
00334    Coefficient *Q;
00335 
00336    Vector shape;
00337    Vector divshape;
00338    DenseMatrix dshape;
00339    DenseMatrix gshape;
00340    DenseMatrix Jadj;
00341 
00342 public:
00343    VectorDivergenceIntegrator() { Q = NULL; }
00344    VectorDivergenceIntegrator(Coefficient *_q) { Q = _q; }
00345    VectorDivergenceIntegrator(Coefficient &q) { Q = &q; }
00346 
00347    virtual void AssembleElementMatrix2(const FiniteElement &trial_fe,
00348                                        const FiniteElement &test_fe,
00349                                        ElementTransformation &Trans,
00350                                        DenseMatrix &elmat);
00351 };
00352 
00354 class DivDivIntegrator: public BilinearFormIntegrator
00355 {
00356 private:
00357    Coefficient *Q;
00358 
00359 #ifndef MFEM_USE_OPENMP
00360    Vector divshape;
00361 #endif
00362 
00363 public:
00364    DivDivIntegrator() { Q = NULL; }
00365    DivDivIntegrator(Coefficient &q) : Q(&q) { }
00366 
00367    virtual void AssembleElementMatrix(const FiniteElement &el,
00368                                       ElementTransformation &Trans,
00369                                       DenseMatrix &elmat);
00370 };
00371 
00374 class VectorDiffusionIntegrator : public BilinearFormIntegrator
00375 {
00376 private:
00377    Coefficient *Q;
00378 
00379    DenseMatrix Jinv;
00380    DenseMatrix dshape;
00381    DenseMatrix gshape;
00382    DenseMatrix pelmat;
00383 
00384 public:
00385    VectorDiffusionIntegrator() { Q = NULL; }
00386    VectorDiffusionIntegrator(Coefficient &q) { Q = &q; }
00387 
00388    virtual void AssembleElementMatrix(const FiniteElement &el,
00389                                       ElementTransformation &Trans,
00390                                       DenseMatrix &elmat);
00391 };
00392 
00398 class ElasticityIntegrator : public BilinearFormIntegrator
00399 {
00400 private:
00401    double q_lambda, q_mu;
00402    Coefficient *lambda, *mu;
00403 
00404 #ifndef MFEM_USE_OPENMP
00405    DenseMatrix dshape, Jinv, gshape, pelmat;
00406    Vector divshape;
00407 #endif
00408 
00409 public:
00410    ElasticityIntegrator(Coefficient &l, Coefficient &m)
00411    { lambda = &l; mu = &m; }
00414    ElasticityIntegrator(Coefficient &m, double q_l, double q_m)
00415    { lambda = NULL; mu = &m; q_lambda = q_l; q_mu = q_m; }
00416 
00417    virtual void AssembleElementMatrix(const FiniteElement &,
00418                                       ElementTransformation &,
00419                                       DenseMatrix &);
00420 };
00421 
00422 
00425 class DiscreteInterpolator : public BilinearFormIntegrator { };
00426 
00427 
00431 class GradientInterpolator : public DiscreteInterpolator
00432 {
00433 public:
00434    virtual void AssembleElementMatrix2(const FiniteElement &h1_fe,
00435                                        const FiniteElement &nd_fe,
00436                                        ElementTransformation &Trans,
00437                                        DenseMatrix &elmat)
00438    { nd_fe.ProjectGrad(h1_fe, Trans, elmat); }
00439 };
00440 
00441 
00445 class IdentityInterpolator : public DiscreteInterpolator
00446 {
00447 public:
00448    virtual void AssembleElementMatrix2(const FiniteElement &dom_fe,
00449                                        const FiniteElement &ran_fe,
00450                                        ElementTransformation &Trans,
00451                                        DenseMatrix &elmat)
00452    { ran_fe.Project(dom_fe, Trans, elmat); }
00453 };
00454 
00455 
00459 class CurlInterpolator : public DiscreteInterpolator
00460 {
00461 public:
00462    virtual void AssembleElementMatrix2(const FiniteElement &dom_fe,
00463                                        const FiniteElement &ran_fe,
00464                                        ElementTransformation &Trans,
00465                                        DenseMatrix &elmat)
00466    { ran_fe.ProjectCurl(dom_fe, Trans, elmat); }
00467 };
00468 
00469 
00478 class DivergenceInterpolator : public DiscreteInterpolator
00479 {
00480 public:
00481    virtual void AssembleElementMatrix2(const FiniteElement &dom_fe,
00482                                        const FiniteElement &ran_fe,
00483                                        ElementTransformation &Trans,
00484                                        DenseMatrix &elmat)
00485    { ran_fe.ProjectDiv(dom_fe, Trans, elmat); }
00486 };
00487 
00488 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines