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

Restrictions on using adapter for 3D cases #149

Open
IshaanDesai opened this issue Feb 6, 2022 · 7 comments
Open

Restrictions on using adapter for 3D cases #149

IshaanDesai opened this issue Feb 6, 2022 · 7 comments
Labels
bug Something isn't working help wanted Extra attention is needed student
Milestone

Comments

@IshaanDesai
Copy link
Member

Functionality to handle 3D cases was introduced in the adapter with #133, #146 and #147

However there are still several restrictions on the use of this functionality. The restrictions are:

  1. When quantities on the coupling boundaries are a set of PointSource objects, the adapter can used for 3D cases but it can only be run in serial. Parallel runs using MPI are forbidden. More information regarding this can be found in this Discourse post. It is expected that using FEniCS-X will resolve this problem.
  2. When quantities on the coupling boundaries are of the type of an Expression object, the adapter cannot be used in 3D. Only 2D cases are possible in this case. The main reason for this is the way in which we manually construct the interpolant. A more general strategy would help lift this restriction. Check out the issue: Compute CouplingExpression from point data via Minimization on P0DG function space #119 for one such idea.
@IshaanDesai IshaanDesai added bug Something isn't working help wanted Extra attention is needed labels Feb 6, 2022
@precice-bot
Copy link

This issue has been mentioned on preCICE Forum on Discourse. There might be relevant details there:

https://precice.discourse.group/t/3d-coupling-of-fenics-watchpoint-function-of-output-forces-and-serial-coupling-procedure/1018/4

@BenjaminRodenberg
Copy link
Member

I'm just providing a brief update on this from my current perspective today, because I just received a request by a user and I think it's useful to summarize this here:

Why is it complicated to do 3D cases in FEniCS with the adapter?

I think it might be complicated to set up a 3D case for several reasons:

  1. We currently don't have a lot of experience with 3D cases in FEniCS. There are also no corresponding tutorials.
  2. Parallelization might need updates to be able to handle 3D cases. Especially w.r.t mesh connectivity and the construction of ghost layers.
  3. Turning data that preCICE provides intro fuctions that FEniCS can use as boundary conditions might need some updates. Using data without mesh connectivity and, therefore, only simple mapping strategies should be relatively straightforward.

Generally I don't think there are a fundamental problem, but the actual implementation requires some work. For details on parallelization and data mapping see our FEniCS adapter paper.

@BenjaminRodenberg
Copy link
Member

Added the "student" label, because I think it might be a nice thesis topic to actually create a 3D tutorial + extend the adapter correspondingly.

@precice-bot
Copy link

This issue has been mentioned on preCICE Forum on Discourse. There might be relevant details there:

https://precice.discourse.group/t/capabilities-of-adapters-for-3d-cht/1310/3

@precice-bot
Copy link

This issue has been mentioned on preCICE Forum on Discourse. There might be relevant details there:

https://precice.discourse.group/t/capabilities-of-adapters-for-3d-cht/1310/4

@BenjaminRodenberg
Copy link
Member

Here is a rough plan on how someone could start working on this issue:

  • Comment out the assertions that enforce 2D and see where problems pop up. SegregatedRBFInterpolationExpression, for example, should work with minor modifications already in 3D.

  • Follow the test-driven-development path, if you want. At some point we need tests in any case and I think here it really helps to get started quickly. (For example, by creating a 3d version of the following test and see what happens:

    def test_convert_fenics_to_precice(self):
    """
    Test conversion from function to write_data
    """
    from fenicsprecice.adapter_core import convert_fenics_to_precice
    from sympy import lambdify, symbols, printing
    mesh = UnitSquareMesh(10, 10) # create dummy mesh
    # scalar valued
    V = FunctionSpace(mesh, 'P', 2) # Create function space using mesh
    x, y = symbols('x[0], x[1]')
    fun_sym = y + x * x
    fun_lambda = lambdify([x, y], fun_sym)
    fun_string = printing.ccode(fun_sym)
    expression = Expression(fun_string, degree=2)
    fenics_function = interpolate(expression, V)
    local_ids = []
    manual_sampling = []
    for v in vertices(mesh):
    local_ids.append(v.index())
    manual_sampling.append(fun_lambda(v.x(0), v.x(1)))
    data = convert_fenics_to_precice(fenics_function, local_ids)
    np.testing.assert_allclose(data, manual_sampling)
    # vector valued
    W = VectorFunctionSpace(mesh, 'P', 2) # Create function space using mesh
    fun_sym_x = y + x * x
    fun_sym_y = y * y + x * x * x * 2
    fun_lambda = lambdify([x, y], [fun_sym_x, fun_sym_y])
    fun_string = (printing.ccode(fun_sym_x), printing.ccode(fun_sym_y))
    expression = Expression(fun_string, degree=2)
    fenics_function = interpolate(expression, W)
    local_ids = []
    manual_sampling = []
    for v in vertices(mesh):
    local_ids.append(v.index())
    manual_sampling.append(fun_lambda(v.x(0), v.x(1)))
    data = convert_fenics_to_precice(fenics_function, local_ids)
    np.testing.assert_allclose(data, manual_sampling)

  • What's also important: For testing we would need to come up with a simple 3D tutorial case. But I imagine one could start with a modified version of the flow-over-heated-plate tutorial.

@precice-bot
Copy link

This issue has been mentioned on preCICE Forum on Discourse. There might be relevant details there:

https://precice.discourse.group/t/automatic-differentiation-of-coupled-system/1601/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed student
Projects
None yet
Development

No branches or pull requests

3 participants