24 const double small = 0.001, big = 0.01;
29 const double X = x(0), Y = x(1);
30 val = std::tanh((10*(Y-0.5) + std::sin(4.0*M_PI*X)) + 1) -
31 std::tanh((10*(Y-0.5) + std::sin(4.0*M_PI*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;
38 val = 0.5*(1+std::tanh(sf*(r-r1))) - 0.5*(1+std::tanh(sf*(r-r2)));
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;
56 val = 0.5*(1+std::tanh(sf*(r-r1))) - 0.5*(1+std::tanh(sf*(r-r2)));
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;
76 double wgt = std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) + 1);
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));
95 v[0] = l1/pow(l2*l3,0.5);
96 v[1] = l2/pow(l1*l3,0.5);
97 v[2] = l3/pow(l2*l1,0.5);
113 T.Transform(ip, pos);
114 if (metric != 14 && metric != 36 && metric != 85)
116 const double xc = pos(0) - 0.5, yc = pos(1) - 0.5;
117 const double r = sqrt(xc*xc + yc*yc);
118 double r1 = 0.15;
double r2 = 0.35;
double sf=30.0;
119 const double eps = 0.5;
121 const double tan1 = std::tanh(sf*(r-r1)),
122 tan2 = std::tanh(sf*(r-r2));
124 K(0, 0) = eps + 1.0 * (tan1 - tan2);
129 else if (metric == 14 || metric == 36)
131 const double xc = pos(0), yc = pos(1);
132 double theta = M_PI * yc * (1.0 - yc) * cos(2 * M_PI * xc);
133 double alpha_bar = 0.1;
135 K(0, 0) = cos(theta);
136 K(1, 0) = sin(theta);
137 K(0, 1) = -sin(theta);
138 K(1, 1) = cos(theta);
142 else if (metric == 85)
145 double xc = x(0)-0.5, yc = x(1)-0.5;
146 double th = 22.5*M_PI/180.;
147 double xn = cos(th)*xc + sin(th)*yc;
148 double yn = -sin(th)*xc + cos(th)*yc;
154 double wgt = std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) + 1)
155 - std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) - 1);
156 if (wgt > 1) { wgt = 1; }
157 if (wgt < 0) { wgt = 0; }
159 xc = pos(0), yc = pos(1);
160 double theta = M_PI * (yc) * (1.0 - yc) * cos(2 * M_PI * xc);
162 K(0, 0) = cos(theta);
163 K(1, 0) = sin(theta);
164 K(0, 1) = -sin(theta);
165 K(1, 1) = cos(theta);
167 double asp_ratio_tar = 0.1 + 1*(1-wgt)*(1-wgt);
169 K(0, 0) *= 1/pow(asp_ratio_tar,0.5);
170 K(1, 0) *= 1/pow(asp_ratio_tar,0.5);
171 K(0, 1) *= pow(asp_ratio_tar,0.5);
172 K(1, 1) *= pow(asp_ratio_tar,0.5);
180 T.Transform(ip, pos);
182 if (metric != 14 && metric != 85)
184 const double xc = pos(0) - 0.5, yc = pos(1) - 0.5;
185 const double r = sqrt(xc*xc + yc*yc);
186 double r1 = 0.15;
double r2 = 0.35;
double sf=30.0;
188 const double tan1 = std::tanh(sf*(r-r1)),
189 tan2 = std::tanh(sf*(r-r2));
190 double tan1d = 0., tan2d = 0.;
193 tan1d = (1.-tan1*tan1)*(sf)/r,
194 tan2d = (1.-tan2*tan2)*(sf)/r;
200 if (comp == 0) { K(0, 0) = tan1d*xc - tan2d*xc; }
201 else if (comp == 1) { K(0, 0) = tan1d*yc - tan2d*yc; }
218 hr_target_type(hr_target_type_) { }
224 T.Transform(ip, pos);
225 if (hr_target_type == 0)
227 double small = 0.001, big = 0.01;
228 if (
dim == 3) { small = 0.005, big = 0.1; }
229 const double xc = pos(0) - 0.5, yc = pos(1) - 0.5;
231 if (
dim == 3) { zc = pos(2) - 0.5; }
232 double r = sqrt(xc*xc + yc*yc);
233 if (
dim == 3) { r = sqrt(xc*xc + yc*yc + zc*zc); }
234 double r1 = 0.15;
double r2 = 0.35;
double sf=30.0;
236 const double tan1 = std::tanh(sf*(r-r1)),
237 tan2 = std::tanh(sf*(r-r2));
239 double ind = (tan1 - tan2);
240 if (ind > 1.0) {ind = 1.;}
241 if (ind < 0.0) {ind = 0.;}
242 double val = ind * small + (1.0 - ind) * big;
248 K(0, 0) *= pow(val,0.5);
249 K(1, 1) *= pow(val,0.5);
250 if (
dim == 3) { K(2, 2) = pow(val,0.5); }
252 else if (hr_target_type == 1)
254 const double small = 0.001, big = 0.01;
255 const double xc = pos(0)-0.5, yc = pos(1)-0.5;
256 const double rv = xc*xc + yc*yc;
258 if (rv>0.) {r = sqrt(rv);}
260 double r1 = 0.2;
double r2 = 0.3;
double sf=30.0;
261 const double szfac = 1;
262 const double asfac = 4;
263 const double eps2 = szfac/asfac;
264 const double eps1 = szfac;
266 double tan1 = std::tanh(sf*(r-r1)+1),
267 tan2 = std::tanh(sf*(r-r2)-1);
268 double wgt = 0.5*(tan1-tan2);
270 tan1 = std::tanh(sf*(r-r1)),
271 tan2 = std::tanh(sf*(r-r2));
273 double ind = (tan1 - tan2);
274 if (ind > 1.0) {ind = 1.;}
275 if (ind < 0.0) {ind = 0.;}
276 double szval = ind * small + (1.0 - ind) * big;
278 double th = std::atan2(yc,xc)*180./M_PI;
279 if (wgt > 1) { wgt = 1; }
280 if (wgt < 0) { wgt = 0; }
282 double maxval = eps2 + eps1*(1-wgt)*(1-wgt);
283 double minval = eps1;
284 double avgval = 0.5*(maxval+minval);
285 double ampval = 0.5*(maxval-minval);
286 double val1 = avgval + ampval*sin(2.*th*M_PI/180.+90*M_PI/180.);
287 double val2 = avgval + ampval*sin(2.*th*M_PI/180.-90*M_PI/180.);
294 K(0,0) *= pow(szval,0.5);
295 K(1,1) *= pow(szval,0.5);
297 else if (hr_target_type == 2)
299 double xc = pos(0)-0.5, yc = pos(1)-0.5;
300 double th = 15.5*M_PI/180.;
301 double xn = cos(th)*xc + sin(th)*yc;
302 double yn = -sin(th)*xc + cos(th)*yc;
303 double th2 = (th > 45.*M_PI/180) ? M_PI/2 - th : th;
304 double stretch = 1/cos(th2);
312 double wgt = std::tanh((tfac*(yc-yl1) + s2*std::sin(s1*M_PI*xc)) + 1) -
313 std::tanh((tfac*(yc-yl2) + s2*std::sin(s1*M_PI*xc)) - 1);
314 if (wgt > 1) { wgt = 1; }
315 if (wgt < 0) { wgt = 0; }
317 const double eps2 = 25;
318 const double eps1 = 1;
319 K(1,1) = eps1/eps2 + eps1*(1-wgt)*(1-wgt);
324 else { MFEM_ABORT(
"Unsupported option / wrong input."); }
341 const double r = sqrt(x(0)*x(0) + x(1)*x(1) + 1e-12);
342 const double den = 0.002;
343 double l2 = 0.2 + 0.5*std::tanh((r-0.16)/den) - 0.5*std::tanh((r-0.17)/den)
344 + 0.5*std::tanh((r-0.23)/den) - 0.5*std::tanh((r-0.24)/den);
351 const double xc = x(0) - 0.1, yc = x(1) - 0.2;
352 const double r = sqrt(xc*xc + yc*yc);
353 double r1 = 0.45;
double r2 = 0.55;
double sf=30.0;
354 double val = 0.5*(1+std::tanh(sf*(r-r1))) - 0.5*(1+std::tanh(sf*(r-r2)));
356 val = std::max(0.,val);
357 val = std::min(1.,val);
369 const double sine = 0.25 * std::sin(4 * M_PI * x(0));
370 return (x(1) >= sine + 0.5) ? 1.0 : -1.0;
376 const double xc = x(0) - 0.5, yc = x(1) - 0.5;
377 const double r = sqrt(xc*xc + yc*yc);
378 return std::tanh(2.0*(r-0.3));
382 const double xc = x(0) - 0.5, yc = x(1) - 0.5, zc = x(2) - 0.5;
383 const double r = sqrt(xc*xc + yc*yc + zc*zc);
384 return std::tanh(2.0*(r-0.3));
397 double integral = 0.0;
406 return (integral > 0.0) ? 1.0 : 0.0;
447 S->
Mult(tmp, fieldtrue);
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 ...
int GetNPoints() const
Returns the number of the points in the integration rule.
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)
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)
int Size() const
Returns the size of the vector.
Container class for integration rules.
Data type dense matrix using column-major storage.
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Relax the linear system Ax=b.
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
void GetValues(int i, const IntegrationRule &ir, Vector &vals, int vdim=1) const
virtual void SetFromTrueDofs(const Vector &tv)
Set the GridFunction from the given true-dof vector.
double discrete_ori_2d(const Vector &x)
Parallel smoothers in hypre.
FiniteElementSpace * FESpace()
void DiffuseField(ParGridFunction &field, int smooth_steps)
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 ...
Mesh * GetMesh() const
Returns the mesh.
HessianCoefficient(int dim, int metric_id)
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
double weight_fun(const Vector &x)
ParFiniteElementSpace * ParFESpace() const
int GetOrder(int i) const
Returns the polynomial degree of the i'th finite element.
double adapt_lim_fun(const Vector &x)
const Vector & GetTrueVector() const
Read only access to the (optional) internal true-dof Vector.
double material_indicator_2d(const Vector &x)
double discrete_size_3d(const Vector &x)
Class for integration point with weight.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
IntegrationRules IntRulesCU(0, Quadrature1D::ClosedUniform)
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.
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication with Jacobi smoother.
int material_id(int el_id, const GridFunction &g)