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