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

models/Eddy2D_H.hh
Go to the documentation of this file.
00001 
00006 #ifndef Eddy2D_hh
00007 #define Eddy2D_hh
00008 
00009 #include "operator/sparseMatrix.hh"
00010 #include "hp2D/hpAdaptiveSpaceH1.hh"
00011 #include "formula/boundary.hh"
00012 #include "models/adaptiveModels.hh"
00013 #include "models/maxwell.hh"
00014 #include "models/maxwellConstants.hh"
00015 #include "models/Eddy2D_geometries.hh"
00016 #include "models/Maxwell2D_H_eField.hh"
00017 
00018 namespace hp2D {
00019 
00020   using concepts::Real;
00021   using concepts::Real2d;
00022   using concepts::Cmplx;
00023 
00024   // forward declaration
00025   class InputEddy2D_H;
00026 
00027   // ***************************************************** Eddy2D_H_Interior **
00028 
00034   class Eddy2D_H_Interior : public concepts::OutputOperator {
00035   public:
00036     Eddy2D_H_Interior(const Real Omega_i, const Real H0) :
00037       Omega_i_(Omega_i), H0_(H0) {
00038       conceptsAssert(Omega_i > 0, concepts::Assertion());
00039     }
00041     Eddy2D_H_Interior(const Eddy2D_H_Interior& i) : 
00042       Omega_i_(i.Omega_i_), H0_(i.H0_) {}
00044     const Real Omega_i() const { return Omega_i_; }
00046     const Real H0() const { return H0_; }
00047   protected:
00048     virtual std::ostream& info(std::ostream& os) const {
00049       return os << "Eddy2D_H_Interior(Omega_i = " << Omega_i_ 
00050     << ", H0_i = " << H0_ << ")";
00051     }
00052   private:
00054     const Real Omega_i_;
00056     const Real H0_;
00057   };
00058 
00059   // ************************************************************** Eddy2D_H **
00060 
00066   class Eddy2D_H : public AdaptiveModel<Cmplx>, public concepts::MaxwellModel {
00067   public:
00069     enum solverType { SUPERLU = 0, BICGSTAB = 1};
00082     Eddy2D_H(concepts::EddyGeometry2D& geom, const concepts::Formula<Real>& H0,
00083        const concepts::Formula<Real2d>& curlH0,
00084        const concepts::Formula<Real>* divgradH0 = 0,
00085        Eddy2D_H_Interior* interior = 0, const uint geomRefAttrib = 100, 
00086        const Real omega = OMEGA50,
00087        const Real mu = MU0, enum solverType type = SUPERLU);
00096     Eddy2D_H(concepts::EddyGeometry2D& geom, const Real H0,
00097        Eddy2D_H_Interior* interior = 0, const uint geomRefAttrib = 100, 
00098        const Real omega = OMEGA50,
00099        const Real mu = MU0, enum solverType type = SUPERLU);
00100     Eddy2D_H(concepts::EddyGeometry2D& geom, InputEddy2D_H& input,
00101        const uint geomRefAttrib = 100);
00102     virtual ~Eddy2D_H() {}
00104     virtual hpAdaptiveSpaceH1& space() const;
00106     virtual Real dissipation();
00108     virtual Real magnEnergy();
00112     concepts::ElementFormula<Cmplx>* hField();
00116     concepts::ElementFormula<concepts::Cmplx2d>* eField();
00117   protected:
00118     virtual std::ostream& info(std::ostream& os) const;
00120     virtual const std::string mshAbbr_() { return geom_.meshAbbreviation(); }
00121   private:
00123     void constructor_(); 
00125     virtual hpFull& prebuild_() { return spc_->prebuild(); }
00127     virtual void solve_();
00129     void matrices_();
00131     void laplaceMatrix_();
00133     void identityMatrix_();
00135     bool connectedIdx_(uint& i);
00137     void systemMatrix_();
00139     void linearform_();
00140 
00142     std::auto_ptr<hpAdaptiveSpaceH1> spc_;
00144     concepts::EddyGeometry2D& geom_;
00146     std::auto_ptr<concepts::BoundaryConditions> bc_;
00148     std::auto_ptr<concepts::CellConditions> cc_;
00150     enum solverType type_;
00152     std::auto_ptr<concepts::Vector<Cmplx> > residual_;
00154     std::auto_ptr<Real> residualNorm_;
00156     std::auto_ptr<concepts::SparseMatrix<Real> > A_;
00158     std::auto_ptr<concepts::SparseMatrix<Real> > M_;
00160     std::auto_ptr<concepts::SparseMatrix<Cmplx> > S_;
00161     // load vector
00162     std::auto_ptr<concepts::Vector<Cmplx> > rhs_;
00164     concepts::PiecewiseFormulaFun<Real,Real> Sigma_Inv_;
00166     std::auto_ptr<const concepts::PiecewiseFormulaBase<Real> > H0_;
00167     std::auto_ptr<const concepts::PiecewiseFormulaBase<Real2d> > curlH0_;
00168     std::auto_ptr<const concepts::PiecewiseFormulaBase<Real> > divgradH0_;
00170      std::auto_ptr<Eddy2D_H_Interior> interior_;
00172     const Real omega_;
00174     const Real mu_;
00176     std::auto_ptr<Real> dissipation_;
00178     std::auto_ptr<Real> magnEnergy_;
00180     std::auto_ptr<const concepts::ElementFunction<Cmplx> > fun_;
00182     double solvetime_, matrixtime_, spacetime_;
00183   };
00184 
00185   // ****************************************************** InputEddy2D_H **
00186 
00194   class InputEddy2D_H : public concepts::InputParameter {
00195   public:
00197     InputEddy2D_H(concepts::InOutParameters& input);
00201     virtual std::ostream& letters(std::ostream& os) const;
00203     virtual std::ostream& arguments(std::ostream& os) const;
00205     virtual std::ostream& description(std::ostream& os) const;
00210     virtual int input(int opt, const char* optarg);
00212     const concepts::Sequence<Real>& omega() const { return omega_; }
00214     const concepts::PiecewiseFormulaBase<Real>* H0() const { return H0_; }
00216     const concepts::PiecewiseFormulaBase<Real2d>* curlH0() const {
00217       return curlH0_; }
00219     const concepts::PiecewiseFormulaBase<Real>* divgradH0() const { 
00220       return divgradH0_; }
00222     bool interior() const { return false; }
00224     enum Eddy2D_H::solverType type() const { return type_; }
00226     bool solving() const { return solving_; }
00227   protected:
00228     virtual std::ostream& info(std::ostream& os) const;
00229   private:
00231     concepts::Sequence<Real> omega_;
00233     concepts::PiecewiseFormulaBase<Real>* H0_;
00235     concepts::PiecewiseFormulaBase<Real2d>* curlH0_;
00237     concepts::PiecewiseFormulaBase<Real>* divgradH0_;
00239     bool defaultOmega_;
00241     enum Eddy2D_H::solverType type_;
00243     bool solving_;
00244   };
00245 
00246 } // namespace hp2D
00247 
00248 namespace concepts {
00249 
00250   // *************************************************** HField_CircularCoil **
00251 
00252   /* Formula for the magnetic field created by a circular coil
00253 
00254       @author  Kersten Schmidt, 2005
00255    */
00256   class HField_CircularCoil : public Formula<Real> {
00257   public:
00263     HField_CircularCoil(const Real R1, const Real R2, const Real h0 = 1.0) :
00264       R1_(R1), R2_(R2), h0_(h0) {
00265       conceptsAssert(R2 >= R1, Assertion());
00266       conceptsAssert(R1 >= 0, Assertion());
00267     }
00268     virtual Real operator() (const Real p, const Real t = 0.0) const {
00269       const Real r = std::abs(p);
00270       if (r >= R2_) return 0.0;
00271       if (r <= R1_) return h0_;
00272       return (R2_ - r)/(R2_ - R1_) * h0_;
00273     }
00274     virtual Real operator() (const Real2d& p, const Real t = 0.0) const {
00275       return (*this)(p.l2());
00276     }
00277     virtual Real operator() (const Real3d& p, const Real t = 0.0) const {
00278       return (*this)(p.l2());
00279     }
00280     virtual HField_CircularCoil* clone() const {
00281       return new HField_CircularCoil(R1_, R2_, h0_);
00282     }
00283   protected:
00284     virtual std::ostream& info(std::ostream& os) const {
00285       os << "HField_CircularCoil(r <= " << R1_ << " : " << h0_ << ", ";
00286       if (R2_ > R1_)
00287   os << R1_ << " < r <= " << R2_ << " : " << R2_/(R2_-R1_)*h0_ << "-("
00288      << h0_/(R2_-R1_) << ")*r, ";
00289       return os << "r > " << R2_ << " : 0.0)";
00290     }
00291   private:
00293     const Real R1_, R2_;
00295     const Real h0_;
00296   };
00297 
00298   // *********************************************** CurlHField_CircularCoil **
00299 
00300   /* Formula for the curl of the magnetic field created by a circular coil
00301 
00302       @author  Kersten Schmidt, 2006
00303    */
00304   class CurlHField_CircularCoil : public Formula<Real2d> {
00305   public:
00311     CurlHField_CircularCoil(const Real R1, const Real R2, const Real h0 = 1.0)
00312       : R1_(R1), R2_(R2), h0_(h0) {
00313       conceptsAssert(R2 >= R1, Assertion());
00314       conceptsAssert(R1 >= 0, Assertion());
00315     }
00316     virtual Real2d operator() (const Real p, const Real t = 0.0) const {
00317       return (*this)(Real2d(p,0));
00318     }
00319     virtual Real2d operator() (const Real2d& p, const Real t = 0.0) const {
00320       const Real r = p.l2();
00321       if (r >= R2_) return 0.0;
00322       if (r <= R1_) return 0.0;
00323       return Real2d(p[1], -p[0]) * (-h0_ /(R2_ - R1_) / r);
00324     }
00325     virtual Real2d operator() (const Real3d& p, const Real t = 0.0) const {
00326       return (*this)(Real2d(p));
00327     }
00328     virtual CurlHField_CircularCoil* clone() const {
00329       return new CurlHField_CircularCoil(R1_, R2_, h0_);
00330     }
00331   protected:
00332     virtual std::ostream& info(std::ostream& os) const {
00333       os << "CurlHField_CircularCoil(";
00334       if (R2_ > R1_)      
00335   os << "r <= " << R1_ << " : " << 0.0 << ", "
00336      << R1_ << " < r <= " << R2_ << " : (y,-x)^T/|r| * " 
00337      << h0_ / (R2_-R1_) << ", r > " << R2_ << " : 0.0";
00338       else os << "0.0";
00339       return os << ")";
00340     }
00341   private:
00343     const Real R1_, R2_;
00345     const Real h0_;
00346   };
00347 
00348   // ******************************************** DivGradHField_CircularCoil **
00349 
00350   /* Formula for the curl of the magnetic field created by a circular coil
00351 
00352       @author  Kersten Schmidt, 2006
00353    */
00354   class DivGradHField_CircularCoil : public Formula<Real> {
00355   public:
00361     DivGradHField_CircularCoil(const Real R1, const Real R2,
00362              const Real h0 = 1.0)
00363       : R1_(R1), R2_(R2), h0_(h0) {
00364       conceptsAssert(R2 >= R1, Assertion());
00365       conceptsAssert(R1 >= 0, Assertion());
00366     }
00367     virtual Real operator() (const Real p, const Real t = 0.0) const {
00368       return (*this)(Real2d(p,0));
00369     }
00370     virtual Real operator() (const Real2d& p, const Real t = 0.0) const {
00371       const Real r = p.l2();
00372       if (r >= R2_) return 0.0;
00373       if (r <= R1_) return 0.0;
00374       return -h0_/(R2_ - R1_)/r;
00375     }
00376     virtual Real operator() (const Real3d& p, const Real t = 0.0) const {
00377       return (*this)(Real2d(p));
00378     }
00379     virtual DivGradHField_CircularCoil* clone() const {
00380       return new DivGradHField_CircularCoil(R1_, R2_, h0_);
00381     }
00382   protected:
00383     virtual std::ostream& info(std::ostream& os) const {
00384       os << "DivGradHField_CircularCoil(";
00385       if (R2_ > R1_)      
00386   os << "r <= " << R1_ << " : " << 0.0 << ", "
00387      << R1_ << " < r <= " << R2_ << " : " << -h0_/(R2_ - R1_) << "/r"
00388      << ", r > " << R2_ << " : 0.0";
00389       else os << "0.0";
00390       return os << ")";
00391     }
00392   private:
00394     const Real R1_, R2_;
00396     const Real h0_;
00397   };
00398 
00399 
00400 } // namespace concepts
00401 
00402 #endif // Eddy2D_hh

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