Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Follow naming convention in partitioned heat conduction - FEniCS #459

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions partitioned-heat-conduction/dirichlet-fenics/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -e -u

python3 ../solver-fenics/heat.py Dirichlet
2 changes: 0 additions & 2 deletions partitioned-heat-conduction/fenics/.gitignore

This file was deleted.

24 changes: 0 additions & 24 deletions partitioned-heat-conduction/fenics/run.sh

This file was deleted.

6 changes: 6 additions & 0 deletions partitioned-heat-conduction/neumann-fenics/clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/sh
set -e -u

. ../../tools/cleaning-tools.sh

clean_fenics .
4 changes: 4 additions & 0 deletions partitioned-heat-conduction/neumann-fenics/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -e -u

python3 ../solver-fenics/heat.py Neumann
3 changes: 0 additions & 3 deletions partitioned-heat-conduction/openfoam-solver/Make/files

This file was deleted.

8 changes: 0 additions & 8 deletions partitioned-heat-conduction/openfoam-solver/Make/options

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,11 @@ def determine_gradient(V_g, u, flux):


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

args = parser.parse_args()
participant_name = args.participantName

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

if args.dirichlet and not args.neumann:
if participant_name == ProblemType.DIRICHLET.value:
problem = ProblemType.DIRICHLET
domain_part = DomainPart.LEFT
elif args.neumann and not args.dirichlet:
elif participant_name == ProblemType.NEUMANN.value:
problem = ProblemType.NEUMANN
domain_part = DomainPart.RIGHT

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

# Initialize the adapter according to the specific participant
precice = Adapter(adapter_config_filename="precice-adapter-config.json")

if problem is ProblemType.DIRICHLET:
precice = Adapter(adapter_config_filename="precice-adapter-config-D.json")
precice.initialize(coupling_boundary, read_function_space=V, write_object=f_N_function)
precice_dt = precice.get_max_time_step_size()
elif problem is ProblemType.NEUMANN:
precice = Adapter(adapter_config_filename="precice-adapter-config-N.json")
precice.initialize(coupling_boundary, read_function_space=W, write_object=u_D_function)
precice_dt = precice.get_max_time_step_size()

precice_dt = precice.get_max_time_step_size()
dt = Constant(0)
dt.assign(np.min([fenics_dt, precice_dt]))
Comment on lines +102 to 111
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the fact that the new structure simplifies the mapping of solver to config file 👍


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,11 @@ def determine_gradient(V_g, u, flux):


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

args = parser.parse_args()
participant_name = args.participantName

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

if args.dirichlet and not args.neumann:
if participant_name == ProblemType.DIRICHLET.value:
problem = ProblemType.DIRICHLET
domain_part = DomainPart.LEFT
elif args.neumann and not args.dirichlet:
elif participant_name == ProblemType.NEUMANN.value:
problem = ProblemType.NEUMANN
domain_part = DomainPart.RIGHT

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

# Initialize the adapter according to the specific participant
precice = Adapter(adapter_config_filename="precice-adapter-config.json")

if problem is ProblemType.DIRICHLET:
precice = Adapter(adapter_config_filename="precice-adapter-config-D.json")
precice.initialize(coupling_boundary, read_function_space=V, write_object=f_N_function)
precice_dt = precice.get_max_time_step_size()
elif problem is ProblemType.NEUMANN:
precice = Adapter(adapter_config_filename="precice-adapter-config-N.json")
precice.initialize(coupling_boundary, read_function_space=W, write_object=u_D_function)
precice_dt = precice.get_max_time_step_size()

precice_dt = precice.get_max_time_step_size()
dt = Constant(0)
dt.assign(np.min([fenics_dt, precice_dt]))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ class ProblemType(Enum):
"""
Enum defines problem type. Details see above.
"""
DIRICHLET = 1 # Dirichlet problem
NEUMANN = 2 # Neumann problem
DIRICHLET = "Dirichlet" # Dirichlet problem
NEUMANN = "Neumann" # Neumann problem


class DomainPart(Enum):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def b_splines(precice, degree, dt):
for node in nodes:
val = precice.read_data(node)
# check if every key set is equal
assert(key_ref == val.keys())
assert (key_ref == val.keys())
weights[i] = val
i += 1

Expand Down