52void view (
float tx = 0.,
float ty = 0.,
55 float sx = 1.,
float sy = 1.,
float sz = 1.,
56 unsigned width = 800,
unsigned height = 800,
unsigned samples = 4,
60 float tz = 0.,
float near = 0.,
float far = 0.,
65 float p1x = 0.,
float p1y = 0.,
float p2x = 0.,
float p2y = 0.,
71 v->fov += (0.1 + 3.*
v->fov)*fov;
74 v->fov =
clamp(
v->fov,0.01,100.);
76 for (
int i = 0;
i < 4;
i++)
78 for (
int j = 0;
j < 4;
j++)
82 v->tx =
relative ?
v->tx + tx*0.02*(0.01 + 3.*
v->fov) : tx;
83 v->ty =
relative ?
v->ty + ty*0.02*(0.01 + 3.*
v->fov) : ty;
87 if (bg[0] || bg[1] || bg[2])
88 for (
int i = 0;
i < 3;
i++)
105 nq =
sscanf (
s,
" q0 = %f q1 = %f q2 = %f q3 = %f",
106 &
q[0], &
q[1], &
q[2], &
q[3]);
108 nf =
sscanf (
s,
" fov = %f", &fov);
110 if (
nq != 4 || nf != 1) {
114 for (
int j = 0;
j < 4;
j++)
181 if ((width && width !=
v->width) ||
183 (samples && samples !=
v->samples)) {
184 v->width =
v->width/
v->samples;
185 v->height =
v->height/
v->samples;
186 if (width)
v->width = width;
188 if (samples)
v->samples = samples;
189 v->width *=
v->samples;
190 v->height *=
v->samples;
251 s[0] = 1. - 2.*
m.x*
m.x;
252 s[1] = - 2.*
m.x*
m.y;
s[2] = - 2.*
m.x*
m.z;
255 s[5] = 1. - 2.*
m.y*
m.y;
s[6] = - 2.*
m.y*
m.z;
257 s[8] =
s[2];
s[9] =
s[6];
s[10] = 1. - 2.*
m.z*
m.z;
259 s[12] = 0.;
s[13] = 0.;
s[14] = 0.;
262 t[0] = 1.;
t[1] = 0.;
t[2] = 0.;
t[3] = 0.;
263 t[4] = 0.;
t[5] = 1.;
t[6] = 0.;
t[7] = 0.;
264 t[8] = 0.;
t[9] = 0.;
t[10] = 1.;
t[11] = 0.;
294 double x =
p->x,
y =
p->y,
z =
p->z,
rm = 0.;
296 for (
int i = -1;
i <= 1;
i += 2)
297 for (
int j = -1;
j <= 1;
j += 2)
298 for (
int k = -1;
k <= 1;
k += 2) {
349 if (
view->gfsview ||
view->reversed)
397 view->reversed =
false;
414 case '1':
return n->d.value;
449 for (
int i = 0;
i < 3;
i++)
452 return s[
k[0],
k[1],
k[2]];
454 case 'D':
return Delta;
467 if (
n->type ==
'v') {
474 if (!
strcmp (
id,
"Delta"))
476 else if (!
strcmp (
id,
"x"))
478 else if (!
strcmp (
id,
"y"))
480 else if (!
strcmp (
id,
"z"))
483 typedef struct {
char * name;
double val; }
Constant;
499 if (
n->type ==
'v') {
506 for (
int i = 0;
i < 3;
i++)
554#define colorize_args() \
556 if (color && strcmp (color, "level")) { \
557 col = compile_expression (color, &expr); \
562 double cmap[NCMAP][3]; \
564 if (min == 0 && max == 0) { \
566 min = 0, max = depth(); \
568 stats s = statsf (col); \
569 double avg = s.sum/s.volume; \
571 min = s.min, max = s.max; \
573 if (!spread) spread = 5.; \
574 min = avg - spread*s.stddev; max = avg + spread*s.stddev; \
583 if ((dimension > 2 || linear) && \
584 !fc[0] && !fc[1] && !fc[2]) \
585 fc[0] = fc[1] = fc[2] = 1.; \
588 colorbar (map, size, pos, label, lscale, min, max, \
589 horizontal, border, mid, \
590 lc, lw, fsize, format, levels);
592#define color_facet() \
593 if (color && (!linear || col.i < 0)) { \
594 Color b = colormap_color (cmap, col.i < 0 ? \
595 (double) level : val(col,0,0,0), \
597 glColor3f (b.r/255., b.g/255., b.b/255.); \
600#define color_vertex(val) \
601 if (color && linear && col.i >= 0) { \
602 if (VertexBuffer.color) { \
603 Color b = colormap_color (cmap, val, min, max); \
604 glColor3f (b.r/255., b.g/255., b.b/255.); \
609 glTexCoord1d (clamp(((_v) - min)/(max - min), 0., 1.)); \
621 for (
int i = 0;
i < 256;
i++) {
642#define colorize() colorized (fc, !VertexBuffer.color || !color, \
643 cmap, !VertexBuffer.color && \
644 color && linear && col.i >= 0)
671 bool mid =
false,
float lc[3] = {0},
float lw = 3,
float fsize = 50,
686 float width = 2./
size;
798#define COLORBAR_PARAMS \
800 float size = 15, float pos[2] = {-.95, -.95}, \
801 char * label = "", double lscale = 1, \
802 bool horizontal = false, bool border = false, \
803 bool mid = false, float fsize = 50, \
804 char * format = "%g", int levels = 50
821 if (
c[] >= 1. -
cmin) {
829 for (
int _n = 0;
_n < 1;
_n++) {
860 double xp,
double yp,
double zp)
903 float fc[3] = {0},
float lc[3] = {0},
float lw = 1.,
940 else if (
d[] > 0. &&
d[] < 1.) {
948 if (
n.x < 0.)
alpha -=
n.
x,
n.x = -
n.x, r.x = - 1.;
957 v[
nv].x = 0.,
v[
nv++].y = 1.;
959 v[
nv].x = 0.,
v[
nv++].y = 0.;
965 v[
nv].x = 0.,
v[
nv++].y = 1.;
969 v[
nv].x = 0.,
v[
nv++].y = 0.;
970 v[
nv].x = 1.,
v[
nv++].y = 0.;
974 for (
int i =
nv - 1;
i >= 0;
i--)
978 for (
int i = 0;
i <
nv;
i++)
1015 for (
int i = 0;
i <
m;
i++)
1033 for (
int i = 0;
i <
m;
i++) {
1057 if (expr)
delete({
col});
1080 float fc[3] = {0},
float lc[3] = {0},
float lw = 1.,
1109 if (expr)
delete ({
col});
1129 float lc[3] = {0},
float lw = 1.)
1149 for (
int i = 0;
i <
m;
i++)
1170 struct {
char x,
y,
z; }
index = {
'x',
'y',
'z'};
1181 float res =
view->res;
1184 int maxlevel =
view->maxlevel;
1193 y +
f.y - (
f.x/2. +
f.y)/5.);
1197 y +
f.y + (
f.x/2. -
f.y)/5.);
1205 view->maxlevel = maxlevel;
1207 fprintf (
stderr,
"vectors() is not implemented in 3D yet\n");
1236 float fc[3] = {0},
float lc[3] = {0},
1273 2.*(
f[1] +
f[-1] +
f[0,1] +
f[0,-1]) +
1274 f[-1,-1] +
f[1,1] +
f[-1,1] +
f[1,-1])/16.);
1295 2.*(
f[1] +
f[-1] +
f[0,1] +
f[0,-1]) +
1296 f[-1,-1] +
f[1,1] +
f[-1,1] +
f[1,-1])/16.);
1300 (
Z[] +
Z[-1] +
Z[-1,-1] +
Z[0,-1])/4.);
1303 (
Z[] +
Z[1] +
Z[1,-1] +
Z[0,-1])/4.);
1306 (
Z[] +
Z[1] +
Z[1,1] +
Z[0,1])/4.);
1309 (
Z[] +
Z[-1] +
Z[-1,1] +
Z[0,1])/4.);
1312 (
Z[] +
Z[-1] +
Z[-1,-1] +
Z[0,-1])/4.);
1323 for (
int i = 0;
i <
m;
i++)
1329 for (
int i = 0;
i <
m;
i++) {
1368 for (
int i = 0;
i <
m;
i++) {
1379 if (expr)
delete ({
col});
1435 for (
int i = -1;
i <= 1;
i += 2) {
1444 for (
int j = -1;
j <= 1;
j += 2) {
1456 for (
int i = 0;
i <=
nt;
i++) {
1542 float fc[3] = {0},
float lc[3] = {0},
float lw = 1,
1562 fv[] = (
ff[] +
ff[-1] +
ff[0,-1] +
ff[-1,-1] +
1563 ff[0,0,-1] +
ff[-1,0,-1] +
ff[0,-1,-1] +
ff[-1,-1,-1])/8.;
1575 fv[0,0,0],
fv[1,0,0],
fv[1,0,1],
fv[0,0,1],
1576 fv[0,1,0],
fv[1,1,0],
fv[1,1,1],
fv[0,1,1]
1580 for (
int i = 0;
i <
nt;
i++) {
1583 for (
int j = 0;
j < 3;
j++) {
1601 if (expr)
delete ({
col});
1615#define interpo(pv, v) \
1616 (!pv ? v : ((t - start)*(pv) + (end - t)*(v))/(end - start))
1619 float tx = 0,
float ty = 0,
float quat[4] = {0},
float fov = 0)
1622 static double told = -1.;
1626 for (
int i = 0;
i < 4;
i++)
1629 if (
t >= start &&
t <= end)
1637 for (
int i = 0;
i < 4;
i++)
1662 float lc[3] = {0},
float lw = 1)
1715 float res =
view->res;
1718 int maxlevel =
view->maxlevel;
1735 view->maxlevel = maxlevel;
1736 if (expr)
delete ({
ff});
1739 fprintf (
stderr,
"labels() is not implemented in 3D yet\n");
1773 while (
c ==
' ' ||
c ==
'\t')
c =
fgetc (
fp);
1774 if (
c ==
'.' ||
c ==
'+' ||
c ==
'-' ||
isdigit (
c)) {
1783 while ((
c =
fgetc(
fp)) ==
' ' ||
c ==
'\t');
vector q[]
The primitive variables are the momentum , pressure , density , (face) specific volume ,...
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 double double char flags
static double interpolate_linear(Point point, scalar v, double xp=0., double yp=0., double zp=0.)
define double double char Reduce reductions
define m((k)==0 &&(l)==0 &&(m)==0) macro2 foreach_point(double _x=0.
static number sq(number x)
static number clamp(number x, number a, number b)
#define center_gradient(a)
static bool is_vertex_scalar(scalar s)
scalar f[]
The primary fields are:
else define undefined((double) DBL_MAX) @ define enable_fpe(flags) @ define disable_fpe(flags) static void set_fpe(void)
if __APPLE__ include< stdint.h > include fp_osx h endif if _GPU define enable_fpe(flags) @else @ define enable_fpe(flags) feenableexcept(flags) @endif @ define disable_fpe(flags) fedisableexcept(flags) static void set_fpe(void)
define sysmalloc malloc define syscalloc calloc define sysrealloc realloc define sysfree free define systrdup strdup define line calloc(n, s) @ define prealloc(p
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 line line strdup(s) @ define tracing(...) @ define end_tracing(...) @define tid() 0 @define pid() 0 @define npe() 1 @define mpi_all_reduce(v
return hxx pow(1.+sq(hx), 3/2.)
trace bool isoline(char *phi, double val=0., int n=1, bool edges=false, double larger=0., int filled=0, char *color=NULL, double min=0, double max=0, double spread=0, bool linear=false, Colormap map=jet, float fc[3]={0}, float lc[3]={0}, float lw=1., bool expr=false, bool cbar=false, float size=15, float pos[2]={-.95, -.95}, char *label="", double lscale=1, bool horizontal=false, bool border=false, bool mid=false, float fsize=50, char *format="%g", int levels=50)
struct @2 bview_interface[]
trace bool squares(char *color, char *z=NULL, double min=0, double max=0, double spread=0, bool linear=false, Colormap map=jet, float fc[3]={0}, float lc[3]={0}, bool expr=false, coord n={0, 0, 1}, double alpha=0, float lw=1, bool cbar=false, float size=15, float pos[2]={-.95, -.95}, char *label="", double lscale=1, bool horizontal=false, bool border=false, bool mid=false, float fsize=50, char *format="%g", int levels=50)
macro2 foreach_visible_stencil(bview *view, char flags, Reduce reductions)
static bool cfilter(Point point, scalar c, double cmin)
The somewhat complicated function below checks whether an interface fragment is present within a give...
static void glvertex3d(bview *view, double x, double y, double z)
#define COLORBAR_PARAMS
Parameters for an (optional) colorbar.
void view(float tx=0., float ty=0., float fov=0., float quat[4]={0}, float sx=1., float sy=1., float sz=1., unsigned width=800, unsigned height=800, unsigned samples=4, float bg[3]={0}, float theta=0., float phi=0., float psi=0., bool relative=false, float tz=0., float near=0., float far=0., float res=0., char *camera=NULL, MapFunc map=NULL, int cache=0, float p1x=0., float p1y=0., float p2x=0., float p2y=0., bview *view1=NULL)
trace bool labels(char *f, float lc[3]={0}, float lw=1, int level=-1)
int(* json)(char *s, int len)
static void mapped_position(bview *view, coord *p, double *r)
static void glvertex2d(bview *view, double x, double y)
trace bool isosurface(char *f, double v, char *color=NULL, double min=0, double max=0, double spread=0, bool linear=false, Colormap map=jet, float fc[3]={0}, float lc[3]={0}, float lw=1, bool expr=false, bool cbar=false, float size=15, float pos[2]={-.95, -.95}, char *label="", double lscale=1, bool horizontal=false, bool border=false, bool mid=false, float fsize=50, char *format="%g", int levels=50)
trace bool draw_vof(char *c, char *s=NULL, bool edges=false, double larger=0., int filled=0, char *color=NULL, double min=0, double max=0, double spread=0, bool linear=false, Colormap map=jet, float fc[3]={0}, float lc[3]={0}, float lw=1., bool expr=false, bool cbar=false, float size=15, float pos[2]={-.95, -.95}, char *label="", double lscale=1, bool horizontal=false, bool border=false, bool mid=false, float fsize=50, char *format="%g", int levels=50)
macro translate(float x=0, float y=0., float z=0.)
static double evaluate_expression(Point point, Node *n)
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.)
macro mirror(coord n={0}, double alpha=0.)
static void glvertex_normal3d(bview *view, Point point, vector n, double xp, double yp, double zp)
#define color_vertex(val)
static double interp(Point point, coord p, scalar col)
trace bool draw_string(char *str, int pos=0, float size=40, float lc[3]={0}, float lw=1)
void travelling(double start=0, double end=0, float tx=0, float ty=0, float quat[4]={0}, float fov=0)
trace bool colorbar(Colormap map=jet, float size=15, float pos[2]={-.95, -.95}, char *label="", double lscale=1, double min=-HUGE, double max=HUGE, bool horizontal=false, bool border=false, bool mid=false, float lc[3]={0}, float lw=3, float fsize=50, char *format="%g", int levels=50)
static scalar compile_expression(char *expr, bool *isexpr)
macro2 foreach_visible(bview *view, char flags=0, Reduce reductions=None)
static bool assemble_node(Node *n)
macro colorized(float fc[3], bool constant_color, double cmap[NCMAP][3], bool use_texture)
macro draw_lines(bview *view, float color[3], float lw)
A similar technique can be used to traverse the cells which are both visible and intersected by a pla...
int _isosurface_json(char *s, int len)
int _draw_vof_json(char *s, int len)
int _cells_json(char *s, int len)
int _labels_json(char *s, int len)
int _vectors_json(char *s, int len)
int _squares_json(char *s, int len)
int _box_json(char *s, int len)
int _isoline_json(char *s, int len)
int _lines_json(char *s, int len)
scalar phi[]
The electric potential and the volume charge density are scalars while the permittivity and conductiv...
*cs[i, 0, 0] a *[i -1, 0, 0] j
void fraction_refine(Point point, scalar c)
coord facet_normal(Point point, scalar c, vector s)
trace void fractions(scalar Phi, scalar c, vector s={0}, double val=0.)
int facets(coord n, double alpha, coord p[2])
From the interface definition, it is also possible to compute the coordinates of the segment in 2D,...
#define GL_TEXTURE_MIN_FILTER
#define GL_TEXTURE_WRAP_S
#define GL_TEXTURE_WRAP_T
#define GL_TEXTURE_MAG_FILTER
macro2 foreach_stencil(char flags, Reduce reductions, int _parallel, External *_externals, const char *_kernel)
static double height(double H)
static void relative(const KdtRect rect, double *o, double *h)
static float length(const KdtRect rect)
macro
We also redefine the "per field" (inner) traversal.
void(* restriction)(Point, scalar)
void set_prolongation(scalar s, void(*prolongation)(Point, scalar))
define is_active() cell(true) @define is_leaf(cell)(point.level
void(* Colormap)(double cmap[127][3])
Color colormap_color(double cmap[127][3], double val, double min, double max)
void jet(double cmap[127][3])
Given a colormap and a minimum and maximum value, this function returns the red/green/blue triplet co...
define n n define n n macro POINT_VARIABLES(Point point=point)
vector lookup_vector(const char *name)
scalar lookup_field(const char *name)
These functions return the scalar/vector fields called name, or -1 if they don't exist.
double theta
This is the generalised minmod limiter.
static bview * _view
For the moment there is a single (static) current view.
bview * draw()
This is called by graphics primitives before drawing.
static cexpr * add_cexpr(cexpr *cache, int maxlen, const char *expr, scalar s)
static scalar get_cexpr(cexpr *cache, const char *expr)