Code Reference¶
dolfin_to_sparrays¶
problem_setups¶
-
problem_setups.
cyl3D_fems
(refinement_level=2, scheme='TH', strtobcsobs='', strtomeshfile='', strtophysicalregions='', bccontrol=False, verbose=False)[source]¶ dictionary for the fem items for the 3D cylinder wake
- which is
the 2D setup extruded in z-direction
with symmetry BCs at the z-walls
- Parameters
- scheme{None, ‘CR’, ‘TH’}
the finite element scheme to be applied, ‘CR’ for Crouzieux-Raviart, ‘TH’ for Taylor-Hood, overrides pdgree, vdgree, defaults to None
- bccontrolboolean, optional
whether to consider boundary control via penalized Robin defaults to False
- Returns
- fempa dictionary with the keys:
V: FEM space of the velocity
Q: FEM space of the pressure
diribcs: list of the (Dirichlet) boundary conditions
dirip: list of the (Dirichlet) boundary conditions for the pressure
fv: right hand side of the momentum equation
fp: right hand side of the continuity equation
charlen: characteristic length of the setup
odcoo: dictionary with the coordinates of the domain of observation
cdcoo: dictionary with the coordinates of the domain of control
uspacedep: int that specifies in what spatial direction Bu changes. The remaining is constant
bcsubdoms: list of subdomains that define the segments where the boundary control is applied
Notes
parts of the code were taken from the NSbench collection https://launchpad.net/nsbench
__author__ = “Kristian Valen-Sendstad <kvs@simula.no>”__date__ = “2009-10-01”__copyright__ = “Copyright (C) 2009-2010 ” + __author____license__ = “GNU GPL version 3 or any later version”
-
problem_setups.
cyl_fems
(refinement_level=2, vdgree=2, pdgree=1, scheme=None, inflowvel=1.0, bccontrol=False, verbose=False)[source]¶ dictionary for the fem items for the cylinder wake
- Parameters
- vdgreepolynomial degree of the velocity basis functions,
defaults to 2
- pdgreepolynomial degree of the pressure basis functions,
defaults to 1
- scheme{None, ‘CR’, ‘TH’}
the finite element scheme to be applied, ‘CR’ for Crouzieux-Raviart, ‘TH’ for Taylor-Hood, overrides pdgree, vdgree, defaults to None
- bccontrolboolean, optional
whether to consider boundary control via penalized Robin defaults to False
- Returns
- fempa dictionary with the keys:
V: FEM space of the velocity
Q: FEM space of the pressure
diribcs: list of the (Dirichlet) boundary conditions
dirip: list of the (Dirichlet) boundary conditions for the pressure
fv: right hand side of the momentum equation
fp: right hand side of the continuity equation
charlen: characteristic length of the setup
odcoo: dictionary with the coordinates of the domain of observation
cdcoo: dictionary with the coordinates of the domain of control
uspacedep: int that specifies in what spatial direction Bu changes. The remaining is constant
bcsubdoms: list of subdomains that define the segments where the boundary control is applied
Notes
TODO: inflowvel as input is there for consistency but not processed
parts of the code were taken from the NSbench collection https://launchpad.net/nsbench
__author__ = “Kristian Valen-Sendstad <kvs@simula.no>”__date__ = “2009-10-01”__copyright__ = “Copyright (C) 2009-2010 ” + __author____license__ = “GNU GPL version 3 or any later version”
-
problem_setups.
drivcav_fems
(N=10, vdgree=2, pdgree=1, scheme=None, bccontrol=None)[source]¶ dictionary for the fem items of the (unit) driven cavity
- Parameters
- Nint
mesh parameter for the unitsquare (N gives 2*N*N triangles)
- vdgreeint, optional
polynomial degree of the velocity basis functions, defaults to 2
- pdgreeint, optional
polynomial degree of the pressure basis functions, defaults to 1
- scheme{None, ‘CR’, ‘TH’}
the finite element scheme to be applied, ‘CR’ for Crouzieux-Raviart, ‘TH’ for Taylor-Hood, overrides pdgree, vdgree, defaults to None
- bccontrolboolean, optional
whether to consider boundary control via penalized Robin defaults to false. TODO: not implemented yet but we need it here for consistency
- Returns
- fempa dict
- of problem FEM description with the keys:
V: FEM space of the velocity
Q: FEM space of the pressure
diribcs: list of the (Dirichlet) boundary conditions
fv: right hand side of the momentum equation
fp: right hand side of the continuity equation
charlen: characteristic length of the setup
odcoo: dictionary with the coordinates of the domain of observation
cdcoo: dictionary with the coordinates of the domain of control
-
problem_setups.
gen_bccont_fems
(scheme='TH', bccontrol=True, verbose=False, strtomeshfile='', strtophysicalregions='', inflowvel=1.0, inflowprofile='parabola', movingwallcntrl=False, strtobcsobs='')[source]¶ dictionary for the fem items for a general 2D flow setup
- with
inflow/outflow
boundary control
- Parameters
- scheme{None, ‘CR’, ‘TH’}
the finite element scheme to be applied, ‘CR’ for Crouzieux-Raviart, ‘TH’ for Taylor-Hood, overrides pdgree, vdgree, defaults to None
- bccontrolboolean, optional
whether to consider boundary control via penalized Robin defaults to True
- movingwallcntrlboolean, optional
whether control is via moving boundaries
- Returns
- fempa dictionary with the keys:
V: FEM space of the velocity
Q: FEM space of the pressure
diribcs: list of the (Dirichlet) boundary conditions
dbcsinds: list vortex indices with (Dirichlet) boundary conditions
dbcsvals: list of values of the (Dirichlet) boundary conditions
dirip: list of the (Dirichlet) boundary conditions for the pressure
fv: right hand side of the momentum equation
fp: right hand side of the continuity equation
charlen: characteristic length of the setup
odcoo: dictionary with the coordinates of the domain of observation
-
problem_setups.
gen_bccont_fems_3D
(scheme='TH', bccontrol=True, verbose=False, strtomeshfile='', strtophysicalregions='', inflowvel=1.0, inflowprofile='parabola', movingwallcntrl=False, strtobcsobs='')[source]¶ dictionary for the fem items for a general 3D flow setup
- with
inflow/outflow
boundary control
- Parameters
- scheme{None, ‘CR’, ‘TH’}
the finite element scheme to be applied, ‘CR’ for Crouzieux-Raviart, ‘TH’ for Taylor-Hood, overrides pdgree, vdgree, defaults to None
- bccontrolboolean, optional
whether to consider boundary control via penalized Robin defaults to True
- movingwallcntrlboolean, optional
whether control is via moving boundaries
- Returns
- fempa dictionary with the keys:
V: FEM space of the velocity
Q: FEM space of the pressure
diribcs: list of the (Dirichlet) boundary conditions
dbcsinds: list vortex indices with (Dirichlet) boundary conditions
dbcsvals: list of values of the (Dirichlet) boundary conditions
dirip: list of the (Dirichlet) boundary conditions for the pressure
fv: right hand side of the momentum equation
fp: right hand side of the continuity equation
charlen: characteristic length of the setup
odcoo: dictionary with the coordinates of the domain of observation
-
problem_setups.
get_sysmats
(problem='gen_bccont', scheme=None, ppin=None, Re=None, nu=None, charvel=1.0, gradvsymmtrc=True, bccontrol=False, mergerhs=False, onlymesh=False, meshparams={})[source]¶ retrieve the system matrices for stokes flow
- Parameters
- problem{‘drivencavity’, ‘cylinderwake’, ‘gen_bccont’, ‘cylinder_rot’}
problem class
- Nint
mesh parameter
- nureal, optional
kinematic viscosity, is set to L/Re if Re is provided
- Rereal, optional
Reynoldsnumber, is set to L/nu if nu is provided
- bccontrolboolean, optional
whether to consider boundary control via penalized Robin defaults to False
- mergerhsboolean, optional
whether to merge the actual rhs and the contribution from the boundary conditions into one rhs, defaults to False
- onlymeshboolean, optional
whether to only return femp, containing the mesh and FEM spaces, defaults to False
- Returns
- fempdict
- with the keys:
V: FEM space of the velocity
Q: FEM space of the pressure
diribcs: list of the (Dirichlet) boundary conditions
dbcinds: indices of the boundary nodes
dbcvals: values of the boundary nodes
invinds: indices of the inner nodes
fv: right hand side of the momentum equation
fp: right hand side of the continuity equation
charlen: characteristic length of the setup
nu: the kinematic viscosity
Re: the Reynolds number
odcoo: dictionary with the coordinates of the domain of observation
- cdcoo: dictionary with the coordinates of the domain of * ppin{int, None}
- which dof of p is used to pin the pressure, typically -1 for internal flows, and None for flows with outflow
control
- stokesmatscdict
- a dictionary of the condensed matrices:
M: the mass matrix of the velocity space,
MP: the mass matrix of the pressure space,
A: the stiffness matrix,
JT: the gradient matrix, and
J: the divergence matrix
Jfull: the uncondensed divergence matrix
- and, if bccontrol=True, the boundary control matrices that weakly impose Arob*v = Brob*u, where
Arob: contribution to A
Brob: input operator
- if mergerhs
- rhsddict
rhsd_vfrc and rhsd_stbc merged
- else
- rhsd_vfrcdict
of the dirichlet and pressure fix reduced right hand sides
- rhsd_stbcdict
- of the contributions of the boundary data to the rhs:
fv: contribution to momentum equation,
fp: contribution to continuity equation
Examples
femp, stokesmatsc, rhsd_vfrc, rhsd_stbc = get_sysmats(problem=’drivencavity’, N=10, nu=1e-2)
data_output_utils¶
-
data_output_utils.
load_or_comp
(filestr=None, comprtn=None, comprtnargs={}, arraytype=None, debug=False, loadrtn=None, loadmsg='loaded ', savertn=None, savemsg='saved ', itsadict=False, numthings=1)[source]¶ routine for caching computation results on disc
- Parameters
- filestr: {string, list of strings, `None`}
where to load/store the computed things, if None nothing is loaded or stored
- arraytype: {`None`, ‘sparse’, ‘dense’}
if not None, then it sets the default routines to save/load dense or sparse arrays
- itsadict: boolean, optional
whether it is python dictionary that can be JSON serialized, overrides all other options concerning arrays
- savertn: fun(), optional
routine for saving the computed results, defaults to None, i.e. no saving here
- debug: boolean, optional
no saving or loading, defaults to False
-
data_output_utils.
output_paraview
(V=None, Q=None, VS=None, fstring='nn', invinds=None, diribcs=None, dbcinds=None, dbcvals=None, vp=None, vc=None, pc=None, sc=None, sname='nn', ppin=None, t=None, tfilter=None, writeoutput=True, vfile=None, pfile=None, sfile=None)[source]¶ write the paraview output for a solution (v,p) or a scalar s
given as coefficients