proteus.richards.Richards module
- proteus.richards.Richards.DIAGNOSTICS = {'boundary_flux': 'the exterior-boundary water-flux decomposition, once per step (LevelModel._logBoundaryFluxSplit)', 'edge_flux': 'the per-edge water fluxes exported to a coupled transport model, once per accepted step (LevelModel._logEdgeFluxExport), and the nodal flux of the rebuilt edge velocity', 'fct': "the FCT step's limiter statistics and the veto on a large correction"}[source]
the run-time diagnostics a Richards model can log, each off by default since it costs MPI reductions every step or call.
- Type:
Coefficients(diagnostics=…)
- class proteus.richards.Richards.ThetaScheme(transport, integrateInterpolationPoints=False, theta=1.0)[source]
Bases:
BackwardEulerTwo-level theta method for the Richards LevelModel.
The storage term is always (m(u^{n+1}) - m(u^n))/dt; the Galerkin flux terms are weighted theta*F(u^{n+1}) + (1-theta)*F(u^n). theta = 1 (default) is backward Euler and theta = 1/2 is Crank-Nicolson. Set it in the numerics file with
timeIntegrationTheta = 0.5.With STABILIZATION_TYPE=0 the theta weighting applies to the Galerkin element integrals (exterior boundary fluxes stay implicit). With the edge-based schemes the low-order operator stays backward Euler and theta enters only the high-order flux used to build the FCT correction.
Set flags that indicate that all terms are implicit.
- class proteus.richards.Richards.RKEV(transport, timeOrder=1, runCFL=0.1, integrateInterpolationPoints=False)[source]
Bases:
SSPSet flags that indicate that all terms are implicit.
- TimeIntegration = <module 'proteus.TimeIntegration' from '/home/cekees/proteus-1.9.1-docs/proteus/TimeIntegration.py'>[source]
- initializeTimeHistory(resetFromDOF=True)[source]
Push necessary information into time history arrays
- class proteus.richards.Richards.Coefficients(nd, Ksw_types, vgm_n_types, vgm_alpha_types, thetaR_types, thetaSR_types, gravity, density, beta, PSK_type='VG', diagonal_conductivity=True, getSeepageFace=None, penalty_constant=None, penalty_power=None, density_model=None, DENSITY_MODEL=None, STABILIZATION_TYPE='Implicit_FCT', ENTROPY_TYPE=2, LUMPED_MASS_MATRIX=False, MONOLITHIC=False, VMS=0.0, SC=0.0, FCT=True, num_fct_iter=1, FCT_SATURATED_LOW_ORDER=True, FCT_TYPE='semi-implicit', FCT_PRELIMITER_POWER=3.0, FCT_PRELIMITER_VARIABLE='pressure', LSCHEME_L=0.0, VG_AIR_ENTRY=0.0, FCT_BND_DIFF=False, FCT_BND_KRW=False, FCT_BND_RESET=True, BC_CONS=False, FCT_DU_MAX=None, NONLINEAR_SOLVER=None, LSCHEME_RETRY_ITS=1, LSCHEME_TRIGGER='residual', LSCHEME_THETA_MAX=0.5, FCT_PREDICTOR_FALLBACK=True, cE=1.0, uL=0.0, uR=1.0, cK=1.0, outputQuantDOFs=False, forceStrongConditions=False, mms_source=None, diagnostics=(), fct_diagnostics_zcut=9.5)[source]
Bases:
TC_baseversion of Re where element material type id’s used in evals
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 conservativeHeadRichardsMualemVanGenuchtenHetEvaluateV2(materialTypes, rho, beta, gravity, alpha, n, thetaR, thetaSR, KWs, u, mass, dmass, f, df, a, da)[source]
- static conservativeHeadRichardsMualemVanGenuchten_sd_het(rowptr, colind, materialTypes, rho, beta, gravity, alpha, n, thetaR, thetaSR, KWs, u, mass, dmass, f, df, a, da, vol_frac, linearize_at_zero, pc_eps)[source]
- attachModels(modelList)[source]
Give the TC object access to other models in a loosely coupled split operator formulation (e.g. a transport equation for concentration might get velocity from a flow equation)
- preStep(t, firstStep=False)[source]
Give the TC object an opportunity to modify itself before the time step.
- initializeMesh(mesh)[source]
Give the TC object access to the mesh for any mesh-dependent information.
- 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.richards.Richards.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, bdyNullSpace=False)[source]
Bases:
OneLevelTransportAllocate 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
- checkFCTParallelLayout()[source]
Refuse a partition on which an OWNED DOF misses part of its element star.
The FCT limiters (both FCT_TYPEs) are nonlinear in the assembled rows (ML, MC, the flux matrices, P_i, Q_i), so a row must be complete at every owned DOF. An additive residual does not need this, which is why Galerkin and the low order still agree with serial on such partitions. Element partitioning with nLayersOfOverlapForParallel = 0 violates it: a node on the cut is owned by one rank but sees only that rank’s elements (Hornung-Messing h = 1/16, 2 ranks: WRR FCT 2.8e-3 vs 6.8e-5 serial). Element partitioning with overlap >= 1 and node partitioning both pass.
Test: ownedElementStarsIncomplete().
- ownedElementStarsIncomplete()[source]
Global number of owned DOFs whose element star is not entirely on their rank (0 in serial).
The number of local elements containing each owned DOF must equal its global count, which is assembled by a reverse-add of the counts over the uniquely owned elements (eN < nElements_owned). Rows of element-assembled matrices (ML, MC, …) are complete at owned DOFs exactly when this is 0.
- femL2Norm(x, lumped=False)[source]
Finite element L2 norm of a nodal vector x (free DOFs, local numbering with ghosts).
||x||_{L2} = sqrt(sum_{i owned} x_i (M_C x)_i), M_C the consistent mass matrix, i.e. the L2(Omega) norm of the finite element function with these nodal values (the quantity MFEM’s GridFunction::ComputeL2Error(0) evaluates). lumped=True uses M_L instead. x must hold current ghost values. The consistent version needs complete rows of M_C at owned DOFs (node partitioning, or element partitioning with overlap >= 1); it raises otherwise. Used by NonlinearSolvers for unorm = ‘L2’ / ‘L2_lumped’.
- ghostScatter(*arrays)[source]
Forward-insert (owner -> ghost copy) each free-DOF array. No-op in serial.
With one layer of overlap only the OWNED DOFs have their full element star and their full set of boundary faces on this rank, so anything built by a loop – mDotLow, min/max_m_bc, the Zalesak ratios – is incomplete at a ghost DOF. The edge loops read those arrays at the COLUMN j of an owned row i, and j can be a ghost, so without this the two ranks sharing a cut edge build different f_ij, the antisymmetry f_ij = -f_ji is lost and the correction manufactures mass along the partition. The owner always holds the complete value, so an insert scatter repairs every ghost.
u[0].par_dof is the only ghosted vector this module owns, so the arrays are shuttled through u[0].dof (the same idiom as mphase_co2/m_comp_co2). Integer arrays round-trip exactly: they only ever carry small whole numbers (0/1 flags, material indices).
- lschemeOn()[source]
True when the next residual should assemble the L-scheme matrix instead of the Jacobian.
- setLScheme(on)[source]
Newton’s switch for NONLINEAR_SOLVER=’hybrid’ (takes effect at the next residual).
- defectCorrection()[source]
True when the current Galerkin solve uses the L-scheme matrix (assembled by the edge kernel).
- kernelStabilizationType()[source]
STABILIZATION_TYPE passed to the kernels. The implicit FCT changes it per phase: Galerkin for the predictor, the edge-based low order for the flux evaluation, and Implicit_FCT (the low order plus the limited correction) for the final solve.
- fctPredictorFallback()[source]
Called by Newton when the implicit FCT’s Galerkin predictor failed. Switches this step’s predictor to the low-order operator and returns True, or returns False (no fallback).
- ImplicitFCTStep()[source]
Implicit FCT (JNMA), called by Newton after each converged solve.
After the Galerkin predictor: evaluate the fluxes at p^H, limit them, store the correction in fluxCorrection and ask Newton (fct_resolve) for the final low-order solve, M_L (m(p) - m^{n,FCT})/dt + A~(p) u(p) = 0, starting from p^H. After the final solve: nothing to do but rearm the predictor.
- computeEdgeVelocity()[source]
Fill q[(‘velocity_edge’,0)] with the velocity whose nodal fluxes are this step’s realized edge fluxes (Richards.h calculateEdgeVelocity),
int rho v.grad(w_i) dV = sum_j E_ij, E_ij = edgeFluxLow_ij + limitedFlux_ij/dt.
Call once per step after the Newton solve and FCTStep: limitedFlux is only final then, and it stays zero with FCT off. Needs STABILIZATION_TYPE 1 or 2, the only types whose residual fills edgeFluxLow and whose FCT correction is limitedFlux.
- invert(u, r=None, ulow=None)[source]
Unified invert method that handles both standard and FCT modes using self.coefficients.FCT as the switching flag.
- 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.
- 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.
- acceptedMass()[source]
The mass of the step just accepted: the limited mass when the semi-implicit FCT applied its correction (mAccepted); otherwise mLow, which the implicit FCT’s final solve also leaves its accepted mass in, and which without FCT is the solution.
- exportTransportFluxes()[source]
Realized fluid exchanges of the step just accepted, for the compatible transport.
With E~_ij the row-i edge flux the residual used (low order, plus alpha_ij f_ij / dt when the FCT correction was applied) and b_i the boundary integral (into the domain), the accepted step satisfies, up to the solver residual r_i,
M_L,i (m_i^{n+1} - m_i^n) / dt = sum_j E~_ij + b_i - r_i.
E~ is antisymmetric except on faces with a weak Dirichlet condition, whose penalty and adjoint terms enter the stiffness matrix unsymmetrically, so the export splits it into E_ij = (E~_ij - E~_ji)/2, which the transport uses, and the symmetric remainder, which the transport sees as boundary exchange through B_i = M_L,i dm_i/dt - sum_j E_ij. Espatial is E without the consistent-mass part of the correction; the transport reconstructs its dispersion velocity from it.
m^n is the old-time mass this step balanced, rho_T(c^n) theta(p^n). The transport adds exactly this increment to its carried storage, so the two balances agree. (Taking m^n from the previous step’s m^{n+1} instead turns every concentration change into a fluid source M_L (rho_T(c^n) - rho_T(c^{n-1})) theta / dt: at a strongly imposed concentration node in the first steps of the levee case, dt = 1e-8 d, the flow Newton cannot absorb it.)