idaholab / moose

Multiphysics Object Oriented Simulation Environment
https://www.mooseframework.org
GNU Lesser General Public License v2.1
1.6k stars 1k forks source link

Modular NEML2 model execution #27493

Closed dschwen closed 1 week ago

dschwen commented 3 weeks ago

Motivation

Currently a now driver user object / material need to bee written for every new set of NEML2 model inputs and outputs to execute a NEML2 model from MOOSE. Furthermore the current UO design is not conducive to inheritance and results in a lot of code duplication in new driver objects.

Design

Create a modular user object based system, where inputs and outputs can be mapped between NEML2 variables and MOOSE Variables/MaterialProperties at run time.

Impact

Execute arbitrary NEML2 models with arbitrary inputs and outputs

moosebuild commented 3 weeks ago

Job Precheck on d48748c 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/27493/clang_format/style.patch | git apply -v

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

git clang-format 4d26c5e4c87d95ff4124129109ec8f51f6528a7d

moosebuild commented 3 weeks ago

Job Documentation on 662f966 wanted to post the following:

View the site here

This comment will be updated on new commits.

moosebuild commented 3 weeks ago

Job Coverage on 0db3591 wanted to post the following:

Framework coverage

14e79c #27493 0db359
Total Total +/- New
Rate 85.11% 85.11% +0.00% 100.00%
Hits 103108 103110 +2 2
Misses 18044 18043 -1 0

Diff coverage report

Full coverage report

Modules coverage

Solid mechanics

14e79c #27493 0db359
Total Total +/- New
Rate 84.90% 84.86% -0.04% 78.28%
Hits 27458 27671 +213 209
Misses 4882 4936 +54 58

Diff coverage report

Full coverage report

Full coverage reports

Reports - [`framework`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/framework) - [`chemical_reactions`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/chemical_reactions) - [`combined`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/combined) - [`contact`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/contact) - [`electromagnetics`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/electromagnetics) - [`external_petsc_solver`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/external_petsc_solver) - [`fluid_properties`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/fluid_properties) - [`fsi`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/fsi) - [`functional_expansion_tools`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/functional_expansion_tools) - [`geochemistry`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/geochemistry) - [`heat_transfer`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/heat_transfer) - [`level_set`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/level_set) - [`misc`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/misc) - [`navier_stokes`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/navier_stokes) - [`optimization`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/optimization) - [`peridynamics`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/peridynamics) - [`phase_field`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/phase_field) - [`porous_flow`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/porous_flow) - [`ray_tracing`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/ray_tracing) - [`rdg`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/rdg) - [`reactor`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/reactor) - [`richards`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/richards) - [`scalar_transport`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/scalar_transport) - [`solid_mechanics`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/solid_mechanics) - [`solid_properties`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/solid_properties) - [`stochastic_tools`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/stochastic_tools) - [`thermal_hydraulics`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/thermal_hydraulics) - [`xfem`](https://mooseframework.inl.gov/docs/PRs/27493/coverage/xfem)

Warnings

This comment will be updated on new commits.

moosebuild commented 2 weeks ago

Job Conda (ARM Mac) on 13efc9f : invalidated by @dschwen

dschwen commented 2 weeks ago

I will restore @dewenyushu 's functionality in a follow on PR. This one has gotten quite large. @hugary1995 there are potentially some small conflicts with your pending PR (such as the FileName -> std::path issue). If your PR get's in first I'll update my PR accordingly.

dschwen commented 2 weeks ago

Failures are unrelated

dschwen commented 2 weeks ago

Rebasing on @hugary1995 just merged PR went without any conflicts but left two copies of a new function we both implemented.

loganharbour commented 2 weeks ago

@dschwen let me know if you want me to look at the framework stuff

hugary1995 commented 2 weeks ago
  1. An element loop runs the strain calculator (Material) and the MOOSEXXXToNEML2 gatherers (Userobject).
  2. The ExecuteNEML2Model (Userobject) calls NEML2 to perform the batched update upon finalize.
  3. An element loop runs the NEML2XXXToMOOSE gatherers (Material) and the kernels to assemble the residual.

Actually now that I had a closer look at this, doesn't this require two element loops before the residual evaluation? Is that possible or am I missing something obvious?

hugary1995 commented 2 weeks ago

Also, let's deprecate the old design. We could give it a short deprecation period as I doubt anyone is heavily using it.

hugary1995 commented 2 weeks ago

Actually now that I had a closer look at this, doesn't this require two element loops before the residual evaluation? Is that possible or am I missing something obvious?

Ignore my question... We are apparently running an element UO loop prior to the residual element loop.

dschwen commented 2 weeks ago

Will the strain calculators be executed twice in both step 1 and 3? I hope the framework is smart enough to skip unnecessary material objects, but IIRC the last time I looked at the threaded loop, there wasn't such check in place.

I was working on a huge PR to limit material execution to exactly what is needed during each loop, but it got out of hand. The compute false materials were a challenge (we are relying on all materials to get evaluated in some places).

https://github.com/idaholab/moose/pull/21804

dschwen commented 1 week ago

Follow on work :#27553

dschwen commented 1 week ago

FSI failure is unrelated.