Skip to content

Commit

Permalink
abbreviate the types
Browse files Browse the repository at this point in the history
  • Loading branch information
PetrKryslUCSD committed Oct 7, 2023
1 parent fc339df commit 494a0ce
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 62 deletions.
14 changes: 7 additions & 7 deletions src/AlgoHeatDiffModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function steadystate(modeldata::FDataDict)
# Construct the temperature field
temp = NodalField(zeros(size(fens.xyz,1),1))

FloatT = eltype(temp.values)
FT = eltype(temp.values)

# Apply the essential boundary conditions on the temperature field
essential_bcs = get(modeldata, "essential_bcs", nothing);
Expand All @@ -93,7 +93,7 @@ function steadystate(modeldata::FDataDict)
dcheck!(ebc, essential_bcs_recognized_keys)
fenids = get(()->error("Must get node list!"), ebc, "node_list");
temperature = get(ebc, "temperature", nothing);
T_fixed = zeros(FloatT,length(fenids)); # default is zero temperature
T_fixed = zeros(FT,length(fenids)); # default is zero temperature
if (temperature != nothing) # if it is nonzero,
if (typeof(temperature) <: Function) # it could be a function
for k = 1:length(fenids)
Expand All @@ -112,7 +112,7 @@ function steadystate(modeldata::FDataDict)
numberdofs!(temp) #,Renumbering_options); # NOT DONE

# Initialize the heat loads vector
F = zeros(FloatT, nalldofs(temp));
F = zeros(FT, nalldofs(temp));

# Construct the system conductivity matrix
K = spzeros(nalldofs(temp), nalldofs(temp)); # (all zeros, for the moment)
Expand All @@ -125,7 +125,7 @@ function steadystate(modeldata::FDataDict)
K = K + conductivity(femm, geom, temp);
Q = get(region, "Q", [0.0]);
if (typeof(Q) <: Function)
fi = ForceIntensity(FloatT, 1, Q);
fi = ForceIntensity(FT, 1, Q);
else
fi = ForceIntensity(Q);
end
Expand All @@ -143,7 +143,7 @@ function steadystate(modeldata::FDataDict)
# Apply the prescribed ambient temperature
fenids = connectednodes(femm.integdomain.fes);
fixed = ones(length(fenids));
T_fixed = zeros(FloatT, length(fenids)); # default is zero
T_fixed = zeros(FT, length(fenids)); # default is zero
ambient_temperature = get(convbc, "ambient_temperature", nothing);
if ambient_temperature != nothing # if given as nonzero
if (typeof(ambient_temperature) <: Function) # given by function
Expand All @@ -170,11 +170,11 @@ function steadystate(modeldata::FDataDict)
dcheck!(fluxbc, flux_bcs_recognized_keys)
normal_flux = fluxbc["normal_flux"];
if (typeof(normal_flux) <: Function)
fi = ForceIntensity(FloatT, 1, normal_flux);
fi = ForceIntensity(FT, 1, normal_flux);
else
if typeof(normal_flux) <: AbstractArray
else
normal_flux = FloatT[normal_flux]
normal_flux = FT[normal_flux]
end
fi = ForceIntensity(normal_flux);
end
Expand Down
54 changes: 27 additions & 27 deletions src/FEMMHeatDiffModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function FEMMHeatDiff(integdomain::IntegDomain{S, F}, material::M) where {S<:Abs
return FEMMHeatDiff(integdomain, CSys(manifdim(integdomain.fes)), material)
end

function _buffers1(self::FEMMHeatDiff, geom::NodalField{GFloatT}, temp::NodalField{FloatT}) where {GFloatT, FloatT}
function _buffers1(self::FEMMHeatDiff, geom::NodalField{GFT}, temp::NodalField{FT}) where {GFT, FT}
# Constants
fes = self.integdomain.fes
IntT = eltype(temp.dofnums)
Expand All @@ -53,22 +53,22 @@ function _buffers1(self::FEMMHeatDiff, geom::NodalField{GFloatT}, temp::NodalFi
sdim = ndofs(geom); # number of space dimensions
mdim = manifdim(fes); # manifold dimension of the element
Kedim = ndn*nne; # dimension of the element matrix
ecoords = fill(zero(FloatT), nne, ndofs(geom)); # array of Element coordinates
elmat = fill(zero(FloatT), Kedim, Kedim); # buffer
elvec = fill(zero(FloatT), Kedim); # buffer
elvecfix = fill(zero(FloatT), Kedim); # buffer
ecoords = fill(zero(FT), nne, ndofs(geom)); # array of Element coordinates
elmat = fill(zero(FT), Kedim, Kedim); # buffer
elvec = fill(zero(FT), Kedim); # buffer
elvecfix = fill(zero(FT), Kedim); # buffer
dofnums = fill(zero(IntT), Kedim); # buffer
loc = fill(zero(FloatT), 1, sdim); # buffer
J = fill(zero(FloatT), sdim, mdim); # buffer
RmTJ = fill(zero(FloatT), mdim, mdim); # buffer
gradN = fill(zero(FloatT), nne, mdim); # buffer
kappa_bar = fill(zero(FloatT), mdim, mdim); # buffer
kappa_bargradNT = fill(zero(FloatT), mdim, nne); # buffer
loc = fill(zero(FT), 1, sdim); # buffer
J = fill(zero(FT), sdim, mdim); # buffer
RmTJ = fill(zero(FT), mdim, mdim); # buffer
gradN = fill(zero(FT), nne, mdim); # buffer
kappa_bar = fill(zero(FT), mdim, mdim); # buffer
kappa_bargradNT = fill(zero(FT), mdim, nne); # buffer
return ecoords, dofnums, loc, J, RmTJ, gradN, kappa_bar, kappa_bargradNT, elmat, elvec, elvecfix
end

"""
conductivity(self::FEMMHeatDiff, assembler::A, geom::NodalField{GFloatT}, temp::NodalField{FloatT}) where {A<:AbstractSysmatAssembler, GFloatT, FloatT}
conductivity(self::FEMMHeatDiff, assembler::A, geom::NodalField{GFT}, temp::NodalField{FT}) where {A<:AbstractSysmatAssembler, GFT, FT}
Compute the conductivity matrix.
Expand All @@ -78,20 +78,20 @@ Compute the conductivity matrix.
- `geom` = geometry field,
- `temp` = temperature field
"""
function conductivity(self::FEMMHeatDiff, assembler::A, geom::NodalField{GFloatT}, temp::NodalField{FloatT}) where {A<:AbstractSysmatAssembler, GFloatT, FloatT}
function conductivity(self::FEMMHeatDiff, assembler::A, geom::NodalField{GFT}, temp::NodalField{FT}) where {A<:AbstractSysmatAssembler, GFT, FT}
mdim = manifdim(finite_elements(self))
kappa_bar = fill(zero(FloatT), mdim, mdim); # buffer
kappa_bar = fill(zero(FT), mdim, mdim); # buffer
kappa_bar = tangentmoduli!(self.material, kappa_bar)
return bilform_diffusion(self, assembler, geom, temp, DataCache(kappa_bar));
end

function conductivity(self::FEMMHeatDiff, geom::NodalField{GFloatT}, temp::NodalField{FloatT}) where {GFloatT, FloatT}
function conductivity(self::FEMMHeatDiff, geom::NodalField{GFT}, temp::NodalField{FT}) where {GFT, FT}
assembler = SysmatAssemblerSparseSymm();
return conductivity(self, assembler, geom, temp);
end

"""
energy(self::FEMMHeatDiff, geom::NodalField{GFloatT}, temp::NodalField{FloatT}) where {GFloatT, FloatT}
energy(self::FEMMHeatDiff, geom::NodalField{GFT}, temp::NodalField{FT}) where {GFT, FT}
Compute the "energy" integral over the interior domain.
Expand All @@ -103,7 +103,7 @@ and the heat flux.
- `geom` = geometry field,
- `temp` = temperature field
"""
function energy(self::FEMMHeatDiff, geom::NodalField{GFloatT}, temp::NodalField{FloatT}) where {GFloatT, FloatT}
function energy(self::FEMMHeatDiff, geom::NodalField{GFT}, temp::NodalField{FT}) where {GFT, FT}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain);
# Prepare assembler and buffers
Expand Down Expand Up @@ -132,7 +132,7 @@ function energy(self::FEMMHeatDiff, geom::NodalField{GFloatT}, temp::NodalField
end

"""
inspectintegpoints(self::FEMMHeatDiff, geom::NodalField{GFloatT}, u::NodalField{T}, temp::NodalField{FloatT}, felist::VecOrMat{IntT}, inspector::F, idat, quantity=:heatflux; context...) where {T<:Number, GFloatT, FloatT, IntT, F<:Function}
inspectintegpoints(self::FEMMHeatDiff, geom::NodalField{GFT}, u::NodalField{T}, temp::NodalField{FT}, felist::VecOrMat{IntT}, inspector::F, idat, quantity=:heatflux; context...) where {T<:Number, GFT, FT, IntT, F<:Function}
Inspect integration point quantities.
Expand All @@ -154,7 +154,7 @@ Inspect integration point quantities.
# Output
The updated inspector data is returned.
"""
function inspectintegpoints(self::FEMMHeatDiff, geom::NodalField{GFloatT}, u::NodalField{T}, temp::NodalField{FloatT}, felist::VecOrMat{IntT}, inspector::F, idat, quantity=:heatflux; context...) where {T<:Number, GFloatT, FloatT, IntT, F<:Function}
function inspectintegpoints(self::FEMMHeatDiff, geom::NodalField{GFT}, u::NodalField{T}, temp::NodalField{FT}, felist::VecOrMat{IntT}, inspector::F, idat, quantity=:heatflux; context...) where {T<:Number, GFT, FT, IntT, F<:Function}
fes = self.integdomain.fes
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain);
ecoords, dofnums, loc, J, RmTJ, gradN, kappa_bar, kappa_bargradNT, elmat, elvec, elvecfix = _buffers1(self, geom, temp)
Expand All @@ -170,13 +170,13 @@ function inspectintegpoints(self::FEMMHeatDiff, geom::NodalField{GFloatT}, u::No
end
t= 0.0
dt = 0.0
Te = fill(zero(FloatT), nodesperelem(fes)) # nodal temperatures -- buffer
Te = fill(zero(FT), nodesperelem(fes)) # nodal temperatures -- buffer
nne = nodesperelem(fes); # number of nodes for element
sdim = ndofs(geom); # number of space dimensions
qpgradT = fill(zero(FloatT), 1, sdim); # Temperature gradient -- buffer
qpflux = fill(zero(FloatT), sdim); # thermal strain -- buffer
out1 = fill(zero(FloatT), sdim); # output -- buffer
out = fill(zero(FloatT), sdim);# output -- buffer
qpgradT = fill(zero(FT), 1, sdim); # Temperature gradient -- buffer
qpflux = fill(zero(FT), sdim); # thermal strain -- buffer
out1 = fill(zero(FT), sdim); # output -- buffer
out = fill(zero(FT), sdim);# output -- buffer
# Loop over all the elements and all the quadrature points within them
for ilist in 1:length(felist) # Loop over elements
i = felist[ilist];
Expand All @@ -203,7 +203,7 @@ function inspectintegpoints(self::FEMMHeatDiff, geom::NodalField{GFloatT}, u::No
end

"""
capacity(self::FEMMHeatDiff, assembler::A, geom::NodalField{GFloatT}, temp::NodalField{FloatT}) where {A<:AbstractSysmatAssembler, GFloatT, FloatT}
capacity(self::FEMMHeatDiff, assembler::A, geom::NodalField{GFT}, temp::NodalField{FT}) where {A<:AbstractSysmatAssembler, GFT, FT}
Compute the capacity matrix.
Expand All @@ -213,11 +213,11 @@ Compute the capacity matrix.
- `geom` = geometry field,
- `temp` = temperature field
"""
function capacity(self::FEMMHeatDiff, assembler::A, geom::NodalField{GFloatT}, temp::NodalField{FloatT}) where {A<:AbstractSysmatAssembler, GFloatT, FloatT}
function capacity(self::FEMMHeatDiff, assembler::A, geom::NodalField{GFT}, temp::NodalField{FT}) where {A<:AbstractSysmatAssembler, GFT, FT}
return bilform_dot(self, assembler, geom, temp, DataCache(self.material.specific_heat))
end

function capacity(self::FEMMHeatDiff, geom::NodalField{GFloatT}, temp::NodalField{FloatT}) where {GFloatT, FloatT}
function capacity(self::FEMMHeatDiff, geom::NodalField{GFT}, temp::NodalField{FT}) where {GFT, FT}
assembler = SysmatAssemblerSparseSymm();
return capacity(self, assembler, geom, temp);
end
Expand Down
26 changes: 13 additions & 13 deletions src/FEMMHeatDiffSurfModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ using FinEtools.DataCacheModule: DataCache
Type for heat diffusion finite element modeling machine for boundary integrals.
"""
mutable struct FEMMHeatDiffSurf{ID<:IntegDomain, FloatT} <: AbstractFEMM
mutable struct FEMMHeatDiffSurf{ID<:IntegDomain, FT} <: AbstractFEMM
integdomain::ID # geometry data
surfacetransfercoeff::FloatT # material object
surfacetransfercoeff::FT # material object
end

function FEMMHeatDiffSurf(integdomain::ID) where {ID<:IntegDomain}
return FEMMHeatDiffSurf(integdomain, 0.0)
end

"""
surfacetransfer(self::FEMMHeatDiffSurf, assembler::A, geom::NodalField{GFloatT}, temp::NodalField{FloatT}) where {A<:AbstractSysmatAssembler, GFloatT, FloatT}
surfacetransfer(self::FEMMHeatDiffSurf, assembler::A, geom::NodalField{GFT}, temp::NodalField{FT}) where {A<:AbstractSysmatAssembler, GFT, FT}
Compute the surface heat transfer matrix.
Expand All @@ -43,17 +43,17 @@ Compute the surface heat transfer matrix.
- `geom` = geometry field,
- `temp` = temperature field
"""
function surfacetransfer(self::FEMMHeatDiffSurf, assembler::A, geom::NodalField{GFloatT}, temp::NodalField{FloatT}) where {A<:AbstractSysmatAssembler, GFloatT, FloatT}
function surfacetransfer(self::FEMMHeatDiffSurf, assembler::A, geom::NodalField{GFT}, temp::NodalField{FT}) where {A<:AbstractSysmatAssembler, GFT, FT}
return bilform_dot(self, assembler, geom, temp, DataCache(self.surfacetransfercoeff); m = 2); # two dimensional, surface, domain
end

function surfacetransfer(self::FEMMHeatDiffSurf, geom::NodalField{GFloatT}, temp::NodalField{FloatT}) where {GFloatT, FloatT}
function surfacetransfer(self::FEMMHeatDiffSurf, geom::NodalField{GFT}, temp::NodalField{FT}) where {GFT, FT}
assembler = SysmatAssemblerSparseSymm()
return surfacetransfer(self, assembler, geom, temp);
end

"""
surfacetransferloads(self::FEMMHeatDiffSurf, assembler::A, geom::NodalField{GFloatT}, temp::NodalField{FloatT}, ambtemp::NodalField{FloatT}) where {A<:AbstractSysvecAssembler, GFloatT, FloatT}
surfacetransferloads(self::FEMMHeatDiffSurf, assembler::A, geom::NodalField{GFT}, temp::NodalField{FT}, ambtemp::NodalField{FT}) where {A<:AbstractSysvecAssembler, GFT, FT}
Compute the load vector corresponding to surface heat transfer.
Expand All @@ -64,7 +64,7 @@ Compute the load vector corresponding to surface heat transfer.
- `temp` = temperature field
- `ambtemp` = ambient temperature field on the surface
"""
function surfacetransferloads(self::FEMMHeatDiffSurf, assembler::A, geom::NodalField{GFloatT}, temp::NodalField{FloatT}, ambtemp::NodalField{FloatT}) where {A<:AbstractSysvecAssembler, GFloatT, FloatT}
function surfacetransferloads(self::FEMMHeatDiffSurf, assembler::A, geom::NodalField{GFT}, temp::NodalField{FT}, ambtemp::NodalField{FT}) where {A<:AbstractSysvecAssembler, GFT, FT}
fes = self.integdomain.fes
# Constants
nfes = count(fes); # number of finite elements in the set
Expand All @@ -76,12 +76,12 @@ function surfacetransferloads(self::FEMMHeatDiffSurf, assembler::A, geom::Noda
# Precompute basis f. values + basis f. gradients wrt parametric coor
npts, Ns, gradNparams, w, pc = integrationdata(self.integdomain);
# Prepare assembler and temporaries
ecoords = fill(zero(FloatT), nne, ndofs(geom)); # array of Element coordinates
Fe = fill(zero(FloatT), Hedim, 1); # element matrix -- used as a buffer
ecoords = fill(zero(FT), nne, ndofs(geom)); # array of Element coordinates
Fe = fill(zero(FT), Hedim, 1); # element matrix -- used as a buffer
dofnums = zeros(eltype(temp.dofnums), Hedim); # degree of freedom array -- used as a buffer
loc = fill(zero(FloatT), 1, sdim); # quadrature point location -- used as a buffer
J = fill(zero(FloatT), sdim, mdim); # Jacobian matrix -- used as a buffer
pT = fill(zero(FloatT), Hedim);
loc = fill(zero(FT), 1, sdim); # quadrature point location -- used as a buffer
J = fill(zero(FT), sdim, mdim); # Jacobian matrix -- used as a buffer
pT = fill(zero(FT), Hedim);
startassembly!(assembler, nalldofs(temp));
for i in 1:count(fes) # Loop over elements
gathervalues_asvec!(ambtemp, pT, fes.conn[i]);# retrieve ambient temp
Expand All @@ -103,7 +103,7 @@ function surfacetransferloads(self::FEMMHeatDiffSurf, assembler::A, geom::Noda
return F
end

function surfacetransferloads(self::FEMMHeatDiffSurf, geom::NodalField{GFloatT}, temp::NodalField{FloatT}, ambtemp::NodalField{FloatT}) where {GFloatT, FloatT}
function surfacetransferloads(self::FEMMHeatDiffSurf, geom::NodalField{GFT}, temp::NodalField{FT}, ambtemp::NodalField{FT}) where {GFT, FT}
assembler = SysvecAssembler()
return surfacetransferloads(self, assembler, geom, temp, ambtemp);
end
Expand Down
30 changes: 15 additions & 15 deletions src/MatHeatDiffModule.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,55 @@ import FinEtools.MatModule: AbstractMat
using FinEtools.MatrixUtilityModule: mulCAB!

"""
MatHeatDiff{FloatT, MTAN<:Function, MUPD<:Function} <: AbstractMat
MatHeatDiff{FT, MTAN<:Function, MUPD<:Function} <: AbstractMat
Type of material model for heat diffusion.
"""
struct MatHeatDiff{FloatT, MTAN<:Function, MUPD<:Function} <: AbstractMat
thermal_conductivity::Array{FloatT, 2};# Thermal conductivity
specific_heat::FloatT;# Specific heat per unit volume
mass_density::FloatT # mass density
struct MatHeatDiff{FT, MTAN<:Function, MUPD<:Function} <: AbstractMat
thermal_conductivity::Array{FT, 2};# Thermal conductivity
specific_heat::FT;# Specific heat per unit volume
mass_density::FT # mass density
tangentmoduli!::MTAN
update!::MUPD
end

"""
MatHeatDiff(thermal_conductivity::Matrix{FloatT}) where {FloatT}
MatHeatDiff(thermal_conductivity::Matrix{FT}) where {FT}
Construct material model for heat diffusion.
Supply the matrix of thermal conductivity constants.
"""
function MatHeatDiff(thermal_conductivity::Matrix{FloatT}) where {FloatT}
return MatHeatDiff(thermal_conductivity, zero(FloatT), zero(FloatT), tangentmoduli!, update!)
function MatHeatDiff(thermal_conductivity::Matrix{FT}) where {FT}
return MatHeatDiff(thermal_conductivity, zero(FT), zero(FT), tangentmoduli!, update!)
end

"""
MatHeatDiff(thermal_conductivity::Matrix{FloatT}, specific_heat::FloatT) where {FloatT}
MatHeatDiff(thermal_conductivity::Matrix{FT}, specific_heat::FT) where {FT}
Construct material model for heat diffusion.
Supply the matrix of thermal conductivity constants.
"""
function MatHeatDiff(thermal_conductivity::Matrix{FloatT}, specific_heat::FloatT) where {FloatT}
return MatHeatDiff(thermal_conductivity, specific_heat, zero(FloatT), tangentmoduli!, update!)
function MatHeatDiff(thermal_conductivity::Matrix{FT}, specific_heat::FT) where {FT}
return MatHeatDiff(thermal_conductivity, specific_heat, zero(FT), tangentmoduli!, update!)
end

"""
tangentmoduli!(self::MatHeatDiff, kappabar::Matrix{FloatT}, t = zero(FloatT), dt = zero(FloatT), loc::Matrix{FloatT} = reshape(FloatT[],0,0), label = 0) where {FloatT}
tangentmoduli!(self::MatHeatDiff, kappabar::Matrix{FT}, t = zero(FT), dt = zero(FT), loc::Matrix{FT} = reshape(FT[],0,0), label = 0) where {FT}
Calculate the thermal conductivity matrix.
- `kappabar` = matrix of thermal conductivity (tangent moduli) in material
coordinate system, supplied as a buffer and overwritten.
"""
function tangentmoduli!(self::MatHeatDiff, kappabar::Matrix{FloatT}, t = zero(FloatT), dt = zero(FloatT), loc::Matrix{FloatT} = reshape(FloatT[],0,0), label = 0) where {FloatT}
function tangentmoduli!(self::MatHeatDiff, kappabar::Matrix{FT}, t = zero(FT), dt = zero(FT), loc::Matrix{FT} = reshape(FT[],0,0), label = 0) where {FT}
copyto!(kappabar, self.thermal_conductivity);
return kappabar
end

"""
update!(self::MatHeatDiff, heatflux::Vector{FloatT}, output::Vector{FloatT}, gradT::Vector{FloatT}, t= zero(FloatT), dt= zero(FloatT), loc::Matrix{FloatT}=reshape(FloatT[],0,0), label=0, quantity=:nothing) where {FloatT}
update!(self::MatHeatDiff, heatflux::Vector{FT}, output::Vector{FT}, gradT::Vector{FT}, t= zero(FT), dt= zero(FT), loc::Matrix{FT}=reshape(FT[],0,0), label=0, quantity=:nothing) where {FT}
Update material state.
Expand All @@ -75,7 +75,7 @@ Update material state.
calculated and stored in the `heatflux` vector.
- `output` = array which is (if necessary) allocated in an appropriate size, filled with the output quantity, and returned.
"""
function update!(self::MatHeatDiff, heatflux::Vector{FloatT}, output::Vector{FloatT}, gradT::Vector{FloatT}, t= zero(FloatT), dt= zero(FloatT), loc::Matrix{FloatT}=reshape(FloatT[],0,0), label=0, quantity=:nothing) where {FloatT}
function update!(self::MatHeatDiff, heatflux::Vector{FT}, output::Vector{FT}, gradT::Vector{FT}, t= zero(FT), dt= zero(FT), loc::Matrix{FT}=reshape(FT[],0,0), label=0, quantity=:nothing) where {FT}
sdim = size(self.thermal_conductivity, 2)
@assert length(heatflux) == sdim
mulCAB!(heatflux, self.thermal_conductivity, -gradT);
Expand Down

0 comments on commit 494a0ce

Please sign in to comment.