DOLFIN User Manual - FEniCS Project

DOLFIN User Manual - FEniCS Project DOLFIN User Manual - FEniCS Project

fenicsproject.org
from fenicsproject.org More from this publisher
12.07.2015 Views

DOLFIN User ManualHoffman, Jansson, Logg, Wellsof a Stokes or Navier-Stokes system (with U the vector-valued velocity andP the scalar pressure), the following example illustrates how to pick subfunctions and components of w:Function w; // mixed Function (U, P)U = w[0]; // first sub function (velocity)P = w[1]; // second sub function (pressure)U0 = U[0]; // first component of the velocityU1 = U[1]; // second component of the velocityU2 = U[2]; // third component of the velocityNote that picking a component or sub function creates a new Function thatshares data with the original Function.5.1.5 OutputA Function can be written to a file in various file formats. To write aFunction u to file in VTK format, suitable for viewing in ParaView orMayaVi, create a file with extension .pvd:File file(‘‘solution.pvd’’);file

DOLFIN User ManualHoffman, Jansson, Logg, Wellslinear combinations of basis functions:v =N∑v i φ i , (5.1)i=1where {φ i } N i=1 is the global basis of the finite element space defined by theMesh and the FiniteElement, and the nodal values {v i } N i=1 are given by thevalues of a Vector.Note that a discrete Function may not be evaluated at arbitrary points (onlyat each Vertex of a Mesh).5.2.1 Creating a discrete functionA discrete Function can be initialized in several ways. In the simplest case,only a Vector x of nodal values needs to be specified:Vector x;Function f(x);If possible, DOLFIN will then automatically try to determine the Mesh andthe FiniteElement.In some cases, it is necessary to also supply a Mesh when initializing a discreteFunction:Vector x;Mesh mesh;Function f(x, mesh);If possible, DOLFIN will then automatically try to determine the FiniteElement.37

<strong>DOLFIN</strong> <strong>User</strong> <strong>Manual</strong>Hoffman, Jansson, Logg, Wellsof a Stokes or Navier-Stokes system (with U the vector-valued velocity andP the scalar pressure), the following example illustrates how to pick subfunctions and components of w:Function w; // mixed Function (U, P)U = w[0]; // first sub function (velocity)P = w[1]; // second sub function (pressure)U0 = U[0]; // first component of the velocityU1 = U[1]; // second component of the velocityU2 = U[2]; // third component of the velocityNote that picking a component or sub function creates a new Function thatshares data with the original Function.5.1.5 OutputA Function can be written to a file in various file formats. To write aFunction u to file in VTK format, suitable for viewing in ParaView orMayaVi, create a file with extension .pvd:File file(‘‘solution.pvd’’);file

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!