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
Allow inhomogeneous Dirichlet in Step-60 #13105
Allow inhomogeneous Dirichlet in Step-60 #13105
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you are still missing a small change in the assemble_system
function, since you also need to pass the embedding_rhs
to the MatrixTools::create_laplace_matrix function
examples/step-60/doc/results.dox
Outdated
@@ -125,6 +125,47 @@ subsection Distributed Lagrange<1,2> | |||
set Variable names = x,y,t | |||
end | |||
|
|||
subsection Embedding value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I would rename this to Embedding Dirichlet boundary conditions
examples/step-60/doc/results.dox
Outdated
@@ -308,6 +357,11 @@ subsection Distributed Lagrange<1,2> | |||
set Function expression = x-.5 | |||
set Variable names = x,y,t | |||
end | |||
subsection Embedding value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here: Embedding Dirichlet boundary conditions
examples/step-60/step-60.cc
Outdated
// In this case the Function is a scalar one. | ||
ParameterAcceptorProxy<Functions::ParsedFunction<spacedim>> | ||
embedding_value_function; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
embedding_dirichlet_boundary_conditions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's related to the value of the forcing term f, the first component of the right-hand side, which is named embedding_rhs
, not to the bcs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand this correctly, this is the rhs of the Poisson problem, right? I would not name this in the same way as the other term, simply because they have a different meaning. Maybe I would rename this embedding_rhs_function
, and similarly for the parameter files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, it's the rhs for Poisson. I'll follow your suggestion.
examples/step-60/step-60.cc
Outdated
embedding_value_function.declare_parameters_call_back.connect( | ||
[]() -> void { ParameterAcceptor::prm.set("Function expression", "0"); }); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not necessary, since by default the function is set to "0"
examples/step-60/step-60.cc
Outdated
@@ -839,7 +850,7 @@ namespace Step60 | |||
space_dh->distribute_dofs(*space_fe); | |||
|
|||
DoFTools::make_hanging_node_constraints(*space_dh, constraints); | |||
for (auto id : parameters.homogeneous_dirichlet_ids) | |||
for (auto id : parameters.dirichlet_ids) | |||
{ | |||
VectorTools::interpolate_boundary_values( | |||
*space_dh, id, Functions::ZeroFunction<spacedim>(), constraints); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be the embedding_dirichlet_boundary_values
instead of Functions::ZeroFunction<spacedim>()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I was assuming that the user should create its own function object to specify different bcs. Anyway, you're totally right, I should create another parsed function for that. I'm fixing this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok. In the comment to the PR you talked about Dirichlet BCs, but your changes actually add a non homogeneous rhs, rather than non-homogeneous Dirichlet BCs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user doesn't change Functions::ZeroFunction<spacedim>()
, then you're right: I only allowed a possibly non-zero rhs.
But with my changes, if the "f" in the original problem is 0, and the user specifies a non-homogeneous Dirichlet BCs on dOmega, the call to create_laplace_matrix()
will distribute correctly the inhomogeneous constraints to the rhs vector. Before this PR, those constraints were not distributed in this scenario. Of course everything works with a non-zero "f" too, like in the picture above.
Thanks Luca for the review.
Here, |
Ciao Marco, welcome! Please, make sure you run "make indent" before committing. The continuous integration system is complaining that step-60 is not indented correctly. Other than this, this looks fine to me! |
I noticed one last thing here: dealii/examples/step-60/doc/results.dox Lines 270 to 273 in bc4c776
This is not what I observe on my machine after several tests. For instance, the default .prm file gives:
Can I delete these lines? |
I've added the function for Dirichlet BCs. The only thing that has to be changed is the comment above about CPU times. The indentation failure was coming from some whitespaces in |
Could you address my last comment, and also change the documentation of the tutorial, including the description of the equations? We now have a |
Sure, thanks. Should I delete those lines about CPU times? |
Yes, indeed, please adjust the comment about the CPU time. A lot of things have changed in the library since the implementation of step-60. :) |
Everything should be okay now! |
One last thing: can you squash all your commits into one, and add a file in the directory: I'll let someone else comment on this before merging, since you are one of my PhD students. :) |
d763978
to
9f0f770
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, thanks @fdrmrc . I have just a couple of very small questions, which shouldn't take long to resolve.
@@ -0,0 +1,3 @@ | |||
Changed: The step-60 tutorial now works also with non-zero Dirichlet BCs and non-zero right-hand side | |||
<br> | |||
(Marco Feder, 2021/12/24) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that you need a new line at the end of this file.
examples/step-60/doc/intro.dox
Outdated
@@ -60,19 +60,20 @@ embedded domain (`dim`) is always smaller by one or equal with respect to the | |||
dimension of the embedding domain $\Omega$ (`spacedim`). | |||
|
|||
We are going to solve the following differential problem: given a sufficiently | |||
regular function $g$ on $\Gamma$, find the solution $u$ to | |||
regular function $g$ on $\Gamma$, a forcing term $f \in L^2(\Omega)$ and a Dirichlet data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a Dirichlet data
This doesn't read right to me. Do you mean "Dirichlet conditions", or something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, exactly. I could replace that with "a Dirichlet boundary condition", since that is imposed on dOmega only. Does that work for you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that would be perfect thanks!
@@ -125,6 +125,88 @@ subsection Distributed Lagrange<1,2> | |||
set Variable names = x,y,t | |||
end | |||
|
|||
subsection Embedding Dirichlet boundary conditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The documentation/commentary for these new set
functions is exactly the same as what's found elsewhere in the tutorials, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks for the confirmation. I did a quick check and it looked identical, but I thought I'd just make sure.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I see that you did this already. Awesome :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from @jppelteret comments, this looks good to me.
56d5aab
to
265dfbe
Compare
Thanks for the checks, @masterleinad and @jppelteret. Everything should be okay now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the nice extension @fdrmrc!
/rebuild |
This PR fixes #13034 and allows inhomogeneous Dirichlet bcs. Indeed, with the current version, the
rhs
vector is not used and changing only the call toVectorTools::interpolate_boundary_values()
doesn't produce the right result as the inhomogeneous constraints are not distributed to therhs
. Now it works even with non-constant bcs, like the one in the picture.