Research Article

Finite Element Assembly Using an Embedded Domain Specific Language

Listing 7

Data passed to the functors.
(template<typename ElementT>
()  struct dsl_data
()  {
()   // Required by Eigen to store fixed-size data
()   EIGEN_MAKE_ALIGNED_OPERATOR_NEW
()   // The concrete element type
()   typedef ElementT element_t;
()  
()   // Construct using the mesh
() dsl_data(const fem::mesh_data& d): mesh_data(d)
() {
() }
()  
() // Set the current element
() void set_element(const int e)
() {
()  for(int i = 0; i != element_t::nb_nodes; ++i)
()  {
()   const int node_idx = mesh_data.connectivity[e][i];
()   node_indices[i] = node_idx;
()   for(int j = 0; j != element_t::dimension; ++j)
()    coord_mat(i,j) = mesh_data.coordinates[node_idx][j];
()  }
() }
()  
() // Reference to the mesh
() const fem::mesh_data& mesh_data;
() // Storage for the coordinates of the current element nodes
() typename ElementT::coord_mat_t coord_mat;
() // Global indices of the nodes of the current element
() int node_indices[element_t::nb_nodes];
() // Value of the last shape function computation
() typename element_t::shape_func_t shape_func;
() // Value of the last Jacobian determinant computation
() double det_jacobian;
() ;