PresetBC vs. DirichletBC

108 views
Skip to first unread message

BEM Becsek

unread,
Jul 27, 2018, 8:25:49 AM7/27/18
to moose-users
Hello,

I am a little confused about the difference between PresetBC and DirichletBC. 
If I understand this right, both BCs set a desired value on a boundary. 
The difference ought to be that while DirichletBC will have the solution converge to the desired value, it will treat the solution at the respective index as a degree of freedom, resulting in a potentially non-zero residual. 
PresetBC on the other hand ought to set the solution in the system before solving it and thus "remove" the solution at that point from the system, essentially resulting in a zero residual. 
Please correct me if I am wrong. But if this is the case, I couldn't find where 
void
PresetNodalBC::computeValue(NumericVector<Number> & current_solution)
{
  dof_id_type & dof_idx = _var.nodalDofIndex();
  _qp = 0;
  current_solution.set(dof_idx, computeQpValue());
}
is called. It is not an overridable function either. I am guessing that PresetBC is not doing what is it supposed to do. 
Please excuse me if what I say is not correct, as I am not the most experienced in object oriented programming. 
Thank you for your help.

Sincerely,
Barna

Andrew E. Slaughter

unread,
Jul 27, 2018, 8:39:29 AM7/27/18
to moose-users

I think your understanding is correct: http://www.mooseframework.org/moose/source/bcs/PresetBC.html.


Understanding the call sequence can be difficult, but most things end up being called by some sort of compute object, in this case

it is the ComputeResidualThread.


PresetNodalBC::computeQpResudual calls computeValue

NodalBC::computeResidual calls computeQpResidual

ComputeResidualThread::onBoundary calls computeResidual


Although it doesn't help much for this case, looking at the inheritance diagram sometimes helps with this sort of digging: http://mooseframework.org/docs/doxygen/moose/classPresetBC.html.



From: moose...@googlegroups.com <moose...@googlegroups.com> on behalf of BEM Becsek <barna...@gmail.com>
Sent: Friday, July 27, 2018 6:25:48 AM
To: moose-users
Subject: PresetBC vs. DirichletBC
 
--
You received this message because you are subscribed to the Google Groups "moose-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to moose-users...@googlegroups.com.
Visit this group at https://groups.google.com/group/moose-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/moose-users/f9b15c50-91da-4c48-a6a8-0f16e12b454f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

BEM Becsek

unread,
Jul 27, 2018, 9:27:08 AM7/27/18
to moose-users
Dear Andrew,
 
Thank you for the prompt answer. I actually now found the place it's called in the framework, namely in NonlinearSystemBase::setInitialSolution(). 
There is still something that puzzles me however that may be related to this:
I have a geometry where two surfaces meet (be it 2D or 3D, the same behaviour is observed) as illustrated in this sketch:

|
o
|   <-surface 1 
o
|
x__o__o__o__o <- surface 2

What I do is I specify 0 displacement with PresetBC on surface 2 in the DOFs located at the "o"s, and I derive from PresetNodalBC a new class where I override computeQpValue() for surface 1 (here I prescribe a non-zero fixed displacement). 
I make sure that in my input geometry surface 2 is labeled with a higher ID than that of surface 1, because I realized BCs are assigned in ascending boundary id (I want "x" to be fixed with 0 displacements).
The odd thing (at least in my opinion) is that the residual in "x" is not zero (the solution for displacement is). I would like it to be 0 however, since DOFs on surface 2 (including "x") should not give me a residual.
I have realized that if I manually remove the lowest element(s) on surface 1 that connect o and x from surface 1's id, I get my desired behaviour. 
I feel like there might be some inconsistency with the application of boundary conditions somehow.

PS: also I think I should obtain 0 residual in the case that I use PresetBCs, thus I should derive from NodalBC for surface 1 (to get a residual) and use PresetBC on surface 2 (to not get a residual). But this does not make a difference for the residuals I obtain.

Thank you and please let me know if I am not clear enough, or if I understand something incorrectly.

Andrew E. Slaughter

unread,
Jul 27, 2018, 9:43:02 AM7/27/18
to moose-users

You are correct with where PresetBC is called, I gave you where DirichletBC is called by mistake.


When BCs are applied on surfaces with shared nodes, we do not guarantee which BC will take priority. One of them will win, but the winner is not guaranteed. To make certain that the BC you desire is applied you might consider removing the "x" node from surfaces 1 and 2 and create a nodeset that contains only the "x" node, this will allow you to set the correct BC at the location.


You probably can use the MeshModifiers (http://www.mooseframework.org/moose/syntax/MeshModifiers/index.html) to add this nodeset; however, I am not certain.


Sent: Friday, July 27, 2018 7:27:07 AM
To: moose-users
Subject: Re: PresetBC vs. DirichletBC
 

BEM Becsek

unread,
Jul 27, 2018, 10:22:24 AM7/27/18
to moose-users
Ok, that already explains some of my problems.
But then I am wrong in assuming that using a BC of type PresetNodalBC ensures a zero residual where applied. It then in fact only is an initial guess before the system is solved, correct?
Because, we derive from PresetNodalBC and we do get the "same" residual value as if deriving from NodalBC (DirichletBC way).

Derek Gaston

unread,
Jul 28, 2018, 4:50:15 PM7/28/18
to moose...@googlegroups.com
Yes - the only difference between DIrichletBC and PresetBC is that PresetBC sets a "better" initial guess.  Everything else is exactly the same.

Derek

Reply all
Reply to author
Forward
0 new messages