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

Create a SubDomain #438

Open
EmilyBourne opened this issue May 3, 2024 · 0 comments
Open

Create a SubDomain #438

EmilyBourne opened this issue May 3, 2024 · 0 comments

Comments

@EmilyBourne
Copy link
Collaborator

I would like to be able to create some kind of SubDomain. For example this could be achieved by adding a stride to the Domain. This would be useful in several places.

It can be used to iterate over a sliced domain. This can be useful for creating a Lagrange interpolation or calculating a quadrature (e.g. Simpson's quadrature).
E.g. currently a Simpson's quadrature is written as:

    for (auto it = domain.begin() + 1; it < domain.end() - 1; it += 2) {
        ddc::DiscreteElement<IDim> idx = *it;
        coefficients(idx) = 2. / 3. * (distance_at_left(idx) + distance_at_right(idx));
        idx += ddc::DiscreteVector<IDim>(1);
        coefficients(idx) = 1. / 3. * (distance_at_left(idx) + distance_at_right(idx));
    }

with a SubDomain it would be:

    for (ddc::DiscreteElement<IDim> idx : subdomain) {
        ddc::DiscreteElement<IDim> idx2 = idx + ddc::DiscreteVector<IDim>(1);
        coefficients(idx) = 2. / 3. * (distance_at_left(idx) + distance_at_right(idx));
        coefficients(idx2) = 1. / 3. * (distance_at_left(idx2) + distance_at_right(idx2));
    }

It can also be used to create a Chunk on a SubDomain. Eg when working with patches it is common to need values of a function over all the domain, but the derivatives only at certain points (usually the boundary). Currently this is only possible by explicitly choosing the number of points at the compilation, or creating a separate mesh for the derivatives (which then have different DiscreteElements)

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

1 participant