Maybe due to my limited experience with PDEs solving I could not find the answer to the following issue. Let's say we have a simple advection along a line:
ClearAll[f1, sol]
line = NDSolve`FEM`ToElementMesh[FullRegion[1], {{0, 500}}]
sol=NDSolveValue[
{ D[f1[x, t], t] + 10 D[f1[x, t], x] == 0
, f1[x, 0] == 95 + 20 Exp[-(x-100)^2/50^2]
, DirichletCondition[ f1[x, t] == 95 , x == 0]
}
, f1
, {t, 0, 100}, x ∈ line
]
Manipulate[ Plot[sol[x, t], {x, 0, 500}, PlotRange -> {80, 120}], {t, 0, 100}]
I want to 'connect' an identical but independent second 'return line' so that the boundary condition is the value of f1[500, t]
. Let's start with connecting at one place at the moment though at the end I want to create a loop.
Probably a loop case can be solved with a dedicated setup but the point here is to learn how to connect evolution of different variable on different meshes.
Anyway, I started with just saying that f2
will travel in a opposite direction but I failed to connect its boundary condition to f1[500,t]
:
ClearAll[f1, f2, sol]
sol=NDSolveValue[
{ D[f1[x, t], t] + 10 D[f1[x, t], x] == 0
, D[f2[x, t], t] - 10 D[f2[x, t], x] == 0
, f1[x, 0] == 95 + 20 Exp[-(x-100)^2/50^2]
, f2[x, 0] == 95
, DirichletCondition[f1[x,t]==95, x==0]
, DirichletCondition[f2[x,t]==f1[x,t], x==500]
}
, {f1, f2}
, {t, 0, 100}, x \[Element] line
]
NDSolveValue::fembdcc: Cross-coupling of dependent variables in DirichletCondition[f2==f1,x==500] is not supported in this version.
I am fully aware that my approach could just be wrong. Or that it is fundamentally not possible (yet). It is hard to know when one just starts exploring NDSolve capabilities, thus the question.
So can this be solved and if so, how?