Skip to content

Commit

Permalink
update for Julia 1.10; clean up method signatures; get rid of ftypes dep
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrKryslUCSD committed Oct 8, 2023
1 parent 5bfae5b commit c0c4892
Show file tree
Hide file tree
Showing 8 changed files with 247 additions and 211 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "FinEtools"
uuid = "91bb5406-6c9a-523d-811d-0644c4229550"
authors = ["Petr Krysl <[email protected]>"]
version = "7.0.5"
version = "7.1.0"

[deps]
ChunkSplitters = "ae650224-84b6-46f8-82ea-d812ca08434e"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ The package supports application packages, for instance:

## News

- 10/07/2023: Update for Julia 1.10.
- 06/19/2023: Introduce DataCache, generic linear and bilinear forms.
- 04/20/2023: Make all types in the library generic.
- 04/18/2023: Implemented resizing of assembly buffers. Makematrix! resets pointers.
Expand Down
3 changes: 3 additions & 0 deletions docs/issues-and-ideas.md
Original file line number Diff line number Diff line change
Expand Up @@ -1317,3 +1317,6 @@ end # module
of the finite element instead of its label?
Done. Also the quadrature point id.
-- The delegation mechanism needs to be described. 09/29/23
-- The finite element model machine documentation needs to be refreshed. 09/29/23
126 changes: 64 additions & 62 deletions src/FEMMBaseModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ function finite_elements(self::AbstractFEMM)
end

"""
associategeometry!(self::AbstractFEMM, geom::NodalField{FT}) where {FT}
associategeometry!(self::AbstractFEMM, geom::NodalField{GFT}) where {GFT}
Associate geometry field with the FEMM.
Expand All @@ -108,44 +108,44 @@ routine is not consistent with the one for which `associategeometry!()`
was called before, `associategeometry!()` needs to be called with
the new geometry field.
"""
function associategeometry!(self::AbstractFEMM, geom::NodalField{FT}) where {FT}
function associategeometry!(self::AbstractFEMM, geom::NodalField{GFT}) where {GFT}
return self # default is no-op
end

"""
inspectintegpoints(
self::FEMM,
geom::NodalField{FT},
geom::NodalField{GFT},
felist::AbstractVector{IT},
inspector::F,
idat,
quantity = :Cauchy;
context...,
) where {FEMM<:AbstractFEMM, FT, IT, F<:Function}
) where {FEMM<:AbstractFEMM, GFT, IT, F<:Function}
Inspect integration points.
"""
function inspectintegpoints(
self::FEMM,
geom::NodalField{FT},
geom::NodalField{GFT},
felist::AbstractVector{IT},
inspector::F,
idat,
quantity = :Cauchy;
context...,
) where {FEMM<:AbstractFEMM,FT,IT,F<:Function}
) where {FEMM<:AbstractFEMM, GFT, IT, F<:Function}
return idat # default is no-op
end

"""
integratefieldfunction(
self::AbstractFEMM,
geom::NodalField{FT},
geom::NodalField{GFT},
afield::FL,
fh::F;
initial::R,
m = -1,
) where {FT, FL<:NodalField{T}, T, F<:Function, R}
) where {GFT, T, FL<:NodalField{T}, F<:Function,R}
Integrate a nodal-field function over the discrete manifold.
Expand All @@ -161,12 +161,12 @@ Returns value of type `R`, which is initialized by `initial`.
"""
function integratefieldfunction(
self::AbstractFEMM,
geom::NodalField{FT},
geom::NodalField{GFT},
afield::FL,
fh::F;
initial::R,
m = -1,
) where {FT,T,FL<:NodalField{T},F<:Function,R}
) where {GFT, T, FL<:NodalField{T}, F<:Function,R}
fes = finite_elements(self)
if m < 0
m = manifdim(fes) # native manifold dimension
Expand All @@ -192,12 +192,12 @@ end
"""
integratefieldfunction(
self::AbstractFEMM,
geom::NodalField{FT},
geom::NodalField{GFT},
afield::FL,
fh::F;
initial::R = zero(FT),
m = -1,
) where {FT, T, FL<:ElementalField{T}, F<:Function, R}
) where {GFT, T, FL<:ElementalField{T}, F<:Function,R}
Integrate a elemental-field function over the discrete manifold.
Expand All @@ -212,12 +212,12 @@ Returns value of type `R`, which is initialized by `initial`.
"""
function integratefieldfunction(
self::AbstractFEMM,
geom::NodalField{FT},
geom::NodalField{GFT},
afield::FL,
fh::F;
initial::R = zero(FT),
m = -1,
) where {FT,T,FL<:ElementalField{T},F<:Function,R}
) where {GFT, T, FL<:ElementalField{T}, F<:Function,R}
fes = finite_elements(self)
if m < 0
m = manifdim(fes) # native manifold dimension
Expand All @@ -241,11 +241,11 @@ end
"""
integratefunction(
self::AbstractFEMM,
geom::NodalField{FT},
geom::NodalField{GFT},
fh::F;
initial::R = zero(FT),
initial::R = zero(typeof(fh(zeros(ndofs(geom), 1)))),
m = -1,
) where {FT, F<:Function, R<:Number}
) where {GFT<:Number, F<:Function, R<:Number}
Integrate a function over the discrete manifold.
Expand All @@ -261,10 +261,10 @@ measure the static moment with respect to the y- axis, and so on.
# Example:
Compute the volume of the mesh and then its center of gravity:
```
V = integratefunction(femm, geom, (x) -> 1.0)
Sx = integratefunction(femm, geom, (x) -> x[1])
Sy = integratefunction(femm, geom, (x) -> x[2])
Sz = integratefunction(femm, geom, (x) -> x[3])
V = integratefunction(femm, geom, (x) -> 1.0, 0.0)
Sx = integratefunction(femm, geom, (x) -> x[1], 0.0)
Sy = integratefunction(femm, geom, (x) -> x[2], 0.0)
Sz = integratefunction(femm, geom, (x) -> x[3], 0.0)
CG = vec([Sx Sy Sz]/V)
```
Compute a moment of inertia of the mesh relative to the origin:
Expand All @@ -274,11 +274,11 @@ Ixx = integratefunction(femm, geom, (x) -> x[2]^2 + x[3]^2)
"""
function integratefunction(
self::AbstractFEMM,
geom::NodalField{FT},
geom::NodalField{GFT},
fh::F;
initial::R = zero(FT),
initial::R = zero(typeof(fh(zeros(ndofs(geom), 1)))),
m = -1,
) where {FT, F<:Function, R<:Number}
) where {GFT<:Number, F<:Function, R<:Number}
fes = finite_elements(self)
if m < 0
m = manifdim(fes) # native manifold dimension
Expand Down Expand Up @@ -620,13 +620,13 @@ end
"""
fieldfromintegpoints(
self::FEMM,
geom::NodalField{FT},
u::NodalField{T},
dT::NodalField{FT},
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
quantity::Symbol,
component::FIntVec;
component::AbstractVector{IT};
context...,
) where {FEMM<:AbstractFEMM, FT<:Number, T<:Number}
) where {FEMM<:AbstractFEMM, GFT<:Number, UFT<:Number, TFT<:Number, IT<:Integer}
Construct nodal field from integration points.
Expand All @@ -648,17 +648,18 @@ Keyword arguments
"""
function fieldfromintegpoints(
self::FEMM,
geom::NodalField{FT},
u::NodalField{T},
dT::NodalField{FT},
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
quantity::Symbol,
component::AbstractVector{IT};
context...,
) where {FEMM<:AbstractFEMM,FT<:Number,T<:Number,IT<:Integer}
) where {FEMM<:AbstractFEMM, GFT<:Number, UFT<:Number, TFT<:Number, IT<:Integer}
fes = finite_elements(self)
# Constants
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
FT = typeof(zero(GFT) + zero(UFT) + zero(TFT))
nodevalmethod = :invdistance
reportat = :default
for apair in pairs(context)
Expand Down Expand Up @@ -738,36 +739,36 @@ end

function fieldfromintegpoints(
self::FEMM,
geom::NodalField{FT},
u::NodalField{T},
dT::NodalField{FT},
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
quantity::Symbol,
component::IT;
context...,
) where {FEMM<:AbstractFEMM,FT<:Number,T<:Number,IT<:Integer}
) where {FEMM<:AbstractFEMM, GFT<:Number, UFT<:Number, TFT<:Number, IT<:Integer}
return fieldfromintegpoints(self, geom, u, dT, quantity, [component]; context...)
end

function fieldfromintegpoints(
self::FEMM,
geom::NodalField{FT},
u::NodalField{T},
geom::NodalField{GFT},
u::NodalField{UFT},
quantity::Symbol,
component::AbstractVector{IT};
context...,
) where {FEMM<:AbstractFEMM,FT<:Number,T<:Number,IT<:Integer}
) where {FEMM<:AbstractFEMM, GFT<:Number, UFT<:Number, IT<:Integer}
dT = NodalField(zeros(FT, nnodes(geom), 1)) # zero difference in temperature
return fieldfromintegpoints(self, geom, u, dT, quantity, component; context...)
end

function fieldfromintegpoints(
self::FEMM,
geom::NodalField{FT},
u::NodalField{T},
geom::NodalField{GFT},
u::NodalField{UFT},
quantity::Symbol,
component::IT;
context...,
) where {FEMM<:AbstractFEMM,FT<:Number,T<:Number,IT<:Integer}
) where {FEMM<:AbstractFEMM, GFT<:Number, UFT<:Number, IT<:Integer}
dT = NodalField(zeros(FT, nnodes(geom), 1)) # zero difference in temperature
return fieldfromintegpoints(self, geom, u, dT, quantity, [component]; context...)
end
Expand All @@ -781,13 +782,13 @@ end
"""
elemfieldfromintegpoints(
self::FEMM,
geom::NodalField{FT},
u::NodalField{T},
dT::NodalField{FT},
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
quantity::Symbol,
component::FIntVec;
component::AbstractVector{IT};
context...,
) where {FEMM<:AbstractFEMM, FT<:Number, T<:Number}
) where {FEMM<:AbstractFEMM, GFT<:Number, UFT<:Number, TFT<:Number, IT<:Integer}
Construct elemental field from integration points.
Expand All @@ -805,17 +806,18 @@ Construct elemental field from integration points.
"""
function elemfieldfromintegpoints(
self::FEMM,
geom::NodalField{FT},
u::NodalField{T},
dT::NodalField{FT},
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
quantity::Symbol,
component::AbstractVector{IT};
context...,
) where {FEMM<:AbstractFEMM,FT<:Number,T<:Number,IT<:Integer}
) where {FEMM<:AbstractFEMM, GFT<:Number, UFT<:Number, TFT<:Number, IT<:Integer}
fes = finite_elements(self)
# Constants
nne = nodesperelem(fes) # number of nodes for element
sdim = ndofs(geom) # number of space dimensions
FT = typeof(zero(GFT) + zero(UFT) + zero(TFT))
# Container of intermediate results
idat = MeanValueInspectorData(
zeros(IT, count(fes)),
Expand Down Expand Up @@ -859,36 +861,36 @@ end

function elemfieldfromintegpoints(
self::FEMM,
geom::NodalField{FT},
u::NodalField{T},
dT::NodalField{FT},
geom::NodalField{GFT},
u::NodalField{UFT},
dT::NodalField{TFT},
quantity::Symbol,
component::IT;
context...,
) where {FEMM<:AbstractFEMM,FT<:Number,T<:Number,IT<:Integer}
) where {FEMM<:AbstractFEMM, GFT<:Number, UFT<:Number, TFT<:Number, IT<:Integer}
return elemfieldfromintegpoints(self, geom, u, dT, quantity, [component]; context...)
end

function elemfieldfromintegpoints(
self::FEMM,
geom::NodalField{FT},
u::NodalField{T},
geom::NodalField{GFT},
u::NodalField{UFT},
quantity::Symbol,
component::IT;
context...,
) where {FEMM<:AbstractFEMM,FT<:Number,T<:Number,IT<:Integer}
) where {FEMM<:AbstractFEMM, GFT<:Number, UFT<:Number, IT<:Integer}
dT = NodalField(zeros(FT, nnodes(geom), 1)) # zero difference in temperature
return elemfieldfromintegpoints(self, geom, u, dT, quantity, [component]; context...)
end

function elemfieldfromintegpoints(
self::FEMM,
geom::NodalField{FT},
u::NodalField{T},
geom::NodalField{GFT},
u::NodalField{UFT},
quantity::Symbol,
component::AbstractVector{IT};
context...,
) where {FEMM<:AbstractFEMM,FT<:Number,T<:Number,IT<:Integer}
) where {FEMM<:AbstractFEMM, GFT<:Number, UFT<:Number, IT<:Integer}
dT = NodalField(zeros(FT, nnodes(geom), 1)) # zero difference in temperature
return elemfieldfromintegpoints(self, geom, u, dT, quantity, component; context...)
end
Expand Down
4 changes: 0 additions & 4 deletions src/FinEtools.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,6 @@ include("allmodules.jl")
###########################################################################
# General facilities
###########################################################################
using .FTypesModule:
FInt, FFlt, FCplxFlt, FFltVec, FIntVec, FFltMat, FIntMat, FMat, FVec, FDataDict
# Exported: basic numerical types, type of data dictionary
export FInt, FFlt, FCplxFlt, FFltVec, FIntVec, FFltMat, FIntMat, FMat, FVec, FDataDict

using .DataCacheModule: DataCache
# Exported: vector-cache type and methods to invoke the update callback
Expand Down
Loading

2 comments on commit c0c4892

@PetrKryslUCSD
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/93017

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v7.1.0 -m "<description of version>" c0c48920e9fbd67c330c3596974e8f8252db7722
git push origin v7.1.0

Please sign in to comment.