Skip to content

Commit fca2363

Browse files
Follow naming convention in partitioned heat conduction FEniCS (#459)
1 parent dadd93c commit fca2363

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+31
-60
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
set -e -u
3+
4+
python3 ../solver-fenics/heat.py Dirichlet

partitioned-heat-conduction/fenics/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

partitioned-heat-conduction/fenics/run.sh

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
set -e -u
3+
4+
. ../../tools/cleaning-tools.sh
5+
6+
clean_fenics .
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
set -e -u
3+
4+
python3 ../solver-fenics/heat.py Neumann

partitioned-heat-conduction/openfoam-solver/Make/files

Lines changed: 0 additions & 3 deletions
This file was deleted.

partitioned-heat-conduction/openfoam-solver/Make/options

Lines changed: 0 additions & 8 deletions
This file was deleted.

partitioned-heat-conduction/fenics/heat.py renamed to partitioned-heat-conduction/solver-fenics/heat.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,11 @@ def determine_gradient(V_g, u, flux):
5353

5454

5555
parser = argparse.ArgumentParser(description="Solving heat equation for simple or complex interface case")
56-
command_group = parser.add_mutually_exclusive_group(required=True)
57-
command_group.add_argument("-d", "--dirichlet", help="create a dirichlet problem", dest="dirichlet",
58-
action="store_true")
59-
command_group.add_argument("-n", "--neumann", help="create a neumann problem", dest="neumann", action="store_true")
56+
parser.add_argument("participantName", help="Name of the solver.", type=str, choices=[p.value for p in ProblemType])
6057
parser.add_argument("-e", "--error-tol", help="set error tolerance", type=float, default=10**-8,)
6158

6259
args = parser.parse_args()
60+
participant_name = args.participantName
6361

6462
fenics_dt = .01 # time step size
6563
# Error is bounded by coupling accuracy. In theory we would obtain the analytical solution.
@@ -68,10 +66,10 @@ def determine_gradient(V_g, u, flux):
6866
alpha = 3 # parameter alpha
6967
beta = 1.2 # parameter beta
7068

71-
if args.dirichlet and not args.neumann:
69+
if participant_name == ProblemType.DIRICHLET.value:
7270
problem = ProblemType.DIRICHLET
7371
domain_part = DomainPart.LEFT
74-
elif args.neumann and not args.dirichlet:
72+
elif participant_name == ProblemType.NEUMANN.value:
7573
problem = ProblemType.NEUMANN
7674
domain_part = DomainPart.RIGHT
7775

@@ -101,15 +99,14 @@ def determine_gradient(V_g, u, flux):
10199
precice, precice_dt, initial_data = None, 0.0, None
102100

103101
# Initialize the adapter according to the specific participant
102+
precice = Adapter(adapter_config_filename="precice-adapter-config.json")
103+
104104
if problem is ProblemType.DIRICHLET:
105-
precice = Adapter(adapter_config_filename="precice-adapter-config-D.json")
106105
precice.initialize(coupling_boundary, read_function_space=V, write_object=f_N_function)
107-
precice_dt = precice.get_max_time_step_size()
108106
elif problem is ProblemType.NEUMANN:
109-
precice = Adapter(adapter_config_filename="precice-adapter-config-N.json")
110107
precice.initialize(coupling_boundary, read_function_space=W, write_object=u_D_function)
111-
precice_dt = precice.get_max_time_step_size()
112108

109+
precice_dt = precice.get_max_time_step_size()
113110
dt = Constant(0)
114111
dt.assign(np.min([fenics_dt, precice_dt]))
115112

partitioned-heat-conduction/fenics/heatHigherOrder.py renamed to partitioned-heat-conduction/solver-fenics/heatHigherOrder.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,11 @@ def determine_gradient(V_g, u, flux):
6161

6262

6363
parser = argparse.ArgumentParser(description="Solving heat equation for simple or complex interface case")
64-
command_group = parser.add_mutually_exclusive_group(required=True)
65-
command_group.add_argument("-d", "--dirichlet", help="create a dirichlet problem", dest="dirichlet",
66-
action="store_true")
67-
command_group.add_argument("-n", "--neumann", help="create a neumann problem", dest="neumann", action="store_true")
64+
parser.add_argument("participantName", help="Name of the solver.", type=str, choices=[p.value for p in ProblemType])
6865
parser.add_argument("-e", "--error-tol", help="set error tolerance", type=float, default=10**-8,)
6966

7067
args = parser.parse_args()
68+
participant_name = args.participantName
7169

7270
fenics_dt = .01 # time step size
7371
# Error is bounded by coupling accuracy. In theory we would obtain the analytical solution.
@@ -76,10 +74,10 @@ def determine_gradient(V_g, u, flux):
7674
alpha = 3 # parameter alpha
7775
beta = 1.2 # parameter beta
7876

79-
if args.dirichlet and not args.neumann:
77+
if participant_name == ProblemType.DIRICHLET.value:
8078
problem = ProblemType.DIRICHLET
8179
domain_part = DomainPart.LEFT
82-
elif args.neumann and not args.dirichlet:
80+
elif participant_name == ProblemType.NEUMANN.value:
8381
problem = ProblemType.NEUMANN
8482
domain_part = DomainPart.RIGHT
8583

@@ -121,15 +119,14 @@ def determine_gradient(V_g, u, flux):
121119
precice, precice_dt, initial_data = None, 0.0, None
122120

123121
# Initialize the adapter according to the specific participant
122+
precice = Adapter(adapter_config_filename="precice-adapter-config.json")
123+
124124
if problem is ProblemType.DIRICHLET:
125-
precice = Adapter(adapter_config_filename="precice-adapter-config-D.json")
126125
precice.initialize(coupling_boundary, read_function_space=V, write_object=f_N_function)
127-
precice_dt = precice.get_max_time_step_size()
128126
elif problem is ProblemType.NEUMANN:
129-
precice = Adapter(adapter_config_filename="precice-adapter-config-N.json")
130127
precice.initialize(coupling_boundary, read_function_space=W, write_object=u_D_function)
131-
precice_dt = precice.get_max_time_step_size()
132128

129+
precice_dt = precice.get_max_time_step_size()
133130
dt = Constant(0)
134131
dt.assign(np.min([fenics_dt, precice_dt]))
135132

partitioned-heat-conduction/fenics/my_enums.py renamed to partitioned-heat-conduction/solver-fenics/my_enums.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ class ProblemType(Enum):
55
"""
66
Enum defines problem type. Details see above.
77
"""
8-
DIRICHLET = 1 # Dirichlet problem
9-
NEUMANN = 2 # Neumann problem
8+
DIRICHLET = "Dirichlet" # Dirichlet problem
9+
NEUMANN = "Neumann" # Neumann problem
1010

1111

1212
class DomainPart(Enum):

partitioned-heat-conduction/fenics/utils/utils.py renamed to partitioned-heat-conduction/solver-fenics/utils/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def b_splines(precice, degree, dt):
3030
for node in nodes:
3131
val = precice.read_data(node)
3232
# check if every key set is equal
33-
assert(key_ref == val.keys())
33+
assert (key_ref == val.keys())
3434
weights[i] = val
3535
i += 1
3636

0 commit comments

Comments
 (0)