Maxwell2D_H.hh

Go to the documentation of this file.
1 
7 #ifndef Maxwell2D_H_hh
8 #define Maxwell2D_H_hh
9 
10 #include "operator/sparseMatrix.hh"
11 #include "operator/domainDecomp.hh"
13 #include "formula/boundary.hh"
14 #include "models/adaptiveModels.hh"
15 #include "models/maxwell.hh"
19 #include "space/domainDecomp.hh"
20 
21 namespace hp2D {
22 
23  using concepts::Real;
24  using concepts::Cmplx;
25 
26  // forward declaration
27  class InputMaxwell2D_H;
28 
29  // ****************************************************** Maxwell2D_H_Base **
30 
36  class Maxwell2D_H_Base : public AdaptiveModel<Cmplx>,
40  public:
42  enum solverType { SUPERLU = 0, SUPERLU2 = 1, BICGSTAB = 2, BICGSTAB2 = 3,
56  enum boundaryType bType = PMC,
57  enum solverType type = SUPERLU, bool diagPrecond = true,
58  bool afterIter = false,
59  const Real eps = EPS0, const Real omega = OMEGA50,
60  const Real mu = MU0, const uint geomRefAttrib = 100);
62  const uint geomRefAttrib = 100);
63  virtual ~Maxwell2D_H_Base() {}
64  protected:
65  virtual std::ostream& info(std::ostream& os) const;
67  virtual const std::string mshAbbr_() { return geom_.meshAbbreviation(); }
77  void linearform_();
78 
82  std::unique_ptr<concepts::BoundaryConditions> bc_;
84  enum solverType type_;
89  std::unique_ptr<concepts::Vector<Cmplx> > residual_;
91  std::unique_ptr<Real> residualNorm_;
92  // load vector
93  std::unique_ptr<concepts::Vector<Cmplx> > rhs_;
101  const Real mu_;
103  std::unique_ptr<Real> dissipation_;
105  std::unique_ptr<Real> magnEnergy_;
110  private:
112  void constructor_();
113  };
114 
115  // *********************************************************** Maxwell2D_H **
116 
122  class Maxwell2D_H : public Maxwell2D_H_Base {
123  friend class concepts::ModelControl<Maxwell2D_H>;
124  public:
138  enum solverType type = SUPERLU, bool diagPrecond = true,
139  bool afterIter = false,
140  const Real eps = EPS0, const Real omega = OMEGA50,
141  const Real mu = MU0, const uint geomRefAttrib = 100);
143  const uint geomRefAttrib = 100);
144  virtual ~Maxwell2D_H() {}
146  virtual hpAdaptiveSpaceH1& space() const;
148  virtual Real dissipation();
150  virtual Real magnEnergy();
159  protected:
160  virtual std::ostream& info(std::ostream& os) const;
162  virtual hpFull& prebuild_() { return spc_->prebuild(); }
163  private:
165  std::unique_ptr<hpAdaptiveSpaceH1> spc_;
167  std::unique_ptr<concepts::SparseMatrix<Cmplx> > A_, S_;
169  std::unique_ptr<concepts::SparseMatrix<Real> > M_;
170 
174  virtual void solve_();
176  void matrices_();
177  };
178 
179  // ******************************************************** Maxwell2D_H_DD **
180 
188  public:
191  enum solverType type = SUPERLU, bool diagPrecond = true,
192  bool afterIter = false,
193  const Real eps = EPS0, const Real omega = OMEGA50,
194  const Real mu = MU0, const uint geomRefAttrib = 100,
195  std::string domains = "(2)");
197  const uint geomRefAttrib = 100,
198  std::string domains = "(2)");
199  virtual ~Maxwell2D_H_DD();
200 
202  return *spc_;
203  }
208  protected:
209  virtual std::ostream& info(std::ostream& os) const;
211  virtual hpFull& prebuild_() { return prebuilds_; }
212  private:
216  std::unique_ptr<concepts::DomainDecomp<hp2D::hpAdaptiveSpaceH1> > spc_;
221 
223  void constructSpace_(const std::string& domainStr);
224 
226  virtual void solve_();
228  void matrices_();
233 
234 
235  template<class F>
236  void clear_(concepts::Sequence<F*>& seq);
237  };
238 
239  template<class F>
241  for (typename concepts::Sequence<F*>::iterator i = seq.begin();
242  i != seq.end(); ++i)
243  delete *i;
244  seq.clear();
245  }
246 
247  // ****************************************************** InputMaxwell2D_H **
248 
258  public:
264  virtual std::ostream& letters(std::ostream& os) const;
266  virtual std::ostream& arguments(std::ostream& os) const;
268  virtual std::ostream& description(std::ostream& os) const;
273  virtual int input(int opt, const char* optarg);
275  const concepts::Sequence<Real>& omega() const { return omega_; }
277  enum Maxwell2D_H::solverType type() const { return type_; }
280  return bType_;
281  }
283  bool solving() const { return solving_; }
284  protected:
285  virtual std::ostream& info(std::ostream& os) const;
286  private:
296  bool solving_;
297  };
298 
299 } // namespace hp2D
300 
301 namespace concepts {
302 
303  // ********************************** ModelControl<hp2D::Maxwell2D_H_Base> **
304 
305  template<>
306  class ModelControl<hp2D::Maxwell2D_H_Base> :
307  public ModelControlBase<Model<Cmplx> > {
308  public:
311  virtual ~ModelControl() {}
312 
314  return static_cast<hp2D::Maxwell2D_H_Base&>(model_);
315  }
316  virtual const hp2D::Maxwell2D_H_Base& model() const {
317  return static_cast<const hp2D::Maxwell2D_H_Base&>(model_);
318  }
320  virtual void matrices() = 0;
323  bool diagPrecond);
325  virtual Real solve() = 0;
327  void storeMatricesToMatlab(const std::string matrixFile) const;
329  void setOmega(const Real omega);
331  void setEpsilon(const Real epsilon);
336  void graphicsOut(const uint numPoints, const std::string path = "");
338  hp2D::hpFull& prebuild() { return model().prebuild_(); }
339  protected:
340  virtual std::ostream& info(std::ostream& os) const;
341  };
342 
343  // *************************************** ModelControl<hp2D::Maxwell2D_H> **
344 
345  template<>
346  class ModelControl<hp2D::Maxwell2D_H> :
347  public ModelControl<hp2D::Maxwell2D_H_Base> {
348  public:
351  virtual ~ModelControl() {}
353  return static_cast<hp2D::Maxwell2D_H&>(model_);
354  }
355  virtual const hp2D::Maxwell2D_H& model() const {
356  return static_cast<const hp2D::Maxwell2D_H&>(model_);
357  }
359  virtual void matrices();
361  virtual Real solve();
363  void storeMatricesToMatlab(const std::string matrixFile) const;
370  void setOmega(const Real omega, bool assembleMatrices);
377  void setEpsilon(const Real epsilon, bool assembleMatrices);
382  void graphicsOut(const uint numPoints, const std::string path = "");
383  protected:
384  virtual std::ostream& info(std::ostream& os) const;
385  };
386 
387  // *********************************** ModelControl<hp2D::Maxwell2D_H_DD> **
388 
389  template<>
390  class ModelControl<hp2D::Maxwell2D_H_DD> :
391  public ModelControl<hp2D::Maxwell2D_H_Base> {
392  public:
395  virtual ~ModelControl() {}
397  return static_cast<hp2D::Maxwell2D_H_DD&>(model_);
398  }
399  virtual const hp2D::Maxwell2D_H_DD& model() const {
400  return static_cast<const hp2D::Maxwell2D_H_DD&>(model_);
401  }
403  virtual void matrices();
405  virtual Real solve();
407  void storeMatricesToMatlab(const std::string matrixFile) const;
413  void setOmega(const Real omega, bool assembleMatrices);
414  protected:
415  virtual std::ostream& info(std::ostream& os) const;
416  };
417 
418 } // namespace concepts
419 
420 
421 
422 #endif // Maxwell2D_H_hh
423 
Base class for calculating Eddy current problem with Maxwell modell in h formulation.
Definition: Maxwell2D_H.hh:38
std::unique_ptr< concepts::Vector< Cmplx > > residual_
Definition: Maxwell2D_H.hh:89
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
concepts::Sequence< concepts::SparseMatrix< Real > * > M_
Mass matrix.
Definition: Maxwell2D_H.hh:220
bool defaultOmega_
Flag, if no omega is given.
Definition: Maxwell2D_H.hh:292
std::unique_ptr< concepts::Vector< Cmplx > > rhs_
Definition: Maxwell2D_H.hh:93
Real dissipation()
Return dissipation power loss.
const Real EPS0
Real magnEnergy()
Return magnetic energy.
virtual hpAdaptiveSpaceH1 & space() const
Returns the space.
const Real MU0
std::unique_ptr< Real > dissipation_
Dissipation power loss.
Definition: Maxwell2D_H.hh:103
virtual hp2D::Maxwell2D_H_DD & model()
Returns the model.
Definition: Maxwell2D_H.hh:396
Maxwell2D_H_Base(concepts::EddyGeometry2D &geom, InputMaxwell2D_H &input, const uint geomRefAttrib=100)
Base class for controlling a model.
Definition: models.hh:27
void solverType(enum hp2D::Maxwell2D_H_Base::solverType type, bool diagPrecond)
Change the solver type.
bool solving() const
Returns true, if model should be solved.
Definition: Maxwell2D_H.hh:283
virtual std::ostream & description(std::ostream &os) const
Returns description for help.
void graphicsOut(const uint numPoints, const std::string path="")
Writes matlab graphics files.
Class for calculating Eddy current problem with Maxwell modell in h formulation, with Domain Decompos...
Definition: Maxwell2D_H.hh:186
solverType
Type of the solver.
Definition: Maxwell2D_H.hh:42
void identityMatrix_()
Calculate identity matrix.
Maxwell2D_H(concepts::EddyGeometry2D &geom, InputMaxwell2D_H &input, const uint geomRefAttrib=100)
virtual std::ostream & info(std::ostream &os) const
enum solverType type_
Solver type.
Definition: Maxwell2D_H.hh:84
double solvetime_
Time to solve the system, to build the matrices, to rebuild the space.
Definition: Maxwell2D_H.hh:107
virtual ~Maxwell2D_H()
Definition: Maxwell2D_H.hh:144
virtual const hp2D::Maxwell2D_H_DD & model() const
Definition: Maxwell2D_H.hh:399
Real eps_
Dielectricity constant.
Definition: Maxwell2D_H.hh:97
virtual hp2D::Maxwell2D_H_Base & model()
Returns the model.
Definition: Maxwell2D_H.hh:313
Holds parameters in hashes.
Definition: inputOutput.hh:75
virtual Real solve()
Solves the system and returns the residual.
Helper class for building 2D hp-FEM spaces (space pre builder).
Abstract class for carrying information, which helps for reading input parameters from command line.
Definition: inputParam.hh:24
concepts::EddyGeometry2D & geom_
Mesh and material constants (sigma, j0)
Definition: Maxwell2D_H.hh:80
concepts::PiecewiseFormulaFun< Cmplx, Real > iOmegaEps_plus_Sigma_Inv_
Piecewise constant formula.
Definition: Maxwell2D_H.hh:95
Maxwell2D_H_Base(concepts::EddyGeometry2D &geom, enum boundaryType bType=PMC, enum solverType type=SUPERLU, bool diagPrecond=true, bool afterIter=false, const Real eps=EPS0, const Real omega=OMEGA50, const Real mu=MU0, const uint geomRefAttrib=100)
Constructor.
void linearform_()
Calculate the load vector, assumes sigma = 0 inside the coil.
concepts::Sequence< Real > omega_
Set of angular frequencies.
Definition: Maxwell2D_H.hh:290
concepts::Sequence< concepts::SparseMatrix< Cmplx > * > S_
Definition: Maxwell2D_H.hh:218
virtual Real dissipation()
Return dissipation power loss.
void setEpsilon(const Real epsilon)
Reset the dielectricity constant.
void graphicsOut(const uint numPoints, const std::string path="")
Writes matlab graphics files.
2D hp-FEM for H1-conforming elements.
virtual std::ostream & info(std::ostream &os) const
std::unique_ptr< concepts::BoundaryConditions > bc_
Boundary conditions.
Definition: Maxwell2D_H.hh:82
virtual const std::string mshAbbr_()
Mesh abbreviation string.
Definition: Maxwell2D_H.hh:67
ModelControl(hp2D::Maxwell2D_H_DD &model)
Constructor.
void setEpsilon(const Real epsilon, bool assembleMatrices)
Reset the dielectricity constant and reset the solution vector and the matrices.
std::unique_ptr< concepts::SparseMatrix< Real > > M_
Mass matrix.
Definition: Maxwell2D_H.hh:169
std::unique_ptr< hpAdaptiveSpaceH1 > spc_
Space.
Definition: Maxwell2D_H.hh:165
std::unique_ptr< concepts::SparseMatrix< Cmplx > > A_
Stiffness and System matrix.
Definition: Maxwell2D_H.hh:167
Class for calculating Eddy current problem with Maxwell modell in h formulation.
Definition: Maxwell2D_H.hh:122
void setOmega(const Real omega, bool assembleMatrices)
Sets the angular frequencies and reset the solution vector and the matrices.
concepts::ElementFormula< concepts::Cmplx2d > * eField()
Returns a pointer to the e-Field.
void setOmega(const Real omega, bool assembleMatrices)
Sets the angular frequencies and reset the solution vector and the matrices.
virtual void solve_()
Method for solving, throws exception when it wasn't successfull.
uint iterations_
Number of iterations for iterative solver.
Definition: Maxwell2D_H.hh:109
Maxwell2D_H(concepts::EddyGeometry2D &geom, enum concepts::MaxwellBoundary::boundaryType bType=PMC, enum solverType type=SUPERLU, bool diagPrecond=true, bool afterIter=false, const Real eps=EPS0, const Real omega=OMEGA50, const Real mu=MU0, const uint geomRefAttrib=100)
Constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual concepts::DomainDecomp< hpAdaptiveSpaceH1 > & space() const
Definition: Maxwell2D_H.hh:201
enum Maxwell2D_H::solverType type() const
Returns solver.
Definition: Maxwell2D_H.hh:277
hp2D::hpFull & prebuild()
Returns Space Prebuilder.
Definition: Maxwell2D_H.hh:338
ModelControl(hp2D::Maxwell2D_H_Base &model)
Constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual Real solve()=0
Solves the system and returns the residual.
void constructSpace_(const std::string &domainStr)
Constructs the space.
void laplaceMatrix_()
Calculate stiffness matrix.
Abstract class for Maxwell's problems.
Definition: maxwell.hh:55
virtual void matrices()
Builds the matrices and the load vector.
const Real mu_
Permeability constant.
Definition: Maxwell2D_H.hh:101
void storeMatricesToMatlab(const std::string matrixFile) const
Stores the calculated vectors.
virtual int input(int opt, const char *optarg)
Process an argument and sets input parameter, if found.
void storeMatricesToMatlab(const std::string matrixFile) const
Stores the calculated matrices.
void clear_(concepts::Sequence< F * > &seq)
Definition: Maxwell2D_H.hh:240
bool diagPrecond_
Using diagonal preconditioning.
Definition: Maxwell2D_H.hh:86
virtual std::ostream & letters(std::ostream &os) const
Return letters for the arguments.
const Real OMEGA50
Maxwell2D_H_DD(concepts::EddyGeometry2D &geom, InputMaxwell2D_H &input, const uint geomRefAttrib=100, std::string domains="(2)")
hp2D::hpFull prebuilds_
Space prebuilder.
Definition: Maxwell2D_H.hh:214
void constructSpace_()
Constructs the space.
concepts::ElementFormula< Cmplx > * hField()
Returns a pointer to the h-Field (solution + h0).
Sequence with operations, output operator, and method of the particular element types.
Definition: sequence.hh:39
Real omega_
Angular frequency.
Definition: Maxwell2D_H.hh:99
void setOmega(const Real omega)
Reset the angular frequency.
virtual Real magnEnergy()
Return magnetic energy.
std::complex< Real > Cmplx
Type for a complex number. It also depends on the setting of Real.
Definition: typedefs.hh:39
virtual hpFull & prebuild_()
Space Prebuilder.
Definition: Maxwell2D_H.hh:162
void meshAbbreviation(const char *meshAbbr)
concepts::Sequence< concepts::SparseMatrix< Cmplx > * > A_
Stiffness and System matrix.
Definition: Maxwell2D_H.hh:218
Helps for reading input parameters for single solving of Maxwell2D_H_Base.
Definition: Maxwell2D_H.hh:257
virtual const hp2D::Maxwell2D_H_Base & model() const
Definition: Maxwell2D_H.hh:316
virtual hpFull & prebuild_()
Space Prebuilder.
Definition: Maxwell2D_H.hh:211
std::unique_ptr< Real > residualNorm_
Euclidian norm of the residual of solving the linear system.
Definition: Maxwell2D_H.hh:91
virtual ~Maxwell2D_H_DD()
std::unique_ptr< Real > magnEnergy_
Magnetic energy.
Definition: Maxwell2D_H.hh:105
boundaryType
Boundary type.
Definition: maxwell.hh:27
bool afterIter_
Nachiteration.
Definition: Maxwell2D_H.hh:88
enum Maxwell2D_H::solverType type_
Solver type.
Definition: Maxwell2D_H.hh:294
const boundaryType bType() const
Returns boundary type.
Definition: maxwell.hh:33
virtual void matrices()
Builds the matrices and the load vector.
void storeMatricesToMatlab(const std::string matrixFile) const
Stores the calculated matrices.
ModelControl(hp2D::Maxwell2D_H &model)
Constructor.
virtual hp2D::Maxwell2D_H & model()
Returns the model.
Definition: Maxwell2D_H.hh:352
const concepts::Sequence< Real > & omega() const
Returns set of angular frequencies.
Definition: Maxwell2D_H.hh:275
enum concepts::MaxwellBoundary::boundaryType bType_
Boundary condition.
Definition: Maxwell2D_H.hh:288
void matrices_()
Building the matrices.
Abstract class for holding geometry and material for eddy current problems.
std::unique_ptr< concepts::SparseMatrix< Cmplx > > S_
Definition: Maxwell2D_H.hh:167
virtual std::ostream & arguments(std::ostream &os) const
Returns argument list as string.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
enum concepts::MaxwellBoundary::boundaryType boundary() const
Returns type of boundary condition.
Definition: Maxwell2D_H.hh:279
virtual void solve_()
Method for solving, throws exception when it wasn't successfull.
concepts::SparseMatrix< Real > * identityMatrix_(concepts::Space< Real > &spc, concepts::SparseMatrix< Cmplx > *S)
Calculate identity matrix and add's it to system matrix S.
void constructor_()
Private constructor.
concepts::SparseMatrix< Cmplx > * laplaceMatrix_(concepts::Space< Real > &spc, concepts::SparseMatrix< Cmplx > *S)
Calculate stiffness matrix and add's it to system matrix S.
virtual ~Maxwell2D_H_Base()
Definition: Maxwell2D_H.hh:63
Domain decomposition space.
Definition: domainDecomp.hh:72
virtual std::ostream & info(std::ostream &os) const
virtual const hp2D::Maxwell2D_H & model() const
Definition: Maxwell2D_H.hh:355
void matrices_()
Building the matrices.
virtual Real solve()
Solves the system and returns the residual.
std::unique_ptr< concepts::DomainDecomp< hp2D::hpAdaptiveSpaceH1 > > spc_
Space.
Definition: Maxwell2D_H.hh:216
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
InputMaxwell2D_H(concepts::InOutParameters &input)
Constructor.
bool solving_
True, if model should be solved.
Definition: Maxwell2D_H.hh:296
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Maxwell2D_H_DD(concepts::EddyGeometry2D &geom, enum concepts::MaxwellBoundary::boundaryType bType, enum solverType type=SUPERLU, bool diagPrecond=true, bool afterIter=false, const Real eps=EPS0, const Real omega=OMEGA50, const Real mu=MU0, const uint geomRefAttrib=100, std::string domains="(2)")
virtual void matrices()=0
Builds the matrices and the load vector.
Class for holding boundary type of Maxwell's problems.
Definition: maxwell.hh:19
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich