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

Add missing connectivities in IconGrid #374

Open
tehrengruber opened this issue Feb 1, 2024 · 1 comment
Open

Add missing connectivities in IconGrid #374

tehrengruber opened this issue Feb 1, 2024 · 1 comment

Comments

@tehrengruber
Copy link
Contributor

The IconGrid is missing some connectivities (that are present in the simple_grid). For example 7696d1a introduced the offset provider for C2CECEC, but we do not construct the respective connectivity.

@philip-paul-mueller
Copy link
Collaborator

@tehrengruber Here is my implementation for E2C2E/E2C2EO it might be of use to you.

def compute_e2c2eO(
        c2e, e2c,
        with_origin = True):
    """Generate the `E2C2E0` map based on the `C2E` and `E2C`.

    The operation is relatively costly, since it has to be done in Python.
    By default the origin edge is included, however, by setting `with_origin` to `False` the function will generate `E2C2E`.
    """

    # You are not supposed to understand this
    dummy_c2e = np.append(c2e, -np.ones_like(c2e), axis=1)
    T  = dummy_c2e[e2c, :]
    Ts = T.shape
    S  = T.reshape(Ts[0], Ts[1] * Ts[2])
    
    # Now we get all the unique indexes
    u = []
    highestCount = -1
    for i in range(S.shape[0]):
        s = S[i]
        s = s[s >= 0]       # Remove the invalid indexes.
        if(with_origin):    # Add the origin edge ID if requested.
            s = list(s) + [i]
        else:               #  or if not, ensure that the ID is not present.
            s = s[s != i]
        #
        u.append(np.unique(s))  # Add the unique indexes.
        highestCount = max(highestCount, u[-1].size)
    #

    # Now combine all indexes inside a single array index.
    _e2c2eO = np.full((len(u), highestCount), -1, dtype=c2e.dtype)
    for i, s in enumerate(u):
        _e2c2eO[i, 0:len(s)] = s
    #
    return _e2c2eO
# end def: compute_e2c2eO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants