You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm doing a volume coupled simulation (with a f * dx term where f is read from preCICE) but the mapping makes the simulation extremely slow. I use nearest neighbor on a matching grid on the preCICE side, but the way FEniCS processes the mapping seems problematic. I assume the RBF interpolation takes a while, but it seems using the expression is slow too: the simulation solves a non-linear problem (with implicit time step) and each iteration is much slower than without preCICE, although the source term is unchanged.
Quickfix
I realized interpolating the coupling expression on a Function object reduces the overhead significantly (but not enough to my liking)
So instead of doing just
read_data=precice.read_data()
precice.update_coupling_expression(flow_expr, read_data)
# Solve a problem with flow_expr * dx in the formulation
I use
So instead of doing just
flow=Function(V)
read_data=precice.read_data()
precice.update_coupling_expression(flow_expr, read_data)
flow.interpolate(flow_expr)
# Solve a problem with flow * dx in the formulation
and get a significant speedup. Open questions:
Are there drawbacks to this approach? Does projecting reduce accuracy, or is that accuracy lost anyway when evaluating the expression ? Should we recommend it by default anytime the read data is not a Dirichlet BC?
Could this be implemented in the adapter (output a function instead of an expression directly) in a way such that performances increase ?
Would it be possible to completely skip the RBF part ? I assume this is trickier than it looks (see Compute CouplingExpression from point data via Minimization on P0DG function space #119 ), especially if we want it to work for weird element types (I'm using 1st order triangles so a direct mapping from preCICE to a function looks obvious, but making it general would be harder)
Run a simulation with 2 participants: flow-precice.py and either chemistry-precice.py or chemistry-precice-slow.py. A monolithic case chemistry.py without preCICE is given as reference.
The "slow" version with preCICE uses the custom expression in the variational problem, whereas the "fast" version interpolates the expression on a Function, which is used in the variational problem. As the name implies, it is much faster (the whole simulation is about 3-4 times faster on my computer!), although both are much slower than the monolithic code.
The text was updated successfully, but these errors were encountered:
As far as I understand we can close this issue due to #152. This issue is probably somehow also related to #162. But I would treat this as a follow-up task.
I'm closing this issue @boris-martin or @IshaanDesai: Please comment, if you disagree and we can always reopen this issue.
Context
I'm doing a volume coupled simulation (with a
f * dx
term wheref
is read from preCICE) but the mapping makes the simulation extremely slow. I use nearest neighbor on a matching grid on the preCICE side, but the way FEniCS processes the mapping seems problematic. I assume the RBF interpolation takes a while, but it seems using the expression is slow too: the simulation solves a non-linear problem (with implicit time step) and each iteration is much slower than without preCICE, although the source term is unchanged.Quickfix
I realized interpolating the coupling expression on a Function object reduces the overhead significantly (but not enough to my liking)
So instead of doing just
I use
So instead of doing just
and get a significant speedup. Open questions:
Reproduce
fenics_case_slow.tar.gz
Run a simulation with 2 participants:
flow-precice.py
and eitherchemistry-precice.py
orchemistry-precice-slow.py
. A monolithic casechemistry.py
without preCICE is given as reference.The "slow" version with preCICE uses the custom expression in the variational problem, whereas the "fast" version interpolates the expression on a Function, which is used in the variational problem. As the name implies, it is much faster (the whole simulation is about 3-4 times faster on my computer!), although both are much slower than the monolithic code.
The text was updated successfully, but these errors were encountered: