#endif#define KILOBYTES(1<10#define MEGABYTES(1<20#define ">
Derivative Fields Code

# Derivative Fields Code - #include...

This preview shows pages 1–2. Sign up to view the full content.

#include <stdio.h> #include "cow.h" #if (COW_MPI) #include <mpi.h> #endif #define KILOBYTES (1<<10) #define MEGABYTES (1<<20) #define GETENVINT(a,dflt) (getenv(a) ? atoi(getenv(a)) : dflt) #define GETENVDBL(a,dflt) (getenv(a) ? atof(getenv(a)) : dflt) static void divcorner ( double * result, double ** args, int ** s, cow_domain * d) { #define M(i,j,k) ((i)*s[0][0] + (j)*s[0][1] + (k)*s[0][2]) double * fx = & args[ 0 ][ 0 ]; double * fy = & args[ 0 ][ 1 ]; double * fz = & args[ 0 ][ 2 ]; * result = ((fx[M( 1 , 0 , 0 )] + fx[M( 1 , 1 , 0 )] + fx[M( 1 , 0 , 1 )] + fx[M( 1 , 1 , 1 )]) - (fx[M( 0 , 0 , 0 )] + fx[M( 0 , 1 , 0 )] + fx[M( 0 , 0 , 1 )] + fx[M( 0 , 1 , 1 )])) / 4.0 + ((fy[M( 0 , 1 , 0 )] + fy[M( 0 , 1 , 1 )] + fy[M( 1 , 1 , 0 )] + fy[M( 1 , 1 , 1 )]) - (fy[M( 0 , 0 , 0 )] + fy[M( 0 , 0 , 1 )] + fy[M( 1 , 0 , 0 )] + fy[M( 1 , 0 , 1 )])) / 4.0 + ((fz[M( 0 , 0 , 1 )] + fz[M( 1 , 0 , 1 )] + fz[M( 0 , 1 , 1 )] + fz[M( 1 , 1 , 1 )]) - (fz[M( 0 , 0 , 0 )] + fz[M( 1 , 0 , 0 )] + fz[M( 0 , 1 , 0 )] + fz[M( 1 , 1 , 0 )])) / 4.0 ; #undef M } static void div5 ( double * result, double ** args, int ** s, cow_domain * d) { #define diff5(f,s) ((-f[2*s] + 8*f[s] - 8*f[-s] + f[-2*s]) / 12.0) double * f0 = & args[ 0 ][ 0 ]; double * f1 = & args[ 0 ][ 1 ]; double * f2 = & args[ 0 ][ 2 ]; * result = diff5(f0, s[ 0 ][ 0 ]) + diff5(f1, s[ 0 ][ 1 ]) + diff5(f2, s[ 0 ][ 2 ]); #undef diff5 } static void curl ( double * result, double ** args, int ** s, cow_domain * d) { // #define diff5(f,s) ((-f[2*s] + 8*f[s] - 8*f[-s] + f[-2*s]) / 12.0) double * f0 = & args[ 0 ][ 0 ]; double * f1 = & args[ 0 ][ 1 ]; double * f2 = & args[ 0 ][ 2 ]; result[ 0 ] = diff5(f2, s[ 0 ][ 1 ]) - diff5(f1, s[ 0 ][ 2 ]); result[ 1 ] = diff5(f0, s[ 0 ][ 2 ]) - diff5(f2, s[ 0 ][ 0 ]); result[ 2 ] = diff5(f1, s[ 0 ][ 0 ]) - diff5(f0, s[ 0 ][ 1 ]); #undef diff5 } static void crossprod ( double * result, double ** args, int ** s, cow_domain * d) { double a0 =

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern