proteus.SimTools module

Collect higher level tools for running simulation, processing results, etc

Inheritance diagram of proteus.SimTools

class proteus.SimTools.zeroFunction[source]

Bases: object

uOfX(x)[source]
uOfXT(x, t)[source]
class proteus.SimTools.zeroVectorFunction(shape)[source]

Bases: object

uOfX(x)[source]
uOfXT(x, t)[source]
class proteus.SimTools.SimulationProcessor(flags=None, nLevels=1, pFile=None, nFile=None, analyticalSolution={})[source]

Bases: object

Collect some functionality for doing something with simulation results like calculating error, saving it to disk, etc.

TO DO

be able to append data to file correctly

save flags for what to compute, how to compute it, and labels for storing things, etc

math = <module 'math' from '/home/travis/miniconda/envs/proteus-dev/lib/python3.10/lib-dynload/math.cpython-310-x86_64-linux-gnu.so'>[source]
defaultFlags = {'appendResults': False, 'components': [0], 'dataDir': '.', 'dataFile': 'results.dat', 'echo': False, 'echoRelativeErrors': False, 'errorNorms': [None], 'errorQuantities': [None], 'errorTimes': [None], 'errorTypes': [None], 'plotOptions': {'ensight': {'on': False}, 'gnuplot': {'on': False}, 'matlab': {'on': False}, 'vtk': {'on': False}}, 'plotQuantities': [None], 'plotTimes': [None], 'simulationName': None, 'simulationNameProc': None, 'storeQuantities': [None], 'storeTimes': [None]}[source]
notSetVal = -12345.0[source]
ErrorQuantities = ['m', 'u', 'grad(u)', 'velocity'][source]
ErrorNorms = ['L1', 'L2', 'LI', 'TV', 'H1', 'H1semi', 'W11', 'W11semi', 'L1_L1', 'L1_LI', 'L2_L2', 'L2_LI', 'TV_L1', 'TV_LI'][source]
ErrorTimes = ['All', 'Last', 'tList'][source]
ErrorTypes = ['globalMassBalance', 'globalHeavisideMassBalance', 'localMassBalance', 'numericalSolution'][source]
PlotTimes = ['All', 'Last', 'Init', 'tList'][source]
PlotQuantities = ['u', 'u_exact', 'velocity', 'velocity_exact', "q:('%s',%d)", "q:('%s',%d,%d)"][source]
PlotOptions = {'ensight': {'on': False}, 'gnuplot': {'on': False, 'setGnuplotGridSize': True}, 'matlab': {'on': False, 'usePDEtoolbox': False}, 'vtk': {'hardcopy': False, 'on': False, 'pause': False}}[source]
StoreTimes = ['All', 'Last', 'Init', 'tList'][source]
StoreQuantities = ['u', 'u_dof', 'errorData', 'simulationData', 'mesh', "q:('%s',%d)", 'multilevelModel'][source]
SolutionDataStorageData = ['nSpace_global', 'name', 'dof', 'dofMap.l2g', 'dim_dof', 'isVector', 'CGDOFMap.lagrangesNodesArray', 'CGDOFMap.l2g'][source]
preprocess(mlvt, tsim)[source]
processTimeLevel(mlvt, tsim=None, plotOffSet=None)[source]

calculate desired quantities after each macro time step

Parameters
  • mlvt (multilevel vector transport that holds the quantities to measure) –

  • tsim (simulation time) –

postprocess(mlvt, tsim)[source]

calculate desired quantities after simulation ends

Parameters
  • mlvt (multilevel vector transport that holds the quantities to measure) –

  • tsim (simulation time) –

saveToDisk()[source]

TO DO save error to disk make sure can append if necessary?

stepProcessError(mlvt, tsim)[source]

calculate desired error quantities for a single step

Parameters
  • mlvt (multilevel vector transport that holds the quantities to measure) –

  • tsim (simulation time) –

getScalarElementStorageKeys(mlvt, tsim)[source]

simple utility to pull out keys for things in element quadrature dictionary that need to be stored

getVectorElementStorageKeys(mlvt, tsim)[source]

simple utility to pull out keys for things in element quadrature dictionary that need to be stored

getTensorElementStorageKeys(mlvt, tsim)[source]

simple utility to pull out keys for things in element quadrature dictionary that need to be stored

getScalarElementBoundaryStorageKeys(mlvt, tsim)[source]

simple utility to pull out keys for things in element boundary quadrature dictionary that need to be stored

getVectorElementBoundaryStorageKeys(mlvt, tsim)[source]

simple utility to pull out keys for things in element boundary quadrature dictionary that need to be stored

getTensorElementBoundaryStorageKeys(mlvt, tsim)[source]

simple utility to pull out keys for things in element boundary quadrature dictionary that need to be stored

getScalarExteriorElementBoundaryStorageKeys(mlvt, tsim)[source]

simple utility to pull out keys for things in exterior element boundary quadrature dictionary that need to be stored

getVectorExteriorElementBoundaryStorageKeys(mlvt, tsim)[source]

simple utility to pull out keys for things in exterior element boundary quadrature dictionary that need to be stored

getTensorExteriorElementBoundaryStorageKeys(mlvt, tsim)[source]

simple utility to pull out keys for things in exterior element boundary quadrature dictionary that need to be stored

stepPlotElementQuantitiesEnsight(mlvt, tsim)[source]
sort through desired quantities in quadrature dictionaries like m, dm, to plot

p — problem definition n — numerics definition mlvt — multilevel vector transport that holds the quantities to measure tsim — simulation time

assumes this is the correct time to plot and plotOffSet is set correctly

stepStoreQuantities(mlvt, tsim)[source]

shelve quantities for a given time instance, if self.storeHeavyData == True soon to be deprecated and will use Archiver tools instead

Quadrature dictionary quantities are shelved in a dictionary whose key is the corresponding quadrature dictionary name.

The stored dictionary has fields ‘x’ ‘t’ and ‘vals’ which hold the quadrature points (assumed static for now) as well as lists of the desired quantities at the requested time levels. The quantities to be stored are specified in flags[‘storeQuantities’] in the format

“q:(%s,%d)”,ebq:(%s,%d) etc e.g., “q:(‘u’,0)” will store component 0 solution values from q

dataStorage[‘q’][‘x’]= [[0.,0.,0.],[…],…] element quadrature points for 1st time called dataStorage[‘q’][‘t’]= [0.0,0.1,…,1.0] dataStorage[‘q’][‘vals’] = [subset of q at t=0.0, subset of q at t=0.1, …]

if multilevelModel is set, stores basically everything

Input

p — problem definition n — numerics definition mlvt — multilevel vector transport that holds the quantities to measure tsim — simulation time

assumes this is the correct time to store

TODO: add option for storage directory

computeNodalQuadratureInfo(mlvt, t)[source]

if need values of quantities at mesh nodes and don’t have them already, use this only compute values on finest mesh for now

stepPlotEnsight(mlvt, tsim)[source]
plot solution and solution ‘velocity’ for ensight/paraview

p — problem definition n — numerics definition mlvt — multilevel vector transport that holds the quantities to measure tsim — simulation time

assumes this is the correct time to plot and plotOffSet is set correctly

assumes that initial case,sos, geo files set somewhere else

writeEnsightMeshForElementQuantities(filename, mlvt, tsim=0.0)[source]
writeEnsightMeshForElementBoundaryQuantities(filename, mlvt, tsim=0.0)[source]
writeScalarElementFunctionHeaderEnsight(ckey, filename, append=False, firstVariable=True, case_filename=None)[source]
writeVectorElementFunctionHeaderEnsight(ckey, filename, append=False, firstVariable=True, case_filename=None)[source]
plotScalarElementQuantityEnsight(ckey, mlvt, tsim)[source]
Ensight plotting routine to look at scalar quantity stored in element quad dictionary q

ckey — what should be plotted p — problem definition n — numerics definition mlvt — multilevel vector transport that holds the quantities to measure tsim — simulation time

assumes this is the correct time to plot and plotOffSet is set correctly

assumes that initial case,sos, geo files set somewhere else

plotVectorElementQuantityEnsight(ckey, mlvt, tsim, scaleOutput=None)[source]
Ensight plotting routine to look at vector quantity stored in element quad dictionary q

ckey — what should be plotted p — problem definition n — numerics definition mlvt — multilevel vector transport that holds the quantities to measure tsim — simulation time

assumes this is the correct time to plot and plotOffSet is set correctly

assumes that initial case,sos, geo files set somewhere else TODO : check format for 3d

plotScalarGlobalElementBoundaryQuantityEnsight(ckey, mlvt, tsim)[source]
Ensight plotting routine to look at scalar quantity stored in element quad dictionary ebq_global

ckey — what should be plotted p — problem definition n — numerics definition mlvt — multilevel vector transport that holds the quantities to measure tsim — simulation time

assumes this is the correct time to plot and plotOffSet is set correctly

assumes that initial case,sos, geo files set somewhere else

plotVectorGlobalElementBoundaryQuantityEnsight(ckey, mlvt, tsim, scaleOutput=None)[source]
Ensight plotting routine to look at vector quantity stored in element quad dictionary ebq_global

ckey — what should be plotted p — problem definition n — numerics definition mlvt — multilevel vector transport that holds the quantities to measure tsim — simulation time

assumes this is the correct time to plot and plotOffSet is set correctly

assumes that initial case,sos, geo files set somewhere else TODO : check format for 3d

proteus.SimTools.projectToFinestLevel(mlTransport, level, tsim=0.0, verbose=0)[source]

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

returns quadrature dictionary of projected values on fine grid

proteus.SimTools.generateParentInfo(mlMesh)[source]
get array P[l,e] = e_c, where element e_c is the parent of element e

P[0,:] = -1

proteus.SimTools.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.SimTools.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