Reference

Particle Generators

class ParticleGenerator.RandomRectangle(ll, ur)

Overloads the RandomGenerator class for generating random particle locations within a rectangular object.

__init__(ll, ur)

Initialize Random Rectangle object.

Parameters:
  • ll (dolfin.Point) – Point containing lower-left x and y coordinate of rectangle.
  • ur (dolfin.Point) – Point containing upper-right x and y coordinate of rectangle.
generate(N, method='full')

Generate points

Parameters:
  • N (int) – Number of points to generate.
  • method (str, optional) – Method that is used for generating the random point locations either “full” or “tensor”. Defaults to “full”
Returns:

Numpy array of generated points.

Return type:

np.array

class ParticleGenerator.RandomCircle(center, radius)

Overloads the RandomGenerator class for generating random particle locations within a rectangular object.

__init__(center, radius)

Initialize RandomCircle class

Parameters:
  • center (Point, list, np.ndarray) – Center coordinates
  • radius (float) – Radius of circle
generate(N, method='full')

Generate points

Parameters:
  • N (int) – Number of points to generate.
  • method (str, optional) – Method that is used for generating the random point locations either “full” or “tensor”. Defaults to “full”
Returns:

Numpy array of generated points.

Return type:

np.array

class ParticleGenerator.RandomBox(ll, ur)

Overloads the RandomGenerator class for generating random particle locations within a box-shaped object.

__init__(ll, ur)

Initialize RandomBox object.

Parameters:
  • ll (dolfin.Point) – Lower left coordinate of box
  • ur (dolfin.Point) – Upper left coordinate of box
generate(N, method='full')

Generate points

Parameters:
  • N (int) – Number of points to generate.
  • method (str, optional) – Method that is used for generating the random point locations either “full” or “tensor”. Defaults to “full”
Returns:

Numpy array of generated points.

Return type:

np.array

class ParticleGenerator.RandomSphere(center, radius)

Overloads the RandomGenerator class for generating random particle locations within a sphere.

__init__(center, radius)

Initialize RandomSphere object.

Parameters:
  • center (dolfin.Point) – Center coordinates of sphere.
  • radius (float) – Radius of sphere
generate(N, method='full')

Generate points

Parameters:
  • N (int) – Number of points to generate.
  • method (str, optional) – Method that is used for generating the random point locations either “full” or “tensor”. Defaults to “full”
Returns:

Numpy array of generated points.

Return type:

np.array

class ParticleGenerator.RegularRectangle(ll, ur)

Class for generating points on a regular lattice in a rectangle

__init__(ll, ur)

Initialize RegularRectangle object.

Parameters:
  • ll (dolfin.Point) – Lower left corner of rectangle
  • ur (dolfin.Point) – Upper right corner of rectangle
generate(N, method='open')

Generate points on regular lattice in rectangle.

Parameters:
  • N (list) – Number of points to generate in each dimension
  • method (str, optional) – Which method to use. Either “open” [endpoints not included], “closed” [endpoints included] or “half open”
Returns:

Numpy array with coordinates

Return type:

np.ndarray

class ParticleGenerator.RegularBox(ll, ur)

Class for generating points on a regular lattice in a box

__init__(ll, ur)

Initialize RegularBox instance.

Parameters:
  • ll (dolfin.Point) – Lower left coordinate of regular box.
  • ur (dolfin.Point) – Upper right coordinate of regular box.
generate(N, method='open')

Generate points on regular lattice in box.

Parameters:
  • N (list) – Number of points to generate in each dimension
  • method (str, optional) – Which method to use. Either “open” [endpoints not included], “closed” [endpoints included] or “half open”
Returns:

Numpy array with coordinates

Return type:

np.ndarray

class ParticleGenerator.RandomCell(mesh)

Generate random particle locations within a dolfin.cell (as yet, only simplicial meshes supported).

__init__(mesh)

Initialize RandomCell generator

Parameters:mesh (dolfin.Mesh) – Mesh on which to generate particles.
generate(N)

Generate a random set of N points per cell.

Parameters:N (int) – Number of points per cell.
Returns:Coordinate array of points.
Return type:np.ndarray

Particles

class ParticleFun.particles(xp, particle_properties, mesh)

Python interface to cpp::particles.h

__init__(xp, particle_properties, mesh)

Initialize particles.

Parameters:
  • xp (np.ndarray) – Particle coordinates
  • particle_properties (list) – List of np.ndarrays with particle properties.
  • mesh (dolfin.Mesh) – The mesh on which the particles will be generated.
interpolate(*args)

Interpolate field to particles. Example usage for updating the first property of particles. Note that first slot is always reserved for particle coordinates!

p.interpolate(psi_h , 1)
Parameters:
  • psi_h (dolfin.Function) – Function which is used to interpolate
  • idx (int) – Integer value indicating which particle property should be updated.
increment(*args)

Increment particle at particle slot by an incrementatl change in the field, much like the FLIP approach proposed by Brackbill

The code to update a property psi_p at the first slot with a weighted increment from the current time step and an increment from the previous time step, can for example be implemented as:

#  Particle
p=particles(xp,[psi_p , dpsi_p_dt], msh)

#  Incremental update with  theta =0.5, step=2
p.increment(psih_new , psih_old ,[1, 2], theta , step
Parameters:
  • psih_new (dolfin.Function) – Function at new timestep
  • psih_old (dolfin.Function) – Function at old time step
  • slots (list) – Which particle slots to use? list[0] is always the quantity that will be updated
  • theta (float, optional) – Use weighted update from current increment and previous increment/ theta = 1: only use current increment theta = 0.5: average of previous increment and current increment
  • step (int) – Which step are you at? The theta=0.5 increment only works from step >=2
return_property(mesh, index)

Return particle property by index.

FIXME: mesh input argument seems redundant.

Parameters:
  • mesh (dolfin.Mesh) – Mesh
  • index (int) – Integer index indicating which particle property should be returned.
Returns:

Numpy array which stores the particle property.

Return type:

np.array

number_of_particles()

Get total number of particles

Returns:Global number of particles
Return type:int

Forms PDE-constrained projection

class FormsPDEMap.FormsPDEMap(mesh, FuncSpace_dict, beta_map=<sphinx.ext.autodoc.importer._MockObject object>, ds=<sphinx.ext.autodoc.importer._MockObject object>)

” Class for defining the forms related to the PDE-constrained projection

Attributes:

W

Function space for the local unknown

Type:dolfin.FunctionSpace
T

FunctionSpace for the Lagrange multiplier space

Type:dolfin.FunctionSpace
Wbar

Function space for the control variable

Type:dolfin.FunctionSpace
n

Symbolic facet normal for mesh

Type:dolfin.FacetNormal
beta_map

Penalty/Regularizatio term to establish coupling between local unknown and control

Type:dolfin.Constant
ds

ds Measure of mesh

Type:dolfin.Measure
gdim

Geometric dimension of mesh

Type:int
__init__(mesh, FuncSpace_dict, beta_map=<sphinx.ext.autodoc.importer._MockObject object>, ds=<sphinx.ext.autodoc.importer._MockObject object>)

Instantiate FormsPDEMap

Parameters:
  • mesh (dolfin.Mesh) – Dolfin Mesh
  • FuncSpace_dict (dict) –
    Dictionary containing the function space definitions. Following keys are required:
    • FuncSpace_local: function space for local variable
    • FuncSpace_lambda: function space for Lagrange multiplier
    • FuncSpace_bar: function space for control variable
  • beta_map (dolfin.Constant, optional) – Penalty/Regularizatio term to establish coupling between local unknown and control. Defaults to Constant(1e-6)
  • ds (dolfin.Measure, optional) – ds Measure of mesh
forms_theta_linear(psih0, uh, dt, theta_map, theta_L=<sphinx.ext.autodoc.importer._MockObject object>, dpsi0=<sphinx.ext.autodoc.importer._MockObject object>, dpsi00=<sphinx.ext.autodoc.importer._MockObject object>, h=<sphinx.ext.autodoc.importer._MockObject object>, neumann_idx=99, zeta=<sphinx.ext.autodoc.importer._MockObject object>)

Set PDEMap forms for a linear advection problem.

Parameters:
  • psih0 (dolfin.Function) – dolfin Function storing the solution from the previous step
  • uh (Constant, Expression, dolfin.Function) – Advective velocity
  • dt (Constant) – Time step value
  • theta_map (Constant) – Theta value for time stepping in PDE-projection according to theta-method NOTE theta only affects solution for Lagrange multiplier space polynomial order >= 1
  • theta_L (Constant, optional) – Theta value for reconstructing intermediate field from the previous solution and old increments. Defaults to Constan(1.)
  • dpsi0 (dolfin.Function, optional) – Increment function from last time step. Defaults to Constant(0)
  • dpsi00 (dolfin.Function) – Increment function from second last time step. Defaults to Constant(0)
  • h (Constant, dolfin.Function, optional) – Expression or Function for non-homogenous Neumann BC. Defaults to Constant(0.)
  • neumann_idx (int, optional) – Integer to use for marking Neumann boundaries. Defaults to value 99
  • zeta (Constant, optional) – Penalty parameter for limiting over/undershoot. Defaults to 0
Returns:

Dictionary with forms

Return type:

dict

forms_theta_nlinear(v0, Ubar0, dt, theta_map=<sphinx.ext.autodoc.importer._MockObject object>, theta_L=<sphinx.ext.autodoc.importer._MockObject object>, duh0=<sphinx.ext.autodoc.importer._MockObject object>, duh00=<sphinx.ext.autodoc.importer._MockObject object>, h=<sphinx.ext.autodoc.importer._MockObject object>, neumann_idx=99)

Set PDEMap forms for a non-linear (but linearized) advection problem,

Parameters:
  • v0 (dolfin.Function) – dolfin.Function storing solution from previous step
  • Ubar0 (dolfin.Function) – Advective velocity at facets
  • dt (Constant) – Time step
  • theta_map (Constant, optional) – Theta value for time stepping in PDE-projection according to theta-method. Defaults to Constant(1.) NOTE theta only affects solution for Lagrange multiplier space polynomial order >= 1
  • theta_L (Constant, optional) – Theta value for reconstructing intermediate field from the previous solution and old increments. Defaults to Constant(1.)
  • duh0 (dolfin.Function, optional) – Increment function from last time step
  • duh00 (dolfin.Function, optional) – Increment function from second last time step
  • h (Constant, dolfin.Function, optional) – Expression or Function for non-homogenous Neumann BC. Defaults to Constant(0.)
  • neumann_idx (int, optional) – Integer to use for marking Neumann boundaries. Defaults to value 99
Returns:

Dictionary with forms

Return type:

dict

forms_theta_nlinear_np(v0, v_int, Ubar0, dt, theta_map=<sphinx.ext.autodoc.importer._MockObject object>, theta_L=<sphinx.ext.autodoc.importer._MockObject object>, duh0=<sphinx.ext.autodoc.importer._MockObject object>, duh00=<sphinx.ext.autodoc.importer._MockObject object>, h=<sphinx.ext.autodoc.importer._MockObject object>, neumann_idx=99)

Set PDEMap forms for a non-linear (but linearized) advection problem, assumes however that the mass matrix can be obtained from the mesh (and not from particles)

NOTE Documentation upcoming.

forms_theta_nlinear_multiphase(rho, rho0, rho00, rhobar, v0, Ubar0, dt, theta_map, theta_L=<sphinx.ext.autodoc.importer._MockObject object>, duh0=<sphinx.ext.autodoc.importer._MockObject object>, duh00=<sphinx.ext.autodoc.importer._MockObject object>, h=<sphinx.ext.autodoc.importer._MockObject object>, neumann_idx=99)

Set PDEMap forms for a non-linear (but linearized) advection problem including density.

Parameters:
  • rho (dolfin.Function) – Current density field
  • rho0 (dolfin.Function) – Density field at previous time step.
  • rho00 (dolfin.Function) – Density field at second last time step
  • rhobar (dolfin.Function) – Density field at facets
  • v0 (dolfin.Function) – Specific momentum at old time level
  • Ubar0 (dolfin.Function) – Advective field at old time level
  • dt (Constant) – Time step
  • theta_map (Constant) – Theta value for time stepping in PDE-projection according to theta-method NOTE theta only affects solution for Lagrange multiplier space polynomial order >= 1
  • theta_L (Constant, optional) – Theta value for reconstructing intermediate field from the previous solution and old increments.
  • duh0 (dolfin.Function, optional) – Increment from previous time step.
  • duh00 (dolfin.Function, optional) – Increment from second last time step
  • h (Constant, dolfin.Function, optional) – Expression or Function for non-homogenous Neumann BC. Defaults to Constant(0.
  • neumann_idx (int, optional) – Integer to use for marking Neumann boundaries. Defaults to value 99
Returns:

Dict with forms

Return type:

dict

facet_integral(integrand)

Facet integral of mesh

Parameters:integrand (UFL) –
Returns:
Return type:UFL Form

Forms HDG Stokes

class FormsStokes.FormsStokes(mesh, FuncSpaces_L, FuncSpaces_G, alpha, beta_stab=<sphinx.ext.autodoc.importer._MockObject object>, ds=<sphinx.ext.autodoc.importer._MockObject object>)

Initializes the forms for the unsteady Stokes problem following Labeur and Wells (2012) and Rhebergen and Wells (2016,2017).

Note that we can easiliy change between the two formulations since pressure stabilization term required for Labeur and Wells (2012) formulation is supported.

It defines the forms in correspondence with following algebraic form:

|  A   B   C   D  | | Uh    |
|  B^T F   0   H  | | Ph    |    |Q|
|                 | |       | =  | |
|  C^T 0   K   L  | | Uhbar |    |S|
|  D^T H^T L^T P  | | Phbar |

With part above blank line indicating the contributions from local momentum- and local mass conservation statement respectively. Part below blank line indicates the contribution from global momentum and global mass conservation statement.

__init__(mesh, FuncSpaces_L, FuncSpaces_G, alpha, beta_stab=<sphinx.ext.autodoc.importer._MockObject object>, ds=<sphinx.ext.autodoc.importer._MockObject object>)

Initialize self. See help(type(self)) for accurate signature.

forms_steady(nu, f)

Steady Stokes

forms_unsteady(ustar, dt, nu, f)

Forms for Backward-Euler time integration

forms_multiphase(rho, ustar, dt, mu, f)

Forms for Backward-Euler time integration two-fluid formulation Stokes