55#define cs_avg(a,i,j,k) \
56 ((a[i,j,k]*(1.5 + cs[i,j,k]) + a[i-1,j,k]*(1.5 + cs[i-1,j,k]))/ \
57 (cs[i,j,k] + cs[i-1,j,k] + 3.))
68#define face_condition(fs, cs) \
69 (fs.x[i,j] > 0.5 && fs.y[i,j + (j < 0)] && fs.y[i-1,j + (j < 0)] && \
78 return ((1. +
fs.
x[
i])*(
a[
i] -
a[
i-1]) +
105 n1.
x = (
f[-1,-1,
i] + 2.*
f[-1,0,
i] +
f[-1,1,
i] -
106 f[+1,-1,
i] - 2.*
f[+1,0,
i] -
f[+1,1,
i]);
110 return (
coord){0.,0.,0.};
115 ((
double *)&
n)[0] = n1.
x, ((
double *)&
n)[1] = n1.
y;
118 p.
x = ((
double *)&
p1)[0],
p.
y = ((
double *)&
p1)[1],
p.
z = 0.;
131#define face_condition(fs, cs) \
132 (fs.x[i,j,k] > 0.5 && (fs.x[i,j,0] > 0.5 || fs.x[i,0,k] > 0.5) && \
133 fs.y[i,j + (j < 0),0] && fs.y[i-1,j + (j < 0),0] && \
134 fs.y[i,j + (j < 0),k] && fs.y[i-1,j + (j < 0),k] && \
135 fs.z[i,0,k + (k < 0)] && fs.z[i-1,0,k + (k < 0)] && \
136 fs.z[i,j,k + (k < 0)] && fs.z[i-1,j,k + (k < 0)] && \
137 cs[i-1,j,0] && cs[i-1,0,k] && cs[i-1,j,k] && \
138 cs[i,j,0] && cs[i,0,k] && cs[i,j,k])
149 return (((
a[
i,0,0] -
a[
i-1,0,0])*(1. -
p.y) +
150 (
a[
i,
j,0] -
a[
i-1,
j,0])*
p.y)*(1. -
p.z) +
151 ((
a[
i,0,
k] -
a[
i-1,0,
k])*(1. -
p.y) +
183#undef face_gradient_x
184#define face_gradient_x(a,i) \
185 (a.third && fs.x[i] < 1. && fs.x[i] > 0. ? \
186 embed_face_gradient_x (point, a, i) : \
187 (a[i] - a[i-1])/Delta)
189#undef face_gradient_y
190#define face_gradient_y(a,i) \
191 (a.third && fs.y[0,i] < 1. && fs.y[0,i] > 0. ? \
192 embed_face_gradient_y (point, a, i) : \
193 (a[0,i] - a[0,i-1])/Delta)
195#undef face_gradient_z
196#define face_gradient_z(a,i) \
197 (a.third && fs.z[0,0,i] < 1. && fs.z[0,0,i] > 0. ? \
198 embed_face_gradient_z (point, a, i) : \
199 (a[0,0,i] - a[0,0,i-1])/Delta)
202#define face_value(a,i) \
203 (a.third && fs.x[i] < 1. && fs.x[i] > 0. ? \
204 embed_face_value_x (point, a, i) : \
211#undef center_gradient
212#define center_gradient(a) (fs.x[] && fs.x[1] ? (a[1] - a[-1])/(2.*Delta) : \
213 fs.x[1] ? (a[1] - a[])/Delta : \
214 fs.x[] ? (a[] - a[-1])/Delta : 0.)
242 if (
cs[] > 0. &&
cs[] < 1.) {
250#define embed_pos() embed_area_center (point, &x, &y, &z)
296 double smin = 0.,
bool opposite =
false)
312 if (
s.x[] && ((!
c[] || !
c[-1]) ||
s.x[] < smin))
317 if (
c[] > 0. &&
c[] < 1.) {
320 for (
int i = 0;
i <= 1;
i++)
332 if (opposite &&
s.x[] == 0. &&
s.x[1] == 0.)
349 fprintf (
stderr,
"src/embed.h:%d: warning: fractions_cleanup() did not converge after "
373#define quadratic(x,a1,a2,a3) \
374 (((a1)*((x) - 1.) + (a3)*((x) + 1.))*(x)/2. - (a2)*((x) - 1.)*((x) + 1.))
389 for (
int l = 0;
l <= 1;
l++) {
391 d[
l] = (
i -
p.x)/
n.x;
392 double y1 =
p.y +
d[
l]*
n.y;
393 int j =
y1 > 0.5 ? 1 :
y1 < -0.5 ? -1 : 0;
400 double z =
p.z +
d[
l]*
n.z;
401 int k =
z > 0.5 ? 1 :
z < -0.5 ? -1 : 0;
515 if (
cs[] > 0. &&
cs[] < 1.) {
536 if (constant(
mu.x) != 0.) {
537 double mua = 0.,
fa = 0.;
665 if (
cs[] >= 1. ||
cs[] <= 0.)
700 double mua = 0.,
fa = 0.;
721 *((
bool *)
data) =
true, expr : 2.*expr -
s[];
728 return data ? *((
bool *)
data) =
true, 0 : -
s[];
736 *((
bool *)
data) =
false, expr :
Delta*expr +
s[];
743 return data ? *((
bool *)
data) =
false, 0 :
s[];
772#define bilinear(point, s) bilinear_embed(point, s)
828 else if (
cs[] >= 1.) {
845 for (
int i = 0;
i <= 1;
i++)
878 for (
int _n = 0;
_n < 1;
_n++)
891 for (
int _n = 0;
_n < 1;
_n++)
954 display (
"draw_vof (c = 'cs', s = 'fs', filled = -1, "
955 "fc = {0.5,0.5,0.5}, order = 2);");
vector uf[]
We allocate the (face) velocity field.
double dtmax
The timestep is computed using the CFL condition on the face velocity field.
if TRASH define &&NewPid *& val(newpid, 0, 0, 0)) -> pid > 0) @else @ define is_newpid()(((NewPid *)&val(newpid, 0, 0, 0)) ->pid > 0) @endif Array *linear_tree(size_t size, scalar newpid)
define m((k)==0 &&(l)==0 &&(m)==0) macro2 foreach_point(double _x=0.
void display(const char *commands, bool overwrite=false)
static number sq(number x)
static int sign(number x)
#define mu(f)
By default the Harmonic mean is used to compute the phase-averaged dynamic viscosity.
scalar f[]
The primary fields are:
return hxx pow(1.+sq(hx), 3/2.)
static void embed_fraction_refine(Point point, scalar cs)
scalar cs[]
The volume and area fractions are stored in these fields.
static coord embed_gradient(Point point, vector u, coord p, coord n)
macro2 double neumann(double expr, Point point=point, scalar s=_s, bool *data=data)
double embed_interpolate(Point point, scalar s, coord p)
This function returns the value of field s interpolated linearly at the barycenter p of the fragment ...
*cs[i, 0, 0] a *[i -1, 0, 0] j
double embed_flux(Point point, scalar s, vector mu, double *val)
macro2 double neumann_homogeneous(double expr, Point point=point, scalar s=_s, bool *data=data)
scalar scalar coord coord p
scalar scalar coord coord double double * coef
For non-degenerate cases, the gradient is obtained using either second- or third-order estimates.
double(* metric_embed_factor)(Point, coord)
#define quadratic(x, a1, a2, a3)
static double embed_geometry(Point point, coord *p, coord *n)
macro2 double dirichlet(double expr, Point point=point, scalar s=_s, bool *data=data)
For ease of use, we replace the Neumann and Dirichlet functions with macros so that they can be used ...
scalar scalar coord coord double bc
static double embed_area_center(Point point, double *x1, double *y1, double *z1)
This function and the macro below shift the position $(x1,y1,z1)$ to the position of the barycenter o...
*cs[i, 0, 0] a *[i -1, 0, 0] *cs[i, j, 0] a *[i -1, j, 0] cs(cs[i, j, 0]+cs[i -1, j, 0]+3.)))/2. attribute
The generalisation to 3D is a bit more complicated.
void event_defaults(void)
We add the embedded boundary to the default display.
trace int fractions_cleanup(scalar c, vector s, double smin=0., bool opposite=false)
trace void embed_force(scalar p, vector u, vector mu, coord *Fp, coord *Fmu)
The force exerted by the fluid on the solid can be written.
trace void update_tracer(scalar f, vector uf, vector flux, double dt)
#define face_condition(fs, cs)
Face gradients and face values, computed from cell-centered values must be tuned to take into account...
macro2 double dirichlet_homogeneous(double expr, Point point=point, scalar s=_s, bool *data=data)
double embed_vorticity(Point point, vector u, coord p, coord n)
In two dimensions, embed_vorticity() returns the vorticity of velocity field u, on the surface of the...
void event_metric(void)
Event: metric (i = 0)
#define cs_avg(a, i, j, k)
When combining third-order Dirichlet conditions and approximate projections, instabilities may occur ...
double dirichlet_gradient(Point point, scalar s, scalar cs, coord n, coord p, double bc, double *coef)
#define SEPS
Embedded boundary operators specific to trees are defined in this file.
void fraction_refine(Point point, scalar c)
coord facet_normal(Point point, scalar c, vector s)
double line_alpha(double c, coord n)
void line_center(coord m, double alpha, double a, coord *p)
This function fills the coordinates p of the centroid of the fraction a of a square cell lying under ...
#define plane_area_center(m, a, p)
static float area(const KdtRect rect)
void(* restriction)(Point, scalar)
static double bilinear(Point point, scalar s)
This function "removes" (by setting their volume fraction to zero) cells which have inconsistent volu...
define n n define coarse(a, k, p, n)((double *)(PARENT(k