prologues:=3; filenametemplate "%j-%c.mps"; numeric parts; parts = 16; % total number of partitions numeric ol_nodes; ol_nodes = 2; % outer left nodes numeric or_nodes; or_nodes = 1; % outer right nodes numeric inner_nodes; inner_nodes = parts - 1 - ol_nodes - or_nodes; % inner nodes numeric cinf, csup, h; % computational domain left and right boundary, and gridstep % The interval is taken to be [0, l] numeric l; l = 5cm; % and we assume that its left and right boundary happen halfway through between % the rightmost outer left node and the first inner node, and between the last % inner node and the leftmost outer right node on the other side. Hence, we % have inner_nodes - 1 inner partitions, plus two halves (one on the left and % one on the right). It follows that: % % * the gridstep is l/inner_nodes h = l/inner_nodes; % * the left computational domain boundary is -(ol_nodes*h + h/2) cinf = -(ol_nodes*h + h/2); % * the right computational domain boundary is l+(or_nodes*h + h/2) csup = l+(or_nodes*h + h/2); % depth of node marks numeric shortmarklength, longmarklength; shortmarklength = 0.05cm; longmarklength = 2*shortmarklength; % base of marks numeric markbase; markbase = 0; % A macro to draw 'standard' node marks vardef mark expr coord = draw (coord, markbase-shortmarklength)--(coord, markbase+shortmarklength); enddef; % A macro to draw 'long' node marks vardef longmark expr coord = draw (coord, markbase-longmarklength)--(coord, markbase+longmarklength); enddef; % A macro to draw 'squig' node marks vardef squigmark expr coord = draw (coord, markbase-longmarklength){left}.. {right}(coord, markbase-shortmarklength){right}.. {left}(coord, markbase){left}.. {right}(coord, markbase+shortmarklength){right}.. {left}(coord, markbase+longmarklength); enddef; % A macro to draw the grid at the current level vardef drawgrid expr level = markbase := -10*level*longmarklength; draw (cinf, markbase)--(csup,markbase); longmark cinf; longmark csup; squigmark 0; squigmark l; for i = (level+1) step (level+1) until (parts-1): mark cinf+i*h; endfor; enddef; beginfig(1) numeric prevmarkbase; % fine grid drawgrid 0; prevmarkbase := markbase; % coarse grid drawgrid 1; % draw arrows ahangle := 20; for i = 2 step 2 until (parts-1): drawdblarrow subpath (.11, .90) of ((cinf+i*h, markbase) -- (cinf+(i-1)*h, prevmarkbase)); drawdblarrow subpath (.12, .89) of ((cinf+i*h, markbase) -- (cinf+i*h, prevmarkbase)); drawdblarrow subpath (.11, .90) of ((cinf+i*h, markbase) -- (cinf+(i+1)*h, prevmarkbase)) if i = 2: withcolor red elseif i=parts-2: withcolor blue fi; endfor; endfig; bye;