HArD::Core3D
Hybrid Arbitrary Degree::Core 3D - Library to implement 3D schemes with vertex, edge, face and cell polynomials as unknowns
laddr-yangmills-lm.hpp
Go to the documentation of this file.
1 #ifndef YANGMILLS_LM_HPP
2 #define YANGMILLS_LM_HPP
3 
4 #include <iostream>
5 
6 #include <boost/math/constants/constants.hpp>
7 
8 #include <Eigen/Sparse>
9 #include <unsupported/Eigen/SparseExtra>
10 
11 #include <mesh.hpp>
12 #include <mesh_builder.hpp>
13 #include <GMpoly_cell.hpp>
14 
15 #include <laxgrad.hpp>
16 #include <laxcurl.hpp>
17 #include <laxdiv.hpp>
18 
19 
26 namespace HArDCore3D
27 {
28 
36  {
38  YangMillsNorms(double norm_E, double norm_A, double norm_lambda):
39  E(norm_E),
40  A(norm_A),
41  lambda(norm_lambda)
42  {
43  // do nothing
44  };
45 
46  double E;
47  double A;
48  double lambda;
49  };
50 
52  struct YangMills
53  {
54  typedef Eigen::SparseMatrix<double> SystemMatrixType;
56  typedef std::function<Eigen::Vector3d(const Eigen::Vector3d &)> ForcingTermType;
57  typedef std::function<Eigen::Vector3d(const Eigen::Vector3d &)> ElectricFieldType;
58  typedef std::function<Eigen::Vector3d(const Eigen::Vector3d &)> MagneticFieldType;
60  typedef std::function<Eigen::Vector3d(const double &, const Eigen::Vector3d &)> TForcingTermType;
61  typedef std::function<Eigen::Vector3d(const double &, const Eigen::Vector3d &)> TElectricFieldType;
62  typedef std::function<Eigen::Vector3d(const double &, const Eigen::Vector3d &)> TMagneticFieldType;
64  typedef std::vector<ForcingTermType> LAForcingTermType;
65  typedef std::vector<ElectricFieldType> LAElectricFieldType;
66  typedef std::vector<MagneticFieldType> LAMagneticFieldType;
68  typedef std::vector<TForcingTermType> TLAForcingTermType;
69  typedef std::vector<TElectricFieldType> TLAElectricFieldType;
70  typedef std::vector<TMagneticFieldType> TLAMagneticFieldType;
71 
73  YangMills(
74  const DDRCore & ddrcore,
75  const LieAlgebra & liealgebra,
76  bool use_threads,
77  std::ostream & output = std::cout
78  );
79 
82  double dt
83  );
85  void setSystemVector(
86  const Eigen::VectorXd & interp_f,
87  const Eigen::VectorXd & interp_dE,
88  const Eigen::VectorXd & interp_A,
89  const Eigen::VectorXd & E_old,
90  const Eigen::VectorXd & A_old,
91  double dt,
92  double theta,
93  double nonlinear_coeff
94  );
97  const Eigen::VectorXd & E_i,
98  const Eigen::VectorXd & A_i,
99  const Eigen::VectorXd & Elambdac_k,
100  const Eigen::VectorXd & sysVec,
101  double dt,
102  double theta,
103  double nonlinear_coeff
104  );
106  double stoppingCrit(
107  const Eigen::VectorXd & v,
108  const Eigen::VectorXd & u
109  );
111  double stoppingCrit2(
112  const Eigen::VectorXd & Elambda_k,
113  const Eigen::VectorXd & E_i,
114  const Eigen::VectorXd & A_i,
115  const Eigen::VectorXd & sysVec,
116  double dt,
117  double theta,
118  double nonlinear_coeff
119  );
122  const LAMagneticFieldType & curl_A,
123  double dt
124  );
126  Eigen::VectorXd computeInitialConditions(const Eigen::MatrixXd & Eh,
127  const Eigen::MatrixXd & Ah,
128  const double nonlinear_coeff,
129  const size_t solver
130  );
131 
133  Eigen::MatrixXd epsBkt_v(size_t iT,
134  boost::multi_array<double, 3> & ebkt_T,
135  const Eigen::VectorXd & v
136  ) const;
137 
139  Eigen::MatrixXd L2v_Bkt(size_t iT,
140  boost::multi_array<double, 3> & intPciPcjPgk,
141  const Eigen::VectorXd & v,
142  const size_t & entry
143  ) const;
144 
146  Eigen::MatrixXd L2v_epsBkt(size_t iT,
147  boost::multi_array<double, 3> & ebkt_T,
148  const Eigen::VectorXd & v_T,
149  const Eigen::MatrixXd & L2prod
150  ) const;
151 
153  inline size_t dimension() const
154  {
155  return m_laxcurl.dimension() + m_laxgrad.dimension();
156  }
157 
159  inline size_t sizeSystem() const
160  {
161  return dimension();
162  }
163 
165  inline const LieAlgebra & lieAlg() const
166  {
167  return m_liealg;
168  }
169 
171  inline const LAXGrad & laXGrad() const
172  {
173  return m_laxgrad;
174  }
175 
177  inline const LAXCurl & laXCurl() const
178  {
179  return m_laxcurl;
180  }
181 
183  inline const LAXDiv & laXDiv() const
184  {
185  return m_laxdiv;
186  }
187 
189  inline const XGrad & xGrad() const
190  {
191  return m_xgrad;
192  }
193 
195  inline const XCurl & xCurl() const
196  {
197  return m_xcurl;
198  }
199 
201  inline const XDiv & xDiv() const
202  {
203  return m_xdiv;
204  }
205 
207  inline const SystemMatrixType & systemMatrix() const {
208  return m_A;
209  }
210 
213  return m_A;
214  }
215 
217  inline const Eigen::VectorXd & systemVector() const {
218  return m_b;
219  }
220 
222  inline Eigen::VectorXd & systemVector() {
223  return m_b;
224  }
225 
227  inline const double & stabilizationParameter() const {
228  return m_stab_par;
229  }
230 
232  inline double & stabilizationParameter() {
233  return m_stab_par;
234  }
235 
237  std::vector<YangMillsNorms> computeYangMillsNorms(
238  const std::vector<Eigen::VectorXd> & list_dofs
239  ) const;
240 
242  template<typename outValue, typename TFct>
243  std::function<outValue(const Eigen::Vector3d &)> contractPara(const TFct &F, double t) const
244  {
245  std::function<outValue(const Eigen::Vector3d &)> f = [&F, t](const Eigen::Vector3d &x) -> outValue {return F(t, x);};
246  return f;
247  }
249  template<typename outValue, typename Fct, typename TFct>
250  std::vector<Fct> contractParaLA(const std::vector<TFct> &TF, double t) const
251  {
252  std::vector<Fct> f;
253  for (size_t i = 0; i < TF.size(); i++){
254  f.emplace_back(contractPara<outValue>(TF[i], t));
255  }
256  return f;
257  }
258 
260  double computeResidual(const Eigen::VectorXd & x) const;
261 
263  Eigen::VectorXd computeConstraint(const Eigen::VectorXd & E, const Eigen::VectorXd & A, const double nonlinear_coeff);
264 
266  double computeConstraintNorm(const Eigen::VectorXd & Ch, const size_t itersolver) const;
267 
268  std::pair<double, double> computeConditionNum() const;
269 
270  private:
272  std::vector<Eigen::MatrixXd>
273  _compute_local_contribution(
274  size_t iT,
275  double dt
276  );
277 
279  void _assemble_local_contribution(
280  size_t iT,
281  const std::vector<Eigen::MatrixXd> & lsT,
282  std::vector<std::list<Eigen::Triplet<double>>> & triplets,
283  std::vector<Eigen::VectorXd> & vecs //< List of vectors for the system
284  );
285 
287  boost::multi_array<double, 3> epsBkt_F(size_t iF) const;
288 
290  boost::multi_array<double, 3> _compute_detnij_Pot_PkF(size_t iF) const;
291 
293  boost::multi_array<double, 3> _compute_detnij_PkF(size_t iF) const;
294 
295  // Local cell *[.,.]^div operators (trilinear form). Returns the projection onto LaGkmo_T and LaGCk_T of *[P_laxcurl v_i, P_laxcurl v_j] (v_ basis of laxcurl_T) and stores the coefficients (on LaGkmo and LaGCk) of the function in the index k
296  boost::multi_array<double, 3> epsBkt_T(size_t iT) const;
297 
299  boost::multi_array<double, 3> _compute_crossij_Pot_T(size_t iT) const;
300 
302  boost::multi_array<double, 3> _compute_crossij_T(size_t iT) const;
303 
305  boost::multi_array<double, 3> _integral_ijk(size_t iT) const;
306 
308  boost::multi_array<double, 3> _int_Pci_bktPcjPgk(size_t iT) const;
309 
310  const DDRCore & m_ddrcore;
311  bool m_use_threads;
312  std::ostream & m_output;
313  const XGrad m_xgrad;
314  const XCurl m_xcurl;
315  const XDiv m_xdiv;
316  const LieAlgebra m_liealg;
317  const LAXGrad m_laxgrad;
318  const LAXCurl m_laxcurl;
319  const LAXDiv m_laxdiv;
320  SystemMatrixType m_A; // Matrix and RHS system
321  Eigen::VectorXd m_b;
322  SystemMatrixType m_laxgrad_L2; // Global laxgrad L2Product matrix
323  SystemMatrixType m_laxcurl_L2; // Global laxcurl L2Product matrix
324  SystemMatrixType m_laxdiv_L2; // Global laxdiv L2Product matrix
325  double m_stab_par;
326  };
327 
329  template<typename outValue, typename Fct>
330  std::vector<Fct> sumLA(const std::vector<Fct> & LAF, const std::vector<Fct> & LAG, double lambda)
331  {
332  std::vector<Fct> values;
333  for (size_t i = 0; i < LAF.size(); i++){
334  values.emplace_back([&, i, lambda](double t, const Eigen::Vector3d & x)-> outValue {return LAF[i](t, x) + lambda * LAG[i](t, x);});
335  }
336  return values;
337  }
338 
339  //------------------------------------------------------------------------------
340  // Exact solutions
341  //------------------------------------------------------------------------------
342 
343  static const double PI = boost::math::constants::pi<double>();
344  using std::sin;
345  using std::cos;
346  using std::pow;
347 
348  //------------------------------------------------------------------------------
349  // Trigonometric solution
350  //------------------------------------------------------------------------------
351 
352  double pressure_scaling = 1.;
354  trigonometric_E1 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
355  return Eigen::Vector3d(
356  -0.5*sin(t)*sin(PI*x(0))*cos(PI*x(1))*cos(PI*x(2)),
357  sin(t)*sin(PI*x(1))*cos(PI*x(0))*cos(PI*x(2)),
358  -0.5*sin(t)*sin(PI*x(2))*cos(PI*x(0))*cos(PI*x(1))
359  );
360  };
362  trigonometric_E2 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
363  return Eigen::Vector3d(
364  0.5*sin(PI*x(0))*cos(t)*cos(PI*x(1))*cos(PI*x(2)),
365  -sin(PI*x(1))*cos(t)*cos(PI*x(0))*cos(PI*x(2)),
366  0.5*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1))
367  );
368  };
369 
371  trigonometric_E3 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
372  return Eigen::Vector3d(
373  0.5*pow(sin(PI*x(1)), 2)*cos(t),
374  sin(t)*pow(cos(PI*x(2)), 2),
375  0.5*cos(t)*pow(cos(PI*x(0)), 2)
376  );
377  };
378 
381 
383  trigonometric_A1 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
384  return Eigen::Vector3d(
385  -0.5*sin(PI*x(0))*cos(t)*cos(PI*x(1))*cos(PI*x(2)),
386  sin(PI*x(1))*cos(t)*cos(PI*x(0))*cos(PI*x(2)),
387  -0.5*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1))
388  );
389  };
390 
392  trigonometric_A2 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
393  return Eigen::Vector3d(
394  -0.5*sin(t)*sin(PI*x(0))*cos(PI*x(1))*cos(PI*x(2)),
395  sin(t)*sin(PI*x(1))*cos(PI*x(0))*cos(PI*x(2)),
396  -0.5*sin(t)*sin(PI*x(2))*cos(PI*x(0))*cos(PI*x(1))
397  );
398  };
399 
401  trigonometric_A3 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
402  return Eigen::Vector3d(-0.5*sin(t)*pow(sin(PI*x(1)), 2),
403  cos(t)*pow(cos(PI*x(2)), 2),
404  -0.5*sin(t)*pow(cos(PI*x(0)), 2)
405  );
406  };
407 
410 
412  trigonometric_B1_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
413  return Eigen::Vector3d(
414  1.5*PI*sin(PI*x(1))*sin(PI*x(2))*cos(t)*cos(PI*x(0)),
415  0,
416  -1.5*PI*sin(PI*x(0))*sin(PI*x(1))*cos(t)*cos(PI*x(2))
417  );
418  };
419 
421  trigonometric_B2_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
422  return Eigen::Vector3d(
423  1.5*PI*sin(t)*sin(PI*x(1))*sin(PI*x(2))*cos(PI*x(0)),
424  0,
425  -1.5*PI*sin(t)*sin(PI*x(0))*sin(PI*x(1))*cos(PI*x(2))
426  );
427  };
428 
430  trigonometric_B3_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
431  return Eigen::Vector3d(
432  2*PI*sin(PI*x(2))*cos(t)*cos(PI*x(2)),
433  -1.0*PI*sin(t)*sin(PI*x(0))*cos(PI*x(0)),
434  1.0*PI*sin(t)*sin(PI*x(1))*cos(PI*x(1))
435  );
436  };
437 
440 
442  trigonometric_B1_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
443  return Eigen::Vector3d(
444  -0.5*pow(sin(t), 2)*sin(PI*x(1))*pow(cos(PI*x(0)), 3)*cos(PI*x(2)) + 0.5*sin(t)*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1))*pow(cos(PI*x(2)), 2),
445  -0.25*pow(sin(t), 2)*sin(PI*x(0))*pow(cos(PI*x(0)), 2)*cos(PI*x(1))*cos(PI*x(2)) + 0.25*pow(sin(t), 2)*pow(sin(PI*x(1)), 2)*sin(PI*x(2))*cos(PI*x(0))*cos(PI*x(1)),
446  0.5*pow(sin(t), 2)*pow(sin(PI*x(1)), 3)*cos(PI*x(0))*cos(PI*x(2)) - 0.5*sin(t)*sin(PI*x(0))*cos(t)*cos(PI*x(1))*pow(cos(PI*x(2)), 3)
447  );
448  };
449 
451  trigonometric_B2_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
452  return Eigen::Vector3d(
453  0.5*sin(t)*sin(PI*x(1))*cos(t)*pow(cos(PI*x(0)), 3)*cos(PI*x(2)) - 0.5*sin(PI*x(2))*pow(cos(t), 2)*cos(PI*x(0))*cos(PI*x(1))*pow(cos(PI*x(2)), 2),
454  0.25*sin(t)*sin(PI*x(0))*cos(t)*pow(cos(PI*x(0)), 2)*cos(PI*x(1))*cos(PI*x(2)) - 0.25*sin(t)*pow(sin(PI*x(1)), 2)*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1)),
455  -0.5*sin(t)*pow(sin(PI*x(1)), 3)*cos(t)*cos(PI*x(0))*cos(PI*x(2)) + 0.5*sin(PI*x(0))*pow(cos(t), 2)*cos(PI*x(1))*pow(cos(PI*x(2)), 3)
456  );
457  };
458 
460  trigonometric_B3_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
461  return Eigen::Vector3d(
462  0,
463  0,
464  0
465  );
466  };
467 
470 
472  trigonometric_dtE1 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
473  return Eigen::Vector3d(
474  -0.5*sin(PI*x(0))*cos(t)*cos(PI*x(1))*cos(PI*x(2)),
475  sin(PI*x(1))*cos(t)*cos(PI*x(0))*cos(PI*x(2)),
476  -0.5*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1))
477  );
478  };
480  trigonometric_dtE2 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
481  return Eigen::Vector3d(
482  -0.5*sin(t)*sin(PI*x(0))*cos(PI*x(1))*cos(PI*x(2)),
483  sin(t)*sin(PI*x(1))*cos(PI*x(0))*cos(PI*x(2)),
484  -0.5*sin(t)*sin(PI*x(2))*cos(PI*x(0))*cos(PI*x(1))
485  );
486  };
487 
489  trigonometric_dtE3 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
490  return Eigen::Vector3d(
491  -0.5*sin(t)*pow(sin(PI*x(1)), 2),
492  cos(t)*pow(cos(PI*x(2)), 2),
493  -0.5*sin(t)*pow(cos(PI*x(0)), 2)
494  );
495  };
496 
499 
501  trigonometric_f1_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
502  return Eigen::Vector3d(
503  -0.5*sin(PI*x(0))*cos(t)*cos(PI*x(1))*cos(PI*x(2)) + 1.5*pow(PI, 2)*sin(PI*x(0))*cos(t)*cos(PI*x(1))*cos(PI*x(2)),
504  -3.0*pow(PI, 2)*sin(PI*x(1))*cos(t)*cos(PI*x(0))*cos(PI*x(2)) + sin(PI*x(1))*cos(t)*cos(PI*x(0))*cos(PI*x(2)),
505  -0.5*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1)) + 1.5*pow(PI, 2)*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1))
506  );
507  };
508 
510  trigonometric_f2_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
511  return Eigen::Vector3d(
512  -0.5*sin(t)*sin(PI*x(0))*cos(PI*x(1))*cos(PI*x(2)) + 1.5*pow(PI, 2)*sin(t)*sin(PI*x(0))*cos(PI*x(1))*cos(PI*x(2)),
513  -3.0*pow(PI, 2)*sin(t)*sin(PI*x(1))*cos(PI*x(0))*cos(PI*x(2)) + sin(t)*sin(PI*x(1))*cos(PI*x(0))*cos(PI*x(2)),
514  -0.5*sin(t)*sin(PI*x(2))*cos(PI*x(0))*cos(PI*x(1)) + 1.5*pow(PI, 2)*sin(t)*sin(PI*x(2))*cos(PI*x(0))*cos(PI*x(1))
515  );
516  };
517 
519  trigonometric_f3_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
520  return Eigen::Vector3d(
521  -0.5*sin(t)*pow(sin(PI*x(1)), 2) + 1.0*pow(PI, 2)*sin(t)*pow(sin(PI*x(1)), 2) - 1.0*pow(PI, 2)*sin(t)*pow(cos(PI*x(1)), 2),
522  2*pow(PI, 2)*pow(sin(PI*x(2)), 2)*cos(t) - 2*pow(PI, 2)*cos(t)*pow(cos(PI*x(2)), 2) + cos(t)*pow(cos(PI*x(2)), 2),
523  -1.0*pow(PI, 2)*sin(t)*pow(sin(PI*x(0)), 2) - 0.5*sin(t)*pow(cos(PI*x(0)), 2) + 1.0*pow(PI, 2)*sin(t)*pow(cos(PI*x(0)), 2)
524  );
525  };
526 
529 
531  trigonometric_f1_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
532  return Eigen::Vector3d(
533  0.5*(0.25*sin(t)*sin(PI*x(0))*cos(t)*pow(cos(PI*x(0)), 2)*cos(PI*x(1))*cos(PI*x(2)) - 0.25*sin(t)*pow(sin(PI*x(1)), 2)*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1)))*sin(t)*pow(cos(PI*x(0)), 2) + (-1.5*PI*sin(t)*sin(PI*x(0))*sin(PI*x(1))*cos(PI*x(2)) - 0.5*sin(t)*pow(sin(PI*x(1)), 3)*cos(t)*cos(PI*x(0))*cos(PI*x(2)) + 0.5*sin(PI*x(0))*pow(cos(t), 2)*cos(PI*x(1))*pow(cos(PI*x(2)), 3))*cos(t)*pow(cos(PI*x(2)), 2) + 0.75*PI*pow(sin(t), 2)*sin(PI*x(0))*sin(PI*x(2))*pow(cos(PI*x(0)), 2)*cos(PI*x(1)) - 2.25*PI*pow(sin(t), 2)*pow(sin(PI*x(1)), 2)*cos(PI*x(0))*cos(PI*x(1))*cos(PI*x(2)) - 0.5*PI*sin(t)*sin(PI*x(0))*sin(PI*x(1))*cos(t)*pow(cos(PI*x(2)), 3),
534  0.5*(-1.5*PI*sin(t)*sin(PI*x(0))*sin(PI*x(1))*cos(PI*x(2)) - 0.5*sin(t)*pow(sin(PI*x(1)), 3)*cos(t)*cos(PI*x(0))*cos(PI*x(2)) + 0.5*sin(PI*x(0))*pow(cos(t), 2)*cos(PI*x(1))*pow(cos(PI*x(2)), 3))*sin(t)*pow(sin(PI*x(1)), 2) - 0.5*(1.5*PI*sin(t)*sin(PI*x(1))*sin(PI*x(2))*cos(PI*x(0)) + 0.5*sin(t)*sin(PI*x(1))*cos(t)*pow(cos(PI*x(0)), 3)*cos(PI*x(2)) - 0.5*sin(PI*x(2))*pow(cos(t), 2)*cos(PI*x(0))*cos(PI*x(1))*pow(cos(PI*x(2)), 2))*sin(t)*pow(cos(PI*x(0)), 2) - 0.5*PI*pow(sin(t), 2)*sin(PI*x(0))*pow(sin(PI*x(1)), 3)*cos(PI*x(2)) - 0.5*PI*pow(sin(t), 2)*sin(PI*x(0))*sin(PI*x(1))*pow(cos(PI*x(1)), 2)*cos(PI*x(2)) - 0.5*PI*pow(sin(t), 2)*sin(PI*x(1))*sin(PI*x(2))*pow(cos(PI*x(0)), 3) + 2.0*PI*sin(t)*pow(sin(PI*x(2)), 2)*cos(t)*cos(PI*x(0))*cos(PI*x(1))*cos(PI*x(2)) - 1.0*PI*sin(t)*cos(t)*cos(PI*x(0))*cos(PI*x(1))*pow(cos(PI*x(2)), 3),
535  -0.5*(0.25*sin(t)*sin(PI*x(0))*cos(t)*pow(cos(PI*x(0)), 2)*cos(PI*x(1))*cos(PI*x(2)) - 0.25*sin(t)*pow(sin(PI*x(1)), 2)*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1)))*sin(t)*pow(sin(PI*x(1)), 2) - (1.5*PI*sin(t)*sin(PI*x(1))*sin(PI*x(2))*cos(PI*x(0)) + 0.5*sin(t)*sin(PI*x(1))*cos(t)*pow(cos(PI*x(0)), 3)*cos(PI*x(2)) - 0.5*sin(PI*x(2))*pow(cos(t), 2)*cos(PI*x(0))*cos(PI*x(1))*pow(cos(PI*x(2)), 2))*cos(t)*pow(cos(PI*x(2)), 2) - 1.0*PI*pow(sin(t), 2)*pow(sin(PI*x(0)), 2)*cos(PI*x(0))*cos(PI*x(1))*cos(PI*x(2)) + 0.25*PI*pow(sin(t), 2)*sin(PI*x(0))*pow(sin(PI*x(1)), 2)*sin(PI*x(2))*cos(PI*x(1)) - 0.25*PI*pow(sin(t), 2)*pow(cos(PI*x(0)), 3)*cos(PI*x(1))*cos(PI*x(2)) + 1.5*PI*sin(t)*sin(PI*x(1))*sin(PI*x(2))*cos(t)*cos(PI*x(0))*pow(cos(PI*x(2)), 2)
536  );
537  };
538 
540  trigonometric_f2_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
541  return Eigen::Vector3d(
542  -0.5*(-0.25*pow(sin(t), 2)*sin(PI*x(0))*pow(cos(PI*x(0)), 2)*cos(PI*x(1))*cos(PI*x(2)) + 0.25*pow(sin(t), 2)*pow(sin(PI*x(1)), 2)*sin(PI*x(2))*cos(PI*x(0))*cos(PI*x(1)))*sin(t)*pow(cos(PI*x(0)), 2) - (0.5*pow(sin(t), 2)*pow(sin(PI*x(1)), 3)*cos(PI*x(0))*cos(PI*x(2)) - 0.5*sin(t)*sin(PI*x(0))*cos(t)*cos(PI*x(1))*pow(cos(PI*x(2)), 3) - 1.5*PI*sin(PI*x(0))*sin(PI*x(1))*cos(t)*cos(PI*x(2)))*cos(t)*pow(cos(PI*x(2)), 2) - 0.75*PI*sin(t)*sin(PI*x(0))*sin(PI*x(2))*cos(t)*pow(cos(PI*x(0)), 2)*cos(PI*x(1)) + 2.25*PI*sin(t)*pow(sin(PI*x(1)), 2)*cos(t)*cos(PI*x(0))*cos(PI*x(1))*cos(PI*x(2)) + 0.5*PI*sin(PI*x(0))*sin(PI*x(1))*pow(cos(t), 2)*pow(cos(PI*x(2)), 3),
543  0.5*(-0.5*pow(sin(t), 2)*sin(PI*x(1))*pow(cos(PI*x(0)), 3)*cos(PI*x(2)) + 0.5*sin(t)*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1))*pow(cos(PI*x(2)), 2) + 1.5*PI*sin(PI*x(1))*sin(PI*x(2))*cos(t)*cos(PI*x(0)))*sin(t)*pow(cos(PI*x(0)), 2) - 0.5*(0.5*pow(sin(t), 2)*pow(sin(PI*x(1)), 3)*cos(PI*x(0))*cos(PI*x(2)) - 0.5*sin(t)*sin(PI*x(0))*cos(t)*cos(PI*x(1))*pow(cos(PI*x(2)), 3) - 1.5*PI*sin(PI*x(0))*sin(PI*x(1))*cos(t)*cos(PI*x(2)))*sin(t)*pow(sin(PI*x(1)), 2) + 0.5*PI*sin(t)*sin(PI*x(0))*pow(sin(PI*x(1)), 3)*cos(t)*cos(PI*x(2)) + 0.5*PI*sin(t)*sin(PI*x(0))*sin(PI*x(1))*cos(t)*pow(cos(PI*x(1)), 2)*cos(PI*x(2)) + 0.5*PI*sin(t)*sin(PI*x(1))*sin(PI*x(2))*cos(t)*pow(cos(PI*x(0)), 3) - 2.0*PI*pow(sin(PI*x(2)), 2)*pow(cos(t), 2)*cos(PI*x(0))*cos(PI*x(1))*cos(PI*x(2)) + 1.0*PI*pow(cos(t), 2)*cos(PI*x(0))*cos(PI*x(1))*pow(cos(PI*x(2)), 3),
544  0.5*(-0.25*pow(sin(t), 2)*sin(PI*x(0))*pow(cos(PI*x(0)), 2)*cos(PI*x(1))*cos(PI*x(2)) + 0.25*pow(sin(t), 2)*pow(sin(PI*x(1)), 2)*sin(PI*x(2))*cos(PI*x(0))*cos(PI*x(1)))*sin(t)*pow(sin(PI*x(1)), 2) + (-0.5*pow(sin(t), 2)*sin(PI*x(1))*pow(cos(PI*x(0)), 3)*cos(PI*x(2)) + 0.5*sin(t)*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1))*pow(cos(PI*x(2)), 2) + 1.5*PI*sin(PI*x(1))*sin(PI*x(2))*cos(t)*cos(PI*x(0)))*cos(t)*pow(cos(PI*x(2)), 2) + 1.0*PI*sin(t)*pow(sin(PI*x(0)), 2)*cos(t)*cos(PI*x(0))*cos(PI*x(1))*cos(PI*x(2)) - 0.25*PI*sin(t)*sin(PI*x(0))*pow(sin(PI*x(1)), 2)*sin(PI*x(2))*cos(t)*cos(PI*x(1)) + 0.25*PI*sin(t)*cos(t)*pow(cos(PI*x(0)), 3)*cos(PI*x(1))*cos(PI*x(2)) - 1.5*PI*sin(PI*x(1))*sin(PI*x(2))*pow(cos(t), 2)*cos(PI*x(0))*pow(cos(PI*x(2)), 2)
545  );
546  };
547 
549  trigonometric_f3_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
550  return Eigen::Vector3d(
551  0.5*(-0.25*pow(sin(t), 2)*sin(PI*x(0))*pow(cos(PI*x(0)), 2)*cos(PI*x(1))*cos(PI*x(2)) + 0.25*pow(sin(t), 2)*pow(sin(PI*x(1)), 2)*sin(PI*x(2))*cos(PI*x(0))*cos(PI*x(1)))*sin(t)*sin(PI*x(2))*cos(PI*x(0))*cos(PI*x(1)) - 0.5*(0.25*sin(t)*sin(PI*x(0))*cos(t)*pow(cos(PI*x(0)), 2)*cos(PI*x(1))*cos(PI*x(2)) - 0.25*sin(t)*pow(sin(PI*x(1)), 2)*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1)))*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1)) + (0.5*pow(sin(t), 2)*pow(sin(PI*x(1)), 3)*cos(PI*x(0))*cos(PI*x(2)) - 0.5*sin(t)*sin(PI*x(0))*cos(t)*cos(PI*x(1))*pow(cos(PI*x(2)), 3) - 1.5*PI*sin(PI*x(0))*sin(PI*x(1))*cos(t)*cos(PI*x(2)))*sin(t)*sin(PI*x(1))*cos(PI*x(0))*cos(PI*x(2)) - (-1.5*PI*sin(t)*sin(PI*x(0))*sin(PI*x(1))*cos(PI*x(2)) - 0.5*sin(t)*pow(sin(PI*x(1)), 3)*cos(t)*cos(PI*x(0))*cos(PI*x(2)) + 0.5*sin(PI*x(0))*pow(cos(t), 2)*cos(PI*x(1))*pow(cos(PI*x(2)), 3))*sin(PI*x(1))*cos(t)*cos(PI*x(0))*cos(PI*x(2)),
552  -0.5*(-0.5*pow(sin(t), 2)*sin(PI*x(1))*pow(cos(PI*x(0)), 3)*cos(PI*x(2)) + 0.5*sin(t)*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1))*pow(cos(PI*x(2)), 2) + 1.5*PI*sin(PI*x(1))*sin(PI*x(2))*cos(t)*cos(PI*x(0)))*sin(t)*sin(PI*x(2))*cos(PI*x(0))*cos(PI*x(1)) + 0.5*(0.5*pow(sin(t), 2)*pow(sin(PI*x(1)), 3)*cos(PI*x(0))*cos(PI*x(2)) - 0.5*sin(t)*sin(PI*x(0))*cos(t)*cos(PI*x(1))*pow(cos(PI*x(2)), 3) - 1.5*PI*sin(PI*x(0))*sin(PI*x(1))*cos(t)*cos(PI*x(2)))*sin(t)*sin(PI*x(0))*cos(PI*x(1))*cos(PI*x(2)) - 0.5*(-1.5*PI*sin(t)*sin(PI*x(0))*sin(PI*x(1))*cos(PI*x(2)) - 0.5*sin(t)*pow(sin(PI*x(1)), 3)*cos(t)*cos(PI*x(0))*cos(PI*x(2)) + 0.5*sin(PI*x(0))*pow(cos(t), 2)*cos(PI*x(1))*pow(cos(PI*x(2)), 3))*sin(PI*x(0))*cos(t)*cos(PI*x(1))*cos(PI*x(2)) + 0.5*(1.5*PI*sin(t)*sin(PI*x(1))*sin(PI*x(2))*cos(PI*x(0)) + 0.5*sin(t)*sin(PI*x(1))*cos(t)*pow(cos(PI*x(0)), 3)*cos(PI*x(2)) - 0.5*sin(PI*x(2))*pow(cos(t), 2)*cos(PI*x(0))*cos(PI*x(1))*pow(cos(PI*x(2)), 2))*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1)),
553  -0.5*(-0.25*pow(sin(t), 2)*sin(PI*x(0))*pow(cos(PI*x(0)), 2)*cos(PI*x(1))*cos(PI*x(2)) + 0.25*pow(sin(t), 2)*pow(sin(PI*x(1)), 2)*sin(PI*x(2))*cos(PI*x(0))*cos(PI*x(1)))*sin(t)*sin(PI*x(0))*cos(PI*x(1))*cos(PI*x(2)) + 0.5*(0.25*sin(t)*sin(PI*x(0))*cos(t)*pow(cos(PI*x(0)), 2)*cos(PI*x(1))*cos(PI*x(2)) - 0.25*sin(t)*pow(sin(PI*x(1)), 2)*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1)))*sin(PI*x(0))*cos(t)*cos(PI*x(1))*cos(PI*x(2)) - (-0.5*pow(sin(t), 2)*sin(PI*x(1))*pow(cos(PI*x(0)), 3)*cos(PI*x(2)) + 0.5*sin(t)*sin(PI*x(2))*cos(t)*cos(PI*x(0))*cos(PI*x(1))*pow(cos(PI*x(2)), 2) + 1.5*PI*sin(PI*x(1))*sin(PI*x(2))*cos(t)*cos(PI*x(0)))*sin(t)*sin(PI*x(1))*cos(PI*x(0))*cos(PI*x(2)) + (1.5*PI*sin(t)*sin(PI*x(1))*sin(PI*x(2))*cos(PI*x(0)) + 0.5*sin(t)*sin(PI*x(1))*cos(t)*pow(cos(PI*x(0)), 3)*cos(PI*x(2)) - 0.5*sin(PI*x(2))*pow(cos(t), 2)*cos(PI*x(0))*cos(PI*x(1))*pow(cos(PI*x(2)), 2))*sin(PI*x(1))*cos(t)*cos(PI*x(0))*cos(PI*x(2)));
554  };
555 
558 
559  //------------------------------------------------------------------------------
560  // Linear solution
561  //------------------------------------------------------------------------------
562 
564  linear_E1 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
565  return Eigen::Vector3d(-x(2), -x(1), -x(0));
566  };
567 
569  linear_E2 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
570  return Eigen::Vector3d(-x(2), -x(0), -x(1));
571  };
572 
574  linear_E3 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
575  return Eigen::Vector3d(-x(1) - x(2), -x(0) - x(2), -x(0) - x(1));
576  };
577 
580 
582  linear_A1 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
583  return Eigen::Vector3d(t*x(2), t*x(1), t*x(0));
584  };
585 
587  linear_A2 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
588  return Eigen::Vector3d(t*x(2), t*x(0), t*x(1));
589  };
590 
592  linear_A3 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
593  return Eigen::Vector3d(t*x(1) + t*x(2), t*x(0) + t*x(2), t*x(0) + t*x(1));
594  };
595 
598 
600  linear_B1_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
601  return Eigen::Vector3d(
602  0,
603  0,
604  0
605  );
606  };
607 
609  linear_B2_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
610  return Eigen::Vector3d(
611  t,
612  t,
613  t
614  );
615  };
616 
618  linear_B3_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
619  return Eigen::Vector3d(
620  0,
621  0,
622  0
623  );
624  };
625 
628 
630  linear_B1_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
631  return Eigen::Vector3d(
632  1.0*t*x(0)*(t*x(0) + t*x(1)) - 1.0*t*x(1)*(t*x(0) + t*x(2)),
633  1.0*t*x(1)*(t*x(1) + t*x(2)) - 1.0*t*x(2)*(t*x(0) + t*x(1)),
634  -1.0*t*x(0)*(t*x(1) + t*x(2)) + 1.0*t*x(2)*(t*x(0) + t*x(2))
635  );
636  };
637 
639  linear_B2_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
640  return Eigen::Vector3d(
641  1.0*t*x(0)*(t*x(0) + t*x(2)) - 1.0*t*x(1)*(t*x(0) + t*x(1)),
642  -1.0*t*x(0)*(t*x(1) + t*x(2)) + 1.0*t*x(2)*(t*x(0) + t*x(1)),
643  1.0*t*x(1)*(t*x(1) + t*x(2)) - 1.0*t*x(2)*(t*x(0) + t*x(2))
644  );
645  };
646 
648  linear_B3_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
649  return Eigen::Vector3d(
650  -1.0*pow(t, 2)*pow(x(0), 2) + 1.0*pow(t, 2)*pow(x(1), 2),
651  1.0*pow(t, 2)*x(0)*x(2) - 1.0*pow(t, 2)*x(1)*x(2),
652  1.0*pow(t, 2)*x(0)*x(2) - 1.0*pow(t, 2)*x(1)*x(2)
653  );
654  };
655 
658 
660  linear_dtE1 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
661  return Eigen::Vector3d(0, 0, 0);
662  };
664  linear_dtE2 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
665  return Eigen::Vector3d(0, 0, 0);
666  };
667 
669  linear_dtE3 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
670  return Eigen::Vector3d(0, 0, 0);
671  };
672 
675 
677  linear_f1_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
678  return Eigen::Vector3d(0, 0, 0);
679  };
680 
682  linear_f2_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
683  return Eigen::Vector3d(0, 0, 0);
684  };
685 
687  linear_f3_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
688  return Eigen::Vector3d(0, 0, 0);
689  };
690 
693 
695  linear_f1_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
696  return Eigen::Vector3d(1.0*pow(t, 2)*x(0) + 1.0*pow(t, 2)*x(1) - t*x(0)*(1.0*pow(t, 2)*x(0)*x(2) - 1.0*pow(t, 2)*x(1)*x(2)) + t*x(1)*(1.0*pow(t, 2)*x(0)*x(2) - 1.0*pow(t, 2)*x(1)*x(2)) - 1.0*t*(t*x(0) + t*x(1)) - (t*x(0) + t*x(1))*(-1.0*t*x(0)*(t*x(1) + t*x(2)) + 1.0*t*x(2)*(t*x(0) + t*x(1)) + t) + (t*x(0) + t*x(2))*(1.0*t*x(1)*(t*x(1) + t*x(2)) - 1.0*t*x(2)*(t*x(0) + t*x(2)) + t), 1.0*pow(t, 2)*x(1) + 1.0*pow(t, 2)*x(2) - t*x(1)*(-1.0*pow(t, 2)*pow(x(0), 2) + 1.0*pow(t, 2)*pow(x(1), 2)) + t*x(2)*(1.0*pow(t, 2)*x(0)*x(2) - 1.0*pow(t, 2)*x(1)*x(2)) - 1.0*t*(t*x(1) + t*x(2)) + (t*x(0) + t*x(1))*(1.0*t*x(0)*(t*x(0) + t*x(2)) - 1.0*t*x(1)*(t*x(0) + t*x(1)) + t) - (t*x(1) + t*x(2))*(1.0*t*x(1)*(t*x(1) + t*x(2)) - 1.0*t*x(2)*(t*x(0) + t*x(2)) + t), 1.0*pow(t, 2)*x(0) + 1.0*pow(t, 2)*x(2) + t*x(0)*(-1.0*pow(t, 2)*pow(x(0), 2) + 1.0*pow(t, 2)*pow(x(1), 2)) - t*x(2)*(1.0*pow(t, 2)*x(0)*x(2) - 1.0*pow(t, 2)*x(1)*x(2)) - 1.0*t*(t*x(0) + t*x(2)) - (t*x(0) + t*x(2))*(1.0*t*x(0)*(t*x(0) + t*x(2)) - 1.0*t*x(1)*(t*x(0) + t*x(1)) + t) + (t*x(1) + t*x(2))*(-1.0*t*x(0)*(t*x(1) + t*x(2)) + 1.0*t*x(2)*(t*x(0) + t*x(1)) + t)
697  );
698  };
699 
701  linear_f2_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
702  return Eigen::Vector3d(-1.0*pow(t, 2)*x(0) - 1.0*pow(t, 2)*x(1) - t*x(0)*(1.0*pow(t, 2)*x(0)*x(2) - 1.0*pow(t, 2)*x(1)*x(2)) + t*x(1)*(1.0*pow(t, 2)*x(0)*x(2) - 1.0*pow(t, 2)*x(1)*x(2)) + 1.0*t*(t*x(0) + t*x(1)) - 1.0*t*(t*x(1) + t*x(2)) + (t*x(0) + t*x(1))*(1.0*t*x(1)*(t*x(1) + t*x(2)) - 1.0*t*x(2)*(t*x(0) + t*x(1))) - (t*x(0) + t*x(2))*(-1.0*t*x(0)*(t*x(1) + t*x(2)) + 1.0*t*x(2)*(t*x(0) + t*x(2))), -1.0*pow(t, 2)*x(0) - 1.0*pow(t, 2)*x(2) + t*x(0)*(-1.0*pow(t, 2)*pow(x(0), 2) + 1.0*pow(t, 2)*pow(x(1), 2)) - t*x(2)*(1.0*pow(t, 2)*x(0)*x(2) - 1.0*pow(t, 2)*x(1)*x(2)) - (t*x(0) + t*x(1))*(1.0*t*x(0)*(t*x(0) + t*x(1)) - 1.0*t*x(1)*(t*x(0) + t*x(2))) + (t*x(1) + t*x(2))*(-1.0*t*x(0)*(t*x(1) + t*x(2)) + 1.0*t*x(2)*(t*x(0) + t*x(2))), -1.0*pow(t, 2)*x(1) - 1.0*pow(t, 2)*x(2) - t*x(1)*(-1.0*pow(t, 2)*pow(x(0), 2) + 1.0*pow(t, 2)*pow(x(1), 2)) + t*x(2)*(1.0*pow(t, 2)*x(0)*x(2) - 1.0*pow(t, 2)*x(1)*x(2)) - 1.0*t*(t*x(0) + t*x(1)) + 1.0*t*(t*x(1) + t*x(2)) + (t*x(0) + t*x(2))*(1.0*t*x(0)*(t*x(0) + t*x(1)) - 1.0*t*x(1)*(t*x(0) + t*x(2))) - (t*x(1) + t*x(2))*(1.0*t*x(1)*(t*x(1) + t*x(2)) - 1.0*t*x(2)*(t*x(0) + t*x(1)))
703  );
704  };
705 
707  linear_f3_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
708  return Eigen::Vector3d(1.0*pow(t, 2)*x(0) - 1.0*pow(t, 2)*x(1) + 1.0*pow(t, 2)*x(2) + t*x(0)*(-1.0*t*x(0)*(t*x(1) + t*x(2)) + 1.0*t*x(2)*(t*x(0) + t*x(2))) + t*x(0)*(-1.0*t*x(0)*(t*x(1) + t*x(2)) + 1.0*t*x(2)*(t*x(0) + t*x(1)) + t) - t*x(1)*(1.0*t*x(1)*(t*x(1) + t*x(2)) - 1.0*t*x(2)*(t*x(0) + t*x(1))) - t*x(1)*(1.0*t*x(1)*(t*x(1) + t*x(2)) - 1.0*t*x(2)*(t*x(0) + t*x(2)) + t), 1.0*pow(t, 2)*x(2) - t*x(0)*(1.0*t*x(0)*(t*x(0) + t*x(2)) - 1.0*t*x(1)*(t*x(0) + t*x(1)) + t) + t*x(1)*(1.0*t*x(0)*(t*x(0) + t*x(1)) - 1.0*t*x(1)*(t*x(0) + t*x(2))) - t*x(2)*(-1.0*t*x(0)*(t*x(1) + t*x(2)) + 1.0*t*x(2)*(t*x(0) + t*x(2))) + t*x(2)*(1.0*t*x(1)*(t*x(1) + t*x(2)) - 1.0*t*x(2)*(t*x(0) + t*x(2)) + t), 2.0*pow(t, 2)*x(1) - 1.0*pow(t, 2)*x(2) - t*x(0)*(1.0*t*x(0)*(t*x(0) + t*x(1)) - 1.0*t*x(1)*(t*x(0) + t*x(2))) + t*x(1)*(1.0*t*x(0)*(t*x(0) + t*x(2)) - 1.0*t*x(1)*(t*x(0) + t*x(1)) + t) + t*x(2)*(1.0*t*x(1)*(t*x(1) + t*x(2)) - 1.0*t*x(2)*(t*x(0) + t*x(1))) - t*x(2)*(-1.0*t*x(0)*(t*x(1) + t*x(2)) + 1.0*t*x(2)*(t*x(0) + t*x(1)) + t)
709  );
710  };
711 
714 
715  //------------------------------------------------------------------------------
716  // Constant solution
717  //------------------------------------------------------------------------------
718 
720  const_E1 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
721  return Eigen::Vector3d::Zero();
722  };
723 
725  const_E2 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
726  return Eigen::Vector3d::Zero();
727  };
728 
730  const_E3 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
731  return Eigen::Vector3d::Zero();
732  };
733 
736 
738  const_A1 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
739  return Eigen::Vector3d(0.2, 0.4, 0.6);
740  };
741 
743  const_A2 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
744  return Eigen::Vector3d(0.8, 1.0, 1.2);
745  };
746 
748  const_A3 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
749  return Eigen::Vector3d(1.4, 1.6, 1.8);
750  };
751 
754 
756  const_B1_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
757  return Eigen::Vector3d(0, 0, 0);
758  };
759 
761  const_B2_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
762  return Eigen::Vector3d(0, 0, 0);
763  };
764 
766  const_B3_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
767  return Eigen::Vector3d(0, 0, 0);
768  };
769 
772 
774  const_B1_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
775  return Eigen::Vector3d(-0.12, 0.24, -0.12);
776  };
777 
779  const_B2_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
780  return Eigen::Vector3d(0.24, -0.48, 0.24);
781  };
782 
784  const_B3_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
785  return Eigen::Vector3d(-0.12, 0.24, -0.12);
786  };
787 
790 
792  const_dtE1 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
793  return Eigen::Vector3d(0, 0, 0);
794  };
796  const_dtE2 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
797  return Eigen::Vector3d(0, 0, 0);
798  };
799 
801  const_dtE3 = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
802  return Eigen::Vector3d(0, 0, 0);
803  };
804 
807 
809  const_f1_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
810  return Eigen::Vector3d(0, 0, 0);
811  };
812 
814  const_f2_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
815  return Eigen::Vector3d(0, 0, 0);
816  };
817 
819  const_f3_linear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
820  return Eigen::Vector3d(0, 0, 0);
821  };
822 
825 
827  const_f1_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
828  return Eigen::Vector3d(1.656, 0.144, -1.368);
829  };
830 
832  const_f2_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
833  return Eigen::Vector3d(0.432, 0, -0.432);
834  };
835 
837  const_f3_nonlinear = [](const double t, const Eigen::Vector3d & x) -> Eigen::Vector3d {
838  return Eigen::Vector3d(-0.792, -0.144, 0.504);
839  };
840 
843 
844  //------------------------------------------------------------------------------
847  {
849  AssembleSystems(std::vector<Eigen::MatrixXd> sys, std::vector<Eigen::VectorXd> vec):
850  systems(sys),
851  vectors(vec)
852  {
853  };
854 
855  std::vector<Eigen::MatrixXd> systems;
856  std::vector<Eigen::VectorXd> vectors;
857  };
860  {
862  AssembledSystems(std::vector<Eigen::SparseMatrix<double>> sys, std::vector<Eigen::VectorXd> vec):
863  systems(sys),
864  vectors(vec)
865  {
866  };
867 
868  std::vector<Eigen::SparseMatrix<double>> systems;
869  std::vector<Eigen::VectorXd> vectors;
870  };
871 
872 
873 
874 } // end of namespace HArDCore3D
875 
876 #endif
Construct all polynomial spaces for the DDR sequence.
Definition: ddrcore.hpp:62
Discrete Lie algebra valued Hcurl space.
Definition: laxcurl.hpp:18
Discrete Lie algebra valued Hdiv space: local operators, L2 product and global interpolator.
Definition: laxdiv.hpp:20
Discrete Lie algebra valued H1 space: local operators, L2 product and global interpolator.
Definition: laxgrad.hpp:18
Lie algebra class: mass matrix, structure constants and Lie bracket.
Definition: liealgebra.hpp:17
Discrete Hcurl space: local operators, L2 product and global interpolator.
Definition: xcurl.hpp:19
Discrete Hdiv space: local operators, L2 product and global interpolator.
Definition: xdiv.hpp:20
Discrete H1 space: local operators, L2 product and global interpolator.
Definition: xgrad.hpp:18
size_t dimension() const
Returns the dimension of the global space (all DOFs for all geometric entities)
Definition: localdofspace.hpp:80
static const double PI
Definition: ddr-magnetostatics.hpp:186
double pressure_scaling
Definition: ddr-stokes.hpp:249
static YangMills::TMagneticFieldType linear_B2_nonlinear
Definition: laddr-yangmills-lm.hpp:639
AssembleSystems(std::vector< Eigen::MatrixXd > sys, std::vector< Eigen::VectorXd > vec)
Constructor.
Definition: laddr-yangmills-lm.hpp:849
const LAXCurl & laXCurl() const
Returns the space LAXCurl.
Definition: laddr-yangmills-lm.hpp:177
static YangMills::TElectricFieldType trigonometric_dtE3
Definition: laddr-yangmills-lm.hpp:489
static YangMills::TLAForcingTermType const_f_linear
Definition: laddr-yangmills-lm.hpp:824
double lambda
Norm of Lagrange multiplier.
Definition: laddr-yangmills-lm.hpp:48
double computeResidual(const Eigen::VectorXd &x) const
Calculates residual with current matrix and rhs from given x (m_A*x = m_b)
Definition: laddr-yangmills-lm.cpp:1561
static YangMills::TMagneticFieldType trigonometric_B2_linear
Definition: laddr-yangmills-lm.hpp:421
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> ForcingTermType
Base functions.
Definition: laddr-yangmills-lm.hpp:56
std::function< Eigen::Vector3d(const double &, const Eigen::Vector3d &)> TForcingTermType
Base functions with time component.
Definition: laddr-yangmills-lm.hpp:60
static YangMills::TMagneticFieldType const_B1_nonlinear
Definition: laddr-yangmills-lm.hpp:774
void addBoundaryConditions(const LAMagneticFieldType &curl_A, double dt)
Adds boundary condition for chosen solution to the system vector.
Definition: laddr-yangmills-lm.cpp:531
static YangMills::TMagneticFieldType trigonometric_B1_linear
Definition: laddr-yangmills-lm.hpp:412
const LieAlgebra & lieAlg() const
Returns the Lie algebra.
Definition: laddr-yangmills-lm.hpp:165
static YangMills::TForcingTermType linear_f1_nonlinear
Definition: laddr-yangmills-lm.hpp:695
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> ElectricFieldType
Definition: laddr-yangmills-lm.hpp:57
static YangMills::TMagneticFieldType trigonometric_B3_linear
Definition: laddr-yangmills-lm.hpp:430
static YangMills::TElectricFieldType trigonometric_E1
Definition: laddr-yangmills-lm.hpp:354
static YangMills::TForcingTermType linear_f3_linear
Definition: laddr-yangmills-lm.hpp:687
static YangMills::TLAElectricFieldType linear_E
Definition: laddr-yangmills-lm.hpp:579
static YangMills::TMagneticFieldType const_B2_linear
Definition: laddr-yangmills-lm.hpp:761
static YangMills::TMagneticFieldType linear_B2_linear
Definition: laddr-yangmills-lm.hpp:609
static YangMills::TLAElectricFieldType trigonometric_A
Definition: laddr-yangmills-lm.hpp:409
size_t dimension() const
Returns the global problem dimension.
Definition: laddr-yangmills-lm.hpp:153
static YangMills::TElectricFieldType const_A1
Definition: laddr-yangmills-lm.hpp:738
static YangMills::TForcingTermType const_f2_nonlinear
Definition: laddr-yangmills-lm.hpp:832
static YangMills::TForcingTermType trigonometric_f2_nonlinear
Definition: laddr-yangmills-lm.hpp:540
double A
Norm of potential.
Definition: laddr-yangmills-lm.hpp:47
static YangMills::TForcingTermType linear_f2_linear
Definition: laddr-yangmills-lm.hpp:682
static YangMills::TElectricFieldType trigonometric_A1
Definition: laddr-yangmills-lm.hpp:383
static YangMills::TForcingTermType trigonometric_f3_linear
Definition: laddr-yangmills-lm.hpp:519
static YangMills::TElectricFieldType trigonometric_A2
Definition: laddr-yangmills-lm.hpp:392
YangMillsNorms(double norm_E, double norm_A, double norm_lambda)
Constructor.
Definition: laddr-yangmills-lm.hpp:38
static YangMills::TForcingTermType linear_f1_linear
Definition: laddr-yangmills-lm.hpp:677
Eigen::MatrixXd L2v_Bkt(size_t iT, boost::multi_array< double, 3 > &intPciPcjPgk, const Eigen::VectorXd &v, const size_t &entry) const
Wrapper to plug vector into L2 integral product: int (Pcurl 1,[Pcurl 2, Pgrad 3])
Definition: laddr-yangmills-lm.cpp:1433
static YangMills::TMagneticFieldType linear_B1_nonlinear
Definition: laddr-yangmills-lm.hpp:630
static YangMills::TElectricFieldType linear_dtE2
Definition: laddr-yangmills-lm.hpp:664
static YangMills::TElectricFieldType linear_E1
Definition: laddr-yangmills-lm.hpp:564
std::vector< TForcingTermType > TLAForcingTermType
Lie algebra valued functions with time component.
Definition: laddr-yangmills-lm.hpp:68
static YangMills::TMagneticFieldType const_B2_nonlinear
Definition: laddr-yangmills-lm.hpp:779
SystemMatrixType & systemMatrix()
Returns the linear system matrix.
Definition: laddr-yangmills-lm.hpp:212
const XGrad & xGrad() const
Returns the space XDiv.
Definition: laddr-yangmills-lm.hpp:189
Eigen::VectorXd computeConstraint(const Eigen::VectorXd &E, const Eigen::VectorXd &A, const double nonlinear_coeff)
Computes the constraint [E, grad P'] + int <E, [A, P']> for the DOFs.
Definition: laddr-yangmills-lm.cpp:1615
std::vector< Eigen::VectorXd > vectors
Definition: laddr-yangmills-lm.hpp:856
static YangMills::TElectricFieldType const_dtE1
Definition: laddr-yangmills-lm.hpp:792
double E
Norm of electric field.
Definition: laddr-yangmills-lm.hpp:44
static YangMills::TElectricFieldType linear_dtE1
Definition: laddr-yangmills-lm.hpp:660
static YangMills::TElectricFieldType trigonometric_dtE1
Definition: laddr-yangmills-lm.hpp:472
AssembledSystems(std::vector< Eigen::SparseMatrix< double >> sys, std::vector< Eigen::VectorXd > vec)
Constructor.
Definition: laddr-yangmills-lm.hpp:862
static YangMills::TMagneticFieldType trigonometric_B3_nonlinear
Definition: laddr-yangmills-lm.hpp:460
static YangMills::TMagneticFieldType trigonometric_B1_nonlinear
Definition: laddr-yangmills-lm.hpp:442
static YangMills::TForcingTermType trigonometric_f3_nonlinear
Definition: laddr-yangmills-lm.hpp:549
static YangMills::TLAElectricFieldType trigonometric_E
Definition: laddr-yangmills-lm.hpp:380
static YangMills::TForcingTermType const_f1_nonlinear
Definition: laddr-yangmills-lm.hpp:827
static YangMills::TElectricFieldType linear_A3
Definition: laddr-yangmills-lm.hpp:592
static YangMills::TLAForcingTermType trigonometric_f_linear
Definition: laddr-yangmills-lm.hpp:528
static YangMills::TForcingTermType const_f3_nonlinear
Definition: laddr-yangmills-lm.hpp:837
static YangMills::TElectricFieldType linear_E2
Definition: laddr-yangmills-lm.hpp:569
size_t sizeSystem() const
Returns the size of the system.
Definition: laddr-yangmills-lm.hpp:159
std::vector< YangMillsNorms > computeYangMillsNorms(const std::vector< Eigen::VectorXd > &list_dofs) const
Compute the discrete L2 norms, for a family of Eigen::VectorXd representing the electric field and po...
Definition: laddr-yangmills-lm.cpp:1506
static YangMills::TMagneticFieldType const_B3_nonlinear
Definition: laddr-yangmills-lm.hpp:784
static YangMills::TLAElectricFieldType const_A
Definition: laddr-yangmills-lm.hpp:753
static YangMills::TElectricFieldType linear_A2
Definition: laddr-yangmills-lm.hpp:587
std::vector< TElectricFieldType > TLAElectricFieldType
Definition: laddr-yangmills-lm.hpp:69
static YangMills::TElectricFieldType const_E1
Definition: laddr-yangmills-lm.hpp:720
static YangMills::TElectricFieldType linear_A1
Definition: laddr-yangmills-lm.hpp:582
Eigen::VectorXd & systemVector()
Returns the linear system right-hand side vector.
Definition: laddr-yangmills-lm.hpp:222
static YangMills::TForcingTermType trigonometric_f1_nonlinear
Definition: laddr-yangmills-lm.hpp:531
std::vector< MagneticFieldType > LAMagneticFieldType
Definition: laddr-yangmills-lm.hpp:66
std::function< Eigen::Vector3d(const double &, const Eigen::Vector3d &)> TElectricFieldType
Definition: laddr-yangmills-lm.hpp:61
double stoppingCrit2(const Eigen::VectorXd &Elambda_k, const Eigen::VectorXd &E_i, const Eigen::VectorXd &A_i, const Eigen::VectorXd &sysVec, double dt, double theta, double nonlinear_coeff)
Stops once close enough to system vector for nonlinear problem.
Definition: laddr-yangmills-lm.cpp:609
static YangMills::TForcingTermType trigonometric_f1_linear
Definition: laddr-yangmills-lm.hpp:501
const LAXGrad & laXGrad() const
Returns the space LAXGrad.
Definition: laddr-yangmills-lm.hpp:171
static YangMills::TElectricFieldType trigonometric_dtE2
Definition: laddr-yangmills-lm.hpp:480
std::function< Eigen::Vector3d(const Eigen::Vector3d &)> MagneticFieldType
Definition: laddr-yangmills-lm.hpp:58
static YangMills::TLAMagneticFieldType linear_B_nonlinear
Definition: laddr-yangmills-lm.hpp:657
static YangMills::TMagneticFieldType linear_B1_linear
Definition: laddr-yangmills-lm.hpp:600
static YangMills::TMagneticFieldType linear_B3_linear
Definition: laddr-yangmills-lm.hpp:618
static YangMills::TForcingTermType linear_f2_nonlinear
Definition: laddr-yangmills-lm.hpp:701
static YangMills::TMagneticFieldType const_B1_linear
Definition: laddr-yangmills-lm.hpp:756
std::vector< Eigen::SparseMatrix< double > > systems
Definition: laddr-yangmills-lm.hpp:866
const double & stabilizationParameter() const
Returns the stabilization parameter.
Definition: laddr-yangmills-lm.hpp:227
static YangMills::TLAForcingTermType linear_f_linear
Definition: laddr-yangmills-lm.hpp:692
std::function< outValue(const Eigen::Vector3d &)> contractPara(const TFct &F, double t) const
Takes a two parameter function and a value and returns a function with the first parameter fixed to v...
Definition: laddr-yangmills-lm.hpp:243
static YangMills::TElectricFieldType trigonometric_E2
Definition: laddr-yangmills-lm.hpp:362
std::vector< Eigen::VectorXd > vectors
Definition: laddr-yangmills-lm.hpp:869
static YangMills::TLAMagneticFieldType trigonometric_B_linear
Definition: laddr-yangmills-lm.hpp:439
double computeConstraintNorm(const Eigen::VectorXd &Ch, const size_t itersolver) const
Solves a system to calculate the norm of the constraint (in the dual space of LaXgrad)
Definition: laddr-yangmills-lm.cpp:1578
static YangMills::TLAElectricFieldType trigonometric_dtE
Definition: laddr-yangmills-lm.hpp:498
double & stabilizationParameter()
Returns the stabilization parameter.
Definition: laddr-yangmills-lm.hpp:232
static YangMills::TMagneticFieldType const_B3_linear
Definition: laddr-yangmills-lm.hpp:766
double stoppingCrit(const Eigen::VectorXd &v, const Eigen::VectorXd &u)
Stops once changes become small.
Definition: laddr-yangmills-lm.cpp:597
void assembleLinearSystem(double dt)
Assemble the global system
Definition: laddr-yangmills-lm.cpp:491
const XCurl & xCurl() const
Returns the space XDiv.
Definition: laddr-yangmills-lm.hpp:195
std::function< Eigen::Vector3d(const double &, const Eigen::Vector3d &)> TMagneticFieldType
Definition: laddr-yangmills-lm.hpp:62
static YangMills::TElectricFieldType const_dtE2
Definition: laddr-yangmills-lm.hpp:796
static YangMills::TLAMagneticFieldType trigonometric_B_nonlinear
Definition: laddr-yangmills-lm.hpp:469
Eigen::VectorXd computeInitialConditions(const Eigen::MatrixXd &Eh, const Eigen::MatrixXd &Ah, const double nonlinear_coeff, const size_t solver)
Computes the projected initial conditions that satisfy the constraint.
Definition: laddr-yangmills-lm.cpp:1658
static YangMills::TElectricFieldType const_A2
Definition: laddr-yangmills-lm.hpp:743
static YangMills::TElectricFieldType const_E3
Definition: laddr-yangmills-lm.hpp:730
std::vector< ElectricFieldType > LAElectricFieldType
Definition: laddr-yangmills-lm.hpp:65
static YangMills::TLAMagneticFieldType linear_B_linear
Definition: laddr-yangmills-lm.hpp:627
static YangMills::TLAElectricFieldType linear_dtE
Definition: laddr-yangmills-lm.hpp:674
static YangMills::TMagneticFieldType trigonometric_B2_nonlinear
Definition: laddr-yangmills-lm.hpp:451
Eigen::SparseMatrix< double > SystemMatrixType
Definition: laddr-yangmills-lm.hpp:54
std::pair< double, double > computeConditionNum() const
Definition: laddr-yangmills-lm.cpp:572
static YangMills::TLAElectricFieldType const_dtE
Definition: laddr-yangmills-lm.hpp:806
const XDiv & xDiv() const
Returns the space XDiv.
Definition: laddr-yangmills-lm.hpp:201
const SystemMatrixType & systemMatrix() const
Returns the linear system matrix.
Definition: laddr-yangmills-lm.hpp:207
static YangMills::TForcingTermType const_f1_linear
Definition: laddr-yangmills-lm.hpp:809
static YangMills::TLAElectricFieldType linear_A
Definition: laddr-yangmills-lm.hpp:597
static YangMills::TForcingTermType const_f2_linear
Definition: laddr-yangmills-lm.hpp:814
YangMills(const DDRCore &ddrcore, const LieAlgebra &liealgebra, bool use_threads, std::ostream &output=std::cout)
Constructor.
Definition: laddr-yangmills-lm.cpp:443
static YangMills::TElectricFieldType const_dtE3
Definition: laddr-yangmills-lm.hpp:801
static YangMills::TElectricFieldType linear_E3
Definition: laddr-yangmills-lm.hpp:574
static YangMills::TLAElectricFieldType const_E
Definition: laddr-yangmills-lm.hpp:735
static YangMills::TElectricFieldType trigonometric_E3
Definition: laddr-yangmills-lm.hpp:371
Eigen::MatrixXd epsBkt_v(size_t iT, boost::multi_array< double, 3 > &ebkt_T, const Eigen::VectorXd &v) const
Calculates the matrix of *[v,.]^div in element index iT.
Definition: laddr-yangmills-lm.cpp:1323
static YangMills::TLAMagneticFieldType const_B_linear
Definition: laddr-yangmills-lm.hpp:771
const LAXDiv & laXDiv() const
Returns the space LAXCurl.
Definition: laddr-yangmills-lm.hpp:183
static YangMills::TForcingTermType linear_f3_nonlinear
Definition: laddr-yangmills-lm.hpp:707
Eigen::MatrixXd L2v_epsBkt(size_t iT, boost::multi_array< double, 3 > &ebkt_T, const Eigen::VectorXd &v_T, const Eigen::MatrixXd &L2prod) const
Calculates the bracket inside the L2prod with v.
Definition: laddr-yangmills-lm.cpp:1466
const Eigen::VectorXd & systemVector() const
Returns the linear system right-hand side vector.
Definition: laddr-yangmills-lm.hpp:217
static YangMills::TElectricFieldType const_E2
Definition: laddr-yangmills-lm.hpp:725
static YangMills::TForcingTermType const_f3_linear
Definition: laddr-yangmills-lm.hpp:819
static YangMills::TElectricFieldType const_A3
Definition: laddr-yangmills-lm.hpp:748
static YangMills::TForcingTermType trigonometric_f2_linear
Definition: laddr-yangmills-lm.hpp:510
static YangMills::TLAMagneticFieldType const_B_nonlinear
Definition: laddr-yangmills-lm.hpp:789
std::vector< ForcingTermType > LAForcingTermType
Lie algebra valued functions (vector of dim Lie algebra)
Definition: laddr-yangmills-lm.hpp:64
void assembleSystemNewton(const Eigen::VectorXd &E_i, const Eigen::VectorXd &A_i, const Eigen::VectorXd &Elambdac_k, const Eigen::VectorXd &sysVec, double dt, double theta, double nonlinear_coeff)
Assembles the system for Newton iterations.
Definition: laddr-yangmills-lm.cpp:879
void setSystemVector(const Eigen::VectorXd &interp_f, const Eigen::VectorXd &interp_dE, const Eigen::VectorXd &interp_A, const Eigen::VectorXd &E_old, const Eigen::VectorXd &A_old, double dt, double theta, double nonlinear_coeff)
Sets system vector for the nonlinear problem.
Definition: laddr-yangmills-lm.cpp:760
std::vector< TMagneticFieldType > TLAMagneticFieldType
Definition: laddr-yangmills-lm.hpp:70
static YangMills::TMagneticFieldType linear_B3_nonlinear
Definition: laddr-yangmills-lm.hpp:648
std::vector< Fct > contractParaLA(const std::vector< TFct > &TF, double t) const
Takes a vector of two parameter functions and a value and returns a function with the first parameter...
Definition: laddr-yangmills-lm.hpp:250
static YangMills::TLAForcingTermType linear_f_nonlinear
Definition: laddr-yangmills-lm.hpp:713
static YangMills::TLAForcingTermType trigonometric_f_nonlinear
Definition: laddr-yangmills-lm.hpp:557
std::vector< Eigen::MatrixXd > systems
Definition: laddr-yangmills-lm.hpp:853
static YangMills::TLAForcingTermType const_f_nonlinear
Definition: laddr-yangmills-lm.hpp:842
static YangMills::TElectricFieldType trigonometric_A3
Definition: laddr-yangmills-lm.hpp:401
std::vector< Fct > sumLA(const std::vector< Fct > &LAF, const std::vector< Fct > &LAG, double lambda)
Template to evaluate a vector of functions.
Definition: laddr-yangmills-lm.hpp:330
static YangMills::TElectricFieldType linear_dtE3
Definition: laddr-yangmills-lm.hpp:669
bool use_threads
Definition: HHO_DiffAdvecReac.hpp:47
Definition: ddr-magnetostatics.hpp:40
Struct to store the systems that need assembling.
Definition: laddr-yangmills-lm.hpp:847
Struct to store the assembled systems.
Definition: laddr-yangmills-lm.hpp:860
Structure to store norm components.
Definition: laddr-yangmills-lm.hpp:36
Assemble a YangMills problem.
Definition: laddr-yangmills-lm.hpp:53