24 const double xc = x(0) - 0.0, yc = x(1) - 0.5,
25 zc = (x.
Size() == 3) ? x(2) - 0.5 : 0.0;
26 const double r = sqrt(xc*xc + yc*yc + zc*zc);
27 double r1 = 0.45;
double r2 = 0.55;
double sf=30.0;
28 double val = 0.5*(1+std::tanh(sf*(r-r1))) - 0.5*(1+std::tanh(sf*(r-r2)));
38 const int NE = mesh.
GetNE();
40 mass = 0.0, vol = 0.0;
41 for (
int e = 0; e < NE; e++)
61 MPI_Allreduce(MPI_IN_PLACE, &mass, 1, MPI_DOUBLE, MPI_SUM, comm);
62 MPI_Allreduce(MPI_IN_PLACE, &vol, 1, MPI_DOUBLE, MPI_SUM, comm);
75 double volume_ind, volume;
78 int NE = mesh.
GetNE();
86 const double size_ratio = (mesh.
Dimension() == 2) ? 9 : 27;
87 const double small_el_size = volume_ind / NE +
88 (volume - volume_ind) / (size_ratio * NE);
89 const double big_el_size = size_ratio * small_el_size;
90 for (
int i = 0; i < size.
Size(); i++)
92 size(i) = size(i) * small_el_size + (1.0 - size(i)) * big_el_size;
98 double xc = x(0)-0.5, yc = x(1)-0.5;
99 double th = 22.5*M_PI/180.;
100 double xn = cos(th)*xc + sin(th)*yc;
101 double yn = -sin(th)*xc + cos(th)*yc;
102 double th2 = (th > 45.*M_PI/180) ? M_PI/2 - th : th;
103 double stretch = 1/cos(th2);
104 xc = xn/stretch; yc = yn/stretch;
108 double wgt = std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) + 1);
109 if (wgt > 1) { wgt = 1; }
110 if (wgt < 0) { wgt = 0; }
116 return M_PI * x(1) * (1.0 - x(1)) * cos(2 * M_PI * x(0));
127 v[0] = l1/pow(l2*l3,0.5);
128 v[1] = l2/pow(l1*l3,0.5);
129 v[2] = l3/pow(l2*l1,0.5);
145 T.Transform(ip, pos);
146 if (metric != 14 && metric != 36 && metric != 85)
148 const double xc = pos(0) - 0.5, yc = pos(1) - 0.5;
149 const double r = sqrt(xc*xc + yc*yc);
150 double r1 = 0.15;
double r2 = 0.35;
double sf=30.0;
151 const double eps = 0.5;
153 const double tan1 = std::tanh(sf*(r-r1)),
154 tan2 = std::tanh(sf*(r-r2));
156 K(0, 0) = eps + 1.0 * (tan1 - tan2);
161 else if (metric == 14 || metric == 36)
163 const double xc = pos(0), yc = pos(1);
164 double theta = M_PI * yc * (1.0 - yc) * cos(2 * M_PI * xc);
165 double alpha_bar = 0.1;
167 K(0, 0) = cos(theta);
168 K(1, 0) = sin(theta);
169 K(0, 1) = -sin(theta);
170 K(1, 1) = cos(theta);
174 else if (metric == 85)
177 double xc = x(0)-0.5, yc = x(1)-0.5;
178 double th = 22.5*M_PI/180.;
179 double xn = cos(th)*xc + sin(th)*yc;
180 double yn = -sin(th)*xc + cos(th)*yc;
186 double wgt = std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) + 1)
187 - std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) - 1);
188 if (wgt > 1) { wgt = 1; }
189 if (wgt < 0) { wgt = 0; }
191 xc = pos(0), yc = pos(1);
192 double theta = M_PI * (yc) * (1.0 - yc) * cos(2 * M_PI * xc);
194 K(0, 0) = cos(theta);
195 K(1, 0) = sin(theta);
196 K(0, 1) = -sin(theta);
197 K(1, 1) = cos(theta);
199 double asp_ratio_tar = 0.1 + 1*(1-wgt)*(1-wgt);
201 K(0, 0) *= 1/pow(asp_ratio_tar,0.5);
202 K(1, 0) *= 1/pow(asp_ratio_tar,0.5);
203 K(0, 1) *= pow(asp_ratio_tar,0.5);
204 K(1, 1) *= pow(asp_ratio_tar,0.5);
212 T.Transform(ip, pos);
214 if (metric != 14 && metric != 85)
216 const double xc = pos(0) - 0.5, yc = pos(1) - 0.5;
217 const double r = sqrt(xc*xc + yc*yc);
218 double r1 = 0.15;
double r2 = 0.35;
double sf=30.0;
220 const double tan1 = std::tanh(sf*(r-r1)),
221 tan2 = std::tanh(sf*(r-r2));
222 double tan1d = 0., tan2d = 0.;
225 tan1d = (1.-tan1*tan1)*(sf)/r,
226 tan2d = (1.-tan2*tan2)*(sf)/r;
232 if (comp == 0) { K(0, 0) = tan1d*xc - tan2d*xc; }
233 else if (comp == 1) { K(0, 0) = tan1d*yc - tan2d*yc; }
250 hr_target_type(hr_target_type_) { }
256 T.Transform(ip, pos);
257 if (hr_target_type == 0)
259 double small = 0.001, big = 0.01;
260 if (
dim == 3) { small = 0.005, big = 0.1; }
261 const double xc = pos(0) - 0.5, yc = pos(1) - 0.5;
265 r = sqrt(xc*xc + yc*yc);
269 const double zc = pos(2) - 0.5;
270 r = sqrt(xc*xc + yc*yc + zc*zc);
272 double r1 = 0.15;
double r2 = 0.35;
double sf=30.0;
274 const double tan1 = std::tanh(sf*(r-r1)),
275 tan2 = std::tanh(sf*(r-r2));
277 double ind = (tan1 - tan2);
278 if (ind > 1.0) {ind = 1.;}
279 if (ind < 0.0) {ind = 0.;}
280 double val = ind * small + (1.0 - ind) * big;
286 K(0, 0) *= pow(val,0.5);
287 K(1, 1) *= pow(val,0.5);
288 if (
dim == 3) { K(2, 2) = pow(val,0.5); }
290 else if (hr_target_type == 1)
292 const double small = 0.001, big = 0.01;
293 const double xc = pos(0)-0.5, yc = pos(1)-0.5;
294 const double rv = xc*xc + yc*yc;
296 if (rv>0.) {r = sqrt(rv);}
298 double r1 = 0.2;
double r2 = 0.3;
double sf=30.0;
299 const double szfac = 1;
300 const double asfac = 4;
301 const double eps2 = szfac/asfac;
302 const double eps1 = szfac;
304 double tan1 = std::tanh(sf*(r-r1)+1),
305 tan2 = std::tanh(sf*(r-r2)-1);
306 double wgt = 0.5*(tan1-tan2);
308 tan1 = std::tanh(sf*(r-r1)),
309 tan2 = std::tanh(sf*(r-r2));
311 double ind = (tan1 - tan2);
312 if (ind > 1.0) {ind = 1.;}
313 if (ind < 0.0) {ind = 0.;}
314 double szval = ind * small + (1.0 - ind) * big;
316 double th = std::atan2(yc,xc)*180./M_PI;
317 if (wgt > 1) { wgt = 1; }
318 if (wgt < 0) { wgt = 0; }
320 double maxval = eps2 + eps1*(1-wgt)*(1-wgt);
321 double minval = eps1;
322 double avgval = 0.5*(maxval+minval);
323 double ampval = 0.5*(maxval-minval);
324 double val1 = avgval + ampval*sin(2.*th*M_PI/180.+90*M_PI/180.);
325 double val2 = avgval + ampval*sin(2.*th*M_PI/180.-90*M_PI/180.);
332 K(0,0) *= pow(szval,0.5);
333 K(1,1) *= pow(szval,0.5);
335 else if (hr_target_type == 2)
337 double xc = pos(0)-0.5, yc = pos(1)-0.5;
338 double th = 15.5*M_PI/180.;
339 double xn = cos(th)*xc + sin(th)*yc;
340 double yn = -sin(th)*xc + cos(th)*yc;
341 double th2 = (th > 45.*M_PI/180) ? M_PI/2 - th : th;
342 double stretch = 1/cos(th2);
350 double wgt = std::tanh((tfac*(yc-yl1) + s2*std::sin(s1*M_PI*xc)) + 1) -
351 std::tanh((tfac*(yc-yl2) + s2*std::sin(s1*M_PI*xc)) - 1);
352 if (wgt > 1) { wgt = 1; }
353 if (wgt < 0) { wgt = 0; }
355 const double eps2 = 25;
356 const double eps1 = 1;
357 K(1,1) = eps1/eps2 + eps1*(1-wgt)*(1-wgt);
362 else { MFEM_ABORT(
"Unsupported option / wrong input."); }
379 const double r = sqrt(x(0)*x(0) + x(1)*x(1) + 1e-12);
380 const double den = 0.002;
381 double l2 = 0.2 + 0.5*std::tanh((r-0.16)/den) - 0.5*std::tanh((r-0.17)/den)
382 + 0.5*std::tanh((r-0.23)/den) - 0.5*std::tanh((r-0.24)/den);
389 const double xc = x(0) - 0.1, yc = x(1) - 0.2;
390 const double r = sqrt(xc*xc + yc*yc);
391 double r1 = 0.45;
double r2 = 0.55;
double sf=30.0;
392 double val = 0.5*(1+std::tanh(sf*(r-r1))) - 0.5*(1+std::tanh(sf*(r-r2)));
394 val = std::max(0.,val);
395 val = std::min(1.,val);
407 const double sine = 0.25 * std::sin(4 * M_PI * x(0));
408 return (x(1) >= sine + 0.5) ? 1.0 : -1.0;
414 const double xc = x(0) - 0.5, yc = x(1) - 0.5;
415 const double r = sqrt(xc*xc + yc*yc);
420 const double xc = x(0) - 0.5, yc = x(1) - 0.5, zc = x(2) - 0.5;
421 const double r = sqrt(xc*xc + yc*yc + zc*zc);
435 double integral = 0.0;
447 return (integral > 0.0) ? 1.0 : 0.0;
449 else if (approach == 1)
451 double minval = g_vals.
Min();
452 return minval > 0.0 ? 1.0 : 0.0;
495 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.
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)
Geometry::Type GetElementBaseGeometry(int i) const
double size_indicator(const Vector &x)
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 Dimension() const
Dimension of the reference space used within the elements.
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.
HRHessianCoefficient(int dim_, int hr_target_type_=0)
void ConstructSizeGF(GridFunction &size)
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.
long long GetGlobalNE() const
Return the total (global) number of elements.
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.
ParMesh * GetParMesh() const
double discrete_ori_2d(const Vector &x)
Parallel smoothers in hypre.
int GetNumRootElements()
Return the number of root elements.
A class for non-conforming AMR. The class is not used directly by the user, rather it is an extension...
FiniteElementSpace * FESpace()
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)
double Min() const
Returns the minimal element of the vector.
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)
int GetNE() const
Returns number of elements.
Class for integration point with weight.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
IntegrationRules IntRulesCU(0, Quadrature1D::ClosedUniform)
void calc_mass_volume(const GridFunction &g, double &mass, double &vol)
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
NCMesh * ncmesh
Optional nonconforming mesh extension.
A general function coefficient.
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)