Hermes2D  2.0
weakforms_hcurl.cpp
1 // This file is part of Hermes2D.
2 //
3 // Hermes2D is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 2 of the License, or
6 // (at your option) any later version.
7 //
8 // Hermes2D is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with Hermes2D. If not, see <http://www.gnu.org/licenses/>.
15 
16 #include "weakforms_hcurl.h"
17 #include "../forms.h"
18 namespace Hermes
19 {
20  namespace Hermes2D
21  {
22  namespace WeakFormsHcurl
23  {
24  template<typename Scalar>
25  DefaultMatrixFormVol<Scalar>::DefaultMatrixFormVol
26  (int i, int j, std::string area, Scalar const_coeff,
27  Hermes2DFunction<Scalar>* f_coeff, SymFlag sym,
28  GeomType gt)
29  : MatrixFormVol<Scalar>(i, j), const_coeff(const_coeff), function_coeff(f_coeff), gt(gt)
30  {
31  this->set_area(area);
32  this->setSymFlag(sym);
33 
34  // If f_coeff is HERMES_DEFAULT_FUNCTION, initialize it to be constant 1.0.
35  if(f_coeff == HERMES_DEFAULT_FUNCTION) this->function_coeff = new Hermes2DFunction<Scalar>(1.0);
36  else throw Hermes::Exceptions::Exception("Nonconstant coefficients in Hcurl forms not implemented yet.");
37  }
38 
39  template<typename Scalar>
40  DefaultMatrixFormVol<Scalar>::DefaultMatrixFormVol
41  (int i, int j, Hermes::vector<std::string> areas, Scalar const_coeff,
42  Hermes2DFunction<Scalar>* f_coeff, SymFlag sym, GeomType gt)
43  : MatrixFormVol<Scalar>(i, j), const_coeff(const_coeff), function_coeff(f_coeff), gt(gt)
44  {
45  this->set_areas(areas);
46  this->setSymFlag(sym);
47 
48  // If f_coeff is HERMES_DEFAULT_FUNCTION, initialize it to be constant 1.0.
49  if(f_coeff == HERMES_DEFAULT_FUNCTION) this->function_coeff = new Hermes2DFunction<Scalar>(1.0);
50  else throw Hermes::Exceptions::Exception("Nonconstant coefficients in Hcurl forms not implemented yet.");
51  }
52 
53  template<typename Scalar>
54  DefaultMatrixFormVol<Scalar>::~DefaultMatrixFormVol()
55  {
56  if(function_coeff == HERMES_DEFAULT_FUNCTION)
57  delete function_coeff;
58  };
59 
60  template<typename Scalar>
61  Scalar DefaultMatrixFormVol<Scalar>::value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *u,
62  Func<double> *v, Geom<double> *e, Func<Scalar> **ext) const
63  {
64  Scalar result = 0;
65  if(gt == HERMES_PLANAR)
66  {
67  result = const_coeff * int_e_f<double, Scalar>(n, wt, u, v);
68  }
69  else throw Hermes::Exceptions::Exception("Axisymmetric Hcurl forms not implemented yet.");
70 
71  return result;
72  }
73 
74  template<typename Scalar>
75  Ord DefaultMatrixFormVol<Scalar>::ord(int n, double *wt, Func<Ord> *u_ext[], Func<Ord> *u, Func<Ord> *v,
76  Geom<Ord> *e, Func<Ord> **ext) const
77  {
78  Ord result = Ord(0);
79  if(gt == HERMES_PLANAR)
80  {
81  result = const_coeff * int_e_f<Ord, Ord>(n, wt, u, v);
82  }
83  else throw Hermes::Exceptions::Exception("Axisymmetric Hcurl forms not implemented yet.");
84 
85  return result;
86  }
87 
88  template<typename Scalar>
89  MatrixFormVol<Scalar>* DefaultMatrixFormVol<Scalar>::clone() const
90  {
91  return new DefaultMatrixFormVol<Scalar>(*this);
92  }
93 
94  template<typename Scalar>
95  DefaultJacobianCurlCurl<Scalar>::DefaultJacobianCurlCurl(int i, int j, std::string area, Scalar const_coeff,
96  CubicSpline* c_spline,
97  SymFlag sym, GeomType gt)
98  : MatrixFormVol<Scalar>(i, j),
99  idx_j(j), const_coeff(const_coeff), spline_coeff(c_spline), gt(gt)
100  {
101  this->set_area(area);
102  this->setSymFlag(sym);
103 
104  // If spline is HERMES_DEFAULT_SPLINE, initialize it to be constant 1.0.
105  if(c_spline == HERMES_DEFAULT_SPLINE) this->spline_coeff = new CubicSpline(1.0);
106  else throw Hermes::Exceptions::Exception("Nonconstant coefficients in Hcurl forms not implemented yet.");
107  };
108 
109  template<typename Scalar>
110  DefaultJacobianCurlCurl<Scalar>::DefaultJacobianCurlCurl(int i, int j, Hermes::vector<std::string> areas,
111  Scalar const_coeff, CubicSpline* c_spline,
112  SymFlag sym, GeomType gt)
113  : MatrixFormVol<Scalar>(i, j),
114  idx_j(j), const_coeff(const_coeff), spline_coeff(c_spline), gt(gt)
115  {
116  this->set_areas(areas);
117  this->setSymFlag(sym);
118 
119  // If spline is HERMES_DEFAULT_SPLINE, initialize it to be constant 1.0.
120  if(c_spline == HERMES_DEFAULT_SPLINE)
121  this->spline_coeff = new CubicSpline(1.0);
122  else throw Hermes::Exceptions::Exception("Nonconstant coefficients in Hcurl forms not implemented yet.");
123  }
124 
125  template<typename Scalar>
126  DefaultJacobianCurlCurl<Scalar>::~DefaultJacobianCurlCurl()
127  {
128  if(spline_coeff == HERMES_DEFAULT_SPLINE)
129  delete spline_coeff;
130  };
131 
132  template<typename Scalar>
133  Scalar DefaultJacobianCurlCurl<Scalar>::value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *u,
134  Func<double> *v, Geom<double> *e, Func<Scalar> **ext) const
135  {
136  Scalar result = 0;
137  if(gt == HERMES_PLANAR)
138  {
139  result = const_coeff * int_curl_e_curl_f<double, Scalar>(n, wt, u, v);
140  }
141  else throw Hermes::Exceptions::Exception("Axisymmetric Hcurl forms not implemented yet.");
142 
143  return result;
144  }
145 
146  template<typename Scalar>
147  Ord DefaultJacobianCurlCurl<Scalar>::ord(int n, double *wt, Func<Ord> *u_ext[], Func<Ord> *u, Func<Ord> *v,
148  Geom<Ord> *e, Func<Ord> **ext) const
149  {
150  Ord result = Ord(0);
151  if(gt == HERMES_PLANAR)
152  {
153  result = const_coeff * int_curl_e_curl_f<Ord, Ord>(n, wt, u, v);
154  }
155  else throw Hermes::Exceptions::Exception("Axisymmetric Hcurl forms not implemented yet.");
156 
157  return result;
158  }
159 
160  template<typename Scalar>
161  MatrixFormVol<Scalar>* DefaultJacobianCurlCurl<Scalar>::clone() const
162  {
163  return new DefaultJacobianCurlCurl(*this);
164  }
165 
166  template<typename Scalar>
167  DefaultVectorFormVol<Scalar>::DefaultVectorFormVol(int i, std::string area, Scalar const_coeff0, Scalar const_coeff1,
168  Hermes2DFunction<Scalar>* f_coeff0, Hermes2DFunction<Scalar>* f_coeff1,
169  GeomType gt)
170  : VectorFormVol<Scalar>(i), const_coeff0(const_coeff0), const_coeff1(const_coeff1),
171  function_coeff0(f_coeff0), function_coeff1(f_coeff1), gt(gt)
172  {
173  this->set_area(area);
174 
175  // If f_coeff0 is HERMES_DEFAULT_FUNCTION, initialize it to be constant 1.0.
176  if(f_coeff0 == HERMES_DEFAULT_FUNCTION) this->function_coeff0 = new Hermes2DFunction<Scalar>(1.0);
177  else throw Hermes::Exceptions::Exception("Nonconstant coefficients in Hcurl forms not implemented yet.");
178  if(f_coeff1 == HERMES_DEFAULT_FUNCTION) this->function_coeff1 = new Hermes2DFunction<Scalar>(1.0);
179  else throw Hermes::Exceptions::Exception("Nonconstant coefficients in Hcurl forms not implemented yet.");
180  }
181 
182  template<typename Scalar>
183  DefaultVectorFormVol<Scalar>::DefaultVectorFormVol(int i, Hermes::vector<std::string> areas,
184  Scalar const_coeff0, Scalar const_coeff1,
185  Hermes2DFunction<Scalar>* f_coeff0, Hermes2DFunction<Scalar>* f_coeff1,
186  GeomType gt)
187  : VectorFormVol<Scalar>(i), const_coeff0(const_coeff0), const_coeff1(const_coeff1),
188  function_coeff0(f_coeff0), function_coeff1(f_coeff1), gt(gt)
189  {
190  this->set_areas(areas);
191 
192  // If f_coeff0 is HERMES_DEFAULT_FUNCTION, initialize it to be constant 1.0.
193  if(f_coeff0 == HERMES_DEFAULT_FUNCTION) this->function_coeff0 = new Hermes2DFunction<Scalar>(1.0);
194  else throw Hermes::Exceptions::Exception("Nonconstant coefficients in Hcurl forms not implemented yet.");
195  if(f_coeff1 == HERMES_DEFAULT_FUNCTION) this->function_coeff1 = new Hermes2DFunction<Scalar>(1.0);
196  else throw Hermes::Exceptions::Exception("Nonconstant coefficients in Hcurl forms not implemented yet.");
197  }
198 
199  template<typename Scalar>
200  DefaultVectorFormVol<Scalar>::~DefaultVectorFormVol()
201  {
202  if(function_coeff0 == HERMES_DEFAULT_FUNCTION) delete function_coeff0;
203  if(function_coeff1 == HERMES_DEFAULT_FUNCTION) delete function_coeff1;
204  };
205 
206  template<typename Scalar>
207  Scalar DefaultVectorFormVol<Scalar>::value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *v,
208  Geom<double> *e, Func<Scalar> **ext) const
209  {
210  Scalar int_v0 = 0, int_v1 = 0;
211  for (int i = 0; i < n; i++) int_v0 += wt[i] * v->val0[i];
212  for (int i = 0; i < n; i++) int_v1 += wt[i] * v->val1[i];
213  return const_coeff0 * int_v0 + const_coeff1 * int_v1;
214  }
215 
216  template<typename Scalar>
217  Ord DefaultVectorFormVol<Scalar>::ord(int n, double *wt, Func<Ord> *u_ext[], Func<Ord> *v,
218  Geom<Ord> *e, Func<Ord> **ext) const
219  {
220  Ord int_v0 = Ord(0), int_v1 = Ord(0);
221  for (int i = 0; i < n; i++) int_v0 += wt[i] * v->val0[i];
222  for (int i = 0; i < n; i++) int_v1 += wt[i] * v->val1[i];
223  return const_coeff0 * int_v0 + const_coeff1 * int_v1;
224  }
225 
226  template<typename Scalar>
227  VectorFormVol<Scalar>* DefaultVectorFormVol<Scalar>::clone() const
228  {
229  return new DefaultVectorFormVol<Scalar>(*this);
230  }
231 
232  template<typename Scalar>
233  DefaultResidualVol<Scalar>::DefaultResidualVol(int i, std::string area, Scalar const_coeff,
234  Hermes2DFunction<Scalar>* f_coeff,
235  GeomType gt)
236  : VectorFormVol<Scalar>(i),
237  idx_i(i), const_coeff(const_coeff), function_coeff(f_coeff), gt(gt)
238  {
239  this->set_area(area);
240 
241  // If f_coeff is HERMES_DEFAULT_FUNCTION, initialize it to be constant 1.0.
242  if(f_coeff == HERMES_DEFAULT_FUNCTION) this->function_coeff = new Hermes2DFunction<Scalar>(1.0);
243  else throw Hermes::Exceptions::Exception("Nonconstant functions in Hcurl forms not implemented yet.");
244  }
245 
246  template<typename Scalar>
247  DefaultResidualVol<Scalar>::DefaultResidualVol(int i, Hermes::vector<std::string> areas, Scalar const_coeff,
248  Hermes2DFunction<Scalar>* f_coeff,
249  GeomType gt)
250  : VectorFormVol<Scalar>(i),
251  idx_i(i), const_coeff(const_coeff), function_coeff(f_coeff), gt(gt)
252  {
253  this->set_areas(areas);
254 
255  // If f_coeff is HERMES_DEFAULT_FUNCTION, initialize it to be constant 1.0.
256  if(f_coeff == HERMES_DEFAULT_FUNCTION) this->function_coeff = new Hermes2DFunction<Scalar>(1.0);
257  else throw Hermes::Exceptions::Exception("Nonconstant functions in Hcurl forms not implemented yet.");
258  }
259 
260  template<typename Scalar>
261  DefaultResidualVol<Scalar>::~DefaultResidualVol()
262  {
263  if(function_coeff == HERMES_DEFAULT_FUNCTION) delete function_coeff;
264  };
265 
266  template<typename Scalar>
267  Scalar DefaultResidualVol<Scalar>::value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *v,
268  Geom<double> *e, Func<Scalar> **ext) const
269  {
270  Scalar result = 0;
271  if(gt == HERMES_PLANAR)
272  {
273  for (int i = 0; i < n; i++)
274  {
275  result += wt[i] * function_coeff->value(e->x[i], e->y[i]) * (u_ext[idx_i]->val0[i] * v->val0[i] +
276  u_ext[idx_i]->val1[i] * v->val1[i]);
277  }
278  }
279  else throw Hermes::Exceptions::Exception("Axisymmetric Hcurl forms not implemented yet.");
280 
281  return const_coeff * result;
282  }
283 
284  template<typename Scalar>
285  Ord DefaultResidualVol<Scalar>::ord(int n, double *wt, Func<Ord> *u_ext[], Func<Ord> *v,
286  Geom<Ord> *e, Func<Ord> **ext) const
287  {
288  Ord result = Ord(0);
289  if(gt == HERMES_PLANAR)
290  {
291  for (int i = 0; i < n; i++)
292  {
293  result += wt[i] * function_coeff->value(e->x[i], e->y[i]) * u_ext[idx_i]->val[i] * v->val[i];
294  }
295  }
296  else throw Hermes::Exceptions::Exception("Axisymmetric Hcurl forms not implemented yet.");
297 
298  return result;
299  }
300 
301  template<typename Scalar>
302  VectorFormVol<Scalar>* DefaultResidualVol<Scalar>::clone() const
303  {
304  return new DefaultResidualVol(*this);
305  }
306 
307  template<typename Scalar>
308  DefaultResidualCurlCurl<Scalar>::DefaultResidualCurlCurl(int i, std::string area, Scalar const_coeff,
309  CubicSpline* c_spline,
310  GeomType gt)
311  : VectorFormVol<Scalar>(i),
312  idx_i(i), const_coeff(const_coeff), spline_coeff(c_spline), gt(gt)
313  {
314  this->set_area(area);
315 
316  // If spline is HERMES_DEFAULT_SPLINE, initialize it to be constant 1.0.
317  if(c_spline == HERMES_DEFAULT_SPLINE) this->spline_coeff = new CubicSpline(1.0);
318  else throw Hermes::Exceptions::Exception("Nonconstant coefficients in Hcurl forms not implemented yet.");
319  };
320 
321  template<typename Scalar>
322  DefaultResidualCurlCurl<Scalar>::DefaultResidualCurlCurl(int i, Hermes::vector<std::string> areas, Scalar const_coeff,
323  CubicSpline* c_spline,
324  GeomType gt)
325  : VectorFormVol<Scalar>(i),
326  idx_i(i), const_coeff(const_coeff), spline_coeff(c_spline), gt(gt)
327  {
328  this->set_areas(areas);
329 
330  // If spline is HERMES_DEFAULT_SPLINE, initialize it to be constant 1.0.
331  if(c_spline == HERMES_DEFAULT_SPLINE) this->spline_coeff = new CubicSpline(1.0);
332  else throw Hermes::Exceptions::Exception("Nonconstant coefficients in Hcurl forms not implemented yet.");
333  }
334 
335  template<typename Scalar>
336  DefaultResidualCurlCurl<Scalar>::~DefaultResidualCurlCurl()
337  {
338  if(spline_coeff == HERMES_DEFAULT_SPLINE) delete spline_coeff;
339  };
340 
341  template<typename Scalar>
342  Scalar DefaultResidualCurlCurl<Scalar>::value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *v,
343  Geom<double> *e, Func<Scalar> **ext) const
344  {
345  Func<Scalar>* u_prev = u_ext[idx_i];
346  Scalar result = 0;
347  if(gt == HERMES_PLANAR)
348  {
349  for (int i = 0; i < n; i++)
350  {
351  double mag0_i = std::abs(u_prev->val0[i]);
352  double mag1_i = std::abs(u_prev->val1[i]);
353  double mag_i = sqrt(sqr(mag0_i) + sqr(mag1_i));
354  result += wt[i] * const_coeff*spline_coeff->value(mag_i)
355  * (u_prev->curl[i] * conj(v->curl[i]));
356  }
357  }
358  else throw Hermes::Exceptions::Exception("Axisymmetric Hcurl forms not implemented yet.");
359 
360  return result;
361  }
362 
363  template<typename Scalar>
364  Ord DefaultResidualCurlCurl<Scalar>::ord(int n, double *wt, Func<Ord> *u_ext[], Func<Ord> *v,
365  Geom<Ord> *e, Func<Ord> **ext) const
366  {
367  Func<Ord>* u_prev = u_ext[idx_i];
368  Ord result = Ord(0);
369  if(gt == HERMES_PLANAR)
370  {
371  for (int i = 0; i < n; i++)
372  {
373  Ord mag0_i = u_prev->val0[i];
374  Ord mag1_i = u_prev->val1[i];
375  Ord mag_i = sqrt(sqr(mag0_i) + sqr(mag1_i));
376  result += wt[i] * const_coeff*spline_coeff->value(mag_i)
377  * (u_prev->curl[i] * conj(v->curl[i]));
378  }
379  }
380  else throw Hermes::Exceptions::Exception("Axisymmetric Hcurl forms not implemented yet.");
381 
382  return result;
383  }
384 
385  template<typename Scalar>
386  VectorFormVol<Scalar>* DefaultResidualCurlCurl<Scalar>::clone() const
387  {
388  return new DefaultResidualCurlCurl(*this);
389  }
390 
391  template<typename Scalar>
392  DefaultMatrixFormSurf<Scalar>::DefaultMatrixFormSurf(int i, int j, std::string area,
393  Scalar const_coeff, Hermes2DFunction<Scalar>* f_coeff,
394  GeomType gt)
395  : MatrixFormSurf<Scalar>(i, j), const_coeff(const_coeff), function_coeff(f_coeff), gt(gt)
396  {
397  this->set_area(area);
398  // If f_coeff is HERMES_DEFAULT_FUNCTION, initialize it to be constant 1.0.
399  if(f_coeff == HERMES_DEFAULT_FUNCTION) this->function_coeff = new Hermes2DFunction<Scalar>(1.0);
400  else throw Hermes::Exceptions::Exception("Nonconstant functions in Hcurl forms not implemented yet.");
401  }
402 
403  template<typename Scalar>
404  DefaultMatrixFormSurf<Scalar>::DefaultMatrixFormSurf(int i, int j, Hermes::vector<std::string> areas,
405  Scalar const_coeff, Hermes2DFunction<Scalar>* f_coeff,
406  GeomType gt)
407  : MatrixFormSurf<Scalar>(i, j), const_coeff(const_coeff), function_coeff(f_coeff), gt(gt)
408  {
409  this->set_areas(areas);
410  // If f_coeff is HERMES_DEFAULT_FUNCTION, initialize it to be constant 1.0.
411  if(f_coeff == HERMES_DEFAULT_FUNCTION) this->function_coeff = new Hermes2DFunction<Scalar>(1.0);
412  else throw Hermes::Exceptions::Exception("Nonconstant functions in Hcurl forms not implemented yet.");
413  }
414 
415  template<typename Scalar>
416  DefaultMatrixFormSurf<Scalar>::~DefaultMatrixFormSurf()
417  {
418  if(function_coeff == HERMES_DEFAULT_FUNCTION) delete function_coeff;
419  };
420 
421  template<typename Scalar>
422  Scalar DefaultMatrixFormSurf<Scalar>::value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *u, Func<double> *v,
423  Geom<double> *e, Func<Scalar> **ext) const
424  {
425  Scalar result = 0;
426  if(gt == HERMES_PLANAR)
427  {
428  result = const_coeff * int_e_tau_f_tau<double, Scalar>(n, wt, u, v, e);
429  }
430  else throw Hermes::Exceptions::Exception("Axisymmetric Hcurl forms not implemnted yet.");
431 
432  return result;
433  }
434 
435  template<typename Scalar>
436  Ord DefaultMatrixFormSurf<Scalar>::ord(int n, double *wt, Func<Ord> *u_ext[], Func<Ord> *u,
437  Func<Ord> *v, Geom<Ord> *e, Func<Ord> **ext) const
438  {
439  Ord result = Ord(0);
440  if(gt == HERMES_PLANAR)
441  {
442  result = const_coeff * int_e_tau_f_tau<Ord, Ord>(n, wt, u, v, e);
443  }
444  else
445  throw Hermes::Exceptions::Exception("Axisymmetric Hcurl forms not implemnted yet.");
446 
447  return result;
448  }
449 
450  template<typename Scalar>
451  MatrixFormSurf<Scalar>* DefaultMatrixFormSurf<Scalar>::clone() const
452  {
453  return new DefaultMatrixFormSurf<Scalar>(*this);
454  }
455 
456  template<typename Scalar>
457  DefaultResidualSurf<Scalar>::DefaultResidualSurf(int i, std::string area,
458  Scalar const_coeff, Hermes2DFunction<Scalar>* f_coeff,
459  GeomType gt)
460  : VectorFormSurf<Scalar>(i), const_coeff(const_coeff), function_coeff(f_coeff), gt(gt)
461  {
462  this->set_area(area);
463  // If f_coeff is HERMES_DEFAULT_FUNCTION, initialize it to be constant 1.0.
464  if(f_coeff == HERMES_DEFAULT_FUNCTION) this->function_coeff = new Hermes2DFunction<Scalar>(1.0);
465  else throw Hermes::Exceptions::Exception("Nonconstant functions in Hcurl forms not implemented yet.");
466  }
467 
468  template<typename Scalar>
469  DefaultResidualSurf<Scalar>::DefaultResidualSurf(int i, Hermes::vector<std::string> areas,
470  Scalar const_coeff, Hermes2DFunction<Scalar>* f_coeff,
471  GeomType gt)
472  : VectorFormSurf<Scalar>(i), const_coeff(const_coeff), function_coeff(f_coeff), gt(gt)
473  {
474  // If f_coeff is HERMES_DEFAULT_FUNCTION, initialize it to be constant 1.0.
475  if(f_coeff == HERMES_DEFAULT_FUNCTION) this->function_coeff = new Hermes2DFunction<Scalar>(1.0);
476  else throw Hermes::Exceptions::Exception("Nonconstant functions in Hcurl forms not implemented yet.");
477  }
478 
479  template<typename Scalar>
480  DefaultResidualSurf<Scalar>::~DefaultResidualSurf()
481  {
482  if(function_coeff == HERMES_DEFAULT_FUNCTION) delete function_coeff;
483  };
484 
485  template<typename Scalar>
486  Scalar DefaultResidualSurf<Scalar>::value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *v,
487  Geom<double> *e, Func<Scalar> **ext) const
488  {
489  Scalar result = 0;
490  if(gt == HERMES_PLANAR)
491  {
492  for (int i = 0; i < n; i++)
493  result += wt[i] * ( (u_ext[0]->val0[i] * e->tx[i] + u_ext[0]->val1[i] * e->ty[i]) *
494  conj(v->val0[i] * e->tx[i] + v->val1[i] * e->ty[i]));
495  result *= const_coeff;
496  }
497  else throw Hermes::Exceptions::Exception("Axisymmetric Hcurl forms not implemnted yet.");
498 
499  return result;
500  }
501 
502  template<typename Scalar>
503  Ord DefaultResidualSurf<Scalar>::ord(int n, double *wt, Func<Ord> *u_ext[],
504  Func<Ord> *v, Geom<Ord> *e, Func<Ord> **ext) const
505  {
506  Ord result = Ord(0);
507  if(gt == HERMES_PLANAR)
508  {
509  for (int i = 0; i < n; i++)
510  result += wt[i] * ( (u_ext[0]->val0[i] * e->tx[i] + u_ext[0]->val1[i] * e->ty[i]) *
511  conj(v->val0[i] * e->tx[i] + v->val1[i] * e->ty[i]));
512  }
513  else throw Hermes::Exceptions::Exception("Axisymmetric Hcurl forms not implemnted yet.");
514 
515  return result;
516  }
517 
518  template<typename Scalar>
519  VectorFormSurf<Scalar>* DefaultResidualSurf<Scalar>::clone() const
520  {
521  return new DefaultResidualSurf(*this);
522  }
523 
524  template<typename Scalar>
525  DefaultVectorFormSurf<Scalar>::DefaultVectorFormSurf(int i, std::string area, Scalar const_coeff,
526  Hermes2DFunction<Scalar>* f_coeff,
527  GeomType gt)
528  : VectorFormSurf<Scalar>(i), const_coeff(const_coeff), function_coeff(f_coeff), gt(gt)
529  {
530  this->set_area(area);
531  // If f_coeff is HERMES_DEFAULT_FUNCTION, initialize it to be constant 1.0.
532  if(f_coeff == HERMES_DEFAULT_FUNCTION) this->function_coeff = new Hermes2DFunction<Scalar>(1.0);
533  else throw Hermes::Exceptions::Exception("Nonconstant coefficients in Hcurl forms not implemented yet.");
534  }
535 
536  template<typename Scalar>
537  DefaultVectorFormSurf<Scalar>::DefaultVectorFormSurf(int i, Hermes::vector<std::string> areas, Scalar const_coeff,
538  Hermes2DFunction<Scalar>* f_coeff,
539  GeomType gt)
540  : VectorFormSurf<Scalar>(i), const_coeff(const_coeff), function_coeff(f_coeff), gt(gt)
541  {
542  this->set_areas(areas);
543  // If f_coeff is HERMES_DEFAULT_FUNCTION, initialize it to be constant 1.0.
544  if(f_coeff == HERMES_DEFAULT_FUNCTION) this->function_coeff = new Hermes2DFunction<Scalar>(1.0);
545  else throw Hermes::Exceptions::Exception("Nonconstant coefficients in Hcurl forms not implemented yet.");
546  }
547 
548  template<typename Scalar>
549  DefaultVectorFormSurf<Scalar>::~DefaultVectorFormSurf()
550  {
551  if(function_coeff == HERMES_DEFAULT_FUNCTION) delete function_coeff;
552  };
553 
554  template<typename Scalar>
555  Scalar DefaultVectorFormSurf<Scalar>::value(int n, double *wt, Func<Scalar> *u_ext[], Func<double> *v,
556  Geom<double> *e, Func<Scalar> **ext) const
557  {
558  Scalar result = 0;
559  if(gt == HERMES_PLANAR)
560  {
561  for (int i = 0; i < n; i++)
562  {
563  result += wt[i] * conj(v->val0[i] * e->tx[i] + v->val1[i] * e->ty[i]);
564  }
565  }
566  else throw Hermes::Exceptions::Exception("Axisymmetric Hcurl forms not implemented yet.");
567 
568  return result;
569  }
570 
571  template<typename Scalar>
572  Ord DefaultVectorFormSurf<Scalar>::ord(int n, double *wt, Func<Ord> *u_ext[], Func<Ord> *v,
573  Geom<Ord> *e, Func<Ord> **ext) const
574  {
575  Ord result = Ord(0);
576  if(gt == HERMES_PLANAR)
577  {
578  for (int i = 0; i < n; i++)
579  {
580  result += wt[i] * conj(v->val0[i] * e->tx[i] + v->val1[i] * e->ty[i]);
581  }
582  }
583  else throw Hermes::Exceptions::Exception("Axisymmetric Hcurl forms not implemented yet.");
584 
585  return result;
586  }
587 
588  template<typename Scalar>
589  VectorFormSurf<Scalar>* DefaultVectorFormSurf<Scalar>::clone() const
590  {
591  return new DefaultVectorFormSurf<Scalar>(*this);
592  }
593 
594  template class HERMES_API DefaultJacobianCurlCurl<double>;
595  template class HERMES_API DefaultJacobianCurlCurl<std::complex<double> >;
596  template class HERMES_API DefaultMatrixFormVol<double>;
597  template class HERMES_API DefaultMatrixFormVol<std::complex<double> >;
598  template class HERMES_API DefaultVectorFormVol<double>;
599  template class HERMES_API DefaultVectorFormVol<std::complex<double> >;
600  template class HERMES_API DefaultResidualVol<double>;
601  template class HERMES_API DefaultResidualVol<std::complex<double> >;
602  template class HERMES_API DefaultResidualCurlCurl<double>;
603  template class HERMES_API DefaultResidualCurlCurl<std::complex<double> >;
604  template class HERMES_API DefaultMatrixFormSurf<double>;
605  template class HERMES_API DefaultMatrixFormSurf<std::complex<double> >;
606  template class HERMES_API DefaultVectorFormSurf<double>;
607  template class HERMES_API DefaultVectorFormSurf<std::complex<double> >;
608  template class HERMES_API DefaultResidualSurf<double>;
609  template class HERMES_API DefaultResidualSurf<std::complex<double> >;
610  };
611  }
612 }