Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
10895d0
Refactor Electro and ThermoElectro
miguelmaso Apr 30, 2026
c92d542
Fixed compilation
miguelmaso Apr 30, 2026
bf90ec9
fix overflow
miguelmaso Apr 30, 2026
cf7a748
fixed missing obj
miguelmaso Apr 30, 2026
cafdd84
missing obj, added ctor
miguelmaso Apr 30, 2026
0340de8
fixed model ctor
miguelmaso May 4, 2026
f89c442
cleaner electro-mech
miguelmaso May 6, 2026
24d544d
removed old get coupling
miguelmaso May 6, 2026
2ea565f
Updated polynomial law
miguelmaso May 7, 2026
2bb77be
rename internal variable
miguelmaso May 11, 2026
faf9e59
added thermal deviatoric
miguelmaso May 11, 2026
3b1212c
fix dielectric energy definition
miguelmaso May 12, 2026
ea0b43d
added constant laws
miguelmaso May 13, 2026
0784797
CellState: Allowed initial value, deprecated initialize_state
miguelmaso May 14, 2026
90419f1
Merge branch 'thermo-electro' of https://github.com/MultiSimOLab/Hype…
miguelmaso May 14, 2026
8ba74c3
missing export thermal laws
miguelmaso May 14, 2026
71e28af
missing unpack field
miguelmaso May 15, 2026
c01fe72
adjust tolerances
miguelmaso May 15, 2026
b8ace66
added IdealDielectric test
miguelmaso May 18, 2026
065fb64
consistent cartesian tags
miguelmaso May 21, 2026
b9361c6
Fix HyperFEM distributed compilation
miguelmaso May 21, 2026
ea49017
New sub-module
miguelmaso May 21, 2026
89d2bf4
added exports
miguelmaso May 21, 2026
83fbd62
try different export
miguelmaso May 21, 2026
8a43faa
missing import
miguelmaso May 21, 2026
67550f9
reorder includes
miguelmaso May 21, 2026
efd5e36
update tags in tests
miguelmaso May 21, 2026
ad5fb51
Merge branch 'main' into thermo-electro
miguelmaso May 26, 2026
2a4edd0
Merge branch 'main' into descript
miguelmaso May 26, 2026
323f948
merge conflicts
miguelmaso May 26, 2026
fb8d553
added simplified Aruda Boyce
miguelmaso May 26, 2026
248fb6e
property destructing
miguelmaso May 27, 2026
7e81de8
Explicit multiple dispatch
miguelmaso May 27, 2026
34c0bca
Merge branch 'main' into thermo-electro
miguelmaso May 27, 2026
19eba4a
Merge branch 'aruda' into thermo-electro
miguelmaso May 27, 2026
cce3bb5
changing var name
miguelmaso May 28, 2026
d29e0e0
Merge branch 'aruda' into thermo-electro
miguelmaso May 28, 2026
0198721
Merge branch 'descript' into thermo-electro
miguelmaso May 28, 2026
f8303d2
Merge branch 'thermo-electro' of https://github.com/MultiSimOLab/Hype…
miguelmaso May 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/ComputationalModels/BoundaryConditions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@ end

getindex(bc::MultiFieldBC, i) = bc.BoundaryCondition[i]

include("EvolutionFunctions.jl")
include("CartesianTags.jl")
include("FaceLabeling.jl")


struct MultiFieldTC{A} <: TimedependentCondition
vh::A # could be a multifield or single field
Expand Down
5 changes: 5 additions & 0 deletions src/ComputationalModels/ComputationalModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ using GridapGmsh: GmshDiscreteModel

import Base.getindex

# Deprecation exports
using HyperFEM.DiscreteModeling
Base.@deprecate_binding CartesianTags DiscreteModeling.CartesianTags
Base.@deprecate_binding EvolutionFunctions DiscreteModeling.EvolutionFunctions

include("BoundaryConditions.jl")
export DirichletBC
export NeumannBC
Expand Down
14 changes: 0 additions & 14 deletions src/ComputationalModels/FaceLabeling.jl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,24 @@
"Shortcuts for the tags of cartesian discrete models."
module CartesianTags

export face0YZ, face1YZ, faceX0Z, faceX1Z, faceXY0, faceXY1

export edgeX00, edgeX10, edgeX01, edgeX11
export edge0Y0, edge1Y0, edge0Y1, edge1Y1
export edge00Z, edge10Z, edge01Z, edge11Z

export corner000, corner100, corner010, corner110
export corner001, corner101, corner011, corner111

export edgeX00⁺, edgeX10⁺, edgeX01⁺, edgeX11⁺
export edge0Y0⁺, edge1Y0⁺, edge0Y1⁺, edge1Y1⁺
export edge00Z⁺, edge10Z⁺, edge01Z⁺, edge11Z⁺

export face0YZ⁺, face1YZ⁺, faceX0Z⁺, faceX1Z⁺, faceXY0⁺, faceXY1⁺

# Deprecated tags
export faceX0, faceX1, faceY0, faceY1, faceZ0, faceZ1

# --- Face tags ---

"Tags indicating the face at plane X0."
Expand Down
20 changes: 20 additions & 0 deletions src/DiscreteModeling/DiscreteModeling.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

"""
A bundle of helper tools to work with discrete models in space/time.
"""
module DiscreteModeling

using Gridap

export CartesianTags
export EvolutionFunctions
export add_tag_from_vertex_filter!
export aspect_ratio
export element_size

include("CartesianTags.jl")
include("EvolutionFunctions.jl")
include("FaceLabeling.jl")
include("MeshDescriptor.jl")

end
28 changes: 28 additions & 0 deletions src/DiscreteModeling/FaceLabeling.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

"""
Create a new tag from a geometry and a coordinate-based filter function.
The filter function takes in vertex coordinates and returns a boolean values. A geometrical
entity is tagged if all its vertices pass the filter.

# See also
- `Gridap.Geometry.face_labeling_from_vertex_filter`
- `Gridap.Geometry.merge!`
"""
function add_tag_from_vertex_filter!(
labels::Gridap.Geometry.FaceLabeling,
tag::String,
geometry::Gridap.Geometry.DiscreteModel,
filter::Function)
new_labels = Gridap.Geometry.face_labeling_from_vertex_filter(geometry.grid_topology, tag, filter)
merge!(labels, new_labels)
end


function add_tag_from_vertex_filter!(
labels::Gridap.Geometry.FaceLabeling,
geometry::Gridap.Geometry.DiscreteModel,
tag::String,
filter::Function)
@warn "This method is deprecated. Call the function with: (labels, tag, geometry, filter)"
add_tag_from_vertex_filter!(labels, tag, geometry, filter)
end
88 changes: 88 additions & 0 deletions src/DiscreteModeling/MeshDescriptor.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@

"""
Return the aspect ratio of the underlying cartesian elements as a string.
This function is only available for an underlying `CartesianGrid`.

# Example
aspect_ratio(Ω) # "51:51:5"
aspect_ratio(Ω, tol=0.05) # "10:10:1"
aspect_ratio(uh⁺, tol=0.1) # "10:10:1"
"""
function aspect_ratio(grid::CartesianGrid; tol=1e-6)
descriptor = Gridap.Geometry.get_cartesian_descriptor(grid)
sizes = descriptor.sizes

rel = sizes ./ minimum(sizes)
best = nothing
best_error = Inf
best_complexity = Inf

for d in 0:20
candidate = round.(Int, rel .* d)
any(candidate .== 0) && continue
approx = candidate ./ d
err = maximum(abs.(approx .- rel) ./ rel)
if err < best_error
complexity = max(candidate...)
if complexity < best_complexity
best = candidate
best_error = err
best_complexity = complexity
end
end
end

if best_error > tol # exact fallback
denominators = denominator.(rationalize.(sizes))
least_mult = lcm(denominators...)
best = round.(Int, sizes .* least_mult)
end

join(best, ":")
end

function aspect_ratio(model::CartesianDiscreteModel; kwargs...)
aspect_ratio(get_grid(model); kwargs...)
end

function aspect_ratio(triangulation::Triangulation; kwargs...)
aspect_ratio(get_background_model(triangulation); kwargs...)
end

function aspect_ratio(f::CellField; kwargs...)
aspect_ratio(get_triangulation(f); kwargs...)
end


"""
Return the element size for a cartesian mesh.
This function is only available for an underlying `CartesianGrid`.

# Example
element_size(model) # Compute the diagonal
element_size(uh, :x) # Get the x-size of the underlying grid
"""
function element_size(grid::CartesianGrid)
descriptor = Gridap.Geometry.get_cartesian_descriptor(grid)
sizes = descriptor.sizes
sqrt(sum(abs2, sizes))
end

function element_size(grid::CartesianGrid, direction)
descriptor = Gridap.Geometry.get_cartesian_descriptor(grid)
direction_indices = Dict(:x => 1, :y => 2, :z => 3)
index = direction_indices[direction]
descriptor.sizes[index]
end

function element_size(model::CartesianDiscreteModel, args...)
element_size(get_grid(model), args...)
end

function element_size(triangulation::Triangulation, args...)
element_size(get_background_model(triangulation), args...)
end

function element_size(f::CellField, args...)
element_size(get_triangulation(f), args...)
end
14 changes: 10 additions & 4 deletions src/Exports.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ end
@publish TensorAlgebra Tensorize


@publish PhysicalModels DerivativeStrategy
@publish PhysicalModels LinearElasticity3D
@publish PhysicalModels LinearElasticity2D
@publish PhysicalModels Yeoh3D
Expand All @@ -45,10 +44,12 @@ end
@publish PhysicalModels NonlinearMooneyRivlin_CV
@publish PhysicalModels NonlinearIncompressibleMooneyRivlin2D_CV
@publish PhysicalModels EightChain
@publish PhysicalModels EightChain5Terms
@publish PhysicalModels TransverseIsotropy3D
@publish PhysicalModels TransverseIsotropy2D
@publish PhysicalModels ThermalModel
@publish PhysicalModels ThermalVolumetric
@publish PhysicalModels ThermalDeviatoric
@publish PhysicalModels IdealDielectric
@publish PhysicalModels Magnetic
@publish PhysicalModels IdealMagnetic
Expand All @@ -58,6 +59,7 @@ end
@publish PhysicalModels ElectroMechModel
@publish PhysicalModels ThermoElectroMechModel
@publish PhysicalModels ThermoMechModel
@publish PhysicalModels ThermoElectroModel
@publish PhysicalModels ThermoMech_Bonet
@publish PhysicalModels ThermoMech_EntropicPolyconvex
@publish PhysicalModels FlexoElectroModel
Expand Down Expand Up @@ -94,10 +96,11 @@ end
@publish PhysicalModels getIsoInvariants

@publish PhysicalModels ThermalLaw
@publish PhysicalModels ConstantEnergyLaw
@publish PhysicalModels ConstantCvLaw
@publish PhysicalModels EntropicElasticityLaw
@publish PhysicalModels NonlinearMeltingLaw
@publish PhysicalModels NonlinearSofteningLaw
@publish PhysicalModels TrigonometricLaw
@publish PhysicalModels PolynomialLaw

@publish PhysicalModels SecondPiola
Expand Down Expand Up @@ -152,8 +155,11 @@ end
@publish ComputationalModels TrialFESpace! # Exporting internal function of Gridap
@publish ComputationalModels L2_Projection

# Note: the files FaceLabeling, CartesianTags and Evolution functions should be moved to a module different than ComputationalModels
@publish ComputationalModels add_tag_from_vertex_filter!
@publish DiscreteModeling CartesianTags
@publish DiscreteModeling EvolutionFunctions
@publish DiscreteModeling add_tag_from_vertex_filter!
@publish DiscreteModeling aspect_ratio
@publish DiscreteModeling element_size

@publish Solvers IterativeSolver
@publish Solvers Newton_RaphsonSolver
Expand Down
2 changes: 1 addition & 1 deletion src/HyperFEM.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ include("TensorAlgebra/TensorAlgebra.jl")
include("PhysicalModels/PhysicalModels.jl")
include("WeakForms/WeakForms.jl")
include("Solvers/Solvers.jl")
include("DiscreteModeling/DiscreteModeling.jl")
include("ComputationalModels/ComputationalModels.jl")

include("Io.jl")
include("Exports.jl")

Expand Down
35 changes: 35 additions & 0 deletions src/PhysicalModels/ElectricalModels.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,38 @@ struct IdealDielectric <: Electro
new(ε)
end
end

function (obj::IdealDielectric)()
J(F) = det(F)
H(F) = det(F) * inv(F)'

# Energy #
HE(F, E) = H(F) * E
HEHE(F, E) = HE(F, E) ⋅ HE(F, E)
Ψem(F, E) = (-obj.ε / (2.0 * J(F))) * HEHE(F, E)

# First Derivatives #
∂Ψem_∂H(F, E) = (-obj.ε / (J(F))) * (HE(F, E) ⊗ E)
∂Ψem_∂J(F, E) = (+obj.ε / (2.0 * J(F)^2.0)) * HEHE(F, E)
∂Ψem_∂E(F, E) = (-obj.ε / (J(F))) * (H(F)' * HE(F, E))
∂Ψem∂F(F, E) = ∂Ψem_∂H(F, E) × F + ∂Ψem_∂J(F, E) * H(F)
∂Ψem∂E(F, E) = ∂Ψem_∂E(F, E)

# Second Derivatives #
∂Ψem_HH(F, E) = (-obj.ε / (J(F))) * (I3 ⊗₁₃²⁴ (E ⊗ E))
∂Ψem_HJ(F, E) = (+obj.ε / (J(F))^2.0) * (HE(F, E) ⊗ E)
∂Ψem_JJ(F, E) = (-obj.ε / (J(F))^3.0) * HEHE(F, E)
∂Ψem∂FF(F, E) = (F × (∂Ψem_HH(F, E) × F)) +
H(F) ⊗₁₂³⁴ (∂Ψem_HJ(F, E) × F) +
(∂Ψem_HJ(F, E) × F) ⊗₁₂³⁴ H(F) +
∂Ψem_JJ(F, E) * (H(F) ⊗₁₂³⁴ H(F)) +
×ᵢ⁴(∂Ψem_∂H(F, E) + ∂Ψem_∂J(F, E) * F)

∂Ψem_EH(F, E) = (-obj.ε / (J(F))) * ((I3 ⊗₁₃² HE(F, E)) + (H(F)' ⊗₁₂³ E))
∂Ψem_EJ(F, E) = (+obj.ε / (J(F))^2.0) * (H(F)' * HE(F, E))
∂Ψem∂EF(F, E) = (∂Ψem_EH(F, E) × F) + (∂Ψem_EJ(F, E) ⊗₁²³ H(F))

∂Ψem∂EE(F, E) = (-obj.ε / (J(F))) * (H(F)' * H(F))

return (Ψem, ∂Ψem∂F, ∂Ψem∂E, ∂Ψem∂FF, ∂Ψem∂EF, ∂Ψem∂EE)
end
Loading
Loading