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

Affine constraint between two DBC constraints should work #530

Closed
fredrikekre opened this issue Oct 27, 2022 · 0 comments · Fixed by #535
Closed

Affine constraint between two DBC constraints should work #530

fredrikekre opened this issue Oct 27, 2022 · 0 comments · Fixed by #535

Comments

@fredrikekre
Copy link
Member

fredrikekre commented Oct 27, 2022

grid = generate_grid(Quadrilateral, (1,1))
dh = DofHandler(grid)
push!(dh, :u, 1)
close!(dh)

ch_affine_first = ConstraintHandler(dh)
add!(ch_affine_first, AffineConstraint(2, [3 => 1.0], 0.0))
add!(ch_affine_first, Dirichlet(:u, getfaceset(grid, "right"), (x, t) -> 1)) # Works without this inhomogeneity
close!(ch_affine_first)
update!(ch_affine_first, 0)

ch_dbc_first = ConstraintHandler(dh)
add!(ch_dbc_first, Dirichlet(:u, getfaceset(grid, "right"), (x, t) -> 1)) # Works without this inhomogeneity
add!(ch_dbc_first, AffineConstraint(2, [3 => 1.0], 0.0))
close!(ch_dbc_first)
update!(ch_dbc_first, 0)

K_affine_first = create_sparsity_pattern(dh, ch_affine_first)
f_affine_first = zeros(size(K_affine_first, 1))
fill!(K_affine_first.nzval, 1)

K_dbc_first = create_sparsity_pattern(dh, ch_dbc_first)
f_dbc_first = zeros(size(K_dbc_first, 1))
fill!(K_dbc_first.nzval, 1)

apply!(K_affine_first, f_affine_first, ch_affine_first)
apply!(K_dbc_first, f_dbc_first, ch_dbc_first)

K_affine_first and K_dbc_first are equal, but not f_affine_first and f_dbc_first.

fredrikekre added a commit that referenced this issue Nov 7, 2022
This patch fixes affine constraints with prescribed dofs in the RHS. In
particular, we allow dofs that are prescribed by just an inhomogeneity
(i.e. DBC) but disallow "nesting" affine constraints.

Concretely, consider e.g. the following two constraints:

    u2 = f(t)
    u3 = u2 + b3

Before this patch this was not handled correctly since the inhomogeneity
for u3 was taken as b3, but it should really be b3 + f(t) by
substituting u2 for f(t). Since we allow for time-dependent
inhomogeneities this substitution has to be done at runtime and not
during close!(::ConstraintHandler).

Nested constraints, e.g.

    u2 = u3
    u3 = u5

are still not allowed but in the future this can be resolved in
close!(::ConstraintHandler) to

    u2 = u5
    u3 = u5

However, this patch checks for such nesting and raises an error instead
of resulting in incorrect answers as is the case before.

Fixes #530.
fredrikekre added a commit that referenced this issue Nov 7, 2022
This patch fixes affine constraints with prescribed dofs in the RHS. In
particular, we allow dofs that are prescribed by just an inhomogeneity
(i.e. DBC) but disallow "nesting" affine constraints.

Concretely, consider e.g. the following two constraints:

    u2 = f(t)
    u3 = u2 + b3

Before this patch this was not handled correctly since the inhomogeneity
for u3 was taken as b3, but it should really be b3 + f(t) by
substituting u2 for f(t). Since we allow for time-dependent
inhomogeneities this substitution has to be done at runtime and not
during close!(::ConstraintHandler).

Nested constraints, e.g.

    u2 = u3
    u3 = u5

are still not allowed but in the future this can be resolved in
close!(::ConstraintHandler) to

    u2 = u5
    u3 = u5

However, this patch checks for such nesting and raises an error instead
of resulting in incorrect answers as is the case before.

Fixes #530.
fredrikekre added a commit that referenced this issue Nov 7, 2022
This patch fixes affine constraints with prescribed dofs in the RHS. In
particular, we allow dofs that are prescribed by just an inhomogeneity
(i.e. DBC) but disallow "nesting" affine constraints.

Concretely, consider e.g. the following two constraints:

    u2 = f(t)
    u3 = u2 + b3

Before this patch this was not handled correctly since the inhomogeneity
for u3 was taken as b3, but it should really be b3 + f(t) by
substituting u2 for f(t). Since we allow for time-dependent
inhomogeneities this substitution has to be done at runtime and not
during close!(::ConstraintHandler).

Nested constraints, e.g.

    u2 = u3
    u3 = u5

are still not allowed but in the future this can be resolved in
close!(::ConstraintHandler) to

    u2 = u5
    u3 = u5

However, this patch checks for such nesting and raises an error instead
of resulting in incorrect answers as is the case before.

Fixes #530.
fredrikekre added a commit that referenced this issue Nov 8, 2022
This patch fixes affine constraints with prescribed dofs in the RHS. In
particular, we allow dofs that are prescribed by just an inhomogeneity
(i.e. DBC) but disallow "nesting" affine constraints.

Concretely, consider e.g. the following two constraints:

    u2 = f(t)
    u3 = u2 + b3

Before this patch this was not handled correctly since the inhomogeneity
for u3 was taken as b3, but it should really be b3 + f(t) by
substituting u2 for f(t). Since we allow for time-dependent
inhomogeneities this substitution has to be done at runtime and not
during close!(::ConstraintHandler).

Nested constraints, e.g.

    u2 = u3
    u3 = u5

are still not allowed but in the future this can be resolved in
close!(::ConstraintHandler) to

    u2 = u5
    u3 = u5

However, this patch checks for such nesting and raises an error instead
of resulting in incorrect answers as is the case before.

Fixes #530.
fredrikekre added a commit that referenced this issue Nov 8, 2022
This patch fixes affine constraints with prescribed dofs in the RHS. In
particular, we allow dofs that are prescribed by just an inhomogeneity
(i.e. DBC) but disallow "nesting" affine constraints.

Concretely, consider e.g. the following two constraints:

    u2 = f(t)
    u3 = u2 + b3

Before this patch this was not handled correctly since the inhomogeneity
for u3 was taken as b3, but it should really be b3 + f(t) by
substituting u2 for f(t). Since we allow for time-dependent
inhomogeneities this substitution has to be done at runtime and not
during close!(::ConstraintHandler).

Nested constraints, e.g.

    u2 = u3
    u3 = u5

are still not allowed but in the future this can be resolved in
close!(::ConstraintHandler) to

    u2 = u5
    u3 = u5

However, this patch checks for such nesting and raises an error instead
of resulting in incorrect answers as is the case before.

Fixes #530.
fredrikekre added a commit that referenced this issue Nov 9, 2022
This patch fixes affine constraints with prescribed dofs in the RHS. In
particular, we allow dofs that are prescribed by just an inhomogeneity
(i.e. DBC) but disallow "nesting" affine constraints.

Concretely, consider e.g. the following two constraints:

    u2 = f(t)
    u3 = u2 + b3

Before this patch this was not handled correctly since the inhomogeneity
for u3 was taken as b3, but it should really be b3 + f(t) by
substituting u2 for f(t). Since we allow for time-dependent
inhomogeneities this substitution can not be done in
close!(::ConstraintHandler) and instead the effective inhomogeneity is
computed in update!.

Nested constraints, e.g.

    u2 = u3
    u3 = u5

are still not allowed but in the future this can be resolved in
close!(::ConstraintHandler) to

    u2 = u5
    u3 = u5

However, this patch checks for such nesting and raises an error instead
of resulting in incorrect answers as is the case before.

Fixes #530.
fredrikekre added a commit that referenced this issue Nov 9, 2022
This patch fixes affine constraints with prescribed dofs in the RHS. In
particular, we allow dofs that are prescribed by just an inhomogeneity
(i.e. DBC) but disallow "nesting" affine constraints.

Concretely, consider e.g. the following two constraints:

    u2 = f(t)
    u3 = u2 + b3

Before this patch this was not handled correctly since the inhomogeneity
for u3 was taken as b3, but it should really be b3 + f(t) by
substituting u2 for f(t). Since we allow for time-dependent
inhomogeneities this substitution can not be done in
close!(::ConstraintHandler) and instead the effective inhomogeneity is
computed in update!.

Nested constraints, e.g.

    u2 = u3
    u3 = u5

are still not allowed but in the future this can be resolved in
close!(::ConstraintHandler) to

    u2 = u5
    u3 = u5

However, this patch checks for such nesting and raises an error instead
of resulting in incorrect answers as is the case before.

Fixes #530.
fredrikekre added a commit that referenced this issue Nov 9, 2022
This patch fixes affine constraints with prescribed dofs in the RHS. In
particular, we allow dofs that are prescribed by just an inhomogeneity
(i.e. DBC) but disallow "nesting" affine constraints.

Concretely, consider e.g. the following two constraints:

    u2 = f(t)
    u3 = u2 + b3

Before this patch this was not handled correctly since the inhomogeneity
for u3 was taken as b3, but it should really be b3 + f(t) by
substituting u2 for f(t). Since we allow for time-dependent
inhomogeneities this substitution can not be done in
close!(::ConstraintHandler) and instead the effective inhomogeneity is
computed in update!.

Nested constraints, e.g.

    u2 = u3
    u3 = u5

are still not allowed but in the future this can be resolved in
close!(::ConstraintHandler) to

    u2 = u5
    u3 = u5

However, this patch checks for such nesting and raises an error instead
of resulting in incorrect answers as is the case before.

Fixes #530.
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

Successfully merging a pull request may close this issue.

1 participant