Package PyFoam :: Package RunDictionary :: Module SolutionDirectory :: Class SolutionDirectory
[hide private]
[frames] | no frames]

Class SolutionDirectory

source code


Represents a solution directory

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

A sub-directory (called the Archive) is created to which solution data is copied

Instance Methods [hide private]
 
__classifyDirectory(self, dPath) source code
 
__contains__(self, item) source code
 
__delitem__(self, key) source code
 
__getitem__(self, key) source code
 
__init__(self, name, archive='ArchiveDir', paraviewLink=True, parallel=False, addLocalConfig=False, tolerant=False, region=None)
x.__init__(...) initializes x; see help(type(x)) for signature
source code
 
__iter__(self) source code
 
__len__(self) source code
 
__scanForPostproc(self, dirName) source code
 
__scanPostproc(self) source code
 
__setitem__(self, key, value) source code
 
__symlinkDir(self, src, dest, toProcess, maxLevel, relPath, polyDirs, symlinks) source code
 
addBackup(self, pth)
add file to list of files that are to be copied to the archive
source code
 
addLocalConfig(self)
Add the local configuration file of the case to the configuration
source code
 
addPostprocDir(self, dirName, fail=True) source code
 
addToClone(self, name)
add directory to the list that is needed to clone this case
source code
 
addToHistory(self, *text)
Adds a line with date and username to a file 'PyFoamHistory' that resides in the local directory
source code
 
addToTar(self, tar, pattern, exclude=[], base=None)
The workhorse for the packCase-method
source code
str
blockMesh(self, region=None)
Returns: the name of the blockMeshDict if it exists.
source code
str
boundaryDict(self, region=None, time=None, processor=None)
Returns: name of the boundary-file
source code
 
clear(self, after=None, processor=True, pyfoam=True, keepLast=False, vtk=True, keepRegular=False, keepParallel=False, keepInterval=None, removeAnalyzed=False, clearHistory=False, clearParameters=False, functionObjectData=False, additional=[])
One-stop-shop to remove data
source code
 
clearOther(self, pyfoam=True, removeAnalyzed=False, clearHistory=False, clearParameters=False)
Remove additional directories
source code
 
clearPattern(self, globPat)
Clear all files that fit a certain shell (glob) pattern
source code
 
clearResults(self, after=None, removeProcs=False, keepLast=False, vtk=True, keepRegular=False, keepParallel=False, keepInterval=None, functionObjectData=False, additional=[])
remove all time-directories after a certain time.
source code
SolutionDirectory or correct subclass
cloneCase(self, name, svnRemove=True, followSymlinks=False)
create a clone of this case directory.
source code
str
constantDir(self, region=None, processor=None)
Returns: the name of the constant-directory
source code
str
controlDict(self)
Returns: the name of the controlDict
source code
 
determineVCS(self)
Find out whether this directory is controlled by a VCS and return the abbreviation of that VCS
source code
 
fullPath(self, time) source code
 
getDictionaryContents(self, directory, name)
Returns: the contents of the file as a python data-structure
source code
 
getDictionaryText(self, directory, name)
Returns: the contents of the file as a big string
source code
str
getFirst(self)
Returns: the first time for which a solution exists
source code
str
getLast(self)
Returns: the last time for which a solution exists
source code
 
getParallelTimes(self)
Get a list of the times in the processor0-directory
source code
 
getParametersFromFile(self)
Get Parameters from the file created by PrepareCase
source code
 
getRegions(self, defaultRegion=False)
Gets a list of all the available mesh regions by checking all directories in constant and using all those that have a polyMesh-subdirectory
source code
 
getTimes(self)
Returns: List of all the available times
source code
str
initialDir(self)
Returns: the name of the first time-directory (==initial conditions)
source code
 
isValid(self)
Checks whether this is a valid case directory by looking for the system- and constant-directories and the controlDict-file
source code
 
lastToArchive(self, name)
copy the last solution (plus the backup-files to the archive)
source code
str
latestDir(self)
Returns: the name of the first last-directory (==simulation results)
source code
 
listFiles(self, directory=None)
List all the plain files (not directories) in a subdirectory of the case
source code
BasicFile
makeFile(self, name)
create a file in the solution directory and return a corresponding BasicFile-object
source code
 
missingFiles(self)
Return a list of all the missing files and directories that are needed for a valid case
source code
 
nrProcs(self)
The number of directories with processor-data
source code
 
packCase(self, tarname, last=False, exclude=[], additional=[], base=None)
Packs all the important files into a compressed tarfile.
source code
str
polyMeshDir(self, region=None, time=None, processor=None)
Returns: the name of the polyMesh
source code
 
processorDirs(self)
List with the processor directories
source code
 
reread(self, force=False)
Rescan the directory for the time directories
source code
 
setToParallel(self)
Use the parallel times instead of the serial.
source code
SolutionDirectory or correct subclass
symlinkCase(self, name, followSymlinks=False, maxLevel=1, relPath=False)
create a clone of this case directory by creating a directory with symbolic links
source code
str
systemDir(self, region=None)
Returns: the name of the system-directory
source code
 
timeIndex(self, item, minTime=False)
Finds the index of a directory that corresponds with the given parameter
source code
 
timeName(self, item, minTime=False)
Finds the name of a directory that corresponds with the given parameter
source code
 
writeDictionaryContents(self, directory, name, contents)
Writes the contents of a dictionary
source code
 
writeDictionaryText(self, directory, name, text)
Writes the contents of a dictionary
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

    Inherited from Basics.Utilities.Utilities
 
copyfile(self, src, dst)
Encapsulates the shutil copyfile and provides an alternative for old Python-version
source code
 
copytree(self, src, dst, symlinks=False, force=False)
Encapsulates the shutil copytree and provides an alternative for old Python-version
source code
 
diskUsage(self, fpath)
Calculate the disk space used at the specified path in bytes
source code
 
execute(self, cmd, debug=False, workdir=None, echo=None)
Execute the command cmd.
source code
 
find(self, pattern, path, directoriesToo=True)
Find all files whose names match
source code
 
humanReadableSize(self, num)
Lifted from http://stackoverflow.com/questions/1094841/reusable-library-to-get-human-readable-version-of-file-size Gets a number in bytes and returns a human readable string
source code
 
listDirectory(self, d)
Lists the files in a directory, but excludes certain names and files with certain endings
source code
 
remove(self, f)
Remove a file if it exists.
source code
 
rmtree(self, dst, ignore_errors=False)
Encapsulates the shutil rmtree and provides an alternative for old Python-version
source code
 
which(self, progname)
Get the full path.
source code
 
writeDictionaryHeader(self, f)
Writes a dummy header so OpenFOAM accepts the file as a dictionary
source code
Class Variables [hide private]
    Inherited from Basics.Utilities.Utilities
  excludeNames = ['^.svn$', '~$']
Properties [hide private]
  distributions
Return sub-directories that contain distribution-data
  pickledData
Get the pickled data files.
  pickledPlots
Get the pickled plot files.
  samples
Return sub-directories that contain sample-data
  surfaces
  timelines
Return sub-directories that contain timeline-data

Inherited from object: __class__

Method Details [hide private]

__init__(self, name, archive='ArchiveDir', paraviewLink=True, parallel=False, addLocalConfig=False, tolerant=False, region=None)
(Constructor)

source code 

x.__init__(...) initializes x; see help(type(x)) for signature

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
  • paraviewLink - Create a symbolic link controlDict.foam for paraview
  • tolerant - do not fail for minor inconsistencies
  • parallel - use the first processor-subdirectory for the authorative information
  • region - Mesh region for multi-region cases
Overrides: object.__init__

addToClone(self, name)

source code 

add directory to the list that is needed to clone this case

Parameters:
  • name - name of the subdirectory (the case directory is prepended)

blockMesh(self, region=None)

source code 
Parameters:
  • region - Specify the region for cases with more than 1 mesh
Returns: str
the name of the blockMeshDict if it exists. Returns an empty string if it doesn't

boundaryDict(self, region=None, time=None, processor=None)

source code 
Parameters:
  • region - Specify the region for cases with more than 1 mesh
Returns: str
name of the boundary-file

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

source code 

One-stop-shop to remove data

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

clearOther(self, pyfoam=True, removeAnalyzed=False, clearHistory=False, clearParameters=False)

source code 

Remove additional directories

Parameters:
  • pyfoam - rremove all directories typically created by PyFoam

clearPattern(self, globPat)

source code 

Clear all files that fit a certain shell (glob) pattern

Parameters:
  • glob - the pattern which the files are going to fit

clearResults(self, after=None, removeProcs=False, keepLast=False, vtk=True, keepRegular=False, keepParallel=False, keepInterval=None, functionObjectData=False, additional=[])

source code 

remove all time-directories after a certain time. If not time ist set the initial time is used

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

cloneCase(self, name, svnRemove=True, followSymlinks=False)

source code 

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
Returns: SolutionDirectory or correct subclass
The target directory

constantDir(self, region=None, processor=None)

source code 
Parameters:
  • region - Specify the region for cases with more than 1 mesh
  • processor - name of the processor directory
Returns: str
the name of the constant-directory

controlDict(self)

source code 
Returns: str
the name of the controlDict

getDictionaryContents(self, directory, name)

source code 
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(self, directory, name)

source code 
Parameters:
  • directory - Sub-directory of the case
  • name - name of the dictionary file
Returns:
the contents of the file as a big string

getFirst(self)

source code 
Returns: str
the first time for which a solution exists

getLast(self)

source code 
Returns: str
the last time for which a solution exists

getRegions(self, defaultRegion=False)

source code 

Gets a list of all the available mesh regions by checking all directories in constant and using all those that have a polyMesh-subdirectory

Parameters:
  • defaultRegion - should the default region also be added (as None)

getTimes(self)

source code 
Returns:
List of all the available times

initialDir(self)

source code 
Returns: str
the name of the first time-directory (==initial conditions)

lastToArchive(self, name)

source code 

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

Parameters:
  • name - name of the sub-directory in the archive

latestDir(self)

source code 
Returns: str
the name of the first last-directory (==simulation results)

listFiles(self, directory=None)

source code 

List all the plain files (not directories) in a subdirectory of the case

Parameters:
  • directory - the subdirectory. If unspecified the case-directory itself is used
Returns:
List with the plain filenames

makeFile(self, name)

source code 

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

Parameters:
  • name - Name of the file
Returns: BasicFile

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

source code 

Packs all the important files into a compressed tarfile. Uses the essential-list and excludes the .svn-directories. Also excludes files ending with ~

Parameters:
  • tarname - the name of the tar-file
  • last - add the last directory to the list of directories to be added
  • exclude - List with additional glob filename-patterns to be excluded
  • additional - List with additional glob filename-patterns that are to be added
  • base - Different name that is to be used as the baseName for the case inside the tar

polyMeshDir(self, region=None, time=None, processor=None)

source code 
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: str
the name of the polyMesh

setToParallel(self)

source code 

Use the parallel times instead of the serial.

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

symlinkCase(self, name, followSymlinks=False, maxLevel=1, relPath=False)

source code 

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)
Returns: SolutionDirectory or correct subclass
The target directory

systemDir(self, region=None)

source code 
Parameters:
  • region - Specify the region for cases with more than 1 mesh
Returns: str
the name of the system-directory

timeIndex(self, item, minTime=False)

source code 

Finds the index of a directory that corresponds with the given parameter

Parameters:
  • item - the time that should be found
  • minTime - search for the time with the minimal difference. Otherwise an exact match will be searched

timeName(self, item, minTime=False)

source code 

Finds the name of a directory that corresponds with the given parameter

Parameters:
  • item - the time that should be found
  • minTime - search for the time with the minimal difference. Otherwise an exact match will be searched

writeDictionaryContents(self, directory, name, contents)

source code 

Writes the contents of a dictionary

Parameters:
  • directory - Sub-directory of the case
  • name - name of the dictionary file
  • contents - Python-dictionary with the dictionary contents

writeDictionaryText(self, directory, name, text)

source code 

Writes the contents of a dictionary

Parameters:
  • directory - Sub-directory of the case
  • name - name of the dictionary file
  • text - String with the dictionary contents

Property Details [hide private]

distributions

Return sub-directories that contain distribution-data

Get Method:
unreachable.distributions(self) - Return sub-directories that contain distribution-data

pickledData

Get the pickled data files. Newest first

Get Method:
unreachable.pickledData(self) - Get the pickled data files.

pickledPlots

Get the pickled plot files. Newest first

Get Method:
unreachable.pickledPlots(self) - Get the pickled plot files.

samples

Return sub-directories that contain sample-data

Get Method:
unreachable.samples(self) - Return sub-directories that contain sample-data

surfaces

Get Method:
unreachable.surfaces(self)

timelines

Return sub-directories that contain timeline-data

Get Method:
unreachable.timelines(self) - Return sub-directories that contain timeline-data