-
Notifications
You must be signed in to change notification settings - Fork 1
Refactors kinematic descriptions in physical models #50
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
Conversation
Introduces a more explicit kinematic description and associates it directly with the physics of the solid material, thus decoupling the kinematic model from the specific electrical or magnetic model. This change simplifies the model definitions and usage in weak forms and post-processors, improving overall code clarity and maintainability.
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.
Pull Request Overview
This PR refactors the kinematic model architecture by removing the Kinematic field from physical models and introducing an explicit KinematicDescription type hierarchy. The key changes include:
- Introducing
SolidandSolidShellas concrete kinematic descriptions - Refactoring
Kinematicsconstructor to require both physics type and description type - Removing
Kinematicfields from all physical model structs - Passing kinematic models explicitly to
residualandjacobianfunctions - Converting
KinematicDescription{:SecondPiola}from a parameterized type to a new functionSecondPiola - Updating state variable update functions to accept deformation gradients directly
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| src/PhysicalModels/KinematicModels.jl | Introduces Solid/SolidShell abstract types and refactors Kinematics constructor to require kinematic description type |
| src/PhysicalModels/MechanicalModels.jl | Removes Kinematic fields from mechanical models; inlines kinematic functions (J, H) in model definitions; converts KinematicDescription{:SecondPiola} to SecondPiola function |
| src/PhysicalModels/ViscousModels.jl | Removes Kinematic field; changes updateStateVariables! signature to accept F and Fn directly; replaces KinematicDescription{:SecondPiola} with SecondPiola function call |
| src/PhysicalModels/ElectricalModels.jl | Removes Kinematic field from IdealDielectric |
| src/PhysicalModels/MagneticModels.jl | Removes Kinematic field from magnetic models |
| src/PhysicalModels/ElectroMechanicalModels.jl | Inlines kinematic functions (J, H) in coupling functions |
| src/PhysicalModels/ThermoMechanicalModels.jl | Inlines kinematic functions (J, H) in coupling and entropy models |
| src/PhysicalModels/ThermoElectroMechanicalModels.jl | Inlines kinematic functions (J, H) in thermo-electro-mechanical coupling |
| src/PhysicalModels/MagnetoMechanicalModels.jl | Inlines kinematic functions (J, H) in magneto-mechanical coupling |
| src/PhysicalModels/PINNs.jl | Updates Kinematics calls to include Solid description |
| src/PhysicalModels/PhysicalModels.jl | Exports SecondPiola and Solid; moves KinematicDescription export |
| src/WeakForms/WeakForms.jl | Adds KinematicModel parameter to residual/jacobian functions; removes internal kinematic creation |
| src/WeakForms/ElectroMechanics.jl | Adds kine::NTuple{2,KinematicModel} parameter to residual/jacobian functions |
| src/ComputationalModels/PostProcessors.jl | Adds kinematic parameter to Jacobian, Cauchy, Entropy, and D0 functions |
| src/Exports.jl | Exports Solid |
| test/data/ViscoElasticSimulation.jl | Creates kinematic models explicitly and passes to residual/jacobian; updates updateStateVariables! calls |
| test/TestWeakForms/WeakForms.jl | Creates kinematic tuples and passes to jacobian functions |
| test/TestConstitutiveModels/*.jl | Creates kinematic models explicitly; updates all test function signatures; removes using HyperFEM: jacobian |
| README.md | Updates example to show explicit kinematic model creation |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function (obj::IncompressibleNeoHookean3D)(::KinematicDescription{:SecondPiola}, Λ::Float64=1.0) | ||
| end | ||
|
|
||
| function SecondPiola(obj::IncompressibleNeoHookean3D,Λ::Float64=1.0) |
Copilot
AI
Nov 5, 2025
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 SecondPiola function is defined outside the struct definition but should be inside or immediately following the struct's closing end. This breaks Julia convention where methods are typically defined within the struct's method block or clearly separated from it. Consider moving this function definition to be immediately after line 823 or reorganizing the code structure.
| function residual(physicalmodel::ThermoElectroMechano, kine::NTuple{3,KinematicModel}, (u, φ, θ), (v, vφ, vθ), dΩ, Λ=1.0) | ||
| residual(physicalmodel, Mechano, kine, (u, φ, θ), v, dΩ, Λ) + | ||
| residual(physicalmodel, Electro, kine, (u, φ, θ), vφ, dΩ, Λ) + | ||
| residual(physicalmodel, Thermo, kine,(u, φ, θ), vθ, dΩ, Λ) |
Copilot
AI
Nov 5, 2025
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.
Inconsistent spacing around function arguments. Line 162 has kine,(u, φ, θ) without a space after the comma, while lines 160-161 have proper spacing. This should be kine, (u, φ, θ) for consistency.
| residual(physicalmodel, Thermo, kine,(u, φ, θ), vθ, dΩ, Λ) | |
| residual(physicalmodel, Thermo, kine, (u, φ, θ), vθ, dΩ, Λ) |
| end | ||
| function jac_mech(uh, θh) | ||
| jac(du, v) = jacobian(modelTM, Mechano, (uh, θh), du, v, dΩ) | ||
| jac(du, v) = jacobian(modelTM, Mechano, k,(uh, θh), du, v, dΩ) |
Copilot
AI
Nov 5, 2025
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.
Missing space after comma between k and (uh, θh). Should be k, (uh, θh) for consistency with Julia style conventions.
| jac(du, v) = jacobian(modelTM, Mechano, k,(uh, θh), du, v, dΩ) | |
| jac(du, v) = jacobian(modelTM, Mechano, k, (uh, θh), du, v, dΩ) |
| end | ||
| function jac_termoh(uh, θh) | ||
| jac(dθ, vθ) = jacobian(modelTM, Thermo, dθ, vθ, dΩ) | ||
| jac(dθ, vθ) = jacobian(modelTM, Thermo,k, dθ, vθ, dΩ) |
Copilot
AI
Nov 5, 2025
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.
Missing space after comma between Thermo and k. Should be Thermo, k for consistency with Julia style conventions.
| jac(dθ, vθ) = jacobian(modelTM, Thermo,k, dθ, vθ, dΩ) | |
| jac(dθ, vθ) = jacobian(modelTM, Thermo, k, dθ, vθ, dΩ) |
| end | ||
| function jac_mech(uh, φh) | ||
| jac(du, v) = jacobian(modelelectro, Mechano, (uh, φh), du, v, dΩ) | ||
| jac(du, v) = jacobian(modelelectro, Mechano, k,(uh, φh), du, v, dΩ) |
Copilot
AI
Nov 5, 2025
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.
Missing space after comma between k and (uh, φh). Should be k, (uh, φh) for consistency with Julia style conventions.
| jac(du, v) = jacobian(modelelectro, Mechano, k,(uh, φh), du, v, dΩ) | |
| jac(du, v) = jacobian(modelelectro, Mechano, k, (uh, φh), du, v, dΩ) |
| res(Λ) = ((u, φ), (v, vφ)) -> residual(physmodel, (km,ke),(u, φ), (v, vφ), dΩ) | ||
| jac(Λ) = ((u, φ), (du, dφ), (v, vφ)) -> jacobian(physmodel, (km,ke), (u, φ), (du, dφ), (v,vφ),dΩ) |
Copilot
AI
Nov 5, 2025
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.
Missing spaces after commas in kinematic tuple (km,ke) and before the next argument (u, φ). Should be (km, ke), (u, φ) for consistency with Julia style conventions.
| res(Λ) = ((u, φ), (v, vφ)) -> residual(physmodel, (km,ke),(u, φ), (v, vφ), dΩ) | |
| jac(Λ) = ((u, φ), (du, dφ), (v, vφ)) -> jacobian(physmodel, (km,ke), (u, φ), (du, dφ), (v,vφ),dΩ) | |
| res(Λ) = ((u, φ), (v, vφ)) -> residual(physmodel, (km, ke), (u, φ), (v, vφ), dΩ) | |
| jac(Λ) = ((u, φ), (du, dφ), (v, vφ)) -> jacobian(physmodel, (km, ke), (u, φ), (du, dφ), (v, vφ), dΩ) |
| res(Λ) = ((u, φ), (v, vφ)) -> residual(physmodel, (km,ke),(u, φ), (v, vφ), dΩ) | ||
| jac(Λ) = ((u, φ), (du, dφ), (v, vφ)) -> jacobian(physmodel, (km,ke), (u, φ), (du, dφ), (v,vφ),dΩ) |
Copilot
AI
Nov 5, 2025
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.
Missing spaces after commas in multiple places: (km,ke) should be (km, ke), (v,vφ) should be (v, vφ), and (v,vφ),dΩ should be (v, vφ), dΩ for consistency with Julia style conventions.
| res(Λ) = ((u, φ), (v, vφ)) -> residual(physmodel, (km,ke),(u, φ), (v, vφ), dΩ) | |
| jac(Λ) = ((u, φ), (du, dφ), (v, vφ)) -> jacobian(physmodel, (km,ke), (u, φ), (du, dφ), (v,vφ),dΩ) | |
| res(Λ) = ((u, φ), (v, vφ)) -> residual(physmodel, (km, ke), (u, φ), (v, vφ), dΩ) | |
| jac(Λ) = ((u, φ), (du, dφ), (v, vφ)) -> jacobian(physmodel, (km, ke), (u, φ), (du, dφ), (v, vφ), dΩ) |
| end | ||
|
|
||
| function jacobian(physicalmodel::ThermoElectroMech_PINNs, ::Type{Thermo}, dθ, vθ, dΩ, Λ=1.0) | ||
| function jacobian(physicalmodel::ThermoElectroMech_PINNs, ::Type{Thermo}, kine::NTuple{2,KinematicModel},dθ, vθ, dΩ, Λ=1.0) |
Copilot
AI
Nov 5, 2025
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.
Inconsistent spacing: double space after ::Type{Thermo}, and missing space after kine::NTuple{2,KinematicModel},. Should be single spaces throughout.
| jacobian(physicalmodel, ThermoMechano, (u, θ), (du, dθ), v, dΩ, Λ) | ||
| function jacobian(physicalmodel::ThermoMechano, kine::NTuple{2,KinematicModel}, (u, θ), (du, dθ), (v, vθ), dΩ, Λ=1.0) | ||
| jacobian(physicalmodel, Mechano, kine, (u, θ), du, v, dΩ, Λ)+ | ||
| jacobian(physicalmodel, Thermo, kine,dθ, vθ, dΩ, Λ)+ |
Copilot
AI
Nov 5, 2025
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.
Missing space after comma between kine and dθ. Should be kine, dθ for consistency with Julia style conventions.
| jacobian(physicalmodel, Thermo, kine,dθ, vθ, dΩ, Λ)+ | |
| jacobian(physicalmodel, Thermo, kine, dθ, vθ, dΩ, Λ)+ |
| jacobian(physicalmodel, Mechano, kine,(u, φ), du, v, dΩ, Λ, Δt, un, A) + | ||
| jacobian(physicalmodel, Electro, kine,(u, φ), dφ, vφ, dΩ, Λ, Δt, un, A) + | ||
| jacobian(physicalmodel, ElectroMechano, kine,(u, φ), (du, dφ), (v, vφ), dΩ, Λ, Δt, un, A) |
Copilot
AI
Nov 5, 2025
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.
Missing spaces after commas between kine and (u, φ) on all three lines. Should be kine, (u, φ) for consistency with Julia style conventions.
| jacobian(physicalmodel, Mechano, kine,(u, φ), du, v, dΩ, Λ, Δt, un, A) + | |
| jacobian(physicalmodel, Electro, kine,(u, φ), dφ, vφ, dΩ, Λ, Δt, un, A) + | |
| jacobian(physicalmodel, ElectroMechano, kine,(u, φ), (du, dφ), (v, vφ), dΩ, Λ, Δt, un, A) | |
| jacobian(physicalmodel, Mechano, kine, (u, φ), du, v, dΩ, Λ, Δt, un, A) + | |
| jacobian(physicalmodel, Electro, kine, (u, φ), dφ, vφ, dΩ, Λ, Δt, un, A) + | |
| jacobian(physicalmodel, ElectroMechano, kine, (u, φ), (du, dφ), (v, vφ), dΩ, Λ, Δt, un, A) |
Benchmark Results (Julia v1)Time benchmarks
Memory benchmarks
|
Introduces a more explicit kinematic description and associates it directly with the physics of the solid material, thus decoupling the kinematic model from the specific electrical or magnetic model.
This change simplifies the model definitions and usage in weak forms and post-processors, improving overall code clarity and maintainability.