moose icon indicating copy to clipboard operation
moose copied to clipboard

Adding direct acceleration calculation to central difference

Open TheGreatCid opened this issue 1 year ago • 5 comments

This PR is addressing the first half of #28008, which to implement a method that allows for a solution update calculated by the direct calculation of acceleration from the internal and external forces.

Reason

This is the first step in improving explicit contact as described in #28008

Design

The "direct" solution update, is calculated as the following:

$a_n=M^{-1}(F^{ext}-F^{int})$ $v_{n+1/2}=v_{n-1/2}+\Delta t a_n$ $d_{n+1}=d_n + \Delta t v_{n+1/2}$

These steps can be found in ExplicitTimeIntegrator.C

The following changes have been made:

  • NonlinearSystemBase.h
    • Added setNodalBCs() member function. This sets nodal BCs for use with the direct time integrator. It is identical to setInitialSolution() but without predictor calls.
  • TimeIntegrator.h
    • Added function isDirect() that returns a bool describing whether or not the direct time integrator is being used
  • ExplicitTimeIntegrator.C
    • Added additional option for is_direct to compute the solution update from acceleration
  • ActuallyExplicitEuler.C
    • Added a call to setNodalBCs() after solution update if using direct solver
  • CentralDifference.C
    • Added a direct acceleration calculation if in the nonlinear system. This effectively does nothing as is, but will be useful for future work with explicit contact.
    • Added parameter use_direct to allow a user to specify if they want to do use a direct acceleration calculation for time integration
  • InertialForce.C
    • Modified computeQpResidual() to have an option to return 0 if using a direct time integrator
    • Modified computeQpJacobian() to return the mass matrix without factor tags needed for the current method

Impact

This will allow a user to specific use_direct=true to invoke a central difference time integrator that computes the solution update based on a direct calculation of acceleration from the internal and external forces.

TheGreatCid avatar Jun 25 '24 22:06 TheGreatCid

@TheGreatCid are you working with anyone at the national labs on this? To know who to assign for the review

GiudGiud avatar Jun 27 '24 02:06 GiudGiud

I'm working with Daniel Schwen. I did not realize drafts were public, this is not ready for review yet

TheGreatCid avatar Jun 27 '24 13:06 TheGreatCid

no worries. Creating drafts is a good idea to get early feedback

GiudGiud avatar Jun 27 '24 15:06 GiudGiud

Documentation still needs to be updated, however any code review would be appreciated

TheGreatCid avatar Jun 27 '24 19:06 TheGreatCid

Documentation has been added.

TheGreatCid avatar Jul 01 '24 17:07 TheGreatCid

Job Conda build (Linux) on 8230654 : invalidated by @lindsayad

moosebuild avatar Jul 08 '24 14:07 moosebuild

Job Documentation on e8072f8 wanted to post the following:

View the site here

This comment will be updated on new commits.

moosebuild avatar Jul 08 '24 17:07 moosebuild

Job Coverage on e8072f8 wanted to post the following:

Framework coverage

5bf0d8 #27991 e8072f
Total Total +/- New
Rate 85.06% 85.04% -0.03% 26.00%
Hits 104544 104552 +8 13
Misses 18360 18398 +38 37

Diff coverage report

Full coverage report

Modules coverage

Solid mechanics

5bf0d8 #27991 e8072f
Total Total +/- New
Rate 84.83% 84.83% -0.00% 75.00%
Hits 27780 27783 +3 3
Misses 4966 4967 +1 1

Diff coverage report

Full coverage report

Full coverage reports

Reports

Warnings

  • framework new line coverage rate 26.00% is less than the suggested 90.0%
  • solid_mechanics new line coverage rate 75.00% is less than the suggested 90.0%

This comment will be updated on new commits.

moosebuild avatar Jul 08 '24 17:07 moosebuild

@lindsayad This implementation of CD really only works with solid mechanics due to how the mass matrix needs to be constructed. At least I am not familiar enough with fluid mechanics to know if the call to the mass matrix construction would return the correct matrix. Should I put in a warning to state this?

TheGreatCid avatar Jul 16 '24 14:07 TheGreatCid

But I can also just ask: are you running into issues related to mass matrices and fluid mechanics? Or was this a preemptive question?

It's a preemptive question. My motivation for this was to fix explicit contact, so I did not give much though to other physics

TheGreatCid avatar Jul 16 '24 19:07 TheGreatCid

My number one concern about this PR is whether it's too specific to solid mechanics such that all this work should be there instead of the framework. If this doesn't work for other physics, then maybe we are missing some generality in the framework that would enable you to implement the time integration you want in your module/application in a seamless way. I would ask you and @dschwen to weigh in and tell me whether you feel like you're locked into a box that doesn't fit very well and if that is the case, how we might make it better

lindsayad avatar Jul 16 '24 22:07 lindsayad

We are certainly missing some generality here. You may be right that this would be best suited for the solid mechanics module. There may a way to make this more general, but I not familiar enough with the other modules to figure that out quickly.

TheGreatCid avatar Jul 17 '24 14:07 TheGreatCid

The lack of generality can be seen in the changes I made to InertialForce.C. I need to modify the residual returned and ComputeQpJacobian as these had terms from the original CD formulation. I am assuming those exist in the other physics as well. It might be overkill to change other time dependent kernels to might this formulation as the point of having this addition CD formulation is for explicit contact

TheGreatCid avatar Jul 17 '24 14:07 TheGreatCid

The changes in InertialForce definitely look a bit funny as Jacobians are supposed to be the derivatives of the residual with respect to the solution dofs and you're returning a 0 residual ... yet the Jacobian is not 0. We introduced LinearSystem recently. I wonder if that would be a better paradigm for the work you're doing where you fill a RHS and a matrix (which would just be the mass matrix when using explicit time integration), and there is not the same J = dR/du conceptual relationship

lindsayad avatar Jul 17 '24 15:07 lindsayad

Yea, I did know it was a bit of a bastardization of the method, but I wasn't aware of another option as that is how the mass matrix is returned in ActuallyExplicitEuler. I was not aware of LinearSystem, I'll need to take a look at that. It looks like I need to take another stab at this and restructure things. I appreciate the feedback!

TheGreatCid avatar Jul 17 '24 15:07 TheGreatCid

Though the fact that the linear system does not support time integrators is an issue

TheGreatCid avatar Jul 17 '24 15:07 TheGreatCid

Ha, yes that is a big issue. It would be great to have someone work on that, but it would make sense if that's not what you want to focus your attention on

lindsayad avatar Jul 17 '24 17:07 lindsayad

If it didn't make sense or would take a lot of effort to re-use the current TimeIntegrator classes for LinearSystem, then this would be a great opportunity to use PETSc TS

lindsayad avatar Jul 17 '24 17:07 lindsayad

Perhaps @grmnptr could weigh-in with his thoughts on time integration for LinearSystem

lindsayad avatar Jul 17 '24 17:07 lindsayad

We talked about this in person and the conclusion was that it would be very hard to do this with the LinearSystem because at the moment it does not have support for:

  1. Finite Elements
  2. TimeIntegrators So a lot of work would be needed here. I recommended registering a new matrix to the nonlinear system in the time integrator and creating a custom ThreadedLoop to assemble the mass matrix into it. That might run into issues on the other fronts so feel free to share other suggestions!

grmnptr avatar Jul 17 '24 23:07 grmnptr

If we are going that route, then I really think we should limit the number of changes made in the framework. I don't want to add second class support in the framework because we don't currently have the time to do the work that needs to be done for first class support. @recuero's explicit dynamics changes didn't really feel quite right when we merged them and I'm worried that this further jams the square peg into the round hole

lindsayad avatar Jul 17 '24 23:07 lindsayad

The better route might be to move this time integrator into solid_mechanics, and then use the tagging system and MassMatrix.C to pass the mass matrix in. MassMatrix.C is something I was unaware of until yesterday evening.

TheGreatCid avatar Jul 18 '24 13:07 TheGreatCid

@lindsayad I opened a new PR, https://github.com/idaholab/moose/pull/28175, with a different approach to implementing this time integrator

TheGreatCid avatar Jul 18 '24 19:07 TheGreatCid

I won't review the other one yet as you have it marked as draft, but I do like it a lot better. It looks quite clean!

lindsayad avatar Jul 18 '24 20:07 lindsayad

I left it as a draft because the documentation/tests are not yet implemented, but the code is ready for review. Should I mark it as ready now, or wait until I have added in doc/tests?

TheGreatCid avatar Jul 18 '24 20:07 TheGreatCid

Might as well wait until you've added the documentation and tests so that a reviewer can look at it in one fell swoop. The input file can influence how I feel about the code design

lindsayad avatar Jul 18 '24 20:07 lindsayad