23 p = ((px(0)*v2(1)-px(1)*v2(0))-(v0(0)*v2(1)-v0(1)*v2(0))) /
24 (v1(0)*v2(1)-v1(1)*v2(0));
25 q = -((px(0)*v1(1)-px(1)*v1(0))-(v0(0)*v1(1)-v0(1)*v1(0))) /
26 (v1(0)*v2(1)-v1(1)*v2(0));
28 return (p > 0 && q > 0 && 1-p-q > 0) ? -1.0 : 1.0;
35 double x = 2*coord(0)-1.0, y = 2*coord(1)-1.0, z = 2*coord(2)-1.0;
38 const double R = 0.8, r = 0.15;
40 doughnut = t*t + z*z - r*r <= 0;
43 x = 3.0*x, y = 3.0*y, z = 3.0*z;
44 cheese = (x*x + y*y - 4.0) * (x*x + y*y - 4.0) +
45 (z*z - 1.0) * (z*z - 1.0) +
46 (y*y + z*z - 4.0) * (y*y + z*z - 4.0) +
47 (x*x - 1.0) * (x*x - 1.0) +
48 (z*z + x*x - 4.0) * (z*z + x*x - 4.0) +
49 (y*y - 1.0) * (y*y - 1.0) - 15.0 <= 0.0;
51 return (doughnut || cheese) ? 1.0 : -1.0;
58 if (type == 1 || type == 2)
60 const double ring_radius = 0.2;
64 return xc.
Norml2() - ring_radius;
72 const int num_circ = 3;
73 double rad[num_circ] = {0.3, 0.15, 0.2};
74 double c[num_circ][2] = { {0.6, 0.6}, {0.3, 0.3}, {0.25, 0.75} };
76 const double xc = x(0), yc = x(1);
79 double r0 = (xc-c[0][0])*(xc-c[0][0]) + (yc-c[0][1])*(yc-c[0][1]);
81 if (r0 <= 0.2) {
return -1.0; }
83 for (
int i = 0; i < num_circ; i++)
85 double r = (xc-c[i][0])*(xc-c[i][0]) + (yc-c[i][1])*(yc-c[i][1]);
87 if (r <= rad[i]) {
return 1.0; }
91 if (0.7 <= xc && xc <= 0.8 && 0.1 <= yc && yc <= 0.8) {
return 1.0; }
94 if (0.3 <= xc && xc <= 0.8 && 0.15 <= yc && yc <= 0.2) {
return 1.0; }
99 double square_side = 0.2;
101 xc = 0.75; xc(1) = 0.25;
103 if (abs(xc(0)) > 0.5*square_side || abs(xc(1)) > 0.5*square_side)
116 p1(0) = 0.25; p1(1) = 0.4;
117 p2(0) = 0.1; p2(1) = 0.1;
118 p3(0) = 0.4; p3(1) = 0.1;
124 xc = 0.5; xc(1) = 0.6;
131 MFEM_ABORT(
" Function type not implement yet.");
151 return (dist >= 0.0) ? 1.0 : -1.0;
165 { dls.Append(&dls_); }
171 MFEM_VERIFY(dls.Size() > 0,
172 "Add at least 1 Dist_level_Set_Coefficient to the Combo.");
173 double dist = dls[0]->Eval(T, ip);
174 for (
int j = 1; j < dls.Size(); j++)
176 dist = min(dist, dls[j]->Eval(T, ip));
178 return (dist >= 0.0) ? 1.0 : -1.0;
192 using VectorCoefficient::Eval;
201 if (type == 1 || type == 2)
204 for (
int i = 0; i <
dim; i++) {
p(i) = 0.5 - x(i); }
205 double length = p.
Norml2();
226 return pow(x(0), xy_p) +
pow(x(1), xy_p);
231 return 1./(M_PI*M_PI)*
std::sin(M_PI*x(0)*x(1));
260 gradient(0) = xy_p*x(0);
261 gradient(1) = xy_p*x(1);
264 return 1.0*(gradient*normal);
276 double coeff = std::max(xy_p*(xy_p-1), 1.);
277 double expon = std::max(0., xy_p-2);
290 return std::sin(M_PI*x(0)*x(1))*(x(0)*x(0)+x(1)*x(1));
double rhs_fun_circle(const Vector &x)
f for the Poisson problem (-nabla^2 u = f).
Base class for vector Coefficients that optionally depend on time and space.
void SetSize(int s)
Resize the vector to size s.
double Norml2() const
Returns the l2 norm of the vector.
int Size() const
Returns the size of the vector.
double dirichlet_velocity_xy_exponent(const Vector &x)
double homogeneous(const Vector &x)
Boundary conditions - Dirichlet.
virtual void Eval(Vector &p, ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the vector coefficient in the element described by T at the point ip, storing the result in ...
Distance vector to the zero level-set.
Level set coefficient: +1 inside the true domain, -1 outside.
Dist_Vector_Coefficient(int dim_, int type_)
double point_inside_trigon(const Vector px, Vector p1, Vector p2, Vector p3)
FDualNumber< tbase > pow(const FDualNumber< tbase > &a, const FDualNumber< tbase > &b)
pow([dual number],[dual number])
double rhs_fun_xy_sinusoidal(const Vector &x)
double p(const Vector &x, double t)
FDualNumber< tbase > sin(const FDualNumber< tbase > &f)
sin([dual number])
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient in the element described by T at the point ip.
Combination of level sets: +1 inside the true domain, -1 outside.
void Add_Level_Set_Coefficient(Dist_Level_Set_Coefficient &dls_)
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient in the element described by T at the point ip.
Dist_Level_Set_Coefficient(int type_)
double rhs_fun_xy_exponent(const Vector &x)
Class for integration point with weight.
double dirichlet_velocity_xy_sinusoidal(const Vector &x)
void normal_vector_1(const Vector &x, Vector &p)
FDualNumber< tbase > sqrt(const FDualNumber< tbase > &f)
sqrt([dual number])
void normal_vector_2(const Vector &x, Vector &p)
Normal vector for level_set_type = 7. Circle centered at [0.5 , 0.6].
double traction_xy_exponent(const Vector &x)
Neumann condition for exponent based solution.
double doughnut_cheese(const Vector &coord)
Combo_Level_Set_Coefficient()
double dist_value(const Vector &x, const int type)