How to combine MFD (meshless finite difference) with ADF (exact boundary constraint)

I am trying to combine MFD (meshless finite difference) with exact boundary condition (ADF) in a study.
MFD in Modulus v22.07 currently only accept single Node or model as input.
ADF (Exact boundary condition) requires a combination of two networks.
First network (Node): input x, output u_star
Second network (Node): input x and u_star, output u.
Therefore, I did not find any way to use MFD with exact boundary condition in Modulus v22.07.

Hi @Spartacus

Good question. This is correct that the finite derivative node does only accept a single model. However, you can pretty easily get around this limitation for instances where multiple models/nodes are needed using Modulus’ graph systems.

To be fair this isn’t a documented solution, its essentially similar to how constraints build their graph. Creating a graph for the MFD node will chain multiple nodes together, which can then be provided as a single model. Here’s an example:

    flow_net = instantiate_arch(
        input_keys=[Key("x"), Key("y")],
        output_keys=[Key("u"), Key("v")],
    flow_net = flow_net.make_node(name="flow_network", jit=cfg.jit)
   # No reason here to have a separate pressure network
   # Just for demonstration of chaining nodes
    pressure_net = instantiate_arch(
        input_keys=[Key("u"), Key("v")],
    pressure_net = pressure_net.make_node(name="pressure_network", jit=cfg.jit)
    # Random derivatives
    derivatives = [Key.from_str("u__x"), Key.from_str("p__x")]

    # Create graph of multiple nodes
    from modulus.graph import Graph
    fdm_graph = Graph([flow_net, pressure_net], invar=[Key("x"), Key("y")], req_names=[Key("u"), Key("v"), Key("p")])
   # Give graph to MFD node as the model
   # Graph will automatically produce output vars u,v,p from inputs x,y
    fdm_node = MeshlessFiniteDerivative.make_node(

Thank you so much for your help! It resolved my question.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.