24 const real_t xc = x(0) - 0.0, yc = x(1) - 0.5,
25 zc = (x.
Size() == 3) ? x(2) - 0.5 : 0.0;
26 const real_t r = sqrt(xc*xc + yc*yc + zc*zc);
28 real_t val = 0.5*(1+std::tanh(sf*(r-r1))) - 0.5*(1+std::tanh(sf*(r-r2)));
30 val = std::max((
real_t) 0.,val);
31 val = std::min((
real_t) 1.,val);
38 const int NE = mesh.
GetNE();
40 mass = 0.0, vol = 0.0;
41 for (
int e = 0; e < NE; e++)
80 int NE = mesh.
GetNE();
89 const real_t small_el_size = volume_ind / NE +
90 (volume - volume_ind) / (size_ratio * NE);
91 const real_t big_el_size = size_ratio * small_el_size;
92 for (
int i = 0; i < size.
Size(); i++)
94 size(i) = size(i) * small_el_size + (1.0 - size(i)) * big_el_size;
100 real_t xc = x(0)-0.5, yc = x(1)-0.5;
101 real_t th = 22.5*M_PI/180.;
102 real_t xn = cos(th)*xc + sin(th)*yc;
103 real_t yn = -sin(th)*xc + cos(th)*yc;
104 real_t th2 = (th > 45.*M_PI/180) ? M_PI/2 - th : th;
105 real_t stretch = 1/cos(th2);
106 xc = xn/stretch; yc = yn/stretch;
110 real_t wgt = std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) + 1);
111 if (wgt > 1) { wgt = 1; }
112 if (wgt < 0) { wgt = 0; }
118 return M_PI * x(1) * (1.0 - x(1)) * cos(2 * M_PI * x(0));
129 v[0] = l1/pow(l2*l3,0.5);
130 v[1] = l2/pow(l1*l3,0.5);
131 v[2] = l3/pow(l2*l1,0.5);
148 if (metric != 14 && metric != 36 && metric != 85)
150 const real_t xc = pos(0) - 0.5, yc = pos(1) - 0.5;
151 const real_t r = sqrt(xc*xc + yc*yc);
155 const real_t tan1 = std::tanh(sf*(r-r1)),
156 tan2 = std::tanh(sf*(r-r2));
158 K(0, 0) = eps + 1.0 * (tan1 - tan2);
163 else if (metric == 14 || metric == 36)
165 const real_t xc = pos(0), yc = pos(1);
166 real_t theta = M_PI * yc * (1.0 - yc) * cos(2 * M_PI * xc);
169 K(0, 0) = cos(theta);
170 K(1, 0) = sin(theta);
171 K(0, 1) = -sin(theta);
172 K(1, 1) = cos(theta);
176 else if (metric == 85)
179 real_t xc = x(0)-0.5, yc = x(1)-0.5;
180 real_t th = 22.5*M_PI/180.;
181 real_t xn = cos(th)*xc + sin(th)*yc;
182 real_t yn = -sin(th)*xc + cos(th)*yc;
188 real_t wgt = std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) + 1)
189 - std::tanh((tfac*(yc) + s2*std::sin(s1*M_PI*xc)) - 1);
190 if (wgt > 1) { wgt = 1; }
191 if (wgt < 0) { wgt = 0; }
193 xc = pos(0), yc = pos(1);
194 real_t theta = M_PI * (yc) * (1.0 - yc) * cos(2 * M_PI * xc);
196 K(0, 0) = cos(theta);
197 K(1, 0) = sin(theta);
198 K(0, 1) = -sin(theta);
199 K(1, 1) = cos(theta);
201 real_t asp_ratio_tar = 0.1 + 1*(1-wgt)*(1-wgt);
203 K(0, 0) *= 1/pow(asp_ratio_tar,0.5);
204 K(1, 0) *= 1/pow(asp_ratio_tar,0.5);
205 K(0, 1) *= pow(asp_ratio_tar,0.5);
206 K(1, 1) *= pow(asp_ratio_tar,0.5);
216 if (metric != 14 && metric != 85)
218 const real_t xc = pos(0) - 0.5, yc = pos(1) - 0.5;
219 const real_t r = sqrt(xc*xc + yc*yc);
222 const real_t tan1 = std::tanh(sf*(r-r1)),
223 tan2 = std::tanh(sf*(r-r2));
224 real_t tan1d = 0., tan2d = 0.;
227 tan1d = (1.-tan1*tan1)*(sf)/r,
228 tan2d = (1.-tan2*tan2)*(sf)/r;
234 if (comp == 0) { K(0, 0) = tan1d*xc - tan2d*xc; }
235 else if (comp == 1) { K(0, 0) = tan1d*yc - tan2d*yc; }
252 hr_target_type(hr_target_type_) { }
259 if (hr_target_type == 0)
261 real_t small = 0.001, big = 0.01;
262 if (
dim == 3) { small = 0.005, big = 0.1; }
263 const real_t xc = pos(0) - 0.5, yc = pos(1) - 0.5;
267 r = sqrt(xc*xc + yc*yc);
271 const real_t zc = pos(2) - 0.5;
272 r = sqrt(xc*xc + yc*yc + zc*zc);
276 const real_t tan1 = std::tanh(sf*(r-r1)),
277 tan2 = std::tanh(sf*(r-r2));
279 real_t ind = (tan1 - tan2);
280 if (ind > 1.0) {ind = 1.;}
281 if (ind < 0.0) {ind = 0.;}
282 real_t val = ind * small + (1.0 - ind) * big;
288 K(0, 0) *= pow(val,0.5);
289 K(1, 1) *= pow(val,0.5);
290 if (
dim == 3) { K(2, 2) = pow(val,0.5); }
292 else if (hr_target_type == 1)
294 const real_t small = 0.001, big = 0.01;
295 const real_t xc = pos(0)-0.5, yc = pos(1)-0.5;
296 const real_t rv = xc*xc + yc*yc;
298 if (rv>0.) {r = sqrt(rv);}
303 const real_t eps2 = szfac/asfac;
304 const real_t eps1 = szfac;
306 real_t tan1 = std::tanh(sf*(r-r1)+1),
307 tan2 = std::tanh(sf*(r-r2)-1);
308 real_t wgt = 0.5*(tan1-tan2);
310 tan1 = std::tanh(sf*(r-r1)),
311 tan2 = std::tanh(sf*(r-r2));
313 real_t ind = (tan1 - tan2);
314 if (ind > 1.0) {ind = 1.;}
315 if (ind < 0.0) {ind = 0.;}
316 real_t szval = ind * small + (1.0 - ind) * big;
318 real_t th = std::atan2(yc,xc)*180./M_PI;
319 if (wgt > 1) { wgt = 1; }
320 if (wgt < 0) { wgt = 0; }
322 real_t maxval = eps2 + eps1*(1-wgt)*(1-wgt);
324 real_t avgval = 0.5*(maxval+minval);
325 real_t ampval = 0.5*(maxval-minval);
326 real_t val1 = avgval + ampval*sin(2.*th*M_PI/180.+90*M_PI/180.);
327 real_t val2 = avgval + ampval*sin(2.*th*M_PI/180.-90*M_PI/180.);
334 K(0,0) *= pow(szval,0.5);
335 K(1,1) *= pow(szval,0.5);
337 else if (hr_target_type == 2)
339 real_t xc = pos(0)-0.5, yc = pos(1)-0.5;
340 real_t th = 15.5*M_PI/180.;
341 real_t xn = cos(th)*xc + sin(th)*yc;
342 real_t yn = -sin(th)*xc + cos(th)*yc;
343 real_t th2 = (th > 45.*M_PI/180) ? M_PI/2 - th : th;
344 real_t stretch = 1/cos(th2);
352 real_t wgt = std::tanh((tfac*(yc-yl1) + s2*std::sin(s1*M_PI*xc)) + 1) -
353 std::tanh((tfac*(yc-yl2) + s2*std::sin(s1*M_PI*xc)) - 1);
354 if (wgt > 1) { wgt = 1; }
355 if (wgt < 0) { wgt = 0; }
359 K(1,1) = eps1/eps2 + eps1*(1-wgt)*(1-wgt);
364 else { MFEM_ABORT(
"Unsupported option / wrong input."); }
381 const real_t r = sqrt(x(0)*x(0) + x(1)*x(1) + 1e-12);
383 real_t l2 = 0.2 + 0.5*std::tanh((r-0.16)/den) - 0.5*std::tanh((r-0.17)/den)
384 + 0.5*std::tanh((r-0.23)/den) - 0.5*std::tanh((r-0.24)/den);
391 const real_t xc = x(0) - 0.1, yc = x(1) - 0.2;
392 const real_t r = sqrt(xc*xc + yc*yc);
394 real_t val = 0.5*(1+std::tanh(sf*(r-r1))) - 0.5*(1+std::tanh(sf*(r-r2)));
396 val = std::max((
real_t) 0.,val);
397 val = std::min((
real_t) 1.,val);
409 const real_t sine = 0.25 * std::sin(4 * M_PI * x(0));
410 return (x(1) >= sine + 0.5) ? 1.0 : -1.0;
416 const real_t xc = x(0) - 0.5, yc = x(1) - 0.5;
417 const real_t r = sqrt(xc*xc + yc*yc);
422 const real_t xc = x(0) - 0.5, yc = x(1) - 0.5, zc = x(2) - 0.5;
423 const real_t r = sqrt(xc*xc + yc*yc + zc*zc);
449 return (integral > 0.0) ? 1.0 : 0.0;
451 else if (approach == 1)
454 return minval > 0.0 ? 1.0 : 0.0;
497 S->
Mult(tmp, fieldtrue);
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 ...
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 ...
HRHessianCoefficient(int dim_, int hr_target_type_=0)
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 ...
HessianCoefficient(int dim, int metric_id)
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 ...
Data type for scaled Jacobi-type smoother of sparse matrix.
virtual void Mult(const Vector &x, Vector &y) const
Matrix vector multiplication with Jacobi smoother.
Data type dense matrix using column-major storage.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
int GetOrder(int i) const
Returns the polynomial degree of the i'th finite element.
Mesh * GetMesh() const
Returns the mesh.
Abstract class for all finite elements.
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
A general function coefficient.
Class for grid function - Vector with associated FE space.
void GetValues(int i, const IntegrationRule &ir, Vector &vals, int vdim=1) const
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
const Vector & GetTrueVector() const
Read only access to the (optional) internal true-dof Vector.
FiniteElementSpace * FESpace()
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
Wrapper for hypre's ParCSR matrix class.
Parallel smoothers in hypre.
virtual void Mult(const HypreParVector &b, HypreParVector &x) const
Relax the linear system Ax=b.
Class for integration point with weight.
Class for an integration rule - an Array of IntegrationPoint.
int GetNPoints() const
Returns the number of the points in the integration rule.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
Container class for integration rules.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
int GetNE() const
Returns number of elements.
int Dimension() const
Dimension of the reference space used within the elements.
void GetElementTransformation(int i, IsoparametricTransformation *ElTr) const
Builds the transformation defining the i-th element in ElTr. ElTr must be allocated in advance and wi...
long long GetGlobalNE() const
Return the total (global) number of elements.
NCMesh * ncmesh
Optional nonconforming mesh extension.
Geometry::Type GetElementBaseGeometry(int i) const
A class for non-conforming AMR. The class is not used directly by the user, rather it is an extension...
int GetNumRootElements()
Return the number of root elements.
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
ParMesh * GetParMesh() const
Class for parallel grid function.
void SetFromTrueDofs(const Vector &tv) override
Set the GridFunction from the given true-dof vector.
ParFiniteElementSpace * ParFESpace() const
@ ClosedUniform
aka closed Newton-Cotes
bool iterative_mode
If true, use the second argument of Mult() as an initial guess.
virtual void SetOperator(const Operator &a)
Set/update the solver for the given operator.
int Size() const
Returns the size of the vector.
void SetSize(int s)
Resize the vector to size s.
real_t Min() const
Returns the minimal element of the vector.
real_t size_indicator(const Vector &x)
int material_id(int el_id, const GridFunction &g)
real_t surface_level_set(const Vector &x)
real_t adapt_lim_fun(const Vector &x)
IntegrationRules IntRulesCU(0, Quadrature1D::ClosedUniform)
real_t weight_fun(const Vector &x)
real_t material_indicator_2d(const Vector &x)
IntegrationRules IntRulesLo(0, Quadrature1D::GaussLobatto)
void ConstructSizeGF(GridFunction &size)
void calc_mass_volume(const GridFunction &g, real_t &mass, real_t &vol)
real_t discrete_ori_2d(const Vector &x)
void discrete_aspr_3d(const Vector &x, Vector &v)
void DiffuseField(ParGridFunction &field, int smooth_steps)
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
Helper struct to convert a C++ type to an MPI type.