From 9c5e4efeb13aebc128a0707809f212a542e75015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Mas=C3=B3?= Date: Wed, 26 Aug 2026 15:57:55 +0200 Subject: [PATCH 1/8] Update docstring --- src/ComputationalModels/Drivers.jl | 4 ++++ src/PhysicalModels/PhysicalModels.jl | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/ComputationalModels/Drivers.jl b/src/ComputationalModels/Drivers.jl index 1622623..50b1c88 100644 --- a/src/ComputationalModels/Drivers.jl +++ b/src/ComputationalModels/Drivers.jl @@ -284,6 +284,8 @@ get_assemblers(m::DynamicNonlinearModel) = (m.caches[4]) """ + update_velocity! + Update the velocity field `vh` based on the current displacement field `xh⁺` and the previous displacement `xh⁻` using a midpoint time-stepping scheme. The velocity is updated in place. @@ -298,6 +300,8 @@ end """ + update_displacements! + Update the old displacement field `xh⁻` with the new displacement field `xh⁺`. The update is performed in place, modifying `xh⁻` to match both the free dof values and the dirichlet dof values of `xh⁺`. diff --git a/src/PhysicalModels/PhysicalModels.jl b/src/PhysicalModels/PhysicalModels.jl index 9690547..eea13d4 100644 --- a/src/PhysicalModels/PhysicalModels.jl +++ b/src/PhysicalModels/PhysicalModels.jl @@ -204,7 +204,11 @@ end """ + update_time_step!(model, Δt) + Set the time step to be used internally by the constitutive model. +The time step is a reference, hence, the weak forms derived from the +constitutive model will be automatically updated with the new time step. """ function update_time_step!(::PhysicalModel, Δt::Float64) Δt From 2acc1f5cdbeb4f8d66dcaf12171b356f7f865305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Mas=C3=B3?= Date: Wed, 26 Aug 2026 16:01:48 +0200 Subject: [PATCH 2/8] removed explicit import --- src/Exports.jl | 1 - src/PhysicalModels/ElectroMechanicalModels.jl | 2 +- src/PhysicalModels/PhysicalModels.jl | 3 +-- src/PhysicalModels/ThermoElectroMechanicalModels.jl | 2 +- src/PhysicalModels/ThermoMechanicalModels.jl | 2 +- src/PhysicalModels/ViscousModels.jl | 8 ++++---- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Exports.jl b/src/Exports.jl index 0417462..83770c4 100644 --- a/src/Exports.jl +++ b/src/Exports.jl @@ -96,7 +96,6 @@ end @publish PhysicalModels FlexoElectro @publish PhysicalModels ThermoElectroMechano @publish PhysicalModels EnergyInterpolationScheme -@publish PhysicalModels update_state! @publish PhysicalModels Kinematics @publish PhysicalModels Solid @publish PhysicalModels KinematicModel diff --git a/src/PhysicalModels/ElectroMechanicalModels.jl b/src/PhysicalModels/ElectroMechanicalModels.jl index dfe36ee..f1f3b61 100644 --- a/src/PhysicalModels/ElectroMechanicalModels.jl +++ b/src/PhysicalModels/ElectroMechanicalModels.jl @@ -81,7 +81,7 @@ function initialize_state(obj::ElectroMechModel) initialize_state(obj.mechano) end -function update_state!(obj::ElectroMechModel, state, F, E, args...) +function Gridap.CellData.update_state!(obj::ElectroMechModel, state, F, E, args...) update_state!(obj.mechano, state, F, args...) end diff --git a/src/PhysicalModels/PhysicalModels.jl b/src/PhysicalModels/PhysicalModels.jl index eea13d4..43752a9 100644 --- a/src/PhysicalModels/PhysicalModels.jl +++ b/src/PhysicalModels/PhysicalModels.jl @@ -12,7 +12,6 @@ using ..TensorAlgebra: _∂H∂F_2D using ..TensorAlgebra: trAA import Base: + -import Gridap: update_state! export Yeoh3D export PlaneStressIncompressible_I1PD @@ -176,7 +175,7 @@ end """ Update the state variables. The state variables must be initialized using the function 'CellState' with the constitutive model. """ -function update_state!(::PhysicalModel, vars...) +function Gridap.CellData.update_state!(::PhysicalModel, vars...) end diff --git a/src/PhysicalModels/ThermoElectroMechanicalModels.jl b/src/PhysicalModels/ThermoElectroMechanicalModels.jl index 1940343..05d1d29 100644 --- a/src/PhysicalModels/ThermoElectroMechanicalModels.jl +++ b/src/PhysicalModels/ThermoElectroMechanicalModels.jl @@ -7,7 +7,7 @@ function initialize_state(obj::ThermoElectroMechano) initialize_state(obj.mechano) end -function update_state!(obj::ThermoElectroMechano, state, F, E, θ, args...) +function Gridap.CellData.update_state!(obj::ThermoElectroMechano, state, F, E, θ, args...) update_state!(obj.mechano, state, F, args...) end diff --git a/src/PhysicalModels/ThermoMechanicalModels.jl b/src/PhysicalModels/ThermoMechanicalModels.jl index 509e43a..96fe9f9 100644 --- a/src/PhysicalModels/ThermoMechanicalModels.jl +++ b/src/PhysicalModels/ThermoMechanicalModels.jl @@ -11,7 +11,7 @@ function initialize_state(obj::TM) where {TM<:ThermoMechano} initialize_state(obj.mechano) end -function update_state!(obj::TM, state, F, θ, args...) where {TM<:ThermoMechano} +function Gridap.CellData.update_state!(obj::TM, state, F, θ, args...) where {TM<:ThermoMechano} update_state!(obj.mechano, state, F, args...) end diff --git a/src/PhysicalModels/ViscousModels.jl b/src/PhysicalModels/ViscousModels.jl index a53d5e6..e37cc1d 100644 --- a/src/PhysicalModels/ViscousModels.jl +++ b/src/PhysicalModels/ViscousModels.jl @@ -40,7 +40,7 @@ function initialize_state(::ViscousIncompressible) VectorValue(I3..., 0.0) end -function update_state!(obj::ViscousIncompressible, A, F, Fn) +function Gridap.CellData.update_state!(obj::ViscousIncompressible, A, F, Fn) state_updater(Aᵅ, Fᵅ, Fnᵅ) = (true, return_mapping(obj, Fᵅ, Fnᵅ, Aᵅ)) update_state!(state_updater, A, F, Fn) end @@ -103,7 +103,7 @@ function initialize_state(obj::NVisco) map(initialize_state, obj) end -function update_state!(obj::NVisco, states, F, Fn) +function Gridap.CellData.update_state!(obj::NVisco, states, F, Fn) @assert length(obj) == length(states) map((b, s) -> update_state!(b, s, F, Fn), obj, states) end @@ -157,11 +157,11 @@ function initialize_state(obj::GeneralizedMaxwell) initialize_state(obj.branches) end -function update_state!(obj::GeneralizedMaxwell{<:IsoElastic}, states, F, Fn) +function Gridap.CellData.update_state!(obj::GeneralizedMaxwell{<:IsoElastic}, states, F, Fn) update_state!(obj.branches, states, F, Fn) end -function update_state!(obj::GeneralizedMaxwell{<:AnisoElastic}, states, F, n, Fn) +function Gridap.CellData.update_state!(obj::GeneralizedMaxwell{<:AnisoElastic}, states, F, n, Fn) update_state!(obj.branches, states, F, Fn) end From 1b9ed4d2aae5650cae26b5272dd3dd764eed8551 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Mas=C3=B3?= Date: Wed, 26 Aug 2026 16:10:40 +0200 Subject: [PATCH 3/8] Added more function titles --- src/PhysicalModels/PhysicalModels.jl | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/PhysicalModels/PhysicalModels.jl b/src/PhysicalModels/PhysicalModels.jl index 43752a9..855375d 100644 --- a/src/PhysicalModels/PhysicalModels.jl +++ b/src/PhysicalModels/PhysicalModels.jl @@ -157,6 +157,8 @@ include("PINNs.jl") Base.broadcastable(m::PhysicalModel) = Ref(m) # Allows to use the @. syntax for passing a single constitutive model into a vectorized function """ + CellState(model, dΩ) + Initialize the state variables for the given constitutive model and discretization. """ function Gridap.CellData.CellState(::PhysicalModel, args...) @@ -165,6 +167,8 @@ end """ + initialize_state(model) + Define the state variable at a Gauss point. Unlike the function 'CellState', the state variable is represented by a number or a tensor. """ function initialize_state(::PhysicalModel) @@ -173,6 +177,8 @@ end """ + update_state!(model, A, F, Fn) + Update the state variables. The state variables must be initialized using the function 'CellState' with the constitutive model. """ function Gridap.CellData.update_state!(::PhysicalModel, vars...) @@ -180,6 +186,8 @@ end """ + return_mapping(model, F, Fn, A...) + Update the state variables at a Gauss point. Unlike the function 'update_state!', the state variables are represented by a number or a tensor. """ function return_mapping(::PhysicalModel, vars...) @@ -187,6 +195,8 @@ end """ + Dissipation(model) + Return the dissipation and its derivatives if any. """ function Dissipation(::PhysicalModel, args...) @@ -195,6 +205,8 @@ end """ + SecondPiola(model) + Return the energy density and its derivatives as functions of C instead of F. """ function SecondPiola(::T, args...) where {T<:PhysicalModel} From 066b0a439deaf54bf6e0d9ace2d8412a70470990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Mas=C3=B3?= Date: Wed, 26 Aug 2026 16:18:49 +0200 Subject: [PATCH 4/8] excluded private docs --- docs/src/api.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/src/api.md b/docs/src/api.md index c2564f6..bf88b2b 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -5,6 +5,7 @@ Modules = [HyperFEM.ComputationalModels] Order = [:module, :type, :function, :macro] Public = true +Private = false ``` ## DiscreteModeling @@ -13,6 +14,7 @@ Public = true Modules = [HyperFEM.DiscreteModeling, HyperFEM.DiscreteModeling.CartesianTags, HyperFEM.DiscreteModeling.EvolutionFunctions] Order = [:module, :type, :function, :macro] Public = true +Private = false ``` ## PhysicalModels @@ -21,6 +23,7 @@ Public = true Modules = [HyperFEM.PhysicalModels] Order = [:module, :type, :function, :macro] Public = true +Private = false ``` ## Solvers @@ -29,6 +32,7 @@ Public = true Modules = [HyperFEM.Solvers] Order = [:module, :type, :function, :macro] Public = true +Private = false ``` ## TensorAlgebra @@ -37,6 +41,7 @@ Public = true Modules = [HyperFEM.TensorAlgebra] Order = [:module, :type, :function, :macro] Public = true +Private = false ``` ## WeakForms @@ -45,4 +50,5 @@ Public = true Modules = [HyperFEM.WeakForms] Order = [:module, :type, :function, :macro] Public = true +Private = false ``` From 264572463ebeec63aac158b50801ddfa1c793386 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Mas=C3=B3?= Date: Wed, 26 Aug 2026 16:41:18 +0200 Subject: [PATCH 5/8] better descriptions, crossref, imported from Gridap --- docs/src/api.md | 5 +++++ src/PhysicalModels/PhysicalModels.jl | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/docs/src/api.md b/docs/src/api.md index bf88b2b..a1f941e 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -26,6 +26,11 @@ Public = true Private = false ``` +```@docs +Gridap.CellData.CellState(::PhysicalModel, args...) +Gridap.CellData.update_state!(::PhysicalModel, vars...) +``` + ## Solvers ```@autodocs diff --git a/src/PhysicalModels/PhysicalModels.jl b/src/PhysicalModels/PhysicalModels.jl index 855375d..1d888b5 100644 --- a/src/PhysicalModels/PhysicalModels.jl +++ b/src/PhysicalModels/PhysicalModels.jl @@ -160,6 +160,8 @@ Base.broadcastable(m::PhysicalModel) = Ref(m) # Allows to use the @. syntax for CellState(model, dΩ) Initialize the state variables for the given constitutive model and discretization. +The constitutive model passed to the function will determine the type of the state variables, +e.g., a vector, tensor, tuple of state variables... """ function Gridap.CellData.CellState(::PhysicalModel, args...) return nothing @@ -169,7 +171,8 @@ end """ initialize_state(model) -Define the state variable at a Gauss point. Unlike the function 'CellState', the state variable is represented by a number or a tensor. +Define the state variable at a Gauss point. Unlike the function [`CellState`](@ref), the returned +state variable is represented by a number or a tensor. """ function initialize_state(::PhysicalModel) return nothing @@ -179,7 +182,11 @@ end """ update_state!(model, A, F, Fn) -Update the state variables. The state variables must be initialized using the function 'CellState' with the constitutive model. +Update the state variables. The state variables must be initialized using the function +[`CellState`](@ref) with the constitutive model. + +NOTE: The Gridap function expects the following order of arguments: `update_state!(updater, cell_states, cell_fields)`, +hence, the order of the arguments differ from the standar energy function, like `Ψ(F, Fn, A...)` """ function Gridap.CellData.update_state!(::PhysicalModel, vars...) end @@ -188,7 +195,7 @@ end """ return_mapping(model, F, Fn, A...) -Update the state variables at a Gauss point. Unlike the function 'update_state!', the state variables are represented by a number or a tensor. +Update the state variables at a Gauss point. Unlike the function [`update_state!`](@ref), the state variables are represented by a number or a tensor. """ function return_mapping(::PhysicalModel, vars...) end From 1be223baa52f3d3cbbaa7d701bbc35754fc0465b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Mas=C3=B3?= Date: Wed, 26 Aug 2026 16:52:10 +0200 Subject: [PATCH 6/8] added import: try fix docs --- src/PhysicalModels/PhysicalModels.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/PhysicalModels/PhysicalModels.jl b/src/PhysicalModels/PhysicalModels.jl index 1d888b5..b2d1e09 100644 --- a/src/PhysicalModels/PhysicalModels.jl +++ b/src/PhysicalModels/PhysicalModels.jl @@ -12,6 +12,7 @@ using ..TensorAlgebra: _∂H∂F_2D using ..TensorAlgebra: trAA import Base: + +import Gridap.CellData: CellState, update_state! export Yeoh3D export PlaneStressIncompressible_I1PD From 5cb3141e9e09d2b44067ab8a17ccb6b932fcb5d3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Mas=C3=B3?= Date: Wed, 26 Aug 2026 16:58:44 +0200 Subject: [PATCH 7/8] making meethod public --- docs/src/api.md | 5 ----- src/Exports.jl | 3 +++ src/PhysicalModels/PhysicalModels.jl | 2 ++ 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/src/api.md b/docs/src/api.md index a1f941e..bf88b2b 100644 --- a/docs/src/api.md +++ b/docs/src/api.md @@ -26,11 +26,6 @@ Public = true Private = false ``` -```@docs -Gridap.CellData.CellState(::PhysicalModel, args...) -Gridap.CellData.update_state!(::PhysicalModel, vars...) -``` - ## Solvers ```@autodocs diff --git a/src/Exports.jl b/src/Exports.jl index 83770c4..d0f4dbf 100644 --- a/src/Exports.jl +++ b/src/Exports.jl @@ -113,6 +113,9 @@ end @publish PhysicalModels SecondPiola @publish PhysicalModels Dissipation + +@publish PhysicalModels CellState # reexport form Gridap +@publish PhysicalModels update_state! # reexport from Gridap @publish PhysicalModels initialize_state @publish PhysicalModels return_mapping @publish PhysicalModels update_time_step! diff --git a/src/PhysicalModels/PhysicalModels.jl b/src/PhysicalModels/PhysicalModels.jl index b2d1e09..185a98e 100644 --- a/src/PhysicalModels/PhysicalModels.jl +++ b/src/PhysicalModels/PhysicalModels.jl @@ -85,6 +85,8 @@ export EnergyInterpolationScheme export SecondPiola export Dissipation +export CellState # reexport from Gridap +export update_state! # reexport form Gridap export initialize_state export return_mapping export update_time_step! From ac0621ac22790a3cf7be754bfe23d30450d94ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miguel=20Mas=C3=B3?= Date: Wed, 26 Aug 2026 17:02:34 +0200 Subject: [PATCH 8/8] minor, fixed indetation --- src/PhysicalModels/ViscousPolyconvex.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/PhysicalModels/ViscousPolyconvex.jl b/src/PhysicalModels/ViscousPolyconvex.jl index e9202e4..48bb126 100644 --- a/src/PhysicalModels/ViscousPolyconvex.jl +++ b/src/PhysicalModels/ViscousPolyconvex.jl @@ -12,7 +12,7 @@ where `F` is the deformation gradient, `J` is the jacobian and `Cᵥ` is the vis - `μ::Float64`: Shear modulus. - `τ::Float64`: Relaxation time. - `Δt::Base.RefValue{Float64}`: `Reference` to the time step. - """ +""" struct ViscousPolyconvex <: Visco μ::Float64 τ::Float64