Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Examples  

WeakForm.h

Go to the documentation of this file.
00001 #ifndef WEAKFORM_H
00002 #define WEAKFORM_H
00003 
00004 #include "SundanceDefs.h"
00005 
00006 #include "Expr.h"
00007 #include "BasisFamily.h"
00008 #include "QuadratureFamily.h"
00009 #include "MultiIndex.h"
00010 #include "XMLObject.h"
00011 
00012 
00013 namespace Sundance
00014 {
00015 
00016   using namespace TSF;
00017   using std::string;
00018 
00019   using std::ostream;
00020 
00021   class EquationSet;
00022 
00023   /** \ingroup LowLevelFE
00024    *
00025    * In a finite elements problem one must do integrals of the form
00026    * \f[ \int_C f(x) D^{(\alpha)} \phi_t  D^{(\beta)} \phi_s \f]
00027    * to obtain matrix entries and integrals of the form
00028    * \f[ \int_C f(x) D^{(\alpha)} \phi_t \f] to obtain vector entries. Here
00029    * \f$ \phi_t \f$ is a basis function for the test function space,
00030    * \f$ \phi_s \f$ is a basis function for the unk function space,
00031    * \f$ \alpha \f$ and \f$ \beta \f$ are multiindices that specify the
00032    * differentiation order and direction on the test and unk basis functions,
00033    * respectively, and \f$ f(x) \f$ is a coefficient function. If the integral
00034    * is to be done with quadrature, then one must also provide
00035    * a quadrature rule. A WeakForm object contains a unique
00036    * combination of basis families, multiindices,
00037    * coefficient function, and quadrature rule; all terms using that
00038    * combination are evaluated using that WeakForm.
00039    *
00040    * Several terms in a problem might share a common WeakForm but have
00041    * different function ID numbers or constant coefficents, and they
00042    * might contribute to different blocks in a block operator. For example,
00043    * in a Navier-Stokes problem the x and y components of velocity will have
00044    * the same basis functions, and the diffusion operator will be applied
00045    * in the same way to both. Thus, all velocity diffusion terms in a
00046    * Navier-Stokes problem can be represented with a common set of WeakForms.
00047    *
00048    *
00049    */
00050 
00051   class WeakForm
00052     {
00053     public:
00054       /** empty ctor for use in container classes */
00055       WeakForm();
00056 
00057       /** ctor for two-forms */
00058       WeakForm(EquationSet* eqnSet, int blockRow, int blockCol,
00059                const Expr& coeff,
00060                const Expr& var, const Expr& unk,
00061                const QuadratureFamily& quad, bool isBC);
00062       /** ctor for one-forms */
00063       WeakForm(EquationSet* eqnSet, int blockRow,
00064                const Expr& coeff, const Expr& var,
00065                const QuadratureFamily& quad, bool isBC);
00066 
00067       /** return the quadrature family common to all terms in this WeakForm */
00068       const QuadratureFamily& quad() const {return quad_;}
00069 
00070       /** return the coefficient function
00071        * common to all terms in this WeakForm */
00072       const Expr& coeff() const {return coeff_;}
00073 
00074       /** return the test function basis family common to all terms
00075        * in this WeakForm */
00076       const BasisFamily& test() const {return test_;}
00077 
00078       /** return the unk function basis family common to all terms
00079        * in this WeakForm */
00080       const BasisFamily& unk() const {return unk_;}
00081 
00082       /** return the multi-index used for all test functions in this weak
00083        * form */
00084       const MultiIndex& miTest() const {return miTest_;}
00085 
00086       /** return the multi-index used for all unk functions in this weak
00087        * form */
00088       const MultiIndex& miUnk() const {return miUnk_;}
00089 
00090       /** indicate whether this weak form has any terms in the
00091           given block */
00092       bool usesBlock(int blockRow, int blockCol) const ;
00093 
00094       /** indicate whether this weak form has any terms in the
00095           given block */
00096       bool usesBlock(int blockRow) const ;
00097 
00098       /**  get the list of testIDs for the given (blockRow, blockCol) */
00099       const TSFArray<int>& testIDList(int blockRow,
00100                                       int blockCol) const ;
00101 
00102       /**  get the list of unkIDs for the given (blockRow, blockCol) */
00103       const TSFArray<int>& unkIDList(int blockRow,
00104                                      int blockCol) const ;
00105 
00106       /** get the list of testIDs for the current block row. This
00107        *  should be used for one-forms only */
00108       const TSFArray<int>& testIDList(int blockRow) const ;
00109 
00110       /** get the list of constant coefficients
00111        * in the (blockRow, blockCol) subblock */
00112       const TSFArray<double>& termCoeff(int blockRow, int blockCol) const ;
00113 
00114       /** get the constant coefficients
00115        * in the blockRow-th subblock (one-forms only) */
00116       const TSFArray<double>& termCoeff(int blockCol) const ;
00117 
00118       /** get transposition flags for the (blockRow, blockCol) block */
00119       const TSFArray<bool>& isTransposed(int blockRow, int blockCol) const ;
00120 
00121       /** get the BC flags for the blockRow-th subblock */
00122       const TSFArray<bool>& isEssentialBC(int blockRow) const ;
00123 
00124       /** get the BC flags for the (blockRow, blockCol) block */
00125       const TSFArray<bool>& isEssentialBC(int blockRow, int blockCol ) const ;
00126 
00127       /** indicate whether this weakform is a one-form */
00128       bool isOneForm() const {return isOneForm_;}
00129 
00130       /** indicate whether this weakform is symmetric, that is, has the
00131        * same basis and multiindex for both test and unk function */
00132       bool isSymmetric() const {return isSymmetric_;}
00133 
00134       /** try to append a term with the given signature to the weak form.
00135        * If the term matches, return true, otherwise return false. */
00136       bool tryAppend(int blockRow, int blockCol,
00137                      const Expr& coeff, const Expr& var,
00138                      const Expr& unk, bool isBC);
00139 
00140       /** try to append a term with the given signature to the weak form.
00141        * If the term matches, return true, otherwise return false. */
00142       bool tryAppend(int blockRow, const Expr& coeff, const Expr& var,
00143                      bool isBC);
00144 
00145       /** write to XML */
00146       XMLObject toXML() const ;
00147 
00148     private:
00149       /** method to do common ctor operations */
00150       void init(int blockRow, int blockCol,
00151                 const Expr& var, const Expr& unk, bool isBC);
00152 
00153       /** unmanaged reverse pointer to the equation set that owns
00154        * this WeakForm */
00155       EquationSet* eqnSet_;
00156 
00157 
00158       /** \name Data that is common to all terms and blocks */
00159       //@{
00160       QuadratureFamily quad_;
00161       Expr coeff_;
00162       BasisFamily test_;
00163       BasisFamily unk_;
00164       MultiIndex miTest_;
00165       MultiIndex miUnk_;
00166       bool isOneForm_;
00167       bool isSymmetric_;
00168       //@}
00169 
00170       /** \name Data that is specific to a given (block, term) combination */
00171       //@{
00172       TSFArray<TSFArray<TSFArray<double> > > termCoeffs_;
00173       TSFArray<TSFArray<TSFArray<int> > > testID_;
00174       TSFArray<TSFArray<TSFArray<int> > > unkID_;
00175       TSFArray<TSFArray<TSFArray<bool> > > isTransposed_;
00176       TSFArray<TSFArray<TSFArray<bool> > > isEssentialBC_;
00177       //@}
00178 
00179       /** \name flags indicating whether a given block is nonzero */
00180       //@{
00181       TSFArray<TSFArray<bool> > isNonzero_;
00182       //@}
00183     };
00184 
00185   /** \relates WeakForm write to a stream */
00186   inline ostream& operator<<(ostream& os, const WeakForm& wf)
00187     {
00188       return os << wf.toXML();
00189     }
00190 
00191 
00192 }
00193 #endif
00194 
00195 

Contact:
Kevin Long (krlong@ca.sandia.gov)


Documentation generated by