PyFoam.RunDictionary.SolutionDirectory module

Working with a solution directory

class PyFoam.RunDictionary.SolutionDirectory.ChemkinSolutionDirectory(name, archive='ArchiveDir')[source]

Bases: PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory

Solution directory with a directory for the Chemkin-files

__init__(name, archive='ArchiveDir')[source]
Parameters
  • name – Name of the solution directory

  • archive – name of the directory where the lastToArchive-method

should copy files, if None no archive is created. Deprecated as it was never used :param paraviewLink: Create a symbolic link controlDict.foam for paraview :param tolerant: do not fail for minor inconsistencies :param parallel: use the first processor-subdirectory for the authorative information :param region: Mesh region for multi-region cases

__module__ = 'PyFoam.RunDictionary.SolutionDirectory'
chemkinDir()[source]
Return type

str

Returns

The directory with the Chemkin-Files

chemkinName = 'chemkin'
class PyFoam.RunDictionary.SolutionDirectory.NoTouchSolutionDirectory(name, region=None)[source]

Bases: PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory

Convenience class that makes sure that nothing new is created

__init__(name, region=None)[source]
Parameters
  • name – Name of the solution directory

  • archive – name of the directory where the lastToArchive-method

should copy files, if None no archive is created. Deprecated as it was never used :param paraviewLink: Create a symbolic link controlDict.foam for paraview :param tolerant: do not fail for minor inconsistencies :param parallel: use the first processor-subdirectory for the authorative information :param region: Mesh region for multi-region cases

__module__ = 'PyFoam.RunDictionary.SolutionDirectory'
class PyFoam.RunDictionary.SolutionDirectory.SolutionDirectory(name, archive=None, paraviewLink=True, parallel=False, addLocalConfig=False, tolerant=False, region=None)[source]

Bases: PyFoam.Basics.Utilities.Utilities

Represents a solution directory

In the solution directory subdirectories whose names are numbers are assumed to be solutions for a specific time-step

_SolutionDirectory__classifyDirectory(dPath)
_SolutionDirectory__scanForPostproc(dirName)
_SolutionDirectory__scanPostproc()
_SolutionDirectory__symlinkDir(src, dest, toProcess, maxLevel, relPath, polyDirs, symlinks)
__contains__(item)[source]
__delitem__(key)[source]
__getitem__(key)[source]
__init__(name, archive=None, paraviewLink=True, parallel=False, addLocalConfig=False, tolerant=False, region=None)[source]
Parameters
  • name – Name of the solution directory

  • archive – name of the directory where the lastToArchive-method

should copy files, if None no archive is created. Deprecated as it was never used :param paraviewLink: Create a symbolic link controlDict.foam for paraview :param tolerant: do not fail for minor inconsistencies :param parallel: use the first processor-subdirectory for the authorative information :param region: Mesh region for multi-region cases

__iter__()[source]
__len__()[source]
__module__ = 'PyFoam.RunDictionary.SolutionDirectory'
__setitem__(key, value)[source]
addBackup(pth)[source]

add file to list of files that are to be copied to the archive

addLocalConfig()[source]

Add the local configuration file of the case to the configuration

addPostprocDir(dirName, fail=True)[source]
addToClone(name)[source]

add directory to the list that is needed to clone this case :param name: name of the subdirectory (the case directory is prepended)

addToHistory(*text)[source]

Adds a line with date and username to a file ‘PyFoamHistory’ that resides in the local directory

addToTar(tar, pattern, exclude=[], base=None, proc=None, verbose=False)[source]

The workhorse for the packCase-method

blockMesh(region=None)[source]
Parameters

region – Specify the region for cases with more than 1 mesh

Returns

the name of the C{blockMeshDict} if it exists. Returns

an empty string if it doesn’t :rtype: str

boundaryDict(region=None, time=None, processor=None)[source]
Parameters

region – Specify the region for cases with more than 1 mesh

Returns

name of the C{boundary}-file

Return type

str

clear(after=None, processor=True, pyfoam=True, keepLast=False, vtk=True, verbose=False, keepRegular=False, keepParallel=False, keepInterval=None, keepTimes=[], removeAnalyzed=False, clearHistory=False, clearParameters=False, functionObjectData=False, dryRun=False, additional=[])[source]

One-stop-shop to remove data :param after: time after which directories ar to be removed :param processor: remove the processorXX directories :param pyfoam: rremove all directories typically created by PyFoam :param keepLast: Keep the last time-step :param additional: list with additional patterns to clear

clearOther(pyfoam=True, removeAnalyzed=False, verbose=False, dryRun=False, clearHistory=False, clearParameters=False)[source]

Remove additional directories :param pyfoam: rremove all directories typically created by PyFoam

clearPattern(globPat, dryRun=False, verbose=False)[source]

Clear all files that fit a certain shell (glob) pattern :param glob: the pattern which the files are going to fit

clearResults(after=None, removeProcs=False, keepLast=False, vtk=True, keepRegular=False, keepParallel=False, keepInterval=None, keepTimes=[], functionObjectData=False, dryRun=False, verbose=False, additional=[])[source]

remove all time-directories after a certain time. If not time ist set the initial time is used :param after: time after which directories ar to be removed :param removeProcs: if True the processorX-directories are removed. Otherwise the timesteps after last are removed from the processor-directories :param keepLast: Keep the data from the last timestep :param keepInterval: if set: keep timesteps that are this far apart :param vtk: Remove the VTK-directory if it exists :param keepRegular: keep all the times (only remove processor and other stuff) :param functionObjectData: tries do determine which data was written by function obejects and removes it :param additional: List with glob-patterns that are removed too

cloneCase(name, svnRemove=True, paraviewLink=True, followSymlinks=False)[source]

create a clone of this case directory. Remove the target directory, if it already exists

Parameters
  • name – Name of the new case directory

  • svnRemove – Look for .svn-directories and remove them

  • followSymlinks – Follow symbolic links instead of just copying them

Return type

SolutionDirectory or correct subclass

Returns

The target directory

constantDir(region=None, processor=None)[source]
Parameters
  • region – Specify the region for cases with more than 1 mesh

  • processor – name of the processor directory

Returns

the name of the C{constant}-directory

Return type

str

controlDict()[source]
Returns

the name of the C{controlDict}

Return type

str

determineVCS()[source]

Find out whether this directory is controlled by a VCS and return the abbreviation of that VCS

property distributions

Return sub-directories that contain distribution-data

fullPath(time)[source]
getDictionaryContents(directory, name)[source]
Parameters
  • directory – Sub-directory of the case

  • name – name of the dictionary file

Returns

the contents of the file as a python data-structure

getDictionaryText(directory, name)[source]
Parameters
  • directory – Sub-directory of the case

  • name – name of the dictionary file

Returns

the contents of the file as a big string

getFirst()[source]
Returns

the first time for which a solution exists

Return type

str

getLast()[source]
Returns

the last time for which a solution exists

Return type

str

getParallelTimes()[source]

Get a list of the times in the processor0-directory

getParametersFromFile()[source]

Get Parameters from the file created by PrepareCase

getRegions(defaultRegion=False)[source]

Gets a list of all the available mesh regions by checking all directories in constant and using all those that have a polyMesh-subdirectory :param defaultRegion: should the default region also be added (as None)

getTimes()[source]
Returns

List of all the available times

initialDir()[source]
Returns

the name of the first time-directory (==initial

conditions) :rtype: str

isValid()[source]

Checks whether this is a valid case directory by looking for the system- and constant-directories and the controlDict-file

lastToArchive(name)[source]

copy the last solution (plus the backup-files to the archive)

Parameters

name – name of the sub-directory in the archive

latestDir()[source]
Returns

the name of the first last-directory (==simulation

results) :rtype: str

listFiles(directory=None)[source]

List all the plain files (not directories) in a subdirectory of the case :param directory: the subdirectory. If unspecified the case-directory itself is used :return: List with the plain filenames

makeFile(name)[source]

create a file in the solution directory and return a corresponding BasicFile-object

Parameters

name – Name of the file

Return type

BasicFile

missingFiles()[source]

Return a list of all the missing files and directories that are needed for a valid case

nrProcs()[source]

The number of directories with processor-data

packCase(tarname, last=False, exclude=[], verbose=False, additional=[], base=None)[source]

Packs all the important files into a compressed tarfile. Uses the essential-list and excludes the .svn-directories. Also excludes files ending with ~ :param tarname: the name of the tar-file :param last: add the last directory to the list of directories to be added :param exclude: List with additional glob filename-patterns to be excluded :param additional: List with additional glob filename-patterns that are to be added :param base: Different name that is to be used as the baseName for the case inside the tar

property pickledData

Get the pickled data files. Newest first

property pickledPlots

Get the pickled plot files. Newest first

polyMeshDir(region=None, time=None, processor=None)[source]
Parameters
  • region – Specify the region for cases with more than 1 mesh

  • time – Time for which the mesh should be looked at

  • processor – Name of the processor directory for decomposed cases

Returns

the name of the C{polyMesh}

Return type

str

processorDirs()[source]

List with the processor directories

regions()[source]

Detect sub-region cases by looking through constant and finding directories with polyMesh-directories

reread(force=False)[source]

Rescan the directory for the time directories

property samples

Return sub-directories that contain sample-data

setToParallel()[source]

Use the parallel times instead of the serial.

Used to reset the behaviour after it has been set by the constructor

property surfaces
symlinkCase(name, followSymlinks=False, maxLevel=1, relPath=False)[source]

create a clone of this case directory by creating a directory with symbolic links

Parameters
  • name – Name of the new case directory

  • maxLevel – Maximum level down to which directories are created instead of symbolically linked

  • followSymlinks – Follow symbolic links instead of just copying them

  • relPath – the created symbolic links are relative (instead of absolute)

Return type

SolutionDirectory or correct subclass

Returns

The target directory

systemDir(region=None, noRegion=False)[source]
Parameters

region – Specify the region for cases with more than 1 mesh

Returns

the name of the C{system}-directory

Return type

str

timeIndex(item, minTime=False)[source]

Finds the index of a directory that corresponds with the given parameter :param item: the time that should be found :param minTime: search for the time with the minimal difference. Otherwise an exact match will be searched

timeName(item, minTime=False)[source]

Finds the name of a directory that corresponds with the given parameter :param item: the time that should be found :param minTime: search for the time with the minimal difference. Otherwise an exact match will be searched

property timelines

Return sub-directories that contain timeline-data

writeDictionaryContents(directory, name, contents)[source]

Writes the contents of a dictionary :param directory: Sub-directory of the case :param name: name of the dictionary file :param contents: Python-dictionary with the dictionary contents

writeDictionaryText(directory, name, text)[source]

Writes the contents of a dictionary :param directory: Sub-directory of the case :param name: name of the dictionary file :param text: String with the dictionary contents