proteus.testStuff module

just add a place to put things I’m testing out before they are ready for including in proteus

class proteus.testStuff.ExplicitLevelSetSolver(nDOF_global, RKorder=2, solnComponent=0, redistance=False, enforceWeakDir=False, redEpsFact=2.0, redCFL=0.1)[source]

Implement explicit, stabilized P^1 C^0 HJ level set algorithm from Barth and Sethian 98 (5.2)

RKorder — order of explicit RK time integration (1 or 2) solnComponent — solution component in VectorTransport to apply alg to.

advanceStage(phiIn, phiOut, wOut, q, ebq, l2g, elementDiameters, elementQuadratureWeights, dt)[source]

apply P^1, C^0 FE discretization with GLS style stablization and mass lumping to move level set function forward one RK stage

computeSolution(vtran, dt)[source]

compute phi^n –> phi^{n+1}, for Delta t= t^{n+1}-t^n

class proteus.testStuff.ExplicitLevelSetIntegrator(mlvtran, mlnl, dtMeth, nOptions, stepExact=True)[source]

Bases: proteus.TimeIntegration.ForwardIntegrator

put in manual integration to play with level-set redistancing

calculateSolution(tIn, tOut)[source]

manually step forward with fixed steps for now

proteus.testStuff.projectToFinestLevel(mlTransport, level, tsim=0.0)[source]

use multilevel transport prolongation to get fine grid information starting at level.

returns quadrature dictionary of projected values on fine grid

proteus.testStuff.generateParentInfo(mlMesh)[source]
get array P[l,e] = e_c, where element e_c is the parent of element e
P[0,:] = -1
proteus.testStuff.getIntegrationPointsOnCoarseGrid(xf, lf, P, lc)[source]

given array of points N^f_e x n_q x 3 on level lf generate dictionary on coarse grid that’s N^c_e x n_q^c(e_c) x 3 and holds the integration points assigned to the correct coarse grid element. If using uniform refinement should have the same number of integration points per coarse grid element but the number depends on the level of refinement eg n_q^4(lf-lc). In general the number won’t be the same for nonuniform refinement

proteus.testStuff.getCoarseGridBasisValuesOnFinePointsUniform(uc, xc, invJc, nEf, nq)[source]

assuming have collection of points in physical space on mesh xc with same number of points per element, map these back to reference element, then calculate shape function values there and return in a fine grid array

proteus.testStuff.getCoarseGridValuesOnFineUniform(uc, vcArray, xc, nEf, nq)[source]

given basis representation for coarse grid at fine grid points compute fem function values and return in fine grid array

proteus.testStuff.projectToFinestLevelNC(mlTransport, level, ci=0, tsim=0.0)[source]

use brute force evaluation to get coarse grid quantities on fine grid starting at level.

returns quadrature dictionary of projected values on fine grid

proteus.testStuff.projectVelocityToFinestLevelNC(mlTransport, level, ci=0, tsim=0.0, verbose=0)[source]

use brute force evaluation to get coarse grid quantities on fine grid starting at level.

returns quadrature dictionary of projected values on fine grid

class proteus.testStuff.MultilevelProjectionOperatorsNC(multiLevelMesh, femSpaceDictList, offsetListList, strideListList, dofBoundaryConditionsDictList)[source]

A class that takes a hierarchical (multiLevel) mesh and generates the interpolation and restriction operators.

restrictList/prolongList – projection and restriction at only the free nodes restrict_bcList/prolong_bcList – includes dirichlet boundaries as well

By default this is set up for conforming spaces. Since the spaces are conforming the coarse basis functions are in the fine space so we need only find the coefficients of the fine space basis functions that yield the coarse space basis functions. This is the matrix of the trivial injection from coarse to fine and it is used as the projection operator. Restriction is taken as the matrix of the adjoint of the injection, which is simply the transpose of the projection matrix. These operators fall out if you try to solve for the error on the coarse grid: Starting with u_f we have a(u_f+e_f,w_f) = <f,w_f>, and we want to solve instead a(e_c,w_c) = <f - a(u_f,w_f),w_c> on the coarse grid Using the injection i we can express this in the fine space as a(i e_c, i w_c) = <f - a(u_f,w_f),i w_c> writing this in matrix form yields p^t A_f p E = p^t R_f

— P1 nonconforming space —- Try to set up now for nonconforming P1 approximation following Chen_96b. Setup prolongation by evaluating coarse grid basis functions at fine grid interpolation condition points (face barycenters).

Then, just need to know if fine grid interpolationCondition point falls on interface of coarse grid elements or not. If so, use average value of coarse grid quantity on fine grid. Otherwise just evaluate it

Use this simple interpolation from coarse to fine as the projection operator. Restriction is taken as the matrix of the adjoint of the injection, which is simply the transpose of the projection matrix.

I don’t think these fall out as nicely since they’re nonconforming.

class proteus.testStuff.AdaptiveForwardIntegrator(mlvtran, mlnl, dtMeth, nOptions, stepExact=True, stepAdapt=True, resetAfterNLfail=True)[source]

class that is responsible for basic process of integrating a problem forward in time given a VectorTranport Problem, Nonlinear Solver, and a Time Integration method

mlvTran — multilevel vector transport object for system being integrated mlNL — multilevel nonlinear solver to solve discrete system dtMet — time integration method to use nOptions — configuration options

initialize(DTSET=None, t0=0.0)[source]
calculateSolution(tIn, tOut)[source]

Move forward from time tIn to time tOut For now doesn’t worry about potential mismatch between tIn and last time value used by model

writeProgress(tn, dt, T)[source]

just echo to screen what new and final time levels are

chooseDT(t, tOut, nlSolveFailed)[source]

try to pick dt for next time step solve. If adapting, lets finest level time integrator determine if error is acceptable and pick the output time step

otherwise, just sets time step to be uniform one

includes adjustment if stepping exactly to output as well

class proteus.testStuff.AdaptiveBackwardEuler(vectorTransport, runCFL=0.9, atol=0.001, rtol=0.001, errorType='LI_global', dtRatioMax=2, dtRatioMin=0.1)[source]

Bases: proteus.TimeIntegration.BackwardEuler

calculateElementCoefficients(q)[source]
chooseDT()[source]

Modify self.DT mwf needs to be checked

updateTimeHistory(resetFromDOF=False, vectorTransport=None)[source]
setLastSolveFailed(lastSolveFailed)[source]

tell integrator last attempted time step failed or not

lastStepErrorOk()[source]

was the last time step acceptable or not

proteus.testStuff.stupidSort(A, hit=-12345)[source]
proteus.testStuff.checkOrder(A)[source]
class proteus.testStuff.RusanovNumericalFlux_Diagonal_Diffusion_LDG(vt, getPointwiseBoundaryConditions, getAdvectiveFluxBoundaryConditions, getDiffusiveFluxBoundaryConditions)[source]

Bases: proteus.NumericalFlux.Advection_DiagonalUpwind_Diffusion_LDG

apply numerical flus \(f_{num}(a,b) = 1/2(f(a)+f(b)-ar{\lambda}(b-a)\) where \(\lambda >= max |f^{\prime}|\) for \(a<= u <= b\) this one applies flux to each component of flux separately

calculateInteriorNumericalFlux(q, ebq, ebq_global)[source]
calculateExteriorNumericalFlux(inflowFlag, q, ebq, ebq_global)[source]
class proteus.testStuff.SSPRKNewton(linearSolver, F, J=None, du=None, par_du=None, rtol_r=0.0001, atol_r=1e-16, rtol_du=0.0001, atol_du=1e-16, maxIts=100, norm=<function l2Norm>, convergenceTest='r', computeRates=True, printInfo=True, fullNewton=True, directSolver=False, EWtol=True, maxLSits=100)[source]

Bases: proteus.NonlinearSolvers.Newton

A simple iterative solver that is Newton’s method if you give it the right Jacobian

solve(u, r=None, b=None, par_u=None, par_r=None)[source]
resetFactorization(needToRefactor=True)[source]