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));
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 double wgt = std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) + 1)
101 - std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) - 1);
102 if (wgt > 1) { wgt = 1; }
103 if (wgt < 0) { wgt = 0; }
104 return 0.1 + 1*(1-wgt)*(1-wgt);
115 v[0] = l1/pow(l2*l3,0.5);
116 v[1] = l2/pow(l1*l3,0.5);
117 v[2] = l3/pow(l2*l1,0.5);
134 if (metric != 14 && metric != 36 && metric != 85)
136 const double xc = pos(0) - 0.5, yc = pos(1) - 0.5;
137 const double r = sqrt(xc*xc + yc*yc);
138 double r1 = 0.15;
double r2 = 0.35;
double sf=30.0;
139 const double eps = 0.5;
141 const double tan1 = std::tanh(sf*(r-r1)),
142 tan2 = std::tanh(sf*(r-r2));
144 K(0, 0) = eps + 1.0 * (tan1 - tan2);
149 else if (metric == 14 || metric == 36)
151 const double xc = pos(0), yc = pos(1);
152 double theta = M_PI * yc * (1.0 - yc) * cos(2 * M_PI * xc);
153 double alpha_bar = 0.1;
155 K(0, 0) = cos(theta);
156 K(1, 0) = sin(theta);
157 K(0, 1) = -sin(theta);
158 K(1, 1) = cos(theta);
162 else if (metric == 85)
165 double xc = x(0)-0.5, yc = x(1)-0.5;
166 double th = 22.5*M_PI/180.;
167 double xn = cos(th)*xc + sin(th)*yc;
168 double yn = -sin(th)*xc + cos(th)*yc;
174 double wgt = std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) + 1)
175 - std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) - 1);
176 if (wgt > 1) { wgt = 1; }
177 if (wgt < 0) { wgt = 0; }
179 xc = pos(0), yc = pos(1);
180 double theta = M_PI * (yc) * (1.0 - yc) * cos(2 * M_PI * xc);
182 K(0, 0) = cos(theta);
183 K(1, 0) = sin(theta);
184 K(0, 1) = -sin(theta);
185 K(1, 1) = cos(theta);
187 double asp_ratio_tar = 0.1 + 1*(1-wgt)*(1-wgt);
189 K(0, 0) *= 1/pow(asp_ratio_tar,0.5);
190 K(1, 0) *= 1/pow(asp_ratio_tar,0.5);
191 K(0, 1) *= pow(asp_ratio_tar,0.5);
192 K(1, 1) *= pow(asp_ratio_tar,0.5);
202 if (metric != 14 && metric != 85)
204 const double xc = pos(0) - 0.5, yc = pos(1) - 0.5;
205 const double r = sqrt(xc*xc + yc*yc);
206 double r1 = 0.15;
double r2 = 0.35;
double sf=30.0;
208 const double tan1 = std::tanh(sf*(r-r1)),
209 tan2 = std::tanh(sf*(r-r2));
210 double tan1d = 0., tan2d = 0.;
213 tan1d = (1.-tan1*tan1)*(sf)/r,
214 tan2d = (1.-tan2*tan2)*(sf)/r;
220 if (comp == 0) { K(0, 0) = tan1d*xc - tan2d*xc; }
221 else if (comp == 1) { K(0, 0) = tan1d*yc - tan2d*yc; }
233 const double r = sqrt(x(0)*x(0) + x(1)*x(1) + 1e-12);
234 const double den = 0.002;
235 double l2 = 0.2 + 0.5*std::tanh((r-0.16)/den) - 0.5*std::tanh((r-0.17)/den)
236 + 0.5*std::tanh((r-0.23)/den) - 0.5*std::tanh((r-0.24)/den);
243 const double xc = x(0) - 0.1, yc = x(1) - 0.2;
244 const double r = sqrt(xc*xc + yc*yc);
245 double r1 = 0.45;
double r2 = 0.55;
double sf=30.0;
246 double val = 0.5*(1+std::tanh(sf*(r-r1))) - 0.5*(1+std::tanh(sf*(r-r2)));
248 val = std::max(0.,val);
249 val = std::min(1.,val);
291 S->
Mult(tmp, fieldtrue);
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 grid function - Vector with associated FE space.
double discrete_size_2d(const Vector &x)
Data type for scaled Jacobi-type smoother of sparse matrix.
IntegrationRules IntRulesLo(0, Quadrature1D::GaussLobatto)
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.
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.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Relax the linear system Ax=b.
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.
double discrete_ori_2d(const Vector &x)
Parallel smoothers in hypre.
FiniteElementSpace * FESpace()
void DiffuseField(ParGridFunction &field, int smooth_steps)
const Vector & GetTrueVector() const
Read only access to the (optional) internal true-dof Vector.
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 ...
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication with Jacobi smoother.
HessianCoefficient(int dim, int metric_id)
double weight_fun(const Vector &x)
double adapt_lim_fun(const Vector &x)
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.
IntegrationRules IntRulesCU(0, Quadrature1D::ClosedUniform)
Class for parallel grid function.
Wrapper for hypre's ParCSR matrix class.
ParFiniteElementSpace * ParFESpace() const