proteus.ADR module

An optimized Advection-Diffusion-Reaction module

class proteus.ADR.SubgridError(coefficients, nd)[source]

Bases: SGE_base

SubgridError approximation for ADR equations

Inheritance diagram of SubgridError

initializeElementQuadrature(mesh, t, cq)[source]
updateSubgridErrorHistory(initializationPhase=False)[source]
calculateSubgridError(q)[source]
class proteus.ADR.ShockCapturing(coefficients, nd, shockCapturingFactor=0.25, lag=True, nStepsToDelay=None)[source]

Bases: ShockCapturing_base

Residual-based shock capturing for ADR equations

Inheritance diagram of ShockCapturing

initializeElementQuadrature(mesh, t, cq)[source]
updateShockCapturingHistory()[source]
class proteus.ADR.NumericalFlux_IIPG(vt, getPointwiseBoundaryConditions, getAdvectiveFluxBoundaryConditions, getDiffusiveFluxBoundaryConditions)[source]

Bases: Advection_DiagonalUpwind_Diffusion_IIPG_exterior

class proteus.ADR.NumericalFlux_SIPG(vt, getPointwiseBoundaryConditions, getAdvectiveFluxBoundaryConditions, getDiffusiveFluxBoundaryConditions)[source]

Bases: Advection_DiagonalUpwind_Diffusion_SIPG_exterior

class proteus.ADR.NumericalFlux_NIPG(vt, getPointwiseBoundaryConditions, getAdvectiveFluxBoundaryConditions, getDiffusiveFluxBoundaryConditions)[source]

Bases: Advection_DiagonalUpwind_Diffusion_NIPG_exterior

proteus.ADR.NumericalFlux[source]

alias of NumericalFlux_SIPG

class proteus.ADR.Coefficients(aOfX, fOfX, velocity=None, nc=1, nd=2, l2proj=None, timeVaryingCoefficients=False, forceStrongDirichlet=False, useMetrics=0.0, sc_uref=1.0, sc_beta=1.0, mua=1.0, mub=1.0, jf=0.0, embeddedBoundary=False, embeddedBoundary_penalty=100.0, embeddedBoundary_ghost_penalty=0.1, embeddedBoundary_sdf=None, embeddedBoundary_u=None, embeddedBoundary_u_inner=None, embeddedBoundary_u_outer=None, embeddedBoundary_robin=False, embeddedBoundary_robin_h=1.0, embeddedBoundary_robin_h_inner=None, embeddedBoundary_robin_h_outer=None, embeddedBoundary_robin_uInfinity_inner=None, embeddedBoundary_robin_uInfinity_outer=None, immersedBoundary=False, immersedBoundary_penalty=100.0, immersedSCIFEM_switch=0.0, immersedSCIFEM_penalty=0.0, PG=False, immersedBoundary_sdf=None, immersedBoundary_u=None, immersedBoundary_fluxJump=None, immersedBoundary_fluxJumpVector=None, immersedBoundary_solutionJump=None, immersedBoundary_fluxJumpLift=True, triplyCut_edgeFluidSide=False, triplyCut_edgeBoundaryOnly=False, analyticalSolution=None, test=1.0)[source]

Bases: TC_base

Coefficients of linear ADR equations

Solves \(\nabla\cdot(\mathbf{v}u - a\nabla u) = f\) with a diffusion tensor \(a(\mathbf{x})\), a source \(f(\mathbf{x})\) and an optional velocity \(\mathbf{v}\). Two unfitted interfaces, described by signed distance functions on a background mesh that does not follow them, can be switched on separately or together:

  • embeddedBoundary: a fluid–solid interface \(\Gamma_s\) (CutFEM). The region embeddedBoundary_sdf < 0 is solid and removed; cells entirely inside it are inactive. On \(\Gamma_s\) a Dirichlet value is imposed weakly by Nitsche’s method, or a Robin condition is applied. A ghost penalty on the interior edges of the active mesh that belong to a \(\Gamma_s\)-cut cell keeps small cut cells stable.

  • immersedBoundary: a fluid–fluid interface \(\Gamma_f\) (immersed FEM). The diffusion coefficient is mua where immersedBoundary_sdf < 0 and mub where it is positive. Cut cells use the two-branch IFEM basis, for \(P_1\) and \(P_2\); prescribed solution and flux jumps are supported.

With both switched on, a cell cut by both interfaces is a triply-cut cell; it is integrated with composite equivalent polynomials. The method and its verification are described in D. Nathawani and C. E. Kees, Hybrid CutFEM-IFEM model for embedded and immersed interfaces with triply-cut cells for the 2D Poisson problem. The drivers test/ci/ladr_3p_2d_p.py (option paper=True selects the settings used there) and test/ci/ladr_fitted_2d_p.py reproduce its tables.

Callables that depend on position are called with keyword arguments x (a 3-vector) and t; the two signed distance functions return (value, unit normal).

Inheritance diagram of Coefficients

Parameters:
  • aOfX (dict) – {ci: callable(x)}: diffusion tensor (nd x nd) of each component. With immersedBoundary on, it must equal mua where immersedBoundary_sdf < 0 and mub where it is positive, as in test/ci/ladr_3p_2d_p.py.

  • fOfX (dict) – {ci: callable(x)}: source of each component.

  • velocity (callable, optional) – Advection velocity \(\mathbf{v}(\mathbf{x})\); None for no advection.

  • nc (int) – Number of components.

  • nd (int) – Space dimension.

  • mua (float) – Diffusion coefficient \(\mu_a\) where immersedBoundary_sdf < 0. Used by the IFEM basis and the terms on \(\Gamma_f\).

  • mub (float) – Diffusion coefficient \(\mu_b\) where immersedBoundary_sdf > 0.

  • jf (float) – Flux jump built into the IFEM basis. Keep 0: a prescribed flux jump is given by immersedBoundary_fluxJump and enters as a load plus a lift.

  • embeddedBoundary (bool) – Switch on the CutFEM treatment of \(\Gamma_s\). Requires embeddedBoundary_sdf and embeddedBoundary_u.

  • embeddedBoundary_penalty (float) – Nitsche parameter \(\gamma_N\); the penalty term is scaled by \(\mu/h\). The paper uses \(10p^2\).

  • embeddedBoundary_ghost_penalty (float) – Ghost-penalty parameter \(\gamma_g\). The paper uses 0.15. In parallel, the ghost penalty and the SCIFEM edge terms need two layers of mesh overlap.

  • embeddedBoundary_sdf (callable) – Signed distance to \(\Gamma_s\): positive in the fluid, negative in the solid.

  • embeddedBoundary_u (callable) – Dirichlet value on \(\Gamma_s\).

  • embeddedBoundary_u_inner (callable, optional) – Dirichlet value for the mua phase, given as a smooth function over a whole cell. On a triply-cut cell, one pointwise value would switch branch across \(\Gamma_f\); a smooth function per phase keeps the Nitsche terms exact. Default: embeddedBoundary_u.

  • embeddedBoundary_u_outer (callable, optional) – The same for the mub phase.

  • embeddedBoundary_robin (bool) – Impose \(\mu\,\partial u/\partial n = -h\,(u - u_\infty)\) on \(\Gamma_s\) instead of the Dirichlet condition, with \(\mathbf{n}\) pointing from the fluid into the solid.

  • embeddedBoundary_robin_h (float) – Robin coefficient \(h\), the default for both phases.

  • embeddedBoundary_robin_h_inner (float, optional) – Robin coefficient on the mua side. Default: embeddedBoundary_robin_h.

  • embeddedBoundary_robin_h_outer (float, optional) – Robin coefficient on the mub side. Default: embeddedBoundary_robin_h.

  • embeddedBoundary_robin_uInfinity_inner (callable) – Robin far-field value \(u_\infty\) on the mua side.

  • embeddedBoundary_robin_uInfinity_outer (callable) – Robin far-field value \(u_\infty\) on the mub side.

  • immersedBoundary (bool) – Switch on the IFEM treatment of \(\Gamma_f\). Requires immersedBoundary_sdf and immersedBoundary_u.

  • immersedBoundary_penalty (float) – Not used by the IFEM scheme.

  • immersedSCIFEM_switch (float) – 1.0 adds the symmetric consistency terms of SCIFEM (Ji, Chen and Li, 2014) on the edges cut by \(\Gamma_f\); 0.0 leaves them out. The paper uses 1.0.

  • immersedSCIFEM_penalty (float) – Interior-penalty parameter \(\gamma_I\) on the edges cut by \(\Gamma_f\), applied to each phase. The paper uses 0 for \(p=1\) and 100 for \(p=2\).

  • PG (bool) – Petrov-Galerkin: test with the standard basis functions instead of the IFEM ones on cells cut by \(\Gamma_f\). An alternative to the SCIFEM edge terms; the trial space is unchanged.

  • immersedBoundary_sdf (callable) – Signed distance to \(\Gamma_f\): negative on the mua side, positive on the mub side. Its gradient is the interface normal \(\mathbf{n}\).

  • immersedBoundary_u (callable) – Required when immersedBoundary is on, but not used by the IFEM scheme.

  • immersedBoundary_fluxJump (callable, optional) – Scalar part \(J_f\) of the prescribed flux jump \([\mu\,\partial u/\partial n] = J_f + \mathbf{g}\cdot\mathbf{n}\), where \([w] = w_b - w_a\). Default: no flux jump.

  • immersedBoundary_fluxJumpVector (callable, optional) – Vector part \(\mathbf{g}\) of the prescribed flux jump. Default: none.

  • immersedBoundary_solutionJump (callable, optional) – Prescribed solution jump \([u] = u_b - u_a\), sampled at the degrees of freedom and carried by a lift. Default: no jump.

  • immersedBoundary_fluxJumpLift (bool) – Represent the flux jump by a lift added once to the trial function, in addition to the load term. Where the solution jump varies on a cell, the lift carries only the part of the flux jump that the solution-jump lift does not. False keeps only the load term.

  • triplyCut_edgeFluidSide (bool) – On a triply-cut cell, integrate the consistency correction over the fluid part of each edge cut by \(\Gamma_f\). The paper uses True. The environment variable ADR_TC_EDGE_FLUID also sets it, with a deprecation warning.

  • triplyCut_edgeBoundaryOnly (bool) – Keep that correction only on edges on the outer boundary; SCIFEM handles the interior edges. The paper uses True. The environment variable ADR_TC_EDGE_BOUNDARY_ONLY also sets it, with a deprecation warning.

  • analyticalSolution (dict, optional) – {0: AnalyticalSolution}. When given, the \(L^2\) and \(L^\infty\) errors over the fluid are logged after each step, taking the exact solution of each phase from uOfX_inner and uOfX_outer if the object has them. If it also provides the exact gradient (duOfX_inner and duOfX_outer, or duOfX), the broken \(H^1\) seminorm and the \(H^1\) error are logged too.

  • l2proj – Options of the standard ADR model, unrelated to the interfaces.

  • timeVaryingCoefficients – Options of the standard ADR model, unrelated to the interfaces.

  • forceStrongDirichlet – Options of the standard ADR model, unrelated to the interfaces.

  • useMetrics – Options of the standard ADR model, unrelated to the interfaces.

  • sc_uref – Options of the standard ADR model, unrelated to the interfaces.

  • sc_beta – Options of the standard ADR model, unrelated to the interfaces.

  • test (float) – Not used.

Set the number of components (equations) of the PDE and initialize the dicitionaries describing the form of the coefficients. Strings naming each component (used for viewing and archiving) and a structure defining the sparsity pattern of diffusion tensors may also be provided.

static L2projectEvaluate(rank, dV, r)[source]
initializeSDF(femSpace)[source]
initializeElementQuadrature(t, cq)[source]

Give the TC object access to the element quadrature storage

initializeElementBoundaryQuadrature(t, cebq, cebq_global)[source]

Give the TC object access to the element boundary quadrature storage

initializeGlobalExteriorElementBoundaryQuadrature(t, cebqe)[source]

Give the TC object access to the exterior element boundary quadrature storage

evaluate(t, c)[source]

Evaluate the coefficients at a given time, t, using the coefficient storage passed in as the dictionary c.

class proteus.ADR.LevelModel(uDict, phiDict, testSpaceDict, matType, dofBoundaryConditionsDict, dofBoundaryConditionsSetterDict, coefficients, elementQuadrature, elementBoundaryQuadrature, fluxBoundaryConditionsDict=None, advectiveFluxBoundaryConditionsSetterDict=None, diffusiveFluxBoundaryConditionsSetterDictDict=None, stressTraceBoundaryConditionsSetterDict=None, stabilization=None, shockCapturing=None, conservativeFluxDict=None, numericalFluxType=None, TimeIntegrationClass=None, massLumping=False, reactionLumping=False, options=None, name='defaultName', reuse_trial_and_test_quadrature=True, sd=True, movingDomain=False)[source]

Bases: OneLevelTransport

Optimized LevelModel for ADR equations

Inheritance diagram of LevelModel

Allocate storage and initialize some variables.

Parameters:
  • uDict (dict) – Dictionary of proteus.FemTools.FiniteElementFunction objects.

  • phiDict (dict) – Dictionary of proteus.FemTools.FiniteElementFunction objects.

  • testSpaceDict (dict) – Dictionary of FiniteElementSpace objects

  • dofBoundaryConditionsDict (dict) – Dictionary of DOFBoundaryConditions objects for the Dirichlet conditions.

  • coefficients (proteus.TransportCoefficients.TC_base) – Problem’s Transport Coefficients class.

  • elementQuadratureDict (dict) – Dictionary of dictionaries of quadrature rules for each element integral in each component equation.

  • elementBoundaryQuadratureDict (dict) – Dictionary of dictionaries of quadrature rules for each element boundary integral in each component equation

  • stabilization (bool)

  • shockCapturing (bool)

  • numericalFlux (bool)

  • bdyNullSpace (bool) – Indicates whether the boundary conditions create a global null space.

Notes

The constructor sets the input arguments, calculates dimensions, and allocates storage. The meanings of variable suffixes are

  • global – per physical domain

  • element – per element

  • elementBoundary – per element boundary

The prefix n means ‘number of’.

Storage is divided into quantities required at different sets of points or geometric entities. Each type of storage has a dictionary for all the quantities of that type. The names and dimensions of the storage dictionaries are

  • e – at element

  • q – at element quadrature, unique to elements

  • ebq – at element boundary quadrature, unique to elements

  • ebq_global – at element boundary quadrature, unique to element boundary

  • ebqe – at element boundary quadrature, unique to global, exterior element boundary

  • phi_ip – at the generalized interpolation points required to build a nonlinear phi

nCalls = 0[source]
calculateCoefficients()[source]
getResidual(u, r)[source]

Calculate the element residuals and add in to the global residual

getJacobian(jacobian)[source]
invalidateIFEMGeometry()[source]

Call whenever the embedded/immersed interface geometry (sdf) changes - e.g. mesh adaptation, or a new time step for a moving interface - so the C++ layer recomputes and refreshes its per-element equivalent- polynomial/IFEM cache on the next residual/Jacobian call instead of reusing stale cut-cell data.

calculateElementQuadrature()[source]

Calculate the physical location and weights of the quadrature rules and the shape information at the quadrature points.

This function should be called only when the mesh changes.

archiveFiniteElementSolutions(archive, t, tCount, initialPhase=False, writeVectors=True, meshChanged=False, femSpaceWritten={}, writeVelocityPostProcessor=True)[source]

write finite element solutions to archive at time t, tries to group finite element functions by their space

calculateElementBoundaryQuadrature()[source]

Calculate the physical location and weights of the quadrature rules and the shape information at the quadrature points on element boundaries.

This function should be called only when the mesh changes.

calculateExteriorElementBoundaryQuadrature()[source]

Calculate the physical location and weights of the quadrature rules and the shape information at the quadrature points on global element boundaries.

This function should be called only when the mesh changes.

estimate_mt()[source]
calculateAuxiliaryQuantitiesAfterStep()[source]
calculateSolutionAtQuadrature()[source]