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