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

Sc/converters coupling #1558

Merged
merged 146 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
146 commits
Select commit Hold shift + click to select a range
bb07419
Added coupling converters.
SimonCan Jun 26, 2023
95892bf
Added generic converter_function for structured 2d meshes.
SimonCan Jun 29, 2023
4e82276
Added example elixir for coupling converters.
SimonCan Jul 3, 2023
7355ed0
Cleaned up converter coupling elixir.
SimonCan Jul 3, 2023
b8cabf4
Added equations in coupling converters.
SimonCan Jul 3, 2023
6d521a7
Added converter functions.
SimonCan Jul 4, 2023
ab8e750
Added identity converter function.
SimonCan Jul 4, 2023
24773c7
Autoformat for converter coupling implementation.
SimonCan Jul 5, 2023
c7da2cc
Added coupled converter elixir.
SimonCan Jul 5, 2023
98bf2cf
Corrected file name of coupled converters test.
SimonCan Jul 5, 2023
79da4e9
Merge branch 'main' into sc/converters_coupling
sloede Jul 11, 2023
d97302d
Removed redundant doc string.
SimonCan Jul 18, 2023
4a22bfe
Added function signature in doc string.
SimonCan Jul 18, 2023
f1f6ee8
Removed coverage_override in coupled tests.
SimonCan Jul 18, 2023
7a7def0
Removed old commented code.
SimonCan Jul 18, 2023
9045c5d
Update make.jl
SimonCan Jul 19, 2023
31cf07f
Update make.jl
SimonCan Jul 19, 2023
2f19315
Create coupling.md
SimonCan Jul 19, 2023
26d8dd3
Update coupling.md
SimonCan Jul 19, 2023
05579d1
Removed troublesome AnalysisCallbackCoupled from test.
SimonCan Jul 20, 2023
84c872e
Chenged coupling converter function.
SimonCan Jul 20, 2023
78f9948
Changed coupling converter function and updated tests.
SimonCan Jul 20, 2023
2e35046
Sepcialized coupling function call.
SimonCan Jul 24, 2023
6bc7c3b
Removed volume coupling from documentation to avoit confusion.
SimonCan Jul 25, 2023
b4decb7
Update src/coupling_converters/coupling_converters.jl
SimonCan Jul 25, 2023
54d8180
Removed redundant converter function for coupling.
SimonCan Jul 25, 2023
160c7bf
Removed redundant coupling converter file mentioned in some files.
SimonCan Jul 25, 2023
8a2187a
Merge branch 'sc/converters_coupling' of github.com:trixi-framework/T…
SimonCan Jul 25, 2023
cab33c2
Autoreformatted.
SimonCan Jul 25, 2023
024106c
Removed old coupled elixir and replaced it with one using converter f…
SimonCan Jul 25, 2023
5c93324
Merge branch 'main' into sc/converters_coupling
SimonCan Jul 28, 2023
c6d6da6
Updated errors for coupled tests.
SimonCan Aug 1, 2023
62d1408
Corrected test results for coupled equations.
SimonCan Aug 1, 2023
09fd691
Corrected comment.
SimonCan Aug 2, 2023
df67f00
Removed coupled test from special tests.
SimonCan Aug 2, 2023
35980a1
Removed coupled test from specials.
SimonCan Aug 2, 2023
aac8430
Chaned the coupling function to the identity.
SimonCan Aug 2, 2023
eaeec5b
Updated coupling tests.
SimonCan Aug 2, 2023
f161938
Updated errors for coupled test.
SimonCan Aug 3, 2023
fe5312b
Merge branch 'main' into sc/converters_coupling
SimonCan Aug 16, 2023
569da04
Added advice about binary compatability for coupled equations in the …
SimonCan Sep 7, 2023
ab417e7
Merge branch 'main' into sc/converters_coupling
SimonCan Sep 19, 2023
93fc571
Typo.
SimonCan Sep 19, 2023
fac0410
Merge branch 'main' into sc/converters_coupling
SimonCan Sep 28, 2023
00e5150
Merge branch 'main' into sc/converters_coupling
SimonCan Oct 2, 2023
b42d753
Merge branch 'main' into sc/converters_coupling
SimonCan Oct 4, 2023
d3334a8
Merge branch 'main' into sc/converters_coupling
SimonCan Oct 4, 2023
ed1fec9
Added numerical fluxes.
SimonCan Oct 5, 2023
3ea484d
Corrected rs copy routine. Now loop over this semi's components.
SimonCan Oct 6, 2023
e5a5dfb
Merge branch 'main' into sc/converters_coupling
SimonCan Oct 9, 2023
c87095e
Merge branch 'main' into sc/converters_coupling
SimonCan Oct 10, 2023
bfd4ec1
Reformatted equations source file.
SimonCan Oct 11, 2023
5ff438a
Merge branch 'main' into sc/converters_coupling
SimonCan Oct 12, 2023
f3e1ee6
Merge branch 'main' into sc/converters_coupling
SimonCan Oct 13, 2023
c4bc8b3
Removed problemating include of time_integration.jl.
SimonCan Oct 16, 2023
cdd984a
Removed export of deleted methods.
SimonCan Oct 16, 2023
4668b26
Merge branch 'main' into sc/converters_coupling
SimonCan Oct 18, 2023
e572ac0
Merge branch 'main' into sc/converters_coupling
SimonCan Oct 19, 2023
6eb92b6
Reverted to old version of compressible Euler multicomponent with no …
SimonCan Oct 20, 2023
8d26189
Renamed documentation file for multi-physics coupling.
SimonCan Oct 20, 2023
afbcc9d
Renamed doc reference.
SimonCan Oct 20, 2023
e730c9a
Update src/semidiscretization/semidiscretization_coupled.jl
SimonCan Oct 20, 2023
29f82f9
Merge branch 'main' into sc/converters_coupling
SimonCan Oct 20, 2023
2747e85
Merge branch 'main' into sc/converters_coupling
SimonCan Oct 24, 2023
1cbed94
Update docs/src/multi-physics_coupling.md
SimonCan Oct 24, 2023
fefbe59
Update docs/src/multi-physics_coupling.md
SimonCan Oct 24, 2023
f9ab642
Update docs/src/multi-physics_coupling.md
SimonCan Oct 24, 2023
b1f63dc
Reinstated structured_2d_dgsem coupled in special tests.
SimonCan Oct 24, 2023
4c3254b
Update examples/structured_2d_dgsem/elixir_advection_coupled.jl
SimonCan Oct 24, 2023
64e8dda
Renamed CouplingFunction to CouplingConverter.
SimonCan Oct 24, 2023
bd59f72
Update src/semidiscretization/semidiscretization_coupled.jl
SimonCan Oct 24, 2023
2331cc1
Cleaned the copy of coupled boundary values.
SimonCan Oct 24, 2023
35bffba
Reduced time span for example coupling elixir.
SimonCan Oct 24, 2023
488cef8
Removed redundant loop.
SimonCan Oct 24, 2023
81a10d0
Applied formatter.
SimonCan Oct 24, 2023
f407e1a
git pushMerge branch 'sc/converters_coupling' of github.com:trixi-fra…
SimonCan Oct 24, 2023
0579dc1
Removed default coupling covnerter function.
SimonCan Oct 24, 2023
baf28fd
Moved coupling converter function into elixir.
SimonCan Oct 24, 2023
7c3d558
Merge branch 'main' into sc/converters_coupling
SimonCan Oct 24, 2023
a4971a5
Apply suggestions from code review
sloede Oct 25, 2023
3491b1a
Update docs/make.jl
sloede Oct 25, 2023
0ff77e2
Removed coupling_converters.jl from the include.
SimonCan Oct 25, 2023
1993560
Corrected introduced issue with coupling boundary copy.
SimonCan Oct 25, 2023
d5129e2
Corrected comment on final simulation time.
SimonCan Oct 25, 2023
21f203f
Updated errors for coupled test to reflect changed final simulation t…
SimonCan Oct 25, 2023
fe4b216
Merge branch 'main' into sc/converters_coupling
SimonCan Oct 25, 2023
4f92bc6
Added miladd.
SimonCan Oct 30, 2023
8789c4b
Corrected coordinate finding in semidiscretization_coupled.
SimonCan Nov 3, 2023
87609bc
Fixed issued related to memory allocation.
SimonCan Nov 3, 2023
2906208
Corrected loop over semidiscretization.
SimonCan Nov 3, 2023
9ee224f
Removed commented out code.
SimonCan Nov 3, 2023
329cbf6
Merge branch 'main' into sc/converters_coupling
SimonCan Nov 6, 2023
dd847e4
Fixed type instability with loops over semidiscretizations using
SimonCan Nov 7, 2023
a54a9e8
Removed obsolete code.
SimonCan Nov 8, 2023
eb14606
Fixed another typa instability in coupled semidiscretization.
SimonCan Nov 8, 2023
20a1676
Cleaning up of the coupled semidiscretization.
SimonCan Nov 8, 2023
58ec8fb
Autoformatted coupled semidiscretization.
SimonCan Nov 8, 2023
52fcb5b
Merge branch 'main' into sc/converters_coupling
SimonCan Nov 8, 2023
ee197c1
Merge branch 'main' into sc/converters_coupling
SimonCan Nov 9, 2023
6886bff
Merge branch 'main' into sc/converters_coupling
SimonCan Nov 13, 2023
49b121e
Fixed last type instability in coupling.
SimonCan Nov 14, 2023
3b5d492
Autoformatter on semidiscretization.
SimonCan Nov 14, 2023
538e401
Fixed bug in boundary values copy that arose when coupling multiple s…
SimonCan Nov 15, 2023
e6b621a
aplpied autoformatter on coupled semidiscretization.
SimonCan Nov 15, 2023
9da5c9f
Merge branch 'main' into sc/converters_coupling
SimonCan Nov 16, 2023
03f7696
Merge branch 'main' into sc/converters_coupling
SimonCan Nov 17, 2023
8b6f7b3
Merge branch 'main' into sc/converters_coupling
SimonCan Nov 20, 2023
cf262a8
Merge branch 'main' into sc/converters_coupling
SimonCan Nov 21, 2023
6737a43
Merge branch 'main' into sc/converters_coupling
SimonCan Nov 23, 2023
2a7fea3
Extended the structured 2d example elixir for the coupled advection
SimonCan Nov 23, 2023
e8c2d52
Updated test results for coupled advection in 2d to reflect
SimonCan Nov 23, 2023
4f76579
Added correct errors for tests for the coupled adveciton equations in…
SimonCan Nov 24, 2023
756eaf1
Merge branch 'main' into sc/converters_coupling
SimonCan Nov 24, 2023
8414741
Merge branch 'main' into sc/converters_coupling
SimonCan Nov 29, 2023
3ea1967
Merge branch 'main' into sc/converters_coupling
SimonCan Dec 4, 2023
824217c
Merge branch 'main' into sc/converters_coupling
SimonCan Dec 8, 2023
418796a
Update examples/structured_2d_dgsem/elixir_advection_coupled.jl
SimonCan Dec 11, 2023
fa4852b
Update examples/structured_2d_dgsem/elixir_advection_coupled.jl
SimonCan Dec 11, 2023
9b55294
Update src/semidiscretization/semidiscretization_coupled.jl
SimonCan Dec 11, 2023
c830e22
Update src/semidiscretization/semidiscretization_coupled.jl
SimonCan Dec 11, 2023
e064a56
Update src/semidiscretization/semidiscretization_coupled.jl
SimonCan Dec 11, 2023
9d8f4e5
Update src/semidiscretization/semidiscretization_coupled.jl
SimonCan Dec 11, 2023
6c60c3e
Update src/semidiscretization/semidiscretization_coupled.jl
SimonCan Dec 11, 2023
388a309
Update src/semidiscretization/semidiscretization_coupled.jl
SimonCan Dec 11, 2023
0e7fd19
Update src/semidiscretization/semidiscretization_coupled.jl
SimonCan Dec 11, 2023
b4493a2
Corrected foreach_enumerate implementation.
SimonCan Dec 11, 2023
98f7eed
Merge branch 'sc/converters_coupling' of github.com:trixi-framework/T…
SimonCan Dec 11, 2023
bbca47e
Merge branch 'main' into sc/converters_coupling
sloede Dec 14, 2023
4753bf5
Merge branch 'main' into sc/converters_coupling
SimonCan Dec 17, 2023
012e01e
Merge branch 'main' into sc/converters_coupling
sloede Dec 19, 2023
34e6fcd
Fix closing parens
sloede Dec 19, 2023
4c2b90b
Remove unused recursive rhs!
sloede Dec 19, 2023
f0911c0
Pass equations to converter function
sloede Dec 19, 2023
dbf2aea
Apply formatting
sloede Dec 19, 2023
307f68a
Merge branch 'main' into sc/converters_coupling
SimonCan Jan 4, 2024
401e835
Reverted copy_to_coupled_boundary to previou version
SimonCan Jan 9, 2024
6472d36
Corrected computation of coupled semidiscretizations and fixed memory…
SimonCan Jan 11, 2024
52f7645
Removed redundant nelements function, as it is no longer used.
SimonCan Jan 15, 2024
dc9dda2
Merge branch 'main' into sc/converters_coupling
SimonCan Jan 15, 2024
9bfc7cc
Applied autoformatter.
SimonCan Jan 15, 2024
26e4c94
Merge branch 'main' into sc/converters_coupling
SimonCan Jan 22, 2024
d313172
Merge branch 'main' into sc/converters_coupling
sloede Jan 29, 2024
2d2194f
Improvements in style and added info about passing equations
SimonCan Jan 30, 2024
05ba222
Merge branch 'main' into sc/converters_coupling
SimonCan Jan 30, 2024
c3e6037
Merge branch 'main' into sc/converters_coupling
sloede Jan 31, 2024
b490cbf
Restored timings in semidiscretization coupled.
SimonCan Jan 31, 2024
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
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ makedocs(
],
"Time integration" => "time_integration.md",
"Callbacks" => "callbacks.md",
"Coupling" => "multi-physics_coupling.md"
],
"Advanced topics & developers" => [
"Conventions" =>"conventions.md",
Expand Down
46 changes: 46 additions & 0 deletions docs/src/multi-physics_coupling.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# [Multi-physics coupling](@id multi-physics-coupling)
A complex simulation can consist of different spatial domains in which
different equations are being solved, different numerical methods being used
or the grid structure is different.
One example would be a fluid in a tank and an extended hot plate attached to it.
We would then like to solve the Navier-Stokes equations in the fluid domain
and the heat conduction equations in the plate.
The coupling would happen at the interface through the exchange of thermal energy.


## Converter coupling
It may happen that the two systems to be coupled do not share any variables, but
share some of the physics.
In such a situation, the same physics is just represented in a different form and with
a different set of variables.
This is the case, for instance assuming two domains, if there is a fluid system in one domain
and a Vlasov system in the other domain.
In that case we would have variables representing distribution functions of
the Vlasov system on one side and variables representing the mechanical quantities, like density,
of the fluid system.
To translate the fields from one description to the other one needs to use
converter functions.
These functions need to be hand tailored by the user in the elixir file where each
pair of coupled systems requires two coupling functions, one for each direction.

In the general case, we have a system $A$ with $m$ variables
$u_{A,i}, \: i = 1, \dots, m$ and another
system $B$ with $n$ variables $u_{B,j}, \: j = 1, \dots, n$.
We then define two coupling functions, one that transforms $u_A$ into $u_B$
sloede marked this conversation as resolved.
Show resolved Hide resolved
and one that goes the other way.

In their minimal form they take the position vector $x$, state vector $u$
and the equations of the two coupled systems
and return the transformed variables.
By passing the equations we can make use of their parameters, if they are required.
Examples can be seen in `examples/structured_2d_dgsem/elixir_advection_coupled.jl`.


## Warning about binary compatibility
Currently the coordinate values on the nodes can differ by machine precision when
simulating the mesh and when splitting the mesh in multiple domains.
This is an issue coming from the coordinate interpolation on the nodes.
As a result, running a simulation in a single system and in two coupled domains
may result in a difference of the order of the machine precision.
While this is not an issue for most practical problems, it is best to keep this in mind when comparing test runs.

191 changes: 138 additions & 53 deletions examples/structured_2d_dgsem/elixir_advection_coupled.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,38 @@ using OrdinaryDiffEq
using Trixi

###############################################################################
# Coupled semidiscretization of two linear advection systems, which are connected periodically
# Coupled semidiscretization of four linear advection systems using converter functions such that
# they are also coupled across the domain boundaries to generate a periodic system.
#
# In this elixir, we have a square domain that is divided into a left half and a right half. On each
# half of the domain, a completely independent SemidiscretizationHyperbolic is created for the
# linear advection equations. The two systems are coupled in the x-direction and have periodic
# boundaries in the y-direction. For a high-level overview, see also the figure below:
# In this elixir, we have a square domain that is divided into a upper-left, lower-left,
SimonCan marked this conversation as resolved.
Show resolved Hide resolved
# upper-right and lower-right quarter. On each quarter
# of the domain, a completely independent SemidiscretizationHyperbolic is created for the
# linear advection equations. The four systems are coupled in the x and y-direction.
# For a high-level overview, see also the figure below:
#
# (-1, 1) ( 1, 1)
# ┌────────────────────┬────────────────────┐
# │ ↑ periodic ↑ │ ↑ periodic ↑ │
# │ │ │
# │ ↑ coupled ↑ │ ↑ coupled ↑ │
# │ │ │
# │ ========= │ ========= │
# │ system #1 │ system #2 │
# │ ========= │ ========= │
# │ │ │
# │<-- coupled │<-- coupled │
# │ coupled -->│ coupled -->│
# │ │ │
# │ ↓ coupled ↓ │ ↓ coupled ↓ │
# ├────────────────────┼────────────────────┤
# │ ↑ coupled ↑ │ ↑ coupled ↑ │
# │ │ │
# │ ========= │ ========= │
# │ system #3 │ system #4 │
# │ ========= │ ========= │
# │ │ │
# │ coupled -->│<-- coupled │
# │ │ │
# │<-- coupled │ coupled -->│
# │ │ │
# │<-- coupled │<-- coupled │
# │ coupled -->│ coupled -->│
# │ │ │
# │ ↓ periodic ↓ │ ↓ periodic ↓ │
# │ ↓ coupled ↓ │ ↓ coupled ↓ │
# └────────────────────┴────────────────────┘
# (-1, -1) ( 1, -1)

Expand All @@ -36,60 +43,135 @@ equations = LinearScalarAdvectionEquation2D(advection_velocity)
# Create DG solver with polynomial degree = 3 and (local) Lax-Friedrichs/Rusanov flux as surface flux
solver = DGSEM(polydeg = 3, surface_flux = flux_lax_friedrichs)

# First mesh is the left half of a [-1,1]^2 square
coordinates_min1 = (-1.0, -1.0) # minimum coordinates (min(x), min(y))
# This will be the number of elements for each quarter/semidiscretization.
cells_per_dimension = (8, 8)

###########
# system #1
###########

coordinates_min1 = (-1.0, 0.0) # minimum coordinates (min(x), min(y))
coordinates_max1 = (0.0, 1.0) # maximum coordinates (max(x), max(y))

# Define identical resolution as a variable such that it is easier to change from `trixi_include`
cells_per_dimension = (8, 16)
mesh1 = StructuredMesh(cells_per_dimension, coordinates_min1, coordinates_max1)

cells_per_dimension1 = cells_per_dimension
# Define the coupling functions
coupling_function12 = (x, u, equations_other, equations_own) -> u
coupling_function13 = (x, u, equations_other, equations_own) -> u

mesh1 = StructuredMesh(cells_per_dimension1, coordinates_min1, coordinates_max1)
# Define the coupling boundary conditions and the system it is coupled to.
boundary_conditions_x_neg1 = BoundaryConditionCoupled(2, (:end, :i_forward), Float64,
coupling_function12)
boundary_conditions_x_pos1 = BoundaryConditionCoupled(2, (:begin, :i_forward), Float64,
coupling_function12)
boundary_conditions_y_neg1 = BoundaryConditionCoupled(3, (:i_forward, :end), Float64,
coupling_function13)
boundary_conditions_y_pos1 = BoundaryConditionCoupled(3, (:i_forward, :begin), Float64,
coupling_function13)

# A semidiscretization collects data structures and functions for the spatial discretization
semi1 = SemidiscretizationHyperbolic(mesh1, equations, initial_condition_convergence_test,
solver,
boundary_conditions = (
# Connect left boundary with right boundary of right mesh
x_neg = BoundaryConditionCoupled(2,
(:end,
:i_forward),
Float64),
# Connect right boundary with left boundary of right mesh
x_pos = BoundaryConditionCoupled(2,
(:begin,
:i_forward),
Float64),
y_neg = boundary_condition_periodic,
y_pos = boundary_condition_periodic))

# Second mesh is the right half of a [-1,1]^2 square
coordinates_min2 = (0.0, -1.0) # minimum coordinates (min(x), min(y))
boundary_conditions = (x_neg = boundary_conditions_x_neg1,
x_pos = boundary_conditions_x_pos1,
y_neg = boundary_conditions_y_neg1,
y_pos = boundary_conditions_y_pos1))

###########
# system #2
###########

coordinates_min2 = (0.0, 0.0) # minimum coordinates (min(x), min(y))
coordinates_max2 = (1.0, 1.0) # maximum coordinates (max(x), max(y))

cells_per_dimension2 = cells_per_dimension
mesh2 = StructuredMesh(cells_per_dimension, coordinates_min2, coordinates_max2)

mesh2 = StructuredMesh(cells_per_dimension2, coordinates_min2, coordinates_max2)
# Define the coupling functions
coupling_function21 = (x, u, equations_other, equations_own) -> u
coupling_function24 = (x, u, equations_other, equations_own) -> u

# Define the coupling boundary conditions and the system it is coupled to.
boundary_conditions_x_neg2 = BoundaryConditionCoupled(1, (:end, :i_forward), Float64,
coupling_function21)
boundary_conditions_x_pos2 = BoundaryConditionCoupled(1, (:begin, :i_forward), Float64,
coupling_function21)
boundary_conditions_y_neg2 = BoundaryConditionCoupled(4, (:i_forward, :end), Float64,
coupling_function24)
boundary_conditions_y_pos2 = BoundaryConditionCoupled(4, (:i_forward, :begin), Float64,
coupling_function24)

# A semidiscretization collects data structures and functions for the spatial discretization
semi2 = SemidiscretizationHyperbolic(mesh2, equations, initial_condition_convergence_test,
solver,
boundary_conditions = (
# Connect left boundary with right boundary of left mesh
x_neg = BoundaryConditionCoupled(1,
(:end,
:i_forward),
Float64),
# Connect right boundary with left boundary of left mesh
x_pos = BoundaryConditionCoupled(1,
(:begin,
:i_forward),
Float64),
y_neg = boundary_condition_periodic,
y_pos = boundary_condition_periodic))

# Create a semidiscretization that bundles semi1 and semi2
semi = SemidiscretizationCoupled(semi1, semi2)
boundary_conditions = (x_neg = boundary_conditions_x_neg2,
x_pos = boundary_conditions_x_pos2,
y_neg = boundary_conditions_y_neg2,
y_pos = boundary_conditions_y_pos2))

###########
# system #3
###########

coordinates_min3 = (-1.0, -1.0) # minimum coordinates (min(x), min(y))
coordinates_max3 = (0.0, 0.0) # maximum coordinates (max(x), max(y))

mesh3 = StructuredMesh(cells_per_dimension, coordinates_min3, coordinates_max3)

# Define the coupling functions
coupling_function34 = (x, u, equations_other, equations_own) -> u
coupling_function31 = (x, u, equations_other, equations_own) -> u

# Define the coupling boundary conditions and the system it is coupled to.
boundary_conditions_x_neg3 = BoundaryConditionCoupled(4, (:end, :i_forward), Float64,
coupling_function34)
boundary_conditions_x_pos3 = BoundaryConditionCoupled(4, (:begin, :i_forward), Float64,
coupling_function34)
boundary_conditions_y_neg3 = BoundaryConditionCoupled(1, (:i_forward, :end), Float64,
coupling_function31)
boundary_conditions_y_pos3 = BoundaryConditionCoupled(1, (:i_forward, :begin), Float64,
coupling_function31)

# A semidiscretization collects data structures and functions for the spatial discretization
semi3 = SemidiscretizationHyperbolic(mesh3, equations, initial_condition_convergence_test,
solver,
boundary_conditions = (x_neg = boundary_conditions_x_neg3,
x_pos = boundary_conditions_x_pos3,
y_neg = boundary_conditions_y_neg3,
y_pos = boundary_conditions_y_pos3))

###########
# system #4
###########

coordinates_min4 = (0.0, -1.0) # minimum coordinates (min(x), min(y))
coordinates_max4 = (1.0, 0.0) # maximum coordinates (max(x), max(y))

mesh4 = StructuredMesh(cells_per_dimension, coordinates_min4, coordinates_max4)

# Define the coupling functions
coupling_function43 = (x, u, equations_other, equations_own) -> u
coupling_function42 = (x, u, equations_other, equations_own) -> u

# Define the coupling boundary conditions and the system it is coupled to.
boundary_conditions_x_neg4 = BoundaryConditionCoupled(3, (:end, :i_forward), Float64,
coupling_function43)
boundary_conditions_x_pos4 = BoundaryConditionCoupled(3, (:begin, :i_forward), Float64,
coupling_function43)
boundary_conditions_y_neg4 = BoundaryConditionCoupled(2, (:i_forward, :end), Float64,
coupling_function42)
boundary_conditions_y_pos4 = BoundaryConditionCoupled(2, (:i_forward, :begin), Float64,
coupling_function42)

# A semidiscretization collects data structures and functions for the spatial discretization
semi4 = SemidiscretizationHyperbolic(mesh4, equations, initial_condition_convergence_test,
solver,
boundary_conditions = (x_neg = boundary_conditions_x_neg4,
x_pos = boundary_conditions_x_pos4,
y_neg = boundary_conditions_y_neg4,
y_pos = boundary_conditions_y_pos4))

# Create a semidiscretization that bundles all the semidiscretizations.
semi = SemidiscretizationCoupled(semi1, semi2, semi3, semi4)

###############################################################################
# ODE solvers, callbacks etc.
Expand All @@ -104,7 +186,10 @@ summary_callback = SummaryCallback()
# The AnalysisCallback allows to analyse the solution in regular intervals and prints the results
analysis_callback1 = AnalysisCallback(semi1, interval = 100)
analysis_callback2 = AnalysisCallback(semi2, interval = 100)
analysis_callback = AnalysisCallbackCoupled(semi, analysis_callback1, analysis_callback2)
analysis_callback3 = AnalysisCallback(semi3, interval = 100)
analysis_callback4 = AnalysisCallback(semi4, interval = 100)
analysis_callback = AnalysisCallbackCoupled(semi, analysis_callback1, analysis_callback2,
analysis_callback3, analysis_callback4)

# The SaveSolutionCallback allows to save the solution to a file in regular intervals
save_solution = SaveSolutionCallback(interval = 100,
Expand Down
Loading
Loading