24 const double small = 0.001, big = 0.01;
29 const double X = x(0), Y = x(1);
35 const double xc = x(0) - 0.0, yc = x(1) - 0.5;
36 const double r =
sqrt(xc*xc + yc*yc);
37 double r1 = 0.45;
double r2 = 0.55;
double sf=30.0;
41 val = std::max(0.,val);
42 val = std::min(1.,val);
44 return val * small + (1.0 - val) * big;
49 const double small = 0.0001, big = 0.01;
53 const double xc = x(0) - 0.0, yc = x(1) - 0.5, zc = x(2) - 0.5;
54 const double r =
sqrt(xc*xc + yc*yc + zc*zc);
55 double r1 = 0.45;
double r2 = 0.55;
double sf=30.0;
58 val = std::max(0.,val);
59 val = std::min(1.,val);
61 return val * small + (1.0 - val) * big;
66 double xc = x(0)-0.5, yc = x(1)-0.5;
67 double th = 22.5*M_PI/180.;
68 double xn =
cos(th)*xc +
sin(th)*yc;
69 double yn = -
sin(th)*xc +
cos(th)*yc;
70 double th2 = (th > 45.*M_PI/180) ? M_PI/2 - th : th;
71 double stretch = 1/
cos(th2);
72 xc = xn/stretch; yc = yn/stretch;
77 if (wgt > 1) { wgt = 1; }
78 if (wgt < 0) { wgt = 0; }
84 return M_PI * x(1) * (1.0 - x(1)) *
cos(2 * M_PI * x(0));
89 double xc = x(0)-0.5, yc = x(1)-0.5;
90 double th = 22.5*M_PI/180.;
91 double xn =
cos(th)*xc +
sin(th)*yc;
92 double yn = -
sin(th)*xc +
cos(th)*yc;
100 if (wgt > 1) { wgt = 1; }
101 if (wgt < 0) { wgt = 0; }
102 return 0.1 + 1*(1-wgt)*(1-wgt);
113 v[0] = l1/
pow(l2*l3,0.5);
114 v[1] = l2/
pow(l1*l3,0.5);
115 v[2] = l3/
pow(l2*l1,0.5);
132 if (metric != 14 && metric != 36 && metric != 85)
134 const double xc = pos(0) - 0.5, yc = pos(1) - 0.5;
135 const double r =
sqrt(xc*xc + yc*yc);
136 double r1 = 0.15;
double r2 = 0.35;
double sf=30.0;
137 const double eps = 0.5;
139 const double tan1 =
std::tanh(sf*(r-r1)),
142 K(0, 0) = eps + 1.0 * (tan1 - tan2);
147 else if (metric == 14 || metric == 36)
149 const double xc = pos(0), yc = pos(1);
150 double theta = M_PI * yc * (1.0 - yc) *
cos(2 * M_PI * xc);
151 double alpha_bar = 0.1;
153 K(0, 0) =
cos(theta);
154 K(1, 0) =
sin(theta);
155 K(0, 1) = -
sin(theta);
156 K(1, 1) =
cos(theta);
160 else if (metric == 85)
163 double xc = x(0)-0.5, yc = x(1)-0.5;
164 double th = 22.5*M_PI/180.;
165 double xn =
cos(th)*xc +
sin(th)*yc;
166 double yn = -
sin(th)*xc +
cos(th)*yc;
174 if (wgt > 1) { wgt = 1; }
175 if (wgt < 0) { wgt = 0; }
177 xc = pos(0), yc = pos(1);
178 double theta = M_PI * (yc) * (1.0 - yc) *
cos(2 * M_PI * xc);
180 K(0, 0) =
cos(theta);
181 K(1, 0) =
sin(theta);
182 K(0, 1) = -
sin(theta);
183 K(1, 1) =
cos(theta);
185 double asp_ratio_tar = 0.1 + 1*(1-wgt)*(1-wgt);
187 K(0, 0) *= 1/
pow(asp_ratio_tar,0.5);
188 K(1, 0) *= 1/
pow(asp_ratio_tar,0.5);
189 K(0, 1) *=
pow(asp_ratio_tar,0.5);
190 K(1, 1) *=
pow(asp_ratio_tar,0.5);
200 if (metric != 14 && metric != 85)
202 const double xc = pos(0) - 0.5, yc = pos(1) - 0.5;
203 const double r =
sqrt(xc*xc + yc*yc);
204 double r1 = 0.15;
double r2 = 0.35;
double sf=30.0;
206 const double tan1 =
std::tanh(sf*(r-r1)),
208 double tan1d = 0., tan2d = 0.;
211 tan1d = (1.-tan1*tan1)*(sf)/r,
212 tan2d = (1.-tan2*tan2)*(sf)/r;
218 if (comp == 0) { K(0, 0) = tan1d*xc - tan2d*xc; }
219 else if (comp == 1) { K(0, 0) = tan1d*yc - tan2d*yc; }
236 hr_target_type(hr_target_type_) { }
243 if (hr_target_type == 0)
245 double small = 0.001, big = 0.01;
246 if (
dim == 3) { small = 0.005, big = 0.1; }
247 const double xc = pos(0) - 0.5, yc = pos(1) - 0.5;
249 if (
dim == 3) { zc = pos(2) - 0.5; }
250 double r =
sqrt(xc*xc + yc*yc);
251 if (
dim == 3) { r =
sqrt(xc*xc + yc*yc + zc*zc); }
252 double r1 = 0.15;
double r2 = 0.35;
double sf=30.0;
254 const double tan1 =
std::tanh(sf*(r-r1)),
257 double ind = (tan1 - tan2);
258 if (ind > 1.0) {ind = 1.;}
259 if (ind < 0.0) {ind = 0.;}
260 double val = ind * small + (1.0 - ind) * big;
266 K(0, 0) *=
pow(val,0.5);
267 K(1, 1) *=
pow(val,0.5);
268 if (
dim == 3) { K(2, 2) =
pow(val,0.5); }
270 else if (hr_target_type == 1)
272 const double small = 0.001, big = 0.01;
273 const double xc = pos(0)-0.5, yc = pos(1)-0.5;
274 const double rv = xc*xc + yc*yc;
276 if (rv>0.) {r =
sqrt(rv);}
278 double r1 = 0.2;
double r2 = 0.3;
double sf=30.0;
279 const double szfac = 1;
280 const double asfac = 4;
281 const double eps2 = szfac/asfac;
282 const double eps1 = szfac;
286 double wgt = 0.5*(tan1-tan2);
291 double ind = (tan1 - tan2);
292 if (ind > 1.0) {ind = 1.;}
293 if (ind < 0.0) {ind = 0.;}
294 double szval = ind * small + (1.0 - ind) * big;
296 double th = std::atan2(yc,xc)*180./M_PI;
297 if (wgt > 1) { wgt = 1; }
298 if (wgt < 0) { wgt = 0; }
300 double maxval = eps2 + eps1*(1-wgt)*(1-wgt);
301 double minval = eps1;
302 double avgval = 0.5*(maxval+minval);
303 double ampval = 0.5*(maxval-minval);
304 double val1 = avgval + ampval*
sin(2.*th*M_PI/180.+90*M_PI/180.);
305 double val2 = avgval + ampval*
sin(2.*th*M_PI/180.-90*M_PI/180.);
312 K(0,0) *=
pow(szval,0.5);
313 K(1,1) *=
pow(szval,0.5);
315 else if (hr_target_type == 2)
317 double xc = pos(0)-0.5, yc = pos(1)-0.5;
318 double th = 15.5*M_PI/180.;
319 double xn =
cos(th)*xc +
sin(th)*yc;
320 double yn = -
sin(th)*xc +
cos(th)*yc;
321 double th2 = (th > 45.*M_PI/180) ? M_PI/2 - th : th;
322 double stretch = 1/
cos(th2);
332 if (wgt > 1) { wgt = 1; }
333 if (wgt < 0) { wgt = 0; }
335 const double eps2 = 25;
336 const double eps1 = 1;
337 K(1,1) = eps1/eps2 + eps1*(1-wgt)*(1-wgt);
342 else { MFEM_ABORT(
"Unsupported option / wrong input."); }
359 const double r =
sqrt(x(0)*x(0) + x(1)*x(1) + 1e-12);
360 const double den = 0.002;
369 const double xc = x(0) - 0.1, yc = x(1) - 0.2;
370 const double r =
sqrt(xc*xc + yc*yc);
371 double r1 = 0.45;
double r2 = 0.55;
double sf=30.0;
374 val = std::max(0.,val);
375 val = std::min(1.,val);
387 const double sine = 0.25 *
std::sin(4 * M_PI * x(0));
388 return (x(1) >= sine + 0.5) ? 1.0 : -1.0;
394 const double xc = x(0) - 0.5, yc = x(1) - 0.5;
395 const double r =
sqrt(xc*xc + yc*yc);
400 const double xc = x(0) - 0.5, yc = x(1) - 0.5, zc = x(2) - 0.5;
401 const double r =
sqrt(xc*xc + yc*yc + zc*zc);
415 double integral = 0.0;
424 return (integral > 0.0) ? 1.0 : 0.0;
465 S->
Mult(tmp, fieldtrue);
int GetNPoints() const
Returns the number of the points in the integration rule.
Abstract class for all finite elements.
void discrete_aspr_3d(const Vector &x, Vector &v)
virtual void EvalGrad(DenseMatrix &K, ElementTransformation &T, const IntegrationPoint &ip, int comp)
Evaluate the derivative of the matrix coefficient with respect to comp in the element described by T ...
Class for an integration rule - an Array of IntegrationPoint.
Class for grid function - Vector with associated FE space.
double discrete_size_2d(const Vector &x)
FDualNumber< tbase > tanh(const FDualNumber< tbase > &f)
tanh([dual number])
Data type for scaled Jacobi-type smoother of sparse matrix.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
IntegrationRules IntRulesLo(0, Quadrature1D::GaussLobatto)
virtual void EvalGrad(DenseMatrix &K, ElementTransformation &T, const IntegrationPoint &ip, int comp)
Evaluate the derivative of the matrix coefficient with respect to comp in the element described by T ...
void SetSize(int s)
Resize the vector to size s.
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
virtual void SetOperator(const Operator &a)
Set/update the solver for the given operator.
HRHessianCoefficient(int dim_, int hr_target_type_=0)
double surface_level_set(const Vector &x)
Container class for integration rules.
Data type dense matrix using column-major storage.
int Size() const
Returns the size of the vector.
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Relax the linear system Ax=b.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
virtual void SetFromTrueDofs(const Vector &tv)
Set the GridFunction from the given true-dof vector.
Mesh * GetMesh() const
Returns the mesh.
double discrete_ori_2d(const Vector &x)
Parallel smoothers in hypre.
void GetValues(int i, const IntegrationRule &ir, Vector &vals, int vdim=1) const
FiniteElementSpace * FESpace()
void DiffuseField(ParGridFunction &field, int smooth_steps)
const Vector & GetTrueVector() const
Read only access to the (optional) internal true-dof Vector.
FDualNumber< tbase > cos(const FDualNumber< tbase > &f)
cos([dual number])
virtual void Eval(DenseMatrix &K, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the matrix coefficient in the element described by T at the point ip, storing the result in ...
FDualNumber< tbase > pow(const FDualNumber< tbase > &a, const FDualNumber< tbase > &b)
pow([dual number],[dual number])
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication with Jacobi smoother.
HessianCoefficient(int dim, int metric_id)
FDualNumber< tbase > sin(const FDualNumber< tbase > &f)
sin([dual number])
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
double weight_fun(const Vector &x)
double adapt_lim_fun(const Vector &x)
int GetOrder(int i) const
Returns the polynomial degree of the i'th finite element.
double material_indicator_2d(const Vector &x)
double discrete_size_3d(const Vector &x)
double discrete_aspr_2d(const Vector &x)
Class for integration point with weight.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
FDualNumber< tbase > sqrt(const FDualNumber< tbase > &f)
sqrt([dual number])
IntegrationRules IntRulesCU(0, Quadrature1D::ClosedUniform)
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
Class for parallel grid function.
virtual void Eval(DenseMatrix &K, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the matrix coefficient in the element described by T at the point ip, storing the result in ...
Wrapper for hypre's ParCSR matrix class.
int material_id(int el_id, const GridFunction &g)
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
ParFiniteElementSpace * ParFESpace() const