# @license GPL-3.0+ <http://spdx.org/licenses/GPL-3.0+> """ Solution Parameter. Args: _filename: OpenFOAM filename that the values are belong to (e.g. blockMeshDict, fvSchemes). _values: new values as a valid OpenFOAM (c++) dictionary. replace_: Set to True if you want the original dictionary to be replaced by new values. Default is False which means the original dictionary will be only updated by new values. Returns: solutionParam: A solution parameter. """ ghenv.Component.Name = "Butterfly_Solution Parameter" ghenv.Component.NickName = "solutionParam" ghenv.Component.Message = 'VER 0.0.04\nMAR_14_2017' ghenv.Component.Category = "Butterfly" ghenv.Component.SubCategory = "06::Solution" ghenv.Component.AdditionalHelpFromDocStrings = "2" try: from butterfly.solution import SolutionParameter except ImportError as e: msg = '\nFailed to import butterfly:' raise ImportError('{}\n{}'.format(msg, e)) if _filename and _values: solutionParam = SolutionParameter.fromCppDictionary( _filename, _values, replace_, tRange_)
if _meshQuality_: raise NotImplementedError('MeshQuality is not implemented yet. It will be added soon.') values = {'castellatedMesh': str(_castellatedMesh_).lower(), 'snap': str(_snap_).lower(), 'addLayers': str(_addLayers_).lower(), 'castellatedMeshControls': { 'nCellsBetweenLevels': str(_nCellsBetweenLevels_), 'maxGlobalCells': str(_maxGlobalCells_) }, 'addLayersControls': { 'expansionRatio': str(_expansionRatio_), 'finalLayerThickness': str(_finalLayerThickness_), 'minThickness': str(_minThickness_), 'nLayerIter': str(_nLayerIter_)} } if _surfaceFeatureLevel_ is not None: values['snapControls'] = {'extractFeaturesRefineLevel': str(_surfaceFeatureLevel_)} if additionalParameters_: try: addedValues = CppDictParser(additionalParameters_).values except Exception as e: raise ValueError("Failed to load additionalParameters_:\n%s" % str(e)) else: values = update_dict(values, addedValues) snappyHexMeshDict = SolutionParameter('snappyHexMeshDict', values)
residualControl_: residualControl. probes_: probes. additionalParams_: List of solution parameters. Use solutionParameter component to create solutionParams. Returns: solutionParams: A list of solution parameters. """ ghenv.Component.Name = "Butterfly_Solution Parameters" ghenv.Component.NickName = "solutionParams" ghenv.Component.Message = 'VER 0.0.04\nNOV_19_2017' ghenv.Component.Category = "Butterfly" ghenv.Component.SubCategory = "06::Solution" ghenv.Component.AdditionalHelpFromDocStrings = "1" try: from butterfly.solution import SolutionParameter except ImportError as e: msg = '\nFailed to import butterfly:' raise ImportError('{}\n{}'.format(msg, e)) if controlDict_: controlDict_ = SolutionParameter.from_cpp_dictionary( 'controlDict', str(controlDict_)) if probes_: probes_ = SolutionParameter.from_cpp_dictionary('probes', str(probes_)) params = [controlDict_, probes_] + additionalParams_ solutionParams = (p for p in params if p)
blockMeshDict, fvSchemes). _values: new values as a valid OpenFOAM (c++) dictionary. replace_: Set to True if you want the original dictionary to be replaced by new values. Default is False which means the original dictionary will be only updated by new values. Returns: solutionParam: A solution parameter. """ ghenv.Component.Name = "Butterfly_Solution Parameter" ghenv.Component.NickName = "solutionParam" ghenv.Component.Message = "VER 0.0.03\nOCT_30_2016" ghenv.Component.Category = "Butterfly" ghenv.Component.SubCategory = "06::Solution" ghenv.Component.AdditionalHelpFromDocStrings = "2" try: from butterfly.solution import SolutionParameter except ImportError as e: msg = ( "\nFailed to import butterfly. Did you install butterfly on your machine?" + "\nYou can download the installer file from github: " + "https://github.com/mostaphaRoudsari/Butterfly/tree/master/plugin/grasshopper/samplefiles" + "\nOpen an issue on github if you think this is a bug:" + " https://github.com/mostaphaRoudsari/Butterfly/issues" ) raise ImportError("{}\n{}".format(msg, e)) if _filename and _values: solutionParam = SolutionParameter.fromCppDictionary(_filename, _values, replace_, tRange_)
values = { 'castellatedMesh': str(_castellated_mesh_).lower(), 'snap': str(_snap_).lower(), 'addLayers': str(_add_layers_).lower(), 'castellatedMeshControls': { 'nCellsBetweenLevels': str(_n_cells_btwn_levels_), 'maxGlobalCells': str(_max_global_cells_) }, 'addLayersControls': { 'expansionRatio': str(_expansion_ratio_), 'finalLayerThickness': str(_final_layer_thickness_), 'minThickness': str(_min_thickness_), 'nLayerIter': str(_n_layer_iter_) } } if _srf_feature_level_ is not None: values['snapControls'] = { 'extractFeaturesRefineLevel': str(_srf_feature_level_) } if additional_par_: try: addedValues = CppDictParser(additional_par_).values except Exception as e: raise ValueError("Failed to load additional_par_:\n%s" % str(e)) else: values = update_dict(values, addedValues) snappy_hex_mesh_dict = SolutionParameter('snappyHexMeshDict', values)
""" Solution Parameter. Args: _filename: OpenFOAM filename that the values are belong to (e.g. blockMeshDict, fvSchemes). _values: new values as a valid OpenFOAM (c++) dictionary. t_range_: Temperature range. replace_: Set to True if you want the original dictionary to be replaced by new values. Default is False which means the original dictionary will be only updated by new values. Returns: solution_par: A solution parameter. """ ghenv.Component.Name = "Butterfly_Solution Parameter" ghenv.Component.NickName = "solutionParam" ghenv.Component.Message = 'VER 0.0.05\nJAN_12_2019' ghenv.Component.Category = "Butterfly" ghenv.Component.SubCategory = "06::Solution" ghenv.Component.AdditionalHelpFromDocStrings = "2" try: from butterfly.solution import SolutionParameter except ImportError as e: msg = '\nFailed to import butterfly:' raise ImportError('{}\n{}'.format(msg, e)) if _filename and _values: solution_par = SolutionParameter.from_cpp_dictionary( _filename, _values, replace_, t_range_)
solutionParams: A list of solution parameters. """ ghenv.Component.Name = "Butterfly_Solution Parameters" ghenv.Component.NickName = "solutionParams" ghenv.Component.Message = 'VER 0.0.03\nOCT_30_2016' ghenv.Component.Category = "Butterfly" ghenv.Component.SubCategory = "06::Solution" ghenv.Component.AdditionalHelpFromDocStrings = "1" try: from butterfly.solution import SolutionParameter except ImportError as e: msg = '\nFailed to import butterfly. Did you install butterfly on your machine?' + \ '\nYou can download the installer file from github: ' + \ 'https://github.com/mostaphaRoudsari/Butterfly/tree/master/plugin/grasshopper/samplefiles' + \ '\nOpen an issue on github if you think this is a bug:' + \ ' https://github.com/mostaphaRoudsari/Butterfly/issues' raise ImportError('{}\n{}'.format(msg, e)) if controlDict_: controlDict_ = SolutionParameter.fromCppDictionary('controlDict', controlDict_) if probes_: probes_ = SolutionParameter.fromCppDictionary('probes', probes_) params = [controlDict_, probes_] + additionalParams_ solutionParams = (p for p in params if p)