#ifndef _1D_LINEAR_CC #define _1D_LINEAR_CC //mapping from a reference element to a given FE double map_to_FE(double x, int ele) { return ((ele+x)*h); } //mapping from a a given FE to a reference element double map_from_FE(double x, int ele) { return ((x-ele*h)/h); } // the number of local degrees of freedom int dofs_per_element() { return 2; } // the mapping of local to global degrees of freedom void fill_element_dofs(int* array, int ele) { array[0] = ele; array[1] = ele+1; } //the i-th shape function on the reference element double reference_shape_funct(int index, double x) { if (index==0) return 1-x; else return x; } //the x-derivative of the i-th shape function on the reference element double reference_shape_funct_x(int index, double x) { if (index==0) return -1; else return 1; } // the jacobian of the transformation // (i.e. the change of variables in the integral over an element // to the reference elemen (unit interval)) double jacobian(double q_point, int ele) { return h; } /********* NOTE **********/ // The following two functions are not needed in general, // since we are only working on the reference element. // I've included them here for clarity. double shape_funct(double x, int ele, int index) { return reference_shape_funct(index, map_from_FE(x,ele)); } double shape_funct_x(double x, int ele, int index) { // (1.0/h) = (map_from_FE)' <------------ TODO return reference_shape_funct_x(index, map_from_FE(x,ele))*(1.0/h); } #endif