Chombo Boot Camp Lecture 3 Multi Dim Chombo
Chombo Boot. Camp Lecture 3: Multi. Dim Chombo
Example: Phase-space • 06/29/2011 Chombo Boot Camp 2
Multi. Dim Chombo • “normal Chombo -- compile-time dimensionality - Dimensionality is pervasive (Space. Dim, D_DECL, etc macros, Ch. F) • Solution – namespaces - Each dimensionality lives in its own distinct namespace: (Chombo: : D 1) - Transdimensional utilities for moving between dimensions - (inject from D to D+1, slice from D to D-1) - Reduction and Spreading utilities within a single dimension - Reduction. Copier, Sum. Op, Spreading. Op - Spreading done by defining Reduction. Copier, then calling reverse() function - Most of the time, work in a single dimensional namespace - Only worry about dimensionality in the interface points 06/29/2011 Chombo Boot Camp 3
Multi. Dim, cont 06/29/2011 Chombo Boot Camp 4
Example : Reduction by summing in y-direction // function to reduce a 2 D Level. Data<FArray. Box> to 1 D by // summing over the y-direction void reduce 2 DTo 1 D(D 1: : Level. Data<D 1: : FArray. Box> >& dest. Data, D 2: : Level. Data<D 2: : Farray. Box> >& src. Data) { // create 2 D version of 1 D boxes D 2: : Level. Data<D 2: : Farray. Box> slice. Grids; D 2: : Slice. Spec slice(1, 0); inject. Disjoint. Box. Layout(slice. Grids, src. Data. get. Boxes(), slice); // define sliced data holder D 2: : Level. Data<D 2: : FArray. Box> reduced. Data(slice. Grids, src. Data. n. Comp); 06/29/2011 Chombo Boot Camp 5
// define Reduction. Copier to compute intersections //(sum in the y-direction) int transverse. Dir = 1; Reduction. Copier reduce. Copier(src. Data. get. Boxes(), slice. Grids, 1); Sum. Op op(transverse. Dir); op. scale = 1. 0; /* do summing operation -- sums data in src. Data along lines in the y-direction and places sum in reduced. Data */ src. Data. copy. To(src. Data. interval(), reduced. Data. interval(), reduce. Copier, op); /*finally, take the data in reduced. Data (which is a 2 D object) and slice to 1 D */ slice. Level. Data(dest. Data, reduced. Data, slice); } 06/29/2011 Chombo Boot Camp 6
06/29/2011 Chombo Boot Camp 7
Multi. Dim Builds • Special build system • Base. Tools library has no dimensionality • Other Chombo libraries can be used with any DIM - Special headers placed in Chombo/lib/include/multidim • Chombo/lib/Multi. Dim contains transdim support - Slicing. H. transdim, Injection. H. transdim • Use 2 GNUmakefiles in local build directory - GNUmakefile: specifies ebase, MINDIM, MAXDIM, MULTIDIM_MAKEFILE - GNUmakefile. multidim: specifies libraries and src directories: - 1 d. Lib. Names, 2 d. Lib. Names, 3 d. Lib. Names, … - 1 dsrc_dirs, 2 dsrc_dirs, 3 dsrc_dirs, … - mdsrc_dirs (files without a compile-time dimension) 06/29/2011 Chombo Boot Camp 8
GNUmakefile: #the location of Chombo lib dir CHOMBO_HOME =. . /lib ebase = phase MINDIM = 1 MAXDIM = 2 # this is the local GNUmakefile which contains this example's # multidim build info -- libraries and src directory information MULTIDIM_MAKEFILE = GNUmakefile. multidim # this is the default target, which just invokes the all-multidim target all: all-multidim # this file contains the basic rules used to build multidim codes (using # the GNUmakefile. multidim in this directory), including the shell script # which orchestrates the make process include $(CHOMBO_HOME)/mk/Make. multidim. basic 06/29/2011 Chombo Boot Camp 9
GNUmakefile. multidim ## Define the variables needed by Make. example # the location of Chombo lib dir CHOMBO_HOME =. . /lib # names of Chombo libraries needed by this program, in order of search. 1 d. Lib. Names = Old. AMRElliptic AMRTools Box. Tools Base. Tools 2 d. Lib. Names = AMRTools Box. Tools #3 d. Lib. Names = Box. Tools # relative paths to source code directories base_dir =. 1 dsrc_dirs =. . /util 2 dsrc_dirs =. . /src. . /util. . /advect. Src 3 dsrc_dirs = mdsrc_dirs =. . /mdsrc # shared code for building example programs include $(CHOMBO_HOME)/mk/Make. example. multidim 06/29/2011 Chombo Boot Camp 10
- Slides: 10