Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

models/Maxwell2D_H.hh
Go to the documentation of this file.
00001 
00007 #ifndef Maxwell2D_H_hh
00008 #define Maxwell2D_H_hh
00009 
00010 #include "operator/sparseMatrix.hh"
00011 #include "operator/domainDecomp.hh"
00012 #include "hp2D/hpAdaptiveSpaceH1.hh"
00013 #include "formula/boundary.hh"
00014 #include "models/adaptiveModels.hh"
00015 #include "models/maxwell.hh"
00016 #include "models/maxwellConstants.hh"
00017 #include "models/Eddy2D_geometries.hh"
00018 #include "models/Maxwell2D_H_eField.hh"
00019 #include "space/domainDecomp.hh"
00020 
00021 namespace hp2D {
00022 
00023   using concepts::Real;
00024   using concepts::Cmplx;
00025 
00026   // forward declaration
00027   class InputMaxwell2D_H;
00028 
00029   // ****************************************************** Maxwell2D_H_Base **
00030 
00036   class Maxwell2D_H_Base : public AdaptiveModel<Cmplx>,
00037          public concepts::MaxwellModel,
00038          public concepts::MaxwellBoundary {
00039     friend class concepts::ModelControl<Maxwell2D_H_Base>;
00040   public:
00042     enum solverType { SUPERLU = 0, SUPERLU2 = 1, BICGSTAB = 2, BICGSTAB2 = 3,
00043           BICGSTABSUPERLU = 4};
00055     Maxwell2D_H_Base(concepts::EddyGeometry2D& geom,
00056          enum boundaryType bType = PMC,
00057          enum solverType type = SUPERLU, bool diagPrecond = true,
00058          bool afterIter = false,
00059          const Real eps = EPS0, const Real omega = OMEGA50,
00060          const Real mu = MU0, const uint geomRefAttrib = 100);
00061     Maxwell2D_H_Base(concepts::EddyGeometry2D& geom, InputMaxwell2D_H& input,
00062          const uint geomRefAttrib = 100);
00063     virtual ~Maxwell2D_H_Base() {}
00064   protected:
00065     virtual std::ostream& info(std::ostream& os) const;
00067     virtual const std::string mshAbbr_() { return geom_.meshAbbreviation(); }
00069     concepts::SparseMatrix<Cmplx>*
00070     laplaceMatrix_(concepts::Space<Real>& spc,
00071        concepts::SparseMatrix<Cmplx>* S);
00073     concepts::SparseMatrix<Real>*
00074     identityMatrix_(concepts::Space<Real>& spc,
00075         concepts::SparseMatrix<Cmplx>* S);
00077     void linearform_();
00078 
00080     concepts::EddyGeometry2D& geom_;
00082     std::auto_ptr<concepts::BoundaryConditions> bc_;
00084     enum solverType type_;
00086     bool diagPrecond_;
00088     bool afterIter_, statusAfterIter_;
00089     std::auto_ptr<concepts::Vector<Cmplx> > residual_;
00091     std::auto_ptr<Real> residualNorm_;
00092     // load vector
00093     std::auto_ptr<concepts::Vector<Cmplx> > rhs_;
00095     concepts::PiecewiseFormulaFun<Cmplx, Real> iOmegaEps_plus_Sigma_Inv_;
00097     Real eps_;
00099     Real omega_;
00101     const Real mu_;
00103     std::auto_ptr<Real> dissipation_;
00105     std::auto_ptr<Real> magnEnergy_;
00107     double solvetime_, matrixtime_, spacetime_;
00109     uint iterations_;
00110   private:
00112     void constructor_(); 
00113   };
00114 
00115   // *********************************************************** Maxwell2D_H **
00116   
00122   class Maxwell2D_H : public Maxwell2D_H_Base {
00123     friend class concepts::ModelControl<Maxwell2D_H>;
00124   public:
00136     Maxwell2D_H(concepts::EddyGeometry2D& geom,
00137     enum concepts::MaxwellBoundary::boundaryType bType = PMC,
00138     enum solverType type = SUPERLU, bool diagPrecond = true,
00139     bool afterIter = false,
00140     const Real eps = EPS0, const Real omega = OMEGA50,
00141     const Real mu = MU0, const uint geomRefAttrib = 100);
00142     Maxwell2D_H(concepts::EddyGeometry2D& geom, InputMaxwell2D_H& input,
00143     const uint geomRefAttrib = 100);
00144     virtual ~Maxwell2D_H() {}
00146     virtual hpAdaptiveSpaceH1& space() const;
00148     virtual Real dissipation();
00150     virtual Real magnEnergy();
00154     concepts::ElementFormula<Cmplx>* hField();
00158     concepts::ElementFormula<concepts::Cmplx2d>* eField();
00159   protected:
00160     virtual std::ostream& info(std::ostream& os) const;
00162     virtual hpFull& prebuild_() { return spc_->prebuild(); }
00163   private:
00165     std::auto_ptr<hpAdaptiveSpaceH1> spc_;
00167     std::auto_ptr<concepts::SparseMatrix<Cmplx> > A_, S_;
00169     std::auto_ptr<concepts::SparseMatrix<Real> > M_;
00170 
00172     void constructSpace_();
00174     virtual void solve_();
00176     void matrices_();
00177   };
00178 
00179   // ******************************************************** Maxwell2D_H_DD **
00180   
00186   class Maxwell2D_H_DD : public Maxwell2D_H_Base {
00187     friend class concepts::ModelControl<Maxwell2D_H_DD>;
00188   public:
00189     Maxwell2D_H_DD(concepts::EddyGeometry2D& geom,
00190        enum concepts::MaxwellBoundary::boundaryType bType,
00191        enum solverType type = SUPERLU, bool diagPrecond = true,
00192        bool afterIter = false,
00193        const Real eps = EPS0, const Real omega = OMEGA50,
00194        const Real mu = MU0, const uint geomRefAttrib = 100,
00195        std::string domains = "(2)");
00196     Maxwell2D_H_DD(concepts::EddyGeometry2D& geom, InputMaxwell2D_H& input,
00197        const uint geomRefAttrib = 100,
00198        std::string domains = "(2)");
00199     virtual ~Maxwell2D_H_DD();
00200 
00201     virtual concepts::DomainDecomp<hpAdaptiveSpaceH1>& space() const { 
00202       return *spc_;
00203     }
00205     Real dissipation();
00207     Real magnEnergy();
00208   protected:
00209     virtual std::ostream& info(std::ostream& os) const;
00211     virtual hpFull& prebuild_() { return prebuilds_; }
00212   private:
00214     hp2D::hpFull prebuilds_;
00216     std::auto_ptr<concepts::DomainDecomp<hp2D::hpAdaptiveSpaceH1> > spc_;
00218     concepts::Sequence<concepts::SparseMatrix<Cmplx>*> A_, S_;
00220     concepts::Sequence<concepts::SparseMatrix<Real>*> M_;
00221 
00223     void constructSpace_(const std::string& domainStr);
00224 
00226     virtual void solve_();
00228     void matrices_();
00230     void laplaceMatrix_();
00232     void identityMatrix_();
00233     
00234 
00235     template<class F>
00236     void clear_(concepts::Sequence<F*>& seq);
00237   };
00238 
00239   template<class F>
00240   void Maxwell2D_H_DD::clear_(concepts::Sequence<F*>& seq) {
00241     for (typename concepts::Sequence<F*>::iterator i = seq.begin(); 
00242    i != seq.end(); ++i)
00243       delete *i;
00244     seq.clear();
00245   }
00246 
00247   // ****************************************************** InputMaxwell2D_H **
00248 
00257   class InputMaxwell2D_H : public concepts::InputParameter {
00258   public:
00260     InputMaxwell2D_H(concepts::InOutParameters& input);
00264     virtual std::ostream& letters(std::ostream& os) const;
00266     virtual std::ostream& arguments(std::ostream& os) const;
00268     virtual std::ostream& description(std::ostream& os) const;
00273     virtual int input(int opt, const char* optarg);
00275     const concepts::Sequence<Real>& omega() const { return omega_; }
00277     enum Maxwell2D_H::solverType type() const { return type_; }
00279     enum concepts::MaxwellBoundary::boundaryType boundary() const { 
00280       return bType_;
00281     }
00283     bool solving() const { return solving_; }
00284   protected:
00285     virtual std::ostream& info(std::ostream& os) const;
00286   private:
00288     enum concepts::MaxwellBoundary::boundaryType bType_;
00290     concepts::Sequence<Real> omega_;
00292     bool defaultOmega_;
00294     enum Maxwell2D_H::solverType type_;
00296     bool solving_;
00297   };
00298 
00299 } // namespace hp2D
00300 
00301 namespace concepts {
00302 
00303   // ********************************** ModelControl<hp2D::Maxwell2D_H_Base> **
00304 
00305   template<>
00306   class ModelControl<hp2D::Maxwell2D_H_Base> : 
00307     public ModelControlBase<Model<Cmplx> > {
00308   public:
00310     ModelControl(hp2D::Maxwell2D_H_Base& model);
00311     virtual ~ModelControl() {}
00312 
00313     virtual hp2D::Maxwell2D_H_Base& model() {
00314       return static_cast<hp2D::Maxwell2D_H_Base&>(model_);
00315     }
00316     virtual const hp2D::Maxwell2D_H_Base& model() const {
00317       return static_cast<const hp2D::Maxwell2D_H_Base&>(model_);
00318     }
00320     virtual void matrices() = 0;
00322     void solverType(enum hp2D::Maxwell2D_H_Base::solverType type,
00323         bool diagPrecond);
00325     virtual Real solve() = 0;
00327     void storeMatricesToMatlab(const std::string matrixFile) const;
00329     void setOmega(const Real omega);
00331     void setEpsilon(const Real epsilon);
00336     void graphicsOut(const uint numPoints, const std::string path = "");
00338     hp2D::hpFull& prebuild() { return model().prebuild_(); }
00339   protected:
00340     virtual std::ostream& info(std::ostream& os) const;
00341   };
00342 
00343   // *************************************** ModelControl<hp2D::Maxwell2D_H> **
00344 
00345   template<>
00346   class ModelControl<hp2D::Maxwell2D_H> :
00347     public ModelControl<hp2D::Maxwell2D_H_Base> {
00348   public:
00350     ModelControl(hp2D::Maxwell2D_H& model);
00351     virtual ~ModelControl() {}
00352     virtual hp2D::Maxwell2D_H& model() {
00353       return static_cast<hp2D::Maxwell2D_H&>(model_);
00354     }
00355     virtual const hp2D::Maxwell2D_H& model() const {
00356       return static_cast<const hp2D::Maxwell2D_H&>(model_);
00357     }
00359     virtual void matrices();
00361     virtual Real solve();
00363     void storeMatricesToMatlab(const std::string matrixFile) const;
00370     void setOmega(const Real omega, bool assembleMatrices);
00377     void setEpsilon(const Real epsilon, bool assembleMatrices);
00382     void graphicsOut(const uint numPoints, const std::string path = "");
00383   protected:
00384     virtual std::ostream& info(std::ostream& os) const;
00385   };
00386 
00387   // *********************************** ModelControl<hp2D::Maxwell2D_H_DD> **
00388 
00389   template<>
00390   class ModelControl<hp2D::Maxwell2D_H_DD> :
00391     public ModelControl<hp2D::Maxwell2D_H_Base> {
00392   public:
00394     ModelControl(hp2D::Maxwell2D_H_DD& model);
00395     virtual ~ModelControl() {}
00396     virtual hp2D::Maxwell2D_H_DD& model() {
00397       return static_cast<hp2D::Maxwell2D_H_DD&>(model_);
00398     }
00399     virtual const hp2D::Maxwell2D_H_DD& model() const {
00400       return static_cast<const hp2D::Maxwell2D_H_DD&>(model_);
00401     }
00403     virtual void matrices();
00405     virtual Real solve();
00407     void storeMatricesToMatlab(const std::string matrixFile) const;
00413     void setOmega(const Real omega, bool assembleMatrices);
00414   protected:
00415     virtual std::ostream& info(std::ostream& os) const;
00416   };
00417 
00418 } // namespace concepts
00419 
00420 
00421 
00422 #endif // Maxwell2D_H_hh
00423 

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)