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 real_t x = 2*coord(0)-1.0, y = 2*coord(1)-1.0, z = 2*coord(2)-1.0;
38 const real_t R = 0.8, r = 0.15;
39 const real_t t = R - std::sqrt(x*x + y*y);
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 real_t ring_radius = 0.2;
64 return xc.
Norml2() - ring_radius;
72 const int num_circ = 3;
73 real_t rad[num_circ] = {0.3, 0.15, 0.2};
74 real_t c[num_circ][2] = { {0.6, 0.6}, {0.3, 0.3}, {0.25, 0.75} };
76 const real_t xc = x(0), yc = x(1);
79 real_t r0 = (xc-c[0][0])*(xc-c[0][0]) + (yc-c[0][1])*(yc-c[0][1]);
80 r0 = (r0 > 0) ? std::sqrt(r0) : 0.0;
81 if (r0 <= 0.2) {
return -1.0; }
83 for (
int i = 0; i < num_circ; i++)
85 real_t r = (xc-c[i][0])*(xc-c[i][0]) + (yc-c[i][1])*(yc-c[i][1]);
86 r = (r > 0) ? std::sqrt(r) : 0.0;
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; }
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;
171 MFEM_VERIFY(dls.
Size() > 0,
172 "Add at least 1 Dist_level_Set_Coefficient to the Combo.");
173 real_t 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;
201 if (type == 1 || type == 2)
204 for (
int i = 0; i <
dim; i++) {
p(i) = 0.5 - x(i); }
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);
284 return -coeff*std::pow(x(0), expon) - coeff*std::pow(x(1), expon);
290 return std::sin(M_PI*x(0)*x(1))*(x(0)*x(0)+x(1)*x(1));
Combination of level sets: +1 inside the true domain, -1 outside.
void Add_Level_Set_Coefficient(Dist_Level_Set_Coefficient &dls_)
Combo_Level_Set_Coefficient()
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)
Evaluate the coefficient in the element described by T at the point ip.
Level set coefficient: +1 inside the true domain, -1 outside.
virtual real_t 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_)
Distance vector to the zero level-set.
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 ...
Dist_Vector_Coefficient(int dim_, int type_)
int Size() const
Return the logical size of the array.
int Append(const T &el)
Append element 'el' to array, resize if necessary.
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
Class for integration point with weight.
Base class for vector Coefficients that optionally depend on time and space.
virtual void Eval(Vector &V, ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the vector coefficient in the element described by T at the point ip, storing the result in ...
real_t Norml2() const
Returns the l2 norm of the vector.
int Size() const
Returns the size of the vector.
real_t p(const Vector &x, real_t t)
real_t rhs_fun_xy_exponent(const Vector &x)
real_t dirichlet_velocity_xy_exponent(const Vector &x)
real_t dirichlet_velocity_xy_sinusoidal(const Vector &x)
real_t rhs_fun_xy_sinusoidal(const Vector &x)
real_t point_inside_trigon(const Vector px, Vector p1, Vector p2, Vector p3)
real_t doughnut_cheese(const Vector &coord)
real_t homogeneous(const Vector &x)
Boundary conditions - Dirichlet.
real_t traction_xy_exponent(const Vector &x)
Neumann condition for exponent based solution.
void normal_vector_1(const Vector &x, Vector &p)
real_t dist_value(const Vector &x, const int type)
real_t rhs_fun_circle(const Vector &x)
f for the Poisson problem (-nabla^2 u = f).
void normal_vector_2(const Vector &x, Vector &p)
Normal vector for level_set_type = 7. Circle centered at [0.5 , 0.6].