proteus.ADR module
An optimized Advection-Diffusion-Reaction module
- class proteus.ADR.SubgridError(coefficients, nd)[source]
Bases:
SGE_baseSubgridError approximation for ADR equations
- class proteus.ADR.ShockCapturing(coefficients, nd, shockCapturingFactor=0.25, lag=True, nStepsToDelay=None)[source]
Bases:
ShockCapturing_baseResidual-based shock capturing for ADR equations
- class proteus.ADR.NumericalFlux_IIPG(vt, getPointwiseBoundaryConditions, getAdvectiveFluxBoundaryConditions, getDiffusiveFluxBoundaryConditions)[source]
- class proteus.ADR.NumericalFlux_SIPG(vt, getPointwiseBoundaryConditions, getAdvectiveFluxBoundaryConditions, getDiffusiveFluxBoundaryConditions)[source]
- class proteus.ADR.NumericalFlux_NIPG(vt, getPointwiseBoundaryConditions, getAdvectiveFluxBoundaryConditions, getDiffusiveFluxBoundaryConditions)[source]
- 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_baseCoefficients 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 regionembeddedBoundary_sdf < 0is 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 ismuawhereimmersedBoundary_sdf < 0andmubwhere 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(optionpaper=Trueselects the settings used there) andtest/ci/ladr_fitted_2d_p.pyreproduce its tables.Callables that depend on position are called with keyword arguments
x(a 3-vector) andt; the two signed distance functions return(value, unit normal).- Parameters:
aOfX (dict) –
{ci: callable(x)}: diffusion tensor (ndxnd) of each component. WithimmersedBoundaryon, it must equalmuawhereimmersedBoundary_sdf < 0andmubwhere it is positive, as intest/ci/ladr_3p_2d_p.py.fOfX (dict) –
{ci: callable(x)}: source of each component.velocity (callable, optional) – Advection velocity \(\mathbf{v}(\mathbf{x})\);
Nonefor 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_fluxJumpand enters as a load plus a lift.embeddedBoundary (bool) – Switch on the CutFEM treatment of \(\Gamma_s\). Requires
embeddedBoundary_sdfandembeddedBoundary_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
muaphase, 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
mubphase.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
muaside. Default:embeddedBoundary_robin_h.embeddedBoundary_robin_h_outer (float, optional) – Robin coefficient on the
mubside. Default:embeddedBoundary_robin_h.embeddedBoundary_robin_uInfinity_inner (callable) – Robin far-field value \(u_\infty\) on the
muaside.embeddedBoundary_robin_uInfinity_outer (callable) – Robin far-field value \(u_\infty\) on the
mubside.immersedBoundary (bool) – Switch on the IFEM treatment of \(\Gamma_f\). Requires
immersedBoundary_sdfandimmersedBoundary_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
muaside, positive on themubside. Its gradient is the interface normal \(\mathbf{n}\).immersedBoundary_u (callable) – Required when
immersedBoundaryis 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 variableADR_TC_EDGE_FLUIDalso 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 variableADR_TC_EDGE_BOUNDARY_ONLYalso 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 fromuOfX_inneranduOfX_outerif the object has them. If it also provides the exact gradient (duOfX_innerandduOfX_outer, orduOfX), 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.
- 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
- 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:
OneLevelTransportOptimized LevelModel for ADR equations
Allocate storage and initialize some variables.
- Parameters:
uDict (dict) – Dictionary of
proteus.FemTools.FiniteElementFunctionobjects.phiDict (dict) – Dictionary of
proteus.FemTools.FiniteElementFunctionobjects.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
- 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.