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

app-bholger/gfem/gfemDiffraction.h
Go to the documentation of this file.
00001 #pragma once
00002 
00003 #include <string>
00004 
00005 #include "app-bholger/pml/pml_formula.h"
00006 #include "basics.hh"
00007 #include "toolbox.hh"
00008 #include "formula.hh"
00009 #include "geometry.hh"
00010 #include "space.hh"
00011 #include "graphics.hh"
00012 #include "function.hh"
00013 #include "operator.hh"
00014 #include "linearFEM.hh"
00015 #include "linDG1D.hh"
00016 #include "hp2D.hh"
00017 #include "gfemIdentity.h"
00018 #include "gfemLaplace.h"
00019 #include "hp2D/formula.hh"
00020 #include <string>
00021 #include "gfemAdvectionIgnore.h" 
00022 #include "gfemIdentityIgnore.h" 
00023 #include "hp1D/bilinearForm.hh"
00024 
00025 namespace concepts {
00026 namespace gfem {
00027 
00028 typedef std::map<int, double> MID;
00029 
00033 class GfemDiffraction {
00034 public:
00035   enum EquationType {TRANSVERSAL_ELECTRIC, TRANSVERSAL_MAGNETIC};
00036 
00037   GfemDiffraction(const SpaceOnCells<Real>& space, 
00038           EquationType type, 
00039           const MID& attrToEpsilon, 
00040           double omega,
00041           const BoundaryConditions& bc,
00042           Set<uint> nonRefl_bdAttr
00043           );
00044 
00045   static PiecewiseConstFormula<Cmplx> genTMCoeff(
00046           const MID& attToEps);
00047 
00048   static PiecewiseConstFormula<Cmplx> genTECoeff(
00049           const MID& attToEps);
00050 
00052   void setRhs(const std::string& rhs_r, const std::string& rhs_i);
00053         
00054   void adjustFloquetT(int dir, Cmplx k, int pml_cellAttrib 
00055       , RCP<const ElementFormula<Cmplx> >    uinc_F
00056       , RCP<const ElementFormula<Cmplx2d> > Duinc_F
00057       , concepts::Set<uint> pml_innerAttrib
00058       , Real2d center
00059       );
00060   
00062   void setNonRefl(Set<uint> nonRefl_bdAttr, 
00063       std::string u_inc_r, std::string u_inc_i,  
00064       std::string Du_inc_r, std::string Du_inc_i  
00065       );
00066  
00067   static const bool CONTRIB_RHS = true;
00068   static const bool NOCONTRIB_RHS = false;
00069 
00070   void set0thSommerfeld(Set<uint> nonRefl_bdAttr
00071       , RCP< concepts::ElementFormula< Cmplx > > rhs_F
00072       , RCP< concepts::ElementFormula< Cmplx > > dn_rhs_F
00073       , bool contribRHS = CONTRIB_RHS 
00074       );
00075  
00076   void setPMLBC(Real2d center, Real2d dist, Real strength, Real powercoeff
00077                 , Real omega
00078                 , RCP<const ElementFormula<Cmplx> > uinc_F
00079                 , RCP<const ElementFormula<Cmplx2d> > Duinc_F
00080                 , int pml_cellAttrib
00081                 , concepts::Set<uint> pml_innerAttrib
00082                 , concepts::Set<uint> pml_outerAttrib
00083                 , RCP<const ElementFormula<Cmplx> > b2_0_F
00084       );
00085 
00086   // TODO: extend for the case where a(x) != const
00087   void setPMLBC_sc(
00088       Real2d center, Real2d dist, Real strength, Real powercoeff
00089       , Real omega
00090       , RCP<const ElementFormula<Cmplx> > uinc_F
00091       , RCP<const ElementFormula<Cmplx2d> > Duinc_F
00092       , RCP<const ElementFormula<Cmplx> > DaDuinc_F
00093       , concepts::Set<uint> innerAttrib
00094       , concepts::Set<uint> pml_outerAttrib
00095       , RCP<const ElementFormula<Cmplx> > b2_0_F
00096       );
00097 
00102   void setDtN( Set<uint> nonRefl_bdAttrTop
00103       , Set<uint> nonRefl_bdAttrBottom
00104       , Set<uint> nonRefl_bdAttr
00105       , std::string u_inc_r, std::string u_inc_i
00106       , std::string Du_inc_r, std::string Du_inc_i
00107       , int approx_oder
00108       , double min_y = 0
00109       );
00110 
00112   void solve(Vector<Cmplx>& sol );
00113 
00114   void storeBFeig(std::string path, bool verbose=false);
00115 
00116 
00117   // not yet supported
00118   //void setKPer(Cmplx k0, Cmplx k1);
00119 
00120   void setKPer(Cmplx k0);
00121   
00125   void compressSystemM() {
00126     system_M->compress();
00127   }
00128 
00129  #if 0
00130 
00131   void solveQR(Vector<Cmplx>& sol );
00132 #endif
00133   
00134   void storeSystemM(const std::string& filename, Vector<Cmplx>* sol = NULL);
00135 
00136   void setOmega(double omega);
00137 
00138   void setB0(double b0) {
00139     this->b0 = b0;
00140   }
00141 
00142   double getb0() {
00143     return b0;
00144   }
00145 
00146   const hp2D::TraceSpace& getTraceSpace() { 
00147     return trace_space;
00148   }
00149 
00150   void assemble();
00151   
00152   void regularizeL2Penalty(double eps);
00153 
00154 private:
00155   const SpaceOnCells<Real>& space;
00156   hp2D::TraceSpace trace_space;
00157   BoundaryConditions bc;
00158 
00159   double omega;
00160   double b0; 
00161   Cmplx kPer; 
00162 
00163 public:
00164   static PiecewiseConstFormula<Cmplx> zero_PW;
00165   static PiecewiseConstFormula<Cmplx> one_PW;
00166 
00167   PiecewiseConstFormula<Cmplx> coeffId;
00168   PiecewiseConstFormula<Cmplx> coeffLap;
00169   RCP< const ElementFormula<Cmplx> > pmlcoeff_ident;
00170   RCP< const ElementFormula<Cmplx> > pmlLapCoeff_ident;
00171   RCP< const ElementFormula<Cmplx> > pmlLapCoeff_advectx;
00172   RCP< const ElementFormula<Cmplx> > pmlLapCoeff_advecty;
00173   RCP< concepts::MatrixElementFormula<Cmplx, 2> > coeffLapMat;
00174 
00175   RCP< SparseMatrix<Cmplx> > id_trace_M;
00176 
00177 private:
00178   GfemLaplace lap_BF;
00179   GfemIdentity id_mass_BF;
00180   //GfemIdentity id_trace_BF;
00181   hp1D::Identity< Cmplx > id_trace_BF;
00182   RCP< GfemAdvectionIgnore > advect; // i * k0 * int(a u \conj v)
00183   RCP< GfemIdentityIgnore > id_mass_k2;
00184 
00185   Vector<Cmplx> rhs;
00186   RCP< SparseMatrix<Cmplx> > lap_M;
00187   RCP< SparseMatrix<Cmplx> > lapPML_M;
00188   RCP< SparseMatrix<Cmplx> > id_mass_M;
00189   RCP< SparseMatrix<Cmplx> > id_mass_k2_M;
00190   RCP< SparseMatrix<Cmplx> > advect_M;
00191 
00192   RCP< SparseMatrix<Cmplx> > system_M;
00193 
00194   RCP< FormulaPMLPowerSigma<Real> > sigma_x;
00195   RCP< FormulaPMLPowerSigma<Real> > sigma_y;
00196 };
00197 
00198 } // namespace
00199 } // namespace

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