1 /*
2 XLiFE++ is an extended library of finite elements written in C++
3     Copyright (C) 2014  Lun�ville, Eric; Kielbasiewicz, Nicolas; Lafranche, Yvon; Nguyen, Manh-Ha; Chambeyron, Colin
4 
5     This program is free software: you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation, either version 3 of the License, or
8     (at your option) any later version.
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13     You should have received a copy of the GNU General Public License
14     along with this program.  If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 /*!
18   \file BilinearFormAsLinearForm.hpp
19   \author E. Lun�ville
20   \since 23 mar 2012
21   \date  01 apr 2012
22 
23   \brief Definition of the xlifepp::LinearForm classes
24 */
25 #ifndef BILINEARFORM_AS_LINEARFORM_HPP
26 #define BILINEARFORM_AS_LINEARFORM_HPP
27 
28 #include "config.h"
29 #include "KernelOperatorOnTermVector.hpp"
30 
31 namespace xlifepp
32 {
33 /*!
34    \class BilinearFormAsLinearForm
35    describes a linear form based on a Bilinearform a(u,v) where u or v are specified as a TermVector
36 */
37 class BilinearFormAsLinearForm : public BasicLinearForm
38 {
39   protected :
40       BasicBilinearForm* blf_;     //!< Basic bilinear form a(u,v)
41       const TermVector* tv_;       //!< TermVector
42   public :
43       bool asUnknown_;        //!< true if tv_ is realted to unknown u, false if tv_ is related to test function v
44 
45   //! Constructor with a reference of BasicLinearForm
BilinearFormAsLinearForm(const BasicBilinearForm & blf,const TermVector & tv,bool asUnknown)46   BilinearFormAsLinearForm(const BasicBilinearForm& blf, const TermVector& tv, bool asUnknown)
47      : blf_(blf.clone()), tv_(&tv), asUnknown_(asUnknown) {}
48   //! Constructor with a pointer of BasicBilinearForm
BilinearFormAsLinearForm(BasicBilinearForm * blf,const TermVector & tv,bool asUnknown)49   BilinearFormAsLinearForm(BasicBilinearForm* blf, const TermVector& tv, bool asUnknown)
50      :  blf_(blf), tv_(&tv), asUnknown_(asUnknown) {if(asUnknown) u_p=&blf->vp(); else u_p=&blf->up();}
51 
52   //! copy-constructor
BilinearFormAsLinearForm(const BilinearFormAsLinearForm & blfaslf)53   BilinearFormAsLinearForm(const BilinearFormAsLinearForm& blfaslf)
54      {
55          u_p = blfaslf.u_p;
56          blf_= blfaslf.blf_->clone();
57          tv_= blfaslf.tv_;
58          asUnknown_=blfaslf.asUnknown_;
59      }
60   //! operator = (copy-constructor)
operator =(const BilinearFormAsLinearForm & blfaslf)61   BilinearFormAsLinearForm& operator = (const BilinearFormAsLinearForm& blfaslf)
62     {
63          if(this == &blfaslf) return *this;
64          if(blf_!=0) delete blf_;
65          u_p = blfaslf.u_p;
66          blf_= blfaslf.blf_->clone();
67          tv_= blfaslf.tv_;
68          asUnknown_=blfaslf.asUnknown_;
69          return *this;
70     }
71     //! destructor
~BilinearFormAsLinearForm()72   ~BilinearFormAsLinearForm()
73     {if(blf_!=0) delete blf_;}
74 //! return the attribute basicLinearForm_
blf() const75   BasicBilinearForm* blf() const {return blf_;}
76 //! return the attribute TermVector tv_
termVector() const77   const TermVector* termVector() const {return tv_;}
clone() const78   virtual BasicLinearForm* clone() const        //! clone of the linear form
79      {return new BilinearFormAsLinearForm(*this);}
type() const80   virtual LinearFormType type() const            //! return the type of the linear form
81     {return _bilinearAsLinear;}
valueType() const82   virtual ValueType valueType() const            //! return the value type of the linear form
83     {return blf_->valueType();}
strucType() const84   virtual StrucType strucType() const            //! return the structure type of the linear form
85     {if(asUnknown_) return blf_->vp().strucType(); else return blf_->up().strucType();}
domain() const86   const GeomDomain* domain() const               //! return the pointer to the domain
87     {if(asUnknown_) return &blf_->dom_vp(); else return &blf_->dom_up();}
88 
asString() const89   virtual string_t asString() const
90     {return "";}
91   virtual void print(std::ostream&) const;       //!< print utility
print(PrintStream & os) const92   virtual void print(PrintStream& os) const {print(os.currentStream());}  //!< print to current stream
93 };
94 
95 //!reinterpretation of double integrals as linear forms
96 LinearForm intg(const GeomDomain& domx, const GeomDomain& domy,
97                 const KernelOperatorOnTermVectorAndUnknown& koptvv,
98                 const IntegrationMethod& im);
99 LinearForm intg(const GeomDomain& domx, const GeomDomain& domy,
100                 const KernelOperatorOnTermVectorAndUnknown& koptvv,
101                 QuadRule qr, number_t qro);
102 LinearForm intg(const GeomDomain& domx, const GeomDomain& domy,
103                 const KernelOperatorOnTermVectorAndUnknown& koptvv);
104 
105 } //end of namespace xlifepp
106 
107 #endif // BILINEARFORM_AS_LINEARFORM_HPP
108