caelus.io – CML Input File Manipulation¶
Caelus/OpenFOAM Input File Interface¶
-
class
caelus.io.dictfile.BlockMeshDict(filename=None, populate_defaults=True)[source]¶ Bases:
caelus.io.dictfile.DictFileconstant/polyMesh/blockMeshDict interface
Parameters: filename (path) – Path to the input file -
create_default_entries()¶ Create defaults from property list
-
blocks¶
-
boundary¶
-
convertToMeters¶
-
edges¶
-
mergePatchPairs¶
-
vertices¶
-
-
class
caelus.io.dictfile.ChangeDictionaryDict(filename=None, populate_defaults=True)[source]¶ Bases:
caelus.io.dictfile.DictFilesystem/changeDictionaryDict interface
Parameters: filename (path) – Path to the input file -
create_default_entries()¶ Create defaults from property list
-
dictionaryReplacement¶
-
-
class
caelus.io.dictfile.CmlControls(filename=None, populate_defaults=True)[source]¶ Bases:
caelus.io.dictfile.DictFilecmlControls interface
Parameters: filename (path) – Path to the input file
-
class
caelus.io.dictfile.ControlDict(filename=None, populate_defaults=True)[source]¶ Bases:
caelus.io.dictfile.DictFilesystem/controlDict interface
Parameters: filename (path) – Path to the input file -
create_default_entries()¶ Create defaults from property list
-
adjustTimeStep¶
-
application¶
-
deltaT¶
-
endTime¶
-
functions¶ function object definitions in controlDict
-
graphFormat¶
-
maxCo¶
-
purgeWrite¶
-
runTimeModifiable¶
-
startFrom¶
-
startTime¶
-
stopAt¶
-
timeFormat¶
-
timePrecision¶
-
writeCompression¶
-
writeControl¶
-
writeFormat¶
-
writeInterval¶
-
writePrecision¶
-
-
class
caelus.io.dictfile.DecomposeParDict(filename=None, populate_defaults=True)[source]¶ Bases:
caelus.io.dictfile.DictFilesystem/decomposeParDict interface
Parameters: filename (path) – Path to the input file -
create_default_entries()¶ Create defaults from property list
-
method¶
-
numberOfSubdomains¶
-
-
class
caelus.io.dictfile.DictFile(filename=None, populate_defaults=True)[source]¶ Bases:
objectCaelus/OpenFOAM input file reader/writer
The default constructor does not read a file, but instead creates a new input file object. If a property list is provided, this is used to initialize the default entries. To read an existing file, the use of
DictFile.read_if_present()method is recommended.Parameters: filename (path) – Path to the input file -
classmethod
load(filename=None, debug=False)[source]¶ Load a Caelus input file from disk
Parameters: - filename (path) – Path to the input files
- debug (bool) – Turn on detailed errors
-
classmethod
read_if_present(casedir=None, filename=None, debug=False, populate_defaults=True)[source]¶ Read the file if present, else create object with default values
Parameters:
-
write(casedir=None, filename=None, update_object=True, write_header=True)[source]¶ Write a formatted Caelus input file
Parameters:
-
contents¶ Access entries within the Caelus CML dictionary
-
data= None¶ Contents of the file as a dictionary suitable for manipulation
-
filename= None¶ File to read/write data
-
header= None¶ Contents of the FoamFile sub-dictionary in the file
-
classmethod
-
class
caelus.io.dictfile.DictMeta(name, bases, cdict)[source]¶ Bases:
typeCreate property methods and add validation for properties.
This metaclass implements the boilerplate code necessary to add getter/setters for various entries found in a Caelus input file. It expects a class variable
_dict_propertiesthat contains tuples for the various entries in the input file. The tuple can be of two forms:- (name, default_value)
- (name, default_value, valid_values)
If the default_value is not None, then this value will be used to automatically initialize the particular entry by
create_default_entries()method. Ifvalid_valuesare provided, any attempt to set/modify this value will be checked to ensure that only the allowed values are used.
-
class
caelus.io.dictfile.FvSchemes(filename=None, populate_defaults=True)[source]¶ Bases:
caelus.io.dictfile.DictFilesystem/fvSchemes interface
Parameters: filename (path) – Path to the input file -
create_default_entries()¶ Create defaults from property list
-
ddtSchemes¶
-
divSchemes¶
-
fluxRequired¶
-
gradSchemes¶
-
interpolationSchemes¶
-
laplacianSchemes¶
-
snGradSchemes¶
-
-
class
caelus.io.dictfile.FvSolution(filename=None, populate_defaults=True)[source]¶ Bases:
caelus.io.dictfile.DictFilesystem/fvSolution interface
Parameters: filename (path) – Path to the input file -
create_default_entries()¶ Create defaults from property list
-
PIMPLE¶
-
PISO¶
-
SIMPLE¶
-
potentialFlow¶
-
relaxationFactors¶
-
solvers¶
-
-
class
caelus.io.dictfile.LESProperties(filename=None, populate_defaults=True)[source]¶ Bases:
caelus.io.dictfile.TurbModelPropsconstant/LESProperties interface
Parameters: filename (path) – Path to the input file -
create_default_entries()[source]¶ Create the default turbulence model entries
In addition to the default options specified in turbulence properties class, this also triggers the default entries for delta.
-
delta¶ LES delta
-
-
class
caelus.io.dictfile.PolyMeshBoundary(filename=None, populate_defaults=True)[source]¶ Bases:
caelus.io.dictfile.DictFileconstant/polyMesh/boundary interface
Parameters: filename (path) – Path to the input file
-
class
caelus.io.dictfile.RASProperties(filename=None, populate_defaults=True)[source]¶ Bases:
caelus.io.dictfile.TurbModelPropsconstant/RASProperties interface
Parameters: filename (path) – Path to the input file
-
class
caelus.io.dictfile.TransportProperties(filename=None, populate_defaults=True)[source]¶ Bases:
caelus.io.dictfile.DictFileconstant/transportProperties interface
Parameters: filename (path) – Path to the input file -
create_default_entries()¶ Create defaults from property list
-
transportModel¶
-
-
class
caelus.io.dictfile.TurbModelProps(filename=None, populate_defaults=True)[source]¶ Bases:
caelus.io.dictfile.DictFileCommon interface for LES/RAS models
Parameters: filename (path) – Path to the input file -
create_default_entries()¶ Create defaults from property list
-
coeffs¶ Turbulence model coefficients
This represents the sub-dictionary (e.g., kOmegaSSTCoeffs, SmagorinksyCoeffs) containing the additional parameters necessary for the turbulence model. The accessor automatically populates the right name when generating the dictionary depending on the turbulence model selected.
-
model¶ Turbulence model
Depending on the type (RANS or LES), this is the entry RASModel or LESModel respectively in the RASProperties and LESProperties file. To simplify access, it is simply named model here.
-
printCoeffs¶
-
turbulence¶
-
-
class
caelus.io.dictfile.TurbulenceProperties(filename=None, populate_defaults=True)[source]¶ Bases:
caelus.io.dictfile.DictFileconstant/turbulenceProperties interface
Parameters: filename (path) – Path to the input file -
create_default_entries()¶ Create defaults from property list
-
simulationType¶
-
-
caelus.io.dictfile.cml_std_files= {'LESProperties': <class 'caelus.io.dictfile.LESProperties'>, 'RASProperties': <class 'caelus.io.dictfile.RASProperties'>, 'blockMeshDict': <class 'caelus.io.dictfile.BlockMeshDict'>, 'changeDictionaryDict': <class 'caelus.io.dictfile.ChangeDictionaryDict'>, 'cmlControls': <class 'caelus.io.dictfile.CmlControls'>, 'controlDict': <class 'caelus.io.dictfile.ControlDict'>, 'decomposeParDict': <class 'caelus.io.dictfile.DecomposeParDict'>, 'fvSchemes': <class 'caelus.io.dictfile.FvSchemes'>, 'fvSolution': <class 'caelus.io.dictfile.FvSolution'>, 'transportProperties': <class 'caelus.io.dictfile.TransportProperties'>, 'turbulenceProperties': <class 'caelus.io.dictfile.TurbulenceProperties'>}¶ Mapping of standard files known to exist in a case directory
Caelus/OpenFOAM Dictionary Implementation¶
-
class
caelus.io.caelusdict.CaelusDict(**kwds)[source]¶ Bases:
caelus.utils.struct.StructCaelus Input File Dictionary
Initialize an ordered dictionary. The signature is the same as regular dictionaries, but keyword arguments are not recommended because their insertion order is arbitrary.
-
yaml_decoder¶ alias of
caelus.utils.struct.StructYAMLLoader
-
yaml_encoder¶ alias of
caelus.utils.struct.StructYAMLDumper
-
Caelus/OpenFOAM Input File Datatypes
-
class
caelus.io.dtypes.BoundaryList(value)[source]¶ Bases:
caelus.io.dtypes.FoamTypepolyMesh/boundary file
-
write_value(fh=<open file '<stdout>', mode 'w'>, indent_str='')[source]¶ Write as a Caelus/OpenFOAM entry
This method is called by
DictPrinterto format the data suitable for writing to a Caelus input file that can be read by the solvers.Parameters: - fh (file) – A valid file handle
- indent_str (str) – Padding for indentation
-
-
class
caelus.io.dtypes.CalcDirective(directive, value)[source]¶ Bases:
caelus.io.dtypes.FoamTypeA
#calcdirective entry- Example::
- radHalfAngle #calc “degToRad($halfAngle)”;
-
class
caelus.io.dtypes.CodeStream(value)[source]¶ Bases:
caelus.io.dtypes.FoamTypeA codestream entry
Contains C++ code that can be compiled and executed to determine dictionary parameters.
-
class
caelus.io.dtypes.DimValue(name, dims, value)[source]¶ Bases:
caelus.io.dtypes.FoamTypeA dimensioned value
A dimensioned value contains three parts: the name, units, and the value. Units are of type
Dimensionand value can be a scalar, vector, tensor or a symmetric tensor.
-
class
caelus.io.dtypes.Dimension(units=None, **kwargs)[source]¶ Bases:
caelus.io.dtypes.FoamTypeCaelus dimensional units
Represents the units of a dimensional quantity as an array of seven integers that represent the powers of the fundamental units: mass, length, time, temperature, quantity, current, and luminous intensity.
Provide an array of individual units as keyword arguments
Parameters: units (list) – A list of 5 or 7 entries
-
class
caelus.io.dtypes.Directive(directive, value)[source]¶ Bases:
caelus.io.dtypes.FoamTypeA Caelus directive type
Directives are keyword-less entries that indicate certain processing actions and begin with a hash (
#) symbol. For example, the#includeEtcdirective that can be used to include files fromfoamEtcdirectory.-
write_value(fh=<open file '<stdout>', mode 'w'>, indent_str='')[source]¶ Write out the dimensional value
-
directive= None¶ Type of directive (str)
-
value= None¶ Value of the directive (e.g., file to be included)
-
-
class
caelus.io.dtypes.Field(ftype, value)[source]¶ Bases:
caelus.io.dtypes.FoamTypeA field declaration
This class represents both uniform and non-uniform fields. The attribute
ftypeindicates the type of field and thevaluecontains the value for the given field. Uniform fields can be scalar, vector, tensor, or symmetric tensors. Non-uniform fields are typically aListTemplateentity.
-
class
caelus.io.dtypes.FoamType[source]¶ Bases:
objectBase class for a FOAM type
-
write_value(fh=<open file '<stdout>', mode 'w'>, indent_str='')[source]¶ Write as a Caelus/OpenFOAM entry
This method is called by
DictPrinterto format the data suitable for writing to a Caelus input file that can be read by the solvers.Parameters: - fh (file) – A valid file handle
- indent_str (str) – Padding for indentation
-
-
class
caelus.io.dtypes.ListTemplate(ltype, value)[source]¶ Bases:
caelus.io.dtypes.FoamTypeList<T> type entries
-
class
caelus.io.dtypes.MacroSubstitution(value)[source]¶ Bases:
caelus.io.dtypes.FoamTypeMacro substition without keyword
-
class
caelus.io.dtypes.MultipleValues(value)[source]¶ Bases:
caelus.io.dtypes.FoamTypeMultiple values for single keyword
- Example::
- laplacian(nuEff,U) Gauss linear corrected;
Here “Gauss linear corrected” is stored as an instance of this class to disambiguate between multi-valued entries and plain lists.
-
write_value(fh=<open file '<stdout>', mode 'w'>, indent_str='')[source]¶ Write as a Caelus/OpenFOAM entry
This method is called by
DictPrinterto format the data suitable for writing to a Caelus input file that can be read by the solvers.Parameters: - fh (file) – A valid file handle
- indent_str (str) – Padding for indentation
Caelus Input File Pretty-printer¶
-
class
caelus.io.printer.DictPrinter(buf=<open file '<stdout>', mode 'w'>, tab_width=4)[source]¶ Bases:
objectCaelus Input File Pretty-printer
Given a CaelusDict instance, this class will emit formatted data suitable for use with Caelus solvers
Parameters: - buf (file handle) – A valid buffer to output to
- tab_width (int) – Indentation width
-
write_dict(value)[source]¶ Pretty-print a Caelus dictionary type
Parameters: value (Mapping) – A valid python dict-like instance
-
write_list(value, recursive=False)[source]¶ Pretty-print a list entry
Lists are mixed-type data entries. Empty lists and short string lists are printed flat in the same line. All other lists have their entries printed on new lines.
Parameters:
-
write_ndarray(value, recursive=False)[source]¶ Pretty-print a numeric list
Parameters: - value (np.ndarray) – Array object
- recursive (bool) – Flag indicating whether it is part of a list or dict
-
write_value(value, recursive=False, indented=False)[source]¶ Pretty-print an RHS entry based on its type
Parameters:
-
keyword_fmt= '%-20s'¶ Default width for keywords
-
class
caelus.io.printer.Indenter(tab_width=4)[source]¶ Bases:
objectAn indentation utility for use with DictPrinter
Parameters: tab_width (int) – Default indentation width -
curr_indent= None¶ Current indentation column
-
indent_str¶ Return an indentation string
-
tab_width= None¶ Identation width
-
-
caelus.io.printer.foam_writer(*args, **kwds)[source]¶ Caelus/OpenFOAM file writer
Parameters: header (CaelusDict) – The FoamFile entries Yields: printer (DictPrinter) – A dictionary printer for printing data