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

Time Derivative for Array Variables #14059

Merged
merged 2 commits into from Sep 19, 2019

Conversation

zachmprince
Copy link
Contributor

Closes #14057

  • Adding ArrayTimeKernel for base class of array kernels involving time derivatives
  • Adding ArrayTimeDerivative for computing time derivative of array variables
  • Adding transient test and documentation


protected:
virtual RealEigenVector computeQpResidual() override;
virtual RealEigenVector computeQpJacobian() override;
Copy link
Contributor

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)?

Copy link
Contributor Author

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)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the getMaterialPropertys in the constructor but I had to move the mooseAsserts into computeQpResidual because of an error I was getting in debug mode. It seems I couldn't access the size of _coeff until then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is fine/expected.

@moosebuild
Copy link
Contributor

moosebuild commented Sep 18, 2019

Job Documentation on f7fcbd8 wanted to post the following:

View the site here

This comment will be updated on new commits.

@zachmprince zachmprince force-pushed the array_time_14057 branch 2 times, most recently from 2b2ab24 to bdb18ac Compare September 18, 2019 22:59
@permcody
Copy link
Member

@zachmprince - I sent you an invite so your PRs will start testing. Please accept.

@zachmprince
Copy link
Contributor Author

@permcody - I don't see the invite you sent, but it seems the PR is automatically testing.

@permcody
Copy link
Member

@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?

@zachmprince
Copy link
Contributor Author

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.

@YaqiWang
Copy link
Contributor

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.

@zachmprince
Copy link
Contributor Author

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.
array_diag_pjfnk.txt
array_jfnk.txt
array_smp_newton.txt
array_smp_pjfnk.txt
diag_pjfnk.txt
jfnk.txt
smp_newton.txt
smp_pjfnk.txt

RealEigenVector
ArrayTimeDerivative::computeQpResidual()
{
if (_coeff_type == 0)
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@rwcarlsen rwcarlsen Sep 19, 2019

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.

@YaqiWang
Copy link
Contributor

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.

@moosebuild
Copy link
Contributor

Job Precheck on 513996f wanted to post the following:

Your code requires style changes.

A patch was auto generated and copied here
You can directly apply the patch by running, in the top level of your repository:

curl -s https://mooseframework.inl.gov/docs/PRs/14059/style.patch | git apply -v

Alternatively, with your repository up to date and in the top level of your repository:

git clang-format ba456f4db1ca36ff1a96cdb4f7fd5402a1a7a77b

@YaqiWang
Copy link
Contributor

Thanks @rwcarlsen for the idea and @zachmprince for the cleanup of array kernels I did before ;-)

@rwcarlsen
Copy link
Contributor

The failures are caused by network issues on the INL side. Not this PR.

@permcody permcody merged commit 1575de5 into idaholab:next Sep 19, 2019
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 this pull request may close these issues.

Time Derivative Kernels for Array Variables
5 participants