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
Time Derivative for Array Variables #14059
Conversation
|
||
protected: | ||
virtual RealEigenVector computeQpResidual() override; | ||
virtual RealEigenVector computeQpJacobian() override; |
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.
Should these maybe be ArrayVariableValue (which evaluates to the same type)?
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 possible, but the base class (ArrayKernel) has these defined as RealEigenVector. Would it be inconsistent to change it in this kernel?
{ | ||
if (_coeff_type == 0) | ||
_coeff = &getMaterialProperty<Real>("time_derivative_coefficient"); | ||
else if (_coeff_type == 1) |
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.
We could move these checks into the initialSetup function and then use hasMaterialProperty<Real/RealEigenVector/RealEigenMatrix>("time_derivative_coeff") to determine the type of the material. Then users don't have to set/remember anything about the coefficient type and it just works automatically.
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.
Good idea! I'll switch to using hasMaterialProperty instead of asking for it from the user.
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.
Note: I get an error when I move these checks to initialSetup.
*** ERROR ***
Material properties must be retrieved during object construction. This is a code problem.
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.
Okay - this is going to have to go back into the constructor due to quirks of object initialization order. The constructor only works in this case because the object you are coding is not a material.
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 kept the getMaterialProperty
s in the constructor but I had to move the mooseAssert
s into computeQpResidual
because of an error I was getting in debug mode. It seems I couldn't access the size of _coeff
until then.
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 is fine/expected.
Job Documentation on f7fcbd8 wanted to post the following: View the site here This comment will be updated on new commits. |
2b2ab24
to
bdb18ac
Compare
@zachmprince - I sent you an invite so your PRs will start testing. Please accept. |
@permcody - I don't see the invite you sent, but it seems the PR is automatically testing. |
Nope - I'm just on top of CIVET. Everyone always says this too me. It should go to whatever your email address is listed as in Github.com. Might be a personal email? |
Oh found it, sorry about that. |
Zach, did you compare the array version of input with the non-array version with the exactly same solver settings? We should be able to get the exactly same convergence. Because you removed the coefficient type parameter, it could be good to do the same for the diffusion and reaction kernels. |
@YaqiWang The convergence is very similar but not identical. As in, the number of linear and nonlinear iterations are exactly the same for every time step, but the residuals don't quite match. They are off by ~0.5% throughout the transient. Not sure why this would be. I've attached the console outputs of the cases I ran. |
RealEigenVector | ||
ArrayTimeDerivative::computeQpResidual() | ||
{ | ||
if (_coeff_type == 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.
These could probably just check if (_coeff/_coeff_array/_coeff_2d_array)
since only one will be non-null. Then we don't need _coeff_type at all.
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 removed _coeff_type
per your suggestion. But I kept getting random crashes, I guess because the null ones were never initiated. So I switched to a ternary operator to assure the unused ones are initiated to nullptr
.
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, as a general rule, we need to make sure every member variable that is a POD type (e.g. pointers, ints, etc.) is explicitly initialized in the constructor. What you did is fine. Another fine option would be to just set all of them to nullptr in the initialization list and leave the if checking code in the constructor body like before.
I looked array_smp_newton.txt and smp_newton.txt. I think they match well. Small differences in residual norms could be just expected due to the numerical round-off. |
bdb18ac
to
513996f
Compare
Job Precheck on 513996f wanted to post the following: Your code requires style changes. A patch was auto generated and copied here
Alternatively, with your repository up to date and in the top level of your repository:
|
513996f
to
f7fcbd8
Compare
Thanks @rwcarlsen for the idea and @zachmprince for the cleanup of array kernels I did before ;-) |
The failures are caused by network issues on the INL side. Not this PR. |
Closes #14057