FlowAroundSphereCodeGenParameters.py 2.36 KB
Newer Older
1
2
3
4
5
6
import waLBerla as wlb
from lbmpy.relaxationrates import relaxation_rate_from_lattice_viscosity


class Scenario:
    def __init__(self):
7
8
        self.timesteps = 1001
        self.vtkWriteFrequency = 100
9
10
11
12
13

        self.cells = (384, 128, 128)
        self.blocks = (1, 1, 1)
        self.periodic = (0, 0, 0)

14
15
        self.constant_inflow = True

16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
        self.diameter_sphere = min(self.cells) // 2
        self.u_max = 0.1
        self.reynolds_number = 1000000

        kinematic_viscosity = (self.diameter_sphere * self.u_max) / self.reynolds_number

        self.omega = relaxation_rate_from_lattice_viscosity(kinematic_viscosity)

        self.total_cells = (self.cells[0] * self.blocks[0],
                            self.cells[1] * self.blocks[1],
                            self.cells[2] * self.blocks[2])

    @wlb.member_callback
    def config(self):
        return {
            'DomainSetup': {
                'blocks': self.blocks,
                'cellsPerBlock': self.cells,
                'periodic': self.periodic,
                'oneBlockPerProcess': True
            },
            'Parameters': {
                'timesteps': self.timesteps,
                'vtkWriteFrequency': self.vtkWriteFrequency,
                'omega': self.omega,
                'u_max': self.u_max,
                'reynolds_number': self.reynolds_number,
43
44
                'diameter_sphere': self.diameter_sphere,
                'constant_inflow': self.constant_inflow
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
            },
            'Boundaries': {
                'Border': [
                    {'direction': 'N', 'walldistance': -1, 'flag': 'NoSlip'},
                    {'direction': 'S', 'walldistance': -1, 'flag': 'NoSlip'},
                    {'direction': 'W', 'walldistance': -1, 'flag': 'UBB'},
                    {'direction': 'E', 'walldistance': -1, 'flag': 'Outflow'},
                    {'direction': 'T', 'walldistance': -1, 'flag': 'NoSlip'},
                    {'direction': 'B', 'walldistance': -1, 'flag': 'NoSlip'},
                ],
                'Body': [
                    {'shape': "sphere",
                     'midpoint': (int(0.40 * self.total_cells[0]), self.total_cells[1] // 2, self.total_cells[2] // 2),
                     'radius': self.diameter_sphere // 2,
                     'flag': 'NoSlip'}
60
                ],
61
62
63
64
65
66
            },
        }


scenarios = wlb.ScenarioManager()
scenarios.add(Scenario())