Home
UFL Specification and User Manual 0.3
Contents
1. i D o a 2 39 Note the resemblance of v and v dx i If the expression to be differentiated w r t x has i as a free index implicit summation is implied Sum of derivatives w r t x_i for all i g Dx v i i 42 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg g vlil dx i Here g will represent the sum of derivatives w r t x for all i that is se I F Ox Uii Note the compact index notation v with implicit summation 2 9 2 Compound spatial derivatives UFL implements several common differential operators The notation is sim ple and their names should be self explaining Df grad f df div f cf curl v rf rot f The operand f can have no free indices 2 9 3 Gradient The gradient of a scalar u is defined as grad u Vu gt Ir 2 40 which is a vector of all spatial partial derivatives of u The gradient of a vector v is defined as Ov grad v Vv az iti 2 41 j 43 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg which written componentwise is A VV Ay Vij 2 42 In general for a tensor A of rank r the definition is A grad A VA z Aio res ipsi 8i De 2 OL Oh 2 43 where is a multiindex of length r In UFL the following pairs of declarations are equivalent Dfi grad f i Dfi f dx i Dvi Dvi grad v i j v i dx j DAi grad A
2. In the following this representation of an expression will be called the com putational graph To construct this graph from a UFL expression simply do G Graph expression V E G The Graph class can build some useful data structures for use in algorithms Vin G VinQ Vin i list of vertex indices j such that there is an ed Vout G Vout Vout i list of vertex indices j such that there is an ed Ein G Ein Ein i list of edge indices j such that E j is an edge Eout G Eout Eout i list of edge indices j such that E j is an edge 90 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg The ordering of the vertices in the graph can in principle be arbitrary but here they are ordered such that Ui lt Vj Y7 Sl 5 3 where a lt b means that a does not depend on b directly or indirectly Another property of the computational graph built by UFL is that no identi cal expression is assigned to more than one vertex This is achieved efficiently by inserting expressions in a dict a hash map during graph building In principle correct code can be generated for an expression from its com putational graph simply by iterating over the vertices and generating code for each one separately However we can do better than that 5 4 2 Partitioning the graph To help generate better code efficiently we can partition vertices by their de pendencies which allows us to
3. d 1 we can define the dot product of any two basis functions as iz iy by where 0 is the Kronecker delta 1 o Oi uo J 2 7 0 otherwise A rank 1 tensor vector quantity v can be represented in terms of unit vectors and its scalar components in that basis In tensor algebra it is common to 29 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg assume implicit summation over indices repeated twice in a product v Ugly Ugik 2 8 k Similarly a rank two tensor matrix quantity A can be represented in terms of unit matrices that is outer products of unit vectors i j This generalizes to tensors of arbitrary rank where C is a rank r tensor and is a multiindex of length r When writing equations on paper a mathematician can easily switch between the v and v representations without stating it explicitly This is possible because of flexible notation and conventions In a programming language we can t use the boldface notation which associates v and v by convention and we can t always interpret such conventions unambiguously Therefore UFL requires that an expression is explicitly mapped from its tensor representation v A to its component representation v A and back This is done using Index objects the indexing operator v i and the function as_tensor More details on these follow In the following descriptions of UFL operator syntax i l and p s are assumed to
4. hg clone http www fenics org hg ufl This version may contain features not yet present in the latest release but may also be less stable and even not work at all B 1 3 Installing UFL UFL follows the standard installation procedure for Python packages Enter the source directory of UFL and issue the following command python setup py install This will install the UFL Python package in a subdirectory called uf1 in the default location for user installed Python packages usually something like usr lib python2 5 site packages In addition the executable ufl analyse a Python script will be installed in the default directory for user installed Python scripts usually in usr bin To see a list of optional parameters to the installation script type python setup py install help If you don t have root access to the system you are using you can pass the home option to the installation script to install UFL in your home directory mkdir local python setup py install home local 99 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg This installs the UFL package in the directory local lib python and the UFL executables in local bin If you use this option make sure to set the environment variable PYTHONPATH to local lib python and to add local bin to the PATH environment variable B 1 4 Running the test suite To verify that the i
5. il DAi A dx i for a scalar expression f a vector expression v and a tensor expression A of arbitrary rank 2 9 4 Divergence The divergence of any nonscalar vector or tensor expression A is defined as the contraction of the partial derivative over the last axis of the expression TODO Detailed examples like for gradient In UFL the following declarations are equivalent dv dv div v vil dx i 44 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg dA dA div A AL 1 dx i for a vector expression v and a tensor expression A 2 9 5 Curl and rot The operator curl accepts as argument a vector valued expression and re turns its curl Ova Ov Ovo Ov Ov Ovo 0x1 Ox Ox Ox Lo 0x1 curl v curlv V x v 2 44 Note that this operator is only defined for vectors of length three 2 9 6 Variable derivatives UFL also supports differentiation with respect to user defined variables A user defined variable can be any expression that is defined as a variable The notation is illustrated here Define some arbitrary expression Function element w sin u 2 e Annotate expression w as a variable that can be used in diff w variable w This expression is a function of w F I diff u x 4TODO There are probably some things that don t make sense 45 UFL Specification and User Manual 0 3 Martin S Aln s Anders
6. 2 48 The expression avg v has the same value shape as the expression v 2 11 Conditional Operators 2 11 1 Conditional UFL has limited support for branching but for some PDEs it is needed The expression c in c conditional condition true_value false_value evaluates to true_value at run time if condition evaluates to true or to false value otherwise This corresponds to the C syntax condition true value false value or the Python syntax true_value if condition else false_value 48 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 2 11 2 Conditions e eq a b represents the condition that a b e ne a b represents the condition that a b e le a b represents the condition that a j b e ge a b represents the condition that a j b e lt a b represents the condition that a b e gt a b represents the condition that a b TODO This is rather limited probably need the operations and and or as well the syntax will be rather convoluted Can we improve Low priority though Advanced Because of details in the way Python behaves we cannot over load the builtin comparison operators for this purpose hence these named operators 2 12 User defined operators A user may define new operators using standard Python syntax As an example consider the strain rate operator e of linear elasticity defined by as Vo Vo 2 49 This op
7. 36 form2uf1 96 ufl analyse 95 ufl convert 95 algebraic operators 34 avg 46 backward Euler 66 basis functions 24 BDM elements 68 boundary measure 16 Brezzi Douglas Marini elements 68 cell integral 16 cofactor 41 conditional operators 48 constants 27 contact 12 coordinates 27 cross product 40 curl 45 datatypes 27 Debian package 100 def 50 dependencies 97 determinant 40 deviatoric 40 DG operators 46 differential operators 42 Discontinuous Galerkin 69 discontinuous Galerkin 46 discontinuous Lagrange element 19 117 UFL Specification and User Manual 0 3 dot product 37 downloading 98 elasticity 64 enumeration 12 examples 61 exterior facet integral 16 facet normal 27 FE and QE 70 finite element space 18 fixed point iteration 65 form arguments 24 form files 59 form language 15 form transformations 50 forms 16 functions 24 25 GNU General Public License 101 GPL 101 heat equation 66 identity matrix 27 index notation 29 indexing 29 indices 12 30 inner product 38 installation 97 integrals 16 interior facet integral 16 interior measure 16 inverse 41 jump 46 Lagrange element 19 lambda 50 license 101 Martin S Aln s Anders Logg linear elasticity 64 mass matrix 61 mixed formulation 67 mixed Poisson 68 Navier Stokes 65 operators 35 outer product 39 Poisson s equation 62 Python 15
8. changed so that their problems will not be attributed erroneously to authors of previous versions Some devices are designed to deny users access to install or run modified versions of the software inside them although the manufacturer can do so This is fundamentally incompatible with the aim of protecting users freedom to change the software The systematic pattern of such abuse occurs in the area of products for individuals to use which is precisely where it is most unacceptable Therefore we have designed this version of the GPL to prohibit the practice for those products If such problems arise substantially in other domains we stand ready to extend this provision to those domains in future versions of the GPL as needed to protect the freedom of users Finally every program is threatened constantly by software patents States should not allow patents to restrict development and use of software on general purpose computers but in those that do we wish to 102 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg avoid the special danger that patents applied to a free program could make it effectively proprietary To prevent this the GPL assures that patents cannot be used to render the program non free The precise terms and conditions for copying distribution and modification follow TERMS AND CONDITIONS O Definitions This License refers to version 3 of the GNU General Public License Copyri
9. restriction 46 rotation 45 skew symmetric 41 source code 98 Stokes equations 67 strain 64 symmetric 40 Taylor Hood element 67 tensor algebra operators 36 tensor components 29 time stepping 66 trace 36 transpose 36 tuple notation 58 typographic conventions 11 Ubuntu package 100 ufl files 59 user defined operators 49 vector constants 27 vector product 40 vector valued Poisson 63 118
10. 11 cofac The cofactor of a matrix A can be written B cofac A The definition is cofac A det A A 2 37 The implementation of this is currently rather crude with a hardcoded sym bolic expression for the cofactor Therefore this is limited to 1x1 2x2 and 3x3 matrices 2 8 12 inv The inverse of matrix A can be written Ainv inv A The implementation of this is currently rather crude with a hardcoded sym bolic expression for the inverse Therefore this is limited to 1x1 2x2 and 3x3 matrices 41 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 2 9 Differential Operators Three different kinds of derivatives are currently supported spatial deriva tives derivatives w r t user defined variables and derivatives of a form or functional w r t a function 2 9 1 Basic spatial derivatives Spatial derivatives hold a special place in partial differential equations from physics and there are several ways to express those The basic way is Derivative w r t x_2 Dx v 2 v dx 2 Derivative w r t x_i Dx v i v dx i 0g 09 Hh Ih H If v is a scalar expression f here is the scalar derivative of v w r t spatial direction z If v has no free indices g is the scalar derivative w r t spatial direction x and g has the free index i Written as formulas this can be expressed compactly using the v notation Ov f Oa U 2 2 38 Ov
11. 5 Algorithms 81 del Formatting expressions lt gt menores deb bs bed es 81 Oe B coe hice aras oS Aa ee AAA 82 Di Tee o kw SBS eRe SS ee ok 82 5 1 4 B I Xformatting oo eke ek we SE ee 83 Blo Dot Tome es hi e aeaa ER OS Bes 83 5 2 Inspecting and manipulating the expression tree 83 5 2 1 Traversing expressions a 02 ee aden 83 5 2 2 Extracting information 244242562445 ds 84 5 2 3 Transforming expressions lt lt 84 5 3 Automatic differentiation implementation 87 Gal Forward mode e seacte fos be Poe e gbi 88 Ge Reverse TONE eot iia PARED REE ae ee da 88 52 SIO CETIVELIVES oo sc ecn Beare ee axe wee Be 88 54 Computational graphs e e serea se na Tee pa ee EDS 88 5 4 1 The computational graph 2 222 ke bw es 88 DA Partitioning the rap sc ead ew Peg ee bb wd 91 Commandline utilities 95 A 1 Validation and debugging ufl analyse 95 A 2 Formatting and visualization ufl convert 95 A 3 Conversion from FFC form files form2ufl 2 96 B Installation 97 B1 Installing irom Source e e u ic Ri 97 B 1 1 Dependencies and requirements 97 B 1 2 Downloading the source code 4 98 BAS Iostalme UFL 662 46 2 a Peo S eS 99 B 1 4 Running the test suite eee ee eG ae ee 100 B2 Debian Ubuntu package 2244 4 6440 454424848 e 100 C License About this manual Intended audience This manual is written bot
12. Logg The derivative of expression f w r t the variable w df diff f w Note that the variable w still represents the same expression This can be useful for example to implement material laws in hyperelasticity where the stress tensor is derived from a Helmholtz strain energy function Currently UFL does not implement time in any particular way but differ entiation w r t time can be done without this support through the use of a constant variable t t variable Constant cell f sin x 0 2 cos t dfdt diff f t 2 9 7 Functional derivatives The third and final kind of derivatives are derivatives of functionals or forms w r t toa Function This is described in more detail in section 2 13 6 about form transformations 2 10 DG operators UFL provides operators for implementation of discontinuous Galerkin meth ods These include the evaluation of the jump and average of a function or in general an expression over the interior facets edges or faces of a mesh 46 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 2 10 1 Restriction v and v When integrating over interior facets dS one may restrict expressions to the positive or negative side of the facet element FiniteElement Discontinuous Lagrange tetrahedron 0 v TestFunction element u TrialFunction element f Function element a f x dot grad v gra
13. Q Q fot f Vo oode 3 27 Then two additional forms are created to compute the tangent C and the gradient of uy This situation shows up in plasticity and other problems where certain quantities need to be computed elsewhere in user defined functions The 3 forms using the standard FiniteElement linear elements can then be implemented as L v oo f FE1NonlinearPoisson ufl element FiniteElement Lagrange triangle 1 DG FiniteElement Discontinuous Lagrange triangle 0 sig VectorElement Discontinuous Lagrange triangle 0 v TestFunction element u TrialFunction element u0 Function element C Function DG sig0 Function sig f Function element a v dx i C u dx i dx v dx i 2 u0 u u0 dx i dx L v f dx dot grad v sig0 dx FElTangent ufl element FiniteElement Lagrange triangle 1 DG FiniteElement Discontinuous Lagrange triangle 0 v TestFunction DG u TrialFunction DG u0 Function element a v u dx L vx 1 0 u0 2 dx 72 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg FElGradient ufl element FiniteElement Lagrange triangle 1 DG VectorElement Discontinuous Lagrange triangle 0 lt l TestFunction DG TrialFunction DG u0 Function element a dot v u dx dot v grad u0 dx E Il The 3 forms can be implemented using the QuadratureElement in a simila
14. This subsection is mostly for form compiler developers and technically inter ested users TODO More details about traversal and transformation algorithms for de velopers 5 2 1 Traversing expressions iter_expressions q f v r g v s u v a q dx 0 r dx 1 s ds 0 for e in iter_expressions a print str e 83 UFL Specification and User Manual 0 3 post_traversal TODO traversal py pre_traversal TODO traversal py walk TODO traversal py traverse_terminals TODO traversal py 5 2 2 Extracting information TODO analysis py 5 2 3 Transforming expressions Martin S Aln s Anders Logg So far the algorithms presented has been about inspecting expressions in var ious ways Some recurring patterns occur when writing algorithms to modify expressions either to apply mathematical transformations or to change their representation Usually different expression node types need different treat ment To assist in such algorithms UFL provides the Transformer class This im plements a variant of the Visitor pattern to enable easy definition of trans 84 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg formation rules for the types you wish to handle Shown here is maybe the simplest transformer possible class Printer Transformer def __init_ self Transformer __init__ self def expr self o operands print Visiting str o with operands
15. a is defined as a u v alv u This operation is implemented in UFL simply by swapping test and trial functions in a Form and is used like this aprime adjoint a 2 13 5 Linear and bilinear parts of a Form Some times it is useful to write an equation on the format a v u L v 0 Before we can assemble the linear equation Au b we need to extract the forms corresponding to the left hand side and right hand side This corresponds to extracting the bilinear and linear terms of the form respectively or the terms that depend on both a test and a trial function on one side and the terms that depend on only a test function on the other This is easily done in UFL using 1hs and rhs 52 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg b u v edx f v dx a L lhs b rhs b Note that rhs multiplies the extracted terms by 1 corresponding to moving them from left to right so this is equivalent to u xv dx L v dx w II As a slightly more complicated example this formulation F v u w dx k dot grad v grad 0 5 w u dx a L lhs F rhs F is equivalent to v uxdx k dot grad v 0 5x grad u x dx v w xdx k dot grad v 0 5 grad w dx w I EP Il 2 13 6 Automatic Functional Differentiation UFL can compute derivatives of functionals or forms w r t to a Function This functionality can be u
16. be predefined indices and unless otherwise specified the name v refers to some vector valued expression and the name A refers to some matrix valued expression The name C refers to a tensor expression of arbitrary rank 2 5 1 Defining indices A set of indices i j k 1 and p q r s are predefined and these should be enough for many applications Examples will usually use these objects instead of creating new ones to conserve space 30 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg The data type Index represents an index used for subscripting derivatives or taking components of non scalar expressions To create indices you can either make a single using Index or make several at once conveniently using indices n i Index j k 1 indices 3 Each of these represents an index range determined by the context if used to subscript a tensor valued expression the range is given by the shape of the expression and if used to subscript a derivative the range is given by the dimension d of the underlying shape of the finite element space As we shall see below indices can be a powerful tool when used to define forms in tensor notation Advanced If using UFL inside PyDOLFIN or another larger programming environment it is a good idea to define your indices explicitly just before your form uses them to avoid name collisions The definition of the predefined indices is simply i j k 1 i
17. covered work authorizing them to use propagate modify or convey a specific copy of the covered work then the patent license you grant is automatically extended to all recipients of the covered work and works based on it A patent license is discriminatory if it does not include within the scope of its coverage prohibits the exercise of or is conditioned on the non exercise of one or more of the rights that are specifically granted under this License You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software under which you make payment to the third party based on the extent of your activity of conveying the work and under which the third party grants to any of the parties who would receive the covered work from you a discriminatory patent license a in connection with copies of the covered work conveyed by you or copies made from those copies or b primarily for and in connection with specific products or compilations that contain the covered work unless you entered into that arrangement or that patent license was granted prior to 28 March 2007 Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law 12 No Surrender of Others Freedom If conditions are imposed on you whether by court order agreement or otherw
18. handler Transformer reuse_if_po will return the input object if the operands have not changed and other wise reconstruct a new instance of the same type but with the new trans formed operands The handler Transformer always_reuse always reuses the instance without recursing into its children usually applied to terminals To set these defaults with less code inherit ReuseTransformer instead of Transformer This ensures that the parts of the expression tree that are not changed by the transformation algorithms always reuse the same instances We have already mentioned the difference between pre traversal and post traversal and some times you need to combine the two Transformer makes this easy by checking the number of arguments to your handler functions to see if they take transformed operands as input or not If a handler function does not take more than a single argument in addition to self its children are not visited automatically and the handler function must call visit on its operands itself 86 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg Here is an example of mixing pre and post traversal class Traverser ReuseTransformer def init__ self ReuseTransformer __init__ self def sum self o operands o operands newoperands for e in operands newoperands append self visit e return sum newoperands element FiniteElement CG triangle 1 f Function element g Fun
19. peer to peer transmission to receive a copy likewise does not require acceptance However nothing other than this License grants you permission to propagate or modify any covered work These actions infringe copyright if you do not accept this License Therefore by modifying or propagating a covered work you indicate your acceptance of this License to do so 10 Automatic Licensing of Downstream Recipients Each time you convey a covered work the recipient automatically receives a license from the original licensors to run modify and propagate that work subject to this License You are not responsible for enforcing compliance by third parties with this License An entity transaction is a transaction transferring control of an organization or substantially all assets of one or subdividing an organization or merging organizations If propagation of a covered work results from an entity transaction each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party s predecessor in interest had or could give under the previous paragraph plus a right to possession of the Corresponding Source of the work from the predecessor in interest if the predecessor has it or can get it with reasonable efforts You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License For example you may not impose a license fee royalty or other charge fo
20. print join map str operands return o element FiniteElement CG triangle 1 v TestFunction element u TrialFunction element a u v p Printer p visit a The call to visit will traverse a and call Printer expr on all expression nodes in post order with the argument operands holding the return values from visits to the operands of o The output is TODO Implementing expr above provides a default handler for any expression node type For each subclass of Expr you can define a handler function to over ride the default by using the name of the type in underscore notation e g basis function for BasisFunction The constructor of Transformer and implementation of Transformer visit handles the mapping from type to handler function automatically Here is a simple example to show how to override default behaviour 85 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg class FunctionReplacer Transformer def __init__ self Transformer __init__ self expr Transformer reuse_if_possible terminal Transformer always_reuse def function self o return FloatValue 3 14 element FiniteElement CG triangle 1 v TestFunction element f Function element a xv r FunctionReplacer b r visit a print b The output of this code is the transformed expression b 3 14 v This code also demonstrates how to reuse existing handlers The
21. run it The Corresponding Source for a work in object code form means all the source code needed to generate install and for an executable work run the object code and to modify the work including scripts to control those activities However it does not include the work s System Libraries or general purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work For example Corresponding Source includes interface definition files associated with source files for the work and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require such as by intimate data communication or control flow between those subprograms and other parts of the work The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source The Corresponding Source for a work in source code form is that same work 104 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 2 Basic Permissions All rights granted under this License are granted for the term of copyright on the Program and are irrevocable provided the stated conditions are met This License explicitly affirms your unlimited permission to run the unmodified Program The output from running a covered work is covered by this License only if the output given its cont
22. s Anders Logg Crouzeix Raviart or CR representing scalar Crouzeix Raviart elements Brezzi Douglas Marini or BDM representing vector valued Brezzi Douglas Marini H div elements Brezzi Douglas Fortin Marini or BDFM representing vector valued Brezzi Douglas Fortin Marini A div elements Raviart Thomas or RT representing vector valued Raviart Thomas H div elements Nedelec 1st kind H div or Nidiv representing vector valued Nedelec H div elements of the first kind Nedelec 2st kind H div or N2div representing vector valued Nedelec H div elements of the second kind Nedelec 1st kind H curl or Nicurl representing vector valued Nedelec H curl elements of the first kind Nedelec 2st kind H curl or N2curl representing vector valued Nedelec H curl elements of the second kind Quadrature or Q representing artificial finite elements with de grees of freedom being function evaluation at quadrature points Boundary Quadrature or BQ representing artificial finite ele ments with degrees of freedom being function evaluation at quadrature points on the boundary Advanced New elements can be added dynamically by the form compiler using the function register_element See the docstring for details To see which elements are registered including the standard built in ones listed above call the function show_elements 20 UFL Specification and Us
23. terminate your rights under this License including any patent licenses granted under the third paragraph of section 11 However if you cease all violation of this License then your license from a particular copyright holder is reinstated a provisionally unless and until the copyright holder explicitly and finally terminates your license and b permanently if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation Moreover your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the 110 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg violation by some reasonable means this is the first time you have received notice of violation of this License for any work from that copyright holder and you cure the violation prior to 30 days after your receipt of the notice Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License If your rights have been terminated and not permanently reinstated you do not qualify to receive new licenses for the same material under section 10 9 Acceptance Not Required for Having Copies You are not required to accept this License in order to receive or run a copy of the Program Ancillary propagation of a covered work occurring solely as a consequence of using
24. used like this Dx v i j Dx u i j dx v i f i dx Cc w oil or like this 63 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg a vlil dx j ulil dx j x dx v i f i dx Il This example is implemented in the file poisson_system uf1 in the collection of demonstration forms included with the UFL source distribution 3 4 The strain strain term of linear elasticity The strain strain term of linear elasticity alu u ew e u dz 3 6 where ds Vo Vo 3 7 can be implemented as follows element VectorElement Lagrange tetrahedron 1 v TestFunction element u TrialFunction element def epsilon v Dv grad v return 0 5 Dv Dv T a inner epsilon v epsilon u dx Alternatively index notation can be used to define the form a 0 25 Dx v j i Dx v il j Dx ulj i Dx uli j dx 64 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg or like this a 0 25 v j dx i v i dx j u j dx i uli dx j dx This example is implemented in the file elasticity ufl in the collection of demonstration forms included with the UFL source distribution 3 5 The nonlinear term of Navier Stokes The bilinear form for fixed point iteration on the nonlinear term of the in compressible Navier Stokes equations a v u w fo Vu vdz 3 8
25. with w the frozen velocity from a previous iteration can be implemented as follows element VectorElement Lagrange tetrahedron 1 v TestFunction element u TrialFunction element w Function element a dot grad u w v dx alternatively using index notation like this a vlil w j l Dx u lil j dx or like this 65 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg a vlil w j u il dx j dx This example is implemented in the file navier_stokes uf1 in the collection of demonstration forms included with the UFL source distribution 3 6 The heat equation Discretizing the heat equation u V cVu f 3 9 in time using the dG 0 method backward Euler we obtain the following variational problem for the discrete solution up uy x t Find u un tn with uz up tn 1 given such that ot A ae det eve Vupde fv fraz 3 10 for all test functions v where k tn t _ denotes the time step In the example below we implement this variational problem with piecewise linear test and trial functions but other choices are possible just choose another finite element Rewriting the variational problem in the standard form a v un L v for all v we obtain the following pair of bilinear and linear forms a v up c k f videt ka f eve Vide 3 11 Q Q L v ue f k ow dz hy of dx 3 12 Q Q which can be imp
26. Element Lagrange cell 2 symmetry True V VectorElement Lagrange cell 1 P FiniteElement DG cell 0 ME MixedElement T V P 2 2 7 EnrichedElement The data type EnrichedElement represents the vector sum of two or more finite elements Example The Mini element can be constructed as 23 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg P1 VectorElement Lagrange triangle 1 B VectorElement Bubble triangle 3 Q FiniteElement Lagrange triangle 1 Mini Pi B xQ 2 3 Form Arguments Form arguments are divided in two groups basis functions and functions A BasisFunction represents an arbitrary basis function in a given discrete finite element space while a Function represents a function in a discrete finite element space that will be provided by the user at a later stage The number of BasisFunctions that occur in a Form equals the arity of the form 2 3 1 Basis functions The data type BasisFunction represents a basis function on a given finite element A BasisFunction must be created for a previously declared finite element simple or mixed v BasisFunction element Note that more than one BasisFunction can be declared for the same FiniteElement Basis functions are associated with the arguments of a multilinear form in the order of declaration For a MixedElement the function BasisFunctions can be used to construct tu
27. Logg 4 2 3 cell u cell returns the first Cell instance found in u It is currently assumed in UFL that no two different cells are used in a single form Not all expression define a cell in which case this returns None and u is spatially constant Note that this property is used in some algorithms 4 2 4 shape u shape returns a tuple of integers which is the tensor shape of u 4 2 5 free indices u free_indices returns a tuple of Index objects which are the unas signed free indices of u 4 2 6 index dimensions u index_dimensions returns a dict mapping from each Index instance in u free_indices to the integer dimension of the value space each index can range over 4 2 7 str u str u returns a human readable string representation of u 4 2 8 repr u repr u returns a Python string representation of u such that eval repr u u holds in Python TT UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 4 2 9 hash u hash u returns a hash code for u which is used extensively indirectly in algorithms whenever u is placed in a Python dict or set 4 2 10 u v u v returns true if and only if u and v represents the same expression in the exact same way This is used extensively indirectly in algorithms whenever u is placed in a Python dict or set 4 2 11 About other relational operators In general UFL expressions are not possible to fully evaluate since the cell and the v
28. PROVE DEFECTIVE YOU ASSUME THE COST OF ALL NECESSARY SERVICING REPAIR OR CORRECTION 16 Limitation of Liability IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER OR ANY OTHER PARTY WHO MODIFIES AND OR CONVEYS 114 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg THE PROGRAM AS PERMITTED ABOVE BE LIABLE TO YOU FOR DAMAGES INCLUDING ANY GENERAL SPECIAL INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 17 Interpretation of Sections 15 and 16 If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program and you want it to be of the greatest possible use to the public the best way to achieve this is to make it free software which everyon
29. This requirement modifies the requirement in section 4 to keep intact all notices c You must license the entire work as a whole under this License to anyone who comes into possession of a copy This License will therefore apply along with any applicable section 7 additional terms to the whole of the work and all its parts regardless of how they are packaged This License gives no permission to license the work in any other way but it does not invalidate such permission if you have separately received it d If the work has interactive user interfaces each must display Appropriate Legal Notices however if the Program has interactive interfaces that do not display Appropriate Legal Notices your work need not make them do so A compilation of a covered work with other separate and independent works which are not by their nature extensions of the covered work and which are not combined with it such as to form a larger program in or on a volume of a storage or distribution medium is called an aggregate if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation s users beyond what the individual works permit Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate 106 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 6 Conveying Non Source Forms You may convey a covered work in o
30. UFL Specification and User Manual 0 3 November 16 2010 Martin S Aln s Anders Logg www fenics org Visit http www fenics org for the latest version of this manual Send comments and suggestions to uf1 dev fenics org Contents About this manual 11 1 Introduction 13 2 Form Language 15 21 Fonas and Integrale e osca ca eho bate dake s dake 16 2 2 Finite Element Spaces o 18 AA AR IIA 18 2 22 Element Families 000 e a eG eo 19 22 3 Basic Elements s aa See bs a a b 21 224 Vector Elements aoaaa a 4 be eo 21 2 2 5 Tensor Elements 22 226 Mized Blements 4 244 620 84 ee be ewe do 22 2 2 7 EnrichedElement 2 4 2624458654208 23 J3 Porm ArpUMenia 4 5 6 wd dle eon See A He Re 24 2 4 2 5 2 6 rat 2 8 23 1 Basis functions 2 2 842 22 268 babe aS 24 23 2 Coefficient functi ns os s dee ee ee ero Eee 25 oer Tigra A 2T 2 4 1 Literals and geometric quantities 27 Indexing and tensor components a sooo o a 29 251 Jeng Md eoa ce cde ea cards oa 30 2 5 2 Taking components of tensors 32 2 5 3 Making tensors from components 33 2 54 maple summation coc ei eS ee ee pe tts 34 Basic algebraic Operators 34 Basic nonlinear functions 2 a aw kk we a a A e 35 Tensor Algebra Operators 0 0000 eens 36 LSL RESISTE oe wee Cas ow HY ESE Se RES EDR EOS 36 VAL UW 22 shee eth ro eh eee h
31. UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg Subclasses of Terminal represent atomic quantities which terminate the ex pression tree e g they have no subexpressions Subclasses of Operator represent operations on one or more other expressions which may usually be Expr subclasses of arbitrary type Different Operators may have restrictions on some properties of their arguments All the types mentioned here are conceptually immutable i e they should never be modified over the course of their entire lifetime When a modified expression measure integral or form is needed a new instance must be created possibly sharing some data with the old one Since the shared data is also immutable sharing can cause no problems 4 2 General properties of expressions Any UFL expression has certain properties defined by functions that every Expr subclass must implement In the following u represents an arbitrary UFL expression i e an instance of an arbitrary Expr subclass 4 2 1 operands u operands returns a tuple with all the operands of u which should all be Expr instances 4 2 2 reconstruct u reconstruct operands returns a new Expr instance representing the same operation as u but with other operands Terminal objects may simply return self since all Expr instance are immutable An important invariant is that u reconstruct u operands 76 UFL Specification and User Manual 0 3 Martin S Aln s Anders
32. UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg namespace available and extract forms and elements that are defined after execution The compilers do not compile all forms and elements that are defined in file but only those that are exported A finite element with the variable name element is exported by default as are forms with the names M L and a The default form names are intended for a functional linear form and bilinear form respectively To export multiple forms and elements or use other names an explicit list with the forms and elements to export can be defined Simply write elements V P TH forms la L F J L2 H1 at the end of the file to export the elements and forms held by these variables 60 Chapter 3 Example Forms The following examples illustrate basic usage of the form language for the definition of a collection of standard multilinear forms We assume that dx has been declared as an integral over the interior of Q and that both i and j have been declared as a free Index The examples presented below can all be found in the subdirectory demo of the UFL source tree together with numerous other examples 3 1 The mass matrix As a first example consider the bilinear form corresponding to a mass matrix alu u f vudz 3 1 Q which can be implemented in UFL as follows element FiniteElement Lagrange triangle 1 TestFunction element TrialFuncti
33. V L such that alv u L v Vue V where awuh f Vo Vudo o PA f Vv un lv n Vu a b lv n u dS de 3 22 n f Vv ful en Vu 7 h vuds Lui fa f vfaes ug ds o o 69 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg The corresponding finite element variational problem for discontinuous first order elements may be implemented as follows cell triangle DG1 FiniteElement Discontinuous Lagrange cell 1 v TestFunction DG1 u TrialFunction DG1 f Function DG1 g Function DG1 h MeshSize cell TODO Do we include MeshSize in UFL h Constant cell alpha 1 TODO Set to proper value gamma 1 TODO Set to proper value a dot grad v grad u dx dot avg grad v jump u dS dot jump v avg grad u dS A alpha h dot jump v jump u dS dot grad v jump u ds dot jump v grad u ds gamma hx v ux ds L v f dx v gx ds This example is implemented in the file poisson_dg ufl in the collection of demonstration forms included with the UFL source distribution 3 10 Quadrature elements FIXME The code examples in this section have been mostly converted to UFL syntaz but the quadrature elements need some more updating as well as the text In UFL I think we should define the element order and not the 70 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg number of po
34. alues of form arguments are not available Implementing relational operators for immediate evaluation is therefore impossible Overloading relational operators as a part of the form language is not possible either since it interferes with the correct use of container types in Python like dict or set 4 3 Elements All finite element classes have a common base class FiniteElementBase The class hierarchy looks like this TODO Class figure TODO Describe all FiniteElementBase subclasses here 78 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 4 4 Terminals All Terminal subclasses have some non Expr data attached to them ScalarValue has a Python scalar Function has a FiniteElement etc Therefore a unified implementation of reconstruct is not possible but since all Expr instances are immutable reconstruct for terminals can simply return self This feature and the immutability property is used extensively in algorithms TODO Describe all Terminal representation classes here 4 5 Operators All instances of Operator subclasses are fully specified by their type plus the tuple of Expr instances that are the operands Their constructors should take these operands as the positional arguments and only that This way a unified implementation of reconstruct is possible by simply calling the constructor with new operands This feature is used extensively in algo rithms TODO Describe all Operator repres
35. anual 5 for more details about using UFL in an integrated problem solving environment This manual is intended for different audiences If you are an end user and all you want to do is to solve your PDEs with the FEniCS framework Chapters 2 and 3 are for you These two chapters explain how to use all operators available in the language and present a number of examples to illustrate the use of the form language in applications The rest of the chapters contain more technical details intended for developers who need to understand what is happening behind the scenes and modify or extend UFL in the future Chapter 4 details the implementation of the language in particular how ex pressions are represented internally by UFL This can also be useful knowl edge to understand error messages and debug errors in your form files 13 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg Chapter 5 explains many algorithms to work with UFL expressions mostly intended to aid developers of form compilers The algorithms available in cludes helper functions for easy and efficient iteration over expression trees formatting tools to present expressions as text or images of different kinds utilities to analyse properties of expressions or checking their validity au tomatic differentiation algorithms as well as algorithms to work with the computational graphs of expressions 14 Chapter 2 Form Language UFL consists of a set of o
36. anual 0 3 Martin S Aln s Anders Logg To try this tool go to the demo directory of the UFL source tree Some of the features to try are basic printing of str and repr string representations of each form ufl convert format str stiffness ufl ufl convert format repr stiffness ufl compilation of forms to mathematical notation in TFX ufl convert filetype pdf format tex show 1 stiffness ufl ETE EX output of forms after processing with UFL compiler utilities ufl convert tpdf ftex s1 compile 1 stiffness ufl and visualization of expression trees using graphviz via compilation of forms to the dot format ufl convert tpdf fdot s1 stiffness ufl Type ufl convert help for more details A 3 Conversion from FFC form files form2uf1 The command form2uf1 can be used to convert old FFC form files to UFL format To convert a form file named myform form to UFL format simply type form2ufl myform ufl Note that although the form2uf1 script may be helpful as a guide to con verting old FFC form files it is not foolproof and may not always yield valid UFL files 96 Appendix B Installation The source code of UFL is portable and should work on any system with a standard Python installation Questions bug reports and patches concerning the installation should be directed to the UFL mailing list at the address ufl dev fenics org UFL must currently be installed directly from source bu
37. bject code form under the terms of sections 4 and 5 provided that you also convey the machine readable Corresponding Source under the terms of this License in one of these ways a Convey the object code in or embodied in a physical product including a physical distribution medium accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange b Convey the object code in or embodied in a physical product including a physical distribution medium accompanied by a written offer valid for at least three years and valid for as long as you offer spare parts or customer support for that product model to give anyone who possesses the object code either 1 a copy of the Corresponding Source for all the software in the product that is covered by this License on a durable physical medium customarily used for software interchange for a price no more than your reasonable cost of physically performing this conveying of source or 2 access to copy the Corresponding Source from a network server at no charge c Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source This alternative is allowed only occasionally and noncommercially and only if you received the object code with such an offer in accord with subsection 6b d Convey the object code by offering access from a designated place gratis or for a charge and offer equi
38. ction element Note that the order in which Functions are declared is important directly reflected in the ordering they have among the arguments to each Form they are part of Function is used to represent user defined functions including e g source terms body forces variable coefficients and stabilization terms UFL treats each Function as a linear combination of unknown basis functions with un known coefficients that is UFL knows nothing about the concrete basis functions of the element and nothing about the value of the function Note that more than one function can be declared for the same FiniteEle ment The following example declares two BasisFunctions and two Functions for the same FiniteElement v BasisFunction element u BasisFunction element f Function element g Function element For a Function on a MixedElement or VectorElement or TensorElement the function split can be used to extract function values on subspaces as illustrated here for a mixed Taylor Hood element up Function TH u p split up A shorthand for this is in place called Functions u p Function TH 26 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg Spatially constant or discontinuous piecewise constant functions can conve niently be represented by Constant VectorConstant and TensorConstant c0 Constant cell vO VectorConstant cell tO Te
39. ction element h Function element a f gth r Traverser b r visit a print b This code inherits the ReuseTransformer like explained above so the default behaviour is to recurse into children first and then call Transformer reuse_if possible to reuse or reconstruct each expression node Since sum only takes self and the expression node instance o as arguments its children are not visited automatically and sum calls on self visit to do this explicitly 5 3 Automatic differentiation implementation This subsection is mostly for form compiler developers and technically inter ested users TODO More details about AD algorithms for developers 87 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 5 3 1 Forward mode TODO forward_ad py 5 3 2 Reverse mode TODO reverse_ad py 5 3 3 Mixed derivatives TODO ad py 5 4 Computational graphs This section is for form compiler developers and is probably of no interest to end users An expression tree can be seen as a directed acyclic graph DAG To aid in the implementation of form compilers UFL includes tools to build a lin earized computational graph from the abstract expression tree A graph can be partitioned into subgraphs based on dependencies of subex pressions such that a quadrature based compiler can easily place subexpres sions inside the right sets of loops 5 4 1 The computational graph TODO finish graph py Lineari
40. d is used like this l action a w action L w Kh Il To give a concrete example these declarations are equivalent a inner grad u grad v dx L action a w a inner grad u grad v dx L inner grad w grad v dx If a is a rank 2 form used to assemble the matrix A L is a rank 1 form that can be used to assemble the vector b Ax directly This can be used to define both the form of a matrix and the form of its action without code duplication and for the action of a Jacobi matrix computed using derivative If L is a rank 1 form used to assemble the vector b f is a functional that can be used to assemble the scalar value f b w directly This operation is sometimes used in e g error control with L being the residual equation and w being the solution to the dual problem However the discrete vector for the assembled residual equation will typically be available so doing the dot product using linear algebra would be faster than using this feature FIXME Is this right 2 13 3 Energy norm of a bilinear Form The functional representing the energy norm v 4 v Av of a matrix A assembled from a form a can be computed like this 51 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg f energy_norm a w which is equivalent to f action action a w w 2 13 4 Adjoint of a bilinear Form The adjoint a of a bilinear form
41. d u dS Restriction may be applied to functions of any finite element space but will only have effect when applied to expressions that are discontinuous across facets 2 10 2 Jump jump v The operator jump may be used to express the jump of a function across a common facet of two cells Two versions of the jump operator are provided If called with only one argument then the jump operator evaluates to the difference between the restrictions of the given expression on the positive and negative sides of the facet jump v v v v 2 45 If the expression v is scalar then jump v will also be scalar and if v is vector valued then jump v will also be vector valued If called with two arguments jump v n evaluates to the jump in v weighted by n Typically n will be chosen to represent the unit outward normal of 47 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg the facet as seen from each of the two neighboring cells If v is scalar then jump v n is given by jump v n vu vint tun 2 46 If v is vector valued then jump v n is given by jump v n gt vu vt n tu en 2 47 Thus if the expression v is scalar then jump v n will be vector valued and if v is vector valued then jump v n will be scalar 2 10 3 Average avg v The operator avg may be used to express the average of an expression across a common facet of two cells avg v gt w Sut
42. details type show w This is free software and you are welcome to redistribute it under certain conditions type show c for details The hypothetical commands show w and show c should show the appropriate parts of the General Public License Of course your program s commands might be different for a GUI interface you would use an about box You should also get your employer if you work as a programmer or school if any to sign a copyright disclaimer for the program if necessary For more information on this and how to apply and follow the GNU GPL see lt http www gnu org licenses gt The GNU General Public License does not permit incorporating your program into proprietary programs If your program is a subroutine library you may consider it more useful to permit linking proprietary applications with the library If this is what you want to do use the GNU Lesser General Public License instead of this License But first please read lt http www gnu org philosophy why not lgpl html gt 116 Index BasisFunctions 24 BasisFunction 24 Constant 25 27 FacetNormal 27 Functions 25 Function 25 Identity 27 Index 30 TensorConstant 25 TestFunctions 24 TestFunction 24 TrialFunctions 24 TrialFunction 24 VectorConstant 25 27 cofac 41 cross 40 curl 45 det 40 dev 40 dot a inner 38 inv 41 outer 39 rot 45 skew 41 split 25 sym 40 transpose 36 tr
43. e can redistribute and change under these terms To do so attach the following notices to the program It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty and each file should have at least the copyright line and a pointer to where the full notice is found lt one line to give the program s name and a brief idea of what it does gt Copyright C lt year gt lt name of author gt This program is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later version This program is distributed in the hope that it will be useful but WITHOUT ANY WARRANTY without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE See the GNU General Public License for more details You should have received a copy of the GNU General Public License along with this program If not see lt http www gnu org licenses gt 115 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg Also add information on how to contact you by electronic and paper mail If the program does terminal interaction make it output a short notice like this when it starts in an interactive mode lt program gt Copyright C lt year gt lt name of author gt This program comes with ABSOLUTELY NO WARRANTY for
44. e eS ea 36 DA Mes ope Meee Ah AA Be 3T Pee SO a E A BA A A e 38 yes DB caca a a de a da Heed 39 Se MOSS Lio ia A a e e Bed 40 e AA Shee AES eee 40 Bee AE 40 ARG AI 40 29 2 10 ZAN 212 2 13 2 GE a a es Bw ds Bw A A 41 Pos COLIC ses osa ar AGE OR os 41 MA A a HS E E ERAN ARA 41 Differential Operator 66244 262080 aa 42 2 9 1 Basic spatial derivatives 06 42 2 9 2 Compound spatial derivatives 43 293 Graden e a ees a ae ESR REE ER EEE RS 43 294 Divergent es he eee SRE SEER ESSERE SE 44 295 Ciel Ah FOr lt e ge ee a AAA 45 2 9 6 Variable derivatives o 45 2 9 7 Functional derivatives 65 48 carr eae 46 o s oe hres Oe Se BS aane Bed 46 210 1 Restriction YOP J md 90 2 cee hw a 47 eC ID TUVO ok eee ee eee RS SER ESSERE OS 47 DAS Ayer IYEN coec o doii OS ew a BES 48 Conditional Operators xs 48 ee wee eae edo 48 ZALLA Conditional s sora 48 2411 2 Conditions a s sor mororo aa ee AA 49 User defined operators a a 49 Form Transformations s lt o s s eos ese dor eo raw sori 50 2 13 1 Replacing arguments of a Form 50 2 13 2 Action of a form on a function 50 2 13 3 Energy norm of a bilinear Form 51 2 13 4 Adjoint of a bilinear Form 52 2 13 5 Linear and bilinear parts of a Form 52 2 13 6 Automatic Functional Differentiation 53 2 13 7 Combining fo
45. e g place expressions outside the quadrature loop if they don t depend directly or indirectly on the spatial coordinates This is done simply by P partition G TODO TODO finish dependencies py TODO 91 Bibliography 5 6 M ALN S AND K A MARDAL SyFi 2007 URL http www fenics org syfi M S ALNES AND A LoGG UFL 2009 URL http www fenics org uf1 M S ALN S A LOGG K A MARDAL O SKAVHAUG AND H P LANGTANGEN UFC 2009 URL http www fenics org ufc 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 A LoGG FFC 2007 URL http www fenics org ftc 93 Appendix A Commandline utilities A 1 Validation and debugging ufl analyse The command ufl analyse loads all forms found in a ufl file tries to discover any errors in them and prints various kinds of information about each form Basic usage is ufl analyse myform ufl For more information type ufl analyse help A 2 Formatting and visualization ufl convert The command ufl convert loads all forms found in a uf1 file compiles them into a different form or extracts some information from them and writes the result in a suitable file format 95 UFL Specification and User M
46. e interval triangle tetrahedron quadrilateral and hexahedron Some examples Note that the other components of FEniCS does not yet handle cells of higher degree so this will only be useful in the future 18 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg Cubic triangle cell cell Cell triangle 3 Quadratic tetrahedron cell cell Cell tetrahedron 2 Objects for linear cells of all basic shapes are predefined Predefined linear cells cell interval cell triangle cell tetrahedron cell quadrilateral cell hexahedron In the rest of this document a variable name ce11 will be used where any cell is a valid argument to make the examples dimension independent wherever possible Using a variable cell to hold the cell type used in a form is highly recommended since this makes most form definitions dimension independent 2 2 2 Element Families UFL predefines a set of names of known element families When defining a finite element below the argument family is a string and its possible values include e Lagrange or CG representing standard scalar Lagrange finite ele ments continuous piecewise polynomial functions e Discontinuous Lagrange or DG representing scalar discontinu ous Lagrange finite elements discontinuous piecewise polynomial func tions 19 UFL Specification and User Manual 0 3 Martin S Aln
47. e vlil vlil gt vivi e ALi jl vlil v jl 7 0 4 50 9 A tensor valued expression indexed twice with the same free index is treated as a sum over that free index e A i i Y Au Cid Cae The spatial derivative in the direction of a free index of an expression with the same free index is treated as a sum over that free index e v i dx i SO v e ALi j dx i Dy A Note that these examples are some times written v and Aj in pen and paper index notation 2 6 Basic algebraic operators The basic algebraic operators can be used freely on UFL expressions They do have some requirements on their operands summarized here Addition or subtraction a bora b 34 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg e The operands a and b must have the same shape e The operands a and b must have the same set of free indices Division a b e The operand b must be a scalar expression e The operand b must have no free indices e The operand a can be non scalar with free indices in which division represents scalar division of all components with the scalar b Multiplication a b e The only non scalar operations allowed is scalar tensor matrix vector and matrix matrix multiplication e If either of the operands have any free indices both must be scalar e If any free indices are repeated summation is implied 2 7 Basic nonlinear functions Some basic nonlinear f
48. ent constitutes a covered work This License acknowledges your rights of fair use or other equivalent as provided by copyright law You may make run and propagate covered works that you do not convey without conditions so long as your license otherwise remains in force You may convey covered works to others for the sole purpose of having them make modifications exclusively for you or provide you with facilities for running those works provided that you comply with the terms of this License in conveying all material for which you do not control copyright Those thus making or running the covered works for you must do so exclusively on your behalf under your direction and control on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you Conveying under any other circumstances is permitted solely under the conditions stated below Sublicensing is not allowed section 10 makes it unnecessary 3 Protecting Users Legal Rights From Anti Circumvention Law No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996 or similar laws prohibiting or restricting circumvention of such measures When you convey a covered work you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exe
49. ent or commitment however denominated not to enforce a patent such as an express permission to practice a patent or covenant not to sue for patent infringement To grant such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party If you convey a covered work knowingly relying on a patent license and the Corresponding Source of the work is not available for anyone to copy free of charge and under the terms of this License through a publicly available network server or other readily accessible means then you must either 1 cause the Corresponding Source to be so available or 2 arrange to deprive yourself of the benefit of the patent license for this particular work or 3 arrange in a manner consistent with the requirements of this License to extend the patent license to downstream recipients Knowingly relying means you have actual knowledge that but for the patent license your conveying the covered work in a country or your recipient s use of the covered work in a country would infringe one or more identifiable patents in that country that you have reason to believe are valid If pursuant to or in connection with a single transaction or 112 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg arrangement you convey or propagate by procuring conveyance of a covered work and grant a patent license to some of the parties receiving the
50. entation classes here 4 6 Extending UFL Adding new types to the UFL class hierarchy must be done with care If you can get away with implementing a new operator as a combination of existing ones that is the easiest route The reason is that only some of the properties of an operator is represented by the Expr subclass Other properties are part of the various algorithms in UFL One example is derivatives which are defined in the differentiation algorithm and how to render a type to the BTFX or dot formats These properties could be merged into the class hierarchy but other properties like how to map a UFL type to some FFC or 79 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg SFC or DOLFIN type can not be part of UFL So before adding a new class consider that doing so may require changes in multiple algorithms and even other projects TODO More issues to consider when adding stuff to ufl 80 Chapter 5 Algorithms Algorithms to work with UFL forms and expressions can be found in the submodule uf1 algorithms You can import all of them with the line from ufl algorithms import This chapter gives an overview of most of the implemented algorithms The intended audience is primarily developers but advanced users may find information here useful for debugging While domain specific languages introduce notation to express particular ideas more easily which can reduce the probability of bug
51. er Manual 0 3 Martin S Aln s Anders Logg 2 2 3 Basic Elements A FiniteElement some times called a basic element represents a finite element in some family on a given cell with a certain polynomial degree Valid families and cells are explained above The notation is element FiniteElement family cell degree Some examples element FiniteElement Lagrange interval 3 element FiniteElement DG tetrahedron 0 element FiniteElement BDM triangle 1 2 2 4 Vector Elements A VectorElement represents a combination of basic elements such that each component of a vector is represented by the basic element The size is usually omitted the default size equals the geometry dimension The notation is element VectorElement family cell degree size Some examples element VectorElement CG triangle 2 element VectorElement DG tetrahedron 0 size 6 21 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 2 2 5 Tensor Elements A TensorElement represents a combination of basic elements such that each component of a tensor is represented by the basic element The shape is usu ally omitted the default shape is d d where d is the geometry dimension The notation is element TensorElement family cell degree shape symmetry Any shape tuple consisting of positive integers is valid and the optional symmet
52. erator can be implemented as a function using the Python def key word def epsilon v return 0 5 grad v grad v T 49 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg Alternatively using the shorthand lambda notation the strain operator may be defined as follows epsilon lambda v 0 5 grad v grad v T 2 13 Form Transformations When you have defined a Form you can derive new related forms from it automatically UFL defines a set of common form transformations described in this section 2 13 1 Replacing arguments of a Form The function replace lets you replace terminal objects with other values using a mapping defined by a Python dict This can be used for example to replace a Function with a fixed value for optimized runtime evaluation f Function element g Function element c Constant cell a f g v dx b replace a 1 f 3 14 g c The replacement values must have the same basic properties as the original values in particular value shape and free indices 2 13 2 Action of a form on a function The action of a bilinear form a is defined as b v w alv w 50 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg The action of a linear form L is defined as fw L w This operation is implemented in UFL simply by replacing the rightmost basis function trial function for a test function for L in a Form an
53. erned by this License without regard to the additional permissions When you convey a copy of a covered work you may at your option remove any additional permissions from that copy or from any part of it Additional permissions may be written to require their own removal in certain cases when you modify the work You may place additional permissions on material added by you to a covered work for which you have or can give appropriate copyright permission Notwithstanding any other provision of this License for material you add to a covered work you may if authorized by the copyright holders of that material supplement the terms of this License with terms a Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License or b Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it or c Prohibiting misrepresentation of the origin of that material or requiring that modified versions of such material be marked in reasonable ways as different from the original version or d Limiting the use for publicity purposes of names of licensors or authors of the material or 109 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg e Declining to grant rights under trademark law for use of some trade names trademarks or service marks or f Requiring i
54. ew problems or concerns Each version is given a distinguishing version number If the Program specifies that a certain numbered version of the GNU General Public License or any later version applies to it you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation If the Program does not specify a version number of the GNU General Public License you may choose any version ever published by the Free Software Foundation If the Program specifies that a proxy can decide which future versions of the GNU General Public License can be used that proxy s public statement of acceptance of a version permanently authorizes you to choose that version for the Program Later license versions may give you additional or different permissions However no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version 15 Disclaimer of Warranty THERE IS NO WARRANTY FOR THE PROGRAM TO THE EXTENT PERMITTED BY APPLICABLE LAW EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND OR OTHER PARTIES PROVIDE THE PROGRAM AS IS WITHOUT WARRANTY OF ANY KIND EITHER EXPRESSED OR IMPLIED INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU SHOULD THE PROGRAM
55. favor of coverage For a particular product received by a particular user normally used refers to a typical or common use of that class of product regardless of the status of the particular user or of the way in which the particular user actually uses or expects or is expected to use the product A product is a consumer product regardless of whether the product has substantial commercial industrial or non consumer uses unless such uses represent the only significant mode of use of the product Installation Information for a User Product means any methods procedures authorization keys or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made If you convey an object code work under this section in or with or specifically for use in a User Product and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term regardless of how the transaction is characterized the Corresponding Source conveyed under this section must be accompanied by the Installation Information But this requirement does not apply if neither you nor any third party retai
56. forms included with the UFL source distribution 3 8 Mixed formulation of Poisson We next consider the following formulation of Poisson s equation as a pair of first order equations for H div and u La o Vu 0 3 17 Vig f 3 18 We multiply the two equations by a pair of test functions 7 and w and integrate by parts to obtain the following variational problem Find u V H div x La such that a 7 w o u L 7 w V r w V 3 19 where al r w e u 707 rutuy ode 3 20 Lira f Jo fdz 3 21 We may implement the corresponding forms in our form language using first order BDM H div conforming elements for and piecewise constant L conforming elements for u as follows 68 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg cell triangle BDM1 FiniteElement Brezzi Douglas Marini cell 1 DGO FiniteElement Discontinuous Lagrange cell 0 element BDM1 DGO tau w TestFunctions element sigma u TrialFunctions element f Function DGO dot tau sigma div tau u w div sigma dx L w f dx w Il This example is implemented in the file mixed_poisson ufl in the collection of demonstration forms included with the UFL source distribution 3 9 Poisson s equation with DG elements We consider again Poisson s equation but now in an interior penalty dis continuous Galerkin formulation Find u
57. g the chain rule we can differentiate the integrand automatically The notation here has potential for improvement feel free to ask if something is unclear or suggest improvements 2 13 7 Combining form transformations Form transformations can be combined freely Note that to do this deriva tives are usually be evaluated before applying e g the action of a form because derivative changes the arity of the form element FiniteElement CG cell 1 w Function element 57 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg w 4 4 dx 0 inner grad w grad w dx 1 derivative f w derivative F w Ja action J w Jp adjoint J Jpa action Jp w g Function element Jnorm energy_norm J g Ga j i TODO Find some more examples e g from error control 2 14 Tuple Notation In addition to the standard integrand notation described above UFL sup ports a simplified tuple notation by which L inner products may be ex pressed as tuples Consider for example the following bilinear form as part of a variational problem for a reaction diffusion problem a v u Vu Vu vudzx Q Vv Vu v u In standard UFL notation this bilinear form may be expressed as a inner grad v grad u dx v u dx In tuple notation this may alternatively be expressed as a grad v grad u v u In general a form may be expressed as a su
58. ght also means copyright like laws that apply to other kinds of works such as semiconductor masks The Program refers to any copyrightable work licensed under this License Each licensee is addressed as you Licensees and recipients may be individuals or organizations To modify a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission other than the making of an exact copy The resulting work is called a modified version of the earlier work or a work based on the earlier work A covered work means either the unmodified Program or a work based on the Program To propagate a work means to do anything with it that without permission would make you directly or secondarily liable for infringement under applicable copyright law except executing it on a computer or modifying a private copy Propagation includes copying distribution with or without modification making available to the public and in some countries other activities as well To convey a work means any kind of propagation that enables other parties to make or receive copies Mere interaction with a user through a computer network with no transfer of a copy is not conveying An interactive user interface displays Appropriate Legal Notices to the extent that it includes a convenient and prominently visible feature that 1 displays an appropriate copyright notice and 2 tells the user that there is no warra
59. h for the beginning and the advanced user There is also some useful information for developers More advanced topics are treated at the end of the manual or in the appendix Typographic conventions e Code is written in monospace typewriter like this e Commands that should be entered in a Unix shell are displayed as follows configure make Commands are written in the dialect of the bash shell For other shells such as tcsh appropriate translations may be needed 11 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg Enumeration and list indices Throughout this manual elements x of sets x of size n are enumerated from i 0 toi n 1 Derivatives in R are enumerated similarly e e Bag Oa Gena Contact Comments corrections and contributions to this manual are most welcome and should be sent to ufl dev fenics org 12 Chapter 1 Introduction The Unified Form Language UFL is a domain specific language for defining discrete variational forms and functionals in a notation close to pen and paper formulation UFL 2 is part of the FEniCS project 4 and is usually used in combination with other components from this project to compute solutions to partial differential equations The form compilers FFC 6 and SFC 1 use UFL as their end user interface producing implementations of the UFC 3 interface as their output See the DOLFIN m
60. his example Geometric dimension d cell d d x d identiy matrix I Identity d Kronecker delta delta_ij I i j Advanced Note that there are some differences from FFC In particular using FacetNormal or cell n does not implicitly add another coefficient Function to the form the normal should be automatically computed in UFC code Note also that MeshSize has been removed because the meaning is ambiguous does it mean min max avg cell radius so use a Constant instead 28 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 2 5 Indexing and tensor components UFL supports index notation which is often a convenient way to express forms The basic principle of index notation is that summation is implicit over indices repeated twice in each term of an expression The following examples illustrate the index notation assuming that each of the variables i and j have been declared as a free Index n 1 vlil wlil lt gt ui V w 2 2 i 0 d 1 Ov Ow Dx v i Dx w i gt AN Vv Vu 2 3 f a Ov Dx v il i 5 TA Vv 2 4 i 0 i n 1 d 1 Dx v i j Dx w i j a Vv Vw 2 5 i 320 Ox OL Here we ll try to very briefly summarize the basic concepts of tensor algebra and index notation just enough to express the operators in UFL Assuming an Euclidean space in d dimensions with d 1 2 or 3 anda set of orthonormal basis vectors i for i 0
61. ints for quadrature elements and let the form compiler choose a quadrature rule This way the form depends less on the cell in use We consider here a nonlinear version of the Poisson s equation to illustrate the main point of the Quadrature finite element family The strong equation looks as follows V 1 w Vu f 3 23 The linearised bilinear and linear forms for this equation a v u Uo i uZ Vu Vudz 1 2uyuVo Vugdx 3 24 o o L v uo f f v fdz fo u2 Vu Vuo dz 3 25 o Q can be implemented in a single form file as follows NonlinearPoisson ufl element FiniteElement Lagrange triangle 1 v TestFunction element TrialFunction element u0 Function element f Function element a 1 u0 2 dot grad v grad u dx 2 u0 u dot grad v grad u0 dx L v f dx 1 u0 2 dot grad v grad u0 dx Here uy represents the solution from the previous Newton Raphson iteration The above form will be denoted REF1 and serve as our reference implemen tation for linear elements A similar form REF2 using quadratic elements will serve as a reference for quadratic elements Now assume that we want to treat the quantities C 1 u2 and oo 1 1u5 Vuy as given functions to be computed elsewhere Substituting into 71 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg bilinear linear forms we obtain a v u f CVv Vudz f 2uou Vv Vuo dz 3 26
62. ions are provided explicitly which is some times necessary e g if part of the form is linearlized manually like in TODO An example that makes sense would be nicer this is just a random form Function element inner grad w grad w dx derivative f w v dot w g v dx derivative F w u G HW Sog Il Derivatives can also be computed w r t functions in mixed spaces Con sider this example an implementation of the harmonic map equations using automatic differentiation X VectorElement Lagrange cell 1 Y FiniteElement Lagrange cell 1 x Function X y Function Y L inner grad x grad x dx dot x x y dx F derivative L x y J derivative F x y Here L is defined as a functional with two coefficient functions x and y from separate finite element spaces However F and J become linear and bilinear forms respectively with basis functions defined on the mixed finite element 59 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg M X Y There is a subtle difference between defining x and y separately and this alternative implementation reusing the elements X Y M u Function M x y split u L inner grad x grad x dx dot x x y dx F derivative L u J derivative F u The difference is that the forms here have one coefficient function u in the mixed space and the forms above have two coefficient funct
63. ions x and y TODO Move this to implementation part If you wonder how this is all done a brief explanation follows Recall that a Function represents a sum of unknown coefficients multiplied with unknown basis functions in some finite element space w x Y wede 2 2 50 Also recall that a BasisFunction represents any unknown basis function in some finite element space v x x Ok E Vh 2 51 A form L v w implemented in UFL is intended for discretization like bi L di Swede Yi Vr 2 52 k The Jacobi matrix Aj of this vector can be obtained by differentiation of b w r t wj which can be written Fi al r s Sunde WO EVa Vj Ve 2 53 k ij j dwj 56 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg for some form a In UFL the form a can be obtained by differentiating L To manage this we note that as long as the domain 2 is independent of Wj i commutes with de and we can differentiate the integrand expression instead e g Bin Ilo w dot f 1000 ds 2 54 d dl dIe L v w f dz 4 f ds 2 55 dwj Q dwj an dw In addition we need that dw Vo Vh 2 56 dw 0 j h which in UFL can be represented as w Function element 2 57 v BasisFunction element 2 58 dw oe 2 since w represents the sum and v represents any and all basis functions in Vh Other operators have well defined derivatives and by repeatedly applyin
64. ise that contradict the conditions of this License they do not excuse you from the conditions of this License If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations then as a consequence you may not convey it at all For example if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program 13 Use with the GNU Affero General Public License Notwithstanding any other provision of this License you have permission to link or combine any covered work with a work licensed under version 3 of the GNU Affero General Public License into a single combined work and to convey the resulting work The terms of this License will continue to apply to the part which is the covered work 113 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg but the special requirements of the GNU Affero General Public License section 13 concerning interaction through a network will apply to the combination as such 14 Revised Versions of this License The Free Software Foundation may publish revised and or new versions of the GNU General Public License from time to time Such new versions will be similar in spirit to the present version but may differ in detail to address n
65. lemented as follows element FiniteElement Lagrange triangle 1 66 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg v TestFunction element Test function ul TrialFunction element Value at t_n u0 Function element Value at t_n 1 c Function element Heat conductivity f Function element Heat source k Constant triangle Time step a veul dx k xc dot grad v grad ul dx L v xu0 dx k v fx dx This example is implemented in the file heat uf1 in the collection of demon stration forms included with the UFL source distribution 3 7 Mixed formulation of Stokes To solve Stokes equations Agr Vp 3 13 V u 0 3 14 we write the variational problem in standard form a v u L v for all v to obtain the following pair of bilinear and linear forms a v q u p vor Vu V v p a u ae 3 15 Lv gif IES 3 16 Using a mixed formulation with Taylor Hood elements this can be imple mented as follows cell triangle P2 VectorElement Lagrange cell 2 P1 FiniteElement Lagrange cell 1 TH P2 P1 67 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg v q TestFunctions TH u p TrialFunctions TH f Function P2 a inner grad v grad u div v p q div u dx L dot v f xdx This example is implemented in the file stokes ufl in the collection of demonstration
66. m of tuples or triples of the form 58 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg v w v w dm where v and w are expressions of matching rank so that inner v w makes sense and dm is a measure If the measure is left out it is assumed that it is dx The following example illustrates how to express a form containing integrals over subdomains and facets a grad v grad u v b grad u dx 2 v u ds jump v jump u ds The following caveats should be noted e The only operation allowed on a tuple is addition In particular tuples may not subtracted Thus a grad v grad u v u must be expressed as a grad v grad u v u e Tuple notation may not be mixed with standard UFL integrand no tation Thus a grad v grad u inner v u dx is not valid Advanced Tuple notation is strictly speaking not a part of the form language but tuples may be converted to UFL forms using the function tuple2form available from the module uf1 algorithms This is normally handled automatically by form compilers but the tuple2form utility may useful when working with UFL from a Python script Automatic conversion is also carried out by UFL form operators such as 1hs and rhs 2 15 Form Files UFL forms and elements can be collected in a form file with the extension uf1 Form compilers will typically execute this file with the global UFL 99
67. n s Anders Logg 2 5 3 Making tensors from components If you have expressions for scalar components of a tensor and wish to convert them to a tensor there are two ways to do it If you have a single expression with free indices that should map to tensor axes like mapping vz to v or Aj to A the following examples show how this is done vk Identity cell d 0 k v as_tensor vk k Aij vlil u jl A as_tensor Aij i j Here v will represent unit vector iy and A will represent the outer product of v and u If you have multiple expressions without indices you can build tensors from them just as easily as illustrated here v as_vector 1 0 2 0 3 0 A as_matrix u 0 0 0 uf1 B as_matrix a b for b in range 2 for a in range 2 Here v A and B will represent the expressions vV io 211 dis 2 12 _ Uo 0 A k a 2 13 0 1 ei 0239 Note that the function as_tensor generalizes from vectors to tensors of ar bitrary rank while the alternative functions as_vector and as matrix work the same way but are only for constructing vectors and matrices They are included for readability and convenience only 33 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 2 5 4 Implicit summation Implicit summation can occur in only a few situations A product of two terms that shares the same free index is implicitly treated as a sum over that free index
68. ndemnification of licensors and authors of that material by anyone who conveys the material or modified versions of it with contractual assumptions of liability to the recipient for any liability that these contractual assumptions directly impose on those licensors and authors All other non permissive additional terms are considered further restrictions within the meaning of section 10 If the Program as you received it or any part of it contains a notice stating that it is governed by this License along with a term that is a further restriction you may remove that term If a license document contains a further restriction but permits relicensing or conveying under this License you may add to a covered work material governed by the terms of that license document provided that the further restriction does not survive such relicensing or conveying If you add terms to a covered work in accord with this section you must place in the relevant source files a statement of the additional terms that apply to those files or a notice indicating where to find the applicable terms Additional terms permissive or non permissive may be stated in the form of a separately written license or stated as exceptions the above requirements apply either way 8 Termination You may not propagate or modify a covered work except as expressly provided under this License Any attempt otherwise to propagate or modify it is void and will automatically
69. ndices 4 P q r s indices 4 Advanced Note that in the old FFC notation the definition i Index 0 meant that the value of the index remained constant This does not mean the same in UFL and this notation is only meant for internal usage Fixed indices are simply integers instead 31 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 2 5 2 Taking components of tensors Basic fixed indexing of a vector valued expression v or matrix valued expres sion A e v 0 component access representing the scalar value of the first com ponent of v e A 0 1 component access representing the scalar value of the first row second column of A Basic indexing e vlil component access representing the scalar value of some compo nent of v e A i j component access representing the scalar value of some com ponent i j of A More advanced indexing e A i 0 component access representing the scalar value of some com ponent i of the first column of A e A i row access representing some row i of A i e rank Ali jl e A j column access representing some column j of A i e rank A j e C 0 subtensor access representing the subtensor of A with the last axis fixed e g A 0 A 0 e C j subtensor access representing the subtensor of A with the last axis fixed e g Alj A j 32 UFL Specification and User Manual 0 3 Martin S Al
70. ns the ability to install modified object code on the User Product for example the work has been installed in ROM The requirement to provide Installation Information does not include a requirement to continue to provide support service warranty or updates for a work that has been modified or installed by the recipient or for the User Product in which it has been modified or installed Access toa network may be denied when the modification itself materially and 108 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg adversely affects the operation of the network or violates the rules and protocols for communication across the network Corresponding Source conveyed and Installation Information provided in accord with this section must be in a format that is publicly documented and with an implementation available to the public in source code form and must require no special password or key for unpacking reading or copying 7 Additional Terms Additional permissions are terms that supplement the terms of this License by making exceptions from one or more of its conditions Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License to the extent that they are valid under applicable law If additional permissions apply only to part of the Program that part may be used separately under those permissions but the entire Program remains gov
71. nsorConstant cell These three lines are equivalent with first defining DGO elements and then defining a Function on each illustrated here DGO FiniteElement Discontinuous Lagrange cell 0 DGOv VectorElement Discontinuous Lagrange cell 0 DGOt TensorElement Discontinuous Lagrange cell 0 ci Function DGO vi Function DGOv t1 Function DGOt 2 4 Basic Datatypes UFL expressions can depend on some other quantities in addition to the functions and basis functions described above 2 4 1 Literals and geometric quantities Some atomic quantities are derived from the cell For example the global spatial coordinates are available as a vector valued expression cell x Linear form for a load vector with a sin y coefficient v TestFunction element 27 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg cell x sin x 1 vx dx POr moon Another quantity is the outwards pointing facet normal cell n The nor mal vector is only defined on the boundary so it can t be used in a cell integral Example functional M an integral of the normal component of a function g over the boundary n cell n g Function VectorElement CG cell 1 M dot n g ds Python scalars int float can be used anywhere a scalar expression is al lowed Another literal constant type is Identity which represents an n x n unit matrix of given size n as in t
72. nstallation is correct you may run the test suite Enter the sub directory test from within the UFL source tree and run the script test py python test py This script runs all unit tests and imports UFL in the process B 2 Debian Ubuntu package In preparation 100 Appendix C License UFL is free software you can redistribute it and or modify it under the terms of the GNU General Public License as published by the Free Software Foundation either version 3 of the License or at your option any later version The GNU GPL is included verbatim below GNU GENERAL PUBLIC LICENSE Version 3 29 June 2007 Copyright C 2007 Free Software Foundation Inc lt http fsf org gt Everyone is permitted to copy and distribute verbatim copies of this license document but changing it is not allowed Preamble The GNU General Public License is a free copyleft license for software and other kinds of works The licenses for most software and other practical works are designed to take away your freedom to share and change the works By contrast the GNU General Public License is intended to guarantee your freedom to share and change all versions of a program to make sure it remains free software for all its users We the Free Software Foundation use the GNU General Public License for most of our software it applies also to 101 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg any other
73. nty for the work except to the extent that warranties are provided that licensees may convey the work under this License and how to view a copy of this License If 103 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg the interface presents a list of user commands or options such as a menu a prominent item in the list meets this criterion 1 Source Code The source code for a work means the preferred form of the work for making modifications to it Object code means any non source form of a work A Standard Interface means an interface that either is an official standard defined by a recognized standards body or in the case of interfaces specified for a particular programming language one that is widely used among developers working in that language The System Libraries of an executable work include anything other than the work as a whole that a is included in the normal form of packaging a Major Component but which is not part of that Major Component and b serves only to enable use of the work with that Major Component or to implement a Standard Interface for which an implementation is available to the public in source code form A Major Component in this context means a major essential component kernel window system and so on of the specific operating system if any on which the executable work runs or a compiler used to produce the work or an object code interpreter used to
74. on element Vv u 61 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg a v eu dx This example is implemented in the file mass uf1 in the collection of demon stration forms included with the UFL source distribution 3 2 Poisson s equation The bilinear and linear forms form for Poisson s equation alv u ve Vudz 3 2 Q If f vfar 3 3 Q can be implemented as follows element FiniteElement Lagrange triangle 1 v TestFunction element u TrialFunction element f Function element a dot grad v grad u dx L v f dx Alternatively index notation can be used to express the scalar product like this a Dx v i Dx u i dx or like this 62 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg a v dx i u dx i dx This example is implemented in the file poisson uf1 in the collection of demonstration forms included with the UFL source distribution 3 3 Vector valued Poisson The bilinear and linear forms for a system of independent Poisson equa tions 2 MAR 2 e ee f Vu Vudz 3 4 Laf fosas 3 5 with v u and f vector valued can be implemented as follows element VectorElement Lagrange triangle 1 v TestFunction element u TrialFunction element f Function element a inner grad v grad u dx L dot v f x dx Alternatively index notation may be
75. perators and atomic expressions that can be used to express variational forms and functionals Below we will define all these operators and atomic expressions in detail UFL is built on top of or embedded in the high level language Python Since the form language is built on top of Python any Python code is valid in the definition of a form but not all Python code defines a multilinear form In particular comments lines starting with and functions keyword def see section 2 12 below are useful in the definition of a form However it is usually a good idea to avoid using advanced Python features in the form definition to stay close to the mathematical notation The entire form language can be imported in Python with the line from ufl import which is assumed in all examples below and can be omitted in uf1 files This can be useful for experimenting with the language in an interactive Python interpreter 15 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 2 1 Forms and Integrals UFL is designed to express forms in the following generalized format A Ur Wigs ag Wn 2 1 gt L V Uri W1 Wy de Ok Ne 5 i TO Ur W1 ces Wn ds IQ k ay lis 0 dS Ty Here the form a depends on the form arguments v v and the form coefficients W1 Wn and its expression is a sum of integrals Each term of a valid form expression must be a scalar valued expression integra
76. ples of BasisFunctions as illustrated here for a mixed Taylor Hood ele ment The term function in UFL maps to the term coefficient in UFC 24 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg BasisFunctions TH BasisFunctions TH eg Q For a BasisFunction on a MixedElement or VectorElement or TensorElement the function split can be used to extract basis function values on subspaces as illustrated here for a mixed Taylor Hood element vq BasisFunction TH v q split up A shorthand for this is in place called BasisFunctions v q BasisFunctions TH For convenience TestFunction and TrialFunction are special instances of BasisFunction with the property that a TestFunction will always be the first argument in a form and TrialFunction will always be the second argument in a form order of declaration does not matter Their usage is otherwise the same as for BasisFunction TestFunction element TrialFunction element TestFunctions TH TrialFunctions TH E lt FES q P gt 2 3 2 Coefficient functions The data type Function represents a function belonging to a given finite element space that is a linear combination of basis functions of the fi nite element space A Function must be declared for a previously declared FiniteElement 25 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg f Fun
77. r fashion in which only the element declaration is different QEiNonlinearPoisson ufl element FiniteElement Lagrange triangle 1 QE FiniteElement Quadrature triangle 2 sig VectorElement Quadrature triangle 2 QElTangent ufl element FiniteElement Lagrange triangle 1 QE FiniteElement Quadrature triangle 2 QElGradient ufl element FiniteElement Lagrange triangle 1 QE VectorElement Quadrature triangle 2 Note that we use 2 points when declaring the QuadratureElement This is because the RHS of the Tangent form is 2 order and therefore we need 2 points for exact integration Due to consistency issues when passing func tions around between the forms we also need to use 2 points when declaring the QuadratureElement in the other forms 73 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg Typical values of the relative residual for each Newton iteration for all 3 approaches are shown in Table 3 1 It is noted that the convergence rate is quadratic as it should be for all 3 methods Iteration REF1 FEI QE1 1 6 342e 02 6 342e 02 6 342e 02 2 5 305e 04 5 305e 04 5 305e 04 3 3 699e 08 3 699e 08 3 699e 08 4 2 925e 16 2 925e 16 2 475e 16 Table 3 1 Relative residuals for each approach for linear elements However if quadratic elements are used to interpolate the unknown field u
78. r exercise of rights granted under this License and you may not initiate litigation including a cross claim or counterclaim in a lawsuit alleging that any patent claim is infringed by making using selling offering for 111 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg sale or importing the Program or any portion of it 11 Patents A contributor is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based The work thus licensed is called the contributor s contributor version A contributor s essential patent claims are all patent claims owned or controlled by the contributor whether already acquired or hereafter acquired that would be infringed by some manner permitted by this License of making using or selling its contributor version but do not include claims that would be infringed only as a consequence of further modification of the contributor version For purposes of this definition control includes the right to grant patent sublicenses in a manner consistent with the requirements of this License Each contributor grants you a non exclusive worldwide royalty free patent license under the contributor s essential patent claims to make use sell offer for sale import and otherwise run modify and propagate the contents of its contributor version In the following three paragraphs a patent license is any express agreem
79. rcising rights under this License with respect to the covered work and you disclaim any intention to limit operation or modification of the work as a means of enforcing against the work s users your or third parties legal rights to forbid circumvention of technological measures 4 Conveying Verbatim Copies You may convey verbatim copies of the Program s source code as you receive it in any medium provided that you conspicuously and 105 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg appropriately publish on each copy an appropriate copyright notice keep intact all notices stating that this License and any non permissive terms added in accord with section 7 apply to the code keep intact all notices of the absence of any warranty and give all recipients a copy of this License along with the Program You may charge any price or no price for each copy that you convey and you may offer support or warranty protection for a fee 5 Conveying Modified Source Versions You may convey a work based on the Program or the modifications to produce it from the Program in the form of source code under the terms of section 4 provided that you also meet all of these conditions a The work must carry prominent notices stating that you modified it and giving a relevant date b The work must carry prominent notices stating that it is released under this License and any conditions added under section 7
80. rm transformations 57 2 14 Tuple Notation oc ncco t 24626 taae iae a 58 2 15 Form Files sc a uo de oe oo AAA AA 59 Example Forms 61 OA TDS MAE soaa a acd ee Renneke see eda 61 3 2 Poissons equation 2 61456464 See 000 we ees 62 oo Vector valued Poisson pce bay ee ina rad 63 3 4 The strain strain term of linear elasticity 64 3 5 The nonlinear term of Navier Stokes 65 3 6 The heat equation 6464 eb eRe EE ELS ee 9 66 3 7 Mixed formulation of Stokes 204 28284084464 67 3 8 Mixed formulation of Poisson 68 3 9 Poisson s equation with DG elements 69 3 10 Quadrature elements 0 000 eee ene 70 311 More Examples ck Go eke ESR EERE Ew ee EUR 74 4 Internal Representation Details 75 Al Structure ofa FOO oscar A 75 4 2 General properties of expressions 76 A oo Ge Sethe Sethe ees AEG AS 76 Llao Seconatrice es sake a Pete OS as e a 76 ee AE sg Boek ee be te ee ee ee ee Sp neh Bede TT A AAA TT 42 5 free indic s 2 sosea sam na aa eS re A26 inder dimensions s s oed eke whe es 77 A CUP se be cee Pee dbase ke wa ES SRS HERS TT ADS TOPE ya de hed aae na aa a a i TT BOM Bashin cosa dar dr 78 ARA o a a a a WR SH ae GU 78 4 2 11 About other relational Operators 78 A3 MS o ccc rad romia a a RES Se 78 cl PITA 79 4 5 Operators en ee hw SRR SRR Be Ee Re Se ee 79 AG Mendig UFL peg co ee ee ee oe RE Oe aE Eel ds 79
81. roduct of two tensors a and b can be written A outer a b The general definition of the outer product of two tensors C of rank r and D of rank s is C D Cig Ded Lg 0 a E 8 Le ia a Some examples with vectors and matrices are easier to understand veu viujiiij vV amp B v Brii ixi The outer product of vectors is often written simply as v amp u vu which is what we ve done with i i above 2 29 2 30 2 31 2 32 2 33 The rank of the outer product is the sum of the ranks of the operands 39 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 2 8 6 cross The operator cross accepts as arguments two logically vector valued expres sions and returns a vector which is the cross product vector product of the two vectors cross v w v X w vjW2 U2W1 VeWo VOW2 Vow ViWo 2 34 Note that this operator is only defined for vectors of length three 2 8 7 det The determinant of a matrix A can be written d det A 2 8 8 dev The deviatoric part of matrix A can be written B dev A 2 8 9 sym The symmetric part of A can be written B sym A The definition is 1 sym A A A 2 35 40 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 2 8 10 skew The skew symmetric part of A can be written B skew A The definition is 1 skew A 5 A7 2 36 2 8
82. ry can either be set to True which means standard matrix symmetry like Aj Aji or a dict like 0 1 1 0 0 2 2 0 where the dict keys are index tuples that are represented by the corresponding dict value Examples element TensorElement CG cell 2 element TensorElement DG cell 0 shape 6 6 element TensorElement DG cell 0 symmetry True element TensorElement DG cell 0 symmetry 0 0 1 1 2 2 6 Mixed Elements A MixedElement represents an arbitrary combination of other elements VectorElement and TensorElement are special cases of a MixedElement where all subelements are equal General notation for an arbitrary number of subelements element MixedElement elementi element2 element3 22 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg Shorthand notation for two subelements element elementi element2 NB Note that multiplication is a binary operator such that element elementi element2 element3 represents el e2 e3 i e this is a mixed element with two subele ments el e2 and e3 See section 2 3 for details on how defining functions on mixed spaces can differ from functions on other finite element spaces Examples Taylor Hood element V VectorElement Lagrange cell 2 P FiniteElement Lagrange cell 1 TH V P A tensor vector scalar element T Tensor
83. s in user code they also add yet another layer of abstraction which can make debugging more difficult when the need arises Many of the utilities described here can be useful in that regard 5 1 Formatting expressions Expressions can be formatted in various ways for inspection which is par ticularly useful for debugging We use the following as an example form for 81 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg the formatting sections below element FiniteElement CG triangle 1 v TestFunction element u TrialFunction element c Function element f Function element a cxux xv dx fx vx xds 5 1 1 str Compact human readable pretty printing Useful in interactive Python ses sions Example output of str a TODO 5 1 2 repr Accurate description of expression with the property that eval repr a a Useful to see which representation types occur in an expression espe cially if str a is ambiguous Example output of repr a TODO 5 1 3 Tree formatting Ascii tree formatting useful to inspect the tree structure of an expression in interactive Python sessions Example output of tree format a TODO 82 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg 5 1 4 BTgXformatting See chapter about commandline utilities 5 1 5 Dot formatting See chapter about commandline utilities 5 2 Inspecting and manipulating the expression tree
84. sed for example to linearize your nonlinear resid ual equation automatically or derive a linear system from a functional or compute sensitivity vectors w r t some coefficient A functional can be differentiated to obtain a linear form F v w F w dp w dw w 53 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg and a linear form can be differentiated to obtain the bilinear form corre sponding to its Jacobi matrix d J v u w Tag E w The UFL code to express this is for a simple functional f w f 5w dx f w 2 2 dx F derivative f w v J derivative F w u which is equivalent to Kh Il w 2 2 dx w v dx J uxvx xdx rj II Assume in the following examples that v TestFunction element u TrialFunction element w Function element The stiffness matrix can be computed from the functional Jo Vw Vwdz by the lines f inner grad w grad w 2 dx F derivative f w v J derivative F w u 5Note that by linear form we only mean a form that is linear in its test function not in the function you differentiate with respect to 54 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg which is equivalent to f inner grad w grad w 2 dx inner grad w grad v dx inner grad u grad v dx Il qa Il Note that here the basis funct
85. t Debian Ubuntu packages will be available in the future for UFL and other FEniCS compo nents B 1 Installing from source B 1 1 Dependencies and requirements UFL currently has no external dependencies apart from a working Python installation 97 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg Installing Python UFL is developed for Python 2 5 and does not work with previous versions To check which version of Python you have installed issue the command python V python V Python 2 5 1 If Python is not installed on your system it can be downloaded from http www python org Follow the installation instructions for Python given on the Python web page For Debian Ubuntu users the package to install is named python B 1 2 Downloading the source code TODO This section isn t yet correct UFL hasn t been released officially yet The latest release of UFL can be obtained as a tar gz archive in the down load section at http www fenics org Download the latest release of UFL for example ufl x y z tar gz and unpack using the command tar zxfv ufl x y z tar gz 98 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg This creates a directory uf1 x y z containing the UFL source code If you want the very latest version of UFL it can be accessed directly from the development repository through hg Mercurial
86. ted exactly once How to define form arguments and integrand expressions is detailed in the rest of this chapter Integrals are expressed through multiplication with a measure representing an integral over either of e the interior of the domain Q dz cell integral e the boundary 02 of Q ds exterior facet integral e the set of interior facets dS interior facet integral UFL declares the measures dx dz ds ds and dS dS As a basic example assume v is a scalar valued expression and consider the integral of v over the interior of 2 This may be expressed as a v dx and the integral of v over OQ is written as 16 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg a vx ds Alternatively measures can be redefined to represent numbered subsets of a domain such that a form can take on different expressions on different parts of the domain If c e0 and el are scalar valued expressions then a cxdx e0xds 0 elx ds 1 a fedo f cods er ds Q Oo 001 No C AQ 01 C OR Generalizing this further we end up with the expression 2 1 Note that the domain Q and its subdomains and boundaries are not known to UFL These will not enter the stage until you start using UFL in a problem solving environment like DOLFIN represents where Advanced A feature for advanced users is attaching metadata to integrals This can be used to define different q
87. the order of all elements in the above forms is increased by 1 This influ ences the convergence rate as seen in Table 3 2 Clearly using the standard FiniteElement leads to a poor convergence whereas the QuadratureElement still leads to quadratic convergence Iteration REF2 FE2 QE2 1 2 637e 01 3 910e 01 2 644e 01 2 1 052e 02 4 573e 02 1 050e 02 3 1 159e 05 1 072e 02 1 551e 05 4 1 081e 11 7 221e 04 9 076e 09 Table 3 2 Relative residuals for each approach for quadratic elements 3 11 More Examples Feel free to send additional demo form files for your favourite PDE to the UFL mailing list 74 Chapter 4 Internal Representation Details This chapter explains how UFL forms and expressions are represented in detail Most operations are mirrored by a representation class e g Sum and Product all which are subclasses of Expr You can import all of them from the submodule uf1 classes by from ufl classes import TODO Automate the construction of class hierarchy figures using ptex2tex 4 1 Structure of a Form TODO Add class relations figure with Form Integral Expr Terminal Op erator Each Form owns multiple Integral instances each associated with a different Measure An Integral owns a Measure and an Expr which represents the integrand expression The Expr is the base class of all expressions It has two direct subclasses Terminal and Operator 79
88. uadrature degrees for different terms in a form and to override other form compiler specific options separately for different terms a cO dx 0 metadata0 c1 dx 1 metadatal The convention is that metadata should be a dict with any of the following keys e integration_order Integer defining the polynomial order that should be integrated exactly This is a compilation hint and the form compiler is free to ignore this if for example exact integration is being used e ffc A dict with further FFC specific options see the FFC manual 17 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg e sfc A dict with further SFC specific options see the SFC manual e Other string A dict with further options specific to some other external code Other standardized options may be added in later versions metadata0 ffc representation quadrature metadatal integration_order 7 ffc representation tensor a v u dx 0 metadatal f v dx 0 metadata2 2 2 Finite Element Spaces Before we can explain how form arguments are declared we need to show how to define function spaces UFL can represent very flexible general hierarchies of mixed finite elements and has predefined names for most common element families 2 2 1 Cells A polygonal cell is defined by a basic shape and a degree written like cell Cell shape degree Valid shapes ar
89. unctions are also available their meaning mostly ob vious e abs f the absolute value of f e sign f the sign of f 1 or 1 e pow f g or f g e sqrt f e exp f 35 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg e in f e cos f e sin f These functions do not accept non scalar operands or operands with free indices or BasisFunction dependencies 2 8 Tensor Algebra Operators 2 8 1 transpose The transpose of a matrix A can be written as AT transpose A AT A T AT as_matrix A i jl j i The definition of the transpose is ATLi j gt AP A 2 15 ji For transposing higher order tensor expressions index notation can be used AT as_tensor A i j k 1 1 k j i 2 8 2 tr The trace of a matrix A is the sum of the diagonal entries This can be written as 36 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg tr A A i il ct ct Wool The definition of the trace is n 1 i 0 2 8 3 dot The dot product of two tensors a and b can be written General tensors f dot a b Vectors a and b f alil b i Matrices a and b f as_matrix ali k b k j i j The definition of the dot product of unit vectors is where 0 is the Kronecker delta as explained earlier The dot product of higher order tensors follow from this as illustrated with the following exam ples An example
90. valent access to the Corresponding Source in the same way through the same place at no further charge You need not require recipients to copy the Corresponding Source along with the object code If the place to copy the object code is a network server the Corresponding Source may be on a different server operated by you or a third party that supports equivalent copying facilities provided you maintain clear directions next to the object code saying where to find the Corresponding Source Regardless of what server hosts the Corresponding Source you remain obligated to ensure that it is available for as long as needed to satisfy these requirements e Convey the object code using peer to peer transmission provided 107 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d A separable portion of the object code whose source code is excluded from the Corresponding Source as a System Library need not be included in conveying the object code work A User Product is either 1 a consumer product which means any tangible personal property which is normally used for personal family or household purposes or 2 anything designed or sold for incorporation into a dwelling In determining whether a product is a consumer product doubtful cases shall be resolved in
91. with two vectors v u v 1 uji viuj ii iz UU 70i UU 3 Assuming an orthonormal basis for a Euclidean space 37 2 18 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg An example with a tensor of rank two A B Ajjisi Brisis 2 19 Ajj Bui ii ij 1 1 2 20 Ai Brad jx ists 2 21 Aix Bradid 2 22 This is the same as to matrix matrix multiplication An example with a vector and a tensor of rank two v A vji Arigi 2 23 uA Meri 2 24 vj Ajdj i 2 25 vp Ani 2 26 This is the same as to vector matrix multiplication This generalizes to tensors of arbitrary rank The dot product applies to the last axis of a and the first axis of b The tensor rank of the product is rank a rank b 2 2 8 4 inner The inner product is a contraction over all axes of a and b that is the sum of all componentwise products The operands must have the exact same dimensions For two vectors it is equivalent to the dot product If A and B are rank 2 tensors and C and D are rank 3 tensors their inner products are Using UFL notation the following pairs of declarations are equivalent 38 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg H Vectors f inner a b f v i b i Matrices f inner A B Ali j Bli j Il Rank 3 tensors f inner C D Cli j k DLli j k Il 2 8 5 outer The outer p
92. work released this way by its authors You can apply it to your programs too When we speak of free software we are referring to freedom not price Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software and charge for them if you wish that you receive source code or can get it if you want it that you can change the software or use pieces of it in new free programs and that you know you can do these things To protect your rights we need to prevent others from denying you these rights or asking you to surrender the rights Therefore you have certain responsibilities if you distribute copies of the software or if you modify it responsibilities to respect the freedom of others For example if you distribute copies of such a program whether gratis or for a fee you must pass on to the recipients the same freedoms that you received You must make sure that they too receive or can get the source code And you must show them these terms so they know their rights Developers that use the GNU GPL protect your rights with two steps 1 assert copyright on the software and 2 offer you this License giving you legal permission to copy distribute and or modify it For the developers and authors protection the GPL clearly explains that there is no warranty for this free software For both users and authors sake the GPL requires that modified versions be marked as
93. zed as in a linear datastructure do not confuse this with automatic differenti ation 88 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg TODO Consider the expression F a b x c d 5 1 where a b c d are arbitrary scalar expressions The expression tree for f looks like this TODO Make figures In UFL f is represented like this expression tree If a b c d are all distinct Function instances the UFL representation will look like this Function Function Function Function N Node Sum Sum 2g Product If we instead have the expression f a b x a b 5 2 the tree will in fact look like this with the functions a and b only represented once Function Function 89 UFL Specification and User Manual 0 3 Martin S Aln s Anders Logg Sum Product IntValue 1 Product Sum The expression tree is a directed acyclic graph DAG where the vertices are Expr instances and each edge represents a direct dependency between two vertices i e that one vertex is among the operands of another A graph can also be represented in a linearized data structure consisting of an array of vertices and an array of edges This representation is convenient for many algorithms An example to illustrate this graph representation G V E a b atb c d c d a b c d 6 2 6 5 5 3 5 4 2 0 2 1 ea lt No
Download Pdf Manuals
Related Search
Related Contents
invitation 2012 LiteComply User Guide SSYYSSTTEEMMEE AAUUDDIIOO SSAANNSS FFIILL Rotel RP-860 User's Manual KEIHIN PE24 キャブレターキット 取扱説明書 Phonix S7000BPA mobile phone case attention User Manual Oracle FLEXCUBE Development Workbench for Direct Copyright © All rights reserved.
Failed to retrieve file