MFEM  v4.3.0
Finite element discretization library
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Pages
tmop.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2021, 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 SetTransformation() is hidden for TMOP_QualityMetric%s,
30  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 Evaluate the strain energy density function, W = W(Jpt).
46  @param[in] Jpt Represents the target->physical transformation
47  Jacobian matrix. */
48  virtual double EvalW(const DenseMatrix &Jpt) const = 0;
49 
50  /** @brief Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
51  @param[in] Jpt Represents the target->physical transformation
52  Jacobian matrix.
53  @param[out] P The evaluated 1st Piola-Kirchhoff stress tensor. */
54  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const = 0;
55 
56  /** @brief Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor
57  and assemble its contribution to the local gradient matrix 'A'.
58  @param[in] Jpt Represents the target->physical transformation
59  Jacobian matrix.
60  @param[in] DS Gradient of the basis matrix (dof x dim).
61  @param[in] weight Quadrature weight coefficient for the point.
62  @param[in,out] A Local gradient matrix where the contribution from this
63  point will be added.
64 
65  Computes weight * d(dW_dxi)_d(xj) at the current point, for all i and j,
66  where x1 ... xn are the FE dofs. This function is usually defined using
67  the matrix invariants and their derivatives.
68  */
69  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
70  const double weight, DenseMatrix &A) const = 0;
71 
72  /** @brief Return the metric ID.
73  */
74  virtual int Id() const { return 0; }
75 };
76 
77 /// Abstract class used to define combination of metrics with constant coefficients.
79 {
80 protected:
83 
84 public:
85  virtual void AddQualityMetric(TMOP_QualityMetric *tq, double wt = 1.0)
86  {
87  tmop_q_arr.Append(tq);
88  wt_arr.Append(wt);
89  }
90 
91  virtual void SetTargetJacobian(const DenseMatrix &Jtr_)
92  {
93  for (int i = 0; i < tmop_q_arr.Size(); i++)
94  {
95  tmop_q_arr[i]->SetTargetJacobian(Jtr_);
96  }
97  }
98 
99  virtual double EvalW(const DenseMatrix &Jpt) const;
100 
101  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
102 
103  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
104  const double weight, DenseMatrix &A) const;
105 };
106 
107 /// 2D non-barrier metric without a type.
109 {
110 protected:
112 
113 public:
114  // W = |J|^2.
115  virtual double EvalW(const DenseMatrix &Jpt) const;
116 
117  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
118 
119  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
120  const double weight, DenseMatrix &A) const;
121 
122  virtual int Id() const { return 1; }
123 };
124 
125 /// 2D non-barrier Skew metric.
127 {
128 public:
129  // W = 0.5 (1 - cos(angle_Jpr - angle_Jtr)).
130  virtual double EvalW(const DenseMatrix &Jpt) const;
131 
132  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
133  { MFEM_ABORT("Not implemented"); }
134 
135  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
136  const double weight, DenseMatrix &A) const
137  { MFEM_ABORT("Not implemented"); }
138 };
139 
140 /// 3D non-barrier Skew metric.
142 {
143 public:
144  // W = 1/6 (3 - sum_i cos(angle_Jpr_i - angle_Jtr_i)), i = 1..3.
145  virtual double EvalW(const DenseMatrix &Jpt) const;
146 
147  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
148  { MFEM_ABORT("Not implemented"); }
149 
150  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
151  const double weight, DenseMatrix &A) const
152  { MFEM_ABORT("Not implemented"); }
153 };
154 
155 /// 2D non-barrier Aspect ratio metric.
157 {
158 public:
159  // W = 0.5 (ar_Jpr/ar_Jtr + ar_Jtr/ar_Jpr) - 1.
160  virtual double EvalW(const DenseMatrix &Jpt) const;
161 
162  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
163  { MFEM_ABORT("Not implemented"); }
164 
165  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
166  const double weight, DenseMatrix &A) const
167  { MFEM_ABORT("Not implemented"); }
168 };
169 
170 /// 3D non-barrier Aspect ratio metric.
172 {
173 public:
174  // W = 1/3 sum [0.5 (ar_Jpr_i/ar_Jtr_i + ar_Jtr_i/ar_Jpr_i) - 1], i = 1..3.
175  virtual double EvalW(const DenseMatrix &Jpt) const;
176 
177  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
178  { MFEM_ABORT("Not implemented"); }
179 
180  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
181  const double weight, DenseMatrix &A) const
182  { MFEM_ABORT("Not implemented"); }
183 };
184 
185 /// 2D barrier shape (S) metric (polyconvex).
187 {
188 protected:
190 
191 public:
192  // W = 0.5|J|^2 / det(J) - 1.
193  virtual double EvalW(const DenseMatrix &Jpt) const;
194 
195  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
196 
197  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
198  const double weight, DenseMatrix &A) const;
199 
200  virtual int Id() const { return 2; }
201 };
202 
203 /// 2D barrier Shape+Size (VS) metric (not polyconvex).
205 {
206 protected:
208 
209 public:
210  // W = |J - J^-t|^2.
211  virtual double EvalW(const DenseMatrix &Jpt) const;
212 
213  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
214 
215  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
216  const double weight, DenseMatrix &A) const;
217 
218  virtual int Id() const { return 7; }
219 };
220 
221 /// 2D barrier Shape+Size (VS) metric (not polyconvex).
223 {
224 protected:
226 
227 public:
228  // W = det(J) * |J - J^-t|^2.
229  virtual double EvalW(const DenseMatrix &Jpt) const;
230 
231  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
232 
233  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
234  const double weight, DenseMatrix &A) const;
235 };
236 
237 /// 2D non-barrier Shape+Size+Orientation (VOS) metric (polyconvex).
239 {
240 public:
241  // W = |T-I|^2.
242  virtual double EvalW(const DenseMatrix &Jpt) const;
243 
244  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
245  { MFEM_ABORT("Not implemented"); }
246 
247  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
248  const double weight, DenseMatrix &A) const
249  { MFEM_ABORT("Not implemented"); }
250 };
251 
252 /// 2D Shifted barrier form of shape metric (mu_2).
254 {
255 protected:
256  double &min_detT;
258 
259 public:
260  TMOP_Metric_022(double &t0): min_detT(t0) {}
261 
262  // W = 0.5(|J|^2 - 2det(J)) / (det(J) - tau0).
263  virtual double EvalW(const DenseMatrix &Jpt) const;
264 
265  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
266 
267  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
268  const double weight, DenseMatrix &A) const;
269 };
270 
271 /// 2D barrier (not a shape) metric (polyconvex).
273 {
274 protected:
276 
277 public:
278  // W = 0.5|J^t J|^2 / det(J)^2 - 1.
279  virtual double EvalW(const DenseMatrix &Jpt) const;
280 
281  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
282 
283  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
284  const double weight, DenseMatrix &A) const;
285 };
286 
287 /// 2D non-barrier size (V) metric (not polyconvex).
289 {
290 protected:
292 
293 public:
294  // W = (det(J) - 1)^2.
295  virtual double EvalW(const DenseMatrix &Jpt) const;
296 
297  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
298 
299  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
300  const double weight, DenseMatrix &A) const;
301 
302 };
303 
304 /// 2D barrier size (V) metric (polyconvex).
306 {
307 protected:
309 
310 public:
311  // W = 0.5( sqrt(det(J)) - 1 / sqrt(det(J)) )^2
312  // = 0.5( det(J) - 1 )^2 / det(J)
313  // = 0.5( det(J) + 1/det(J) ) - 1.
314  virtual double EvalW(const DenseMatrix &Jpt) const;
315 
316  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
317 
318  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
319  const double weight, DenseMatrix &A) const;
320 };
321 
322 /// 2D barrier shape (S) metric (not polyconvex).
324 {
325 protected:
327 
328 public:
329  // W = |J^t J|^2 / det(J)^2 - 2|J|^2 / det(J) + 2
330  // = I1b (I1b - 2).
331  virtual double EvalW(const DenseMatrix &Jpt) const;
332 
333  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
334 
335  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
336  const double weight, DenseMatrix &A) const;
337 };
338 
339 /// 2D barrier size (V) metric (polyconvex).
341 {
342 protected:
344 
345 public:
346  // W = 0.5(det(J) - 1 / det(J))^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 77; }
355 };
356 
357 /// 2D barrier Shape+Size (VS) metric (polyconvex).
359 {
360 protected:
362  double gamma;
364 
365 public:
366  TMOP_Metric_080(double gamma_) : gamma(gamma_),
369  {
370  // (1-gamma) mu_2 + gamma mu_77
371  AddQualityMetric(sh_metric, 1.-gamma_);
372  AddQualityMetric(sz_metric, gamma_);
373  }
374  virtual int Id() const { return 80; }
375  double GetGamma() const { return gamma; }
376 
377  virtual ~TMOP_Metric_080() { delete sh_metric; delete sz_metric; }
378 };
379 
380 /// 2D barrier Shape+Orientation (OS) metric (polyconvex).
382 {
383 public:
384  // W = |T-T'|^2, where T'= |T|*I/sqrt(2).
385  virtual double EvalW(const DenseMatrix &Jpt) const;
386 
387  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
388  { MFEM_ABORT("Not implemented"); }
389 
390  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
391  const double weight, DenseMatrix &A) const
392  { MFEM_ABORT("Not implemented"); }
393 };
394 
395 /// 2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
397 {
398 public:
399  // W = 1/tau |T-I|^2.
400  virtual double EvalW(const DenseMatrix &Jpt) const;
401 
402  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
403  { MFEM_ABORT("Not implemented"); }
404 
405  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
406  const double weight, DenseMatrix &A) const
407  { MFEM_ABORT("Not implemented"); }
408 };
409 
410 /// 2D untangling metric.
412 {
413 protected:
414  const double eps;
416 
417 public:
418  TMOP_Metric_211(double epsilon = 1e-4) : eps(epsilon) { }
419 
420  // W = (det(J) - 1)^2 - det(J) + sqrt(det(J)^2 + eps).
421  virtual double EvalW(const DenseMatrix &Jpt) const;
422 
423  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
424 
425  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
426  const double weight, DenseMatrix &A) const;
427 };
428 
429 /// Shifted barrier form of metric 56 (area, ideal barrier metric), 2D
431 {
432 protected:
433  double &tau0;
435 
436 public:
437  /// Note that @a t0 is stored by reference
438  TMOP_Metric_252(double &t0): tau0(t0) {}
439 
440  // W = 0.5(det(J) - 1)^2 / (det(J) - tau0).
441  virtual double EvalW(const DenseMatrix &Jpt) const;
442 
443  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
444 
445  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
446  const double weight, DenseMatrix &A) const;
447 };
448 
449 /// 3D barrier Shape (S) metric.
451 {
452 protected:
454 
455 public:
456  // W = |J| |J^-1| / 3 - 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 /// 3D barrier Shape (S) metric.
467 {
468 protected:
470 
471 public:
472  // W = |J|^2 |J^-1|^2 / 9 - 1.
473  virtual double EvalW(const DenseMatrix &Jpt) const;
474 
475  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
476 
477  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
478  const double weight, DenseMatrix &A) const;
479 
480  virtual int Id() const { return 302; }
481 };
482 
483 /// 3D barrier Shape (S) metric.
485 {
486 protected:
488 
489 public:
490  // W = |J|^2 / 3 * det(J)^(-2/3) - 1.
491  virtual double EvalW(const DenseMatrix &Jpt) const;
492 
493  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
494 
495  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
496  const double weight, DenseMatrix &A) const;
497 
498  virtual int Id() const { return 303; }
499 };
500 
501 /// 3D Size (V) untangling metric.
503 {
504 protected:
505  const double eps;
507 
508 public:
509  TMOP_Metric_311(double epsilon = 1e-4) : eps(epsilon) { }
510 
511  // W = (det(J) - 1)^2 - det(J) + (det(J)^2 + eps)^(1/2).
512  virtual double EvalW(const DenseMatrix &Jpt) const;
513 
514  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
515 
516  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
517  const double weight, DenseMatrix &A) const;
518 };
519 
520 /// 3D Shape (S) metric, untangling version of 303.
522 {
523 protected:
524  double &min_detT;
526 
527 public:
528  TMOP_Metric_313(double &mindet) : min_detT(mindet) { }
529 
530  // W = 1/3 |J|^2 / [det(J)-tau0]^(-2/3).
531  virtual double EvalW(const DenseMatrix &Jpt) const;
532 
533  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
534 
535  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
536  const double weight, DenseMatrix &A) const;
537 
538  virtual int Id() const { return 313; }
539 };
540 
541 /// 3D non-barrier Size (V) metric.
543 {
544 protected:
546 
547 public:
548  // W = (det(J) - 1)^2.
549  virtual double EvalW(const DenseMatrix &Jpt) const;
550 
551  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
552 
553  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
554  const double weight, DenseMatrix &A) const;
555 
556  virtual int Id() const { return 315; }
557 };
558 
559 /// 3D barrier Size (V) metric.
561 {
562 protected:
564 
565 public:
566  // W = 0.5( sqrt(det(J)) - 1 / sqrt(det(J)) )^2
567  // = 0.5( det(J) - 1 )^2 / det(J)
568  // = 0.5( det(J) + 1/det(J) ) - 1.
569  virtual double EvalW(const DenseMatrix &Jpt) const;
570 
571  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
572 
573  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
574  const double weight, DenseMatrix &A) const;
575 };
576 
577 /// 3D barrier Shape+Size (VS) metric.
579 {
580 protected:
582 
583 public:
584  // W = |J - J^-t|^2.
585  virtual double EvalW(const DenseMatrix &Jpt) const;
586 
587  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
588 
589  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
590  const double weight, DenseMatrix &A) const;
591 
592  virtual int Id() const { return 321; }
593 };
594 
595 /// 3D barrier Shape+Size (VS) metric (polyconvex).
597 {
598 protected:
599  double gamma;
601 
602 public:
603  TMOP_Metric_332(double gamma_) : gamma(gamma_),
606  {
607  // (1-gamma) mu_302 + gamma mu_315
608  AddQualityMetric(sh_metric, 1.-gamma_);
609  AddQualityMetric(sz_metric, gamma_);
610  }
611 
612  virtual int Id() const { return 332; }
613  double GetGamma() const { return gamma; }
614 
615  virtual ~TMOP_Metric_332() { delete sh_metric; delete sz_metric; }
616 };
617 
618 /// 3D barrier Shape+Size (VS) metric (polyconvex).
620 {
621 protected:
622  double gamma;
624 
625 public:
626  TMOP_Metric_333(double gamma_) : gamma(gamma_),
629  {
630  // (1-gamma) mu_302 + gamma mu_316
631  AddQualityMetric(sh_metric, 1.-gamma_);
632  AddQualityMetric(sz_metric, gamma_);
633  }
634 
635  virtual int Id() const { return 333; }
636  double GetGamma() const { return gamma; }
637 
638  virtual ~TMOP_Metric_333() { delete sh_metric; delete sz_metric; }
639 };
640 
641 /// Shifted barrier form of 3D metric 16 (volume, ideal barrier metric), 3D
643 {
644 protected:
645  double &tau0;
647 
648 public:
649  TMOP_Metric_352(double &t0): tau0(t0) {}
650 
651  // W = 0.5(det(J) - 1)^2 / (det(J) - tau0).
652  virtual double EvalW(const DenseMatrix &Jpt) const;
653 
654  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const;
655 
656  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
657  const double weight, DenseMatrix &A) const;
658 };
659 
660 /// A-metrics
661 /// 2D barrier Shape (S) metric (polyconvex).
663 {
664 protected:
666 
667 public:
668  // (1/4 alpha) | A - (adj A)^t W^t W / omega |^2
669  virtual double EvalW(const DenseMatrix &Jpt) const;
670 
671  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
672  { MFEM_ABORT("Not implemented"); }
673 
674  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
675  const double weight, DenseMatrix &A) const
676  { MFEM_ABORT("Not implemented"); }
677 };
678 
679 /// 2D barrier Size (V) metric (polyconvex).
681 {
682 protected:
684 
685 public:
686  // 0.5 * ( sqrt(alpha/omega) - sqrt(omega/alpha) )^2
687  virtual double EvalW(const DenseMatrix &Jpt) const;
688 
689  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
690  { MFEM_ABORT("Not implemented"); }
691 
692  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
693  const double weight, DenseMatrix &A) const
694  { MFEM_ABORT("Not implemented"); }
695 };
696 
697 /// 2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
699 {
700 protected:
702 
703 public:
704  // (1/alpha) | A - W |^2
705  virtual double EvalW(const DenseMatrix &Jpt) const;
706 
707  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
708  { MFEM_ABORT("Not implemented"); }
709 
710  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
711  const double weight, DenseMatrix &A) const
712  { MFEM_ABORT("Not implemented"); }
713 };
714 
715 /// 2D barrier Shape+Orientation (OS) metric (polyconvex).
717 {
718 protected:
720 
721 public:
722  // (1/2 alpha) | A - (|A|/|W|) W |^2
723  virtual double EvalW(const DenseMatrix &Jpt) const;
724 
725  virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
726  { MFEM_ABORT("Not implemented"); }
727 
728  virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS,
729  const double weight, DenseMatrix &A) const
730  { MFEM_ABORT("Not implemented"); }
731 };
732 
733 /// 2D barrier Shape+Size (VS) metric (polyconvex).
735 {
736 protected:
738  double gamma;
740 
741 public:
742  TMOP_AMetric_126(double gamma_) : gamma(gamma_),
745  {
746  // (1-gamma) nu_11 + gamma nu_14
747  AddQualityMetric(sh_metric, 1.-gamma_);
748  AddQualityMetric(sz_metric, gamma_);
749  }
750 
751  virtual ~TMOP_AMetric_126() { delete sh_metric; delete sz_metric; }
752 };
753 
754 /// Base class for limiting functions to be used in class TMOP_Integrator.
755 /** This class represents a scalar function f(x, x0, d), where x and x0 are
756  positions in physical space, and d is a reference physical distance
757  associated with the point x0. */
759 {
760 public:
761  /// Returns the limiting function, f(x, x0, d).
762  virtual double Eval(const Vector &x, const Vector &x0, double d) const = 0;
763 
764  /** @brief Returns the gradient of the limiting function f(x, x0, d) with
765  respect to x. */
766  virtual void Eval_d1(const Vector &x, const Vector &x0, double dist,
767  Vector &d1) const = 0;
768 
769  /** @brief Returns the Hessian of the limiting function f(x, x0, d) with
770  respect to x. */
771  virtual void Eval_d2(const Vector &x, const Vector &x0, double dist,
772  DenseMatrix &d2) const = 0;
773 
774  /// Virtual destructor.
775  virtual ~TMOP_LimiterFunction() { }
776 };
777 
778 /// Default limiter function in TMOP_Integrator.
780 {
781 public:
782  virtual double Eval(const Vector &x, const Vector &x0, double dist) const
783  {
784  MFEM_ASSERT(x.Size() == x0.Size(), "Bad input.");
785 
786  return 0.5 * x.DistanceSquaredTo(x0) / (dist * dist);
787  }
788 
789  virtual void Eval_d1(const Vector &x, const Vector &x0, double dist,
790  Vector &d1) const
791  {
792  MFEM_ASSERT(x.Size() == x0.Size(), "Bad input.");
793 
794  d1.SetSize(x.Size());
795  subtract(1.0 / (dist * dist), x, x0, d1);
796  }
797 
798  virtual void Eval_d2(const Vector &x, const Vector &x0, double dist,
799  DenseMatrix &d2) const
800  {
801  MFEM_ASSERT(x.Size() == x0.Size(), "Bad input.");
802 
803  d2.Diag(1.0 / (dist * dist), x.Size());
804  }
805 
807 };
808 
809 class FiniteElementCollection;
810 class FiniteElementSpace;
811 class ParFiniteElementSpace;
812 
814 {
815 protected:
816  // Owned.
819 
820 #ifdef MFEM_USE_MPI
821  // Owned.
824 #endif
825 
826  int dim, ncomp;
827 
828 public:
829  AdaptivityEvaluator() : mesh(NULL), fes(NULL)
830  {
831 #ifdef MFEM_USE_MPI
832  pmesh = NULL;
833  pfes = NULL;
834 #endif
835  }
836  virtual ~AdaptivityEvaluator();
837 
838  /** Specifies the Mesh and FiniteElementCollection of the solution that will
839  be evaluated. The given mesh will be copied into the internal object. */
840  void SetSerialMetaInfo(const Mesh &m,
841  const FiniteElementCollection &fec, int num_comp);
842 
843 #ifdef MFEM_USE_MPI
844  /// Parallel version of SetSerialMetaInfo.
845  void SetParMetaInfo(const ParMesh &m,
846  const FiniteElementCollection &fec, int num_comp);
847 #endif
848 
849  // TODO use GridFunctions to make clear it's on the ldofs?
850  virtual void SetInitialField(const Vector &init_nodes,
851  const Vector &init_field) = 0;
852 
853  virtual void ComputeAtNewPosition(const Vector &new_nodes,
854  Vector &new_field) = 0;
855 
856  void ClearGeometricFactors();
857 };
858 
859 /** @brief Base class representing target-matrix construction algorithms for
860  mesh optimization via the target-matrix optimization paradigm (TMOP). */
861 /** This class is used by class TMOP_Integrator to construct the target Jacobian
862  matrices (reference-element to target-element) at quadrature points. It
863  supports a set of algorithms chosen by the #TargetType enumeration.
864 
865  New target-matrix construction algorithms can be defined by deriving new
866  classes and overriding the methods ComputeElementTargets() and
867  ContainsVolumeInfo(). */
869 {
870 public:
871  /// Target-matrix construction algorithms supported by this class.
873  {
875  Ideal shape, unit size; the nodes are not used. */
877  Ideal shape, equal size/volume; the given nodes define the total target
878  volume; for each mesh element, the target volume is the average volume
879  multiplied by the volume scale, set with SetVolumeScale(). */
881  Ideal shape, given size/volume; the given nodes define the target
882  volume at all quadrature points. */
884  Given shape, given size/volume; the given nodes define the exact target
885  Jacobian matrix at all quadrature points. */
887  Full target tensor is specified at every quadrature point. */
888  };
889 
890 protected:
891  // Nodes that are used in ComputeElementTargets(), depending on target_type.
892  const GridFunction *nodes; // not owned
893  mutable double avg_volume;
894  double volume_scale;
896  bool uses_phys_coords; // see UsesPhysicalCoordinates()
897 
898 #ifdef MFEM_USE_MPI
899  MPI_Comm comm;
900  bool Parallel() const { return (comm != MPI_COMM_NULL); }
901 #else
902  bool Parallel() const { return false; }
903 #endif
904 
905  // should be called only if avg_volume == 0.0, i.e. avg_volume is not
906  // computed yet
907  void ComputeAvgVolume() const;
908 
909  template<int DIM>
911  const IntegrationRule &ir,
912  const Vector &xe,
913  DenseTensor &Jtr) const;
914 
915  // CPU fallback that uses ComputeElementTargets()
917  const IntegrationRule &ir,
918  const Vector &xe,
919  DenseTensor &Jtr) const;
920 
921 public:
922  /// Constructor for use in serial
924  : nodes(NULL), avg_volume(), volume_scale(1.0), target_type(ttype),
925  uses_phys_coords(false)
926  {
927 #ifdef MFEM_USE_MPI
928  comm = MPI_COMM_NULL;
929 #endif
930  }
931 #ifdef MFEM_USE_MPI
932  /// Constructor for use in parallel
933  TargetConstructor(TargetType ttype, MPI_Comm mpicomm)
934  : nodes(NULL), avg_volume(), volume_scale(1.0), target_type(ttype),
935  uses_phys_coords(false), comm(mpicomm) { }
936 #endif
937  virtual ~TargetConstructor() { }
938 
939  /** @brief Set the nodes to be used in the target-matrix construction.
940 
941  This method should be called every time the target nodes are updated
942  externally and recomputation of the target average volume is needed. The
943  nodes are used by all target types except IDEAL_SHAPE_UNIT_SIZE. */
944  void SetNodes(const GridFunction &n) { nodes = &n; avg_volume = 0.0; }
945 
946  /** @brief Get the nodes to be used in the target-matrix construction. */
947  const GridFunction *GetNodes() const { return nodes; }
948 
949  /// Used by target type IDEAL_SHAPE_EQUAL_SIZE. The default volume scale is 1.
950  void SetVolumeScale(double vol_scale) { volume_scale = vol_scale; }
951 
953 
954  /** @brief Return true if the methods ComputeElementTargets(),
955  ComputeAllElementTargets(), and ComputeElementTargetsGradient() use the
956  physical node coordinates provided by the parameters 'elfun', or 'xe'. */
957  bool UsesPhysicalCoordinates() const { return uses_phys_coords; }
958 
959  /// Checks if the target matrices contain non-trivial size specification.
960  virtual bool ContainsVolumeInfo() const;
961 
962  /** @brief Given an element and quadrature rule, computes ref->target
963  transformation Jacobians for each quadrature point in the element.
964  The physical positions of the element's nodes are given by @a elfun. */
965  virtual void ComputeElementTargets(int e_id, const FiniteElement &fe,
966  const IntegrationRule &ir,
967  const Vector &elfun,
968  DenseTensor &Jtr) const;
969 
970  /** @brief Computes reference-to-target transformation Jacobians for all
971  quadrature points in all elements.
972 
973  @param[in] fes The nodal FE space
974  @param[in] ir The quadrature rule to use for all elements
975  @param[in] xe E-vector with the current physical coordinates/positions;
976  this parameter is used only when needed by the target
977  constructor, see UsesPhysicalCoordinates()
978  @param[out] Jtr The computed ref->target Jacobian matrices. */
979  virtual void ComputeAllElementTargets(const FiniteElementSpace &fes,
980  const IntegrationRule &ir,
981  const Vector &xe,
982  DenseTensor &Jtr) const;
983 
984  virtual void ComputeElementTargetsGradient(const IntegrationRule &ir,
985  const Vector &elfun,
987  DenseTensor &dJtr) const;
988 };
989 
991 {
992 public:
993  explicit TMOPMatrixCoefficient(int dim) : MatrixCoefficient(dim, dim) { }
994 
995  /** @brief Evaluate the derivative of the matrix coefficient with respect to
996  @a comp in the element described by @a T at the point @a ip, storing the
997  result in @a K. */
998  virtual void EvalGrad(DenseMatrix &K, ElementTransformation &T,
999  const IntegrationPoint &ip, int comp) = 0;
1000 
1002 };
1003 
1005 {
1006 protected:
1007  // Analytic target specification.
1011 
1012 public:
1014  : TargetConstructor(ttype),
1015  scalar_tspec(NULL), vector_tspec(NULL), matrix_tspec(NULL)
1016  { uses_phys_coords = true; }
1017 
1018  virtual void SetAnalyticTargetSpec(Coefficient *sspec,
1019  VectorCoefficient *vspec,
1020  TMOPMatrixCoefficient *mspec);
1021 
1022  /** @brief Given an element and quadrature rule, computes ref->target
1023  transformation Jacobians for each quadrature point in the element.
1024  The physical positions of the element's nodes are given by @a elfun. */
1025  virtual void ComputeElementTargets(int e_id, const FiniteElement &fe,
1026  const IntegrationRule &ir,
1027  const Vector &elfun,
1028  DenseTensor &Jtr) const;
1029 
1030  virtual void ComputeAllElementTargets(const FiniteElementSpace &fes,
1031  const IntegrationRule &ir,
1032  const Vector &xe,
1033  DenseTensor &Jtr) const;
1034 
1035  virtual void ComputeElementTargetsGradient(const IntegrationRule &ir,
1036  const Vector &elfun,
1038  DenseTensor &dJtr) const;
1039 };
1040 
1041 #ifdef MFEM_USE_MPI
1042 class ParGridFunction;
1043 #endif
1044 
1046 {
1047 protected:
1048  // Discrete target specification.
1049  // Data is owned, updated by UpdateTargetSpecification.
1051  Vector tspec; //eta(x)
1053  Vector tspec_pert1h; //eta(x+h)
1054  Vector tspec_pert2h; //eta(x+2*h)
1055  Vector tspec_pertmix; //eta(x+h,y+h)
1056  // The order inside these perturbation vectors (e.g. in 2D) is
1057  // eta1(x+h,y), eta2(x+h,y) ... etan(x+h,y), eta1(x,y+h), eta2(x,y+h) ...
1058  // same for tspec_pert2h and tspec_pertmix.
1059 
1060  // Components of Target Jacobian at each quadrature point of an element. This
1061  // is required for computation of the derivative using chain rule.
1063 
1064  // Note: do not use the Nodes of this space as they may not be on the
1065  // positions corresponding to the values of tspec.
1068 
1069  // These flags can be used by outside functions to avoid recomputing the
1070  // tspec and tspec_perth fields again on the same mesh.
1072 
1073  // Evaluation of the discrete target specification on different meshes.
1074  // Owned.
1076 
1077  void SetDiscreteTargetBase(const GridFunction &tspec_);
1078  void SetTspecAtIndex(int idx, const GridFunction &tspec_);
1080 #ifdef MFEM_USE_MPI
1081  void SetTspecAtIndex(int idx, const ParGridFunction &tspec_);
1082  void FinalizeParDiscreteTargetSpec(const ParGridFunction &tspec_);
1083 #endif
1084 
1085 public:
1087  : TargetConstructor(ttype),
1088  ncomp(0),
1089  sizeidx(-1), skewidx(-1), aspectratioidx(-1), orientationidx(-1),
1091  tspec_fes(NULL), tspec_fesv(NULL),
1092  good_tspec(false), good_tspec_grad(false), good_tspec_hess(false),
1093  adapt_eval(NULL) { }
1094 
1096  {
1097  delete adapt_eval;
1098  delete tspec_fes;
1099  delete tspec_fesv;
1100  }
1101 
1102  /** @name Target specification methods.
1103  The following methods are used to specify geometric parameters of the
1104  targets when these parameters are given by discrete FE functions.
1105  Note that every GridFunction given to the Set methods must use a
1106  H1_FECollection of the same order. The number of components must
1107  correspond to the type of geometric parameter and dimension.
1108 
1109  @param[in] tspec_ Input values of a geometric parameter. Note that
1110  the methods in this class support only functions that
1111  use H1_FECollection collection of the same order. */
1112  ///@{
1113  virtual void SetSerialDiscreteTargetSpec(const GridFunction &tspec_);
1114  virtual void SetSerialDiscreteTargetSize(const GridFunction &tspec_);
1115  virtual void SetSerialDiscreteTargetSkew(const GridFunction &tspec_);
1116  virtual void SetSerialDiscreteTargetAspectRatio(const GridFunction &tspec_);
1117  virtual void SetSerialDiscreteTargetOrientation(const GridFunction &tspec_);
1118 #ifdef MFEM_USE_MPI
1119  virtual void SetParDiscreteTargetSpec(const ParGridFunction &tspec_);
1120  virtual void SetParDiscreteTargetSize(const ParGridFunction &tspec_);
1121  virtual void SetParDiscreteTargetSkew(const ParGridFunction &tspec_);
1122  virtual void SetParDiscreteTargetAspectRatio(const ParGridFunction &tspec_);
1123  virtual void SetParDiscreteTargetOrientation(const ParGridFunction &tspec_);
1124 #endif
1125  ///@}
1126 
1127  /// Used in combination with the Update methods to avoid extra computations.
1129  { good_tspec = good_tspec_grad = good_tspec_hess = false; }
1130 
1131  /** Used to update the target specification after the mesh has changed. The
1132  new mesh positions are given by new_x. If @a use_flags is true, repeated
1133  calls won't do anything until ResetUpdateFlags() is called. */
1134  void UpdateTargetSpecification(const Vector &new_x, bool use_flag = false);
1135 
1136  void UpdateTargetSpecification(Vector &new_x, Vector &IntData);
1137 
1140  int nodenum, int idir,
1141  const Vector &IntData);
1142 
1144 
1145  /** Used for finite-difference based computations. Computes the target
1146  specifications after a mesh perturbation in x or y direction.
1147  If @a use_flags is true, repeated calls won't do anything until
1148  ResetUpdateFlags() is called. */
1149  void UpdateGradientTargetSpecification(const Vector &x, double dx,
1150  bool use_flag = false);
1151  /** Used for finite-difference based computations. Computes the target
1152  specifications after two mesh perturbations in x and/or y direction.
1153  If @a use_flags is true, repeated calls won't do anything until
1154  ResetUpdateFlags() is called. */
1155  void UpdateHessianTargetSpecification(const Vector &x, double dx,
1156  bool use_flag = false);
1157 
1159  {
1160  if (adapt_eval) { delete adapt_eval; }
1161  adapt_eval = ae;
1162  }
1163 
1164  const Vector &GetTspecPert1H() { return tspec_pert1h; }
1165  const Vector &GetTspecPert2H() { return tspec_pert2h; }
1167 
1168  /** @brief Given an element and quadrature rule, computes ref->target
1169  transformation Jacobians for each quadrature point in the element.
1170  The physical positions of the element's nodes are given by @a elfun.
1171  Note that this function assumes that UpdateTargetSpecification() has
1172  been called with the position vector corresponding to @a elfun. */
1173  virtual void ComputeElementTargets(int e_id, const FiniteElement &fe,
1174  const IntegrationRule &ir,
1175  const Vector &elfun,
1176  DenseTensor &Jtr) const;
1177 
1178  virtual void ComputeAllElementTargets(const FiniteElementSpace &fes,
1179  const IntegrationRule &ir,
1180  const Vector &xe,
1181  DenseTensor &Jtr) const;
1182 
1183  virtual void ComputeElementTargetsGradient(const IntegrationRule &ir,
1184  const Vector &elfun,
1186  DenseTensor &dJtr) const;
1187 };
1188 
1189 class TMOPNewtonSolver;
1190 
1191 /** @brief A TMOP integrator class based on any given TMOP_QualityMetric and
1192  TargetConstructor.
1193 
1194  Represents @f$ \int W(Jpt) dx @f$ over a target zone, where W is the
1195  metric's strain energy density function, and Jpt is the Jacobian of the
1196  target->physical coordinates transformation. The virtual target zone is
1197  defined by the TargetConstructor. */
1199 {
1200 protected:
1201  friend class TMOPNewtonSolver;
1202  friend class TMOPComboIntegrator;
1203 
1205  const TargetConstructor *targetC; // not owned
1206 
1207  // Custom integration rules.
1210 
1211  // Weight Coefficient multiplying the quality metric term.
1212  Coefficient *coeff1; // not owned, if NULL -> coeff1 is 1.
1213  // Normalization factor for the metric term.
1215 
1216  // Nodes and weight Coefficient used for "limiting" the TMOP_Integrator.
1217  // These are both NULL when there is no limiting.
1218  // The class doesn't own nodes0 and coeff0.
1221  // Limiting reference distance. Not owned.
1223  // Limiting function. Owned.
1225  // Normalization factor for the limiting term.
1226  double lim_normal;
1227 
1228  // Adaptive limiting.
1229  const GridFunction *zeta_0; // Not owned.
1230  GridFunction *zeta; // Owned. Updated by adapt_eval.
1231  Coefficient *coeff_zeta; // Not owned.
1233 
1235 
1236  // Parameters for FD-based Gradient & Hessian calculation.
1237  bool fdflag;
1238  double dx;
1239  double dxscale;
1240  // Specifies that ComputeElementTargets is being called by a FD function.
1241  // It's used to skip terms that have exact derivative calculations.
1243  // Compute the exact action of the Integrator (includes derivative of the
1244  // target with respect to spatial position)
1246 
1249 
1250  // Jrt: the inverse of the ref->target Jacobian, Jrt = Jtr^{-1}.
1251  // Jpr: the ref->physical transformation Jacobian, Jpr = PMatI^t DS.
1252  // Jpt: the target->physical transformation Jacobian, Jpt = Jpr Jrt.
1253  // P: represents dW_d(Jtp) (dim x dim).
1254  // DSh: gradients of reference shape functions (dof x dim).
1255  // DS: gradients of the shape functions in the target configuration,
1256  // DS = DSh Jrt (dof x dim).
1257  // PMatI: current coordinates of the nodes (dof x dim).
1258  // PMat0: reshaped view into the local element contribution to the operator
1259  // output - the result of AssembleElementVector() (dof x dim).
1261 
1262  // PA extension
1263  // ------------
1264  // E: Q-vector for TMOP-energy
1265  // O: Q-Vector of 1.0, used to compute sums using the dot product kernel.
1266  // X0: E-vector for initial nodal coordinates used for limiting.
1267  // H: Q-Vector for Hessian associated with the metric term.
1268  // C0: Q-Vector for spatial weight used for the limiting term.
1269  // LD: E-Vector constructed using limiting distance grid function (delta).
1270  // H0: Q-Vector for Hessian associated with the limiting term.
1271  //
1272  // maps: Dof2Quad map for fespace associate with nodal coordinates.
1273  // maps_lim: Dof2Quad map for fespace associated with the limiting distance
1274  // grid function.
1275  //
1276  // Jtr_debug_grad
1277  // We keep track if Jtr was set by AssembleGradPA() in Jtr_debug_grad: it
1278  // is set to true by AssembleGradPA(); any other call to
1279  // ComputeAllElementTargets() will set the flag to false. This flag will
1280  // be used to check that Jtr is the one set by AssembleGradPA() when
1281  // performing operations with the gradient like AddMultGradPA() and
1282  // AssembleGradDiagonalPA().
1283  //
1284  // TODO:
1285  // * Merge LD, C0, H0 into one scalar Q-vector
1286  struct
1287  {
1288  bool enabled;
1289  int dim, ne, nq;
1290  mutable DenseTensor Jtr;
1291  mutable bool Jtr_needs_update;
1292  mutable bool Jtr_debug_grad;
1293  mutable Vector E, O, X0, H, C0, LD, H0;
1294  const DofToQuad *maps;
1295  const DofToQuad *maps_lim = nullptr;
1299  } PA;
1300 
1302  double &metric_energy, double &lim_energy);
1303 
1306  const Vector &elfun, Vector &elvect);
1307 
1308  void AssembleElementGradExact(const FiniteElement &el,
1310  const Vector &elfun, DenseMatrix &elmat);
1311 
1312  void AssembleElementVectorFD(const FiniteElement &el,
1314  const Vector &elfun, Vector &elvect);
1315 
1316  // Assumes that AssembleElementVectorFD has been called.
1317  void AssembleElementGradFD(const FiniteElement &el,
1319  const Vector &elfun, DenseMatrix &elmat);
1320 
1321  void AssembleElemVecAdaptLim(const FiniteElement &el, const Vector &weights,
1323  const IntegrationRule &ir, DenseMatrix &m);
1324  void AssembleElemGradAdaptLim(const FiniteElement &el, const Vector &weights,
1326  const IntegrationRule &ir, DenseMatrix &m);
1327 
1328  double GetFDDerivative(const FiniteElement &el,
1330  Vector &elfun, const int nodenum,const int idir,
1331  const double baseenergy, bool update_stored);
1332 
1333  /** @brief Determines the perturbation, h, for FD-based approximation. */
1334  void ComputeFDh(const Vector &x, const FiniteElementSpace &fes);
1335 #ifdef MFEM_USE_MPI
1336  void ComputeFDh(const Vector &x, const ParFiniteElementSpace &pfes);
1337 #endif
1338  void ComputeMinJac(const Vector &x, const FiniteElementSpace &fes);
1339 
1340  void UpdateAfterMeshChange(const Vector &new_x);
1341 
1343  {
1344  nodes0 = NULL; coeff0 = NULL; lim_dist = NULL;
1345  delete lim_func; lim_func = NULL;
1346  }
1347 
1349  {
1350  if (IntegRules)
1351  {
1352  return IntegRules->Get(el.GetGeomType(), integ_order);
1353  }
1354  return (IntRule) ? *IntRule
1355  /* */ : IntRules.Get(el.GetGeomType(), 2*el.GetOrder() + 3);
1356  }
1358  {
1359  // TODO the energy most likely needs less integration points.
1360  return EnergyIntegrationRule(el);
1361  }
1363  {
1364  // TODO the action and energy most likely need less integration points.
1365  return EnergyIntegrationRule(el);
1366  }
1367 
1368  // Auxiliary PA methods
1369  void AssembleGradPA_2D(const Vector&) const;
1370  void AssembleGradPA_3D(const Vector&) const;
1371  void AssembleGradPA_C0_2D(const Vector&) const;
1372  void AssembleGradPA_C0_3D(const Vector&) const;
1373 
1374  double GetLocalStateEnergyPA_2D(const Vector&) const;
1375  double GetLocalStateEnergyPA_C0_2D(const Vector&) const;
1376  double GetLocalStateEnergyPA_3D(const Vector&) const;
1377  double GetLocalStateEnergyPA_C0_3D(const Vector&) const;
1378 
1379  void AddMultPA_2D(const Vector&, Vector&) const;
1380  void AddMultPA_3D(const Vector&, Vector&) const;
1381  void AddMultPA_C0_2D(const Vector&, Vector&) const;
1382  void AddMultPA_C0_3D(const Vector&, Vector&) const;
1383 
1384  void AddMultGradPA_2D(const Vector&, Vector&) const;
1385  void AddMultGradPA_3D(const Vector&, Vector&) const;
1386  void AddMultGradPA_C0_2D(const Vector&, Vector&) const;
1387  void AddMultGradPA_C0_3D(const Vector&, Vector&) const;
1388 
1389  void AssembleDiagonalPA_2D(Vector&) const;
1390  void AssembleDiagonalPA_3D(Vector&) const;
1391  void AssembleDiagonalPA_C0_2D(Vector&) const;
1392  void AssembleDiagonalPA_C0_3D(Vector&) const;
1393 
1394  void AssemblePA_Limiting();
1395  void ComputeAllElementTargets(const Vector &xe = Vector()) const;
1396 
1397 public:
1398  /** @param[in] m TMOP_QualityMetric that will be integrated (not owned).
1399  @param[in] tc Target-matrix construction algorithm to use (not owned). */
1401  : metric(m), targetC(tc), IntegRules(NULL), integ_order(-1),
1402  coeff1(NULL), metric_normal(1.0),
1403  nodes0(NULL), coeff0(NULL),
1404  lim_dist(NULL), lim_func(NULL), lim_normal(1.0),
1405  zeta_0(NULL), zeta(NULL), coeff_zeta(NULL), adapt_eval(NULL),
1406  discr_tc(dynamic_cast<DiscreteAdaptTC *>(tc)),
1407  fdflag(false), dxscale(1.0e3), fd_call_flag(false), exact_action(false)
1408  { PA.enabled = false; }
1409 
1410  ~TMOP_Integrator();
1411 
1412  /// Release the device memory of large PA allocations. This will copy device
1413  /// memory back to the host before releasing.
1414  void ReleasePADeviceMemory();
1415 
1416  /// Prescribe a set of integration rules; relevant for mixed meshes.
1417  /** This function has priority over SetIntRule(), if both are called. */
1418  void SetIntegrationRules(IntegrationRules &irules, int order)
1419  {
1420  IntegRules = &irules;
1421  integ_order = order;
1422  }
1423 
1424  /// Sets a scaling Coefficient for the quality metric term of the integrator.
1425  /** With this addition, the integrator becomes
1426  @f$ \int w1 W(Jpt) dx @f$.
1427 
1428  Note that the Coefficient is evaluated in the physical configuration and
1429  not in the target configuration which may be undefined. */
1430  void SetCoefficient(Coefficient &w1) { coeff1 = &w1; }
1431 
1432  /** @brief Limiting of the mesh displacements (general version).
1433 
1434  Adds the term @f$ \int w_0 f(x, x_0, d) dx @f$, where f is a measure of
1435  the displacement between x and x_0, given the max allowed displacement d.
1436 
1437  @param[in] n0 Original mesh node coordinates (x0 above).
1438  @param[in] dist Allowed displacement in physical space (d above).
1439  @param[in] w0 Coefficient scaling the limiting integral.
1440  @param[in] lfunc TMOP_LimiterFunction defining the function f. If
1441  NULL, a TMOP_QuadraticLimiter will be used. The
1442  TMOP_Integrator assumes ownership of this pointer. */
1443  void EnableLimiting(const GridFunction &n0, const GridFunction &dist,
1444  Coefficient &w0, TMOP_LimiterFunction *lfunc = NULL);
1445 
1446  /** @brief Adds a limiting term to the integrator with limiting distance
1447  function (@a dist in the general version of the method) equal to 1. */
1448  void EnableLimiting(const GridFunction &n0, Coefficient &w0,
1449  TMOP_LimiterFunction *lfunc = NULL);
1450 
1451  /** @brief Restriction of the node positions to certain regions.
1452 
1453  Adds the term @f$ \int c (z(x) - z_0(x_0))^2 @f$, where z0(x0) is a given
1454  function on the starting mesh, and z(x) is its image on the new mesh.
1455  Minimizing this, means that a node at x0 is allowed to move to a
1456  position x(x0) only if z(x) ~ z0(x0).
1457  Such term can be used for tangential mesh relaxation.
1458 
1459  @param[in] z0 Function z0 that controls the adaptive limiting.
1460  @param[in] coeff Coefficient c for the above integral.
1461  @param[in] ae AdaptivityEvaluator to compute z(x) from z0(x0). */
1462  void EnableAdaptiveLimiting(const GridFunction &z0, Coefficient &coeff,
1463  AdaptivityEvaluator &ae);
1464 #ifdef MFEM_USE_MPI
1465  /// Parallel support for adaptive limiting.
1466  void EnableAdaptiveLimiting(const ParGridFunction &z0, Coefficient &coeff,
1467  AdaptivityEvaluator &ae);
1468 #endif
1469 
1470  /// Update the original/reference nodes used for limiting.
1471  void SetLimitingNodes(const GridFunction &n0) { nodes0 = &n0; }
1472 
1473  /** @brief Computes the integral of W(Jacobian(Trt)) over a target zone.
1474  @param[in] el Type of FiniteElement.
1475  @param[in] T Mesh element transformation.
1476  @param[in] elfun Physical coordinates of the zone. */
1477  virtual double GetElementEnergy(const FiniteElement &el,
1479  const Vector &elfun);
1480 
1481  virtual void AssembleElementVector(const FiniteElement &el,
1483  const Vector &elfun, Vector &elvect);
1484 
1485  virtual void AssembleElementGrad(const FiniteElement &el,
1487  const Vector &elfun, DenseMatrix &elmat);
1488 
1489  // PA extension
1491  virtual void AssemblePA(const FiniteElementSpace&);
1492 
1493  virtual void AssembleGradPA(const Vector&, const FiniteElementSpace&);
1494 
1495  virtual double GetLocalStateEnergyPA(const Vector&) const;
1496 
1497  virtual void AddMultPA(const Vector&, Vector&) const;
1498 
1499  virtual void AddMultGradPA(const Vector&, Vector&) const;
1500 
1501  virtual void AssembleGradDiagonalPA(Vector&) const;
1502 
1504 
1505  /** @brief Computes the normalization factors of the metric and limiting
1506  integrals using the mesh position given by @a x. */
1507  void EnableNormalization(const GridFunction &x);
1508 #ifdef MFEM_USE_MPI
1509  void ParEnableNormalization(const ParGridFunction &x);
1510 #endif
1511 
1512  /** @brief Enables FD-based approximation and computes dx. */
1513  void EnableFiniteDifferences(const GridFunction &x);
1514 #ifdef MFEM_USE_MPI
1516 #endif
1517 
1518  void SetFDhScale(double dxscale_) { dxscale = dxscale_; }
1519  bool GetFDFlag() const { return fdflag; }
1520  double GetFDh() const { return dx; }
1521 
1522  /** @brief Flag to control if exact action of Integration is effected. */
1523  void SetExactActionFlag(bool flag_) { exact_action = flag_; }
1524 };
1525 
1527 {
1528 protected:
1529  // Integrators in the combination. Owned.
1531 
1532 public:
1534 
1536  {
1537  for (int i = 0; i < tmopi.Size(); i++) { delete tmopi[i]; }
1538  }
1539 
1540  /// Adds a new TMOP_Integrator to the combination.
1541  void AddTMOPIntegrator(TMOP_Integrator *ti) { tmopi.Append(ti); }
1542 
1544 
1545  /// Adds the limiting term to the first integrator. Disables it for the rest.
1546  void EnableLimiting(const GridFunction &n0, const GridFunction &dist,
1547  Coefficient &w0, TMOP_LimiterFunction *lfunc = NULL);
1548 
1549  /** @brief Adds the limiting term to the first integrator. Disables it for
1550  the rest (@a dist in the general version of the method) equal to 1. */
1551  void EnableLimiting(const GridFunction &n0, Coefficient &w0,
1552  TMOP_LimiterFunction *lfunc = NULL);
1553 
1554  /// Update the original/reference nodes used for limiting.
1555  void SetLimitingNodes(const GridFunction &n0);
1556 
1557  virtual double GetElementEnergy(const FiniteElement &el,
1559  const Vector &elfun);
1560  virtual void AssembleElementVector(const FiniteElement &el,
1562  const Vector &elfun, Vector &elvect);
1563  virtual void AssembleElementGrad(const FiniteElement &el,
1565  const Vector &elfun, DenseMatrix &elmat);
1566 
1567  /// Normalization factor that considers all integrators in the combination.
1568  void EnableNormalization(const GridFunction &x);
1569 #ifdef MFEM_USE_MPI
1570  void ParEnableNormalization(const ParGridFunction &x);
1571 #endif
1572 
1573  // PA extension
1575  virtual void AssemblePA(const FiniteElementSpace&);
1576  virtual void AssembleGradPA(const Vector&, const FiniteElementSpace&);
1577  virtual double GetLocalStateEnergyPA(const Vector&) const;
1578  virtual void AddMultPA(const Vector&, Vector&) const;
1579  virtual void AddMultGradPA(const Vector&, Vector&) const;
1580  virtual void AssembleGradDiagonalPA(Vector&) const;
1581 };
1582 
1583 /// Interpolates the @a metric's values at the nodes of @a metric_gf.
1584 /** Assumes that @a metric_gf's FiniteElementSpace is initialized. */
1585 void InterpolateTMOP_QualityMetric(TMOP_QualityMetric &metric,
1586  const TargetConstructor &tc,
1587  const Mesh &mesh, GridFunction &metric_gf);
1588 }
1589 
1590 #endif
Abstract class for all finite elements.
Definition: fe.hpp:243
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:180
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:343
void AssembleGradPA_2D(const Vector &) const
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:344
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:74
virtual void SetParDiscreteTargetSize(const ParGridFunction &tspec_)
Definition: tmop.cpp:1347
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:73
Shifted barrier form of metric 56 (area, ideal barrier metric), 2D.
Definition: tmop.hpp:430
Shifted barrier form of 3D metric 16 (volume, ideal barrier metric), 3D.
Definition: tmop.hpp:642
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:961
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:314
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:506
virtual void SetInitialField(const Vector &init_nodes, const Vector &init_field)=0
void AddMultGradPA_C0_3D(const Vector &, Vector &) const
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...
void AddMultPA_C0_2D(const Vector &, Vector &) const
void SetSerialMetaInfo(const Mesh &m, const FiniteElementCollection &fec, int num_comp)
Definition: tmop.cpp:2148
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:150
Class for an integration rule - an Array of IntegrationPoint.
Definition: intrules.hpp:90
VectorCoefficient * vector_tspec
Definition: tmop.hpp:1009
virtual void AddMultGradPA(const Vector &, Vector &) const
Method for partially assembled gradient action.
void EnableFiniteDifferences(const GridFunction &x)
Enables FD-based approximation and computes dx.
Definition: tmop.cpp:3070
const TargetType target_type
Definition: tmop.hpp:895
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:728
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:725
Class for grid function - Vector with associated FE space.
Definition: gridfunc.hpp:30
void UpdateAfterMeshChange(const Vector &new_x)
Definition: tmop.cpp:3042
DenseMatrix PMatO
Definition: tmop.hpp:1260
virtual void AddMultPA(const Vector &, Vector &) const
Method for partially assembled action.
Definition: tmop.cpp:3228
DenseTensor Jtr
Definition: tmop.hpp:1290
double & min_detT
Definition: tmop.hpp:256
3D barrier Shape+Size (VS) metric.
Definition: tmop.hpp:578
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:525
const DenseMatrix * Jtr
Definition: tmop.hpp:26
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:581
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
Definition: intrules.cpp:920
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:674
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:402
Base class for vector Coefficients that optionally depend on time and space.
double GetLocalStateEnergyPA_3D(const Vector &) const
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:177
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:692
DenseMatrix Jrt
Definition: tmop.hpp:1260
const GridFunction * lim_dist
Definition: tmop.hpp:1222
virtual void SetSerialDiscreteTargetOrientation(const GridFunction &tspec_)
Definition: tmop.cpp:1454
virtual double GetElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun)
Compute the local energy.
Definition: tmop.cpp:3127
double epsilon
Definition: ex25.cpp:140
Coefficient * coeff0
Definition: tmop.hpp:1220
virtual ~TMOP_Metric_333()
Definition: tmop.hpp:638
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:798
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
double GetGamma() const
Definition: tmop.hpp:613
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:218
TMOP_AMetric_126(double gamma_)
Definition: tmop.hpp:742
virtual void AssemblePA(const FiniteElementSpace &)
Method defining partial assembly.
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:291
const double eps
Definition: tmop.hpp:505
void EnableNormalization(const GridFunction &x)
Computes the normalization factors of the metric and limiting integrals using the mesh position given...
Definition: tmop.cpp:2938
void SetSize(int s)
Resize the vector to size s.
Definition: vector.hpp:513
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:3254
3D barrier Shape (S) metric.
Definition: tmop.hpp:484
TMOP_QualityMetric * metric
Definition: tmop.hpp:1204
void SetAdaptivityEvaluator(AdaptivityEvaluator *ae)
Definition: tmop.hpp:1158
virtual ~TMOP_Metric_332()
Definition: tmop.hpp:615
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:308
virtual ~TMOP_LimiterFunction()
Virtual destructor.
Definition: tmop.hpp:775
Base class for limiting functions to be used in class TMOP_Integrator.
Definition: tmop.hpp:758
virtual double EvalW(const DenseMatrix &Jpt) const =0
Evaluate the strain energy density function, W = W(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:935
const GridFunction * GetNodes() const
Get the nodes to be used in the target-matrix construction.
Definition: tmop.hpp:947
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 void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const
Definition: tmop.cpp:1721
3D non-barrier Skew metric.
Definition: tmop.hpp:141
2D barrier Shape+Size (VS) metric (polyconvex).
Definition: tmop.hpp:358
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:866
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:793
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:202
DenseMatrix Jpr
Definition: tmop.hpp:1260
IntegrationRules * IntegRules
Definition: tmop.hpp:1208
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...
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:363
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:739
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:584
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:993
void SetFDhScale(double dxscale_)
Definition: tmop.hpp:1518
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:111
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
Definition: fe.hpp:327
virtual void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const
Definition: tmop.cpp:1270
Container class for integration rules.
Definition: intrules.hpp:311
ParFiniteElementSpace * pfes
Definition: tmop.hpp:823
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:664
Data type dense matrix using column-major storage.
Definition: densemat.hpp:23
3D barrier Shape (S) metric.
Definition: tmop.hpp:466
int Size() const
Returns the size of the vector.
Definition: vector.hpp:190
void SetVolumeScale(double vol_scale)
Used by target type IDEAL_SHAPE_EQUAL_SIZE. The default volume scale is 1.
Definition: tmop.hpp:950
void AssembleElemGradAdaptLim(const FiniteElement &el, const Vector &weights, IsoparametricTransformation &Tpr, const IntegrationRule &ir, DenseMatrix &m)
Definition: tmop.cpp:2693
2D barrier shape (S) metric (polyconvex).
Definition: tmop.hpp:186
void FinalizeSerialDiscreteTargetSpec()
Definition: tmop.cpp:1463
void EnableAdaptiveLimiting(const GridFunction &z0, Coefficient &coeff, AdaptivityEvaluator &ae)
Restriction of the node positions to certain regions.
Definition: tmop.cpp:2239
virtual void AddMultPA(const Vector &, Vector &) const
Method for partially assembled action.
3D non-barrier Size (V) metric.
Definition: tmop.hpp:542
2D barrier size (V) metric (polyconvex).
Definition: tmop.hpp:340
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:737
void SetIntegrationRules(IntegrationRules &irules, int order)
Prescribe a set of integration rules; relevant for mixed meshes.
Definition: tmop.hpp:1418
virtual ~DiscreteAdaptTC()
Definition: tmop.hpp:1095
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:719
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:122
void EnableNormalization(const GridFunction &x)
Normalization factor that considers all integrators in the combination.
Definition: tmop.cpp:3171
2D barrier Shape+Size (VS) metric (polyconvex).
Definition: tmop.hpp:734
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:596
Coefficient * coeff1
Definition: tmop.hpp:1212
double & min_detT
Definition: tmop.hpp:524
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:162
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:520
Abstract parallel finite element space.
Definition: pfespace.hpp:28
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:147
virtual void AssemblePA(const FiniteElementSpace &)
Method defining partial assembly.
Definition: tmop.cpp:3203
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:200
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:225
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:244
Structure for storing mesh geometric factors: coordinates, Jacobians, and determinants of the Jacobia...
Definition: mesh.hpp:1555
const IntegrationRule * ir
Definition: tmop.hpp:1298
void SetExactActionFlag(bool flag_)
Flag to control if exact action of Integration is effected.
Definition: tmop.hpp:1523
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:326
void AssembleElementVectorFD(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
Definition: tmop.cpp:2779
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:480
const GridFunction * nodes
Definition: tmop.hpp:892
virtual void SetSerialDiscreteTargetSkew(const GridFunction &tspec_)
Definition: tmop.cpp:1437
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:556
struct mfem::TMOP_Integrator::@13 PA
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:390
void UpdateGradientTargetSpecification(const Vector &x, double dx, bool use_flag=false)
Definition: tmop.cpp:2068
2D non-barrier Aspect ratio metric.
Definition: tmop.hpp:156
TMOP_Metric_080(double gamma_)
Definition: tmop.hpp:366
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:855
2D barrier Shape+Size (VS) metric (not polyconvex).
Definition: tmop.hpp:204
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:623
Default limiter function in TMOP_Integrator.
Definition: tmop.hpp:779
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-&gt;target transformation Jacobians for each quadratur...
Definition: tmop.cpp:1535
void AssembleElementGradExact(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
Definition: tmop.cpp:2548
Array< Vector * > ElemDer
Definition: tmop.hpp:1247
virtual ~TMOP_AMetric_126()
Definition: tmop.hpp:751
const Vector & GetTspecPertMixH()
Definition: tmop.hpp:1166
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:3098
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:432
double GetFDh() const
Definition: tmop.hpp:1520
2D Shifted barrier form of shape metric (mu_2).
Definition: tmop.hpp:253
TMOP_Metric_313(double &mindet)
Definition: tmop.hpp:528
TMOP_Metric_352(double &t0)
Definition: tmop.hpp:649
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-&gt;target transformation Jacobians for each quadratur...
Definition: tmop.cpp:1236
GridFunction * zeta
Definition: tmop.hpp:1230
AdaptivityEvaluator * adapt_eval
Definition: tmop.hpp:1232
Coefficient * coeff_zeta
Definition: tmop.hpp:1231
Coefficient * scalar_tspec
Definition: tmop.hpp:1008
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:620
virtual void SetSerialDiscreteTargetAspectRatio(const GridFunction &tspec_)
Definition: tmop.cpp:1445
void ReleasePADeviceMemory()
Definition: tmop.cpp:2193
void UpdateTargetSpecification(const Vector &new_x, bool use_flag=false)
Definition: tmop.cpp:1486
TMOPMatrixCoefficient(int dim)
Definition: tmop.hpp:993
const FiniteElementSpace * tspec_fesv
Definition: tmop.hpp:1067
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:720
2D barrier shape (S) metric (not polyconvex).
Definition: tmop.hpp:323
const DofToQuad * maps
Definition: tmop.hpp:1294
virtual ~TMOP_QualityMetric()
Definition: tmop.hpp:35
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:107
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:710
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:448
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:33
const GeometricFactors * geom
Definition: tmop.hpp:1296
virtual void AddMultGradPA(const Vector &, Vector &) const
Method for partially assembled gradient action.
Definition: tmop.cpp:3236
virtual void ComputeElementTargetsGradient(const IntegrationRule &ir, const Vector &elfun, IsoparametricTransformation &Tpr, DenseTensor &dJtr) const
Definition: tmop.cpp:1213
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
Definition: fe.hpp:320
2D barrier Size (V) metric (polyconvex).
Definition: tmop.hpp:680
Abstract class for local mesh quality metrics in the target-matrix optimization paradigm (TMOP) by P...
Definition: tmop.hpp:23
virtual ~TMOPMatrixCoefficient()
Definition: tmop.hpp:1001
virtual ~AdaptivityEvaluator()
Definition: tmop.cpp:2183
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:545
virtual void AddQualityMetric(TMOP_QualityMetric *tq, double wt=1.0)
Definition: tmop.hpp:85
void SetLimitingNodes(const GridFunction &n0)
Update the original/reference nodes used for limiting.
Definition: tmop.cpp:3119
virtual ~TMOP_Metric_080()
Definition: tmop.hpp:377
void SetDiscreteTargetBase(const GridFunction &tspec_)
Definition: tmop.cpp:1388
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:822
DiscreteAdaptTC * discr_tc
Definition: tmop.hpp:1234
void EnableLimiting(const GridFunction &n0, const GridFunction &dist, Coefficient &w0, TMOP_LimiterFunction *lfunc=NULL)
Limiting of the mesh displacements (general version).
Definition: tmop.cpp:2214
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:554
void AddMultGradPA_C0_2D(const Vector &, Vector &) const
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:665
void SetCoefficient(Coefficient &w1)
Sets a scaling Coefficient for the quality metric term of the integrator.
Definition: tmop.hpp:1430
2D non-barrier size (V) metric (not polyconvex).
Definition: tmop.hpp:288
void UpdateTargetSpecificationAtNode(const FiniteElement &el, ElementTransformation &T, int nodenum, int idir, const Vector &IntData)
Definition: tmop.cpp:1504
void AssembleDiagonalPA_C0_2D(Vector &) const
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:390
int Append(const T &el)
Append element &#39;el&#39; to array, resize if necessary.
Definition: array.hpp:746
TargetConstructor(TargetType ttype)
Constructor for use in serial.
Definition: tmop.hpp:923
TargetType GetTargetType() const
Definition: tmop.hpp:952
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:46
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:419
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:264
3D barrier Size (V) metric.
Definition: tmop.hpp:560
DiscreteAdaptTC(TargetType ttype)
Definition: tmop.hpp:1086
void AssembleDiagonalPA_3D(Vector &) const
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:415
void SetNodes(const GridFunction &n)
Set the nodes to be used in the target-matrix construction.
Definition: tmop.hpp:944
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:698
void AssembleElementVectorExact(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
Definition: tmop.cpp:2410
void AssembleDiagonalPA_2D(Vector &) const
virtual void AssembleGradDiagonalPA(Vector &) const
Method for computing the diagonal of the gradient with partial assembly.
Definition: tmop.cpp:3220
const TargetConstructor * targetC
Definition: tmop.hpp:1205
Array< Vector * > ElemPertEnergy
Definition: tmop.hpp:1248
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:563
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:623
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:600
virtual void AssemblePA(const FiniteElementSpace &fes)
Method defining partial assembly.
Definition: nonlininteg.cpp:25
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:671
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:478
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:612
Abstract class used to define combination of metrics with constant coefficients.
Definition: tmop.hpp:78
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:257
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:3211
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:147
virtual void SetParDiscreteTargetAspectRatio(const ParGridFunction &tspec_)
Definition: tmop.cpp:1363
virtual void AssembleGradPA(const Vector &, const FiniteElementSpace &)
Prepare the integrator for partial assembly (PA) gradient evaluations on the given FE space fes at th...
virtual ~TargetConstructor()
Definition: tmop.hpp:937
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:491
void ParEnableNormalization(const ParGridFunction &x)
Definition: tmop.cpp:3187
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:434
double GetLocalStateEnergyPA_2D(const Vector &) const
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
Definition: tmop.cpp:2381
virtual double GetLocalStateEnergyPA(const Vector &) const
Compute the local (to the MPI rank) energy with partial assembly.
Definition: tmop.cpp:3244
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
Definition: tmop.hpp:396
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:777
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:239
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:67
virtual bool ContainsVolumeInfo() const
Checks if the target matrices contain non-trivial size specification.
Definition: tmop.cpp:1128
Array< TMOP_QualityMetric * > tmop_q_arr
Definition: tmop.hpp:81
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:689
void RestoreTargetSpecificationAtNode(ElementTransformation &T, int nodenum)
Definition: tmop.cpp:1521
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:231
TMOP_QualityMetric * sh_metric
Definition: tmop.hpp:363
2D barrier Shape+Orientation (OS) metric (polyconvex).
Definition: tmop.hpp:716
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:387
void SetTspecAtIndex(int idx, const GridFunction &tspec_)
Definition: tmop.cpp:1416
void ComputeAvgVolume() const
Definition: tmop.cpp:1014
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:844
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:23
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:361
virtual double Eval(const Vector &x, const Vector &x0, double dist) const
Returns the limiting function, f(x, x0, d).
Definition: tmop.hpp:782
virtual ~TMOP_QuadraticLimiter()
Definition: tmop.hpp:806
2D barrier (not a shape) metric (polyconvex).
Definition: tmop.hpp:272
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:739
virtual void SetTargetJacobian(const DenseMatrix &Jtr_)
Specify the reference-element -&gt; target-element Jacobian matrix for the point of interest.
Definition: tmop.hpp:43
TMOP_Metric_211(double epsilon=1e-4)
Definition: tmop.hpp:418
void UpdateHessianTargetSpecification(const Vector &x, double dx, bool use_flag=false)
Definition: tmop.cpp:2094
virtual void AssembleGradDiagonalPA(Vector &) const
Method for computing the diagonal of the gradient with partial assembly.
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
Assemble the local gradient matrix.
Definition: tmop.cpp:2395
const DofToQuad * maps_lim
Definition: tmop.hpp:1295
2D untangling metric.
Definition: tmop.hpp:411
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:132
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Definition: fespace.hpp:87
3D Size (V) untangling metric.
Definition: tmop.hpp:502
const double eps
Definition: tmop.hpp:414
virtual void SetTargetJacobian(const DenseMatrix &Jtr_)
Specify the reference-element -&gt; target-element Jacobian matrix for the point of interest.
Definition: tmop.hpp:91
2D barrier size (V) metric (polyconvex).
Definition: tmop.hpp:305
void SetLimitingNodes(const GridFunction &n0)
Update the original/reference nodes used for limiting.
Definition: tmop.hpp:1471
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:498
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
Definition: coefficient.hpp:39
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:646
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
Definition: fe_coll.hpp:26
void subtract(const Vector &x, const Vector &y, Vector &z)
Definition: vector.cpp:438
TMOPMatrixCoefficient * matrix_tspec
Definition: tmop.hpp:1010
virtual double GetLocalStateEnergyPA(const Vector &) const
Compute the local (to the MPI rank) energy with partial assembly.
TMOP_Metric_333(double gamma_)
Definition: tmop.hpp:626
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-&gt;target transformation Jacobians for each quadratur...
Definition: tmop.cpp:1142
const IntegrationRule & ActionIntegrationRule(const FiniteElement &el) const
Definition: tmop.hpp:1357
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...
Base class for Matrix Coefficients that optionally depend on time and space.
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:275
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:83
void AssembleElemVecAdaptLim(const FiniteElement &el, const Vector &weights, IsoparametricTransformation &Tpr, const IntegrationRule &ir, DenseMatrix &m)
Definition: tmop.cpp:2654
bool UsesPhysicalCoordinates() const
Return true if the methods ComputeElementTargets(), ComputeAllElementTargets(), and ComputeElementTar...
Definition: tmop.hpp:957
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:214
void DisableLimiting()
Definition: tmop.hpp:1342
double GetLocalStateEnergyPA_C0_2D(const Vector &) const
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
Assemble the local gradient matrix.
Definition: tmop.cpp:3155
double DistanceSquaredTo(const double *p) const
Compute the square of the Euclidean distance to another vector.
Definition: vector.hpp:649
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:371
DiscreteAdaptTC * GetDiscreteAdaptTC() const
Definition: tmop.hpp:1503
void AddMultGradPA_2D(const Vector &, Vector &) const
Structure representing the matrices/tensors needed to evaluate (in reference space) the values...
Definition: fe.hpp:139
TMOP_Metric_252(double &t0)
Note that t0 is stored by reference.
Definition: tmop.hpp:438
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:403
DenseTensor Jtrcomp
Definition: tmop.hpp:1062
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:576
const IntegrationRule * IntRule
Definition: nonlininteg.hpp:30
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:374
void ResetUpdateFlags()
Used in combination with the Update methods to avoid extra computations.
Definition: tmop.hpp:1128
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:592
AnalyticAdaptTC(TargetType ttype)
Definition: tmop.hpp:1013
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:701
void AddTMOPIntegrator(TMOP_Integrator *ti)
Adds a new TMOP_Integrator to the combination.
Definition: tmop.hpp:1541
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:462
2D non-barrier Skew metric.
Definition: tmop.hpp:126
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:752
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:298
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:224
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:281
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:801
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:470
void AddMultPA_3D(const Vector &, Vector &) const
DenseMatrix PMatI
Definition: tmop.hpp:1260
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:563
2D barrier Shape+Size (VS) metric (not polyconvex).
Definition: tmop.hpp:222
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:272
void AddMultPA_2D(const Vector &, Vector &) const
void SetTransformation(ElementTransformation &)
The method SetTransformation() is hidden for TMOP_QualityMetrics, because it is not used...
Definition: tmop.hpp:31
void ComputeFDh(const Vector &x, const FiniteElementSpace &fes)
Determines the perturbation, h, for FD-based approximation.
Definition: tmop.cpp:3052
void AssembleGradPA_C0_2D(const Vector &) const
virtual double Eval(const Vector &x, const Vector &x0, double d) const =0
Returns the limiting function, f(x, x0, d).
Class for integration point with weight.
Definition: intrules.hpp:25
AdaptivityEvaluator * adapt_eval
Definition: tmop.hpp:1075
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:453
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:405
void AssembleDiagonalPA_C0_3D(Vector &) const
const FiniteElementSpace * fes
Definition: tmop.hpp:1297
Array< TMOP_Integrator * > tmopi
Definition: tmop.hpp:1530
A standard isoparametric element transformation.
Definition: eltrans.hpp:348
void ComputeMinJac(const Vector &x, const FiniteElementSpace &fes)
Definition: tmop.cpp:3009
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:682
void ComputeNormalizationEnergies(const GridFunction &x, double &metric_energy, double &lim_energy)
Definition: tmop.cpp:2957
void Diag(double c, int n)
Creates n x n diagonal matrix with diagonal elements c.
Definition: densemat.cpp:1344
This class is used to express the local action of a general nonlinear finite element operator...
Definition: nonlininteg.hpp:27
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:710
const IntegrationRule & EnergyIntegrationRule(const FiniteElement &el) const
Definition: tmop.hpp:1348
const IntegrationRule & GradientIntegrationRule(const FiniteElement &el) const
Definition: tmop.hpp:1362
double GetFDDerivative(const FiniteElement &el, ElementTransformation &T, Vector &elfun, const int nodenum, const int idir, const double baseenergy, bool update_stored)
Definition: tmop.cpp:2757
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.hpp:707
2D barrier Shape+Size+Orientation (VOS) metric (polyconvex).
Definition: tmop.hpp:698
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:674
void SetParMetaInfo(const ParMesh &m, const FiniteElementCollection &fec, int num_comp)
Parallel version of SetSerialMetaInfo.
Definition: tmop.cpp:2161
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:440
3D Shape (S) metric, untangling version of 303.
Definition: tmop.hpp:521
int dim
Definition: ex24.cpp:53
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:2273
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:61
void AssembleGradPA_3D(const Vector &) const
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.
void AddMultGradPA_3D(const Vector &, Vector &) const
const GridFunction * zeta_0
Definition: tmop.hpp:1229
void ComputeAllElementTargets_Fallback(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const
Definition: tmop.cpp:1056
3D non-barrier Aspect ratio metric.
Definition: tmop.hpp:171
const Vector & GetTspecPert2H()
Definition: tmop.hpp:1165
const Vector & GetTspecPert1H()
Definition: tmop.hpp:1164
void AssembleElementGradFD(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
Definition: tmop.cpp:2843
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:814
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:189
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:629
virtual void SetParDiscreteTargetSpec(const ParGridFunction &tspec_)
Definition: tmop.cpp:1381
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:207
Abstract class for hyperelastic models.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:167
bool ComputeAllElementTargets(const FiniteElementSpace &fes, const IntegrationRule &ir, const Vector &xe, DenseTensor &Jtr) const
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:334
TargetConstructor(TargetType ttype, MPI_Comm mpicomm)
Constructor for use in parallel.
Definition: tmop.hpp:933
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:830
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:247
void ComputeAllElementTargets(const Vector &xe=Vector()) const
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:635
TMOP_Integrator(TMOP_QualityMetric *m, TargetConstructor *tc)
Definition: tmop.hpp:1400
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:614
void FinalizeParDiscreteTargetSpec(const ParGridFunction &tspec_)
Definition: tmop.cpp:1317
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:538
bool GetFDFlag() const
Definition: tmop.hpp:1519
Vector data type.
Definition: vector.hpp:60
DenseMatrix DSh
Definition: tmop.hpp:1260
double GetGamma() const
Definition: tmop.hpp:636
DenseMatrix DS
Definition: tmop.hpp:1260
TMOP_Metric_022(double &t0)
Definition: tmop.hpp:260
3D barrier Shape+Size (VS) metric (polyconvex).
Definition: tmop.hpp:619
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:487
const GridFunction * nodes0
Definition: tmop.hpp:1219
const FiniteElementSpace * tspec_fes
Definition: tmop.hpp:1066
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:538
TargetType
Target-matrix construction algorithms supported by this class.
Definition: tmop.hpp:872
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:411
double GetLocalStateEnergyPA_C0_3D(const Vector &) const
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:568
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:729
TMOP_Metric_311(double epsilon=1e-4)
Definition: tmop.hpp:509
virtual void SetSerialDiscreteTargetSpec(const GridFunction &tspec_)
Definition: tmop.cpp:1479
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:683
virtual void SetParDiscreteTargetSkew(const ParGridFunction &tspec_)
Definition: tmop.cpp:1355
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:382
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:789
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:165
InvariantsEvaluator2D< double > ie
Definition: tmop.hpp:737
virtual int Id() const
Return the metric ID.
Definition: tmop.hpp:498
virtual void SetParDiscreteTargetOrientation(const ParGridFunction &tspec_)
Definition: tmop.cpp:1372
Class for parallel grid function.
Definition: pgridfunc.hpp:32
Base class representing target-matrix construction algorithms for mesh optimization via the target-ma...
Definition: tmop.hpp:868
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:977
void AddMultPA_C0_3D(const Vector &, Vector &) const
TMOP_Metric_332(double gamma_)
Definition: tmop.hpp:603
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:208
virtual void SetAnalyticTargetSpec(Coefficient *sspec, VectorCoefficient *vspec, TMOPMatrixCoefficient *mspec)
Definition: tmop.cpp:1227
3D barrier Shape+Size (VS) metric (polyconvex).
Definition: tmop.hpp:596
Rank 3 tensor (array of matrices)
Definition: densemat.hpp:745
Class for parallel meshes.
Definition: pmesh.hpp:32
virtual void SetSerialDiscreteTargetSize(const GridFunction &tspec_)
Definition: tmop.cpp:1428
TMOP_QualityMetric * sz_metric
Definition: tmop.hpp:600
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
Definition: intrules.hpp:377
TMOP_LimiterFunction * lim_func
Definition: tmop.hpp:1224
const Array< TMOP_Integrator * > & GetTMOPIntegrators() const
Definition: tmop.hpp:1543
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:785
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:704
InvariantsEvaluator3D< double > ie
Definition: tmop.hpp:469
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
Definition: tmop.cpp:3139
DenseMatrix Jpt
Definition: tmop.hpp:1260
double GetGamma() const
Definition: tmop.hpp:375
2D barrier Shape+Orientation (OS) metric (polyconvex).
Definition: tmop.hpp:381
Array< double > wt_arr
Definition: tmop.hpp:82
void ParEnableNormalization(const ParGridFunction &x)
Definition: tmop.cpp:2946
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:900
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:135
DenseMatrix P
Definition: tmop.hpp:1260
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:912
virtual void ComputeAtNewPosition(const Vector &new_nodes, Vector &new_field)=0
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
Definition: tmop.cpp:772
bool Parallel() const
Definition: tmop.hpp:900
3D barrier Shape (S) metric.
Definition: tmop.hpp:450
void AssembleGradPA_C0_3D(const Vector &) const
2D non-barrier metric without a type.
Definition: tmop.hpp:108
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Definition: tmop.cpp:892
FiniteElementSpace * fes
Definition: tmop.hpp:818
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:507
A TMOP integrator class based on any given TMOP_QualityMetric and TargetConstructor.
Definition: tmop.hpp:1198
2D non-barrier Shape+Size+Orientation (VOS) metric (polyconvex).
Definition: tmop.hpp:238