MFEM  v4.6.0
Finite element discretization library
tmop.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2023, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef MFEM_TMOP_HPP
13 #define MFEM_TMOP_HPP
14 
15 #include "../linalg/invariants.hpp"
16 #include "nonlininteg.hpp"
17 
18 namespace mfem
19 {
20 
21 /** @brief Abstract class for local mesh quality metrics in the target-matrix
22  optimization paradigm (TMOP) by P. Knupp et al. */
24 {
25 protected:
26  const DenseMatrix *Jtr; /**< Jacobian of the reference-element to
27  target-element transformation. */
28 
29  /** @brief The method HyperelasticModel::SetTransformation() is hidden
30  for TMOP_QualityMetric%s, because it is not used. */
32 
33 public:
34  TMOP_QualityMetric() : Jtr(NULL) { }
35  virtual ~TMOP_QualityMetric() { }
36 
37  /** @brief Specify the reference-element -> target-element Jacobian matrix
38  for the point of interest.
39 
40  The specified Jacobian matrix, #Jtr, can be used by metrics that cannot
41  be written just as a function of the target->physical Jacobian matrix,
42  Jpt. */
43  virtual void SetTargetJacobian(const DenseMatrix &Jtr_) { Jtr = &Jtr_; }
44 
45  /** @brief Evaluates the metric in matrix form (opposed to invariant form).
46  Used for validating the invariant evaluations. */
47  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
48  { return -1.0; /* not implemented -> checks would fail. */ }
49 
50  /** @brief Evaluate the strain energy density function, W = W(Jpt), by using
51  the 2D or 3D matrix invariants, see linalg/invariants.hpp.
52  @param[in] Jpt Represents the target->physical transformation
53  Jacobian matrix. */
54  virtual double EvalW(const DenseMatrix &Jpt) const = 0;
55 
56  /** @brief Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
57  @param[in] Jpt Represents the target->physical transformation
58  Jacobian matrix.
59  @param[out] P The evaluated 1st Piola-Kirchhoff stress tensor. */
60  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const = 0;
61 
62  /** @brief Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor
63  and assemble its contribution to the local gradient matrix 'A'.
64  @param[in] Jpt Represents the target->physical transformation
65  Jacobian matrix.
66  @param[in] DS Gradient of the basis matrix (dof x dim).
67  @param[in] weight Quadrature weight coefficient for the point.
68  @param[in,out] A Local gradient matrix where the contribution from this
69  point will be added.
70 
71  Computes weight * d(dW_dxi)_d(xj) at the current point, for all i and j,
72  where x1 ... xn are the FE dofs. This function is usually defined using
73  the matrix invariants and their derivatives. */
74  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
75  const double weight, DenseMatrix &A) const = 0;
76 
77  /** @brief Return the metric ID. */
78  virtual int Id() const { return 0; }
79 };
80 
81 class TargetConstructor;
82 
83 /// Abstract class used to define explicit combination of metrics with constant
84 /// coefficients.
86 {
87 protected:
88  Array<TMOP_QualityMetric *> tmop_q_arr; //the metrics are not owned
90 
91 public:
92  virtual void AddQualityMetric(TMOP_QualityMetric *tq, double wt = 1.0)
93  {
94  tmop_q_arr.Append(tq);
95  wt_arr.Append(wt);
96  }
97 
98  virtual void SetTargetJacobian(const DenseMatrix &Jtr_)
99  {
100  for (int i = 0; i < tmop_q_arr.Size(); i++)
101  {
102  tmop_q_arr[i]->SetTargetJacobian(Jtr_);
103  }
104  }
105 
106  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
107 
108  virtual double EvalW(const DenseMatrix &Jpt) const;
109 
110  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
111 
112  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
113  const double weight, DenseMatrix &A) const;
114 
115  /// Computes the averages of all metrics (integral of metric / volume).
116  /// Works in parallel when called with a ParGridFunction.
117  void ComputeAvgMetrics(const GridFunction &nodes,
118  const TargetConstructor &tc,
119  Vector &averages) const;
120 
121  /// Computes weights so that the averages of all metrics are equal, and the
122  /// weights sum to one. Works in parallel when called with a ParGridFunction.
123  void ComputeBalancedWeights(const GridFunction &nodes,
124  const TargetConstructor &tc,
125  Vector &weights) const;
126 
127  void GetWeights(Array<double> &weights) const { weights = wt_arr; }
128 
129  /// Changes the weights of the metrics in the combination.
130  void SetWeights(const Vector &weights)
131  {
132  MFEM_VERIFY(tmop_q_arr.Size() == weights.Size(), "Incorrect #weights");
133  for (int i = 0; i < tmop_q_arr.Size(); i++) { wt_arr[i] = weights(i); }
134  }
135 };
136 
137 /// Simultaneous Untangler + Worst Case Improvement Metric
138 /// Uses a base metric mu and is defined as:
139 /// mu_tilde = mu_hat, when WorstCaseType = None,
140 /// = mu_hat/(beta - mu_hat), when WorstCaseType = Beta,
141 /// = mu_hat^p, when WorstCaseType = PMean,
142 /// where beta = max(mu_hat) + muT_ep,
143 /// and mu_hat = (mu/2phi(tau,ep)) where
144 /// 2phi(tau,ep) = 1, when when BarrierType = None,
145 /// = 2*(tau - min(alpha*min(tau)-detT_ep,0)), when BarrierType = Shifted
146 /// = tau^2 + sqrt(tau^2 + ep^2), when BarrierType = Pseudo
147 /// where tau = det(T), and max(mu_hat) and min(tau) are computed over the
148 /// entire mesh.
149 /// Ultimately, this metric can be used for mesh untangling with the BarrierType
150 /// option and for worst case quality improvement with the WorstCaseType option.
152 {
153 public:
154  enum class BarrierType
155  {
156  None,
157  Shifted,
158  Pseudo
159  };
160  enum class WorstCaseType
161  {
162  None,
163  Beta,
164  PMean
165  };
166 
167 protected:
168  TMOP_QualityMetric &tmop_metric; // non-barrier metric to use
169  double min_detT; // minimum Jacobian in the mesh
170  double max_muT; // max mu_k/phi(tau,ep) in the mesh
171  int exponent; // used for p-mean metrics
172  double alpha; // scaling factor for min(det(T))
173  double detT_ep; // small constant subtracted from min(detT)
174  double muT_ep; // small constant added to muT term
177 
178 public:
180  int exponent_ = 1,
181  double alpha_ = 1.5,
182  double detT_ep_ = 0.0001,
183  double muT_ep_ = 0.0001,
186  tmop_metric(tmop_metric_), exponent(exponent_), alpha(alpha_),
187  detT_ep(detT_ep_), muT_ep(muT_ep_), btype(btype_), wctype(wctype_)
188  {
189  MFEM_VERIFY(wctype == WorstCaseType::None,
190  "Worst-case optimization has not been fully developed!");
191  if (btype != BarrierType::None)
192  {
193  const int m_id = tmop_metric.Id();
194  MFEM_VERIFY(m_id == 4 || m_id == 14 || m_id == 66,
195  "Incorrect input barrier metric -- must be 4 / 14 / 66");
196  }
197  }
198 
199  virtual double EvalW(const DenseMatrix &Jpt) const;
200 
201  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
202  { MFEM_ABORT("Not implemented"); }
203 
204  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
205  const double weight, DenseMatrix &A) const
206  { MFEM_ABORT("Not implemented"); }
207 
208  // Compute mu_hat.
209  virtual double EvalWBarrier(const DenseMatrix &Jpt) const;
210 
211  virtual void SetMinDetT(double min_detT_) { min_detT = min_detT_; }
212 
213  virtual void SetMaxMuT(double max_muT_) { max_muT = max_muT_; }
214 
215  virtual BarrierType GetBarrierType() { return btype; }
216 
217  virtual WorstCaseType GetWorstCaseType() { return wctype; }
218 };
219 
220 /// 2D non-barrier metric without a type.
222 {
223 protected:
225 
226 public:
227  // W = |J|^2.
228  virtual double EvalW(const DenseMatrix &Jpt) const;
229 
230  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
231 
232  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
233  const double weight, DenseMatrix &A) const;
234 
235  virtual int Id() const { return 1; }
236 };
237 
238 /// 2D non-barrier Skew metric.
240 {
241 public:
242  // W = 0.5 (1 - cos(angle_Jpr - angle_Jtr)).
243  virtual double EvalW(const DenseMatrix &Jpt) const;
244 
245  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
246  { MFEM_ABORT("Not implemented"); }
247 
248  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
249  const double weight, DenseMatrix &A) const
250  { MFEM_ABORT("Not implemented"); }
251 };
252 
253 /// 3D non-barrier Skew metric.
255 {
256 public:
257  // W = 1/6 (3 - sum_i cos(angle_Jpr_i - angle_Jtr_i)), i = 1..3.
258  virtual double EvalW(const DenseMatrix &Jpt) const;
259 
260  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
261  { MFEM_ABORT("Not implemented"); }
262 
263  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
264  const double weight, DenseMatrix &A) const
265  { MFEM_ABORT("Not implemented"); }
266 };
267 
268 /// 2D non-barrier Aspect ratio metric.
270 {
271 public:
272  // W = 0.5 (ar_Jpr/ar_Jtr + ar_Jtr/ar_Jpr) - 1.
273  virtual double EvalW(const DenseMatrix &Jpt) const;
274 
275  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
276  { MFEM_ABORT("Not implemented"); }
277 
278  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
279  const double weight, DenseMatrix &A) const
280  { MFEM_ABORT("Not implemented"); }
281 };
282 
283 /// 3D non-barrier Aspect ratio metric.
285 {
286 public:
287  // W = 1/3 sum [0.5 (ar_Jpr_i/ar_Jtr_i + ar_Jtr_i/ar_Jpr_i) - 1], i = 1..3.
288  virtual double EvalW(const DenseMatrix &Jpt) const;
289 
290  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
291  { MFEM_ABORT("Not implemented"); }
292 
293  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
294  const double weight, DenseMatrix &A) const
295  { MFEM_ABORT("Not implemented"); }
296 };
297 
298 /// 2D barrier shape (S) metric (polyconvex).
299 /// Grade - A.
301 {
302 protected:
304 
305 public:
306  // W = 0.5 |J|^2 / det(J) - 1.
307  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
308 
309  // W = 0.5 I1b - 1.
310  virtual double EvalW(const DenseMatrix &Jpt) const;
311 
312  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
313 
314  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
315  const double weight, DenseMatrix &A) const;
316 
317  virtual int Id() const { return 2; }
318 };
319 
320 /// 2D non-barrier shape (S) metric.
321 /// Grade - F.
323 {
324 protected:
326 
327 public:
328  // W = |J|^2 - 2*det(J)
329  virtual double EvalW(const DenseMatrix &Jpt) const;
330 
331  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
332 
333  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
334  const double weight, DenseMatrix &A) const;
335 
336  virtual int Id() const { return 4; }
337 };
338 
339 /// 2D barrier Shape+Size (VS) metric (not polyconvex).
341 {
342 protected:
344 
345 public:
346  // W = |J - J^-t|^2.
347  virtual double EvalW(const DenseMatrix &Jpt) const;
348 
349  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
350 
351  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
352  const double weight, DenseMatrix &A) const;
353 
354  virtual int Id() const { return 7; }
355 };
356 
357 /// 2D barrier Shape+Size (VS) metric (not polyconvex).
359 {
360 protected:
362 
363 public:
364  // W = det(J) * |J - J^-t|^2.
365  virtual double EvalW(const DenseMatrix &Jpt) const;
366 
367  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
368 
369  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
370  const double weight, DenseMatrix &A) const;
371 };
372 
373 /// 2D non-barrier Shape+Size+Orientation (VOS) metric (polyconvex).
375 {
376 public:
377  // W = |T-I|^2.
378  virtual double EvalW(const DenseMatrix &Jpt) const;
379 
380  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
381  { MFEM_ABORT("Not implemented"); }
382 
383  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
384  const double weight, DenseMatrix &A) const
385  { MFEM_ABORT("Not implemented"); }
386 };
387 
388 /// 2D Shifted barrier form of shape metric (mu_2).
390 {
391 protected:
392  double &min_detT;
394 
395 public:
396  TMOP_Metric_022(double &t0): min_detT(t0) {}
397 
398  // W = 0.5(|J|^2 - 2det(J)) / (det(J) - tau0).
399  virtual double EvalW(const DenseMatrix &Jpt) const;
400 
401  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
402 
403  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
404  const double weight, DenseMatrix &A) const;
405 };
406 
407 /// 2D barrier shape metric (polyconvex).
408 /// Grade - A.
410 {
411 protected:
413 
414 public:
415  // W = 0.5 |J^t J|^2 / det(J)^2 - 1.
416  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
417 
418  // W = 0.5 I1b^2 - 2.
419  virtual double EvalW(const DenseMatrix &Jpt) const;
420 
421  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
422 
423  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
424  const double weight, DenseMatrix &A) const;
425 };
426 
427 /// 2D non-barrier size (V) metric (not polyconvex).
428 /// Grade - F.
430 {
431 protected:
433 
434 public:
435  // W = (det(J) - 1)^2.
436  virtual double EvalW(const DenseMatrix &Jpt) const;
437 
438  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
439 
440  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
441  const double weight, DenseMatrix &A) const;
442 
443 };
444 
445 /// 2D barrier size (V) metric (polyconvex).
446 /// Grade - C.
448 {
449 protected:
451 
452 public:
453  // W = 0.5 (det(J) + 1 / det(J)) - 1.
454  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
455 
456  // W = 0.5 (I2b + 1/I2b) - 1.
457  virtual double EvalW(const DenseMatrix &Jpt) const;
458 
459  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
460 
461  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
462  const double weight, DenseMatrix &A) const;
463 };
464 
465 /// 2D barrier shape (S) metric (not polyconvex).
467 {
468 protected:
470 
471 public:
472  // W = |J^t J|^2 / det(J)^2 - 2|J|^2 / det(J) + 2
473  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
474 
475  // W = I1b (I1b - 2).
476  virtual double EvalW(const DenseMatrix &Jpt) const;
477 
478  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
479 
480  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
481  const double weight, DenseMatrix &A) const;
482 };
483 
484 /// 2D non-barrier Shape+Size (VS) metric.
485 /// Grade - F.
487 {
488 protected:
491 
492 public:
493  TMOP_Metric_066(double gamma)
495  {
496  // (1-gamma) mu_4 + gamma mu_55
497  AddQualityMetric(sh_metric, 1.-gamma);
498  AddQualityMetric(sz_metric, gamma);
499  }
500  virtual int Id() const { return 66; }
501  double GetGamma() const { return wt_arr[1]; }
502 
503  virtual ~TMOP_Metric_066() { delete sh_metric; delete sz_metric; }
504 };
505 
506 /// 2D barrier size (V) metric (polyconvex).
507 /// Grade - C.
509 {
510 protected:
512 
513 public:
514  // W = 0.5 (det(J) - 1 / det(J))^2.
515  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
516 
517  // W = 0.5 (I2 + 1 / I2) - 1.0.
518  virtual double EvalW(const DenseMatrix &Jpt) const;
519 
520  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
521 
522  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
523  const double weight, DenseMatrix &A) const;
524 
525  virtual int Id() const { return 77; }
526 };
527 
528 /// 2D barrier Shape+Size (VS) metric (polyconvex).
529 /// Grade - A.
531 {
532 protected:
535 
536 public:
537  TMOP_Metric_080(double gamma)
539  {
540  // (1-gamma) mu_2 + gamma mu_77
541  AddQualityMetric(sh_metric, 1.0 - gamma);
542  AddQualityMetric(sz_metric, gamma);
543  }
544 
545  virtual int Id() const { return 80; }
546  double GetGamma() const { return wt_arr[1]; }
547 
548  virtual ~TMOP_Metric_080() { delete sh_metric; delete sz_metric; }
549 };
550 
551 /// 2D barrier Shape+Orientation (OS) metric (polyconvex).
553 {
554 public:
555  // W = |T-T'|^2, where T'= |T|*I/sqrt(2).
556  virtual double EvalW(const DenseMatrix &Jpt) const;
557 
558  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
559  { MFEM_ABORT("Not implemented"); }
560 
561  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
562  const double weight, DenseMatrix &A) const
563  { MFEM_ABORT("Not implemented"); }
564 };
565 
566 /// 2D compound barrier Shape+Size (VS) metric (balanced).
568 {
569 protected:
572 
573 public:
576  {
577  // mu_50 + lambda mu_77.
578  // 1 <= lambda <= 4 should produce best asymptotic balance.
581  }
582 
583  virtual int Id() const { return 90; }
584  virtual ~TMOP_Metric_090() { delete sh_metric; delete sz_metric; }
585 };
586 
587 /// 2D compound barrier Shape+Size (VS) metric (balanced).
589 {
590 protected:
593 
594 public:
597  {
598  // mu_2 + lambda mu_56.
599  // 1 <= lambda <= 2 should produce best asymptotic balance.
602  }
603 
604  virtual int Id() const { return 94; }
605  virtual ~TMOP_Metric_094() { delete sh_metric; delete sz_metric; }
606 };
607 
608 /// 2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
610 {
611 public:
612  // W = 1/tau |T-I|^2.
613  virtual double EvalW(const DenseMatrix &Jpt) const;
614 
615  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
616  { MFEM_ABORT("Not implemented"); }
617 
618  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
619  const double weight, DenseMatrix &A) const
620  { MFEM_ABORT("Not implemented"); }
621 };
622 
623 /// 2D untangling metric.
625 {
626 protected:
627  const double eps;
629 
630 public:
631  TMOP_Metric_211(double epsilon = 1e-4) : eps(epsilon) { }
632 
633  // W = (det(J) - 1)^2 - det(J) + sqrt(det(J)^2 + eps).
634  virtual double EvalW(const DenseMatrix &Jpt) const;
635 
636  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
637 
638  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
639  const double weight, DenseMatrix &A) const;
640 };
641 
642 /// Shifted barrier form of metric 56 (area, ideal barrier metric), 2D
644 {
645 protected:
646  double &tau0;
648 
649 public:
650  /// Note that @a t0 is stored by reference
651  TMOP_Metric_252(double &t0): tau0(t0) {}
652 
653  // W = 0.5(det(J) - 1)^2 / (det(J) - tau0).
654  virtual double EvalW(const DenseMatrix &Jpt) const;
655 
656  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
657 
658  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
659  const double weight, DenseMatrix &A) const;
660 };
661 
662 /// 3D barrier Shape (S) metric, well-posed (polyconvex & invex).
664 {
665 protected:
667 
668 public:
669  // W = 1/3 |J| |J^-1| - 1.
670  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
671 
672  // W = 1/3 sqrt(I1b * I2b) - 1
673  virtual double EvalW(const DenseMatrix &Jpt) const;
674 
675  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
676 
677  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
678  const double weight, DenseMatrix &A) const;
679 };
680 
681 /// 3D barrier Shape (S) metric, well-posed (polyconvex & invex).
683 {
684 protected:
686 
687 public:
688  // W = |J|^2 |J^{-1}|^2 / 9 - 1.
689  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
690 
691  // W = I1b * I2b / 9 - 1.
692  virtual double EvalW(const DenseMatrix &Jpt) const;
693 
694  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
695 
696  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
697  const double weight, DenseMatrix &A) const;
698 
699  virtual int Id() const { return 302; }
700 };
701 
702 /// 3D barrier Shape (S) metric, well-posed (polyconvex & invex).
704 {
705 protected:
707 
708 public:
709  // W = |J|^2 / 3 / det(J)^(2/3) - 1.
710  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
711 
712  // W = I1b / 3 - 1.
713  virtual double EvalW(const DenseMatrix &Jpt) const;
714 
715  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
716 
717  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
718  const double weight, DenseMatrix &A) const;
719 
720  virtual int Id() const { return 303; }
721 };
722 
723 /// 3D barrier Shape (S) metric, well-posed (polyconvex & invex).
725 {
726 protected:
728 
729 public:
730  // W = |J|^3 / 3^(3/2) / det(J) - 1.
731  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
732 
733  // W = (I1b/3)^3/2 - 1.
734  virtual double EvalW(const DenseMatrix &Jpt) const;
735 
736  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
737 
738  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
739  const double weight, DenseMatrix &A) const;
740 
741  virtual int Id() const { return 304; }
742 };
743 
744 /// 3D Size (V) untangling metric.
746 {
747 protected:
748  const double eps;
750 
751 public:
752  TMOP_Metric_311(double epsilon = 1e-4) : eps(epsilon) { }
753 
754  // W = (det(J) - 1)^2 - det(J) + (det(J)^2 + eps)^(1/2).
755  virtual double EvalW(const DenseMatrix &Jpt) const;
756 
757  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
758 
759  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
760  const double weight, DenseMatrix &A) const;
761 };
762 
763 /// 3D Shape (S) metric, untangling version of 303.
765 {
766 protected:
767  double &min_detT;
769 
770 public:
771  TMOP_Metric_313(double &mindet) : min_detT(mindet) { }
772 
773  // W = 1/3 |J|^2 / [det(J)-tau0]^(-2/3).
774  virtual double EvalW(const DenseMatrix &Jpt) const;
775 
776  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
777 
778  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
779  const double weight, DenseMatrix &A) const;
780 
781  virtual int Id() const { return 313; }
782 };
783 
784 /// 3D Size (V) metric.
786 {
787 protected:
789 
790 public:
791  // W = (det(J) - 1)^2.
792  virtual double EvalW(const DenseMatrix &Jpt) const;
793 
794  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
795 
796  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
797  const double weight, DenseMatrix &A) const;
798 
799  virtual int Id() const { return 315; }
800 };
801 
802 /// 3D Size (V) metric.
804 {
805 protected:
807 
808 public:
809  // W = 0.5 (det(J) + 1/det(J)) - 1.
810  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
811 
812  // W = 0.5 (I3b + 1/I3b) - 1.
813  virtual double EvalW(const DenseMatrix &Jpt) const;
814 
815  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
816 
817  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
818  const double weight, DenseMatrix &A) const;
819 };
820 
821 /// 3D Size (V) metric.
823 {
824 protected:
826 
827 public:
828  // W = 0.5 (det(J)^2 + 1/det(J)^2) - 1.
829  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
830 
831  // W = 0.5 (I3 + 1/I3) - 1.
832  virtual double EvalW(const DenseMatrix &Jpt) const;
833 
834  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
835 
836  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
837  const double weight, DenseMatrix &A) const;
838 
839  virtual int Id() const { return 318; }
840 };
841 
842 /// 3D barrier Shape+Size (VS) metric, well-posed (invex).
844 {
845 protected:
847 
848 public:
849  // W = |J - J^-t|^2.
850  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
851 
852  // W = I1 + I2/I3 - 6.
853  virtual double EvalW(const DenseMatrix &Jpt) const;
854 
855  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
856 
857  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
858  const double weight, DenseMatrix &A) const;
859 
860  virtual int Id() const { return 321; }
861 };
862 
863 /// 3D barrier Shape+Size (VS) metric, well-posed (invex).
865 {
866 protected:
868 
869 public:
870  // W = |J - adjJ^-t|^2.
871  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
872 
873  // W = I1b / (I3b^-1/3) / 6 + I2b (I3b^1/3) / 6 - 1
874  virtual double EvalW(const DenseMatrix &Jpt) const;
875 
876  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
877 
878  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
879  const double weight, DenseMatrix &A) const;
880 
881  virtual int Id() const { return 322; }
882 };
883 
884 /// 3D barrier Shape+Size (VS) metric, well-posed (invex).
886 {
887 protected:
889 
890 public:
891  // W = |J|^3 - 3 sqrt(3) ln(det(J)) - 3 sqrt(3).
892  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
893 
894  // W = I1^3/2 - 3 sqrt(3) ln(I3b) - 3 sqrt(3).
895  virtual double EvalW(const DenseMatrix &Jpt) const;
896 
897  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
898 
899  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
900  const double weight, DenseMatrix &A) const;
901 
902  virtual int Id() const { return 323; }
903 };
904 
905 /// 3D compound barrier Shape+Size (VS) metric (polyconvex, balanced).
907 {
908 protected:
911 
912 public:
915  {
916  // lambda mu_301 + mu_316.
917  // 3/8 <= lambda <= 9/8 should produce best asymptotic balance.
920  }
921 
922  virtual int Id() const { return 328; }
923  virtual ~TMOP_Metric_328() { delete sh_metric; delete sz_metric; }
924 };
925 
926 /// 3D compound barrier Shape+Size (VS) metric (polyconvex).
928 {
929 protected:
931 
932 public:
933  TMOP_Metric_332(double gamma)
935  {
936  // (1-gamma) mu_302 + gamma mu_315
937  AddQualityMetric(sh_metric, 1.-gamma);
938  AddQualityMetric(sz_metric, gamma);
939  }
940 
941  virtual int Id() const { return 332; }
942  double GetGamma() const { return wt_arr[1]; }
943 
944  virtual ~TMOP_Metric_332() { delete sh_metric; delete sz_metric; }
945 };
946 
947 /// 3D barrier Shape+Size (VS) metric, well-posed (polyconvex).
949 {
950 protected:
953 
954 public:
955  TMOP_Metric_333(double gamma)
957  {
958  // (1-gamma) mu_302 + gamma mu_316
959  AddQualityMetric(sh_metric, 1.-gamma);
960  AddQualityMetric(sz_metric, gamma);
961  }
962 
963  virtual ~TMOP_Metric_333() { delete sh_metric; delete sz_metric; }
964 };
965 
966 /// 3D barrier Shape+Size (VS) metric, well-posed (polyconvex).
968 {
969 protected:
972 
973 public:
974  TMOP_Metric_334(double gamma)
976  {
977  // (1-gamma) mu_303 + gamma mu_316
978  AddQualityMetric(sh_metric, 1.-gamma);
979  AddQualityMetric(sz_metric, gamma);
980  }
981 
982  virtual int Id() const { return 334; }
983  double GetGamma() const { return wt_arr[1]; }
984 
985  virtual ~TMOP_Metric_334() { delete sh_metric; delete sz_metric; }
986 };
987 
988 /// 3D compound barrier Shape+Size (VS) metric (polyconvex, balanced).
990 {
991 protected:
994 
995 public:
998  {
999  // mu_302 + lambda mu_318.
1000  // 4/9 <= lambda <= 3 should produce best asymptotic balance.
1002  AddQualityMetric(sz_metric, 0.5 * (4.0/9.0 + 3.0));
1003  }
1004 
1005  virtual int Id() const { return 338; }
1006  virtual ~TMOP_Metric_338() { delete sh_metric; delete sz_metric; }
1007 };
1008 
1009 /// 3D barrier Shape+Size (VS) metric, well-posed (polyconvex).
1011 {
1012 protected:
1015 
1016 public:
1017  TMOP_Metric_347(double gamma)
1019  {
1020  // (1-gamma) mu_304 + gamma mu_316
1021  AddQualityMetric(sh_metric, 1.-gamma);
1022  AddQualityMetric(sz_metric, gamma);
1023  }
1024 
1025  virtual int Id() const { return 347; }
1026  double GetGamma() const { return wt_arr[1]; }
1027 
1028  virtual ~TMOP_Metric_347() { delete sh_metric; delete sz_metric; }
1029 };
1030 
1031 /// 3D shifted barrier form of metric 316 (not typed).
1033 {
1034 protected:
1035  double &tau0;
1037 
1038 public:
1039  TMOP_Metric_352(double &t0): tau0(t0) {}
1040 
1041  // W = 0.5(det(J) - 1)^2 / (det(J) - tau0).
1042  virtual double EvalW(const DenseMatrix &Jpt) const;
1043 
1044  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
1045 
1046  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
1047  const double weight, DenseMatrix &A) const;
1048 };
1049 
1050 /// 3D non-barrier Shape (S) metric.
1052 {
1053 protected:
1055 
1056 public:
1057  // W = |J|^3 / 3^(3/2) - det(J).
1058  virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const;
1059 
1060  // W = (I1b/3)^3/2 - 1.
1061  virtual double EvalW(const DenseMatrix &Jpt) const;
1062 
1063  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
1064 
1065  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
1066  const double weight, DenseMatrix &A) const;
1067 
1068  virtual int Id() const { return 360; }
1069 };
1070 
1071 /// A-metrics
1072 /// 2D barrier Shape (S) metric (polyconvex).
1074 {
1075 protected:
1077 
1078 public:
1079  // (1/4 alpha) | A - (adj A)^t W^t W / omega |^2
1080  virtual double EvalW(const DenseMatrix &Jpt) const;
1081 
1082  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
1083  { MFEM_ABORT("Not implemented"); }
1084 
1085  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
1086  const double weight, DenseMatrix &A) const
1087  { MFEM_ABORT("Not implemented"); }
1088 };
1089 
1090 /// 2D barrier Size (V) metric (polyconvex).
1092 {
1093 protected:
1095 
1096 public:
1097  // 0.5 * ( sqrt(alpha/omega) - sqrt(omega/alpha) )^2
1098  virtual double EvalW(const DenseMatrix &Jpt) const;
1099 
1100  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
1101  { MFEM_ABORT("Not implemented"); }
1102 
1103  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
1104  const double weight, DenseMatrix &A) const
1105  { MFEM_ABORT("Not implemented"); }
1106 };
1107 
1108 /// 2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
1110 {
1111 protected:
1113 
1114 public:
1115  // (1/alpha) | A - W |^2
1116  virtual double EvalW(const DenseMatrix &Jpt) const;
1117 
1118  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
1119  { MFEM_ABORT("Not implemented"); }
1120 
1121  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
1122  const double weight, DenseMatrix &A) const
1123  { MFEM_ABORT("Not implemented"); }
1124 };
1125 
1126 /// 2D barrier Shape+Orientation (OS) metric (polyconvex).
1128 {
1129 protected:
1131 
1132 public:
1133  // (1/2 alpha) | A - (|A|/|W|) W |^2
1134  virtual double EvalW(const DenseMatrix &Jpt) const;
1135 
1136  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
1137  { MFEM_ABORT("Not implemented"); }
1138 
1139  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
1140  const double weight, DenseMatrix &A) const
1141  { MFEM_ABORT("Not implemented"); }
1142 };
1143 
1144 /// 2D barrier Shape+Size (VS) metric (polyconvex).
1146 {
1147 protected:
1150 
1151 public:
1152  TMOP_AMetric_126(double gamma)
1154  {
1155  // (1-gamma) nu_11 + gamma nu_14
1156  AddQualityMetric(sh_metric, 1.-gamma);
1157  AddQualityMetric(sz_metric, gamma);
1158  }
1159 
1160  virtual ~TMOP_AMetric_126() { delete sh_metric; delete sz_metric; }
1161 };
1162 
1163 /// Base class for limiting functions to be used in class TMOP_Integrator.
1164 /** This class represents a scalar function f(x, x0, d), where x and x0 are
1165  positions in physical space, and d is a reference physical distance
1166  associated with the point x0. */
1168 {
1169 public:
1170  /// Returns the limiting function, f(x, x0, d).
1171  virtual double Eval(const Vector &x, const Vector &x0, double d) const = 0;
1172 
1173  /** @brief Returns the gradient of the limiting function f(x, x0, d) with
1174  respect to x. */
1175  virtual void Eval_d1(const Vector &x, const Vector &x0, double dist,
1176  Vector &d1) const = 0;
1177 
1178  /** @brief Returns the Hessian of the limiting function f(x, x0, d) with
1179  respect to x. */
1180  virtual void Eval_d2(const Vector &x, const Vector &x0, double dist,
1181  DenseMatrix &d2) const = 0;
1182 
1183  /// Virtual destructor.
1185 };
1186 
1187 /// Default limiter function in TMOP_Integrator.
1189 {
1190 public:
1191  virtual double Eval(const Vector &x, const Vector &x0, double dist) const
1192  {
1193  MFEM_ASSERT(x.Size() == x0.Size(), "Bad input.");
1194 
1195  return 0.5 * x.DistanceSquaredTo(x0) / (dist * dist);
1196  }
1197 
1198  virtual void Eval_d1(const Vector &x, const Vector &x0, double dist,
1199  Vector &d1) const
1200  {
1201  MFEM_ASSERT(x.Size() == x0.Size(), "Bad input.");
1202 
1203  d1.SetSize(x.Size());
1204  subtract(1.0 / (dist * dist), x, x0, d1);
1205  }
1206 
1207  virtual void Eval_d2(const Vector &x, const Vector &x0, double dist,
1208  DenseMatrix &d2) const
1209  {
1210  MFEM_ASSERT(x.Size() == x0.Size(), "Bad input.");
1211 
1212  d2.Diag(1.0 / (dist * dist), x.Size());
1213  }
1214 
1216 };
1217 
1218 /// Exponential limiter function in TMOP_Integrator.
1220 {
1221 public:
1222  virtual double Eval(const Vector &x, const Vector &x0, double dist) const
1223  {
1224  MFEM_ASSERT(x.Size() == x0.Size(), "Bad input.");
1225 
1226  return exp(10.0*((x.DistanceSquaredTo(x0) / (dist * dist))-1.0));
1227  }
1228 
1229  virtual void Eval_d1(const Vector &x, const Vector &x0, double dist,
1230  Vector &d1) const
1231  {
1232  MFEM_ASSERT(x.Size() == x0.Size(), "Bad input.");
1233 
1234  d1.SetSize(x.Size());
1235  double dist_squared = dist*dist;
1236  subtract(20.0*exp(10.0*((x.DistanceSquaredTo(x0) / dist_squared) - 1.0)) /
1237  dist_squared, x, x0, d1);
1238  }
1239 
1240  virtual void Eval_d2(const Vector &x, const Vector &x0, double dist,
1241  DenseMatrix &d2) const
1242  {
1243  MFEM_ASSERT(x.Size() == x0.Size(), "Bad input.");
1244  Vector tmp;
1245  tmp.SetSize(x.Size());
1246  double dist_squared = dist*dist;
1247  double dist_squared_squared = dist_squared*dist_squared;
1248  double f = exp(10.0*((x.DistanceSquaredTo(x0) / dist_squared)-1.0));
1249 
1250  subtract(x,x0,tmp);
1251  d2.SetSize(x.Size());
1252  d2(0,0) = ((400.0*tmp(0)*tmp(0)*f)/dist_squared_squared)+(20.0*f/dist_squared);
1253  d2(1,1) = ((400.0*tmp(1)*tmp(1)*f)/dist_squared_squared)+(20.0*f/dist_squared);
1254  d2(0,1) = (400.0*tmp(0)*tmp(1)*f)/dist_squared_squared;
1255  d2(1,0) = d2(0,1);
1256 
1257  if (x.Size() == 3)
1258  {
1259  d2(0,2) = (400.0*tmp(0)*tmp(2)*f)/dist_squared_squared;
1260  d2(1,2) = (400.0*tmp(1)*tmp(2)*f)/dist_squared_squared;
1261  d2(2,0) = d2(0,2);
1262  d2(2,1) = d2(1,2);
1263  d2(2,2) = ((400.0*tmp(2)*tmp(2)*f)/dist_squared_squared)+(20.0*f/dist_squared);
1264  }
1265 
1266  }
1267 
1269 };
1270 
1271 class FiniteElementCollection;
1272 class FiniteElementSpace;
1273 class ParFiniteElementSpace;
1274 
1276 {
1277 protected:
1278  // Owned.
1281 
1282 #ifdef MFEM_USE_MPI
1283  // Owned.
1286 #endif
1287 
1288 public:
1289  AdaptivityEvaluator() : mesh(NULL), fes(NULL)
1290  {
1291 #ifdef MFEM_USE_MPI
1292  pmesh = NULL;
1293  pfes = NULL;
1294 #endif
1295  }
1296  virtual ~AdaptivityEvaluator();
1297 
1298  /** Specifies the Mesh and FiniteElementSpace of the solution that will
1299  be evaluated. The given mesh will be copied into the internal object. */
1300  void SetSerialMetaInfo(const Mesh &m,
1301  const FiniteElementSpace &f);
1302 
1303 #ifdef MFEM_USE_MPI
1304  /// Parallel version of SetSerialMetaInfo.
1305  void SetParMetaInfo(const ParMesh &m,
1306  const ParFiniteElementSpace &f);
1307 #endif
1308 
1309  // TODO use GridFunctions to make clear it's on the ldofs?
1310  virtual void SetInitialField(const Vector &init_nodes,
1311  const Vector &init_field) = 0;
1312 
1313  virtual void ComputeAtNewPosition(const Vector &new_nodes,
1314  Vector &new_field,
1315  int new_nodes_ordering = Ordering::byNODES) = 0;
1316 
1317  void ClearGeometricFactors();
1318 };
1319 
1320 /** @brief Base class representing target-matrix construction algorithms for
1321  mesh optimization via the target-matrix optimization paradigm (TMOP). */
1322 /** This class is used by class TMOP_Integrator to construct the target Jacobian
1323  matrices (reference-element to target-element) at quadrature points. It
1324  supports a set of algorithms chosen by the #TargetType enumeration.
1325 
1326  New target-matrix construction algorithms can be defined by deriving new
1327  classes and overriding the methods ComputeElementTargets() and
1328  ContainsVolumeInfo(). */
1330 {
1331 public:
1332  /// Target-matrix construction algorithms supported by this class.
1334  {
1336  Ideal shape, unit size; the nodes are not used. */
1338  Ideal shape, equal size/volume; the given nodes define the total target
1339  volume; for each mesh element, the target volume is the average volume
1340  multiplied by the volume scale, set with SetVolumeScale(). */
1342  Ideal shape, given size/volume; the given nodes define the target
1343  volume at all quadrature points. */
1345  Given shape, given size/volume; the given nodes define the exact target
1346  Jacobian matrix at all quadrature points. */
1348  Full target tensor is specified at every quadrature point. */
1349  };
1350 
1351 protected:
1352  // Nodes that are used in ComputeElementTargets(), depending on target_type.
1353  const GridFunction *nodes; // not owned
1354  mutable double avg_volume;
1357  bool uses_phys_coords; // see UsesPhysicalCoordinates()
1358 
1359 #ifdef MFEM_USE_MPI
1360  MPI_Comm comm;
1361 #endif
1362 
1363  // should be called only if avg_volume == 0.0, i.e. avg_volume is not
1364  // computed yet
1365  void ComputeAvgVolume() const;
1366 
1367  template<int DIM>
1369  const IntegrationRule &ir,
1370  const Vector &xe,
1371  DenseTensor &Jtr) const;
1372 
1373  // CPU fallback that uses ComputeElementTargets()
1375  const IntegrationRule &ir,
1376  const Vector &xe,
1377  DenseTensor &Jtr) const;
1378 
1379 public:
1380  /// Constructor for use in serial
1382  : nodes(NULL), avg_volume(), volume_scale(1.0), target_type(ttype),
1383  uses_phys_coords(false)
1384  {
1385 #ifdef MFEM_USE_MPI
1386  comm = MPI_COMM_NULL;
1387 #endif
1388  }
1389 #ifdef MFEM_USE_MPI
1390  /// Constructor for use in parallel
1391  TargetConstructor(TargetType ttype, MPI_Comm mpicomm)
1392  : nodes(NULL), avg_volume(), volume_scale(1.0), target_type(ttype),
1393  uses_phys_coords(false), comm(mpicomm) { }
1394 #endif
1395  virtual ~TargetConstructor() { }
1396 
1397 #ifdef MFEM_USE_MPI
1398  bool Parallel() const { return (comm != MPI_COMM_NULL); }
1399  MPI_Comm GetComm() const { return comm; }
1400 #else
1401  bool Parallel() const { return false; }
1402 #endif
1403 
1404  /** @brief Set the nodes to be used in the target-matrix construction.
1405 
1406  This method should be called every time the target nodes are updated
1407  externally and recomputation of the target average volume is needed. The
1408  nodes are used by all target types except IDEAL_SHAPE_UNIT_SIZE. */
1409  void SetNodes(const GridFunction &n) { nodes = &n; avg_volume = 0.0; }
1410 
1411  /** @brief Get the nodes to be used in the target-matrix construction. */
1412  const GridFunction *GetNodes() const { return nodes; }
1413 
1414  /// Used by target type IDEAL_SHAPE_EQUAL_SIZE. The default volume scale is 1.
1415  void SetVolumeScale(double vol_scale) { volume_scale = vol_scale; }
1416 
1418 
1419  /** @brief Return true if the methods ComputeElementTargets(),
1420  ComputeAllElementTargets(), and ComputeElementTargetsGradient() use the
1421  physical node coordinates provided by the parameters 'elfun', or 'xe'. */
1423 
1424  /// Checks if the target matrices contain non-trivial size specification.
1425  virtual bool ContainsVolumeInfo() const;
1426 
1427  /** @brief Given an element and quadrature rule, computes ref->target
1428  transformation Jacobians for each quadrature point in the element.
1429  The physical positions of the element's nodes are given by @a elfun. */
1430  virtual void ComputeElementTargets(int e_id, const FiniteElement &fe,
1431  const IntegrationRule &ir,
1432  const Vector &elfun,
1433  DenseTensor &Jtr) const;
1434 
1435  /** @brief Computes reference-to-target transformation Jacobians for all
1436  quadrature points in all elements.
1437 
1438  @param[in] fes The nodal FE space
1439  @param[in] ir The quadrature rule to use for all elements
1440  @param[in] xe E-vector with the current physical coordinates/positions;
1441  this parameter is used only when needed by the target
1442  constructor, see UsesPhysicalCoordinates()
1443  @param[out] Jtr The computed ref->target Jacobian matrices. */
1444  virtual void ComputeAllElementTargets(const FiniteElementSpace &fes,
1445  const IntegrationRule &ir,
1446  const Vector &xe,
1447  DenseTensor &Jtr) const;
1448 
1449  virtual void ComputeElementTargetsGradient(const IntegrationRule &ir,
1450  const Vector &elfun,
1452  DenseTensor &dJtr) const;
1453 };
1454 
1456 {
1457 public:
1459 
1460  /** @brief Evaluate the derivative of the matrix coefficient with respect to
1461  @a comp in the element described by @a T at the point @a ip, storing the
1462  result in @a K. */
1463  virtual void EvalGrad(DenseMatrix &K, ElementTransformation &T,
1464  const IntegrationPoint &ip, int comp) = 0;
1465 
1467 };
1468 
1470 {
1471 protected:
1472  // Analytic target specification.
1476 
1477 public:
1479  : TargetConstructor(ttype),
1480  scalar_tspec(NULL), vector_tspec(NULL), matrix_tspec(NULL)
1481  { uses_phys_coords = true; }
1482 
1483  virtual void SetAnalyticTargetSpec(Coefficient *sspec,
1484  VectorCoefficient *vspec,
1485  TMOPMatrixCoefficient *mspec);
1486 
1487  /** @brief Given an element and quadrature rule, computes ref->target
1488  transformation Jacobians for each quadrature point in the element.
1489  The physical positions of the element's nodes are given by @a elfun. */
1490  virtual void ComputeElementTargets(int e_id, const FiniteElement &fe,
1491  const IntegrationRule &ir,
1492  const Vector &elfun,
1493  DenseTensor &Jtr) const;
1494 
1495  virtual void ComputeAllElementTargets(const FiniteElementSpace &fes,
1496  const IntegrationRule &ir,
1497  const Vector &xe,
1498  DenseTensor &Jtr) const;
1499 
1500  virtual void ComputeElementTargetsGradient(const IntegrationRule &ir,
1501  const Vector &elfun,
1503  DenseTensor &dJtr) const;
1504 };
1505 
1506 #ifdef MFEM_USE_MPI
1507 class ParGridFunction;
1508 #endif
1509 
1511 {
1512 protected:
1513  // Discrete target specification.
1514  // Data is owned, updated by UpdateTargetSpecification.
1516  Vector tspec; //eta(x) - we enforce Ordering::byNODES
1518  Vector tspec_pert1h; //eta(x+h)
1519  Vector tspec_pert2h; //eta(x+2*h)
1520  Vector tspec_pertmix; //eta(x+h,y+h)
1521  // The order inside these perturbation vectors (e.g. in 2D) is
1522  // eta1(x+h,y), eta2(x+h,y) ... etan(x+h,y), eta1(x,y+h), eta2(x,y+h) ...
1523  // same for tspec_pert2h and tspec_pertmix.
1524 
1525  // DenseMatrix to hold target_spec values for the (children of the)
1526  // element being refined to consider for h-refinement.
1528  // Vector to hold the target_spec values for the coarse version of the
1529  // current mesh. Used for derefinement decision with hr-adaptivity.
1531 
1532  // Components of Target Jacobian at each quadrature point of an element. This
1533  // is required for computation of the derivative using chain rule.
1535 
1536  // Note: do not use the Nodes of this space as they may not be on the
1537  // positions corresponding to the values of tspec.
1539  FiniteElementSpace *coarse_tspec_fesv; //not owned, derefinement FESpace
1540  GridFunction *tspec_gf; //owned, uses tspec and tspec_fes
1541  // discrete adaptivity
1542 #ifdef MFEM_USE_MPI
1543  ParFiniteElementSpace *ptspec_fesv; //owned, needed for derefinement to
1544  // get update operator.
1545  ParGridFunction *tspec_pgf; // similar to tspec_gf
1546 #endif
1547 
1548  int amr_el;
1550 
1551  // These flags can be used by outside functions to avoid recomputing the
1552  // tspec and tspec_perth fields again on the same mesh.
1554 
1555  // Evaluation of the discrete target specification on different meshes.
1556  // Owned.
1558 
1559  void SetDiscreteTargetBase(const GridFunction &tspec_);
1560  void SetTspecAtIndex(int idx, const GridFunction &tspec_);
1561  void FinalizeSerialDiscreteTargetSpec(const GridFunction &tspec_);
1562 #ifdef MFEM_USE_MPI
1563  void SetTspecAtIndex(int idx, const ParGridFunction &tspec_);
1564  void FinalizeParDiscreteTargetSpec(const ParGridFunction &tspec_);
1565 #endif
1566 
1567 public:
1569  : TargetConstructor(ttype),
1570  ncomp(0),
1571  sizeidx(-1), skewidx(-1), aspectratioidx(-1), orientationidx(-1),
1574  tspec_fesv(NULL), coarse_tspec_fesv(NULL), tspec_gf(NULL),
1575 #ifdef MFEM_USE_MPI
1576  ptspec_fesv(NULL), tspec_pgf(NULL),
1577 #endif
1578  amr_el(-1), lim_min_size(-0.1),
1579  good_tspec(false), good_tspec_grad(false), good_tspec_hess(false),
1580  adapt_eval(NULL) { }
1581 
1582  virtual ~DiscreteAdaptTC();
1583 
1584  /** @name Target specification methods.
1585  The following methods are used to specify geometric parameters of the
1586  targets when these parameters are given by discrete FE functions.
1587  Note that every GridFunction given to the Set methods must use a
1588  H1_FECollection of the same order. The number of components must
1589  correspond to the type of geometric parameter and dimension.
1590 
1591  @param[in] tspec_ Input values of a geometric parameter. Note that
1592  the methods in this class support only functions that
1593  use H1_FECollection collection of the same order. */
1594  ///@{
1595  virtual void SetSerialDiscreteTargetSpec(const GridFunction &tspec_);
1596  virtual void SetSerialDiscreteTargetSize(const GridFunction &tspec_);
1597  virtual void SetSerialDiscreteTargetSkew(const GridFunction &tspec_);
1598  virtual void SetSerialDiscreteTargetAspectRatio(const GridFunction &tspec_);
1599  virtual void SetSerialDiscreteTargetOrientation(const GridFunction &tspec_);
1600 #ifdef MFEM_USE_MPI
1601  virtual void SetParDiscreteTargetSpec(const ParGridFunction &tspec_);
1602  virtual void SetParDiscreteTargetSize(const ParGridFunction &tspec_);
1603  virtual void SetParDiscreteTargetSkew(const ParGridFunction &tspec_);
1604  virtual void SetParDiscreteTargetAspectRatio(const ParGridFunction &tspec_);
1605  virtual void SetParDiscreteTargetOrientation(const ParGridFunction &tspec_);
1606 #endif
1607  ///@}
1608 
1609  /// Used in combination with the Update methods to avoid extra computations.
1611  { good_tspec = good_tspec_grad = good_tspec_hess = false; }
1612 
1613  /// Get one of the discrete fields from tspec.
1614  void GetDiscreteTargetSpec(GridFunction &tspec_, int idx);
1615  /// Get the FESpace associated with tspec.
1617  /// Get the entire tspec.
1619  /// Update all discrete fields based on tspec and update for AMR
1621 
1622 #ifdef MFEM_USE_MPI
1625 #endif
1626 
1627  /** Used to update the target specification after the mesh has changed. The
1628  new mesh positions are given by new_x. If @a reuse_flag is true,
1629  repeated calls won't do anything until ResetUpdateFlags() is called. */
1630  void UpdateTargetSpecification(const Vector &new_x, bool reuse_flag = false,
1631  int new_x_ordering=Ordering::byNODES);
1632 
1633  void UpdateTargetSpecification(Vector &new_x, Vector &IntData,
1634  int new_x_ordering=Ordering::byNODES);
1635 
1638  int nodenum, int idir,
1639  const Vector &IntData);
1640 
1642 
1643  /** Used for finite-difference based computations. Computes the target
1644  specifications after a mesh perturbation in x or y direction.
1645  If @a reuse_flag is true, repeated calls won't do anything until
1646  ResetUpdateFlags() is called. */
1647  void UpdateGradientTargetSpecification(const Vector &x, double dx,
1648  bool reuse_flag = false,
1649  int x_ordering = Ordering::byNODES);
1650  /** Used for finite-difference based computations. Computes the target
1651  specifications after two mesh perturbations in x and/or y direction.
1652  If @a reuse_flag is true, repeated calls won't do anything until
1653  ResetUpdateFlags() is called. */
1654  void UpdateHessianTargetSpecification(const Vector &x, double dx,
1655  bool reuse_flag = false,
1656  int x_ordering = Ordering::byNODES);
1657 
1659  {
1660  if (adapt_eval) { delete adapt_eval; }
1661  adapt_eval = ae;
1662  }
1663 
1665  {
1666  return adapt_eval;
1667  }
1668 
1669  const Vector &GetTspecPert1H() { return tspec_pert1h; }
1670  const Vector &GetTspecPert2H() { return tspec_pert2h; }
1672 
1673  /** @brief Given an element and quadrature rule, computes ref->target
1674  transformation Jacobians for each quadrature point in the element.
1675  The physical positions of the element's nodes are given by @a elfun.
1676  Note that this function assumes that UpdateTargetSpecification() has
1677  been called with the position vector corresponding to @a elfun. */
1678  virtual void ComputeElementTargets(int e_id, const FiniteElement &fe,
1679  const IntegrationRule &ir,
1680  const Vector &elfun,
1681  DenseTensor &Jtr) const;
1682 
1683  virtual void ComputeAllElementTargets(const FiniteElementSpace &fes,
1684  const IntegrationRule &ir,
1685  const Vector &xe,
1686  DenseTensor &Jtr) const;
1687 
1688  virtual void ComputeElementTargetsGradient(const IntegrationRule &ir,
1689  const Vector &elfun,
1691  DenseTensor &dJtr) const;
1692 
1693  // Generates tspec_vals for target construction using intrule
1694  // Used for the refinement component in hr-adaptivity.
1695  void SetTspecFromIntRule(int e_id, const IntegrationRule &intrule);
1696 
1697  // Targets based on discrete functions can result in invalid (negative)
1698  // size at the quadrature points. This method can be used to set a
1699  // minimum target size.
1700  void SetMinSizeForTargets(double min_size_) { lim_min_size = min_size_; }
1701 
1702  /// Computes target specification data with respect to the coarse FE space.
1704 
1705  // Reset refinement data associated with h-adaptivity component.
1707  {
1708  tspec_refine.Clear();
1709  amr_el = -1;
1710  }
1711 
1712  // Reset derefinement data associated with h-adaptivity component.
1714  {
1716  coarse_tspec_fesv = NULL;
1717  }
1718 
1719  // Used to specify the fine element for determining energy of children of a
1720  // parent element.
1721  void SetRefinementSubElement(int amr_el_) { amr_el = amr_el_; }
1722 };
1723 
1724 class TMOPNewtonSolver;
1725 
1726 /** @brief A TMOP integrator class based on any given TMOP_QualityMetric and
1727  TargetConstructor.
1728 
1729  Represents @f$ \int W(Jpt) dx @f$ over a target zone, where W is the
1730  metric's strain energy density function, and Jpt is the Jacobian of the
1731  target->physical coordinates transformation. The virtual target zone is
1732  defined by the TargetConstructor. */
1734 {
1735 protected:
1736  friend class TMOPNewtonSolver;
1737  friend class TMOPComboIntegrator;
1738 
1741  const TargetConstructor *targetC; // not owned
1742 
1743  // Custom integration rules.
1746  bool integ_over_target = true;
1747 
1748  // Weight Coefficient multiplying the quality metric term.
1749  Coefficient *metric_coeff; // not owned, if NULL -> metric_coeff is 1.
1750  // Normalization factor for the metric term.
1752 
1753  // Nodes and weight Coefficient used for "limiting" the TMOP_Integrator.
1754  // These are both NULL when there is no limiting.
1755  // The class doesn't own lim_nodes0 and lim_coeff.
1758  // Limiting reference distance. Not owned.
1760  // Limiting function. Owned.
1762  // Normalization factor for the limiting term.
1763  double lim_normal;
1764 
1765  // Adaptive limiting.
1766  const GridFunction *adapt_lim_gf0; // Not owned.
1767 #ifdef MFEM_USE_MPI
1769 #endif
1770  GridFunction *adapt_lim_gf; // Owned. Updated by adapt_lim_eval.
1773 
1774  // Surface fitting.
1775  const Array<bool> *surf_fit_marker; // Not owned. Nodes to fit.
1776  Coefficient *surf_fit_coeff; // Not owned. Fitting term scaling.
1777  // Fitting to a discrete level set.
1778  GridFunction *surf_fit_gf; // Owned. Updated by surf_fit_eval.
1780  // Fitting to given physical positions.
1781  TMOP_QuadraticLimiter *surf_fit_limiter; // Owned. Created internally.
1782  const GridFunction *surf_fit_pos; // Not owned. Positions to fit.
1789 
1791 
1792  // Parameters for FD-based Gradient & Hessian calculation.
1793  bool fdflag;
1794  double dx;
1795  double dxscale;
1796  // Specifies that ComputeElementTargets is being called by a FD function.
1797  // It's used to skip terms that have exact derivative calculations.
1799  // Compute the exact action of the Integrator (includes derivative of the
1800  // target with respect to spatial position)
1802 
1805 
1806  // Jrt: the inverse of the ref->target Jacobian, Jrt = Jtr^{-1}.
1807  // Jpr: the ref->physical transformation Jacobian, Jpr = PMatI^t DS.
1808  // Jpt: the target->physical transformation Jacobian, Jpt = Jpr Jrt.
1809  // P: represents dW_d(Jtp) (dim x dim).
1810  // DSh: gradients of reference shape functions (dof x dim).
1811  // DS: gradients of the shape functions in the target configuration,
1812  // DS = DSh Jrt (dof x dim).
1813  // PMatI: current coordinates of the nodes (dof x dim).
1814  // PMat0: reshaped view into the local element contribution to the operator
1815  // output - the result of AssembleElementVector() (dof x dim).
1817 
1818  // PA extension
1819  // ------------
1820  // E: Q-vector for TMOP-energy
1821  // O: Q-Vector of 1.0, used to compute sums using the dot product kernel.
1822  // X0: E-vector for initial nodal coordinates used for limiting.
1823  // H: Q-Vector for Hessian associated with the metric term.
1824  // C0: Q-Vector for spatial weight used for the limiting term.
1825  // LD: E-Vector constructed using limiting distance grid function (delta).
1826  // H0: Q-Vector for Hessian associated with the limiting term.
1827  //
1828  // maps: Dof2Quad map for fespace associate with nodal coordinates.
1829  // maps_lim: Dof2Quad map for fespace associated with the limiting distance
1830  // grid function.
1831  //
1832  // Jtr_debug_grad
1833  // We keep track if Jtr was set by AssembleGradPA() in Jtr_debug_grad: it
1834  // is set to true by AssembleGradPA(); any other call to
1835  // ComputeAllElementTargets() will set the flag to false. This flag will
1836  // be used to check that Jtr is the one set by AssembleGradPA() when
1837  // performing operations with the gradient like AddMultGradPA() and
1838  // AssembleGradDiagonalPA().
1839  //
1840  // TODO:
1841  // * Merge LD, C0, H0 into one scalar Q-vector
1842  struct
1843  {
1844  bool enabled;
1845  int dim, ne, nq;
1846  mutable DenseTensor Jtr;
1847  mutable bool Jtr_needs_update;
1848  mutable bool Jtr_debug_grad;
1849  mutable Vector E, O, X0, H, C0, LD, H0;
1850  const DofToQuad *maps;
1851  const DofToQuad *maps_lim = nullptr;
1855  } PA;
1856 
1858  double &metric_energy, double &lim_energy,
1859  double &surf_fit_gf_energy);
1860 
1863  const Vector &elfun, Vector &elvect);
1864 
1865  void AssembleElementGradExact(const FiniteElement &el,
1867  const Vector &elfun, DenseMatrix &elmat);
1868 
1869  void AssembleElementVectorFD(const FiniteElement &el,
1871  const Vector &elfun, Vector &elvect);
1872 
1873  // Assumes that AssembleElementVectorFD has been called.
1874  void AssembleElementGradFD(const FiniteElement &el,
1876  const Vector &elfun, DenseMatrix &elmat);
1877 
1878  void AssembleElemVecAdaptLim(const FiniteElement &el,
1880  const IntegrationRule &ir,
1881  const Vector &weights, DenseMatrix &mat);
1882  void AssembleElemGradAdaptLim(const FiniteElement &el,
1884  const IntegrationRule &ir,
1885  const Vector &weights, DenseMatrix &m);
1886 
1887  // First derivative of the surface fitting term.
1888  void AssembleElemVecSurfFit(const FiniteElement &el_x,
1890  DenseMatrix &mat);
1891 
1892  // Second derivative of the surface fitting term.
1893  void AssembleElemGradSurfFit(const FiniteElement &el_x,
1895  DenseMatrix &mat);
1896 
1897  double GetFDDerivative(const FiniteElement &el,
1899  Vector &elfun, const int nodenum,const int idir,
1900  const double baseenergy, bool update_stored);
1901 
1902  /** @brief Determines the perturbation, h, for FD-based approximation. */
1903  void ComputeFDh(const Vector &x, const FiniteElementSpace &fes);
1904  void ComputeMinJac(const Vector &x, const FiniteElementSpace &fes);
1905 
1906  void UpdateAfterMeshPositionChange(const Vector &x_new,
1907  const FiniteElementSpace &x_fes);
1908 
1910  {
1911  lim_nodes0 = NULL; lim_coeff = NULL; lim_dist = NULL;
1912  delete lim_func; lim_func = NULL;
1913  }
1914 
1916  {
1917  if (IntegRules)
1918  {
1919  return IntegRules->Get(el.GetGeomType(), integ_order);
1920  }
1921  return (IntRule) ? *IntRule
1922  /* */ : IntRules.Get(el.GetGeomType(), 2*el.GetOrder() + 3);
1923  }
1925  {
1926  // TODO the energy most likely needs less integration points.
1927  return EnergyIntegrationRule(el);
1928  }
1930  {
1931  // TODO the action and energy most likely need less integration points.
1932  return EnergyIntegrationRule(el);
1933  }
1934 
1935  // Auxiliary PA methods
1936  void AssembleGradPA_2D(const Vector&) const;
1937  void AssembleGradPA_3D(const Vector&) const;
1938  void AssembleGradPA_C0_2D(const Vector&) const;
1939  void AssembleGradPA_C0_3D(const Vector&) const;
1940 
1941  double GetLocalStateEnergyPA_2D(const Vector&) const;
1942  double GetLocalStateEnergyPA_C0_2D(const Vector&) const;
1943  double GetLocalStateEnergyPA_3D(const Vector&) const;
1944  double GetLocalStateEnergyPA_C0_3D(const Vector&) const;
1945 
1946  void AddMultPA_2D(const Vector&, Vector&) const;
1947  void AddMultPA_3D(const Vector&, Vector&) const;
1948  void AddMultPA_C0_2D(const Vector&, Vector&) const;
1949  void AddMultPA_C0_3D(const Vector&, Vector&) const;
1950 
1951  void AddMultGradPA_2D(const Vector&, Vector&) const;
1952  void AddMultGradPA_3D(const Vector&, Vector&) const;
1953  void AddMultGradPA_C0_2D(const Vector&, Vector&) const;
1954  void AddMultGradPA_C0_3D(const Vector&, Vector&) const;
1955 
1956  void AssembleDiagonalPA_2D(Vector&) const;
1957  void AssembleDiagonalPA_3D(Vector&) const;
1958  void AssembleDiagonalPA_C0_2D(Vector&) const;
1959  void AssembleDiagonalPA_C0_3D(Vector&) const;
1960 
1961  void AssemblePA_Limiting();
1962  void ComputeAllElementTargets(const Vector &xe = Vector()) const;
1963 
1964  // Compute Min(Det(Jpt)) in the mesh, does not reduce over MPI.
1965  double ComputeMinDetT(const Vector &x, const FiniteElementSpace &fes);
1966  // Compute Max(mu_hat) for the TMOP_WorstCaseUntangleOptimizer_Metric,
1967  // does not reduce over MPI.
1968  double ComputeUntanglerMaxMuBarrier(const Vector &x,
1969  const FiniteElementSpace &fes);
1970 
1971 public:
1972  /** @param[in] m TMOP_QualityMetric for r-adaptivity (not owned).
1973  @param[in] tc Target-matrix construction algorithm to use (not owned).
1974  @param[in] hm TMOP_QualityMetric for h-adaptivity (not owned). */
1976  TMOP_QualityMetric *hm)
1977  : h_metric(hm), metric(m), targetC(tc), IntegRules(NULL),
1978  integ_order(-1), metric_coeff(NULL), metric_normal(1.0),
1979  lim_nodes0(NULL), lim_coeff(NULL),
1980  lim_dist(NULL), lim_func(NULL), lim_normal(1.0),
1981  adapt_lim_gf0(NULL), adapt_lim_gf(NULL), adapt_lim_coeff(NULL),
1982  adapt_lim_eval(NULL),
1983  surf_fit_marker(NULL), surf_fit_coeff(NULL),
1984  surf_fit_gf(NULL), surf_fit_eval(NULL),
1985  surf_fit_limiter(NULL), surf_fit_pos(NULL),
1986  surf_fit_normal(1.0),
1987  surf_fit_gf_bg(false), surf_fit_grad(NULL), surf_fit_hess(NULL),
1989  discr_tc(dynamic_cast<DiscreteAdaptTC *>(tc)),
1990  fdflag(false), dxscale(1.0e3), fd_call_flag(false), exact_action(false)
1991  { PA.enabled = false; }
1992 
1994  : TMOP_Integrator(m, tc, m) { }
1995 
1996  ~TMOP_Integrator();
1997 
1998  /// Release the device memory of large PA allocations. This will copy device
1999  /// memory back to the host before releasing.
2000  void ReleasePADeviceMemory(bool copy_to_host = true);
2001 
2002  /// Prescribe a set of integration rules; relevant for mixed meshes.
2003  /** This function has priority over SetIntRule(), if both are called. */
2004  void SetIntegrationRules(IntegrationRules &irules, int order)
2005  {
2006  IntegRules = &irules;
2007  integ_order = order;
2008  }
2009 
2010  /// The TMOP integrals can be computed over the reference element or the
2011  /// target elements. This function is used to switch between the two options.
2012  /// By default integration is performed over the target elements.
2013  void IntegrateOverTarget(bool integ_over_target_)
2014  {
2015  MFEM_VERIFY(metric_normal == 1.0 && lim_normal == 1.0,
2016  "This function must be called before EnableNormalization, as "
2017  "the normalization computations must know how to integrate.");
2018 
2019  integ_over_target = integ_over_target_;
2020  }
2021 
2022  /// Sets a scaling Coefficient for the quality metric term of the integrator.
2023  /** With this addition, the integrator becomes
2024  @f$ \int w1 W(Jpt) dx @f$.
2025 
2026  Note that the Coefficient is evaluated in the physical configuration and
2027  not in the target configuration which may be undefined. */
2029 
2030  /** @brief Limiting of the mesh displacements (general version).
2031 
2032  Adds the term @f$ \int w_0 f(x, x_0, d) dx @f$, where f is a measure of
2033  the displacement between x and x_0, given the max allowed displacement d.
2034 
2035  @param[in] n0 Original mesh node coordinates (x0 above).
2036  @param[in] dist Allowed displacement in physical space (d above).
2037  @param[in] w0 Coefficient scaling the limiting integral.
2038  @param[in] lfunc TMOP_LimiterFunction defining the function f. If
2039  NULL, a TMOP_QuadraticLimiter will be used. The
2040  TMOP_Integrator assumes ownership of this pointer. */
2041  void EnableLimiting(const GridFunction &n0, const GridFunction &dist,
2042  Coefficient &w0, TMOP_LimiterFunction *lfunc = NULL);
2043 
2044  /** @brief Adds a limiting term to the integrator with limiting distance
2045  function (@a dist in the general version of the method) equal to 1. */
2046  void EnableLimiting(const GridFunction &n0, Coefficient &w0,
2047  TMOP_LimiterFunction *lfunc = NULL);
2048 
2049  /** @brief Restriction of the node positions to certain regions.
2050 
2051  Adds the term @f$ \int c (z(x) - z_0(x_0))^2 @f$, where z0(x0) is a given
2052  function on the starting mesh, and z(x) is its image on the new mesh.
2053  Minimizing this term means that a node at x0 is allowed to move to a
2054  position x(x0) only if z(x) ~ z0(x0).
2055  Such term can be used for tangential mesh relaxation.
2056 
2057  @param[in] z0 Function z0 that controls the adaptive limiting.
2058  @param[in] coeff Coefficient c for the above integral.
2059  @param[in] ae AdaptivityEvaluator to compute z(x) from z0(x0). */
2060  void EnableAdaptiveLimiting(const GridFunction &z0, Coefficient &coeff,
2061  AdaptivityEvaluator &ae);
2062 #ifdef MFEM_USE_MPI
2063  /// Parallel support for adaptive limiting.
2064  void EnableAdaptiveLimiting(const ParGridFunction &z0, Coefficient &coeff,
2065  AdaptivityEvaluator &ae);
2066 #endif
2067 
2068  /** @brief Fitting of certain DOFs to the zero level set of a function.
2069 
2070  Having a level set function s0(x0) on the starting mesh, and a set of
2071  marked nodes (or DOFs), we move these nodes to the zero level set of s0.
2072  If s(x) is the image of s0(x0) on the current mesh, this function adds to
2073  the TMOP functional the term @f$ \int c \bar{s}(x))^2 @f$, where
2074  @f$\bar{s}(x)@f$ is the restriction of s(x) on the aligned DOFs.
2075  Minimizing this term means that a marked node at x0 is allowed to move to
2076  a position x(x0) only if s(x) ~ 0.
2077  Such term can be used for surface fitting and tangential relaxation.
2078 
2079  @param[in] s0 The level set function on the initial mesh.
2080  @param[in] smarker Indicates which DOFs will be aligned.
2081  @param[in] coeff Coefficient c for the above integral.
2082  @param[in] ae AdaptivityEvaluator to compute s(x) from s0(x0). */
2083  void EnableSurfaceFitting(const GridFunction &s0,
2084  const Array<bool> &smarker, Coefficient &coeff,
2085  AdaptivityEvaluator &ae);
2086 
2087 #ifdef MFEM_USE_MPI
2088  /// Parallel support for surface fitting to the zero level set of a function.
2089  void EnableSurfaceFitting(const ParGridFunction &s0,
2090  const Array<bool> &smarker, Coefficient &coeff,
2091  AdaptivityEvaluator &ae);
2092 
2093  /** @brief Fitting of certain DOFs in the current mesh to the zero level set
2094  of a function defined on another (finer) source mesh.
2095 
2096  Having a level set function s_bg(x_bg) on a source/background mesh,
2097  a set of marked nodes (or DOFs) in the current mesh, we move the marked
2098  nodes to the zero level set of s_bg. This functionality is used for
2099  surface fitting and tangential relaxation.
2100 
2101  @param[in] s_bg The level set function on the background mesh.
2102  @param[in] s0 The level set function (automatically) interpolated
2103  on the initial mesh.
2104  @param[in] smarker Marker for aligned DOFs in the current mesh.
2105  @param[in] coeff Coefficient c for the fitting penalty term.
2106  @param[in] ae Interpolates s(x) from s_bg(x_bg).
2107  @param[in] s_bg_grad Gradient of s_bg on the background mesh.
2108  @param[in] s0_grad Gradient of s0 on the initial mesh.
2109  @param[in] age Interpolates s_grad(x) from s_bg_grad(x_bg).
2110  @param[in] s_bg_hess Hessian of s(x) on the background mesh.
2111  @param[in] s0_hess Hessian of s0 on the initial mesh.
2112  @param[in] ahe Interpolates s_hess(x) from s_bg_hess(x_bg).
2113  See the pmesh-fitting miniapp for details on usage. */
2115  ParGridFunction &s0,
2116  const Array<bool> &smarker,
2117  Coefficient &coeff,
2118  AdaptivityEvaluator &ae,
2119  const ParGridFunction &s_bg_grad,
2120  ParGridFunction &s0_grad,
2121  AdaptivityEvaluator &age,
2122  const ParGridFunction &s_bg_hess,
2123  ParGridFunction &s0_hess,
2124  AdaptivityEvaluator &ahe);
2125 #endif
2126  /** @brief Fitting of certain DOFs to given positions in physical space.
2127 
2128  Having a set S of marked nodes (or DOFs) and their target positions in
2129  physical space x_t, we move these nodes to the target positions during
2130  the optimization process.
2131  This function adds to the TMOP functional the term
2132  @f$ \sum_{i \in S} c \frac{1}{2} (x_i - x_{t,i})^2 @f$,
2133  where @f$c@f$ corresponds to @a coeff below and is evaluated at the
2134  DOF locations.
2135 
2136  @param[in] pos The desired positions for the mesh nodes.
2137  @param[in] smarker Indicates which DOFs will be aligned.
2138  @param[in] coeff Coefficient c for the above integral. */
2139  void EnableSurfaceFitting(const GridFunction &pos,
2140  const Array<bool> &smarker, Coefficient &coeff);
2141  void GetSurfaceFittingErrors(const Vector &pos,
2142  double &err_avg, double &err_max);
2144  {
2145  return surf_fit_gf != NULL || surf_fit_pos != NULL;
2146  }
2147 
2148  /// Update the original/reference nodes used for limiting.
2149  void SetLimitingNodes(const GridFunction &n0) { lim_nodes0 = &n0; }
2150 
2151  /** @brief Computes the integral of W(Jacobian(Trt)) over a target zone.
2152  @param[in] el Type of FiniteElement.
2153  @param[in] T Mesh element transformation.
2154  @param[in] elfun Physical coordinates of the zone. */
2155  virtual double GetElementEnergy(const FiniteElement &el,
2157  const Vector &elfun);
2158 
2159  /** @brief Computes the mean of the energies of the given element's children.
2160 
2161  In addition to the inputs for GetElementEnergy, this function requires an
2162  IntegrationRule to be specified that will give the decomposition of the
2163  given element based on the refinement type being considered. */
2164  virtual double GetRefinementElementEnergy(const FiniteElement &el,
2166  const Vector &elfun,
2167  const IntegrationRule &irule);
2168 
2169  /// This function is similar to GetElementEnergy, but ignores components
2170  /// such as limiting etc. to compute the element energy.
2171  virtual double GetDerefinementElementEnergy(const FiniteElement &el,
2173  const Vector &elfun);
2174 
2175  virtual void AssembleElementVector(const FiniteElement &el,
2177  const Vector &elfun, Vector &elvect);
2178 
2179  virtual void AssembleElementGrad(const FiniteElement &el,
2181  const Vector &elfun, DenseMatrix &elmat);
2182 
2184 
2186 #ifdef MFEM_USE_MPI
2188 #endif
2189 
2190  // PA extension
2192  virtual void AssemblePA(const FiniteElementSpace&);
2193 
2194  virtual void AssembleGradPA(const Vector&, const FiniteElementSpace&);
2195 
2196  virtual double GetLocalStateEnergyPA(const Vector&) const;
2197 
2198  virtual void AddMultPA(const Vector&, Vector&) const;
2199 
2200  virtual void AddMultGradPA(const Vector&, Vector&) const;
2201 
2202  virtual void AssembleGradDiagonalPA(Vector&) const;
2203 
2205 
2206  /** @brief Computes the normalization factors of the metric and limiting
2207  integrals using the mesh position given by @a x. */
2208  void EnableNormalization(const GridFunction &x);
2209 #ifdef MFEM_USE_MPI
2210  void ParEnableNormalization(const ParGridFunction &x);
2211 #endif
2212 
2213  /** @brief Enables FD-based approximation and computes dx. */
2214  void EnableFiniteDifferences(const GridFunction &x);
2215 #ifdef MFEM_USE_MPI
2217 #endif
2218 
2219  void SetFDhScale(double dxscale_) { dxscale = dxscale_; }
2220  bool GetFDFlag() const { return fdflag; }
2221  double GetFDh() const { return dx; }
2222 
2223  /** @brief Flag to control if exact action of Integration is effected. */
2224  void SetExactActionFlag(bool flag_) { exact_action = flag_; }
2225 
2226  /// Update the surface fitting weight as surf_fit_coeff *= factor;
2227  void UpdateSurfaceFittingWeight(double factor);
2228 
2229  /// Get the surface fitting weight.
2230  double GetSurfaceFittingWeight();
2231 
2232  /// Computes quantiles needed for UntangleMetrics. Note that in parallel,
2233  /// the ParFiniteElementSpace must be passed as argument for consistency
2234  /// across MPI ranks.
2235  void ComputeUntangleMetricQuantiles(const Vector &x,
2236  const FiniteElementSpace &fes);
2237 };
2238 
2240 {
2241 protected:
2242  // Integrators in the combination. Owned.
2244 
2245 public:
2247 
2249  {
2250  for (int i = 0; i < tmopi.Size(); i++) { delete tmopi[i]; }
2251  }
2252 
2253  /// Adds a new TMOP_Integrator to the combination.
2254  void AddTMOPIntegrator(TMOP_Integrator *ti) { tmopi.Append(ti); }
2255 
2257 
2258  /// Adds the limiting term to the first integrator. Disables it for the rest.
2259  void EnableLimiting(const GridFunction &n0, const GridFunction &dist,
2260  Coefficient &w0, TMOP_LimiterFunction *lfunc = NULL);
2261 
2262  /** @brief Adds the limiting term to the first integrator. Disables it for
2263  the rest (@a dist in the general version of the method) equal to 1. */
2264  void EnableLimiting(const GridFunction &n0, Coefficient &w0,
2265  TMOP_LimiterFunction *lfunc = NULL);
2266 
2267  /// Update the original/reference nodes used for limiting.
2268  void SetLimitingNodes(const GridFunction &n0);
2269 
2270  virtual double GetElementEnergy(const FiniteElement &el,
2272  const Vector &elfun);
2273  virtual void AssembleElementVector(const FiniteElement &el,
2275  const Vector &elfun, Vector &elvect);
2276  virtual void AssembleElementGrad(const FiniteElement &el,
2278  const Vector &elfun, DenseMatrix &elmat);
2279 
2280  virtual double GetRefinementElementEnergy(const FiniteElement &el,
2282  const Vector &elfun,
2283  const IntegrationRule &irule);
2284 
2285  virtual double GetDerefinementElementEnergy(const FiniteElement &el,
2287  const Vector &elfun);
2288 
2289  /// Normalization factor that considers all integrators in the combination.
2290  void EnableNormalization(const GridFunction &x);
2291 #ifdef MFEM_USE_MPI
2292  void ParEnableNormalization(const ParGridFunction &x);
2293 #endif
2294 
2295  // PA extension
2297  virtual void AssemblePA(const FiniteElementSpace&);
2298  virtual void AssembleGradPA(const Vector&, const FiniteElementSpace&);
2299  virtual double GetLocalStateEnergyPA(const Vector&) const;
2300  virtual void AddMultPA(const Vector&, Vector&) const;
2301  virtual void AddMultGradPA(const Vector&, Vector&) const;
2302  virtual void AssembleGradDiagonalPA(Vector&) const;
2303 };
2304 
2305 /// Interpolates the @a metric's values at the nodes of @a metric_gf.
2306 /** Assumes that @a metric_gf's FiniteElementSpace is initialized. */
2307 void InterpolateTMOP_QualityMetric(TMOP_QualityMetric &metric,
2308  const TargetConstructor &tc,
2309  const Mesh &mesh, GridFunction &metric_gf);
2310 }
2311 
2312 #endif
double GetGamma() const
Definition: tmop.hpp:501
Abstract class for all finite elements.
Definition: fe_base.hpp:233
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:720
void ComputeUntangleMetricQuantiles(const Vector &x, const FiniteElementSpace &fes)
Definition: tmop.cpp:4645
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:511
GridFunction * surf_fit_hess
Definition: tmop.hpp:1785
virtual void ComputeElementTargets(int e_id, const FiniteElement &fe, const IntegrationRule &ir, const Vector &elfun, DenseTensor &Jtr) const
Given an element and quadrature rule, computes ref->target transformation Jacobians for each quadratu...
Definition: tmop.cpp:1710
virtual double GetDerefinementElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun)
Definition: tmop.cpp:3379
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:466
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:955
virtual void SetParDiscreteTargetSize(const ParGridFunction &tspec_)
Definition: tmop.cpp:1847
virtual void ComputeElementTargets(int e_id, const FiniteElement &fe, const IntegrationRule &ir, const Vector &elfun, DenseTensor &Jtr) const
Given an element and quadrature rule, computes ref->target transformation Jacobians for each quadratu...
Definition: tmop.cpp:2107
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:694
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:772
Shifted barrier form of metric 56 (area, ideal barrier metric), 2D.
Definition: tmop.hpp:643
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:989
3D shifted barrier form of metric 316 (not typed).
Definition: tmop.hpp:1032
void GetWeights(Array< double > &weights) const
Definition: tmop.hpp:127
virtual void ComputeAllElementTargets(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const
Computes reference-to-target transformation Jacobians for all quadrature points in all elements...
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:749
virtual void SetInitialField(const Vector &init_nodes, const Vector &init_field)=0
const GridFunction * surf_fit_pos
Definition: tmop.hpp:1782
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:407
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const =0
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:867
void AssembleElemVecSurfFit(const FiniteElement &el_x, IsoparametricTransformation &Tpr, DenseMatrix &mat)
Definition: tmop.cpp:3806
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:222
Class for an integration rule - an Array of IntegrationPoint.
Definition: intrules.hpp:96
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:935
VectorCoefficient * vector_tspec
Definition: tmop.hpp:1474
3D non-barrier Shape (S) metric.
Definition: tmop.hpp:1051
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:1126
double GetGamma() const
Definition: tmop.hpp:1026
void EnableFiniteDifferences(const GridFunction &x)
Enables FD-based approximation and computes dx.
Definition: tmop.cpp:4497
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:611
void UpdateTargetSpecification(const Vector &new_x, bool reuse_flag=false, int new_x_ordering=Ordering::byNODES)
Definition: tmop.cpp:2022
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:699
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:539
const TargetType target_type
Definition: tmop.hpp:1356
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:881
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:30
DenseMatrix PMatO
Definition: tmop.hpp:1816
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:1119
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.hpp:204
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.hpp:383
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:1105
DenseTensor Jtr
Definition: tmop.hpp:1846
void ComputeAvgMetrics(const GridFunction &nodes, const TargetConstructor &tc, Vector &averages) const
Definition: tmop.cpp:99
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.hpp:1139
double & min_detT
Definition: tmop.hpp:392
3D barrier Shape+Size (VS) metric, well-posed (invex).
Definition: tmop.hpp:843
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:768
const DenseMatrix * Jtr
Definition: tmop.hpp:26
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:846
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:1335
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:970
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
Definition: intrules.cpp:980
double GetSurfaceFittingWeight()
Get the surface fitting weight.
Definition: tmop.cpp:4203
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:550
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:590
3D barrier Shape+Size (VS) metric, well-posed (polyconvex).
Definition: tmop.hpp:967
Base class for vector Coefficients that optionally depend on time and space.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:346
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:1006
virtual ~TMOP_Metric_334()
Definition: tmop.hpp:985
virtual double Eval(const Vector &x, const Vector &x0, double dist) const
Returns the limiting function, f(x, x0, d).
Definition: tmop.hpp:1222
void ComputeBalancedWeights(const GridFunction &nodes, const TargetConstructor &tc, Vector &weights) const
Definition: tmop.cpp:70
DenseMatrix Jrt
Definition: tmop.hpp:1816
const GridFunction * lim_dist
Definition: tmop.hpp:1759
virtual void SetSerialDiscreteTargetOrientation(const GridFunction &tspec_)
Definition: tmop.cpp:1960
virtual double GetElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun)
Compute the local energy.
Definition: tmop.cpp:4714
void AddMultGradPA_2D(const Vector &, Vector &) const
double epsilon
Definition: ex25.cpp:141
bool UsesPhysicalCoordinates() const
Return true if the methods ComputeElementTargets(), ComputeAllElementTargets(), and ComputeElementTar...
Definition: tmop.hpp:1422
struct mfem::TMOP_Integrator::@23 PA
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:1451
virtual void ComputeAtNewPosition(const Vector &new_nodes, Vector &new_field, int new_nodes_ordering=Ordering::byNODES)=0
virtual ~TMOP_Metric_333()
Definition: tmop.hpp:963
virtual void EvalGrad(DenseMatrix &K, ElementTransformation &T, const IntegrationPoint &ip, int comp)=0
Evaluate the derivative of the matrix coefficient with respect to comp in the element described by T ...
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:354
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:1005
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:432
const double eps
Definition: tmop.hpp:748
void EnableNormalization(const GridFunction &x)
Computes the normalization factors of the metric and limiting integrals using the mesh position given...
Definition: tmop.cpp:4214
TMOP_QualityMetric & GetAMRQualityMetric()
Definition: tmop.hpp:2183
void AssembleGradPA_2D(const Vector &) const
void ComputeAllElementTargets(const Vector &xe=Vector()) const
Definition: tmop_pa.cpp:167
const IntegrationRule & GradientIntegrationRule(const FiniteElement &el) const
Definition: tmop.hpp:1929
void SetSize(int s)
Resize the vector to size s.
Definition: vector.hpp:517
3D Size (V) metric.
Definition: tmop.hpp:822
void InterpolateTMOP_QualityMetric(TMOP_QualityMetric &metric, const TargetConstructor &tc, const Mesh &mesh, GridFunction &metric_gf)
Interpolates the metric&#39;s values at the nodes of metric_gf.
Definition: tmop.cpp:4867
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
Definition: tmop.hpp:703
TMOP_QualityMetric * metric
Definition: tmop.hpp:1740
void SetAdaptivityEvaluator(AdaptivityEvaluator *ae)
Definition: tmop.hpp:1658
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:1118
virtual ~TMOP_Metric_332()
Definition: tmop.hpp:944
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:450
virtual ~TMOP_LimiterFunction()
Virtual destructor.
Definition: tmop.hpp:1184
Base class for limiting functions to be used in class TMOP_Integrator.
Definition: tmop.hpp:1167
virtual void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const
Definition: tmop.cpp:2322
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:512
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:374
virtual double EvalW(const DenseMatrix &Jpt) const =0
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Array< int > surf_fit_marker_dof_index
Definition: tmop.hpp:1788
virtual void Eval_d2(const Vector &x, const Vector &x0, double dist, DenseMatrix &d2) const =0
Returns the Hessian of the limiting function f(x, x0, d) with respect to x.
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:604
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:1435
3D non-barrier Skew metric.
Definition: tmop.hpp:254
const Array< TMOP_Integrator * > & GetTMOPIntegrators() const
Definition: tmop.hpp:2256
void ParUpdateAfterMeshTopologyChange()
Definition: tmop.cpp:1816
DenseMatrix Jpr
Definition: tmop.hpp:1816
IntegrationRules * IntegRules
Definition: tmop.hpp:1744
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:992
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:534
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:1149
DiscreteAdaptTC * GetDiscreteAdaptTC() const
Definition: tmop.hpp:2204
void SetFDhScale(double dxscale_)
Definition: tmop.hpp:2219
virtual void Eval_d2(const Vector &x, const Vector &x0, double dist, DenseMatrix &d2) const
Returns the Hessian of the limiting function f(x, x0, d) with respect to x.
Definition: tmop.hpp:1240
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const =0
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:224
int Size() const
Returns the size of the vector.
Definition: vector.hpp:197
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:55
void SetMinSizeForTargets(double min_size_)
Definition: tmop.hpp:1700
void AddMultPA_3D(const Vector &, Vector &) const
Definition: tmop_pa_p3.cpp:231
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:941
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:1295
Container class for integration rules.
Definition: intrules.hpp:412
ParFiniteElementSpace * pfes
Definition: tmop.hpp:1285
Data type dense matrix using column-major storage.
Definition: densemat.hpp:23
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
Definition: tmop.hpp:682
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:1380
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:969
void SetVolumeScale(double vol_scale)
Used by target type IDEAL_SHAPE_EQUAL_SIZE. The default volume scale is 1.
Definition: tmop.hpp:1415
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:788
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:1327
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:742
void EnableAdaptiveLimiting(const GridFunction &z0, Coefficient &coeff, AdaptivityEvaluator &ae)
Restriction of the node positions to certain regions.
Definition: tmop.cpp:2876
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:1014
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:634
3D Size (V) metric.
Definition: tmop.hpp:785
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:235
void SetIntegrationRules(IntegrationRules &irules, int order)
Prescribe a set of integration rules; relevant for mixed meshes.
Definition: tmop.hpp:2004
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:1130
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:1396
void EnableNormalization(const GridFunction &x)
Normalization factor that considers all integrators in the combination.
Definition: tmop.cpp:4784
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:878
3D compound barrier Shape+Size (VS) metric (polyconvex, balanced).
Definition: tmop.hpp:989
2D barrier Shape+Size (VS) metric (polyconvex).
Definition: tmop.hpp:1145
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:200
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:827
bool IsSurfaceFittingEnabled()
Definition: tmop.hpp:2143
double & min_detT
Definition: tmop.hpp:767
3D barrier Shape+Size (VS) metric, well-posed (invex).
Definition: tmop.hpp:885
const AdaptivityEvaluator * GetAdaptivityEvaluator() const
Definition: tmop.hpp:1664
Abstract parallel finite element space.
Definition: pfespace.hpp:28
virtual void AssemblePA(const FiniteElementSpace &)
Method defining partial assembly.
Definition: tmop.cpp:4816
TMOP_Metric_080(double gamma)
Definition: tmop.hpp:537
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:361
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.hpp:561
void SetSerialMetaInfo(const Mesh &m, const FiniteElementSpace &f)
Definition: tmop.cpp:2781
Structure for storing mesh geometric factors: coordinates, Jacobians, and determinants of the Jacobia...
Definition: mesh.hpp:2183
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:399
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:1387
const IntegrationRule * ir
Definition: tmop.hpp:1854
void SetExactActionFlag(bool flag_)
Flag to control if exact action of Integration is effected.
Definition: tmop.hpp:2224
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:469
void AssembleElementVectorFD(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
Definition: tmop.cpp:4024
const GridFunction * nodes
Definition: tmop.hpp:1353
TMOP_WorstCaseUntangleOptimizer_Metric(TMOP_QualityMetric &tmop_metric_, int exponent_=1, double alpha_=1.5, double detT_ep_=0.0001, double muT_ep_=0.0001, BarrierType btype_=BarrierType::None, WorstCaseType wctype_=WorstCaseType::None)
Definition: tmop.hpp:179
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:982
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:905
virtual void SetSerialDiscreteTargetSkew(const GridFunction &tspec_)
Definition: tmop.cpp:1940
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:758
void UpdateSurfaceFittingWeight(double factor)
Update the surface fitting weight as surf_fit_coeff *= factor;.
Definition: tmop.cpp:4191
AdaptivityEvaluator * surf_fit_eval_bg_grad
Definition: tmop.hpp:1786
void SetRefinementSubElement(int amr_el_)
Definition: tmop.hpp:1721
2D non-barrier Aspect ratio metric.
Definition: tmop.hpp:269
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.hpp:263
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.hpp:293
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:711
void UpdateAfterMeshPositionChange(const Vector &x_new, const FiniteElementSpace &x_fes)
Definition: tmop.cpp:4345
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:951
virtual double GetLocalStateEnergyPA(const Vector &) const
Compute the local (to the MPI rank) energy with partial assembly.
Definition: tmop_pa.cpp:297
void IntegrateOverTarget(bool integ_over_target_)
Definition: tmop.hpp:2013
2D barrier Shape+Size (VS) metric (not polyconvex).
Definition: tmop.hpp:340
virtual ~TMOP_Metric_090()
Definition: tmop.hpp:584
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:952
Default limiter function in TMOP_Integrator.
Definition: tmop.hpp:1188
virtual double GetLocalStateEnergyPA(const Vector &) const
Compute the local (to the MPI rank) energy with partial assembly.
Definition: tmop.cpp:4857
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:615
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:206
void AssembleElementGradExact(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
Definition: tmop.cpp:3601
virtual void AddMultGradPA(const Vector &, Vector &) const
Method for partially assembled gradient action.
Definition: tmop.cpp:4849
Array< Vector * > ElemDer
Definition: tmop.hpp:1803
3D barrier Shape+Size (VS) metric, well-posed (invex).
Definition: tmop.hpp:864
virtual ~TMOP_AMetric_126()
Definition: tmop.hpp:1160
const Vector & GetTspecPertMixH()
Definition: tmop.hpp:1671
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.hpp:1085
void EnableLimiting(const GridFunction &n0, const GridFunction &dist, Coefficient &w0, TMOP_LimiterFunction *lfunc=NULL)
Adds the limiting term to the first integrator. Disables it for the rest.
Definition: tmop.cpp:4685
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:909
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:490
2D Shifted barrier form of shape metric (mu_2).
Definition: tmop.hpp:389
TMOP_Metric_313(double &mindet)
Definition: tmop.hpp:771
TMOP_Metric_352(double &t0)
Definition: tmop.hpp:1039
Coefficient * scalar_tspec
Definition: tmop.hpp:1473
virtual void SetSerialDiscreteTargetAspectRatio(const GridFunction &tspec_)
Definition: tmop.cpp:1950
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:290
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:702
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:582
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
Definition: intrules.hpp:480
TMOPMatrixCoefficient(int dim)
Definition: tmop.hpp:1458
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:834
2D barrier shape (S) metric (not polyconvex).
Definition: tmop.hpp:466
const DofToQuad * maps
Definition: tmop.hpp:1850
virtual ~TMOP_QualityMetric()
Definition: tmop.hpp:35
std::function< double(const Vector &)> f(double mass_coeff)
Definition: lor_mms.hpp:30
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:897
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:659
const IntegrationRule & EnergyIntegrationRule(const FiniteElement &el) const
Definition: tmop.hpp:1915
void UpdateGradientTargetSpecification(const Vector &x, double dx, bool reuse_flag=false, int x_ordering=Ordering::byNODES)
Definition: tmop.cpp:2669
virtual void AddMultPA(const Vector &, Vector &) const
Method for partially assembled action.
Definition: tmop_pa.cpp:250
double ComputeUntanglerMaxMuBarrier(const Vector &x, const FiniteElementSpace &fes)
Definition: tmop.cpp:4583
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:571
void AddMultPA_C0_2D(const Vector &, Vector &) const
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:1136
const GeometricFactors * geom
Definition: tmop.hpp:1852
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
Definition: tmop.hpp:724
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
Definition: fe_base.hpp:320
bool ComputeAllElementTargets(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const
double GetLocalStateEnergyPA_C0_3D(const Vector &) const
2D barrier Size (V) metric (polyconvex).
Definition: tmop.hpp:1091
Abstract class for local mesh quality metrics in the target-matrix optimization paradigm (TMOP) by P...
Definition: tmop.hpp:23
void AssembleGradPA_C0_2D(const Vector &) const
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:1214
void FinalizeSerialDiscreteTargetSpec(const GridFunction &tspec_)
Definition: tmop.cpp:1970
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:432
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:212
Coefficient * adapt_lim_coeff
Definition: tmop.hpp:1771
virtual ~TMOPMatrixCoefficient()
Definition: tmop.hpp:1466
virtual ~AdaptivityEvaluator()
Definition: tmop.cpp:2812
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:1467
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:246
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:788
2D compound barrier Shape+Size (VS) metric (balanced).
Definition: tmop.hpp:588
virtual void AddQualityMetric(TMOP_QualityMetric *tq, double wt=1.0)
Definition: tmop.hpp:92
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:352
void SetLimitingNodes(const GridFunction &n0)
Update the original/reference nodes used for limiting.
Definition: tmop.cpp:4706
virtual ~TMOP_Metric_080()
Definition: tmop.hpp:548
void SetDiscreteTargetBase(const GridFunction &tspec_)
Definition: tmop.cpp:1893
virtual ~TMOP_Metric_066()
Definition: tmop.hpp:503
AdaptivityEvaluator * adapt_lim_eval
Definition: tmop.hpp:1772
virtual void AssembleGradPA(const Vector &, const FiniteElementSpace &)
Prepare the integrator for partial assembly (PA) gradient evaluations on the given FE space fes at th...
Definition: tmop_pa.cpp:23
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:598
virtual double EvalWBarrier(const DenseMatrix &Jpt) const
Definition: tmop.cpp:184
void AddMultGradPA_3D(const Vector &, Vector &) const
DiscreteAdaptTC * discr_tc
Definition: tmop.hpp:1790
void EnableLimiting(const GridFunction &n0, const GridFunction &dist, Coefficient &w0, TMOP_LimiterFunction *lfunc=NULL)
Limiting of the mesh displacements (general version).
Definition: tmop.cpp:2851
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:23
void AssembleDiagonalPA_3D(Vector &) const
virtual WorstCaseType GetWorstCaseType()
Definition: tmop.hpp:217
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:1076
void SetCoefficient(Coefficient &w1)
Sets a scaling Coefficient for the quality metric term of the integrator.
Definition: tmop.hpp:2028
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:260
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:626
void UpdateTargetSpecificationAtNode(const FiniteElement &el, ElementTransformation &T, int nodenum, int idir, const Vector &IntData)
Definition: tmop.cpp:2042
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:971
void SetTspecFromIntRule(int e_id, const IntegrationRule &intrule)
Definition: tmop.cpp:2073
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:78
int Append(const T &el)
Append element &#39;el&#39; to array, resize if necessary.
Definition: array.hpp:759
TargetConstructor(TargetType ttype)
Constructor for use in serial.
Definition: tmop.hpp:1381
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.hpp:248
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:482
3D Size (V) metric.
Definition: tmop.hpp:803
DiscreteAdaptTC(TargetType ttype)
Definition: tmop.hpp:1568
void AddMultGradPA_C0_2D(const Vector &, Vector &) const
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:1014
void ResetRefinementTspecData()
Definition: tmop.hpp:1706
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:628
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:245
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:306
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:1288
void SetNodes(const GridFunction &n)
Set the nodes to be used in the target-matrix construction.
Definition: tmop.hpp:1409
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:825
void AssembleElementVectorExact(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
Definition: tmop.cpp:3462
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:525
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:910
const TargetConstructor * targetC
Definition: tmop.hpp:1741
Array< Vector * > ElemPertEnergy
Definition: tmop.hpp:1804
const GridFunction * lim_nodes0
Definition: tmop.hpp:1756
const ParGridFunction * adapt_lim_pgf0
Definition: tmop.hpp:1768
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:952
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:930
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:490
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:1041
virtual void AssemblePA(const FiniteElementSpace &fes)
Method defining partial assembly.
Definition: nonlininteg.cpp:25
3D barrier Shape+Size (VS) metric, well-posed (polyconvex).
Definition: tmop.hpp:1010
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:1142
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:393
virtual void Eval_d2(const Vector &x, const Vector &x0, double dist, DenseMatrix &d2) const
Returns the Hessian of the limiting function f(x, x0, d) with respect to x.
Definition: tmop.hpp:1207
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:922
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:887
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:1235
virtual void AssembleGradPA(const Vector &, const FiniteElementSpace &)
Prepare the integrator for partial assembly (PA) gradient evaluations on the given FE space fes at th...
Definition: tmop.cpp:4824
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:888
virtual void SetParDiscreteTargetAspectRatio(const ParGridFunction &tspec_)
Definition: tmop.cpp:1867
virtual void AssemblePA(const FiniteElementSpace &)
Method defining partial assembly.
Definition: tmop_pa.cpp:179
void AssembleGradPA_C0_3D(const Vector &) const
virtual ~TMOP_ExponentialLimiter()
Definition: tmop.hpp:1268
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:380
virtual ~TargetConstructor()
Definition: tmop.hpp:1395
virtual void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const
Definition: tmop.cpp:1687
void ParEnableNormalization(const ParGridFunction &x)
Definition: tmop.cpp:4800
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:647
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:839
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:993
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
Definition: tmop.cpp:3433
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:325
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
Definition: tmop.hpp:609
GridFunction * GetTSpecData()
Get the entire tspec.
Definition: tmop.hpp:1618
FiniteElementSpace * tspec_fesv
Definition: tmop.hpp:1538
Coefficient * metric_coeff
Definition: tmop.hpp:1749
void AssembleElemGradSurfFit(const FiniteElement &el_x, IsoparametricTransformation &Tpr, DenseMatrix &mat)
Definition: tmop.cpp:3887
TMOP_QualityMetric * h_metric
Definition: tmop.hpp:1739
Array< TMOP_QualityMetric * > tmop_q_arr
Definition: tmop.hpp:88
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:1068
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:1177
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:368
virtual BarrierType GetBarrierType()
Definition: tmop.hpp:215
void AssembleDiagonalPA_2D(Vector &) const
void RestoreTargetSpecificationAtNode(ElementTransformation &T, int nodenum)
Definition: tmop.cpp:2059
bool Parallel() const
Definition: tmop.hpp:1398
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:1062
void AssemblePA_Limiting()
Definition: tmop_pa.cpp:51
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:534
2D barrier Shape+Orientation (OS) metric (polyconvex).
Definition: tmop.hpp:1127
void SetTspecAtIndex(int idx, const GridFunction &tspec_)
Definition: tmop.cpp:1917
virtual double GetRefinementElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, const IntegrationRule &irule)
Computes the mean of the energies of the given element&#39;s children.
Definition: tmop.cpp:3293
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:43
Array< int > surf_fit_dof_count
Definition: tmop.hpp:1787
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:358
double GetLocalStateEnergyPA_3D(const Vector &) const
Definition: tmop_pa_w3.cpp:176
Coefficient * lim_coeff
Definition: tmop.hpp:1757
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:502
3D compound barrier Shape+Size (VS) metric (polyconvex, balanced).
Definition: tmop.hpp:906
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:533
AdaptivityEvaluator * surf_fit_eval
Definition: tmop.hpp:1779
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:449
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:201
TMOP_Metric_066(double gamma)
Definition: tmop.hpp:493
virtual void Eval_d1(const Vector &x, const Vector &x0, double dist, Vector &d1) const
Returns the gradient of the limiting function f(x, x0, d) with respect to x.
Definition: tmop.hpp:1229
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:667
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:977
virtual ~TMOP_QuadraticLimiter()
Definition: tmop.hpp:1215
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:1070
FiniteElementSpace * GetTSpecFESpace()
Get the FESpace associated with tspec.
Definition: tmop.hpp:1616
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:592
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:1149
virtual void SetTargetJacobian(const DenseMatrix &Jtr_)
Specify the reference-element -> target-element Jacobian matrix for the point of interest.
Definition: tmop.hpp:43
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:1013
TMOP_Metric_211(double epsilon=1e-4)
Definition: tmop.hpp:631
double GetFDh() const
Definition: tmop.hpp:2221
void AssembleElemGradAdaptLim(const FiniteElement &el, IsoparametricTransformation &Tpr, const IntegrationRule &ir, const Vector &weights, DenseMatrix &m)
Definition: tmop.cpp:3745
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:286
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
Assemble the local gradient matrix.
Definition: tmop.cpp:3447
const DofToQuad * maps_lim
Definition: tmop.hpp:1851
2D untangling metric.
Definition: tmop.hpp:624
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:1054
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:1188
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition: fespace.hpp:219
3D Size (V) untangling metric.
Definition: tmop.hpp:745
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:1311
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:1224
const double eps
Definition: tmop.hpp:627
virtual void SetTargetJacobian(const DenseMatrix &Jtr_)
Specify the reference-element -> target-element Jacobian matrix for the point of interest.
Definition: tmop.hpp:98
void SetLimitingNodes(const GridFunction &n0)
Update the original/reference nodes used for limiting.
Definition: tmop.hpp:2149
DenseMatrix tspec_refine
Definition: tmop.hpp:1527
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:1156
TMOP_AMetric_126(double gamma)
Definition: tmop.hpp:1152
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
Definition: coefficient.hpp:41
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:558
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:1036
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:33
void AddMultPA_C0_3D(const Vector &, Vector &) const
void subtract(const Vector &x, const Vector &y, Vector &z)
Definition: vector.cpp:473
TMOPMatrixCoefficient * matrix_tspec
Definition: tmop.hpp:1475
void AssembleDiagonalPA_C0_2D(Vector &) const
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:341
const GridFunction * GetNodes() const
Get the nodes to be used in the target-matrix construction.
Definition: tmop.hpp:1412
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:489
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:1251
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:1021
bool GetFDFlag() const
Definition: tmop.hpp:2220
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:1082
virtual bool ContainsVolumeInfo() const
Checks if the target matrices contain non-trivial size specification.
Definition: tmop.cpp:1602
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:618
Base class for Matrix Coefficients that optionally depend on time and space.
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:412
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:1166
void ReleasePADeviceMemory(bool copy_to_host=true)
Definition: tmop.cpp:2822
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:860
virtual void Eval_d1(const Vector &x, const Vector &x0, double dist, Vector &d1) const
Returns the gradient of the limiting function f(x, x0, d) with respect to x.
Definition: tmop.hpp:1198
void Clear()
Delete the matrix data array (if owned) and reset the matrix state.
Definition: densemat.hpp:98
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:1100
void DisableLimiting()
Definition: tmop.hpp:1909
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
Assemble the local gradient matrix.
Definition: tmop.cpp:4742
Structure representing the matrices/tensors needed to evaluate (in reference space) the values...
Definition: fe_base.hpp:136
TMOP_Metric_252(double &t0)
Note that t0 is stored by reference.
Definition: tmop.hpp:651
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:380
DenseTensor Jtrcomp
Definition: tmop.hpp:1534
void SetParMetaInfo(const ParMesh &m, const ParFiniteElementSpace &f)
Parallel version of SetSerialMetaInfo.
Definition: tmop.cpp:2792
GridFunction * surf_fit_grad
Definition: tmop.hpp:1785
const IntegrationRule * IntRule
Definition: nonlininteg.hpp:39
void ResetUpdateFlags()
Used in combination with the Update methods to avoid extra computations.
Definition: tmop.hpp:1610
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:545
AnalyticAdaptTC(TargetType ttype)
Definition: tmop.hpp:1478
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:1112
void AddTMOPIntegrator(TMOP_Integrator *ti)
Adds a new TMOP_Integrator to the combination.
Definition: tmop.hpp:2254
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:724
GridFunction * tspec_gf
Definition: tmop.hpp:1540
2D non-barrier Skew metric.
Definition: tmop.hpp:239
virtual void AssembleGradDiagonalPA(Vector &) const
Method for computing the diagonal of the gradient with partial assembly.
Definition: tmop_pa.cpp:225
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:902
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:648
void UpdateAfterMeshTopologyChange()
Definition: tmop.cpp:3109
virtual void SetMaxMuT(double max_muT_)
Definition: tmop.hpp:213
DenseMatrix PMatI
Definition: tmop.hpp:1816
virtual void SetMinDetT(double min_detT_)
Definition: tmop.hpp:211
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:806
2D barrier Shape+Size (VS) metric (not polyconvex).
Definition: tmop.hpp:358
void SetTransformation(ElementTransformation &)
The method HyperelasticModel::SetTransformation() is hidden for TMOP_QualityMetrics, because it is not used.
Definition: tmop.hpp:31
virtual void ComputeElementTargets(int e_id, const FiniteElement &fe, const IntegrationRule &ir, const Vector &elfun, DenseTensor &Jtr) const
Given an element and quadrature rule, computes ref->target transformation Jacobians for each quadratu...
Definition: tmop.cpp:1616
double GetLocalStateEnergyPA_C0_2D(const Vector &) const
void ComputeFDh(const Vector &x, const FiniteElementSpace &fes)
Determines the perturbation, h, for FD-based approximation.
Definition: tmop.cpp:4481
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:1373
void ComputeNormalizationEnergies(const GridFunction &x, double &metric_energy, double &lim_energy, double &surf_fit_gf_energy)
Definition: tmop.cpp:4237
virtual double Eval(const Vector &x, const Vector &x0, double d) const =0
Returns the limiting function, f(x, x0, d).
Coefficient * surf_fit_coeff
Definition: tmop.hpp:1776
Class for integration point with weight.
Definition: intrules.hpp:31
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.hpp:47
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:561
virtual ~TMOP_Metric_347()
Definition: tmop.hpp:1028
double GetGamma() const
Definition: tmop.hpp:942
AdaptivityEvaluator * adapt_eval
Definition: tmop.hpp:1557
void SetWeights(const Vector &weights)
Changes the weights of the metrics in the combination.
Definition: tmop.hpp:130
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:800
ParFiniteElementSpace * ptspec_fesv
Definition: tmop.hpp:1543
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:666
const FiniteElementSpace * fes
Definition: tmop.hpp:1853
Array< TMOP_Integrator * > tmopi
Definition: tmop.hpp:2243
A standard isoparametric element transformation.
Definition: eltrans.hpp:361
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:592
void ComputeMinJac(const Vector &x, const FiniteElementSpace &fes)
Definition: tmop.cpp:4310
void AssembleDiagonalPA_C0_3D(Vector &) const
TMOP_Integrator(TMOP_QualityMetric *m, TargetConstructor *tc, TMOP_QualityMetric *hm)
Definition: tmop.hpp:1975
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:1409
const IntegrationRule & ActionIntegrationRule(const FiniteElement &el) const
Definition: tmop.hpp:1924
void Diag(double c, int n)
Creates n x n diagonal matrix with diagonal elements c.
Definition: densemat.cpp:1389
MPI_Comm GetComm() const
Definition: tmop.hpp:1399
This class is used to express the local action of a general nonlinear finite element operator...
Definition: nonlininteg.hpp:27
virtual void AddMultGradPA(const Vector &, Vector &) const
Method for partially assembled gradient action.
Definition: tmop_pa.cpp:272
double GetFDDerivative(const FiniteElement &el, ElementTransformation &T, Vector &elfun, const int nodenum, const int idir, const double baseenergy, bool update_stored)
Definition: tmop.cpp:4002
Exponential limiter function in TMOP_Integrator.
Definition: tmop.hpp:1219
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.hpp:278
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
Definition: tmop.hpp:1109
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:943
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:998
void EnableSurfaceFittingFromSource(const ParGridFunction &s_bg, ParGridFunction &s0, const Array< bool > &smarker, Coefficient &coeff, AdaptivityEvaluator &ae, const ParGridFunction &s_bg_grad, ParGridFunction &s0_grad, AdaptivityEvaluator &age, const ParGridFunction &s_bg_hess, ParGridFunction &s0_hess, AdaptivityEvaluator &ahe)
Fitting of certain DOFs in the current mesh to the zero level set of a function defined on another (f...
Definition: tmop.cpp:2978
double surf_fit_normal
Definition: tmop.hpp:1783
3D Shape (S) metric, untangling version of 303.
Definition: tmop.hpp:764
int dim
Definition: ex24.cpp:53
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:799
virtual double GetElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun)
Computes the integral of W(Jacobian(Trt)) over a target zone.
Definition: tmop.cpp:3135
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.hpp:1121
void AssembleElemVecAdaptLim(const FiniteElement &el, IsoparametricTransformation &Tpr, const IntegrationRule &ir, const Vector &weights, DenseMatrix &mat)
Definition: tmop.cpp:3709
void ParUpdateAfterMeshTopologyChange()
Definition: tmop.cpp:3122
virtual double GetDerefinementElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun)
Definition: tmop.cpp:4771
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.hpp:1103
void ComputeAvgVolume() const
Definition: tmop.cpp:1488
2D compound barrier Shape+Size (VS) metric (balanced).
Definition: tmop.hpp:567
void Destroy()
Destroy a vector.
Definition: vector.hpp:594
virtual void Eval_d1(const Vector &x, const Vector &x0, double dist, Vector &d1) const =0
Returns the gradient of the limiting function f(x, x0, d) with respect to x.
AdaptivityEvaluator * surf_fit_eval_bg_hess
Definition: tmop.hpp:1786
TMOP_Metric_347(double gamma)
Definition: tmop.hpp:1017
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:317
void GetSurfaceFittingErrors(const Vector &pos, double &err_avg, double &err_max)
Definition: tmop.cpp:3047
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:767
3D non-barrier Aspect ratio metric.
Definition: tmop.hpp:284
const Vector & GetTspecPert2H()
Definition: tmop.hpp:1670
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:675
const Vector & GetTspecPert1H()
Definition: tmop.hpp:1669
void AssembleElementGradFD(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
Definition: tmop.cpp:4092
ParFiniteElementSpace * GetTSpecParFESpace()
Definition: tmop.hpp:1623
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:971
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:440
TMOP_QuadraticLimiter * surf_fit_limiter
Definition: tmop.hpp:1781
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:303
virtual void SetParDiscreteTargetSpec(const ParGridFunction &tspec_)
Definition: tmop.cpp:1887
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:343
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:910
Abstract class for hyperelastic models.
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:741
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:1302
void UpdateHessianTargetSpecification(const Vector &x, double dx, bool reuse_flag=false, int x_ordering=Ordering::byNODES)
Definition: tmop.cpp:2705
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:1134
GridFunction * adapt_lim_gf
Definition: tmop.hpp:1770
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:570
TMOP_Metric_333(double gamma)
Definition: tmop.hpp:955
TargetConstructor(TargetType ttype, MPI_Comm mpicomm)
Constructor for use in parallel.
Definition: tmop.hpp:1391
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:781
GridFunction * surf_fit_gf
Definition: tmop.hpp:1778
void AssembleGradPA_3D(const Vector &) const
double GetLocalStateEnergyPA_2D(const Vector &) const
Definition: tmop_pa_w2.cpp:164
TMOP_Integrator(TMOP_QualityMetric *m, TargetConstructor *tc)
Definition: tmop.hpp:1993
void FinalizeParDiscreteTargetSpec(const ParGridFunction &tspec_)
Definition: tmop.cpp:1791
ParGridFunction * tspec_pgf
Definition: tmop.hpp:1545
Vector data type.
Definition: vector.hpp:58
void GetDiscreteTargetSpec(GridFunction &tspec_, int idx)
Get one of the discrete fields from tspec.
Definition: tmop.cpp:1991
DenseMatrix DSh
Definition: tmop.hpp:1816
double GetGamma() const
Definition: tmop.hpp:983
const Array< bool > * surf_fit_marker
Definition: tmop.hpp:1775
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:818
TMOP_Metric_332(double gamma)
Definition: tmop.hpp:933
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:1025
DenseMatrix DS
Definition: tmop.hpp:1816
TMOP_Metric_022(double &t0)
Definition: tmop.hpp:396
3D barrier Shape+Size (VS) metric, well-posed (polyconvex).
Definition: tmop.hpp:948
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:706
virtual void AssembleGradDiagonalPA(Vector &) const
Method for computing the diagonal of the gradient with partial assembly.
Definition: tmop.cpp:4833
void SetTspecDataForDerefinement(FiniteElementSpace *fes)
Computes target specification data with respect to the coarse FE space.
Definition: tmop.cpp:2099
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:688
virtual ~TMOP_Metric_094()
Definition: tmop.hpp:605
TargetType
Target-matrix construction algorithms supported by this class.
Definition: tmop.hpp:1333
virtual ~TMOP_Metric_338()
Definition: tmop.hpp:1006
void EnableSurfaceFitting(const GridFunction &s0, const Array< bool > &smarker, Coefficient &coeff, AdaptivityEvaluator &ae)
Fitting of certain DOFs to the zero level set of a function.
Definition: tmop.cpp:2911
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:1054
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:780
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:167
TMOP_Metric_311(double epsilon=1e-4)
Definition: tmop.hpp:752
virtual void SetSerialDiscreteTargetSpec(const GridFunction &tspec_)
Definition: tmop.cpp:2016
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:1094
virtual void SetParDiscreteTargetSkew(const ParGridFunction &tspec_)
Definition: tmop.cpp:1857
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:921
virtual void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const
Definition: tmop.cpp:1744
virtual double GetRefinementElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, const IntegrationRule &irule)
Definition: tmop.cpp:4758
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:1148
virtual void SetParDiscreteTargetOrientation(const ParGridFunction &tspec_)
Definition: tmop.cpp:1877
virtual void ComputeAllElementTargets(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const
Computes reference-to-target transformation Jacobians for all quadrature points in all elements...
Definition: tmop_pa.cpp:138
Class for parallel grid function.
Definition: pgridfunc.hpp:32
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:336
Base class representing target-matrix construction algorithms for mesh optimization via the target-ma...
Definition: tmop.hpp:1329
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
Definition: densemat.hpp:105
virtual ~DiscreteAdaptTC()
Definition: tmop.cpp:2771
TMOP_Metric_334(double gamma)
Definition: tmop.hpp:974
void AddMultPA_2D(const Vector &, Vector &) const
Definition: tmop_pa_p2.cpp:195
virtual void SetAnalyticTargetSpec(Coefficient *sspec, VectorCoefficient *vspec, TMOPMatrixCoefficient *mspec)
Definition: tmop.cpp:1701
3D compound barrier Shape+Size (VS) metric (polyconvex).
Definition: tmop.hpp:927
Rank 3 tensor (array of matrices)
Definition: densemat.hpp:1096
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:392
virtual double EvalWMatrixForm(const DenseMatrix &Jpt) const
Evaluates the metric in matrix form (opposed to invariant form). Used for validating the invariant ev...
Definition: tmop.cpp:1083
Class for parallel meshes.
Definition: pmesh.hpp:32
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:993
virtual void SetSerialDiscreteTargetSize(const GridFunction &tspec_)
Definition: tmop.cpp:1930
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:930
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:1347
TMOP_LimiterFunction * lim_func
Definition: tmop.hpp:1761
double GetGamma() const
Definition: tmop.hpp:546
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:685
const GridFunction * adapt_lim_gf0
Definition: tmop.hpp:1766
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
Definition: tmop.cpp:4726
double ComputeMinDetT(const Vector &x, const FiniteElementSpace &fes)
Definition: tmop.cpp:4541
virtual void AddMultPA(const Vector &, Vector &) const
Method for partially assembled action.
Definition: tmop.cpp:4841
double DistanceSquaredTo(const double *p) const
Compute the square of the Euclidean distance to another vector.
Definition: vector.hpp:658
DenseMatrix Jpt
Definition: tmop.hpp:1816
2D barrier Shape+Orientation (OS) metric (polyconvex).
Definition: tmop.hpp:552
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
Definition: fe_base.hpp:327
Array< double > wt_arr
Definition: tmop.hpp:89
void ParEnableNormalization(const ParGridFunction &x)
Definition: tmop.cpp:4224
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:583
void ComputeAllElementTargets_Fallback(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const
Definition: tmop.cpp:1530
DenseMatrix P
Definition: tmop.hpp:1816
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:1089
void UpdateAfterMeshTopologyChange()
Update all discrete fields based on tspec and update for AMR.
Definition: tmop.cpp:2005
void ResetDerefinementTspecData()
Definition: tmop.hpp:1713
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:928
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:569
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.hpp:618
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:275
3D barrier Shape (S) metric, well-posed (polyconvex & invex).
Definition: tmop.hpp:663
virtual double Eval(const Vector &x, const Vector &x0, double dist) const
Returns the limiting function, f(x, x0, d).
Definition: tmop.hpp:1191
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt), by using the 2D or 3D matrix invariants...
Definition: tmop.cpp:962
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:843
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:1097
void AddMultGradPA_C0_3D(const Vector &, Vector &) const
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:500
2D non-barrier metric without a type.
Definition: tmop.hpp:221
FiniteElementSpace * fes
Definition: tmop.hpp:1280
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:571
TargetType GetTargetType() const
Definition: tmop.hpp:1417
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:727
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:591
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Definition: tmop.cpp:1046
virtual ~TMOP_Metric_328()
Definition: tmop.hpp:923
FiniteElementSpace * coarse_tspec_fesv
Definition: tmop.hpp:1539
A TMOP integrator class based on any given TMOP_QualityMetric and TargetConstructor.
Definition: tmop.hpp:1733
2D non-barrier Shape+Size+Orientation (VOS) metric (polyconvex).
Definition: tmop.hpp:374