Class documentation of Concepts

Loading...
Searching...
No Matches
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"
13#include "formula/boundary.hh"
15#include "models/maxwell.hh"
18#include "models/Maxwell2D_H_eField.hh"
19#include "space/domainDecomp.hh"
20
21namespace 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,
43 BICGSTABSUPERLU = 4};
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(); }
78
82 std::unique_ptr<concepts::BoundaryConditions> bc_;
88 bool afterIter_, statusAfterIter_;
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_;
97 Real eps_;
99 Real omega_;
101 const Real mu_;
103 std::unique_ptr<Real> dissipation_;
105 std::unique_ptr<Real> magnEnergy_;
107 double solvetime_, matrixtime_, spacetime_;
110 private:
112 void constructor_();
113 };
114
115 // *********************************************************** Maxwell2D_H **
116
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
172 void constructSpace_();
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:
214 hp2D::hpFull prebuilds_;
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_();
230 void laplaceMatrix_();
232 void identityMatrix_();
233
234
235 template<class F>
236 void clear_(concepts::Sequence<F*>& seq);
237 };
238
239 template<class F>
240 void Maxwell2D_H_DD::clear_(concepts::Sequence<F*>& seq) {
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:
292 bool defaultOmega_;
294 enum Maxwell2D_H::solverType type_;
296 bool solving_;
297 };
298
299} // namespace hp2D
300
301namespace 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:
310 ModelControl(hp2D::Maxwell2D_H_Base& model);
311 virtual ~ModelControl() {}
312
313 virtual hp2D::Maxwell2D_H_Base& model() {
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;
322 void solverType(enum hp2D::Maxwell2D_H_Base::solverType type,
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() {}
352 virtual hp2D::Maxwell2D_H& model() {
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() {}
396 virtual hp2D::Maxwell2D_H_DD& model() {
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
const boundaryType bType() const
Returns boundary type.
Definition maxwell.hh:33
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual F & model()
Returns the model.
Definition models.hh:102
ModelControl(F &model)
Constructor.
Definition models.hh:177
enum concepts::MaxwellBoundary::boundaryType boundary() const
Returns type of boundary condition.
virtual std::ostream & letters(std::ostream &os) const
bool solving() const
Returns true, if model should be solved.
const concepts::Sequence< Real > & omega() const
Returns set of angular frequencies.
InputMaxwell2D_H(concepts::InOutParameters &input)
Constructor.
virtual int input(int opt, const char *optarg)
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual std::ostream & arguments(std::ostream &os) const
Returns argument list as string.
virtual std::ostream & description(std::ostream &os) const
Returns description for help.
enum Maxwell2D_H::solverType type() const
Returns solver.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
const Real mu_
Permeability constant.
concepts::SparseMatrix< Real > * identityMatrix_(concepts::Space< Real > &spc, concepts::SparseMatrix< Cmplx > *S)
Calculate identity matrix and add's it to system matrix S.
void linearform_()
Calculate the load vector, assumes sigma = 0 inside the coil.
solverType
Type of the solver.
bool afterIter_
Nachiteration.
std::unique_ptr< concepts::BoundaryConditions > bc_
Boundary conditions.
uint iterations_
Number of iterations for iterative solver.
std::unique_ptr< Real > magnEnergy_
Magnetic energy.
std::unique_ptr< Real > residualNorm_
Euclidian norm of the residual of solving the linear system.
double solvetime_
Time to solve the system, to build the matrices, to rebuild the space.
enum solverType type_
Solver type.
Real omega_
Angular frequency.
concepts::PiecewiseFormulaFun< Cmplx, Real > iOmegaEps_plus_Sigma_Inv_
Piecewise constant formula.
bool diagPrecond_
Using diagonal preconditioning.
concepts::EddyGeometry2D & geom_
Mesh and material constants (sigma, j0)
Real eps_
Dielectricity constant.
virtual const std::string mshAbbr_()
Mesh abbreviation string.
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)
concepts::SparseMatrix< Cmplx > * laplaceMatrix_(concepts::Space< Real > &spc, concepts::SparseMatrix< Cmplx > *S)
Calculate stiffness matrix and add's it to system matrix S.
std::unique_ptr< Real > dissipation_
Dissipation power loss.
virtual hpFull & prebuild_()
Space Prebuilder.
Real dissipation()
Return dissipation power loss.
Real magnEnergy()
Return magnetic energy.
virtual concepts::DomainDecomp< hpAdaptiveSpaceH1 > & space() const
Returns the space.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual Real dissipation()
Return dissipation power loss.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
concepts::ElementFormula< concepts::Cmplx2d > * eField()
virtual Real magnEnergy()
Return magnetic energy.
concepts::ElementFormula< Cmplx > * hField()
virtual hpFull & prebuild_()
Space Prebuilder.
virtual hpAdaptiveSpaceH1 & space() const
Returns the space.
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)
double Real
Definition typedefs.hh:39
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320
std::complex< Real > Cmplx
Type for a complex number. It also depends on the setting of Real.
Definition typedefs.hh:42