-
Notifications
You must be signed in to change notification settings - Fork 297
Hp adaptivity through local smoothness & error estimate #4207
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
base: devel
Are you sure you want to change the base?
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 made a few minor comments, but hp-adaptivity is really under @roystgnr's purview, so he will hopefully have a lot more to say here.
@@ -97,7 +98,7 @@ class HPCoarsenTest : public HPSelector | |||
* refinement and potentially change the desired | |||
* refinement type. | |||
*/ | |||
virtual void select_refinement (System & system) override; | |||
virtual void select_refinement (System & system, ErrorVector & smoothness); |
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 changing a public HPCoarsenTest
API which we typically try to avoid doing without some period of deprecation. I would be curious to know what @roystgnr thinks about this particular API, though, I'm not sure it's used widely.
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 sure hope it's not used widely - this class has never really worked well.
And for that reason, the constructor has always been marked libmesh_experimental()
, and for both those reasons, anyone crazy enough to use this class should be on the ball enough to handle an API change without a transition period.
I'm not sure about this specific change, though.
If this class had actually worked, the original plan had been for both it and HPSingularity
(and any future selection options) to become subclasses of HPSelector
. And although a smoothness vector sure appears to be what we need here, I don't think it's what we need in general. Wouldn't it make just as much sense to create the smoothness
vector inside this implementation of select_refinement
, rather than creating it separately and passing it in?
Job Coverage, step Generate coverage on ae0e884 wanted to post the following: Coverage
Warnings
This comment will be updated on new commits. |
5d90b22
to
d7f0482
Compare
Is this ready to review? I'm in the middle of one but I just had a comment submission invalidated by a force-push. |
@roystgnr It is ready. I just added a warning message. Please continue reviewing (accedentally force pushed) |
#include "libmesh/libmesh_common.h" | ||
#include "libmesh/smoothness_estimator.h" | ||
#include "libmesh/dof_map.h" | ||
#include "libmesh/fe_base.h" | ||
#include "libmesh/dense_matrix.h" | ||
#include "libmesh/dense_vector.h" | ||
#include "libmesh/error_vector.h" | ||
#include "libmesh/libmesh_logging.h" | ||
#include "libmesh/elem.h" | ||
#include "libmesh/quadrature_grid.h" | ||
#include "libmesh/system.h" | ||
#include "libmesh/mesh_base.h" | ||
#include "libmesh/numeric_vector.h" | ||
#include "libmesh/tensor_value.h" | ||
#include "libmesh/threads.h" | ||
#include "libmesh/tensor_tools.h" | ||
#include "libmesh/enum_error_estimator_type.h" | ||
#include "libmesh/enum_norm_type.h" | ||
#include "libmesh/int_range.h" | ||
#include "libmesh/enum_to_string.h" |
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 just the full list from patch_recovery_error_estimator.C, right? We need to trim it down to just the necessary parts.
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 forgot that. I just used all headers in patch_recovery_error_estimator.C :(. Cleaned
const Order element_order = fe_type.order + elem->p_level(); | ||
|
||
if (element_order == 1) | ||
libmesh_warning("Warning: Polynomial order in element is 1, smoothness cannot be stimated!\n" |
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.
libmesh_warning("Warning: Polynomial order in element is 1, smoothness cannot be stimated!\n" | |
libmesh_warning("Warning: Polynomial order in element is 1, smoothness cannot be estimated!\n" |
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.
Although, I'm not sure we want a warning here at all. Surely we expect to hit element_order=1
cases legitimately, and we don't need to warn the user because they're not doing anything wrong?
But we should document (not here, but in the header) what does end up in the output ErrorVector
in those elements' entries in those cases.
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 agree with this.
For element order 1, the linear fit would be absurd for log|order| vs log |coefficients| . This results in Nan on smoothness vector, and pure h refinement triggered.
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.
Ooh - can we return std::numeric_limits<Real>::max()
instead of triggering a NaN
? We have a lot of users who turn on floating point exceptions.
@@ -40,7 +40,8 @@ enum ErrorEstimatorType : int { | |||
LAPLACIAN = 5, | |||
PATCH_RECOVERY = 6, | |||
WEIGHTED_PATCH_RECOVERY = 7, | |||
UNIFORM_REFINEMENT = 8}; | |||
UNIFORM_REFINEMENT = 8, | |||
SMOOTHNESS = 9}; |
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.
Calling the SmoothnessEstimator an ErrorEstimator feels like a category error to me. We're returning a smoothness, which should be non-zero for the exact solution, rather than error, which shouldn't be, 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, smoothness shall be non-zero for the exact solution. So do you think the ENUM for smoothness is better to remove?
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.
Yeah - even if it's super useful for estimating error, it's still not a type of error.
Oh, BTW, that was just a question about readiness; I didn't mean to criticize the force push. Force push after a negative review bugs me (because then it's much harder to see what's changed between reviews), but force push while I'm in the middle of a review just means I'm not reviewing fast enough. ;-) Plus, I told you I'd be on vacation for 2 weeks, so you probably weren't expecting me back until Monday, not today. |
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 couple new bits along with the remaining previous discussion.
#include "libmesh/error_vector.h" | ||
#include "libmesh/libmesh_logging.h" | ||
#include "libmesh/elem.h" | ||
#include "libmesh/quadrature_grid.h" |
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 missed this one; PREE uses a QGrid
but you don't.
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.
Missed that
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 need quadrature_grid.h
as I'm using at at a qp_loop
later #line250.
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 qrule here isn't a QGrid. Just include "libmesh/quadrature.h".
const Order element_order = fe_type.order + elem->p_level(); | ||
|
||
if (element_order == 1) | ||
libmesh_warning("Warning: Polynomial order in element is 1, smoothness cannot be stimated!\n" |
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.
Ooh - can we return std::numeric_limits<Real>::max()
instead of triggering a NaN
? We have a lot of users who turn on floating point exceptions.
@@ -40,7 +40,8 @@ enum ErrorEstimatorType : int { | |||
LAPLACIAN = 5, | |||
PATCH_RECOVERY = 6, | |||
WEIGHTED_PATCH_RECOVERY = 7, | |||
UNIFORM_REFINEMENT = 8}; | |||
UNIFORM_REFINEMENT = 8, | |||
SMOOTHNESS = 9}; |
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.
Yeah - even if it's super useful for estimating error, it's still not a type of error.
How and why did you pull in those three completely-unrelated commits? |
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.
Can you do a force push just to remove the three unrelated commits? If we have to bisect anything later I don't want to be as baffled looking at git history then as I am right now.
That plus the header choice may be all we have left to fix here.
#include "libmesh/error_vector.h" | ||
#include "libmesh/libmesh_logging.h" | ||
#include "libmesh/elem.h" | ||
#include "libmesh/quadrature_grid.h" |
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 qrule here isn't a QGrid. Just include "libmesh/quadrature.h".
24308ac
to
393a126
Compare
which commits do you want removed/deleted? |
hp-Adaptivity: Added documentation for few lines hp-Adaptivity: Few minor corrections - hp adaptivity
… from ErrorEstimator
…nement, thus override is safe hp-Adaptivity: fixed headers
hp-Adaptivity algorithm : logic flow
p_error
) and h corsen error (h_error
) (as @roystgnr composed in hp_coarsentest.C) and then if the element's local solution is having highest regularity than mean andp_error > h_error
then do p refine else h refine.ps: Negative value of regularity indicates the singularity of solution for the given element. This means higher order terms in Legendre expansion contaminated by singularity behavior and low order spectral modes unable be capture the solution behaviour.