xx PUGHReduce

PUGHReduce

Gabrielle Allen, Thomas Radke

Date

Abstract

Reductions operations which are performed using the PUGH driver

1 Purpose

This thorn registers a number of reduction operators with the flesh. The reductions are performed using internals of the PUGH driver, so that this thorn can only be used when CactusPUGH/PUGH is active.

The reduction operations this thorn registers are

11 Reduction Operator 11 Calculates  11 By
11 average, mean      11 the average/mean of a grid variable  11
11 count              11 the number of grid points in a grid variable 11
11 maximum            11 the maximum of a grid variable  11
11 minimum            11 the minimum of a grid variable  11
11 norm1, L1Norm      11 the L1 norm of a grid variable  11
11 norm2, L2Norm      11 the L2 norm of a grid variable  11
11 norm3, L3Norm      11 the L3 norm of a grid variable  11
11 norm4, L4Norm      11 the L4 norm of a grid variable  11
11 normxinf, LinfNorm 11 the Infinitity norm of a grid variable  11
11 sum                11 the sum of the elements of a grid variable 11

11

Reduction operators with multiple names are just synonyms for the same kind of reduction operation. In the formulas is the grid variable to be reduced, and denotes the number of its elements. Reduction operators marked with cannot be applied to grid variables of complex datatype.

2 Examples

The following C example illustrates how the get the maximum value of a grid function.

xxintxvindex;xxxxxxxxxxxxx/*xgridxvariablexindexx*/
xxCCTK_REALxresult;xxxxxxx/*xresultingxreductionxvaluex*/
xxintxtarget_proc;xxxxxxxx/*xprocessorxtoxholdxthexresultx*/
xxintxreduction_handle;xxx/*xhandlexforxreductionxoperatorx*/
xxcharx*reduction_name;xxx/*xreductionxoperatorxtoxusex*/

xx/*xwantxtoxgetxthexmaximumxforxthexwavetoyxgridxfunctionx*/
xxreduction_namex=x"maximum";
xxvindexx=xCCTK_VarIndexx("wavetoy::phi");
xx/*xthexreductionxresultxwillxbexobtainedxbyxprocessorx0xonlyx*/
xxtarget_procx=x0;
xx/*xgetxthexhandlexforxthexgivenxreductionxoperatorx*/
xxreduction_handlex=xCCTK_ReductionHandlex(reduction_name);
xxifx(reduction_handlex>=x0)
xx{
xxxx/*xnowxdoxthexreductionxusingxthexflesh'sxgenericxreductionxAPI
xxxxxx(passingxinxonexinput,xexpectingxonexoutputxvaluexofxREALxtype)x*/
xxxxifx(CCTK_Reducex(cctkGH,xtarget_proc,xreduction_handle,
xxxxxxxxxxxxxxxxxxxxx1,xCCTK_VARIABLE_REAL,x&result,x1,xvindex)x==x0)
xxxx{
xxxxxxifx(CCTK_MyProcx(cctkGH)x==xtarget_proc)
xxxxxx{
xxxxxxxxprintfx("%sxreductionxvaluexisx%f\n",xreduction_name,xresult);
xxxxxx}
xxxx}
xxxxelse
xxxx{
xxxxxxCCTK_VWarnx(1,x__LINE__,x__FILE__,xCCTK_THORNSTRING,
xxxxxxxxxxxxxxxxxx"%sxreductionxfailed",xreduction_name);
xxxx}
xx}
xxelse
xx{
xxxxCCTK_VWarnx(1,x__LINE__,x__FILE__,xCCTK_THORNSTRING,
xxxxxxxxxxxxxxxx"Invalidxreductionxoperatorx'%s'",xreduction_name);

3 Parameters

4 Interfaces

General Implements: reduce

5 Schedule This section lists all the variables which are assigned storage by thorn CactusPUGH/PUGHReduce. Storage can either last for the duration of the run (Always means that if this thorn is activated storage will be assigned, Conditional means that if this thorn is activated storage will be assigned for the duration of the run if some condition is met), or can be turned on for the duration of a schedule function.

Storage NONE

Scheduled Functions

CCTKxSTARTUP x pughreducexstartup x startup routine

11 x 11 Language: 11 c
11 x 11 Type:  11 function