Home

UFC Specification and User Manual 1.1

image

Contents

1. TT UFC Specification and User Manual 1 1 Fi Evaluate all basis functions at given point in cell virtual void evaluate_basis_all double values const double coordinates const cell amp c const 0 Evaluate order n derivatives of basis function i at given point in cell virtual void evaluate_basis_derivatives unsigned int i unsigned int n double values const double coordinates const cell amp c const 0 Evaluate order n derivatives of all basis functions at given point in cell virtual void evaluate_basis_derivatives_all unsigned int n double values const double coordinates const cell amp c const 0 Evaluate linear functional for dof i on the function f virtual double evaluate_dof unsigned int i const function amp f const cell amp c const 0 Evaluate linear functionals for all dofs on the function f virtual void evaluate_dofs double values const function amp f const cell amp c const 0 Interpolate vertex values from dof values virtual void interpolate_vertex_values double vertex_values const double dof_values const cell amp c const 0 Map coordinate xhat from reference cell to coordinate x in cell virtual void map_from_reference_cell double x const double xhat const cell amp c 0 Map from coordinate x in cell to coordinate xhat in reference cell virtual void map_to_reference_cell double xhat const double
2. Generate combinations of derivatives for unsigned int row 1 row lt num_derivatives row for unsigned int num 0 num lt row num for unsigned int col n 1 col 1 gt 0 col if combinations row col 1 gt 1 combinations row col 0 100 initialise UFC Specification and User Manual 1 1 else combinations row c break ol 1 Compute inverse of Jacobian const double Jinv 2 2 J_11 detJ J_01 detJ J_10 detJ J_00 detJ Declare transformation matrix Declare pointer to two dimensional array and initialise double transform new double num_derivatives for unsigned int j 0 j transform j new double for unsigned int k 0 transform j k 1 lt num_derivatives j num_derivatives k lt num_derivatives k Construct transformation matrix for unsigned int row 0 for unsigned int col 0 for unsigned int k 0 transform row col F F Reset values for unsigned int j 0 j values j 0 Map degree of freedom to const unsigned int dof i Generate scalings const double scalings_y_0 const double scalings_y_1 Compute psitilde_a const double psitilde_a_0O const double psitilde_a_1i Compute psitilde_bs const double psitilde_bs_0_ const double psitilde_bs_0_ const double psitilde_bs_1i_ Compute basisvalues const
3. Compute affine mapping y F X double y 2 y 0 wO x 0 0 wi x 1 0 w2 x 2 0 y 1 wO x 0 1 wi x 1 1 w2 x 2 1 Evaluate function at physical points double values 1 f evaluate values y c Map function values using appropriate mapping Affine map Do nothing Note that we do not map the weights yet Take directional components for int k 0 k lt 1 k result values k D i 0 k Multiply by weights result W i 0 96 is not yet implemented UFC Specification and User Manual 1 1 return result Evaluate linear functionals for all dofs on the function f virtual void evaluate_dofs double values const ufc function amp f const ufc cell amp c const throw std runtime_error Not implemented introduced in UFC vi 1 Interpolate vertex values from dof values virtual void interpolate_vertex_values double vertex_values const double dof_values const ufc cell amp c const Evaluate at vertices and use affine mapping vertex_values 0 dof_values 0 vertex_values 1 dof_values 1 vertex_values 2 dof_values 2 Return the number of sub elements for a mixed element virtual unsigned int num_sub_elements const return 1 Create a new finite element for sub element i for a mixed element virtual ufc finite_element create_sub_element unsigned int i const re
4. Tabulate the tensor for the contribution from a local exterior facet using the specified reference cell quadrature points weights virtual void tabulate_tensor double A const double const w const cell amp c unsigned int num_quadrature_points const double const quadrature_points const double quadrature_weights const 0 F This class defines the interface for the tabulation of the interior facet tensor corresponding to the local contribution to a form from the integral over an interior facet class interior_facet_integral public Constructor interior_facet_integral Destructor virtual interior_facet_integral Tabulate the tensor for the contribution from a local interior facet virtual void tabulate_tensor double A const double const w const cell amp c0 const cell amp ci unsigned int facet0O unsigned int faceti const 0 Tabulate the tensor for the contribution from a local interior facet using the specified reference cell quadrature points weights virtual void tabulate_tensor double A const double const w const cell amp c unsigned int num_quadrature_points const double const quadrature_points const double quadrature_weights const 0 3 This class defines the interface for the assembly of the global 81 UFC Specification and User Manual 1 1 tensor corresponding to a form with r n argume
5. ufc dof_map form__stiffness_form__Lagrange_1_2D create_dof_map unsigned int i const switch i case 0 return new dof_map_Lagrange_1_2D case 1 return new dof_map_Lagrange_1_2D throw std runtime_error Invalid index in create_dof_map Create a new cell integral on sub domain i ufc cell_integral form__stiffness_form__Lagrange_1_2D create_cell_integral unsigned int i const return new cell_itg__stiffness_form__Lagrange_1_2D Create a new exterior facet integral on sub domain i ufc exterior_facet_integral form__stiffness_form__Lagrange_1_2D create_exterior_facet_integral unsigned int i const return 0 Create a new interior facet integral on sub domain i ufc interior_facet_integral form__stiffness_form__Lagrange_1_2D create_interior_facet_integral unsigned int i const return 0 namespace 130 Appendix D Python utilities The UFC distribution includes a set of Python utilities for generating code that conforms to the UFC specification These utilities consist of format string templates for C header files h files implementation files cpp and combined header and implementation files h files containing both the declaration and definition of the UFC functions The following format strings are provided function_combined_ header implementation combined finite_element_ header implementation combined dofmap_ header i
6. 68 5 4 2 Numbering of mesh entities on triangular cells 69 5 4 3 Numbering of mesh entities on quadrilateral cells 69 5 4 4 Numbering of mesh entities on tetrahedral cells 70 5 4 5 Numbering of mesh entities on hexahedral cells 71 A C Interface 75 B A basic UFC based assembler 85 C Complete UFC code for Poisson s equation 89 C 1 Code generated by PFC 6 habe ee eee ee eee ws 90 C 2 Code generated by SyFi e sea ite sesane be ees 115 C 2 1 Header file for linear Lagrange element in2D 115 C 2 2 Source file for linear Lagrange element in2D 117 C 2 3 God C 2 5 C 2 6 Header file for the dofmap Source file for the dofmap Header file for the stiffness matrix form Source file for the stiffness matrix form D Python utilities E Installation ET Imstaling UFO lt o teh a ee ye inde ee ee eee ee OS F UFC versions F l Version 1 0 2 4 2 4 66 6 be ew ee ee ee ee Po Vere Isl oe pola ee Shak we WS eee oe ok we ok Po Version easpa ee Be Be Be ee BOE ATMOS Es Pel Version 1A ww 2a 6 ow bad GOR EERE REA F o Version 2 0 246 666 eee whe ee ee eee G License 131 133 133 135 135 135 136 136 136 139 Chapter 1 Introduction Large parts of a finite element program are similar from problem to problem and can therefore be coded as a general reusable library Mesh data struc t
7. Return the number of cell integrals virtual unsigned int num_cell_integrals const Return the number of exterior facet integrals virtual unsigned int num_exterior_facet_integrals const Return the number of interior facet integrals virtual unsigned int num_interior_facet_integrals const Create a new finite element for argument function i virtual ufc finite_element create_finite_element unsigned int i const Create a new dof map for argument function i virtual ufc dof_map create_dof_map unsigned int i const Create a new cell integral on sub domain i virtual ufc cell_integral create_cell_integral unsigned int i const Create a new exterior facet integral on sub domain i virtual ufc exterior_facet_integral create_exterior_facet_integral unsigned int i const Create a new interior facet integral on sub domain i virtual ufc interior_facet_integral create_interior_facet_integral unsigned int i const 3 namespace endif 126 UFC Specification and User Manual 1 1 C 2 6 Source file for the stiffness matrix form This code complies with UFC version 1 0 and is generated with SyFi version 0 4 0 http www fenics org syfi http www fenics org ufc include lt stdexcept gt include lt math h gt include lt ufc h gt include lt pycc Functions Ptv h gt include lt pycc Functions Ptv_tools h gt include lt p
8. Generate scalings const double scalings_y_0O 1 const double scalings_y_1 scalings_y_0 0 5 0 5 y Compute psitilde_a const double psitilde_a_O 1 const double psitilde_a_1 x Compute psitilde_bs const double psitilde_bs_0_0O 1 const double psitilde_bs_0_1i 1 5 y 0 5 const double psitilde_bs_1_0 13 Compute basisvalues const double basisvalueO 0 707106781186548 psitilde_a_0O scalings_y_0 psitilde_bs_0_0 const double basisvaluel 1 73205080756888 psitilde_a_1 scalings_y_1 psitilde_bs_1_0 const double basisvalue2 psitilde_a_0 scalings_y_0 psitilde_bs_0_1 Table s of coefficients const static double coefficients0 3 3 0 471404520791032 0 288675134594813 0 166666666666667 0 471404520791032 0 288675134594813 0 166666666666667 0 471404520791032 0 0 333333333333333 Interesting new part Tables of derivatives of the polynomial base transpose const static double dmats0 3 3 0 0 O 4 89897948556636 0 O 0 0 OF const static double dmats1 3 3 0 0 O 2 44948974278318 0 O 4 24264068711928 0 O Compute reference derivatives Declare pointer to array of derivatives on FIAT element double derivatives new double num_derivatives 94 UFC Specification and User Manual 1 1 Declare coefficients double coeff0_0O 0 double coeff0_1i 0 double coeff0_2 0 Declare new coefficients double new
9. const double J_01 element_coordinates 2 0 element_coordinates 0 0 const double J_10 element_coordinates 1 1 element_coordinates 0 1 const double J_11 element_coordinates 2 1 element_coordinates 0 1 Compute determinant of Jacobian const double detJ J_00 J_11 J_01 J_10 Compute inverse of Jacobian Get coordinates and map to the reference UFC element double x element_coordinates 0 1 element_coordinates 2 0 element_coordinates 0 0 element_coordinates 2 1 J_11 coordinates 0 J_01 coordinates i detJ double y element_coordinates 1 1 element_coordinates 0 0 element_coordinates 1 0 element_coordinates 0 1 J_10 coordinates 0 J_00 coordinates 1i detJ Map coordinates to the reference square if std abs y 1 0 lt 1e 14 98 UFC Specification and User Manual 1 1 x 1 0 else x 2 0 x 1 0 y 1 0 y 2 0 y 1 0 Reset values values 0 Map degree of freedom to element degree of freedom const unsigned int dof i Generate scalings const double scalings_y_0 1 const double scalings_y_1 scalings_y_0 0 5 0 5 y Compute const double psitilde_a_O 1 const double psitilde_a_1i x Compute psitilde_bs const double psitilde_bs_0_O 1 const double psitilde_bs_0_1 1 5 y 0 5 const double psitilde_bs_1_O 1 Compute const double basisvalueO const doub
10. If the integral evaluates to zero this function may return a null pointer 56 Chapter 4 Reference cells The following five reference cells are covered by the UFC specification the reference interval the reference triangle the reference quadrilateral the ref erence tetrahedron and the reference hexahedron see Table 4 1 The UFC specification assumes that each cell in a finite element mesh is always isomorphic to one of the reference cells Reference cell Dimension Vertices Facets The reference interval ji 2 2 The reference triangle 2 3 3 The reference quadrilateral 2 4 4 The reference tetrahedron 3 4 4 The reference hexahedron 3 8 6 Table 4 1 Reference cells covered by the UFC specification 57 UFC Specification and User Manual 1 1 _ Uhr 0 1 Figure 4 1 The reference interval Vertex Coordinate Vo x 0 v x 1 Table 4 2 Vertex coordinates of the reference interval 4 1 The reference interval The reference interval is shown in Figure 4 1 and is defined by its two vertices with coordinates as specified in Table 4 2 4 2 The reference triangle The reference triangle is shown in Figure 4 2 and is defined by its three vertices with coordinates as specified in Table 4 3 Vertex Coordinate Vo x 0 0 V1 x 1 0 V2 x 0 1 Table 4 3 Vertex coordinates of the reference triangle 58
11. double G10 y1 y0 double G11 y2 y0 double v i double x 2 switch i case 0 x 0 x0 x 1 y0 break case 1 x 0 x0 G00 x 1 G10 y0 break case 2 x 0 GO1 x0 x 1 y0 G11 break f evaluate v x c return vli 1 Interpolate vertex values from dof values void fe_Lagrange_1_2D interpolate_vertex_values double vertex_values const double dof_values const ufc cell amp c const vertex_values 0 dof_values 0 vertex_values 1 dof_values 1 vertex_values 2 dof_values 2 Return the number of sub elements for a mixed element unsigned int fe_Lagrange_1_2D num_sub_elements const return 1 Create a new finite element for sub element i for a mixed element ufc finite_element fe_Lagrange_1_2D create_sub_element unsigned int i const return new fe_Lagrange_1_2D namespace 119 UFC Specification and User Manual 1 1 C 2 3 Header file for the dofmap This code complies with UFC version 1 0 and is generated with SyFi version 0 4 0 bttp www fenics org syfi bttp www fenics org ufc ifndef __dof_map_Lagrange_1_2D_H define __dof_map_Lagrange_1_2D_H include lt stdexcept gt include lt math h gt include lt ufc h gt include lt pycc Functions Ptv h gt include lt pycc Functions Ptv_tools h gt include lt pycc Functions Dof_Ptv h gt include lt
12. const Create a new finite element for sub element i for a mixed element virtual ufc finite_element create_sub_element unsigned int i const 3 namespace endif 116 UFC Specification and User Manual 1 1 C 2 2 Source file for linear Lagrange element in 2D This code complies with UFC version 1 0 and is generated with SyFi version 0 4 0 http www fenics org syfi http www fenics org ufc include lt stdexcept gt include lt math h gt include lt ufc h gt include lt pycc Functions Ptv h gt include lt pycc Functions Ptv_tools h gt include lt pycc Functions Dof_Ptv h gt include lt pycc Functions OrderedPtvSet h gt include lt pycc Functions Dof_OrderedPtvSet h gt include fe_Lagrange_1_2D h namespace pycc Constructor fe_Lagrange_1_2D fe_Lagrange_1_2D ufc finite_element Destructor fe_Lagrange_1_2D fe_Lagrange_1_2D Return a string identifying the finite element const char fe_Lagrange_1_2D signature const return fe_Lagrange_1_2D generated by SyFi F Return the cell shape ufc shape fe_Lagrange_1_2D cell_shape const return ufc triangle Return the dimension of the finite element function space unsigned int fe_Lagrange_1_2D space_dimension const return 3 Return the rank of the value space 117 UFC Specification and
13. form The ufc form class is the central part of the UFC interface and it represents a form a afvi 225 Ur Wig ex s Wn 3 1 52 UFC Specification and User Manual 1 1 defined on the product space Vj x V x x Vp x Wi x We X x W of two sets V _1 W _ of finite element function spaces on a triangulation T of a domain 2 C R A ufc form provides functions for accessing the rank r and number of co efficients n for a form and factory functions for creating UFC objects for the corresponding cell integrals exterior facet integrals interior facet integrals and all associated finite elements and dofmaps local to global mappings 3 12 1 The function signature virtual const char signature const 0 This function returns a signature string that uniquely identifies the form This can be used to compare whether or not two given ufc form objects are identical 3 12 2 The function rank virtual unsigned int rank const 0 This function returns the rank r of the global tensor generated by the form the arity of the form 3 12 3 The function num_coefficients virtual unsigned int num_coefficients const 0 This function returns the number of coefficients n for the form Note that all integral terms of a form must have the same coefficients even if not all coefficients are present in each term of the form 53 UFC Specification and User Manual 1 1 3 12 4
14. 0 2 v2 vo V1 V3 v3 0 3 v3 vo V1 V2 eo 1 0 V2 U3 vo V1 e 1 1 v1 U3 vo Va e2 1 2 v1 va vo U3 e3 1 3 vo V3 v1 V2 e4 1 4 vo v2 v1 V3 e5 1 5 vo v1 v2 v3 fo 2 0 v1 V2 U3 vo f 2 1 vo V2 U3 v1 jo 2 2 vo V1 V3 v2 fs 2 3 Vo U1 V2 v3 co 3 0 U9 U1 V2 V3 70 UFC Specification and User Manual 1 1 5 4 5 Numbering of mesh entities on hexahedral cells Entity Incident vertices Non incident vertices vo 0 0 vo V1 V2 U3 V4 U5 U6 U7 v1 0 1 v1 U0 V2 U3 V4 U5 V6 U7 v2 0 2 v2 V0 V1 U3 V4 U5 V6 U7 v3 0 3 v3 V0 V1 V2 V4 U5 V6 U7 v4 0 4 v4 V0 U1 V2 U3 U5 U6 U7 vs 0 5 v5 vo V1 V2 U3 U4 V6 V7 ve 0 6 ve V0 V1 V2 U3 V4 U5 V7 v7 0 7 v7 U0 V1 V2 U3 V4 U5 V6 eo 1 0 v6 U7 Vo V1 V2 U3 U4 U5 e1 1 1 v5 ve v0 U1 V2 U3 V4 U7 e2 1 2 v4 v7 vo V1 V2 U3 U5 V6 e3 1 3 v4 U5 v0 U1 V2 U3 U6 U7 e4 1 4 v3 v7 vo U1 V2 V4 U5 V6 e5 1 5 v2 ve vo U1 V3 V4 V5 U7 es 1 6 v2 v3 v0 U1 V4 U5 U6 U7 e7 1 7 v1 U5 vo V2 V3 V4 U6 U7 eg 1 8 v1 v2 v0 U3 V4 U5 U6 U7 eg 1 9 vo v4 v1 V2 U3 U5 U6 U7 e10 1 10 vo v3 v1
15. 1 Compute affine mapping y F X double y 2 y 0 wO x 0 0 wi x 1 0 w2 x 2 0 y 1 wO x 0 1 wi x 1 1 w2 x 2 1 Evaluate function at physical points double values 1 f evaluate values y c Map function values using appropriate mapping Affine map Do nothing Note that we do not map the weights yet Take directional components for int k 0 k lt 1 k result values k D i 0 k Multiply by weights result W i 0 return result Evaluate linear functionals for all dofs on the function f virtual void evaluate_dofs double values const ufc function amp f const ufc cell amp c const throw std runtime_error Not implemented introduced in UFC v1 1 Interpolate vertex values from dof values virtual void interpolate_vertex_values double vertex_values const double dof_values const ufc cell amp c const Evaluate at vertices and use affine mapping vertex_values 0 dof_values 0 vertex_values 1 dof_values 1 vertex_values 2 dof_values 2 Return the number of sub elements for a mixed element virtual unsigned int num_sub_elements const return 1 Create a new finite element for sub element i for a mixed element virtual ufc finite_element create_sub_element unsigned int i const return new PoissonBilinearForm_finite_element_1 F 104 UFC Specification and
16. 8 iii Assemble contributions from all interior facets for each S 0 T forj 1 2 97 Tabulate the local to global mapping Le s for j 1 2 5 7 Extract the values of w on K S Take 0 lt k lt n such that S 0 7 Tabulate the interior facet tensor A for Ti Add A to Aj ir for i Ik s Ks 41 4Fe gy 2 yore Ure cs 23 Chapter 3 Interface specification 3 1 A short remark on design UFC is organized as a minimalistic set of abstract C classes representing low level abstractions of the finite element method The functions in these classes are mainly of two types i functions returning dimensions which are typically used to allocate an array and ii functions that fill an array with values It is considered the assembly routine s responsibility to allocate and deallo cate arrays of proper size Consider for example the function for evaluating the ith basis function in the class ufc finite_element virtual void evaluate_basis unsigned int i double x values const double coordinates const cell amp c const 0 This function assumes that the array values has the correct size which may be obtained by calling the functions value_rank and value_dimension as described in detail below 25 UFC Specification and User Manual 1 1 Thus the UFC interface is a low level interface that should be simple to integrate into an existing C finite element code but which
17. In all other cases this variable should be set to 1 3 4 8 The integer mesh_identifier Introduced in UFC version 2 0 30 UFC Specification and User Manual 1 1 int mesh_identifier The integer mesh_identifier can be used during callbacks to the evaluate function of ufc function to specify a global identifier for the mesh on which the function is being evaluated This allows ufc function subclasses to handle evaluation differently on different meshes If not used this variable should be set to 1 3 5 The class ufc function The class ufc function is an interface for evaluation of general tensor valued functions on the cells of a mesh 3 5 1 The function evaluate virtual void evaluate double values const double coordinates const cell amp c const 0 The only function in this class is evaluate which evaluates all the value components of the function at a given point in a given cell of the mesh The output of evaluate should be written to the array values For a scalar valued function a single value should be written to values 0 For general tensor valued functions the values should be written in a flattened row major ordering of the tensor values Thus for a function f K gt R where A f x is a 2 x 2 matrix the array values should contain the values A11 A12 A21 Age in this order The input to evaluate are the coordinates of a point in a cell and the U
18. UFC Specification and User Manual 1 1 0 1 0 0 1 0 Figure 4 2 The reference triangle 4 3 The reference quadrilateral The reference quadrilateral is shown in Figure 4 3 and is defined by its four vertices with coordinates as specified in Table 4 4 Vertex Coordinate Vo x 0 0 vi x 1 0 U9 r U3 T Table 4 4 Vertex coordinates of the reference quadrilateral 59 UFC Specification and User Manual 1 1 0 1 0 0 1 0 Figure 4 3 The reference quadrilateral 4 4 The reference tetrahedron The reference tetrahedron is shown in Figure 4 4 and is defined by its four vertices with coordinates as specified in Table 4 5 Vertex Coordinate vo x 0 0 0 v x 1 0 0 v2 x 0 1 0 ve x 0 0 1 Table 4 5 Vertex coordinates of the reference tetrahedron 60 UFC Specification and User Manual 1 1 0 0 1 0 0 0 1 0 0 Figure 4 4 The reference tetrahedron Vertex Coordinate Vertex Coordinate Vo x 0 0 0 v4 x 0 0 1 v x 1 0 0 Us x 1 0 1 V2 x 1 1 0 U6 e 1 11 U3 x 0 1 0 U7 x 0 1 1 Table 4 6 Vertex coordinates of the reference hexahedron 4 5 The reference hexahedron The reference hexahedron is shown in Figure 4 5 and is defined by its eight vertices with coordinates as specified in Table 4 6 61 UFC
19. and when the facet is a facet of a tetrahedron the argument facet should be an integer between zero and three 0 1 2 3 3 10 2 The function tabulate tensor quadrature version Introduced in version version 2 0 virtual void tabulate_tensor double A const double const w const cell amp c unsigned int num_quadrature_points const double const quadrature_points const double quadrature_weights const 0 This function is identical to tabulate_tensor described above but computes the integral over the cell using the given set of quadrature points and weights Note that the quadrature points should be specified on the reference cell By a careful choice of quadrature points this function can be used to integrate over subsets of facets 3 11 The class ufc interior facet_integral The class ufc interior_facet_integral represents the integral of a form over a local interior facet in a finite element mesh It has a single function tabulate tensor which may be called to tabulate the values of the interior facet tensor for a given facet 50 UFC Specification and User Manual 1 1 3 11 1 The function tabulate_tensor virtual void tabulate_tensor double A const double const w const cell amp cO const cell amp ci unsigned int facet0O unsigned int facet1 const 0 Just as for the cell_integral and exterior_facet_integral classes the tabulate_tensor function for the class interior
20. we present a general algorithm for assembling the contri butions from the local cell exterior facet and interior facet tensors into a global sparse tensor In all cases we iterate over all entities cells exte rior or interior facets compute the local cell tensor A or exterior interior facet tensor Af and add it to the global sparse tensor as determined by the local to global mapping see Figure 2 1 22 UFC Specification and User Manual 1 1 Algorithm 1 Assembling the global tensor A from the local contributions on all cells exterior and interior facets For assembly over exterior facets K S refers to the cell K T incident to the exterior facet S and for assembly over interior facets K S refers to the macro cell consisting of the pair of cells K and K incident to the interior facet S A 0 i Assemble contributions from all cells for each KET for 7 1 2 aT Tabulate the local to global mapping t for j 1 2 2 5 Extract the values of w on K Take 0 lt k lt ne such that K Tk Tabulate the cell tensor A for TE Add AK to Ad iGO ts Uh ir for i Ik ii Assemble contributions from all exterior facets for each S 0 7 forj 1 2 9r Tabulate the local to global mapping Ue 5 for j 1 2 n Extract the values of w on K S Take 0 lt k lt ne such that S 0 7 Tabulate the exterior facet tensor AS for I k Add A to A ir for i E Ik s Kis li htkes 2 5 4
21. 1 1 10 R C KIRBY M G KNEPLEY A LOGG AND L R SCOTT Opti 11 12 13 14 15 16 mizing the evaluation of finite element matrices SIAM J Sci Comput 27 2005 pp 741 758 R C KIRBY AND A LOGG A compiler for variational forms ACM Transactions on Mathematical Software 32 2006 pp 417 444 Efficient compilation of a class of variational forms ACM Trans actions on Mathematical Software 33 2007 R C KIRBY A LocG L R SCOTT AND A R TERREL Topo logical optimization of the evaluation of finite element ma trices SIAM J Sci Comput 28 2006 pp 224 240 A LoGG FFC 2007 URL http www fenics org ffc K LONG Sundance 2006 URL http software sandia gov sundance O C ZIENKIEWICZ R L TAYLOR AND J Z ZHU The Finite Element Method Its Basis and Fundamentals 6th e dition Elsevier 2005 first published in 1967 74 Appendix A C Interface Below follows a verbatim copy of the complete UFC interface which is spec ified in the header file ufc h This is UFC Unified Form assembly Code v 2 0 This code is released into the public domain The FEniCS Project http www fenicsproject org 2006 2011 ifndef __UFC_H define __UFC_H define UFC_VERSION_MAJOR 2 define UFC_VERSION_MINOR 0 define UFC_VERSION_MAINTENANCE 0 include lt stdexcept gt const char UFC_VERSION 2 0 namespace ufc Va
22. Specification and User Manual 1 1 0 0 1 1 1 1 0 0 0 1 1 0 1 0 0 Figure 4 5 The reference hexahedron 62 Chapter 5 Numbering of mesh entities The UFC specification dictates a certain numbering of the vertices edges etc of the cells of a finite element mesh First an ad hoc numbering is picked for the vertices of each cell Then the remaining entities are ordered based on a simple rule as described in detail below 5 1 Basic concepts The topological entities of a cell or mesh are referred to as mesh entities A mesh entity can be identified by a pair d i where d is the topological dimension of the mesh entity and 7 is a unique index of the mesh entity Mesh entities are numbered within each topological dimension from 0 to ng 1 where ng is the number of mesh entities of topological dimension d For convenience mesh entities of topological dimension 0 are referred to as vertices entities of dimension 1 as edges entities of dimension 2 as faces entities of codimension 1 as facets and entities of codimension 0 as cells These concepts are summarized in Table 5 1 Thus the vertices of a tetrahedron are identified as v 0 0 vi 0 1 and v2 0 2 the edges are eg 1 0 e1 1 1 e2 1 2 e3 1 3 63 UFC Specification and User Manual 1 1 Entity Dimension Codimension Vertex 0 Edge 1 Face 2 Facet 1 Cell 0 Table 5 1 Named
23. The function num_cell_domains virtual unsigned int num_cell_domains const 0 This function returns the number of different cell domains for the form A form may have an arbitrary number of integrals over disjoint subdomains of the mesh 3 12 5 The function num_exterior_facet_domains virtual unsigned int num_exterior_facet_domains const 0 This function returns the number of different exterior facet domains for the form A form may have an arbitrary number of integrals over disjoint sub domains of the mesh boundary 3 12 6 The function num_interior_facet_domains virtual unsigned int num_interior_facet_domains const 0 This function returns the number of different interior facet domains for the form A form may have an arbitrary number of integrals over disjoint subsets of the interior facets of the mesh 3 12 7 The function create_finite_element virtual finite_element create_finite_element unsigned int i const 0 54 UFC Specification and User Manual 1 1 This factory function constructs a ufc finite_element object for form argument i A form with rank r and number of coefficients n has r n arguments so this function returns the finite element object for tensor axis i ifi lt r or the finite element for coefficient i r if i gt r The caller is responsible for deleting the returned object 3 12 8 The function create_dofmap virtual dofmap creat
24. User Manual 1 1 This class defines the interface for a local to global mapping of degrees of freedom dofs class PoissonBilinearForm_dof_map_0 public ufc dof_map private unsigned int __global_dimension public Constructor PoissonBilinearForm_dof_map_0 ufc dof_map __global_dimension 0 Destructor virtual PoissonBilinearForm_dof_map_0 Do nothing Return a string identifying the dof map virtual const char signature const return FFC dof map for FiniteElement Lagrange triangle 1 Return true iff mesh entities of topological dimension d are needed virtual bool needs_mesh_entities unsigned int d const switch d case 0 return true break case 1 return false break case 2 return false break return false Initialize dof map for mesh return true iff init_cell is needed virtual bool init_mesh const ufc mesh amp m __global_dimension m num_entities 0 return false Initialize dof map for given cell virtual void init_cell const ufc mesh amp m 105 UFC Specification and User Manual 1 1 const ufc cell amp c Do nothing Finish initialization of dof map for cells virtual void init_cell_finalize Do nothing Return the dimension of the global finite element function space virtual unsigned int global_dimension const return __global_di
25. User Manual 1 1 unsigned int fe_Lagrange_1_2D value_rank const return 0 Return the dimension of the value space for axis i unsigned int fe_Lagrange_1_2D value_dimension unsigned int i const return 1 Evaluate basis function i at given point in cell void fe_Lagrange_1_2D evaluate_basis unsigned int i double values const double coordinates const ufc cell amp c const const double x coordinates 0 const double y coordinates 1 switch i case 0 values 0 x y 1 0 break case 1 values 0 break case 2 values 0 break i Ed i lt Evaluate order n derivatives of basis function i at given point in cell void fe_Lagrange_1_2D evaluate_basis_derivatives unsigned int i unsigned int n double values const double coordinates const ufc cell amp c const throw std runtime_error gen_evaluate_basis_derivatives not implemented yet Evaluate linear functional for dof i on the function f double fe_Lagrange_1_2D evaluate_dof unsigned int i const ufc function amp f const ufc cell amp c const coordinates double x0 c coordinates 0 0 double yO c coordinates 0 1 double x1 c coordinates 1 0 double y1 c coordinates 1 1 double x2 c coordinates 2 0 double y2 c coordinates 2 1 affine map double GOO x1 x0 double GO1 x2 x0 118 UFC Specification and User Manual 1 1
26. W1 Oe 2 6 In the simplest case all function spaces are equal but there are many im portant examples such as mixed methods where the arguments come from different function spaces 16 UFC Specification and User Manual 1 1 2 1 3 Discretization To discretize the form a we introduce bases 2 4 7 for the function spaces V V V respectively and let i i1 2 be a multiindex of length i r The form a then defines a rank r tensor given by Aj alpi Pigs Ori Wi Wa Wn WET 2 7 where Z is the index set z J n viN j 1 1 1 1 ae een N1 N NO 2 8 We refer to the tensor A as the discrete operator generated by the form a and the particular choice of basis functions For any given form of arity r n the tensor A is a typically sparse tensor of rank r and dimension V x Ve x x V Nt x N x x N Typically the rank r is 0 1 or 2 When r 0 the tensor A is a scalar a tensor of rank zero when r 1 the tensor A is a vector the load vector and when r 2 the tensor A is a matrix the stiffness matrix Forms of higher arity also appear though they are rarely assembled as a higher dimensional sparse tensor Note here that we consider the functions w1 w2 Wn as fixed in the sense that the discrete operator A is computed for a given set of functions which we refer to as coefficients As an example consider again the
27. double basisvalueO const double basisvalue1 const double basisvalue2 row lt num_derivatives rowt col lt num_derivatives col k lt n k Jinv combinations col k combinations row k lt 1i num_derivatives j element degree of freedom 1 scalings_y_0 0 5 0 5 y 1 O0 1 1 1 5 y 0 5 0 1 0 707106781186548 psitilde_a_O scalings_y_0 psitilde_bs_0_0 1 73205080756888 psitilde_a_i scalings_y_1 psitilde_bs_1_0 psitilde_a_0 scalings_y_0 psitilde_bs_0_1 101 UFC Specification and User Manual 1 1 Table s of coefficients const static double coefficients0 3 3 0 471404520791032 0 288675134594813 0 166666666666667 0 471404520791032 0 288675134594813 0 166666666666667 0 471404520791032 0 0 333333333333333 Interesting new part Tables of derivatives of the polynomial base transpose const static double dmats0 3 3 0 0 O 4 89897948556636 0 O 0 0 OF const static double dmats1 3 3 0 0 O 2 44948974278318 0 O 4 24264068711928 0 O Compute reference derivatives Declare pointer to array of derivatives on FIAT element double derivatives new double num_derivatives Declare coefficients double coeff0_0 0 double coeff0_1i 0 double coeff0_2 0 Declare new coefficients double new_coeff0_0O 0 double new_coeff0_1 0 double new_coeff0_2 0 Loop possibl
28. for unsigned int col 0 col lt num_derivatives col values row transform row col derivatives col Delete pointer to array of derivatives on FIAT element delete derivatives Delete pointer to array of combinations of derivatives and transform 95 UFC Specification and User Manual 1 1 for unsigned int row 0 row lt num_derivatives row delete combinations row delete transform row delete combinations delete transform Evaluate order n derivatives of all basis functions at given point in cell virtual void evaluate_basis_derivatives_all unsigned int n double values const double coordinates const ufc cell amp c const throw std runtime_error The vectorised version of evaluate_basis_derivatives Evaluate linear functional for dof i on the function f virtual double evaluate_dof unsigned int i const ufc function amp f const ufc cell amp c const The reference points direction and weights const static double X 3 1 2 0 0 1 O 0 1 const static double W 3 1 1 1 1 const static double D 3 1 1 1 1 1 const double const x c coordinates double result 0 0 Iterate over the points Evaluate basis functions for affine mapping const double wO 1 0 X i 0 0 X i 0 1 const double w1 X i 0 0 const double w2 X i 0 1
29. gt ag Ur W1 3 Wn Ne SOD loni wun de k 1 KET Ne 2 15 5 D f Bontit un ds ee k 1 SE eTk S Ni D Ti vy Up W1 Wn ds k 1 SE0 Y S We refer to an integral over a cell K as a cell integral an integral over an exterior facet S as an exterior facet integral typically used to implement Neumann and Robin type boundary conditions and to an integral over an interior facet S as an interior facet integral typically used in discontinuous Galerkin methods For simplicity we consider here initially assembly of the global sparse ten sor A corresponding to a form a given by a single integral over all cells 7 and later extend to the general case where we must also account for contributions 19 UFC Specification and User Manual 1 1 from several cell integrals interior facet integrals and exterior facet integrals We thus consider the form G5 x s 5 tps Wigs lt 5 Wn So flor yest ye de 2 16 KeT for which the global sparse tensor A is given by Ai a Ioh 3 O3 W Wn da gate KeT EK To see how to compute the tensor A by summing the local contributions from each cell K we let ni P denote the dimension of the local finite element space on K for the jth primary argument v Vj forj 12 ccugt Furthermore let i L nf gt 1 NI 2 18 denote the local to global mapping for Vj that is on any given K 7 the mapping g maps the number of a lo
30. j 0 j lt num_derivatives j combinations j new unsigned int n for unsigned int k 0 k lt n k combinations j k 0 F Generate combinations of derivatives for unsigned int row 1 row lt num_derivatives row for unsigned int num 0 num lt row num for unsigned int col n 1 col 1 gt 0 col if combinations row col 1 gt 1 combinations row col 0 else combinations row col 1 break Compute inverse of Jacobian const double Jinv 2 2 J_11 detJ J_01 detJ J_10 detJ J_00 detJ Declare transformation matrix Declare pointer to two dimensional array and initialise double transform new double num_derivatives for unsigned int j 0 j lt num_derivatives j transform j new double num_derivatives for unsigned int k 0 k lt num_derivatives k transform j k 1 93 initialise UFC Specification and User Manual 1 1 Construct transformation matrix for unsigned int row 0 row lt num_derivatives row for unsigned int col 0 col lt num_derivatives col for unsigned int k 0 k lt n k transform row col Jinv combinations col k combinations row k Reset values for unsigned int j 0 j lt 1 num_derivatives j values j 0 Map degree of freedom to element degree of freedom const unsigned int dof i
31. mesh entities e4 1 4 and es 1 5 the faces facets are fo 2 0 fi 2 1 fo 2 2 and fs 2 3 and the cell itself is co 3 0 5 2 Numbering of vertices For simplicial cells intervals triangles and tetrahedra of a finite element mesh the vertices are numbered locally based on the corresponding global vertex numbers In particular a tuple of increasing local vertex numbers corresponds to a tuple of increasing global vertex numbers This is illustrated in Figure 5 1 for a mesh consisting of two triangles For non simplicial cells quadrilaterals and hexahedra the numbering is arbitrary as long as each cell is isomorphic to the corresponding reference cell by matching each vertex with the corresponding vertex in the reference cell This is illustrated in Figure 5 2 for a mesh consisting of two quadrilaterals 5 3 Numbering of other mesh entities When the vertices have been numbered the remaining mesh entities are num bered within each topological dimension based on a lexicographical ordering of the corresponding ordered tuples of non incident vertices 64 UFC Specification and User Manual 1 1 1 Figure 5 1 The vertices of a simplicial mesh are numbered locally based on the corresponding global vertex numbers 0 1 2 Figure 5 2 The local numbering of vertices of a non simplicial mesh is arbitrary as long as each cell is isomorphic to the reference cell by matching each vertex to the correspon
32. needs_mesh_entities 41 3 7 3 The function initmesh aaaea ee ee eee ds 41 3ra The uction initagell seara et Book e An eK 41 3 7 5 The function init_cell_finalize 42 3 7 6 The function topological_dimension 42 3 8 3 9 3 10 3 11 3 7 7 The function geometric dimension 42 3 7 8 The function global_dimension 42 3 T 9 The tunction lecal dimension p s ss was ors 43 3 7 10 The function max_local_dimension 43 3 7 11 The function num facet dofs 25 se bn es Ses 43 3 7 12 The function numentity dofs 44 3 7 13 The function tabulatedofs lt 84 4555 5 44 3 7 14 The function tabulate_facet_dofs 44 3 7 15 The function tabulate_entity_dofs 45 3 7 16 The function tabulate_coordinates 45 3 7 17 The function num subdofmaps 6 4 ave kes 46 3 7 18 The function create_sub_dofmap 46 3 1 19 The function Greate e oco 2 44 44 28 464 9805 47 The integral classes ooe s ew moop Kobe eK SER OS Bes 47 Theclass ufc cell integral oo 266s eee ee ee wau 48 3 9 1 The function tabulate tensor aoaaa aaa 48 3 9 2 The function tabulate_tensor quadrature version 48 The class ufc exterior_facet_integral 49 3 10 1 The function tabulate tensor 49 3 10 2 The function tabulate_tensor quadrature version 50 The class ufc interior facet_integral 50 3 12 3 11 1 The f
33. pycc Functions OrderedPtvSet h gt include lt pycc Functions Dof_OrderedPtvSet h gt namespace pycc This class defines the interface for a local to global mapping of degrees of freedom dofs class dof_map_Lagrange_1_2D public ufc dof_map public pycc Dof_Ptv dof unsigned int num_elements unsigned int loc2glob public Constructor dof_map_Lagrange_1_2D Destructor virtual dof_map_Lagrange_1_2D Return a string identifying the dof map virtual const char signature const Return true iff mesh entities of topological dimension d are needed virtual bool needs_mesh_entities unsigned int d const Initialize dof map for mesh return true iff init_cell is needed virtual bool init_mesh const ufc mesh amp m Initialize dof map for given cell virtual void init_cell const ufc meshk m const ufc cell amp c 120 UFC Specification and User Manual 1 1 Finish initialization of dof map for cells virtual void init_cell_finalize Return the dimension of the global finite element function space virtual unsigned int global_dimension const Return the dimension of the local finite element function space virtual unsigned int local_dimension const Return the number of dofs on each cell facet virtual unsigned int num_facet_dofs const Tabulate the local to global mapping of dofs on a cell virtual void tabulate_dofs unsign
34. the expansion coefficients for all coef ficients of the form in the finite element nodal basis for each corresponding function space on the macro cell Thus the size of the array w should be equal to the number of coefficients n and the size of each each array w 0 51 UFC Specification and User Manual 1 1 w 1 etc should be equal to twice the space dimension of the corresponding local finite element space The additional arguments facetO and facet1 should specify the local num ber of the facet with respect to its two incident cells Thus when the facet is an edge of a triangle each of these arguments may be an integer between zero and two 0 1 2 and when the facet is a face of a tetrahedron each of these arguments may be an integer between zero and three 0 1 2 3 3 11 2 The function tabulate_tensor quadrature version Introduced in version version 2 0 virtual void tabulate_tensor double A const double const w const cell amp c unsigned int num_quadrature_points const double const quadrature_points const double quadrature_weights const 0 This function is identical to tabulate_tensor described above but computes the integral over the cell using the given set of quadrature points and weights Note that the quadrature points should be specified on the reference cell By a careful choice of quadrature points this function can be used to integrate over subsets of facets 3 12 The class ufc
35. variational problem 2 1 for the weighted Poisson s equation For the trilinear form a the rank is r 2 and the number of coefficients is n 1 while for the linear form L the rank is r 1 and the number of coefficients is n 1 We may also choose to directly compute the action of the form a obtained by assembling a vector from the form a v w1 w2 wiVv1 Vwe dz 2 9 Q where now r 1 and n 2 We list below a few other examples to illustrate the notation 17 UFC Specification and User Manual 1 1 EXAMPLE 2 1 1 Our first example is related to the divergence constraint in fluid flow Let the form a be given by a q u f qV udz qEV uev 2 10 Q where V is a space of scalar valued functions and where V is a space of vector valued functions The forma V x V R has two primary ar guments and thus r 2 Furthermore the form does not depend on any coefficients and thus n 0 EXAMPLE 2 1 2 Another common form in fluid flow with variable density is a v u w 0 vow Vudz 2 11 Q Here v V u V w W o WF where Vl V2 and W are spaces of vector valued functions while W is a space of scalar valued functions The form takes four arguments where two of the arguments are coefficients a V x V x W x WF gt R 2 12 Hence r 2 and n 2 EXAMPLE 2 1 3 The H Q norm of the error e u up squared is a l u un fe up V u up d
36. x const cell amp c 0 Return the number of sub elements for a mixed element virtual unsigned int num_sub_elements const 0 Create a new finite element for sub element i for a mixed element virtual finite_element create_sub_element unsigned int i const 0 Create a new class instance virtual finite_element create const 0 This class defines the interface for a local to global mapping of degrees of freedom dofs 78 UFC Specification and User Manual 1 1 class dofmap public Constructor dofmap Destructor virtual dofmap Return a string identifying the dofmap virtual const char signature const 0 Return true iff mesh entities of topological dimension d are needed virtual bool needs_mesh_entities unsigned int d const 0 Initialize dofmap for mesh return true iff init_cell is needed virtual bool init_mesh const mesh amp mesh 0 Initialize dofmap for given cell virtual void init_cell const mesh amp m const cell amp c 0 Finish initialization of dofmap for cells virtual void init_cell_finalize 0 Return the topological dimension of the associated cell shape virtual unsigned int topological_dimension const 0 Return the geometric dimension of the associated cell shape virtual unsigned int geometric_dimension const 0 Return the dimension of the global finite element function space v
37. 0 col lt num_derivatives col values row transform row col derivatives col Delete pointer to array of derivatives on FIAT element delete derivatives Delete pointer to array of combinations of derivatives and transform for unsigned int row 0 row lt num_derivatives row delete combinations row delete transform row delete combinations delete transform Evaluate order n derivatives of all basis functions at given point in cell virtual void evaluate_basis_derivatives_all unsigned int n double values const double coordinates const ufc cell amp c const throw std runtime_error The vectorised version of evaluate_basis_derivatives is not Evaluate linear functional for dof i on the function f virtual double evaluate_dof unsigned int i const ufc function amp f const ufc cell amp c const The reference points direction and weights const static double X 3 1 2 0 0 1 0 0 1 const static double W 3 1 1 1 1 const static double D 3 1 1 1 1 1 const double const x c coordinates double result 0 0 Iterate over the points Evaluate basis functions for affine mapping const double wO 1 0 X i 0 0 X i 0 1 const double wi X i 0 0 103 yet implemented UFC Specification and User Manual 1 1 const double w2 X i 0
38. 4 The function geometric_dimension Introduced in UFC version 2 0 virtual unsigned int geometric_dimension const 0 This function returns the geometric dimension of the cell the finite element is defined on 3 6 5 The function space_dimension virtual unsigned int space_dimension const 0 This function returns the dimension of the local finite element space V which is equal to the number of basis functions This should also be equal to the value of local_dimension for the corresponding ufc dofmap see below 3 6 6 The function value rank virtual unsigned int value_rank const 0 33 UFC Specification and User Manual 1 1 A finite element can have general tensor valued basis functions The function value_rank returns the rank of the value space of the basis functions For a scalar element this function should return zero for vector valued functions it should return one for matrix valued functions it should return two etc For mixed elements this may not always make sense for example with a tensor vector scalar element Thus the value rank of a mixed element must be 1 if any of the subelements have different value ranks 3 6 7 The function value_dimension virtual unsigned int value_dimension unsigned int i const 0 This function returns the dimension of the value space of the finite element basis functions for the given axis where the given axi
39. EO_D01 1 3 1 0 1 Compute element tensor using UFL quadrature representation Optimisations simplify expressions False ignore zero tables False non Total number of operations to compute element tensor 162 Loop quadrature points for integral Number of operations to compute element tensor for following IP loop 162 Only 1 integration point omitting IP loop Number of operations for primary indices 162 for unsigned int j 0 j lt 3 j for unsigned int k 0 k lt 3 k Number of operations to compute entry 18 A j 3 k Jinv_00 FE0_D10 0 j Jinv_10 FE0_D01 0 j Jinv_00 FE0_D10 0 end loop over k zero columns False remove k Jinv_10 FEO_D01 0 k J end loop over j 111 UFC Specification and User Manual 1 1 3 This class defines the interface for the tabulation of the cell tensor corresponding to the local contribution to a form from the integral over a cell class PoissonBilinearForm_cell_integral_0 public ufc cell_integral private PoissonBilinearForm_cell_integral_O_quadrature integral_O_quadrature public Constructor PoissonBilinearForm_cell_integral_0 ufc cell_integral Do nothing Destructor virtual PoissonBilinearForm_cell_integral_0 Do nothing Tabulate the tensor for the contribution from a local cell virtual
40. FC view of the cell containing that point 31 UFC Specification and User Manual 1 1 See also the description of ufc finite_element evaluate_dof below 3 6 The class ufc finite_element The class ufc finite_element represents a finite element in the classical Ciarlet sense 6 or rather a particular instance of a finite element for a particular choice of nodal basis functions Thus a ufc finite_element has functions for accessing the shape of the finite element the dimension of the polynomial function space the basis functions of the function space and their derivatives and the linear functionals defining the degrees of freedom In addition a ufc finite_element provides functionality for interpolation 3 6 1 The function signature virtual const char signature const 0 This function returns a signature string that uniquely identifies the finite element This can be used to compare whether or not two given ufc fi nite element objects are identical 3 6 2 The function cell_shape virtual shape cell_shape const 0 This function returns the shape of the cell the finite element is defined on 3 6 3 The function topological dimension Introduced in UFC version 2 0 32 UFC Specification and User Manual 1 1 virtual unsigned int topological_dimension const 0 This function returns the topological dimension of the cell the finite element is defined on 3 6
41. The function init_cell_finalize virtual void init_cell_finalize 0 For ufc dofmap objects where init_mesh returns true this function must be called after init_cell is called for each cell in the mesh to complete initialization of the dofmap 3 7 6 The function topological_dimension Introduced in UFC version 1 1 virtual unsigned int topological_dimension const 0 This function returns the topological dimension of the associated cell shape 3 7 7 The function geometric_dimension Introduced in UFC version 2 0 virtual unsigned int geometric_dimension const 0 This function returns the geometric dimension of the associated cell shape 3 7 8 The function global_dimension virtual unsigned int global_dimension const 0 42 UFC Specification and User Manual 1 1 This function returns the dimension of the global finite element space on the mesh that the ufc dofmap has been initialized for The result of calling this function before the initialization is complete is undefined 3 7 9 The function local_dimension Changed in version 1 2 virtual unsigned int local_dimension const cell amp c const 0 This function returns the dimension of the local finite element space on a given cell 3 7 10 The function max_local_dimension Introduced in UFC version 1 2 virtual unsigned int max_local_dimension const 0 This function r
42. UFC Specification and User Manual 1 1 February 21 2011 Martin Sandve Aln s Anders Logg Kent Andre Mardal Ola Skavhaug and Hans Petter Langtangen www fenics org Visit http www fenics org for the latest version of this manual Send comments and suggestions to ufc dev fenics org Contents 1 Introduction 11 1 1 Unified Form assembly Code 12 Le Amand acp ce Sk EEG RE SRE GEESE SSE o 12 Toe Os kan ee ere he See a See EEE Ae ee oS 13 2 Finite element assembly 15 2 1 Finite Element Discretization 15 2 1 1 The Finite Element 15 ae Varational Forms lt s s s oe piaui BEERS R a 16 ae Dibrelzatiom sa a ea ek aaah iata ed 17 2 2 Finite Element Assembly 2 000 18 3 Interface specification 25 3 1 A short remark on design 2 0000 4 25 3a Sl es sec ow ee ee Ae eo EE SS SES 26 3 3 3 4 3 9 3 6 The class uiciimesh o o cg 4 ncu 2 2 44 20 448844 27 3 3 1 The integer topological dimension 27 3 3 2 The integer geometric_dimension 21 Soo Thearray numentitigs 2nd ecien ods u a es 27 The class ufeiicell vn ad ocs aope oe See ee a e eS ER 28 3 4 1 The enum variable cell_shape 28 3 4 2 The integer topological dimension 28 3 4 3 The integer geometricdimension 29 3 4 4 The array entity_indices 20 3 4 55 The array coordinates s es eda aog g dalyo G ya 29 3 4 6 The i
43. V2 V4 U5 U6 U7 ey 1 11 vo v1 V2 U3 V4 U5 U6 U7 fo 2 0 v4 U5 U6 U7 vo V1 V2 V3 fi 2 1 v2 U3 U6 U7 vo 11 V4 U5 f2 2 2 v1 V2 U5 U6 vo V3 V4 U7 fs 2 3 vo U3 U4 U7 v1 v2 U5 V6 fa 2 4 vo V1 V4 U5 v2 U3 U6 U7 fs 2 5 vo V1 V2 v3 v4 U5 V6 U7 co 3 0 v0 V1 V2 V3 V4 U5 V6 V7 0 71 Bibliography Trilinos URL http software sandia gov trilinos M ALN S AND K A MARDAL SyFi 2007 URL http www fenics org syfi S BALAY K BUSCHELMAN W D GROPP D KAUSHIK M G KNEPLEY L C McINNES B F SMITH AND H ZHANG PETSc 2006 URL http www mcs anl gov petsc W BANGERTH R HARTMANN AND G KANSCHAT deal II Differential Equations Analysis Library 2006 URL http www dealii org A M BRUASET H P LANGTANGEN ET AL Diffpack 2006 URL http www diffpack com P G CIARLET The Finite Element Method for Elliptic Problems North Holland Amsterdam New York Oxford 1978 J HOFFMAN J JANSSON C JOHNSON M G KNEPLEY R C KIRBY A Loce L R SCOTT AND G N WELLS FEniCS 2006 URL http www fenics org J HOFFMAN J JANSSON A LOGG AND G N WELLS DOLFIN 2006 URL http www fenics org dolfin T J R HUGHES The Finite Element Method Linear Static and Dy namic Finite Ele ment Analysis Prentice Hall 1987 73 UFC Specification and User Manual
44. _coeff0_0O 0 double new_coeff0_1 0 double new_coeff0_2 0 Loop possible derivatives for unsigned int deriv_num 0 deriv_num lt num_derivatives deriv_num Get values from coefficients array new_coeff0_0 coefficients0 dof 0 new_coeff0_1 coefficients0 dof 1 new_coeff0_2 coefficients0 dof 2 Loop derivative order for unsigned int j 0 j lt n j t Update old coefficients coeff0_0 new_coeff0_0 coeff0_1 new_coeff0_1 coeff0_2 new_coeff0_2 if combinations deriv_num j 0 new_coeff0_0 coeff0_0 dmats0O 0 0 coeff0_1 dmats0O 1 0 coeff0_2 dmats0 2 0 new_coeff0_1 coeff0_0 dmatsO 0 1 coeff0_1 dmatsO 1 1 coeff0_2 dmats0 2 1 new_coeff0_2 coeff0_0 dmats0O 0 2 coeff0_1 dmats0O 1 2 coeff0_2 dmats0 2 2 if combinations deriv_num j 1 new_coeff0_0 coeff0_0 dmats1 0 0 coeff0_1 dmatsi 1 0 coeff0_2 dmats1 2 0 new_coeff0_1 coeff0_0 dmats1 0 1 coeff0_1 dmatsi 1 1 coeff0_2 dmats1 2 1 new_coeff0_2 coeff0_0 dmats1 0 2 coeff0_1 dmatsi i 2 coeff0_2 dmats1i 2 2 3 Compute derivatives on reference element as dot product of coefficients and basisvalues derivatives deriv_num new_coeff0_0 basisvalueO new_coeff0_1 basisvaluei new_coeff0_2 basisvalue 2 Transform derivatives back to physical element for unsigned int row 0 row lt num_derivatives row
45. _dofs unsigned int dofs const ufc mesh amp m const ufc cell amp c const dofs 0 c entity_indices 0 0 dofs 1 c entity_indices 0 1 dofs 2 c entity_indices 0 2 Tabulate the local to local mapping from facet dofs to cell dofs virtual void tabulate_facet_dofs unsigned int dofs unsigned int facet const switch facet case 0 dofs 0 1 dofs 1 2 break case 1 dofs 0 0 dofs 1 2 break case 2 109 UFC Specification and User Manual 1 1 dofs 0 0 dofs i 1 break Tabulate the local to local mapping of dofs on entity d i virtual void tabulate_entity_dofs unsigned int dofs unsigned int d unsigned int i const throw std runtime_error Not implemented introduced in UFC v1 1 Tabulate the coordinates of all dofs on a cell virtual void tabulate_coordinates double coordinates const ufc cell amp c const const double const x c coordinates coordinates 0 0 x 0 0 coordinates 0 1 x 0 1 coordinates 1 0 x 1 0 coordinates 1 1 x 1 1 coordinates 2 0 x 2 0 coordinates 2 1 x 2 1 Return the number of sub dof maps for a mixed element virtual unsigned int num_sub_dof_maps const return 1 Create a new dof_map for sub dof map i for a mixed element virtual ufc dof_map create_sub_dof_map unsigned int i const return new PoissonBilin
46. _facet_integral tabulates the values of the local interior facet tensor into the array A given the nodal basis expansions of the form coefficients in the array w However the interior facet tensor contains contributions from the two incident cells of an interior facet and thus the dimensions of these arrays are different On each interior facet the two incident neighboring cells form a macro cell consisting of the total set of local basis functions on the two cells The set of basis functions on the macro element is obtained by extending the basis functions on each of the two cells by zero to the macro cell Thus the space dimension of the finite element function space on the macro element is twice the size of the finite element function space on a single cell The ordering of basis functions and degrees of freedom on the macro cell is obtained by first enumerating the basis functions and degrees of freedom on one of the two cells and then the basis functions and degrees of freedom on the second cell Thus the size of the array A should be equal to the product of twice the local space dimensions for the set of finite element function spaces corresponding to the arguments of the form For example when computing the matrix for a bilinear form defined on piecewise linear elements on triangles the space dimension of the local finite element is three and so the size of the array A should be 6 x 6 36 Similarly the array w should contain
47. al_dimension plus one Thus entity indices 0 should be an array containing the global indices of all the vertices of the cell entity_indices 1 should be an array containing the global indices of all the edges of the cell etc The sizes of these arrays are implicitly defined by the cell type Note that the entity indices are not always needed for all entities of the cell Which entities are required is specified by the ufc dofmap class see ufc dofmap needs mesh_entities below 3 4 5 The array coordinates double coordinates 29 UFC Specification and User Manual 1 1 The array coordinates should contain the global coordinates for all vertices of the cell and thus its length should be equal to number of vertices of the cell The length of the array coordinates 0 should be equal to the value of the variable geometric_dimension and it should contain the z y coordinates of the first vertex etc 3 4 6 The integer index Introduced in UFC version 2 0 unsigned int index The integer index should contain the global index for the cell This is a short cut for entity_indices topological_dimension 0 3 4 7 The integer local facet Introduced in UFC version 2 0 int local_facet The integer local_facet can be used during callbacks to the evaluate func tion of ufc function to specify the local index of a facet relative to the cell on which the function is being evaluated
48. ate_exterior_facet_integral unsigned int i cons interior_facet_integral create_interior_facet_integral unsigned int i cons 114 UFC Specification and User Manual 1 1 C 2 Code generated by SyFi In the following we list the complete code for the finite element the dofmap and the variational form for computing a stiffness matrix based on linear Lagrangian elements in 2D The code below is generated for the assembler in PyCC and it therefore includes some PyCC files since the option SFC options include_from pycc was used during the code generation If PyCC is not present the op tion SFC options include_from syfi can be used and this will result in some additional files that define the numbering scheme C 2 1 Header file for linear Lagrange element in 2D This code complies with UFC version 1 0 and is generated with SyFi version 0 4 0 http www fenics org syfi http www fenics org ufc ifndef __fe_Lagrange_1_2D_H define __fe_Lagrange_1_2D_H include lt stdexcept gt include lt math h gt include lt ufc h gt include lt pycc Functions Ptv h gt include lt pycc Functions Ptv_tools h gt include lt pycc Functions Dof_Ptv h gt include lt pycc Functions OrderedPtvSet h gt include lt pycc Functions Dof_OrderedPtvSet h gt namespace pycc This class defines the interface for a finite element class fe_Lagrange_1_2D public ufc finite_elemen
49. ated by FFC This code conforms with the UFC specification version 1 0 and was automatically generated by FFC version 0 6 2 ifndef __POISSON_H define __POISSON_H include lt cmath gt include lt stdexcept gt include lt ufc h gt This class defines the interface for a finite element class PoissonBilinearForm_finite_element_0 public ufc finite_element public Constructor PoissonBilinearForm_finite_element_0 ufc finite_element Do nothing Destructor virtual PoissonBilinearForm_finite_element_0 Do nothing Return a string identifying the finite element virtual const char signature const return FiniteElement Lagrange triangle 1 Return the cell shape virtual ufc shape cell_shape const return ufc triangle Return the dimension of the finite element function space virtual unsigned int space_dimension const return 3 Return the rank of the value space virtual unsigned int value_rank const return 0 Return the dimension of the value space for axis i 90 UFC Specification and User Manual 1 1 virtual unsigned int value_dimension unsigned int i const return 1 Evaluate basis function i at given point in cell virtual void evaluate_basis unsigned int i double values const double coordinates const ufc cell amp c const Extract vertex c
50. c coordinates 2 0 double y2 affine map double GOO x1 double G01 x2 double G10 y1 double G11 y2 double detG_tmp c coordinates 1 1 c coordinates 2 1 x0 x0 yO yO GOO G11 GO1 G10 double detG fabs detG_tmp double GinvT00 double GinvT01 double GinvT10 double GinvT11 G11 detG_tmp G10 detG_tmp G01 detG_tmp GOO detG_tmp memset A 0 sizeof double 9 A 3 0 0 detG GinvT01 GinvT01 2 0 GinvT11 GinvT11 2 0 GinvT10 GinvT00 GinvT01 Ginv1 T11 GinvT00 GinvT00 2 0 GinvT10 GinvT10 2 0 A 3 0 1 detG GinvT01 GinvT01 2 0 GinvT10 GinvT00 2 0 GinvT01 GinvT11 2 0 GinvT00 GinvT00 2 0 A 3 0 2 detG GinvT11 GinvT11 2 0 GinvT10 GinvT00 2 0 GinvT01 Ginv1 11 2 0 GinvT10 GinvT10 2 0 A 3 1 0 detG GinvT01 GinvT01 2 0 GinvT10 GinvT00 2 0 GinvT01 Ginv1 11 2 0 GinvT00 GinvT00 2 0 A 3 1 1 detG GinvT01 GinvT01 2 0 GinvT00 GinvT00 2 0 A 3 1 2 detG GinvT10 GinvT00 2 0 GinvT01 GinvT11 2 0 A 3 2 0 detG GinvT11 GinvT11 2 0 GinvT10 GinvT00 2 0 GinvT01 Ginv1 11 2 0 GinvT10 GinvT10 2 0 A 3 2 1 detG GinvT10 GinvT00 2 0 GinvT01 GinvT11 2 0 A 3 2 2 detG GinvT11 GinvT11 2 0 GinvT10 GinvT10 2 0 Constructor form__stiffness_form__Lagrange_1_2D form__stiffness_form__Lagrange_1_2D ufc form 128 UFC Specification and U
51. cal degree of freedom or equivalently local basis function to the number of the corresponding global degree of freedom or equivalently global basis function We then define for each K T the collective local to global mapping tx Zg gt Z by ili tie lii 02 i2 be ip Vi Ix 2 19 where Tyg is the index set r Tx 0 Pell j 1 A p sss Do ess hes e haea eN 2 20 j j n Furthermore for each V we let of 4 denote the restriction to an element K of the subset of the basis C Pi of V supported on K 20 UFC Specification and User Manual 1 1 We may now compute A by summing the contributions from the local cells A Cb Pats st de KeT c 2k K r gt J PB Gy ay o Say Voo Wa de 2 21 KETI K E 2 Az i KETI where A is the local cell tensor on cell K the element stiffness matrix given by aka f PO ti Uen de 2 22 K and where F denotes the set of cells on which all basis functions o 67 0 are supported Similarly we may sum the local contributions from the exte rior and interior facets in the form of local exterior facet tensors and interior facet tensors jo ji j2 1 iO 2 3 il A21 i2 Figure 2 1 Adding the entries of a cell tensor A to the global tensor A using the local to global mapping vx illustrated here for a rank two tensor a matrix 21 UFC Specification and User Manual 1 1 In Algorithm 1
52. coordinates Interpolate coefficients library specific so omitted here 86 UFC Specification and User Manual 1 1 Tabulate dofs for each dimension for unsigned int i 0 i lt ufc form rank i dofmaps i gt tabulate_dofs dofs i mesh cell Tabulate cell tensor cell_integrals sub_domain gt tabulate_tensor AK w cell Add entries to global tensor library specific so omitted here Delete data structures delete mesh num_entities 87 Appendix C Complete UFC code for Poisson s equation In this section a simple example is given of UFC code generated by the form compilers FFC 14 10 13 11 12 and SyFi 2 for Poisson s equation The code presented below is generated for the bilinear form of Poisson s equation for standard continuous piecewise linear Lagrange finite elements on a two dimensional domain Q alv u ve Vudz C 1 Although FFC and SyFi are two different form compilers with very different approaches to code generation both generate code that conforms to the UFC specification and may thus be used interchangeably within any UFC based system In the generated code we have omitted the two functions evaluate_basis and evaluate_basis_derivatives to save space lFor FFC this may be done by using the compiler flags fno evaluate_basis and fno evaluate_basis_derivatives 89 UFC Specification and User Manual 1 1 C 1 Code gener
53. dentifier int mesh_identifier 76 UFC Specification and User Manual 1 1 This class defines the interface for a general tensor valued function class function public Constructor function Destructor virtual function Evaluate function at given point in cell virtual void evaluate double values const double coordinates const cell amp c const 0 Dee This class defines the interface for a finite element class finite_element public Constructor finite_element Destructor virtual finite_element Return a string identifying the finite element virtual const char signature const 0 Return the cell shape virtual shape cell_shape const 0 Return the topological dimension of the cell shape virtual unsigned int topological_dimension const 0 Return the geometric dimension of the cell shape virtual unsigned int geometric_dimension const 0 Return the dimension of the finite element function space virtual unsigned int space_dimension const 0 Return the rank of the value space virtual unsigned int value_rank const 0 Return the dimension of the value space for axis i virtual unsigned int value_dimension unsigned int i const 0 Evaluate basis function i at given point in cell virtual void evaluate_basis unsigned int i double values const double coordinates const cell amp c const 0
54. ding vertex of the reference cell 65 UFC Specification and User Manual 1 1 As an illustration consider the numbering of edges the mesh entities of topological dimension one on the reference triangle in Figure 5 3 To number the edges of the reference triangle we identify for each edge the corresponding non incident vertices For each edge there is only one such vertex the vertex opposite to the edge We thus identify the three edges in the reference triangle with the tuples vo v1 and v2 The first of these is edge eo between vertices v and v opposite to vertex vo the second is edge e between vertices Ug and v opposite to vertex v and the third is edge eg between vertices Up and v opposite to vertex v Similarly we identify the six edges of the reference tetrahedron with the corresponding non incident tuples vo v1 vo V2 vo v3 V1 V2 V1 U3 and v2 v3 The first of these is edge eo between vertices v2 and v3 opposite to vertices vo and v as shown in Figure 5 4 v2 Vo U1 Figure 5 3 Mesh entities are ordered based on a lexicographical ordering of the corresponding ordered tuples of non incident vertices The first edge e9 is non incident to vertex vp 5 3 1 Relative ordering The relative ordering of mesh entities with respect to other incident mesh entities follows by sorting the entities by their global indices Thus the pair of vertices incident to the first edge eo of a triangular cel
55. e 2 13 Q The form takes two arguments and both are coefficients a W x WF gt R 2 14 Hence r 0 and n 2 2 2 Finite Element Assembly The standard algorithm for computing the global sparse tensor A is known as assembly see 16 9 By this algorithm the tensor A may be computed 18 UFC Specification and User Manual 1 1 by assembling summing the contributions from the local entities of a finite element mesh To express this algorithm for assembly of the global sparse tensor A for a general finite element variational form of arity r we introduce the following notation and assumptions Let T K be a set of disjoint cells a triangulation partitioning the domain 2 UgxerK Further let 0 7 denote the set of exterior facets the set of cell facets incident with the boundary 02 and let 0 7 denote the set of interior facets the set of cell facets non incident with the boundary OQ For each discrete function space Vi j 1 2 r we assume that the global basis N is obtained by patching together local function spaces P on each cell K as determined by a local to global mapping We shall further assume that the variational form 2 5 may be expressed as a sum of integrals over the cells 7 the exterior facets 0 7 and the interior facets 0 7 We shall allow integrals expressed on disjoint subsets T U7 Tk OT Upe 0eT and OiT Uz 0 7 respectively We thus assume that the form a is given by WUi p
56. e computed values for a single basis func tion are placed contiguously in the array Note that just as for evaluate_basis the point defined by coordinates should be located inside the cell c The result is otherwise undefined 3 6 10 The function evaluate_basis derivatives virtual void evaluate_basis_derivatives unsigned int i unsigned int n double values In particular the basis functions generated by FIAT FFC are undefined along the line y 1 on the UFC reference element since the collapsed cube mapping used by FIAT is singular along that line 35 UFC Specification and User Manual 1 1 const double coordinates const cell amp c const 0 This function evaluates all order n derivatives of basis function i at the given coordinates within the given cell and stores the values in the array values Derivatives may be obtained up to the polynomial degree of the finite element function space with higher degree derivatives evaluating to Zero The number of derivatives is given by d where d is the geometric dimen sion of the cell For n 1 d 3 the order of the derivatives is natu rally 0 Ox 0 Oy 0 Oz For n 2 d 3 the order of the derivatives is a sp or n Thus the derivatives are stored in a flattened row major ordering based on the derivative spatial dimensions For tensor valued basis functions the ordering of derivatives is row major based on the value space dimensions followed by the deri
57. e derivatives for unsigned int deriv_num 0 deriv_num lt num_derivatives deriv_num Get values from coefficients array new_coeff0_0 coefficients0 dof 0 new_coeff0_1 coefficients0 dof 1 new_coeff0_2 coefficients0 dof 2 Loop derivative order for unsigned int j 0 j lt n j Update old coefficients coeff0_0 new_coeff0_0 coeff0_1 new_coeff0_1 coeff0_2 new_coeff0_2 if combinations deriv_num j 0 new_coeff0_0 coeff0_0 dmats0 0 0 coeff0_1 dmatsO 1 0 coeff0_2 dmats0 2 0 new_coeff0_1 coeff0_0 dmats0 0 1 coeff0_1 dmatsO 1 1 coeff0_2 dmats0 2 1 new_coeff0_2 coeff0_0 dmats0 0 2 coeff0_1 dmats0O 1 2 coeff0_2 dmats0 2 2 if combinations deriv_num j 1 102 UFC Specification and User Manual 1 1 new_coeff0_0 coeff0_0 dmats1i 0 0 coeff0_1 dmats1 1 0 coeff0_2 dmatsi 2 new_coeff0_1 coeff0_0 dmats1 0 1 coeff0_1 dmats1 1 1 coeff0_2 dmatsi 2 new_coeff0_2 coeff0_0 dmats1 0 2 coeff0_1 dmats1 1 2 coeff0_2 dmats1i 2 0 1 2 Compute derivatives on reference element as dot product of coefficients and basisvalues derivatives deriv_num new_coeff0_0 basisvalueO new_coeff0_1 basisvaluei new_coeff0_2 basisvalue2 Transform derivatives back to physical element for unsigned int row 0 row lt num_derivatives row for unsigned int col
58. e global mesh to UFC functions 3 3 1 The integer topological_dimension unsigned int topological_dimension The unsigned integer topological_dimension holds the topological dimen sion of the mesh that is the topological dimension of the cells of the mesh For the supported cell shapes defined above the topological dimensions are as follows interval has dimension one triangle and quadrilateral have dimension two and tetrahedron and hexahedron have dimension three 3 3 2 The integer geometric dimension unsigned int geometric_dimension The unsigned integer geometric_dimension holds the geometric dimension of the mesh that is the dimension of the coordinates of the mesh vertices Often the geometric dimension is equal to the topological dimension but they may differ For example one may have a topologically two dimensional mesh embedded in three dimensional space 3 3 3 The array num entities unsigned int num_entities 27 UFC Specification and User Manual 1 1 The array num_entities should contain the number of entities within each topological dimension of the mesh see Chapter 4 The size of the array should be equal to the topological dimension of the mesh plus one Thus for a mesh of tetrahedral cells num_entities 0 should contain the number of vertices num_entities 1 should contain the number of edges if they are needed see ufc dofmap needs_mesh_ entities below num e
59. e_dofmap unsigned int i const 0 This factory function constructs a ufc dofmap object for form argument i A form with rank r and number of coefficients n has r n arguments so this function returns the dofmap object for tensor axis 7 if i lt r or the dofmap for coefficient i r if i gt r The caller is responsible for deleting the returned object 3 12 9 The function create_cell_integral virtual cell_integral create_cell_integral unsigned int i const 0 This factory function constructs a cell_integral object for cell domain i The caller is responsible for deleting the returned object If the integral evaluates to zero this function may return a null pointer 3 12 10 The function create_exterior_facet_integral virtual exterior_facet_integral create_exterior_facet_integral unsigned int i const 0 55 UFC Specification and User Manual 1 1 This factory function constructs an exterior_facet_integral object for exterior facet domain i The caller is responsible for deleting the returned object If the integral evaluates to zero this function may return a null pointer 3 12 11 The function create_interior_facet_integral virtual interior_facet_integral create_interior_facet_integral unsigned int i const 0 This factory function constructs an interior_facet_integral object for interior facet domain i The caller is responsible for deleting the returned object
60. earForm_dof_map_1 F This class defines the interface for the tabulation of the cell tensor corresponding to the local contribution to a form from the integral over a cell class PoissonBilinearForm_cell_integral_0_quadrature public ufc cell_integral public Constructor PoissonBilinearForm_cell_integral_O_quadrature ufc cell_integral Do nothing Destructor virtual PoissonBilinearForm_cell_integral_O_quadrature 110 UFC Specification and User Manual 1 1 Tabulate the tensor for the contribution from a local cell virtual void tabulate_tensor double A Do nothing const double const w const ufc cell amp c const Extract vertex coordinates const double const x c coordinates Compute Jacobian of affine map from reference cell const double J_00 x 1 0 x 0 0 const double J_01 x 2 0 x 0 0 const double J_10 x 1 1 x 0 1 const double J_11 x 2 1 x 0 1 Compute determinant of Jacobian double detJ J_00 J_11 J_01 J_10 Compute inverse of Jacobian const double Jinv_00 J_11 detJ const double Jinv_01 J_01 detJ const double Jinv_10 J_10 detJ const double Jinv_11 J_00 detJ Set scale factor const double det std abs detJ Array of quadrature weights const static double Wi 0 5 const static double FEO_D10 1 3 ttsdy dy o const static double F
61. ed int dofs const ufc mesh amp m const ufc cell amp c const Tabulate the local to local mapping from facet dofs to cell dofs virtual void tabulate_facet_dofs unsigned int dofs unsigned int facet const Tabulate the coordinates of all dofs on a cell virtual void tabulate_coordinates double coordinates const ufc cell amp c const Return the number of sub dof maps for a mixed element virtual unsigned int num_sub_dof_maps const Create a new dof_map for sub dof map i for a mixed element virtual ufc dof_map create_sub_dof_map unsigned int i const 3 namespace endif C 2 4 Source file for the dofmap This code complies with UFC version 1 0 and is generated with SyFi version 0 4 0 http www fenics org syfi http www fenics org ufc include lt stdexcept gt include lt math h gt include lt ufc h gt 121 UFC Specification and User Manual 1 1 include lt pycc Functions Ptv h gt include lt pycc Functions Ptv_tools h gt include lt pycc Functions Dof_Ptv h gt include lt pycc Functions OrderedPtvSet h gt include lt pycc Functions Dof_OrderedPtvSet h gt include dof_map_Lagrange_1_2D h namespace pycc Constructor dof _map_Lagrange_1_2D dof_map_Lagrange_1_2D ufc dof_map loc2glob 0 Destructor dof _map_Lagrange_1_2D dof_map_Lagrange_1_2D if loc2glob delete l
62. eference cell const double J_00 element_coordinates 1 0 element_coordinates 0 0 const double J_01 element_coordinates 2 0 element_coordinates 0 0 const double J_10 element_coordinates 1 1 element_coordinates 0 1 const double J_11 element_coordinates 2 1 element_coordinates 0 1 Compute determinant of Jacobian const double detJ J_00 J_11 J_01 J_10 Compute inverse of Jacobian Get coordinates and map to the reference UFC element double x element_coordinates 0 1 element_coordinates 2 0 element_coordinates 0 0 element_coordinates 2 1 J_11 coordinates 0 J_01 coordinates i detJ double y element_coordinates 1 1 element_coordinates 0 0 element_coordinates 1 0 element_coordinates 0 1 J_10 coordinates 0 J_00 coordinates i detJ Map coordinates to the reference square if std abs y 1 0 lt 1e 14 x 1 0 else x 2 0 x 1 0 y 1 0 y 2 0 y 1 0 Compute number of derivatives unsigned int num_derivatives 1 for unsigned int j 0 j lt n j num_derivatives 2 Declare pointer to two dimensional array that holds combinations of derivatives and A aN unsigned int combinations new unsigned int num_derivatives for unsigned int j 0 j lt num_derivatives j combinations j new unsigned int n for unsigned int k 0 k lt n k combinations j k 0
63. element mesh It has a single function tabulate tensor which may be called to tabulate the values of the cell tensor for a given cell 3 9 1 The function tabulate_tensor virtual void tabulate_tensor double A const double const w const cell amp c const 0 This function tabulates the values of the cell tensor for a form into the given array A The size of this array should be equal to the product of the local space dimensions for the set of finite element function spaces corresponding to the arguments of the form For example when computing the matrix for a bilinear form defined on piecewise linear scalar elements on triangles the space dimension of the local finite element is three and so the size of the array A should be 3 x 3 9 The array w should contain the expansion coefficients for all coefficients of the form in the finite element nodal basis for each corresponding function space Thus the size of the array w should be equal to the number of coefficients n and the size of each each array w 0 w 1 etc should be equal to the space dimension of the corresponding local finite element space 3 9 2 The function tabulate_tensor quadrature version Introduced in UFC version version 2 0 virtual void tabulate_tensor double A 48 UFC Specification and User Manual 1 1 const double const w const cell amp c unsigned int num_quadrature_points const double const quadrature_points const d
64. ent 1 pdof1 double dof2 2 x0 GO1 G1it tyO Ptv pdof2 2 dof2 dof insert_dof element 2 pdof2 Finish initialization of dof map for cells void dof_map_Lagrange_1_2D init_cell_finalize loc2glob new unsigned int num_elements local_dimension dof build_loc2dof num_elements local_dimension reinterpret_cast lt int gt loc2glob Return the dimension of the global finite element function space unsigned int dof_map_Lagrange_1_2D global_dimension const return dof size Return the dimension of the local finite element function space unsigned int dof_map_Lagrange_1_2D local_dimension const return 3 Return the number of dofs on each cell facet unsigned int dof_map_Lagrange_1_2D num_facet_dofs const return 2 Tabulate the local to global mapping of dofs on a cell void dof_map_Lagrange_1_2D tabulate_dofs unsigned int dofs const ufc mesh amp m const ufc cell amp c const const unsigned int from_dofs loc2glob 3 c entity_indices 2 0 memcpy dofs from_dofs sizeof unsigned int 3 123 UFC Specification and User Manual 1 1 Tabulate the local to local mapping from facet dofs to cell dofs void dof_map_Lagrange_1_2D tabulate_facet_dofs unsigned int dofs unsigned int facet const switch facet case 0 dofs 0 1 dofs i 2 break case 1 dofs 0 0 dofs i 2 break ca
65. er facets or normal components on facets 3 6 13 The function evaluate dofs Introduced in UFC version 1 1 virtual void evaluate_dofs double values const function amp f const cell amp c const 0 Vectorized version of evaluate_dof for efficiency returning the values of all degrees of freedom in the array values 37 UFC Specification and User Manual 1 1 3 6 14 The function interpolate_vertex_values virtual void interpolate_vertex_values double vertex_values const double dof_values const cell amp c const 0 This function takes as input the array dof_values containing the expansion coefficients for some function in the nodal basis and computes the values of that function at the vertices of the given cell storing those values in the array vertex_values If the function is tensor valued the values are stored in the array vertex_values row major on the list of vertices followed by the row major ordering of the tensor values as described above 3 6 15 The function map_from_reference_cell Introduced in UFC version 2 0 virtual void map_from_reference_cell double x const double xhat const cell amp c 0 This function maps a given coordinate xhat on the reference cell to a coor dinate x on a given ufc cell 3 6 16 The function map_to_reference_cell Introduced in UFC version 2 0 virtual void map_to_reference_cell double xhat const double x const cell a
66. eturn the number of cell integrals virtual unsigned int num_cell_integrals const return 1 Return the number of exterior facet integrals virtual unsigned int num_exterior_facet_integrals const return 0 Return the number of interior facet integrals virtual unsigned int num_interior_facet_integrals const Function FiniteElement Lagrange 113 UFC Specification and User Manual 1 1 return 0 Create a new finite element for argument function i virtual ufc finite_element create_finite_element unsigned int i const switch i case 0 return new PoissonBilinearForm_finite_element_0 break case 1 return new PoissonBilinearForm_finite_element_1i break return 0 Create a new dof map for argument function i virtual ufc dof_map create_dof_map unsigned int i const a switch i case 0 return new PoissonBilinearForm_dof_map_0 break case 1 return new PoissonBilinearForm_dof_map_1 break return 0 Create a new cell integral on sub domain i virtual ufc cell_integral create_cell_integral unsigned int i const return new PoissonBilinearForm_cell_integral_0 Create a new exterior facet integral on sub domain i virtual ufc return 0 Create a new interior facet integral on sub domain i virtual ufc h 3 return 0 endif exterior_facet_integral cre
67. eturns the maximum dimension of the local finite element space on a single cell 3 7 11 The function num_facet_dofs virtual unsigned int num_facet_dofs const 0 This function returns the number of dofs associated with a single facet of a cell including all dofs associated with mesh entities of lower dimension 43 UFC Specification and User Manual 1 1 incident with the facet For example on a tetrahedron this will include dofs associated with edges and vertices of the triangle face This is also the number of dofs that should be set if a Dirichlet boundary condition is applied to a single facet 3 7 12 The function num entity dofs Introduced in UFC version 1 1 virtual unsigned int num_entity_dofs unsigned int d const 0 This function returns the number of dofs associated with a single mesh entity of dimension d in a cell not including dofs associated with incident entities of lower dimension unlike num facet_dofs It is assumed that all cells of the mesh have the same number of degrees of freedom on each mesh entity of the same dimension 3 7 13 The function tabulate _dofs virtual void tabulate_dofs unsigned int dofs const mesh amp m const cell amp c const 0 This function tabulates the global dof indices corresponding to each dof on the given cell The size of the output array dofs should be equal to the value returned by local_dimension 3 7 14 The function tabula
68. gree on the orientation of the common edge 5 4 Numbering schemes for reference cells The numbering scheme is demonstrated below for cells isomorphic to each of the five reference cells 5 4 1 Numbering of mesh entities on intervals Entity Incident vertices Non incident vertices vo 0 0 vo v1 v 0 1 v1 vo co 1 0 vo V1 0 68 UFC Specification and User Manual 1 1 5 4 2 Numbering of mesh entities on triangular cells Entity Incident vertices Non incident vertices vo 0 0 vo v1 V2 v 0 1 v1 vo V2 va 0 2 v2 vo v1 eo 1 0 v1 V2 vo e1 1 1 vo V2 v1 eg 1 2 vo 1 v2 co 2 0 vo U1 V2 5 4 3 Numbering of mesh entities on quadrilateral cells Entity Incident vertices Non incident vertices vo 0 0 vo v1 V2 V3 v 0 1 v1 vo V2 U3 v2 0 2 v2 vo U1 U3 v3 0 3 v3 Vo V1 V2 eo 1 0 v2 v3 vo U1 1 1 v1 V2 vo U3 e 1 2 vo U3 v1 V2 e3 1 3 vo U1 v2 U3 o 2 0 vo U1 V2 V3 0 69 UFC Specification and User Manual 1 1 5 4 4 Numbering of mesh entities on tetrahedral cells Entity Incident vertices Non incident vertices vo 0 0 vo v1 V2 V3 v 0 1 v1 vo V2 V3 vz
69. he UFC specification and in particular the header file ufc h is released into the public domain 139 Index hexahedron 26 global tensor 17 interval 26 quadrilateral 26 tabulate_tensor 48 49 installation 133 tabulate_tensor quadrature version terface 25 48 50 52 i interior facet tensor 21 tetrahedron 26 interval 58 triangle 26 hexahedron 61 ufc cell_integral 48 license 139 ufc cell 28 ufc dofmap 40 mesh entity 63 ufc exterior_facet_integral 49 a numbering 63 ufc finite element 32 ufc form 52 Poisson s equation 89 ufc function 31 Python utilities 131 ufc interior_facet_integral 50 ufc mesh 27 quadrilateral 59 assembly 18 reference cells 57 Cell shapes 26 SyFi 11 115 cell tensor 21 tetrahedron 60 code generation 131 etrahedron topological dimension 63 design 25 triangle 58 example code 89 ufc h 26 exterior facet tensor 21 weemtonal foun ae FFC 11 90 versions 135 finite anus 15 vertex numbering 64 form compilers 11 141
70. i const 0 Create a new class instance virtual dofmap create const 0 F This class defines the interface for the tabulation of the cell tensor corresponding to the local contribution to a form from the integral over a cell class cell_integral public Constructor cell_integral Destructor virtual cell_integral Tabulate the tensor for the contribution from a local cell virtual void tabulate_tensor double A const double const w const cell amp c const 0 Tabulate the tensor for the contribution from a local cell using the specified reference cell quadrature points weights virtual void tabulate_tensor double A const double const w const cell amp c unsigned int num_quadrature_points const double const quadrature_points const double quadrature_weights const 0 F This class defines the interface for the tabulation of the exterior facet tensor corresponding to the local contribution to a form from the integral over an exterior facet class exterior_facet_integral public 80 UFC Specification and User Manual 1 1 Constructor exterior_facet_integral Destructor virtual exterior_facet_integral Tabulate the tensor for the contribution from a local exterior facet virtual void tabulate_tensor double A const double const w const cell amp c unsigned int facet const 0
71. ilde_bs_0_O 1 const double psitilde_bs_0_1 1 5 y 0 5 91 UFC Specification and User Manual 1 1 const double psitilde_bs_1_0 1 Compute basisvalues const double basisvalueO 0 707106781186548 psitilde_a_O scalings_y_0O psitilde_bs_0_0 const double basisvalue1 1 73205080756888 psitilde_a_1 scalings_y_1 psitilde_bs_1_0 const double basisvalue2 psitilde_a_0 scalings_y_0 psitilde_bs_0_1 Table s of coefficients const static double coefficients0 3 3 0 471404520791032 0 288675134594813 0 166666666666667 0 471404520791032 0 288675134594813 0 166666666666667 0 471404520791032 0 0 333333333333333 Extract relevant coefficients const double coeff0_0 coefficients0 dof 0 const double coeff0_1 coefficients0 dof 1 const double coeff0_2 coefficients0 dof 2 Compute value s xvalues coeff0_0 basisvalueO coeff0_1 basisvaluei coeff0_2 basisvalue2 Evaluate all basis functions at given point in cell virtual void evaluate_basis_all double values const double coordinates const ufc cell amp c const throw std runtime_error The vectorised version of evaluate_basis is not yet implemented Evaluate order n derivatives of basis function i at given point in cell virtual void evaluate_basis_derivatives unsigned int i unsigned int n double values const double coordinates const ufc cell amp c const Extract vertex coordinates c
72. ions must be transformed by the Piola mapping UFC code has been successfully generated and used in finite element codes for standard continuous Galerkin methods Lagrange finite elements of arbitrary order discontinuous Galerkin methods including integrals of jumps and av erages over interior facets and mixed methods including Brezzi Douglas Marini and Raviart Thomas elements 12 UFC Specification and User Manual 1 1 1 3 Outline In the next section we give an overview of finite element assembly and explain how the code generated by form compilers may be used as the basic building blocks in the assembly algorithm We then present the UFC interface in detail in Section 3 In Section 4 and Section 5 we define the reference cells and numbering conventions that must be followed by UFC based form compilers and assemblers 13 Chapter 2 Finite element assembly In this section we present a general algorithm for assembly of finite element variational forms and define the concepts that the UFC interface is based on 2 1 Finite Element Discretization 2 1 1 The Finite Element A finite element is mathematically defined as a triplet consisting of a poly gon a polynomial function space and a set of linear functionals see 6 Given that the dimension of the function space and the number of the lin early independent linear functionals are equal the finite element is uniquely defined Hence we will refer to a finite eleme
73. irtual unsigned int global_dimension const 0 Return the dimension of the local finite element function space for a cell virtual unsigned int local_dimension const cell amp c const 0 Return the maximum dimension of the local finite element function space virtual unsigned int max_local_dimension const 0 Return the number of dofs on each cell facet virtual unsigned int num_facet_dofs const 0 Return the number of dofs associated with each cell entity of dimension d virtual unsigned int num_entity_dofs unsigned int d const 0 Tabulate the local to global mapping of dofs on a cell virtual void tabulate_dofs unsigned int dofs const mesh amp m const cell amp c const 0 Tabulate the local to local mapping from facet dofs to cell dofs virtual void tabulate_facet_dofs unsigned int dofs unsigned int facet const 0 79 UFC Specification and User Manual 1 1 Tabulate the local to local mapping of dofs on entity d i virtual void tabulate_entity_dofs unsigned int dofs unsigned int d unsigned int i const 0 Tabulate the coordinates of all dofs on a cell virtual void tabulate_coordinates double coordinates const cell amp c const 0 Return the number of sub dofmaps for a mixed element virtual unsigned int num_sub_dofmaps const 0 Create a new dofmap for sub dofmap i for a mixed element virtual dofmap create_sub_dofmap unsigned int
74. is probably not suitable to be exposed as part of an end user interface The UFC interface is defined by a single header file ufc h which defines the central interface class ufc form and a small set of auxiliary interface classes In addition a pair of data structures ufc mesh and ufc cell are defined and used for passing data to the interface functions All functions defined by the UFC interface are pure virtual meaning that all these functions must be overloaded in each implementation of the classes All but two functions initmesh and init_cell are const meaning that calling these const functions will leave the UFC objects unchanged Input argument pointers are always const while output arguments pointers are always non const The interface is presented below in the same order as it is defined in the header file ufc h Thus the interface is presented bottom up starting with the definition of basic data structures and ending with the definition of the main ufc form interface class 3 2 Cell shapes enum shape interval triangle quadrilateral tetrahedron hexahedron This enumeration includes all cell shapes that are covered by the UFC spec ification see Chapter 4 26 UFC Specification and User Manual 1 1 3 3 The class ufc mesh The class ufc mesh defines a data structure containing basic information about an unstructured mesh It is used for passing a minimal amount of information about th
75. l is v1 v2 not v2 v1 Similarly the first face fo of a tetrahedral cell is incident to vertices v V2 U3 66 UFC Specification and User Manual 1 1 U3 o VO Ui Figure 5 4 Mesh entities are ordered based on a lexicographical ordering of the corresponding ordered tuples of non incident vertices The first edge e is non incident to vertices vg and v1 For simplicial cells the relative ordering in combination with the convention of numbering the vertices locally based on global vertex indices means that two incident cells will always agree on the orientation of incident subsimplices Thus two incident triangles will agree on the orientation of the common edge and two incident tetrahedra will agree on the orientation of the common edge s and the orientation of the common face if any This is illustrated in Figure 5 5 for two incident triangles sharing a common edge 5 3 2 Limitations The UFC specification is only concerned with the ordering of mesh entities with respect to entities of larger topological dimension In other words the UFC specification is only concerned with the ordering of incidence relations of the class d d where d gt d For example the UFC specification is not concerned with the ordering of incidence relations of the class 0 1 that is the ordering of edges incident to vertices 67 UFC Specification and User Manual 1 1 Figure 5 5 Two incident triangles will always a
76. le basisvalue1 const double basisvalue2 psitilde_a_0 scalings_y_0 psitilde_bs_0_1 Table s const static double coefficients0 3 3 0 471404520791032 0 288675134594813 0 166666666666667 0 471404520791032 0 288675134594813 0 166666666666667 0 471404520791032 0 0 333333333333333 Extract const double coeff0_0 coefficients0 dof 0 const double coeff0_1 coefficients0 dof 1 const double coeff0_2 coefficients0 dof 2 Compute values coeff0_0 basisvalueO coeff0_1 basisvalue1 coeff0_2 basisvalue2 Evaluate virtual void throw std Evaluate virtual void psitilde_a basisvalues 0 707106781186548 psitilde_a_O scalings_y_0 psitilde_bs_0_0 1 73205080756888 psitilde_a_i scalings_y_1 psitilde_bs_1_0 of coefficients relevant coefficients value s all basis functions at given point in cell evaluate_basis_all double values const double coordinates const ufc cell amp c const runtime_error The vectorised version of evaluate_basis is not yet implemented order n derivatives of basis function i at given point in cell evaluate_basis_derivatives unsigned int i unsigned int n double values const double coordinates 99 UFC Specification and User Manual 1 1 const ufc cell amp c const Extract vertex coordinates const double const element_coordinates c coordinates Compute Jacobian of affine map from r
77. lid cell shapes enum shape interval triangle quadrilateral tetrahedron hexahedron This class defines the data structure for a finite element mesh class mesh public Constructor 79 UFC Specification and User Manual 1 1 mesh topological_dimension 0 geometric_dimension 0 num_entities 0 Destructor virtual mesh Topological dimension of the mesh unsigned int topological_dimension Geometric dimension of the mesh unsigned int geometric_dimension Array of the global number of entities of each topological dimension unsigned int num_entities Fs This class defines the data structure for a cell in a mesh class cell public Constructor cell cell_shape interval topological_dimension 0 geometric_dimension 0 entity_indices 0 coordinates 0 index 0 local_facet 1 mesh_identifier 1 Destructor virtual cell Shape of the cell shape cell_shape Topological dimension of the mesh unsigned int topological_dimension Geometric dimension of the mesh unsigned int geometric_dimension Array of global indices for the mesh entities of the cell unsigned int entity_indices Array of coordinates for the vertices of the cell double coordinates Cell index short cut for entity_indices topological_dimension 0 unsigned int index Local facet index int local_facet Unique mesh i
78. mension Return the dimension of the local finite element function space virtual unsigned int local_dimension const return 3 Return the geometric dimension of the coordinates this dof map provides virtual unsigned int geometric_dimension const return 2 Return the number of dofs on each cell facet virtual unsigned int num_facet_dofs const return 2 Return the number of dofs associated with each cell entity of dimension d virtual unsigned int num_entity_dofs unsigned int d const throw std runtime_error Not implemented introduced in UFC v1 1 Tabulate the local to global mapping of dofs on a cell virtual void tabulate_dofs unsigned int dofs const ufc mesh amp m const ufc cell amp c const dofs 0 c entity_indices 0 0 dofs 1 c entity_indices 0 1 dofs 2 c entity_indices 0 2 Tabulate the local to local mapping from facet dofs to cell dofs virtual void tabulate_facet_dofs unsigned int dofs unsigned int facet const switch facet 106 UFC Specification and User Manual 1 1 case 0 dofs 0 1 dofs 1 2 break case 1 dofs 0 0 dofs 1 2 break case 2 dofs 0 0 dofs 1 1 break Tabulate the local to local mapping of dofs on entity d i virtual void tabulate_entity_dofs unsigned int dofs unsigned int d unsigned int i const throw std runtime_error Not implemen
79. mp c 0 38 UFC Specification and User Manual 1 1 This function maps a given coordinate x on a given ufc cell to a coordinate xhat on the reference cell 3 6 17 The function num_sub_elements virtual unsigned int num_sub_elements const 0 This function returns the number of subelements for a nested mixed ele ment For simple elements non nested this function should return one A nested element is an element that is defined from a set of elements by taking the direct sum tensor product of the polynomial spaces of those elements For example the basis functions 1 We Wm of a vector valued Lagrange element may be constructed from a scalar Lagrange element by repeating the basis functions 1 2 n of the scalar element and padding with 0 ds y Q 0 Yp Q2 0 Un dn 0 Vn41 0 1 ny2 0 d2 oa Finite elements may be nested at arbitrary depth For example a mixed Taylor Hood element may be created by combining a vector valued quadratic Lagrange finite element with a scalar linear Lagrange finite element and the vector valued element may in turn be created by combining a set of scalar quadratic Lagrange elements 3 6 18 The function create_sub_element virtual finite_element create_sub_element unsigned int i const 0 This factory function constructs a ufc finite_element object for subele ment i The argument i must be an integer between ze
80. mplementation combined cell_integral_ header implementation combined exterior_facet_integral_ header implementation combined interior_facet_integral_f header implementation combined form_ header implementation combined We demonstrate below how to use the format string form_combined together with a dictionary that specifies the code to be inserted into the format string Typically a form compiler will first generate the code to be inserted into the dictionary and then in a later stage write the generated code to file in UFC format using the provided format strings 131 UFC Specification and User Manual 1 1 from ufc import form_combined code code classname Poisson code rank return 2 code num_coefficients return 0 code num_cell_domains return 1 print form_combined code 132 Appendix E Installation The UFC package consists of two parts the main part being a single header file called ufc h In addition a set of Python utilities to simplify the gener ation of UFC code is provided Questions bug reports and patches concerning the installation should be directed to the UFC mailing list at the address fenics lists launchpad net E 1 Installing UFC To install UFC simply run scons sudo scons install This installs the header file ufc h and a small set of Python utilities tem plates for generating UFC code Files
81. n tities 2 should contain the number of faces and num_entities 3 should contain the number of volumes If d is the topological dimension of the mesh num_entities d should contain the number of cells or elements 3 4 The class ufc cell The class ufc cell defines the data structure for a cell in a mesh Its intended use is not as a building block in a mesh data structure but merely as a view of specific data for a single cell It is used to pass cell data to UFC functions with a minimal amount of assumptions on how the computational mesh is represented and stored 3 4 1 The enum variable cell shape shape cell_shape The variable cell_shape should be set to the corresponding ufc shape for the cell 3 4 2 The integer topological_dimension unsigned int topological_dimension 28 UFC Specification and User Manual 1 1 The integer topological_dimension should be set to the topological dimen sion of the cell see ufc mesh above 3 4 3 The integer geometric_dimension unsigned int geometric_dimension The integer geometric_dimension should be set to the geometric dimension of the cell see ufc mesh above 3 4 4 The array entity_indices unsigned int entity_indices The array entity_indices should contain the global indices for all entities of the cell see Chapter 4 The length of the array entity_indices should be equal to the value of the variable topologic
82. ned int d const switch d case 0 return true break case 1 return false break case 2 return false break return false Initialize dof map for mesh return true iff init_cell is needed virtual bool init_mesh const ufc mesh amp m __global_dimension m num_entities 0 return false Initialize dof map for given cell virtual void init_cell const ufc mesh amp m const ufc cell amp c Do nothing Finish initialization of dof map for cells virtual void init_cell_finalize Do nothing 108 UFC Specification and User Manual 1 1 Return the dimension of the global finite element function space virtual unsigned int global_dimension const return __global_dimension Return the dimension of the local finite element function space virtual unsigned int local_dimension const return 3 Return the geometric dimension of the coordinates this dof map provides virtual unsigned int geometric_dimension const return 2 Return the number of dofs on each cell facet virtual unsigned int num_facet_dofs const return 2 Return the number of dofs associated with each cell entity of dimension d virtual unsigned int num_entity_dofs unsigned int d const throw std runtime_error Not implemented introduced in UFC vi 1 Tabulate the local to global mapping of dofs on a cell virtual void tabulate
83. ness_form__Lagrange_1_2D_H include lt stdexcept gt include lt math h gt include lt ufc h gt include lt pycc Functions Ptv h gt include lt pycc Functions Ptv_tools h gt include lt pycc Functions Dof_Ptv h gt include lt pycc Functions OrderedPtvSet h gt include lt pycc Functions Dof_OrderedPtvSet h gt include dof_map_Lagrange_1_2D h include fe_Lagrange_1_2D h namespace pycc This class defines the interface for the assembly of the global tensor corresponding to a form with r n arguments that is a mapping a VixV2x Vr x Wi x W2 x x Wn gt R with arguments vi v2 vr w1 w2 wn The rank r global tensor A is defined by fff A alVi V2 ca Very why W2 a03 WOJ where each argument Vj represents the application to the sequence of basis functions of Vj and wl w2 wn are given fixed functions coefficients class form__stiffness_form__Lagrange_1_2D public ufc form 125 UFC Specification and User Manual 1 1 public Constructor form__stiffness_form__Lagrange_1_2D Destructor virtual form__stiffness_form__Lagrange_1_2D Return a string identifying the form virtual const char signature const Return the rank of the global tensor r virtual unsigned int rank const Return the number of coefficients n virtual unsigned int num_coefficients const
84. ns are virtual but not pure virtual F 3 Version 1 2 The following functions have been modified e ufc dof_map local_dimension The following functions have been added to the interface e ufc dof map max_local_dimension F 4 Version 1 4 The behavior of the functions ufc form create_cell_integral ufc form create_exte and ufc form create_interior facet_integral were changed to return a zero pointer when there is no integral on the given domain F 5 Version 2 0 The following names have been changed e ufc dofmap ufc dofmap 136 UFC Specification and User Manual 1 1 e ufc form num_cell_integrals ufc form num_cell_domains e ufc form num_exterior_facet_integrals ufc form num_exterior_facet_domains e ufc form num_interior_facet_integrals ufc form num_interior_facet_domains The following new data members have been added e ufc cell index e ufc cell local_facet e ufc cell mesh_identifier The following new functions have been added e ufc finite_ element topological dimension e ufc finite_element geometric_dimension e ufc finite_element create e ufc dofmap topological dimension e ufc dofmap create e ufc cell_integral tabulate_tensor quadrature version e ufc exterior_facet_integral tabulate_tensor quadrature ver sion e ufc interior_integral tabulate_tensor quadrature version 137 Appendix G License T
85. nt as a collection of e a polygon K e a polynomial space Px on K e a set of linearly independent linear functionals the degrees of freedom L i Pg gt Rot R E ce 15 UFC Specification and User Manual 1 1 2 1 2 Variational Forms Consider the weighted Poisson problem V wVu f with Dirichlet boundary conditions on a domain Q C R Multiplying by a test function v V and integrating by parts one obtains the variational problem wve Vudzr f vufdx W E Vh 2 1 Q Q for u Vp If w f Wp for some discrete finite element space W which may be different from V we may thus write 2 1 as alv u w Lv f Vue Va 2 2 where the trilinear form a V x Vp x Wp gt R is given by a v u w 1 wVv Vudgz 2 3 Q and the bilinear form L V x Wp gt R is given by Lof por dz 2 4 Note here that a is bilinear for any given fixed w W and L is linear for any given fixed f Wh In general we shall be concerned with the discretization of finite element variational forms of general arity r n gt 0 a Vix Vx xV x Wi xW x xW OR 2 5 defined on the product space V x V x x Vi x W x W x x Wp of two sets V _1 W 7_ of discrete finite element function spaces on Q j l We refer to v1 V2 Ur E V x VZ x x Vf as primary arguments and to wi W2 Wn E Wi x W x x W as coefficients and write OSG Oi 54 Ur
86. nteger index aoaaa ae tok a eR es 30 3 4 7 The integer local facet 2 4 aaou eo ee 30 3 4 8 The integer mesh identifier 30 Theclass ufe T unction s er mo oe SEK EES OS Sas 31 3 5 1 The function evaluate o ss ecew ene se was 31 The class ufc finite_element oaaao aaa aa 32 3 6 1 The function signature 26 446 Sed aa 32 3 6 2 The function cell shape aooaa aa 32 3 6 3 The function topological dimension 32 3 6 4 The function geometric_dimension 33 3 6 5 The function space dimension 33 3 7 3 6 6 The function value rank 2 44 664 54 oe b h 33 3 6 7 The function value dimension 34 3 6 8 The function evaluate basis 34 3 6 9 The function evaluate basis all 35 3 6 10 The function evaluate_basis_derivatives 30 3 6 11 The function evaluate_basis_derivatives_all 36 3 6 12 The function evaluate dof 37 3 6 13 The function evaluate dofs 2 2 244 885 37 3 6 14 The function interpolate_vertex_values 38 3 6 15 The function map from_reference cell 38 3 6 16 The function map_to_reference_cell 38 3 6 17 The function num_sub_elements 39 3 6 18 The function create subelement 39 o b 10 The function create s s dace es de eGedeeas 40 The clase ufe rdofmap e so ri o sore oiean SAS ee e a 40 Sol The function Signature ca cocs cacra eadi eta 40 3 7 2 The function
87. nts that is a mapping a VixV2x Vr x Wi x W2x x Wn gt R with arguments v1 v2 vr w1 w2 wn The rank r global tensor A is defined by fff A a V1 V2 Vr wl w2 wn where each argument Vj represents the application to the sequence of basis functions of Vj and w1 w2 wn are given fixed functions coefficients class form public Constructor form Destructor virtual form Return a string identifying the form virtual const char signature const 0 Return the rank of the global tensor r virtual unsigned int rank const 0 Return the number of coefficients n virtual unsigned int num_coefficients const 0 Return the number of cell domains virtual unsigned int num_cell_domains const 0 Return the number of exterior facet domains virtual unsigned int num_exterior_facet_domains const 0 Return the number of interior facet domains virtual unsigned int num_interior_facet_domains const 0 Create a new finite element for argument function i virtual finite_element create_finite_element unsigned int i const 0 Create a new dofmap for argument function i virtual dofmap create_dofmap unsigned int i const 0 Create a new cell integral on sub domain i virtual cell_integral create_cell_integral unsigned int i const 0 Create a new exteri
88. num_cell_domains i cell_integrals i form create_cell_integral i Create dofmaps ufc dofmaps dofmaps dofmaps new ufc dofmap form rank form num_coefficients for unsigned int i 0 i lt form rank form num_coefficients i dofmaps i form create_dofmap i Initialize dofmap if dofmaps i gt init_mesh mesh Iterate over cells for Coua Update cell data structure to current cell cell entity_indices cell coordinates Initialize dofmap for cell dofmaps i gt init_cell mesh cell dofmap init_cell_finalize Initialize array of values for the cell tensor unsigned int size 1 for unsigned int i 0 i lt form rank i size dofmaps i gt max_local_dimension double AK new double size Initialize array of local to global dofmaps unsigned int dofs new unsigned int form rank for unsigned int i 0 i lt form rank i dofs i new unsigned int dofmaps i gt max_local_dimension Initialize array of coefficient values double w new double form num_coefficients for unsigned int i 0 i lt form num_coefficients i w i new double dofmaps form rank i gt max_local_dimension Iterate over cells for eec Get number of subdomain for current cell const unsigned int sub_domain Update cell data structure to current cell cell entity_indices cell
89. o and the number of sub dofmaps 46 UFC Specification and User Manual 1 1 num_sub_dofmaps minus one If the dofmap is simple non nested this function returns a zero pointer The caller is responsible for deleting the returned object Note that in earlier versions of UFC this function returned a copy of the dofmap itself in the case of a simple element To create a copy of the element use the create function instead 3 7 19 The function create Introduced in UFC version 2 0 virtual dofmap create const 0 This factory function creates a new instance of the generated ufc dofmap subclass 3 8 The integral classes As described in Section 2 and in particular Equation 2 15 the global sparse tensor the stiffness matrix representing a given form differential oper ator may be assembled by summing the contributions from the local cells exterior facets and interior facets of the mesh These contributions are represented in the UFC interface by the classes cell_integral exterior_facet_integral and interior_facet_integral Each of these three integral classes has a single function tabulate_tensor which may be called to compute the corresponding local contribution cell tensor exterior facet tensor or interior facet tensor 47 UFC Specification and User Manual 1 1 3 9 The class ufc cell_integral The class ufc cell_integral represents the integral of a form over a local cell in a finite
90. oc2glob Return a string identifying the dof map const char dof_map_Lagrange_1_2D signature const return dof_map_Lagrange_1_2D generated by SyFi Return true iff mesh entities of topological dimension d are needed bool dof_map_Lagrange_1_2D needs_mesh_entities unsigned int d const switch d case 0 return true vertices case 1 return true edges case 2 return true faces case 3 return false volumes return false strange unsupported case or error Initialize dof map for mesh return true iff init_cell is needed bool dof_map_Lagrange_1_2D init_mesh const ufc mesh amp m int top_dim 2 num_elements m num_entities top_dim return true Initialize dof map for given cell void dof_map_Lagrange_1_2D init_cell const ufc mesh amp m const ufc cell amp c coordinates double x0 c coordinates 0 0 double yO c coordinates 0 1 double x1 c coordinates 1 0 double y1 c coordinates 1 1 122 UFC Specification and User Manual 1 1 double x2 c coordinates 2 0 double y2 c coordinates 2 1 affine map double GOO xi x0 double G01 x2 x0 double G10 double G11 yl y0 y2 y0 int element c entity_indices 2 0 double dof0 2 x0 yO Ptv pdof0 2 dof0 dof insert_dof element 0 pdof0 double dof1 2 GOO x0 y0 G10 Ptv pdof1i 2 dof1 dof insert_dof elem
91. onst double const element_coordinates c coordinates Compute Jacobian of affine map from reference cell const double J_00 element_coordinates 1 0 element_coordinates 0 0 const double J_01 element_coordinates 2 0 element_coordinates 0 0 const double J_10 element_coordinates 1 1 element_coordinates 0 1 const double J_11 element_coordinates 2 1 element_coordinates 0 1 Compute determinant of Jacobian const double detJ J_00 J_11 J_01 J_10 Compute inverse of Jacobian Get coordinates and map to the reference UFC element double x element_coordinates 0 1 element_coordinates 2 0 element_coordinates 0 0 element_coordinates 2 1 J_11 coordinates 0 J_01 coordinates i detJ double y element_coordinates 1 1 element_coordinates 0 0 element_coordinates 1 0 element_coordinates 0 1 92 UFC Specification and User Manual 1 1 J_10 coordinates 0 J_00 coordinates 1i detJ Map coordinates to the reference square if std abs y 1 0 lt 1e 14 x 1 0 else x 2 0 x 1 0 y 1 0 y 2 0 y 1 0 Compute number of derivatives unsigned int num_derivatives 1 for unsigned int j 0 j lt n j num_derivatives 2 Declare pointer to two dimensional array that holds combinations of derivatives and unsigned int combinations new unsigned int num_derivatives for unsigned int
92. oordinates const double const element_coordinates c coordinates Compute Jacobian of affine map from reference cell const double J_00 element_coordinates 1 0 element_coordinates 0 0 const double J_01 element_coordinates 2 0 element_coordinates 0 0 const double J_10 element_coordinates 1 1 element_coordinates 0 1 const double J_11 element_coordinates 2 1 element_coordinates 0 1 Compute determinant of Jacobian const double detJ J_00 J_11 J_01 J_10 Compute inverse of Jacobian Get coordinates and map to the reference UFC element double x element_coordinates 0 1 element_coordinates 2 0 element_coordinates 0 0 element_coordinates 2 1 J_11 coordinates 0 J_01 coordinates 1i detJ double y element_coordinates 1 1 element_coordinates 0 0 element_coordinates 1 0 element_coordinates 0 1 J_10 coordinates 0 J_00 coordinates 1i detJ Map coordinates to the reference square if std abs y 1 0 lt 1e 14 x 1 0 else x 2 0 x 1 0 y 1 0 y 2 0 y 1 0 Reset values values 0 Map degree of freedom to element degree of freedom const unsigned int dof i Generate scalings const double scalings_y_0 1 const double scalings_y_1 scalings_y_0 0 5 0 5 y Compute psitilde_a const double psitilde_a_O 1 const double psitilde_a_1i x Compute psitilde_bs const double psit
93. or facet integral on sub domain i virtual exterior_facet_integral create_exterior_facet_integral unsigned int i const 0 Create a new interior facet integral on sub domain i virtual interior_facet_integral 82 UFC Specification and User Manual 1 1 create_interior_facet_integral unsigned int i const 0 33 T endif 83 Appendix B A basic UFC based assembler Below we include a sketch of a UFC based implementation of the assembly of the global tensor A by summing the local contributions from all cells The contributions from all exterior and interior facets may be computed similarly The implementation is incomplete and system specific details such as inter action with mesh and linear algebra libraries have been omitted void assemble ufc formk form Initialize mesh data structure ufc mesh mesh mesh num_entities new unsigned int Initialize cell data structure ufc cell cell cell entity_indices new unsigned int cell coordinates new double Create cell integrals ufc cell_integral cell_integrals cell_integrals new ufc cell_integral form num_cell_domains lFor an example of a complete implementation of a UFC based assembler we refer to the source code of DOLFIN 8 in particular class Assembler as implemented in Assembler cpp 85 UFC Specification and User Manual 1 1 for unsigned int i 0 i lt form
94. ouble quadrature_weights const 0 This function is identical to tabulate_tensor described above but computes the integral over the cell using the given set of quadrature points and weights Note that the quadrature points should be specified on the reference cell By a careful choice of quadrature points this function can be used to integrate over subsets of cells 3 10 The class ufc exterior facet integral The class ufc exterior facet_integral represents the integral of a form over a local exterior facet boundary facet in a finite element mesh It has a single function tabulate_tensor which may be called to tabulate the values of the exterior facet tensor for a given facet 3 10 1 The function tabulate tensor virtual void tabulate_tensor double A const double const w const cell amp c unsigned int facet const 0 The arrays A and w have the same function and should have the same sizes as described in the documentation for cell_integral tabulate_tensor Thus the values of the exterior facet integral will be tabulated into the array A and the nodal basis expansions of all coefficients should be provided in the array w 49 UFC Specification and User Manual 1 1 The additional argument facet should specify the local number of the facet with respect to its single incident cell Thus when the facet is an edge of a triangle the argument facet should be an integer between zero and two 0 1 2
95. rm assembly Code is a unified framework for finite element assembly More precisely it defines a fixed interface for communicating low level routines functions for evaluating and assembling finite element varia tional forms The UFC interface consists of a single header file ufc h that specifies a C interface that must be implemented by code that complies with the UFC specification Both FFC since version 0 4 0 and SyFi since version 0 3 4 generate code that complies with the UFC specification Thus code generated by FFC and SyFi may be used interchangeably by any UFC based finite element assembler such as DOLFIN 8 1 2 Aim and scope The UFC interface has been designed to make a minimal amount of assump tions on the form compilers generating the UFC code and the assemblers built on top of the UFC specification Thus the UFC specification provides a min imal amount of abstractions and data structures Programmers wishing to implement the UFC specification will typically want to create system specific but simple wrappers for the generated code Few assumptions have also been made on the underlying finite element methodology The current specification is limited to affinely mapped cells but does not restrict the mapping of finite element function spaces Thus UFC code may be generated for elements where basis functions are trans formed from the reference cell by the affine mapping as well as for elements where the basis funct
96. ro and the number of subelements num_sub_elements minus one If the element is simple non nested this function returns a zero pointer The caller is responsible for deleting the returned object 39 UFC Specification and User Manual 1 1 Note that in earlier versions of UFC this function returned a copy of the element itself in the case of a simple element To create a copy of the element use the create function instead 3 6 19 The function create Introduced in UFC version 2 0 virtual finite_element create const 0 This factory function creates a new instance of the generated ufc finite_ element subclass 3 7 The class ufc dofmap This class represents the local to global mapping of degrees of freedom dofs or rather one particular instance of such a mapping there are many possible local to global mappings as defined in Equation 2 18 The most central function of this class is tabulate_dofs which tabulates the local to global mapping from the degree of freedom indices on a local cell to a global vector of degree of freedom indices 3 7 1 The function signature virtual const char signature const 0 This function returns a signature string that uniquely identifies the dofmap This can be used to compare whether or not two given ufc dofmap objects are identical This may be used to optimize the assembly of forms by caching previously computed dofmaps 40 UFC Specifica
97. s function will tabulate a set of points on the given cell such that the dofs of the finite element are given by evaluation at those points For elements that do not have a direct relationship between coordinates and dofs an attempt should be made at a sensible implementation of this func tion For example if a dof is defined as the integral over a facet the midpoint of the facet can be used If no other choice makes sense the midpoint of the cell can be used as a last resort This function must thus be used with care if non Lagrangian elements are used The size of the output array coordinates should be equal to the value returned by local_dimension and the size of each subarray coordi nates 0 coordinates 1 etc should be equal to the geometric dimension of the mesh which can be obtained with the function dofmap geometric_ dimension 3 7 17 The function num_sub_dofmaps virtual unsigned int num_sub_dofmaps const 0 This function returns the number of sub dofmaps for a nested mixed ele ment For a discussion on the subelement concept see the documentation of the function ufc finite element num_sub_elements For simple ele ments non nested this function should return one 3 7 18 The function create sub dofmap virtual dofmap create_sub_dofmap unsigned int i const 0 This factory function constructs a ufc dofmap object for subelement i The argument i must be a number between zer
98. s must be a number between zero and the value rank minus one Note that the total size number of values of the value space is obtained as the product of value_dimension i for 0 lt i lt value_rank For a mixed element with value rank 1 Since the value rank of a mixed element must be 1 if any of the subelements have different value ranks value_dimension 0 is then the total value size of all the subelements 3 6 8 The function evaluate_basis virtual void evaluate_basis unsigned int i double values const double coordinates const cell amp c const 0 This function evaluates basis function i at the given coordinates within the given cell c and stores the values in the array values The size of the 34 UFC Specification and User Manual 1 1 output array should be equal to size of the value space see value_dimension above The point defined by coordinates should be located inside the cell c If the point is located outside the cell then the result is undefined 3 6 9 The function evaluate_basis_all Introduced in UFC version 1 1 virtual void evaluate_basis_all double values const double coordinates const cell amp c const 0 As evaluate_basis but evaluates all basis functions at once which can be implemented much more effectively than multiple calls to evaluate_basis The size of the output array should be equal to size of the value space times the number of basis functions Th
99. se 2 dofs 0 0 dofs i 1 break default throw std runtime_error Invalid facet number Tabulate the coordinates of all dofs on a cell void dof_map_Lagrange_1_2D tabulate_coordinates double coordinates const ufc cell amp c const coordinates double x0 c coordinates 0 0 double yO c coordinates 0 1 double x1 c coordinates 1 0 double y1 c coordinates 1 1 double x2 c coordinates 2 0 double y2 c coordinates 2 1 affine map double GOO x1 x0 double GO1 x2 x0 double G10 y1 y0 double G11 y2 y0 coordinates 0 0 x0 coordinates 0 1 y0 coordinates i 0 G00 x0 coordinates 1 1 y0 G10 coordinates 2 0 x0 G01 coordinates 2 1 G11 y0 Return the number of sub dof maps for a mixed element unsigned int dof_map_Lagrange_1_2D num_sub_dof_maps const return 1 Create a new dof_map for sub dof map i for a mixed element ufc dof_map dof_map_Lagrange_1_2D create_sub_dof_map unsigned int i const 124 UFC Specification and User Manual 1 1 return new dof_map_Lagrange_1_2D namespace C 2 5 Header file for the stiffness matrix form This code complies with UFC version 1 0 and is generated with SyFi version 0 4 0 http www fenics org syfi http www fenics org ufc ifndef __form__stiffness_form__Lagrange_1_2D_H define __form__stiff
100. ser Manual 1 1 Destructor form__stiffness_form__Lagrange_1_2D form__stiffness_form__Lagrange_1_2D Return a string identifying the form const char form__stiffness_form__Lagrange_1_2D signature const return form__stiffness_form__Lagrange_1_2D generated by SyFi Return the rank of the global tensor r unsigned int form__stiffness_form__Lagrange_1_2D rank const return 2 Return the number of coefficients n unsigned int form__stiffness_form__Lagrange_1_2D num_coefficients const return 0 Return the number of cell integrals unsigned int form__stiffness_form__Lagrange_1_2D num_cell_integrals const return 1 Return the number of exterior facet integrals unsigned int form__stiffness_form__Lagrange_1_2D num_exterior_facet_integrals const return 0 Return the number of interior facet integrals unsigned int form__stiffness_form__Lagrange_1_2D num_interior_facet_integrals const return 0 Create a new finite element for argument function i ufc finite_element form__stiffness_form__Lagrange_1_2D create_finite_element unsigned int i const switch i case 0 return new fe_Lagrange_1_2D case 1 return new fe_Lagrange_1_2D throw std runtime_error Invalid index in create_finite_element Create a new dof map for argument function i 129 UFC Specification and User Manual 1 1
101. t public Constructor fe_Lagrange_1_2D 115 UFC Specification and User Manual 1 1 Destructor virtual fe_Lagrange_1_2D Return a string identifying the finite element virtual const char signature const Return the cell shape virtual ufc shape cell_shape const Return the dimension of the finite element function space virtual unsigned int space_dimension const Return the rank of the value space virtual unsigned int value_rank const Return the dimension of the value space for axis i virtual unsigned int value_dimension unsigned int i const Evaluate basis function i at given point in cell virtual void evaluate_basis unsigned int i double values const double coordinates const ufc cell amp c const Evaluate order n derivatives of basis function i at given point in cell virtual void evaluate_basis_derivatives unsigned int i unsigned int n double values const double coordinates const ufc cell amp c const Evaluate linear functional for dof i on the function f virtual double evaluate_dof unsigned int i const ufc function amp f const ufc cell amp c const Interpolate vertex values from dof values virtual void interpolate_vertex_values double vertex_values const double dof_values const ufc cell amp c const Return the number of sub elements for a mixed element virtual unsigned int num_sub_elements
102. te_facet_dofs virtual void tabulate_facet_dofs unsigned int dofs 44 UFC Specification and User Manual 1 1 unsigned int facet const 0 This function tabulates the local dof indices associated with a given local facet including all dofs associated with mesh entities of lower dimension incident with the facet The size of the output array dofs should equal the value returned by num facet_dofs 3 7 15 The function tabulate entity dofs Introduced in UFC version 1 1 virtual void tabulate_entity_dofs unsigned int dofs unsigned int d unsigned int i const 0 This function tabulates the local dof indices associated with a given local mesh entity i of dimension d i e mesh entity d i not including dofs associ ated with incident entities of lower dimension unlike tabulate _facet_dofs The size of the output array dofs should equal the value returned by the function num_entity_dofs d As an example calling tabulate_entity_dofs for a face d 2 should yield only the dofs associated with the face that are not associated with vertices and edges Thus tabulate_entity_dofs can be used to build connectivity information 3 7 16 The function tabulate_coordinates virtual void tabulate_coordinates double coordinates const cell amp c const 0 45 UFC Specification and User Manual 1 1 This function tabulates the coordinates for each dof on the given cell For Lagrange elements thi
103. ted introduced in UFC vi 1 Tabulate the coordinates of all dofs on a cell virtual void tabulate_coordinates double coordinates const ufc cell amp c const const double const x c coordinates coordinates 0 0 x 0 0 coordinates 0 1 x 0 1 coordinates 1 0 x 1 0 coordinates 1 1 x 1 4 coordinates 2 0 x 2 0 coordinates 2 1 x 2 1 Return the number of sub dof maps for a mixed element virtual unsigned int num_sub_dof_maps const return 1 Create a new dof_map for sub dof map i for a mixed element virtual ufc dof_map create_sub_dof_map unsigned int i const return new PoissonBilinearForm_dof_map_0 3 This class defines the interface for a local to global mapping of degrees of freedom dofs class PoissonBilinearForm_dof_map_1 public ufc dof_map private unsigned int __global_dimension 107 UFC Specification and User Manual 1 1 public Constructor PoissonBilinearForm_dof_map_1 ufc dof_map __global_dimension 0 Destructor virtual PoissonBilinearForm_dof_map_1 Do nothing F Return a string identifying the dof map virtual const char signature const return FFC dof map for FiniteElement Lagrange triangle 1 Return true iff mesh entities of topological dimension d are needed virtual bool needs_mesh_entities unsig
104. tion and User Manual 1 1 3 7 2 The function needs_mesh_entities virtual bool needs_mesh_entities unsigned int d const 0 This function returns true if the ufc dofmap requires mesh entities of topo logical dimension d to be available in ufc cell arguments Thus if this function returns false for a given value of d then the array entity_indices d of the ufc cell data structure will not be used during calls to ufc dofmap functions In those cases the array entity_indices d may be set to zero This may be used to check which entities must be generated to tabulate the local to global mapping For example linear Lagrange elements will only need to know the vertices of each cell in the mesh while quadratic Lagrange elements will also need to know the edges of each cell in the mesh 3 7 3 The function init mesh virtual bool init_mesh const mesh amp mesh 0 This function initializes the dofmap for a given mesh If it returns true calls to init_cell and init_cell_finalize are required to complete the initialization The function global_dimension be may only be called when the initialization is complete 3 7 4 The function init_cell virtual void init_cell const mesh amp m const cell amp c 0 For ufc dofmap objects where init_mesh returns true this function must be called for each cell in the mesh to initialize the dofmap 41 UFC Specification and User Manual 1 1 3 7 5
105. turn new PoissonBilinearForm_finite_element_0 F This class defines the interface for a finite element class PoissonBilinearForm_finite_element_1 public ufc finite_element public Constructor PoissonBilinearForm_finite_element_1 ufc finite_element Do nothing Destructor virtual PoissonBilinearForm_finite_element_1 Do nothing Return a string identifying the finite element virtual const char signature const 97 UFC Specification and User Manual 1 1 return FiniteElement Lagrange triangle 1 Return the cell shape virtual ufc shape cell_shape const return ufc triangle Return the dimension of the finite element function space virtual unsigned int space_dimension const return 3 Return the rank of the value space virtual unsigned int value_rank const return 0 Return the dimension of the value space for axis i virtual unsigned int value_dimension unsigned int i const return 1 Evaluate basis function i at given point in cell virtual void evaluate_basis unsigned int i double values const double coordinates const ufc cell amp c const Extract vertex coordinates const double const element_coordinates c coordinates Compute Jacobian of affine map from reference cell const double J_00 element_coordinates 1 0 element_coordinates 0 0
106. unction tabulate tensor 3 11 2 The function tabulate_tensor quadrature version The class nfet form oos cb ee RS ee be SS oe ES 3 12 1 The function signature c 265 ew eb ae ee eS 312 2 The function rank o oe ee eS RR ESHER GS 3 12 3 The function num_coefficients 3 12 4 The function num_cell_domains 3 12 5 The function num_exterior_facet_domains 3 12 6 The function num_interior_facet_domains 3 12 7 The function create_finite_element 3 12 8 The function create_dofmap 3 12 9 The function create_cell_integral 3 12 10 The function create_exterior_facet_integral 3 12 11 The function create_interior_facet_integral 4 Reference cells 4 1 4 2 4 3 4 4 4 5 The reference interval 22 ia eee eee bee beded as The reference triangle o a aaa a The reference quadrilateral o oa a a a a a a The reference tetrahedron aoao a The reference hexahedron oaoa a a a a a a 52 52 53 53 53 54 54 54 54 59 59 59 56 57 5 Numbering of mesh entities 63 5 1 Basic concepts lt n bb asarria aa Eee EE 63 5 2 Numbering of vertices oaoa a a 64 5 3 Numbering of other mesh entities 64 5 3 1 Relative ordering aoaaa 66 oe TIONS s e r e Hs i ee ee We ee Mee 67 5 4 Numbering schemes for reference cells 68 5 4 1 Numbering of mesh entities on intervals
107. ures linear algebra and finite element assembly are examples of operations that are naturally coded in a problem independent way and made available in reusable libraries 7 3 15 4 1 5 However some parts of a finite element program are difficult to code in a problem independent way In particular this includes the evaluation of the element tensor the element stiffness ma trix that is the evaluation of the local contribution from a finite element to a global sparse tensor the stiffness matrix representing a discretized differential operator These parts must thus be implemented by the appli cation programmer for each specific combination of differential equation and discretization finite element spaces However domain specific compilers such as FFC 14 10 13 11 12 and SyFi 2 make it possible to automatically generate the code for the evaluation of the element tensor These form compilers accept as input a high level description of a finite element variational form and generate low level code code for efficient evaluation of the element tensor and associated quantities It thus becomes important to specify the interface between form compilers and finite element assemblers such that the code generated by FFC SyFi and other form compilers can be used to assemble finite element matrices and vectors and in general tensors 11 UFC Specification and User Manual 1 1 1 1 Unified Form assembly Code UFC Unified Fo
108. vative spatial di mensions Note that just as for evaluate_basis the point defined by coordinates should be located inside the cell c The result is otherwise undefined 3 6 11 The function evaluate_basis_derivatives_all Introduced in UFC version 1 1 virtual void evaluate_basis_derivatives_all unsigned int n double values const double coordinates const cell amp c const 0 As evaluate_basis_derivatives but evaluated for all basis functions at once which can be implemented much more effectively than multiple calls 36 UFC Specification and User Manual 1 1 to evaluate_basis_derivatives The size of the output array should be equal to the corresponding size defined for evaluate_basis_derivatives times the number of basis functions The computed values for a single basis function are placed contiguously in the array Note that just as for evaluate_basis the point defined by coordinates should be located inside the cell c The result is otherwise undefined 3 6 12 The function evaluate dof virtual double evaluate_dof unsigned int i const function amp f const cell amp c const 0 This function evaluates and returns the value of the degree of freedom i which is a linear functional on the given function f For example the degrees of freedom for Lagrange finite elements are given by evaluation of f at a set of points Other examples of degrees of freedom include weighted integrals ov
109. void tabulate_tensor double A const double const w const ufc cell amp c const Reset values of the element tensor block oO oo0oo0oo0000o0 Add all contributions to element tensor integral_0_quadrature tabulate_tensor A w c 3 This class defines the interface for the assembly of the global tensor corresponding to a form with r n arguments that is a mapping a Vi x V2x Vr x Wix W2x x Wn gt R with arguments vi v2 vr wl w2 wn The rank r 112 UFC Specification and User Manual 1 1 global tensor A is defined by A a V1 V2 Vr wi w2 wn where each argument Vj represents the application to the sequence of basis functions of Vj and w1 w2 wn are given fixed functions coefficients class PoissonBilinearForm public ufc form public Constructor PoissonBilinearForm ufc form Do nothing Destructor virtual PoissonBilinearForm Do nothing Return a string identifying the form virtual const char signature const return Form Integral IndexSum Product Indexed ComponentTensor SpatialDerivative Basis Return the rank of the global tensor r virtual unsigned int rank const return 2 Return the number of coefficients n virtual unsigned int num_coefficients const return 0 R
110. will be installed under the default prefix 133 UFC Specification and User Manual 1 1 The installation prefix may be optionally specified for example scons install prefix local Alternatively just copy the single header file src ufc ufc h into a suitable include directory If you do not want to build and install the python extenstion module of UFC needed by e g Py DOLFIN you can write sudo enablePyUFC No sudo cons install Help with available options and default arguments can be viewed by scons h 134 Appendix F UFC versions To keep things simple the UFC classes do not have any run time version control To upgrade to a new UFC version all libraries and applications must therefore be recompiled with the new header file ufc h F 1 Version 1 0 Initial release F 2 Version 1 1 The following six functions have been added to the interface e ufc finite_element evaluate_dofs e ufc finite_element evaluate_basis_all e ufc finite_element evaluate_basis_derivatives_all e ufc dof_map geometric_dimension 135 UFC Specification and User Manual 1 1 e ufc dof_map num_entity_dofs e ufc dof_map tabulate_entity_dofs An implementation of UFC version 1 0 can be recompiled with the header file from UFC version 1 1 without changes to the source code The new functions introduced in 1 1 will then simply throw an informative exception The new functio
111. ycc Functions Dof_Ptv h gt include lt pycc Functions OrderedPtvSet h gt include lt pycc Functions Dof_OrderedPtvSet h gt include dof_map_Lagrange_1_2D h include fe_Lagrange_1_2D h include form__stiffness_form__Lagrange_1_2D h namespace pycc This class defines the interface for the tabulation of the cell tensor corresponding to the local contribution to a form from the integral over a cell class cell_itg__stiffness_form__Lagrange_1_2D public ufc cell_integral public Constructor cell_itg__stiffness_form__Lagrange_1_2D Destructor virtual cell_itg__stiffness_form__Lagrange_1_2D Tabulate the tensor for the contribution from a local cell virtual void tabulate_tensor double A const double const w const ufc cell amp c const 3 Constructor cell_itg__stiffness_form__Lagrange_1_2D cell_itg__stiffness_form__Lagrange_1_2D ufc cell_integral F Destructor 127 UFC Specification and User Manual 1 1 cell_itg__stiffness_form__Lagrange_1_2D cell_itg__stiffness_form__Lagrange_1_2D Tabulate the tensor for the contribution from a local cell void cell_itg__stiffness_form__Lagrange_1_2D tabulate_tensor double A coordinates const double const w const ufc cell amp c const double x0 c coordinates 0 0 double yO c coordinates 0 1 double x1 c coordinates 1 0 double y1 double x2

Download Pdf Manuals

image

Related Search

Related Contents

Denon Ceol Cariono  Manual de Usuario - Kawai Musical Instruments Manufacturing Co  AURTTA2001 Identify basic automotive faults using troubleshooting  NetTool    Máquina Automática de Molas  Radstone PIO-2 Manual  Samsung WD0130XTK 用户手册  9.9FMH`08(63V7) 15FMH`08(63W7)  Series 8650A Universal Power Meters - Giga  

Copyright © All rights reserved.
Failed to retrieve file