124 const char *
kernel,
const void * externals)
126 static int index = 1;
130 for (
const External *
i = externals;
i &&
i->name;
i++,
m++);
139 .
name = (
char *) name,
147#define foreach_function(f, body) do { \
148 for (khiter_t k = kh_begin(_functions); k != kh_end(_functions); ++k) \
149 if (kh_exist(_functions, k)) { \
150 External * f = &kh_value(_functions, k); \
191 while (
sb.i <
nvar &&
n < block &&
sb.freed)
195 for (
sb.i =
s.
i,
n = 0;
n < block;
n++,
sb.i++) {
215 for (
int n = 0;
n < block;
n++,
nvar++) {
229 for (
sb.i =
s.
i,
n = 0;
n < block;
n++,
sb.i++)
243 for (
sb.i =
s.
i,
n = 0;
n < block;
n++,
sb.i++)
256 struct {
char *
x, *
y, *
z; }
ext = {
".x",
".y",
".z"};
279 for (
int i = 0;
i < block;
i++) {
295 for (
int i = 0;
i < block;
i++) {
311 struct {
char *
x, *
y, *
z; }
ext = {
".x",
".y",
".z"};
323 struct {
char *
x, *
y, *
z; }
ext = {
".x.x",
".y.y",
".z.z"};
390 clone.boundary_homogeneous = boundary_homogeneous;
394 clone.boundary_homogeneous[
i] =
src.boundary_homogeneous[
i];
395 clone.boundary_stencil[
i] =
src.boundary_stencil[
i];
406 for (
int _s = 0;
_s < 1;
_s++) {
412 for (
int _s = 0;
_s < 1;
_s++)
414 if (
s.v.x.
i >= 0 && map[
s.v.x.
i] >= 0)
415 s.v.x.
i = map[
s.v.x.
i];
424 for (
int _f = 0;
_f < 1;
_f++) {
425 for (
int i = 0;
i <
f.block;
i++) {
430 free (fb.boundary); fb.boundary =
NULL;
431 free (fb.boundary_homogeneous); fb.boundary_homogeneous =
NULL;
432 free (fb.boundary_stencil); fb.boundary_stencil =
NULL;
433 free (fb.depends); fb.depends =
NULL;
445 for (
int _f = 0;
_f < 1;
_f++) {
450 for (;
s[
f.block].
i >= 0;
s++)
456 for (;
s[1].
i >= 0;
s++)
512#define boundary(...) \
513 boundary_internal ((scalar *)__VA_ARGS__, __FILE__, LINENO)
520 for (
int _v = 0;
_v < 1;
_v++)
530 for (
int _t = 0;
_t < 1;
_t++)
534 for (
int _d = 0;
_d < 1;
_d++)
548 for (
int _s = 0;
_s < 1;
_s++)
551 if (
s.face && !(
s.stencil.bc &
s_face))
562 fprintf (
stderr,
"warning: bc already applied on '%s'\n",
s.name);
571 for (
int _s = 0;
_s < 1;
_s++)
584 for (
int _s = 0;
_s < 1;
_s++)
589 for (
int _s = 0;
_s < 1;
_s++)
604 for (
int _s = 0;
_s < 1;
_s++) {
639 BoundaryFunc * boundary_homogeneous =
s.boundary_homogeneous;
645 s.block = block > 0 ? block : 1;
648 s.boundary_homogeneous = boundary_homogeneous ? boundary_homogeneous :
653 s.boundary[
b] =
s.boundary_homogeneous[
b] =
655 s.boundary_stencil[
b] =
NULL;
672 s.boundary[
d] =
s.boundary_homogeneous[
d] =
NULL,
s.boundary_stencil[
d] =
NULL;
684 struct {
char *
x, *
y, *
z; }
ext = {
".x",
".y",
".z"};
697 v.x.boundary[
d] =
v.x.boundary_homogeneous[
d] =
699 v.x.boundary_stencil[
d] =
NULL;
712 v.x.boundary[
d] =
v.x.boundary_homogeneous[
d] =
NULL,
v.x.boundary_stencil[
d] =
NULL;
718 struct {
char *
x, *
y, *
z; }
ext = {
".x",
".y",
".z"};
731 t.x.x.boundary[
b] =
t.x.x.boundary_homogeneous[
b] =
733 t.x.x.boundary_stencil[
b] =
NULL;
737 t.x.x.boundary[
b] =
t.y.x.boundary[
b] =
738 t.x.x.boundary_homogeneous[
b] =
t.y.y.boundary_homogeneous[
b] =
740 t.x.y.boundary[
b] =
t.y.y.boundary[
b] =
741 t.x.y.boundary_homogeneous[
b] =
t.y.x.boundary_homogeneous[
b] =
743 t.x.x.boundary_stencil[
b] =
t.y.y.boundary_stencil[
b] =
744 t.x.y.boundary_stencil[
b] =
t.y.x.boundary_stencil[
b] =
NULL;
766 fprintf (
fp,
"%g %g\n%g %g\n%g %g\n%g %g\n%g %g\n\n",
773 for (
int i = -1;
i <= 1;
i += 2) {
774 fprintf (
fp,
"%g %g %g\n%g %g %g\n%g %g %g\n%g %g %g\n%g %g %g\n\n",
780 for (
int j = -1;
j <= 1;
j += 2)
814 " load 'debug.plot'\n"
817 " plot '%s' w l lc 0, "
818 "'%s' u 1+2*v:(0):2+2*v w labels tc lt 1 title columnhead(2+2*v)",
820 " plot '%s' w l lc 0, "
821 "'%s' u 1+3*v:2+3*v:3+3*v w labels tc lt 1 title columnhead(3+3*v)",
823 " splot '%s' w l lc 0, "
824 "'%s' u 1+4*v:2+4*v:3+4*v:4+4*v w labels tc lt 1"
825 " title columnhead(4+4*v)",
833 char name[80] =
"cells";
835 sprintf (name,
"cells-%d", pid());
844 for (
int _v = 0;
_v < 1;
_v++)
854 for (
int k = -2;
k <= 2;
k++) {
855 for (
int _v = 0;
_v < 1;
_v++) {
865 for (
int k = -2;
k <= 2;
k++)
866 for (
int l = -2;
l <= 2;
l++) {
867 for (
int _v = 0;
_v < 1;
_v++) {
879 for (
int k = -2;
k <= 2;
k++)
880 for (
int l = -2;
l <= 2;
l++)
881 for (
int m = -2;
m <= 2;
m++) {
882 for (
int _v = 0;
_v < 1;
_v++) {
897 fp =
fopen (
"debug.plot",
"w");
900 "set size ratio -1\n"
901 "set key outside\n");
902 for (
int _s = 0;
_s < 1;
_s++) {
909 fprintf (
stderr,
"Last point stencils can be displayed using (in gnuplot)\n");
937 double xp = 0.,
double yp = 0.,
double zp = 0.)
944 return v[]*(1. -
x) +
v[
i]*
x;
951 return ((
v[]*(1. -
x) +
v[
i]*
x)*(1. -
y) +
960 return (((
v[]*(1. -
x) +
v[
i]*
x)*(1. -
y) +
961 (
v[0,
j]*(1. -
x) +
v[
i,
j]*
x)*
y)*(1. -
z) +
962 ((
v[0,0,
k]*(1. -
x) +
v[
i,0,
k]*
x)*(1. -
y) +
982 for (
int _s = 0;
_s < 1;
_s++)
984 for (
int i = 0;
i <
n;
i++) {
988 for (
int _s = 0;
_s < 1;
_s++) {
995 for (
int _s = 0;
_s < 1;
_s++)
999 for (
int _s = 0;
_s < 1;
_s++)
1014 for (
int _s = 0;
_s < 1;
_s++) {
1019 for (
int _s = 0;
_s < 1;
_s++) {
1022 else if (
s.v.x.
i ==
s.
i) {
1025 v.y.boundary[
b] =
v.y.boundary_homogeneous[
b] =
symmetry;
1026 v.x.boundary[
b] =
v.x.boundary_homogeneous[
b] =
1043 for (
int _s = 0;
_s < 1;
_s++) {
1045 s.boundary[
d] =
s.boundary_homogeneous[
d] =
NULL;
1048 s.boundary_stencil[
d] =
NULL;
1051 for (
int _s = 0;
_s < 1;
_s++)
1054 v.x.boundary[
d] =
v.x.boundary_homogeneous[
d] =
NULL;
1085 for (
int _s = 0;
_s < 1;
_s++) {
1086 if (
s.v.x.
i != -1) {
1088 for (
int _c = 0;
_c < 1;
_c++)
1115 fprintf (
stderr,
"%s:%d: error: trying to access a deleted field\n",
1158 fprintf (
stderr,
"%s:%d: error: trying to modify a%s field\n",
1159 file,
line,
s.
i < 0 ?
"n undefined" :
" constant");
1165 fprintf (
stderr,
"%s:%d: error: trying to access a deleted field\n",
void array_free(Array *a)
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 boundary_iterate(type,...)
void default_stencil(Point p, scalar *list)
trace void boundary_internal(scalar *list, const char *fname, int line)
There are two types of boundary conditions: "full" boundary conditions, done by boundary_internal() a...
trace double interpolate(scalar v, double xp=0., double yp=0., double zp=0., bool linear=true)
vector new_const_vector(const char *name, int i, double *val)
void init_const_scalar(scalar s, const char *name, double val)
BoundaryFunc default_scalar_bc[]
double getvalue(Point point, scalar s, int i, int j, int k)
void cartesian_debug(Point point)
define _val_constant(a, k, l, m)((const double) _constant[a.i -_NVARMAX]) @define val_diagonal(a
scalar cartesian_init_vertex_scalar(scalar s, const char *name)
static scalar * list_add_depends(scalar *list, scalar s)
void init_const_vector(vector v, const char *name, double *val)
tensor cartesian_init_tensor(tensor t, const char *name)
void(* boundary_face)(vectorl)
scalar * list_clone(scalar *l)
static void write_stencil_index(int *index)
This displays a (1D,2D,3D) stencil index.
define double double char flags
void stencil_val_a(Point p, scalar s, int i, int j, int k, bool input, const char *file, int line)
vector cartesian_init_vector(vector v, const char *name)
static double periodic_bc(Point point, Point neighbor, scalar s, bool *data)
scalar new_const_scalar(const char *name, int i, double val)
BoundaryFunc default_vector_bc[]
void stencil_val(Point p, scalar s, int i, int j, int k, const char *file, int line, bool overflow)
void cartesian_boundary_level(scalar *list, int l)
static void cartesian_scalar_clone(scalar clone, scalar src)
static void periodic_boundary(int d)
void(* boundary_level)(scalar *, int l)
tensor init_symmetric_tensor(tensor t, const char *name)
void cartesian_boundary_face(vectorl vl)
static double interpolate_linear(Point point, scalar v, double xp=0., double yp=0., double zp=0.)
scalar cartesian_init_scalar(scalar s, const char *name)
static double antisymmetry(Point point, Point neighbor, scalar s, bool *data)
static void debug_plot(FILE *fp, const char *name, const char *cells, const char *stencil)
static double symmetry(Point point, Point neighbor, scalar s, bool *data)
vector cartesian_init_face_vector(vector v, const char *name)
static char * replace_(const char *vname)
define double double char Reduce reductions
void output_cells(FILE *fp=stdout, coord c={0}, double size=0.)
void boundary_flux(vector *list) __attribute__((deprecated))
define m((k)==0 &&(l)==0 &&(m)==0) macro2 foreach_point(double _x=0.
trace void interpolate_array(scalar *list, coord *a, int n, double *v, bool linear=false)
Point locate(double xp=0, double yp=0, double zp=0)
define neighbor(o, p, q)((Point)
if TRASH undef trash define trash(list) reset(list
define VT _attribute[s.i] v y scalar * list
vector(* init_vector)(vector, const char *)
scalar(* init_vertex_scalar)(scalar, const char *)
void(* scalar_clone)(scalar, scalar)
static _Attributes * _attribute
scalar * list_add(scalar *list, scalar s)
tensor(* init_tensor)(tensor, const char *)
void(* free_solver_func)(void)
static Array * free_solver_funcs
scalar * list_copy(scalar *l)
void(* BoundaryStencilFunc)(Point, Point, scalar, void *)
vector(* init_face_vector)(vector, const char *)
static int sign(number x)
scalar * list_append(scalar *list, scalar s)
static bool is_vertex_scalar(scalar s)
scalar(* init_scalar)(scalar, const char *)
double(* BoundaryFunc)(Point, Point, scalar, bool *)
scalar f[]
The primary fields are:
define sysmalloc malloc define syscalloc calloc define sysrealloc realloc define sysfree free define systrdup strdup define line line line line type
static void qpclose_all()
define sysmalloc malloc define syscalloc calloc define sysrealloc realloc define sysfree free define systrdup strdup define line calloc(n, s) @ define prealloc(p
define m m double _val_higher_dimension
define sysmalloc malloc define syscalloc calloc define sysrealloc realloc define sysfree free define systrdup strdup define file
define sysmalloc malloc define syscalloc calloc define sysrealloc realloc define sysfree free define systrdup strdup define line line realloc(p, s) @ define pfree(p
define sysmalloc malloc define syscalloc calloc define sysrealloc realloc define sysfree free define systrdup strdup define line line line line strdup(s) @ define tracing(...) @ define end_tracing(...) @define tid() 0 @define pid() 0 @define npe() 1 @define mpi_all_reduce(v
trace bool box(bool notics=false, float lc[3]={0}, float lw=1.)
trace bool cells(coord n={0, 0, 1}, double alpha=0., float lc[3]={0}, float lw=1.)
macro2 double neumann(double expr, Point point=point, scalar s=_s, bool *data=data)
*cs[i, 0, 0] a *[i -1, 0, 0] j
macro2 double neumann_homogeneous(double expr, Point point=point, scalar s=_s, bool *data=data)
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 ...
macro2 double dirichlet_homogeneous(double expr, Point point=point, scalar s=_s, bool *data=data)
#define realloc_scalar(size)
#define kh_get(name, h, k)
#define kh_destroy(name, h)
#define KHASH_MAP_INIT_INT64(name, khval_t)
#define kh_put(name, h, k, r)
void boundary_stencil(ForeachData *loop)
This functions applies the boundary conditions, as defined by check_stencil().
static bool scalar_is_dirty(scalar s)
define n sizeof(Cell))) @define fine(a
def allocated(k, l, n)(mem_allocated(((Tree *) grid) -> L[point.level]->m, point.i+k, point.j+l)) @ @def NEIGHBOR(k, l, n)(((((Tree *) grid) ->L[point.level]->m) ->b[point.i+k][point.j+l])) @ @def PARENT(k, l, n)(((((Tree *) grid) ->L[point.level-1]->m) ->b[(point.i+2)/2+k][(point.j+2)/2+l])) @ @def allocated_child(k, l, n)(level< depth() &&mem_allocated(((Tree *) grid) ->L[point.level+1]->m, 2 *point.i- 2+k, 2 *point.j- 2+l)) @ @def CHILD(k, l, n)(((((Tree *) grid) ->L[point.level+1]->m) ->b[2 *point.i- 2+k][2 *point.j- 2+l])) @ @define CELL(m)(*((Cell *)(m))) @define depth()(grid->depth) @define aparent(k, l, n) CELL(PARENT(k, l, n)) @define child(k, l, n) CELL(CHILD(k, l, n)) @define cell CELL(NEIGHBOR(0, 0, 0)) @define neighbor(k, l, n) CELL(NEIGHBOR(k, l, n)) @def neighborp(l, m, n)(Point)