Skip to content

Commit 7b4883b

Browse files
Merge pull request #69 from PetrKryslUCSD/develop
Develop
2 parents de92d36 + 4fa5d10 commit 7b4883b

File tree

5 files changed

+103
-61
lines changed

5 files changed

+103
-61
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "FinEtools"
22
uuid = "91bb5406-6c9a-523d-811d-0644c4229550"
33
authors = ["Petr Krysl <pkrysl@ucsd.edu>"]
4-
version = "8.0.27"
4+
version = "8.0.28"
55

66
[deps]
77
DataDrop = "aa547a04-dd37-49ab-8e73-656744f8a8fc"

src/CSysModule.jl

Lines changed: 45 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ struct CSys{T<:Number,F<:Function}
2222
__updatebuffer!::F # function to update the coordinate system matrix.
2323
# Signature: `update!(csmatout::Matrix{T}, XYZ::VecOrMat{T}, tangents::Matrix{T},
2424
# feid::IT, qpid::IT) where {T, IT}`
25-
_csmat::Array{T,2} # the coordinate system matrix (buffer); see
25+
_csmat::Matrix{T} # the coordinate system matrix (buffer); see
2626
end
2727

2828
"""
@@ -33,8 +33,13 @@ rotation matrix is given.
3333
3434
The function signature:
3535
```
36-
update!(csmatout::Matrix{T}, XYZ::VecOrMat{T}, tangents::Matrix{T},
37-
feid::IT, qpid::IT) where {T, IT}
36+
update!(
37+
csmatout::AbstractMatrix{<:Real},
38+
XYZ::AbstractVecOrMat{<:Real},
39+
tangents::AbstractMatrix{<:Real},
40+
feid::Integer,
41+
qpid::Integer,
42+
)
3843
```
3944
where
4045
- `csmatout`= output matrix buffer, of size `(sdim, mdim)`
@@ -76,8 +81,13 @@ rotation matrix of type `T` is given.
7681
- `z` = zero value,
7782
- The `computecsmat` function signature:
7883
```
79-
update!(csmatout::Matrix{T}, XYZ::VecOrMat{T}, tangents::Matrix{T},
80-
feid::IT, qpid::IT) where {T, IT}
84+
update!(
85+
csmatout::AbstractMatrix{<:Real},
86+
XYZ::AbstractVecOrMat{<:Real},
87+
tangents::AbstractMatrix{<:Real},
88+
feid::Integer,
89+
qpid::Integer,
90+
)
8191
```
8292
where
8393
- `csmatout`= output matrix buffer, of size `(sdim, mdim)`;
@@ -122,12 +132,12 @@ Construct coordinate system when the rotation matrix is given.
122132
"""
123133
function CSys(csmat::Matrix{T}) where {T}
124134
function __updatebuffer!(
125-
csmatout::Matrix{T},
126-
XYZ::VecOrMat{T},
127-
tangents::Matrix{T},
128-
feid::IT1,
129-
qpid::IT2,
130-
) where {T,IT1,IT2}
135+
csmatout::AbstractMatrix{<:Real},
136+
XYZ::AbstractVecOrMat{<:Real},
137+
tangents::AbstractMatrix{<:Real},
138+
feid::Integer,
139+
qpid::Integer,
140+
)
131141
return csmatout # nothing to be done here, the matrix is already in the buffer
132142
end
133143
return CSys(true, false, __updatebuffer!, deepcopy(csmat))# fill the buffer with the given matrix
@@ -143,12 +153,12 @@ identity.
143153
"""
144154
function CSys(dim::IT, z::T) where {IT<:Integer,T}
145155
function __updatebuffer!(
146-
csmatout::Matrix{T},
147-
XYZ::VecOrMat{T},
148-
tangents::Matrix{T},
149-
feid::IT1,
150-
qpid::IT2,
151-
) where {T,IT1,IT2}
156+
csmatout::AbstractMatrix{<:Real},
157+
XYZ::AbstractVecOrMat{<:Real},
158+
tangents::AbstractMatrix{<:Real},
159+
feid::Integer,
160+
qpid::Integer,
161+
)
152162
return csmatout # nothing to be done here, the matrix is already in the buffer
153163
end
154164
return CSys(
@@ -191,23 +201,25 @@ finite elements.
191201
"""
192202
function CSys(sdim::IT1, mdim::IT2) where {IT1<:Integer,IT2<:Integer}
193203
function __updatebuffer!(
194-
csmatout::Matrix{T},
195-
XYZ::VecOrMat{T},
196-
tangents::Matrix{T},
197-
feid::IT1,
198-
qpid::IT2,
199-
) where {T,IT1,IT2}
204+
csmatout::AbstractMatrix{<:Real},
205+
XYZ::AbstractVecOrMat{<:Real},
206+
tangents::AbstractMatrix{<:Real},
207+
feid::Integer,
208+
qpid::Integer,
209+
)
200210
return gen_iso_csmat!(csmatout, XYZ, tangents, feid, qpid)
201211
end
202212
return CSys(false, false, __updatebuffer!, fill(zero(Float64), sdim, mdim))
203213
end
204214

205215
"""
206-
updatecsmat!(self::CSys,
207-
XYZ::Matrix{T},
208-
tangents::Matrix{T},
209-
feid::IT1,
210-
qpid::IT2) where {T, IT1, IT2}
216+
updatecsmat!(
217+
self::CSys,
218+
XYZ::AbstractVecOrMat{<:Real},
219+
tangents::AbstractMatrix{<:Real},
220+
feid::Integer,
221+
qpid::Integer,
222+
)
211223
212224
Update the coordinate system orientation matrix.
213225
@@ -221,11 +233,11 @@ buffer as `self.csmat`.
221233
"""
222234
function updatecsmat!(
223235
self::CSys,
224-
XYZ::Matrix{T},
225-
tangents::Matrix{T},
226-
feid::IT1,
227-
qpid::IT2,
228-
) where {T,IT1,IT2}
236+
XYZ::AbstractVecOrMat{<:Real},
237+
tangents::AbstractMatrix{<:Real},
238+
feid::Integer,
239+
qpid::Integer,
240+
)
229241
self.__updatebuffer!(self._csmat, XYZ, tangents, feid, qpid)
230242
return self._csmat
231243
end

src/DataCacheModule.jl

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@ follows:
2222
2323
```
2424
function fillcache!(cacheout::D,
25-
XYZ::VecOrMat{T}, tangents::Matrix{T}, feid::IT, qpid::IT) where {D, T, IT}
25+
XYZ::AbstractVecOrMat{<:Real}, tangents::AbstractMatrix{<:Real},
26+
feid::IT, qpid::IT) where {D, T, IT}
2627
... # modify the value of cacheout
2728
return cacheout
2829
end
@@ -41,7 +42,7 @@ called, and the output `cacheout` is filled with the value of the cached data.
4142
# Example
4243
```
4344
function fillcache!(cacheout::Array{CT, N},
44-
XYZ::VecOrMat{T}, tangents::Matrix{T},
45+
XYZ::AbstractVecOrMat{<:Real}, tangents::AbstractMatrix{<:Real},
4546
feid::IT, qpid::IT) where {CT, N, T, IT}
4647
cacheout .= LinearAlgebra.I(3)
4748
return cacheout
@@ -61,26 +62,26 @@ end
6162
The bad news is, the cache is not thread safe. Reading is okay, but writing
6263
can lead to data races.
6364
"""
64-
mutable struct DataCache{D,F<:Function}
65+
mutable struct DataCache{D, F<:Function}
6566
# Cache where the current value of the data can be retrieved
6667
_cache::D
6768
# Function to update and retrieve the array
6869
_fillcache!::F
6970
end
7071

7172
"""
72-
DataCache(data::Array{CT, N}) where {CT<:Number, N}
73+
DataCache(data::D) where {D}
7374
7475
Construct data cache. The *constant* data is given.
7576
"""
7677
function DataCache(data::D) where {D}
7778
function _fillcache_constant!(
7879
cacheout::D,
79-
XYZ::VecOrMat{T},
80-
tangents::Matrix{T},
80+
XYZ::AbstractVecOrMat{<:Real},
81+
tangents::AbstractMatrix{<:Real},
8182
feid::IT,
8283
qpid::IT,
83-
) where {D,T<:Number,IT<:Integer}
84+
) where {D, IT<:Integer}
8485
# do nothing: the data is already in the cache
8586
return cacheout
8687
end
@@ -90,16 +91,21 @@ end
9091
datatype(c::DataCache) = typeof(c._cache)
9192

9293
"""
93-
(c::DataCache)(XYZ::VecOrMat{T}, tangents::Matrix{T}, feid::IT, qpid::IT) where {T<:Number, IT<:Integer}
94+
(c::DataCache)(
95+
XYZ::AbstractVecOrMat{<:Real},
96+
tangents::AbstractMatrix{<:Real},
97+
feid::IT,
98+
qpid::IT,
99+
) where {IT<:Integer}
94100
95101
Update the cache and retrieve the array.
96102
"""
97103
function (c::DataCache)(
98-
XYZ::VecOrMat{T},
99-
tangents::Matrix{T},
104+
XYZ::AbstractVecOrMat{<:Real},
105+
tangents::AbstractMatrix{<:Real},
100106
feid::IT,
101107
qpid::IT,
102-
) where {T<:Number,IT<:Integer}
108+
) where {IT<:Integer}
103109
c._cache = c._fillcache!(c._cache, XYZ, tangents, feid, qpid)
104110
return c._cache
105111
end

src/IntegDomainModule.jl

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,30 @@ function IntegDomain(
7575
integration_rule::IR,
7676
otherdimension::T,
7777
) where {S<:AbstractFESet,IR<:AbstractIntegRule,T<:Number}
78-
function otherdimensionfu(loc::Matrix{T}, conn::CC, N::Matrix{T}) where {CC,T<:Number}
78+
function otherdimensionfu(loc::AbstractVecOrMat{<:Real}, conn::CC, N::AbstractMatrix{<:Real}) where {CC}
7979
return otherdimension
8080
end
8181
return IntegDomain(fes, integration_rule, otherdimensionfu, false)
8282
end
8383

84+
"""
85+
IntegDomain(
86+
fes::S,
87+
integration_rule::IR,
88+
otherdimension::F,
89+
) where {S<:AbstractFESet, IR<:AbstractIntegRule, F<:Function}
90+
91+
Construct with the default orientation matrix (identity), and other
92+
dimension provided by a function.
93+
"""
94+
function IntegDomain(
95+
fes::S,
96+
integration_rule::IR,
97+
otherdimension::F,
98+
) where {S<:AbstractFESet, IR<:AbstractIntegRule, F<:Function}
99+
return IntegDomain(fes, integration_rule, otherdimension, false)
100+
end
101+
84102
"""
85103
IntegDomain(
86104
fes::S,

src/SurfaceNormalModule.jl

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ point `XYZ`, using the columns of the Jacobian matrix of the element,
2525
quadrature point, `qpid`:
2626
2727
```
28-
function computenormal!(normalout::Vector{CT}, XYZ::Matrix{T},
29-
tangents::Matrix{T}, feid::IT, qpid::IT) where {CT, T, IT}
30-
# Calculate the normal and copy it into the buffer....
31-
return normalout
32-
end
28+
function computenormal!(normalout::Vector{CT}, XYZ::AbstractVecOrMat{<:Real},
29+
tangents::AbstractMatrix{<:Real}, feid::IT, qpid::IT) where {CT, IT}
30+
# Calculate the normal and copy it into the buffer....
31+
return normalout
32+
end
3333
```
3434
3535
The buffer `normalout` needs to be filled with the value of the normal vector.
@@ -65,8 +65,8 @@ vector is given.
6565
have a signature of
6666
6767
```
68-
function computenormal!(normalout::Vector{CT}, XYZ::Matrix{T},
69-
tangents::Matrix{T}, feid::IT, qpid::IT) where {CT, T, IT}
68+
function computenormal!(normalout::Vector{CT}, XYZ::AbstractVecOrMat{<:Real},
69+
tangents::AbstractMatrix{<:Real}, feid::IT, qpid::IT) where {CT, IT}
7070
# Calculate the normal and copy it into the buffer....
7171
return normalout
7272
end
@@ -95,12 +95,12 @@ In that case a zero vector is returned, and a warning is printed.
9595
"""
9696
function SurfaceNormal(ndimensions)
9797
function defaultcomputenormal!(
98-
normalout::Vector{T},
99-
XYZ::Matrix{T},
100-
tangents::Matrix{T},
98+
normalout::AbstractVector{T},
99+
XYZ::AbstractVecOrMat{<:Real},
100+
tangents::AbstractMatrix{<:Real},
101101
feid::IT,
102102
qpid::IT,
103-
) where {T<:Number,IT<:Integer}
103+
) where {T<:Real, IT<:Integer}
104104
fill!(normalout, zero(T))
105105
# Produce a default normal
106106
if (size(tangents, 1) == 3) && (size(tangents, 2) == 2)# surface in three dimensions
@@ -132,19 +132,25 @@ function SurfaceNormal(vector::Vector{T}) where {T<:Number}
132132
end
133133

134134
"""
135-
updatenormal!(self::SurfaceNormal, XYZ::Matrix{T}, tangents::Matrix{T}, feid::IT, qpid::IT) where {T, IT}
135+
updatenormal!(
136+
self::SurfaceNormal,
137+
XYZ::AbstractVecOrMat{<:Real},
138+
tangents::AbstractMatrix{<:Real},
139+
feid::IT,
140+
qpid::IT,
141+
) where {IT}
136142
137143
Update the surface normal vector.
138144
139145
Returns the normal vector (stored in the cache).
140146
"""
141147
function updatenormal!(
142148
self::SurfaceNormal,
143-
XYZ::Matrix{T},
144-
tangents::Matrix{T},
149+
XYZ::AbstractVecOrMat{<:Real},
150+
tangents::AbstractMatrix{<:Real},
145151
feid::IT,
146152
qpid::IT,
147-
) where {T,IT}
153+
) where {IT}
148154
return self._cache(XYZ, tangents, feid, qpid)
149155
end
150156

0 commit comments

Comments
 (0)