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 double xc = x(0)-0.5, yc = x(1)-0.5;
50 double th = 22.5*M_PI/180.;
51 double xn = cos(th)*xc + sin(th)*yc;
52 double yn = -sin(th)*xc + cos(th)*yc;
53 double th2 = (th > 45.*M_PI/180) ? M_PI/2 - th : th;
54 double stretch = 1/cos(th2);
55 xc = xn/stretch; yc = yn/stretch;
59 double wgt = std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) + 1);
60 if (wgt > 1) { wgt = 1; }
61 if (wgt < 0) { wgt = 0; }
67 return M_PI * x(1) * (1.0 - x(1)) * cos(2 * M_PI * x(0));
72 double xc = x(0)-0.5, yc = x(1)-0.5;
73 double th = 22.5*M_PI/180.;
74 double xn = cos(th)*xc + sin(th)*yc;
75 double yn = -sin(th)*xc + cos(th)*yc;
83 double wgt = std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) + 1)
84 - std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) - 1);
85 if (wgt > 1) { wgt = 1; }
86 if (wgt < 0) { wgt = 0; }
87 return 0.1 + 1*(1-wgt)*(1-wgt);
98 v[0] = l1/pow(l2*l3,0.5);
99 v[1] = l2/pow(l1*l3,0.5);
100 v[2] = l3/pow(l2*l1,0.5);
117 if (metric != 14 && metric != 85)
119 const double xc = pos(0) - 0.5, yc = pos(1) - 0.5;
120 const double r = sqrt(xc*xc + yc*yc);
121 double r1 = 0.15;
double r2 = 0.35;
double sf=30.0;
122 const double eps = 0.5;
124 const double tan1 = std::tanh(sf*(r-r1)),
125 tan2 = std::tanh(sf*(r-r2));
127 K(0, 0) = eps + 1.0 * (tan1 - tan2);
132 else if (metric == 14)
134 const double xc = pos(0), yc = pos(1);
135 double theta = M_PI * yc * (1.0 - yc) * cos(2 * M_PI * xc);
136 double alpha_bar = 0.1;
138 K(0, 0) = cos(theta);
139 K(1, 0) = sin(theta);
140 K(0, 1) = -sin(theta);
141 K(1, 1) = cos(theta);
145 else if (metric == 85)
148 double xc = x(0)-0.5, yc = x(1)-0.5;
149 double th = 22.5*M_PI/180.;
150 double xn = cos(th)*xc + sin(th)*yc;
151 double yn = -sin(th)*xc + cos(th)*yc;
157 double wgt = std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) + 1)
158 - std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) - 1);
159 if (wgt > 1) { wgt = 1; }
160 if (wgt < 0) { wgt = 0; }
162 xc = pos(0), yc = pos(1);
163 double theta = M_PI * (yc) * (1.0 - yc) * cos(2 * M_PI * xc);
165 K(0, 0) = cos(theta);
166 K(1, 0) = sin(theta);
167 K(0, 1) = -sin(theta);
168 K(1, 1) = cos(theta);
170 double asp_ratio_tar = 0.1 + 1*(1-wgt)*(1-wgt);
172 K(0, 0) *= 1/pow(asp_ratio_tar,0.5);
173 K(1, 0) *= 1/pow(asp_ratio_tar,0.5);
174 K(0, 1) *= pow(asp_ratio_tar,0.5);
175 K(1, 1) *= pow(asp_ratio_tar,0.5);
185 if (metric != 14 && metric != 85)
187 const double xc = pos(0) - 0.5, yc = pos(1) - 0.5;
188 const double r = sqrt(xc*xc + yc*yc);
189 double r1 = 0.15;
double r2 = 0.35;
double sf=30.0;
191 const double tan1 = std::tanh(sf*(r-r1)),
192 tan2 = std::tanh(sf*(r-r2));
193 double tan1d = 0., tan2d = 0.;
196 tan1d = (1.-tan1*tan1)*(sf)/r,
197 tan2d = (1.-tan2*tan2)*(sf)/r;
203 if (comp == 0) { K(0, 0) = tan1d*xc - tan2d*xc; }
204 else if (comp == 1) { K(0, 0) = tan1d*yc - tan2d*yc; }
216 const double r = sqrt(x(0)*x(0) + x(1)*x(1) + 1e-12);
217 const double den = 0.002;
218 double l2 = 0.2 + 0.5*std::tanh((r-0.16)/den) - 0.5*std::tanh((r-0.17)/den)
219 + 0.5*std::tanh((r-0.23)/den) - 0.5*std::tanh((r-0.24)/den);
226 const double xc = x(0) - 0.1, yc = x(1) - 0.2;
227 const double r = sqrt(xc*xc + yc*yc);
228 double r1 = 0.45;
double r2 = 0.55;
double sf=30.0;
229 double val = 0.5*(1+std::tanh(sf*(r-r1))) - 0.5*(1+std::tanh(sf*(r-r2)));
231 val = std::max(0.,val);
232 val = std::min(1.,val);
274 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.
void DiffuseField(GridFunction &field, int smooth_steps)
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()
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_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