butterfly.foamfile module¶
Foam File Class.
-
class
butterfly.foamfile.
Condition
(name, cls, location=None, file_format='ascii', default_values=None, values=None)[source]¶ Bases:
butterfly.foamfile.FoamFile
OpenFOAM conditions object.
Use this class to create conditions such as initialConditions and ABLConditions. Conditions don’t have OpenFOAM header. It’s only values.
-
class
butterfly.foamfile.
FoamFile
(name, cls, location=None, file_format='ascii', default_values=None, values=None)[source]¶ Bases:
object
FoamFile base class for OpenFOAM dictionaries.
Read (http://cfd.direct/openfoam/user-guide/basic-file-format/) for more information about FoamFile
-
name
¶ Filename (e.g. controlDict)
-
cls
¶ OpenFOAM class constructed from the data file concerned. Typically dictionary or a field, e.g. volVectorField
-
location
¶ Folder name (0, constant or system)
-
file_format
¶ File format (ascii / binary) (default: ascii)
-
classmethod
from_file
(filepath, location=None)[source]¶ Create a FoamFile from a file.
Parameters: - filepath – Full file path to dictionary.
- location – Optional folder name for location (0, constant or system)
-
get_value_by_parameter
(parameter)[source]¶ Get values for a given parameter by parameter name.
Parameters: parameter – Name of a parameter as a string.
-
isFoamFile
¶ Return True for FoamFile.
-
is_constant_file
¶ Check if the file location is ‘constant’ folder.
-
is_system_file
¶ Check if the file location is ‘system’ folder.
-
is_zero_file
¶ Check if the file location is folder 0.
-
parameters
¶ Get list of parameters.
-
save
(project_folder, sub_folder=None, overwrite=True)[source]¶ Save to file.
Parameters: - project_folder – Path to project folder as a string.
- sub_folder – Optional input for sub_folder (default: self.location).
-
set_value_by_parameter
(parameter, value)[source]¶ Set value for a parameter.
Parameters: - parameter – Name of a parameter as a string.
- value – Parameter value as a string.
-
update_values
(v, replace=False, mute=False)[source]¶ Update current values from dictionary v.
if key is not available in current values it will be added, if the key already exists it will be updated.
Returns: True is the dictionary is updated.
-
values
¶ Return values as a dictionary.
-
-
class
butterfly.foamfile.
FoamFileZeroFolder
(name, cls, location=None, file_format='ascii', default_values=None, values=None)[source]¶ Bases:
butterfly.foamfile.FoamFile
FoamFiles under 0 folder.
The main difference between FoamFileZeroFolder and FoamFile is that FoamFileZeroFolder has a method to set boundary fields based on input geometry (e.g. Butterfly objects).