Esempio n. 1
0
 def __init__(self, values=None):
     """Init class."""
     FoamFile.__init__(self, name='g',
                       cls='uniformDimensionedVectorField',
                       location='constant',
                       defaultValues=self.__defaultValues,
                       values=values)
 def __init__(self, values=None):
     """Init class."""
     FoamFile.__init__(
         self,
         name="transportProperties",
         cls="dictionary",
         location="constant",
         defaultValues=self.__defaultValues,
         values=values,
     )
Esempio n. 3
0
 def __init__(self, values=None):
     """Init class."""
     FoamFile.__init__(
         self,
         name="controlDict",
         cls="dictionary",
         location="system",
         defaultValues=self.__defaultValues,
         values=values,
     )
Esempio n. 4
0
    def LES(cls,
            LESModel='kEqn',
            delta='cubeRootVol',
            turbulence=True,
            printCoeffs=True,
            LESModelCoeffs=None,
            deltaCoeffs=None):
        """Large eddy simulation (LES) modelling.

        Args:
            LESModel: Name of LES turbulence model.
                Incompressible LES turbulence models.
                    DeardorffDiffStress, Smagorinsky, SpalartAllmarasDDES,
                    SpalartAllmarasDES, SpalartAllmarasIDDES, WALE, dynamicKEqn,
                    dynamicLagrangian, kEqn, kOmegaSSTDES
                Compressible LES turbulence models.
                    DeardorffDiffStress, Smagorinsky, SpalartAllmarasDDES,
                    SpalartAllmarasDES, SpalartAllmarasIDDES, WALE, dynamicKEqn,
                    dynamicLagrangian, kEqn, kOmegaSSTDES
            delta: Name of delta model.
            turbulence: Boolean switch to turn the solving of turbulence
                modelling on/off (default: True).
            printCoeffs: Boolean switch to print model coeffs to terminal at
                simulation start up (default: True).
            LESModelCoeffs: Dictionary of coefficients for the respective LESModel,
                to override the default coefficients.
            deltaCoeffs: Dictionary of coefficients for the delta model.
        """
        assert LESModel in cls.__LESModels, \
            '{} is not a valid input for LESModels.' \
            ' Try one of the models below:'.format(cls.__LESModels)

        values = {
            'simulationType': 'LES',
            'LES': {
                'LESModel': LESModel,
                'delta': delta,
                'turbulence': FoamFile.convertBoolValue(turbulence),
                'printCoeffs': FoamFile.convertBoolValue(printCoeffs)
            }
        }

        if LESModelCoeffs:
            values['LES'].update({'%sCoeffs' % LESModel: LESModelCoeffs})

        if deltaCoeffs:
            values['LES'].update({'%sCoeffs' % deltaCoeffs: deltaCoeffs})

        return cls(values=values)
Esempio n. 5
0
    def RAS(cls,
            RASModel='RNGkEpsilon',
            turbulence=True,
            printCoeffs=True,
            RASModel_coeffs=None):
        """Reynolds-averaged simulation (RAS) turbulence model.

        Read more: http://cfd.direct/openfoam/user-guide/turbulence/
        Watch this: https://www.youtube.com/watch?v=Eu_4ppppQmw

        Args:
            RASModel: Name of RAS turbulence model (default: RNGkEpsilon).
                Incompressible RAS turbulence models:
                    LRR, LamBremhorstKE, LaunderSharmaKE, LienCubicKE,
                    LienLeschziner, RNGkEpsilon, SSG, ShihQuadraticKE,
                    SpalartAllmaras, kEpsilon, kOmega, kOmegaSSTSAS, kkLOmega,
                    qZeta, realizableKE, v2f
                Compressible RAS turbulence models:
                    LRR, LaunderSharmaKE, RNGkEpsilon, SSG, SpalartAllmaras,
                    buoyantKEpsilon, kEpsilon, kOmega, kOmegaSSTSAS,
                    realizableKE, v2f
            turbulence: Boolean switch to turn the solving of turbulence
                modelling on/off (default: True).
            printCoeffs: Boolean switch to print model coeffs to terminal at
                simulation start up (default: True).
            RASModel_coeffs: Optional dictionary of coefficients for the respective
                RASModel, to override the default coefficients.
        """
        # check RASModel input
        assert RASModel in cls.__RASModels, \
            '{} is not a valid input for RASModel.' \
            ' Try one of the models below:\n{}'.format(RASModel, cls.__RASModels)

        values = {
            'simulationType': 'RAS',
            'RAS': {
                'RASModel': RASModel,
                'turbulence': FoamFile.convert_bool_value(turbulence),
                'printCoeffs': FoamFile.convert_bool_value(printCoeffs)
            }
        }

        if RASModel_coeffs:
            values['RAS'].update({'%sCoeffs' % RASModel: RASModel_coeffs})

        return cls(values=values)
Esempio n. 6
0
    def __init__(self, values=None):
        """Init class."""
        FoamFile.__init__(self,
                          name='blockMeshDict',
                          cls='dictionary',
                          location='system',
                          defaultValues=self.__defaultValues,
                          values=values)

        self.__BFBlockGeometries = None  # this will be overwritten in classmethods
        self.__vertices = None
        self.__isFromVertices = False
        # variables for 2d blockMeshDict
        self.__is2dInXDir = False
        self.__is2dInYDir = False
        self.__is2dInZDir = False
        self.__original3dVertices = None
    def LES(cls, LESModel='kEqn', delta='cubeRootVol', turbulence=True,
            printCoeffs=True, LESModelCoeffs=None, deltaCoeffs=None):
        """Large eddy simulation (LES) modelling.

        Args:
            LESModel: Name of LES turbulence model.
                Incompressible LES turbulence models.
                    DeardorffDiffStress, Smagorinsky, SpalartAllmarasDDES,
                    SpalartAllmarasDES, SpalartAllmarasIDDES, WALE, dynamicKEqn,
                    dynamicLagrangian, kEqn, kOmegaSSTDES
                Compressible LES turbulence models.
                    DeardorffDiffStress, Smagorinsky, SpalartAllmarasDDES,
                    SpalartAllmarasDES, SpalartAllmarasIDDES, WALE, dynamicKEqn,
                    dynamicLagrangian, kEqn, kOmegaSSTDES
            delta: Name of delta model.
            turbulence: Boolean switch to turn the solving of turbulence
                modelling on/off (default: True).
            printCoeffs: Boolean switch to print model coeffs to terminal at
                simulation start up (default: True).
            LESModelCoeffs: Dictionary of coefficients for the respective LESModel,
                to override the default coefficients.
            deltaCoeffs: Dictionary of coefficients for the delta model.
        """
        assert LESModel in cls.__LESModels, \
            '{} is not a valid input for LESModels.' \
            ' Try one of the models below:'.format(cls.__LESModels)

        values = {'simulationType': 'LES', 'LES': {
            'LESModel': LESModel,
            'delta': delta,
            'turbulence': FoamFile.convertBoolValue(turbulence),
            'printCoeffs': FoamFile.convertBoolValue(printCoeffs)}
        }

        if LESModelCoeffs:
            values['LES'].update({'%sCoeffs' % LESModel: LESModelCoeffs})

        if deltaCoeffs:
            values['LES'].update({'%sCoeffs' % deltaCoeffs: deltaCoeffs})

        return cls(values=values)
    def RAS(cls, RASModel='RNGkEpsilon', turbulence=True, printCoeffs=True,
            RASModelCoeffs=None):
        """Reynolds-averaged simulation (RAS) turbulence model.

        Read more: http://cfd.direct/openfoam/user-guide/turbulence/
        Watch this: https://www.youtube.com/watch?v=Eu_4ppppQmw

        Args:
            RASModel: Name of RAS turbulence model (default: RNGkEpsilon).
                Incompressible RAS turbulence models:
                    LRR, LamBremhorstKE, LaunderSharmaKE, LienCubicKE,
                    LienLeschziner, RNGkEpsilon, SSG, ShihQuadraticKE,
                    SpalartAllmaras, kEpsilon, kOmega, kOmegaSSTSAS, kkLOmega,
                    qZeta, realizableKE, v2f
                Compressible RAS turbulence models:
                    LRR, LaunderSharmaKE, RNGkEpsilon, SSG, SpalartAllmaras,
                    buoyantKEpsilon, kEpsilon, kOmega, kOmegaSSTSAS,
                    realizableKE, v2f
            turbulence: Boolean switch to turn the solving of turbulence
                modelling on/off (default: True).
            printCoeffs: Boolean switch to print model coeffs to terminal at
                simulation start up (default: True).
            RASModelCoeffs: Optional dictionary of coefficients for the respective
                RASModel, to override the default coefficients.
        """
        # check RASModel input
        assert RASModel in cls.__RASModels, \
            '{} is not a valid input for RASModel.' \
            ' Try one of the models below:'.format(cls.__RASModels)

        values = {'simulationType': 'RAS', 'RAS': {
            'RASModel': RASModel,
            'turbulence': FoamFile.convertBoolValue(turbulence),
            'printCoeffs': FoamFile.convertBoolValue(printCoeffs)}
        }

        if RASModelCoeffs:
            values['RAS'].update({'%sCoeffs' % RASModel: RASModelCoeffs})

        return cls(values=values)
Esempio n. 9
0
 def __init__(self, values=None):
     """Init class."""
     FoamFile.__init__(self, name='RASProperties', cls='dictionary',
                       location='constant', defaultValues=self.__defaultValues,
                       values=values)
Esempio n. 10
0
 def __init__(self, values=None):
     """Init class."""
     FoamFile.__init__(self, name='fvSolution', cls='dictionary',
                       location='system', defaultValues=self.__defaultValues,
                       values=values)
Esempio n. 11
0
 def __init__(self, values=None):
     """Init class."""
     FoamFile.__init__(self, name='fvSchemes', cls='dictionary',
                       location='system', defaultValues=self.__defaultValues,
                       values=values)
 def __init__(self, values=None):
     """Init class."""
     FoamFile.__init__(self, name='surfaceFeatureExtractDict', cls='dictionary',
                       location='system', default_values=self.__default_values,
                       values=values)
Esempio n. 13
0
grid_block_y_n = 10  # grid_block_y_n is a y number of convection grid blocks
viscosity = 2.e-2 / params['density']  # viscosity (m2/sec)
p_inlet = 300007.0 / params['density']  # inlet pressure (m2/sec2)
p_outlet = 300000.0 / params['density']  # outlet pressure (m2/sec2)

params['grid_block_x_n'] = int(grid_block_x_n)
params['grid_block_y_n'] = int(grid_block_y_n)
params['viscosity'] = float(viscosity)
params['diffusivity'] = float(diffusivity)
params['p_inlet'] = float(p_inlet)
params['p_outlet'] = float(p_outlet)

# controlDict

file_name = 'inOut/convection/system/controlDict'
with FoamFile(file_name) as f:
    foam_content = f.read()
foam_content['endTime'] = params['time'] + params['time_equil']
foam_content['deltaT'] = params['time_step']
with FoamFile(file_name, "w", foam_class="dictionary") as f:
    f.write(foam_content)

# transportProperties

file_name = 'inOut/convection/constant/transportProperties'
with FoamFile(file_name) as f:
    foam_content = f.read()
foam_content['nu'] = '[0 2 -1 0 0 0 0] ' + str(params['viscosity'])
with FoamFile(file_name, "w", foam_class="dictionary") as f:
    f.write(foam_content)