|
6 | 6 | from thetaScheme import perform_partitioned_implicit_trapezoidal_rule_step, perform_partitioned_implicit_euler_step |
7 | 7 | import numpy as np |
8 | 8 | import tubePlotting |
9 | | - |
10 | 9 | import matplotlib.pyplot as plt |
11 | 10 | import matplotlib.animation as manimation |
12 | | - |
13 | 11 | from output import writeOutputToVTK |
14 | | - |
15 | 12 | import precice |
16 | 13 | from precice import action_write_initial_data, action_write_iteration_checkpoint, action_read_iteration_checkpoint |
17 | 14 |
|
| 15 | +# physical properties of the tube |
| 16 | +r0 = 1 / np.sqrt(np.pi) # radius of the tube |
| 17 | +a0 = r0**2 * np.pi # cross sectional area |
| 18 | +u0 = 10 # mean velocity |
| 19 | +ampl = 3 # amplitude of varying velocity |
| 20 | +frequency = 10 # frequency of variation |
| 21 | +t_shift = 0 # temporal shift of variation |
| 22 | +p0 = 0 # pressure at outlet |
| 23 | +kappa = 100 |
| 24 | + |
| 25 | +L = 10 # length of tube/simulation domain |
| 26 | +N = 100 |
| 27 | +dx = L / kappa |
| 28 | +# helper function to create constant cross section |
| 29 | + |
| 30 | +def velocity_in(t): return u0 + ampl * np.sin(frequency * |
| 31 | + (t + t_shift) * np.pi) # inflow velocity |
| 32 | + |
| 33 | + |
| 34 | +def crossSection0(N): |
| 35 | + return a0 * np.ones(N + 1) |
| 36 | + |
| 37 | + |
18 | 38 | parser = argparse.ArgumentParser() |
19 | 39 | parser.add_argument("configurationFileName", help="Name of the xml precice configuration file.", |
20 | 40 | nargs='?', type=str, default="../precice-config.xml") |
|
44 | 64 |
|
45 | 65 | print("Starting Fluid Solver...") |
46 | 66 |
|
47 | | -configFileName = args.configurationFileName |
48 | | - |
49 | | -# physical properties of the tube |
50 | | -r0 = 1 / np.sqrt(np.pi) # radius of the tube |
51 | | -a0 = r0**2 * np.pi # cross sectional area |
52 | | -u0 = 10 # mean velocity |
53 | | -ampl = 3 # amplitude of varying velocity |
54 | | -frequency = 10 # frequency of variation |
55 | | -t_shift = 0 # temporal shift of variation |
56 | | -p0 = 0 # pressure at outlet |
57 | | -kappa = 100 |
58 | | - |
59 | | - |
60 | | -def velocity_in(t): return u0 + ampl * np.sin(frequency * |
61 | | - (t + t_shift) * np.pi) # inflow velocity |
62 | | - |
63 | | - |
64 | | -L = 10 # length of tube/simulation domain |
65 | | -N = 100 |
66 | | -dx = L / kappa |
67 | | -# helper function to create constant cross section |
68 | | - |
69 | | - |
70 | | -def crossSection0(N): |
71 | | - return a0 * np.ones(N + 1) |
72 | | - |
73 | | - |
74 | 67 | print("N: " + str(N)) |
75 | 68 |
|
76 | | -solverName = "Fluid" |
77 | | - |
78 | 69 | print("Configure preCICE...") |
79 | | -interface = precice.Interface(solverName, configFileName, 0, 1) |
| 70 | +interface = precice.Interface("Fluid", args.configurationFileName, 0, 1) |
80 | 71 | print("preCICE configured...") |
81 | 72 |
|
82 | 73 | dimensions = interface.get_dimensions() |
@@ -110,11 +101,10 @@ def crossSection0(N): |
110 | 101 | vertexIDs = interface.set_mesh_vertices(meshID, grid) |
111 | 102 |
|
112 | 103 | t = 0 |
113 | | -precice_dt = 0.01 |
114 | 104 |
|
115 | 105 | print("Fluid: init precice...") |
116 | 106 | # preCICE defines timestep size of solver via precice-config.xml |
117 | | -interface.initialize() |
| 107 | +precice_dt = interface.initialize() |
118 | 108 |
|
119 | 109 | if interface.is_action_required(action_write_initial_data()): |
120 | 110 | interface.write_block_scalar_data(pressureID, vertexIDs, pressure) |
|
0 commit comments