Eddy2D_H.hh

Go to the documentation of this file.
1 
7 #ifndef Eddy2D_hh
8 #define Eddy2D_hh
9 
10 #include "operator/sparseMatrix.hh"
12 #include "formula/boundary.hh"
13 #include "models/adaptiveModels.hh"
14 #include "models/maxwell.hh"
18 
19 namespace hp2D {
20 
21  using concepts::Real;
22  using concepts::Real2d;
23  using concepts::Cmplx;
24 
25  // forward declaration
26  class InputEddy2D_H;
27 
28  // ***************************************************** Eddy2D_H_Interior **
29 
36  public:
38  Omega_i_(Omega_i), H0_(H0) {
40  }
43  Omega_i_(i.Omega_i_), H0_(i.H0_) {}
45  const Real Omega_i() const { return Omega_i_; }
47  const Real H0() const { return H0_; }
48  protected:
49  virtual std::ostream& info(std::ostream& os) const {
50  return os << concepts::typeOf(*this)<<"(Omega_i = " << Omega_i_
51  << ", H0_i = " << H0_ << ")";
52  }
53  private:
55  const Real Omega_i_;
57  const Real H0_;
58  };
59 
60  // ************************************************************** Eddy2D_H **
61 
67  class Eddy2D_H : public AdaptiveModel<Cmplx>, public concepts::MaxwellModel {
68  public:
70  enum solverType { SUPERLU = 0, BICGSTAB = 1};
84  const concepts::Formula<Real2d>& curlH0,
85  const concepts::Formula<Real>* divgradH0 = 0,
86  Eddy2D_H_Interior* interior = 0, const uint geomRefAttrib = 100,
87  const Real omega = OMEGA50,
88  const Real mu = MU0, enum solverType type = SUPERLU);
98  Eddy2D_H_Interior* interior = 0, const uint geomRefAttrib = 100,
99  const Real omega = OMEGA50,
100  const Real mu = MU0, enum solverType type = SUPERLU);
102  const uint geomRefAttrib = 100);
103  virtual ~Eddy2D_H() {}
105  virtual hpAdaptiveSpaceH1& space() const;
107  virtual Real dissipation();
109  virtual Real magnEnergy();
118  protected:
119  virtual std::ostream& info(std::ostream& os) const;
121  virtual const std::string mshAbbr_() { return geom_.meshAbbreviation(); }
122  private:
124  void constructor_();
126  virtual hpFull& prebuild_() { return spc_->prebuild(); }
128  virtual void solve_();
130  void matrices_();
136  bool connectedIdx_(uint& i);
140  void linearform_();
141 
143  std::unique_ptr<hpAdaptiveSpaceH1> spc_;
147  std::unique_ptr<concepts::BoundaryConditions> bc_;
149  std::unique_ptr<concepts::CellConditions> cc_;
151  enum solverType type_;
153  std::unique_ptr<concepts::Vector<Cmplx> > residual_;
155  std::unique_ptr<Real> residualNorm_;
157  std::unique_ptr<concepts::SparseMatrix<Real> > A_;
159  std::unique_ptr<concepts::SparseMatrix<Real> > M_;
161  std::unique_ptr<concepts::SparseMatrix<Cmplx> > S_;
162  // load vector
163  std::unique_ptr<concepts::Vector<Cmplx> > rhs_;
167  std::unique_ptr<const concepts::PiecewiseFormulaBase<Real> > H0_;
168  std::unique_ptr<const concepts::PiecewiseFormulaBase<Real2d> > curlH0_;
169  std::unique_ptr<const concepts::PiecewiseFormulaBase<Real> > divgradH0_;
171  std::unique_ptr<Eddy2D_H_Interior> interior_;
173  const Real omega_;
175  const Real mu_;
177  std::unique_ptr<Real> dissipation_;
179  std::unique_ptr<Real> magnEnergy_;
181  std::unique_ptr<const concepts::ElementFunction<Cmplx> > fun_;
183  double solvetime_;
184  };
185 
186  // ****************************************************** InputEddy2D_H **
187 
196  public:
202  virtual std::ostream& letters(std::ostream& os) const;
204  virtual std::ostream& arguments(std::ostream& os) const;
206  virtual std::ostream& description(std::ostream& os) const;
211  virtual int input(int opt, const char* optarg);
213  const concepts::Sequence<Real>& omega() const { return omega_; }
215  const concepts::PiecewiseFormulaBase<Real>* H0() const { return H0_; }
218  return curlH0_; }
221  return divgradH0_; }
223  bool interior() const { return false; }
225  enum Eddy2D_H::solverType type() const { return type_; }
227  bool solving() const { return solving_; }
228  protected:
229  virtual std::ostream& info(std::ostream& os) const;
230  private:
244  bool solving_;
245  };
246 
247 } // namespace hp2D
248 
249 namespace concepts {
250 
251  // *************************************************** HField_CircularCoil **
252 
253  /* Formula for the magnetic field created by a circular coil
254 
255  @author Kersten Schmidt, 2005
256  */
257  class HField_CircularCoil : public Formula<Real> {
258  public:
264  HField_CircularCoil(const Real R1, const Real R2, const Real h0 = 1.0) :
265  R1_(R1), R2_(R2), h0_(h0) {
266  conceptsAssert(R2 >= R1, Assertion());
267  conceptsAssert(R1 >= 0, Assertion());
268  }
269  virtual Real operator() (const Real p, const Real t = 0.0) const {
270  const Real r = std::abs(p);
271  if (r >= R2_) return 0.0;
272  if (r <= R1_) return h0_;
273  return (R2_ - r)/(R2_ - R1_) * h0_;
274  }
275  virtual Real operator() (const Real2d& p, const Real t = 0.0) const {
276  return (*this)(p.l2());
277  }
278  virtual Real operator() (const Real3d& p, const Real t = 0.0) const {
279  return (*this)(p.l2());
280  }
281  virtual HField_CircularCoil* clone() const {
282  return new HField_CircularCoil(R1_, R2_, h0_);
283  }
284  protected:
285  virtual std::ostream& info(std::ostream& os) const {
286  os << concepts::typeOf(*this)<<"(r <= " << R1_ << " : " << h0_ << ", ";
287  if (R2_ > R1_)
288  os << R1_ << " < r <= " << R2_ << " : " << R2_/(R2_-R1_)*h0_ << "-("
289  << h0_/(R2_-R1_) << ")*r, ";
290  return os << "r > " << R2_ << " : 0.0)";
291  }
292  private:
294  const Real R1_, R2_;
296  const Real h0_;
297  };
298 
299  // *********************************************** CurlHField_CircularCoil **
300 
301  /* Formula for the curl of the magnetic field created by a circular coil
302 
303  @author Kersten Schmidt, 2006
304  */
305  class CurlHField_CircularCoil : public Formula<Real2d> {
306  public:
312  CurlHField_CircularCoil(const Real R1, const Real R2, const Real h0 = 1.0)
313  : R1_(R1), R2_(R2), h0_(h0) {
314  conceptsAssert(R2 >= R1, Assertion());
315  conceptsAssert(R1 >= 0, Assertion());
316  }
317  virtual Real2d operator() (const Real p, const Real t = 0.0) const {
318  return (*this)(Real2d(p,0));
319  }
320  virtual Real2d operator() (const Real2d& p, const Real t = 0.0) const {
321  const Real r = p.l2();
322  if (r >= R2_) return 0.0;
323  if (r <= R1_) return 0.0;
324  return Real2d(p[1], -p[0]) * (-h0_ /(R2_ - R1_) / r);
325  }
326  virtual Real2d operator() (const Real3d& p, const Real t = 0.0) const {
327  return (*this)(Real2d(p));
328  }
329  virtual CurlHField_CircularCoil* clone() const {
330  return new CurlHField_CircularCoil(R1_, R2_, h0_);
331  }
332  protected:
333  virtual std::ostream& info(std::ostream& os) const {
334  os << concepts::typeOf(*this)<<"(";
335  if (R2_ > R1_)
336  os << "r <= " << R1_ << " : " << 0.0 << ", "
337  << R1_ << " < r <= " << R2_ << " : (y,-x)^T/|r| * "
338  << h0_ / (R2_-R1_) << ", r > " << R2_ << " : 0.0";
339  else os << "0.0";
340  return os << ")";
341  }
342  private:
344  const Real R1_, R2_;
346  const Real h0_;
347  };
348 
349  // ******************************************** DivGradHField_CircularCoil **
350 
351  /* Formula for the curl of the magnetic field created by a circular coil
352 
353  @author Kersten Schmidt, 2006
354  */
355  class DivGradHField_CircularCoil : public Formula<Real> {
356  public:
363  const Real h0 = 1.0)
364  : R1_(R1), R2_(R2), h0_(h0) {
365  conceptsAssert(R2 >= R1, Assertion());
366  conceptsAssert(R1 >= 0, Assertion());
367  }
368  virtual Real operator() (const Real p, const Real t = 0.0) const {
369  return (*this)(Real2d(p,0));
370  }
371  virtual Real operator() (const Real2d& p, const Real t = 0.0) const {
372  const Real r = p.l2();
373  if (r >= R2_) return 0.0;
374  if (r <= R1_) return 0.0;
375  return -h0_/(R2_ - R1_)/r;
376  }
377  virtual Real operator() (const Real3d& p, const Real t = 0.0) const {
378  return (*this)(Real2d(p));
379  }
381  return new DivGradHField_CircularCoil(R1_, R2_, h0_);
382  }
383  protected:
384  virtual std::ostream& info(std::ostream& os) const {
385  os << concepts::typeOf(*this)<<"(";
386  if (R2_ > R1_)
387  os << "r <= " << R1_ << " : " << 0.0 << ", "
388  << R1_ << " < r <= " << R2_ << " : " << -h0_/(R2_ - R1_) << "/r"
389  << ", r > " << R2_ << " : 0.0";
390  else os << "0.0";
391  return os << ")";
392  }
393  private:
395  const Real R1_, R2_;
397  const Real h0_;
398  };
399 
400 
401 } // namespace concepts
402 
403 #endif // Eddy2D_hh
bool defaultOmega_
Flag, if no omega is given.
Definition: Eddy2D_H.hh:240
Class for calculating Eddy current problem with Maxwell modell in h formulation.
Definition: Eddy2D_H.hh:67
virtual std::ostream & description(std::ostream &os) const
Returns description for help.
virtual Real magnEnergy()
Return magnetic energy.
concepts::PiecewiseFormulaBase< Real2d > * curlH0_
Formula for curl of homogenization.
Definition: Eddy2D_H.hh:236
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Eddy2D_H(concepts::EddyGeometry2D &geom, const Real H0, Eddy2D_H_Interior *interior=0, const uint geomRefAttrib=100, const Real omega=OMEGA50, const Real mu=MU0, enum solverType type=SUPERLU)
Constructor.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Definition: Eddy2D_H.hh:49
virtual HField_CircularCoil * clone() const
Definition: Eddy2D_H.hh:281
const Real MU0
std::unique_ptr< concepts::BoundaryConditions > bc_
Boundary conditions.
Definition: Eddy2D_H.hh:147
std::unique_ptr< concepts::Vector< Cmplx > > rhs_
Definition: Eddy2D_H.hh:163
virtual int input(int opt, const char *optarg)
Process an argument and sets input parameter, if found.
const concepts::PiecewiseFormulaBase< Real > * H0() const
Returns formula for homogenization.
Definition: Eddy2D_H.hh:215
bool connectedIdx_(uint &i)
Gives connected index at interior border to i, if exists.
std::unique_ptr< Real > magnEnergy_
Magnetic energy.
Definition: Eddy2D_H.hh:179
const Real h0_
Magnetic field produced by the coil.
Definition: Eddy2D_H.hh:346
virtual ~Eddy2D_H()
Definition: Eddy2D_H.hh:103
const Real h0_
Magnetic field produced by the coil.
Definition: Eddy2D_H.hh:296
enum solverType type_
Solver type.
Definition: Eddy2D_H.hh:151
void matrices_()
Building the matrices.
virtual CurlHField_CircularCoil * clone() const
Definition: Eddy2D_H.hh:329
std::unique_ptr< concepts::SparseMatrix< Cmplx > > S_
System matrix.
Definition: Eddy2D_H.hh:161
Eddy2D_H_Interior(const Eddy2D_H_Interior &i)
Copy constructor.
Definition: Eddy2D_H.hh:42
bool solving_
True, if model should be solved.
Definition: Eddy2D_H.hh:244
const Real omega_
Angular frequency.
Definition: Eddy2D_H.hh:173
concepts::EddyGeometry2D & geom_
Mesh and material constants (sigma)
Definition: Eddy2D_H.hh:145
Point< Real, 2 > Real2d
const Real R1_
Inner and outer radia of the coil.
Definition: Eddy2D_H.hh:344
Holds parameters in hashes.
Definition: inputOutput.hh:75
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
std::unique_ptr< const concepts::PiecewiseFormulaBase< Real2d > > curlH0_
Definition: Eddy2D_H.hh:168
virtual std::ostream & letters(std::ostream &os) const
Return letters for the arguments.
std::unique_ptr< const concepts::PiecewiseFormulaBase< Real > > divgradH0_
Definition: Eddy2D_H.hh:169
std::unique_ptr< Real > dissipation_
dissipation energy
Definition: Eddy2D_H.hh:177
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
virtual hpAdaptiveSpaceH1 & space() const
Returns the space.
virtual Real dissipation()
Return dissipation energy.
std::unique_ptr< concepts::CellConditions > cc_
Cell conditions.
Definition: Eddy2D_H.hh:149
const concepts::PiecewiseFormulaBase< Real2d > * curlH0() const
Returns the curl formula for homogenization.
Definition: Eddy2D_H.hh:217
InputEddy2D_H(concepts::InOutParameters &input)
Constructor.
std::unique_ptr< const concepts::ElementFunction< Cmplx > > fun_
Element function, is hp2D::Value + homogenisation.
Definition: Eddy2D_H.hh:181
2D hp-FEM for H1-conforming elements.
HField_CircularCoil(const Real R1, const Real R2, const Real h0=1.0)
Constructor.
Definition: Eddy2D_H.hh:264
CurlHField_CircularCoil(const Real R1, const Real R2, const Real h0=1.0)
Constructor.
Definition: Eddy2D_H.hh:312
const Real Omega_i() const
Returns size of the embedded area.
Definition: Eddy2D_H.hh:45
DivGradHField_CircularCoil(const Real R1, const Real R2, const Real h0=1.0)
Constructor.
Definition: Eddy2D_H.hh:362
virtual void solve_()
Method for solving, throws exception when it wasn't successfull.
const concepts::Sequence< Real > & omega() const
Returns set of angular frequencies.
Definition: Eddy2D_H.hh:213
bool interior() const
Returns true, if there is a embedded area.
Definition: Eddy2D_H.hh:223
std::unique_ptr< concepts::SparseMatrix< Real > > A_
Stiffness matrix.
Definition: Eddy2D_H.hh:157
virtual std::ostream & info(std::ostream &os) const
Definition: Eddy2D_H.hh:285
virtual const std::string mshAbbr_()
Mesh abbreviation string.
Definition: Eddy2D_H.hh:121
void identityMatrix_()
Calculate identity matrix.
virtual Real operator()(const Real p, const Real t=0.0) const
Application operator.
Definition: Eddy2D_H.hh:269
concepts::ElementFormula< Cmplx > * hField()
Returns a pointer to the h-Field (solution + h0).
virtual std::ostream & info(std::ostream &os) const
Definition: Eddy2D_H.hh:333
Exception class for assertions.
Definition: exceptions.hh:258
const Real H0() const
Returns magnetic field of homogenization at.
Definition: Eddy2D_H.hh:47
Class holding size and magnetic field of embedded (interior) area.
Definition: Eddy2D_H.hh:35
Real l2() const
Returns the Euclidian norm of the vector.
Abstract class for Maxwell's problems.
Definition: maxwell.hh:55
const Real H0_
Trace of homogenization function to inner boundary.
Definition: Eddy2D_H.hh:57
concepts::PiecewiseFormulaFun< Real, Real > Sigma_Inv_
Piecewise constant formula.
Definition: Eddy2D_H.hh:165
void constructor_()
Private constructor.
const Real OMEGA50
std::unique_ptr< concepts::Vector< Cmplx > > residual_
Residual vector.
Definition: Eddy2D_H.hh:153
void linearform_()
Calculate the load vector.
std::complex< Real > Cmplx
Type for a complex number. It also depends on the setting of Real.
Definition: typedefs.hh:39
std::unique_ptr< Eddy2D_H_Interior > interior_
Size and magnetic field of or in the nonconducting imbedded region.
Definition: Eddy2D_H.hh:171
virtual DivGradHField_CircularCoil * clone() const
Definition: Eddy2D_H.hh:380
void meshAbbreviation(const char *meshAbbr)
virtual std::ostream & info(std::ostream &os) const
Definition: Eddy2D_H.hh:384
enum Eddy2D_H::solverType type() const
Returns solver.
Definition: Eddy2D_H.hh:225
uint abs(const uint &v)
Definition: operations.hh:95
Eddy2D_H(concepts::EddyGeometry2D &geom, InputEddy2D_H &input, const uint geomRefAttrib=100)
const Real h0_
Magnetic field produced by the coil.
Definition: Eddy2D_H.hh:397
std::unique_ptr< concepts::SparseMatrix< Real > > M_
Mass matrix.
Definition: Eddy2D_H.hh:159
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
const Real R1_
Inner and outer radia of the coil.
Definition: Eddy2D_H.hh:294
std::unique_ptr< hpAdaptiveSpaceH1 > spc_
Space.
Definition: Eddy2D_H.hh:143
concepts::PiecewiseFormulaBase< Real > * H0_
Formula for homogenization.
Definition: Eddy2D_H.hh:234
const Real Omega_i_
size of the nonconducting imbedded region
Definition: Eddy2D_H.hh:55
concepts::PiecewiseFormulaBase< Real > * divgradH0_
Formula for div grad of homogenization.
Definition: Eddy2D_H.hh:238
concepts::ElementFormula< concepts::Cmplx2d > * eField()
Returns a pointer to the e-Field.
std::unique_ptr< const concepts::PiecewiseFormulaBase< Real > > H0_
Formula for homogenization.
Definition: Eddy2D_H.hh:167
void laplaceMatrix_()
Calculate stiffness matrix.
const concepts::PiecewiseFormulaBase< Real > * divgradH0() const
Returns the curl formula for homogenization.
Definition: Eddy2D_H.hh:220
virtual std::ostream & arguments(std::ostream &os) const
Returns argument list as string.
enum Eddy2D_H::solverType type_
Solver type.
Definition: Eddy2D_H.hh:242
concepts::Sequence< Real > omega_
Set of angular frequencies.
Definition: Eddy2D_H.hh:232
Eddy2D_H_Interior(const Real Omega_i, const Real H0)
Definition: Eddy2D_H.hh:37
std::unique_ptr< Real > residualNorm_
Euclidian norm of the residual of solving the linear system.
Definition: Eddy2D_H.hh:155
Abstract class for holding geometry and material for eddy current problems.
solverType
Type of the solver.
Definition: Eddy2D_H.hh:70
bool solving() const
Returns true, if model should be solved.
Definition: Eddy2D_H.hh:227
virtual Real2d operator()(const Real p, const Real t=0.0) const
Application operator.
Definition: Eddy2D_H.hh:317
std::string typeOf(const T &t)
Return the typeid name of a class object.
Definition: output.hh:43
double solvetime_
Time to solve the system.
Definition: Eddy2D_H.hh:183
void systemMatrix_()
Compress system matrix.
Class providing an output operator.
Helps for reading input parameters for single solving of Eddy2D_H.
Definition: Eddy2D_H.hh:195
Eddy2D_H(concepts::EddyGeometry2D &geom, const concepts::Formula< Real > &H0, const concepts::Formula< Real2d > &curlH0, const concepts::Formula< Real > *divgradH0=0, Eddy2D_H_Interior *interior=0, const uint geomRefAttrib=100, const Real omega=OMEGA50, const Real mu=MU0, enum solverType type=SUPERLU)
Constructor.
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
virtual Real operator()(const Real p, const Real t=0.0) const
Application operator.
Definition: Eddy2D_H.hh:368
const Real R1_
Inner and outer radia of the coil.
Definition: Eddy2D_H.hh:395
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
virtual hpFull & prebuild_()
Space Prebuilder.
Definition: Eddy2D_H.hh:126
const Real mu_
Permeability constant.
Definition: Eddy2D_H.hh:175
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich