Skip to content

Commit 51b756d

Browse files
committed
put back a compatibility gather
1 parent 787edcf commit 51b756d

File tree

6 files changed

+47
-14
lines changed

6 files changed

+47
-14
lines changed

src/ElementalFieldModule.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __precompile__(true)
99

1010
import ..FieldModule: AbstractField, nents
1111
import ..FieldModule.@add_Field_fields
12+
import ..FieldModule.KIND_INT
1213
import ..FieldModule.DOF_KIND_FREE
1314

1415
"""

src/FieldModule.jl

Lines changed: 41 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,20 @@ See also: [`@add_Field_fields()`](@ref) .
2424
"""
2525
abstract type AbstractField end
2626

27+
"""
28+
KIND_INT
29+
30+
Constant representing the type of the integer representing the `kind` of a degree of freedom.
31+
"""
32+
const KIND_INT = Int8
33+
34+
"""
35+
Predefined kinds of degrees of freedom.
36+
"""
37+
const DOF_KIND_ALL::KIND_INT = 0
38+
const DOF_KIND_FREE::KIND_INT = 1
39+
const DOF_KIND_DATA::KIND_INT = 2
40+
2741
"""
2842
add_Field_fields()
2943
@@ -33,18 +47,11 @@ the abstract type depend on these attributes to be present.
3347
macro add_Field_fields()
3448
return esc(:(values::Array{T,2};
3549
dofnums::Array{IT,2};
36-
kind::Matrix{Int8};
50+
kind::Matrix{KIND_INT};
3751
ranges::Vector{UnitRange{IT}}
3852
))
3953
end
4054

41-
"""
42-
Predefined kinds of degrees of freedom.
43-
"""
44-
const DOF_KIND_ALL = 0
45-
const DOF_KIND_FREE = 1
46-
const DOF_KIND_DATA = 2
47-
4855
"""
4956
ndofs(self::F)
5057
@@ -76,21 +83,21 @@ end
7683
"""
7784
nfreedofs(self::F) where {F<:AbstractField}
7885
79-
Return to number of FREE degrees of freedom (known, data).
86+
Return the number of FREE degrees of freedom (known, data).
8087
"""
8188
nfreedofs(self::F) where {F<:AbstractField} = length(dofrange(self, DOF_KIND_FREE))
8289

8390
"""
8491
nfixeddofs(self::F)
8592
86-
Return to number of FIXED degrees of freedom (known, data).
93+
Return the number of FIXED degrees of freedom (known, data).
8794
"""
8895
nfixeddofs(self::F) where {F<:AbstractField} = length(dofrange(self, DOF_KIND_DATA))
8996

9097
"""
9198
nalldofs(self::F) where {F<:AbstractField}
9299
93-
Return to number of ALL degrees of freedom (known, data).
100+
Return the number of ALL degrees of freedom (known, data).
94101
"""
95102
nalldofs(self::F) where {F<:AbstractField} = sum(length(v) for v in values(self.ranges))
96103

@@ -139,20 +146,41 @@ function wipe!(self::F) where {F<:AbstractField}
139146
end
140147

141148
"""
142-
gathersysvec(self::F, kind = DOF_KIND_FREE) where {F<:AbstractField}
149+
gathersysvec(self::F, kind::KIND_INT = DOF_KIND_FREE) where {F<:AbstractField}
143150
144151
Gather values from the field for the system vector.
145152
146153
# Arguments
147154
- `self`: field;
148155
- `kind`: kind of degrees of freedom to gather; default is `DOF_KIND_FREE`.
149156
"""
150-
function gathersysvec(self::F, kind = DOF_KIND_FREE) where {F<:AbstractField}
157+
function gathersysvec(self::F, kind::KIND_INT = DOF_KIND_FREE) where {F<:AbstractField}
151158
N = length(dofrange(self, kind))
152159
vec = zeros(eltype(self.values), N)
153160
return gathersysvec!(self, vec, kind)
154161
end
155162

163+
"""
164+
gathersysvec(self::F, kind::Symbol) where {F<:AbstractField}
165+
166+
Gather values from the field for the system vector.
167+
168+
This is a compatibility version, using a symbol.
169+
170+
# Arguments
171+
- `self::F`: The field object.
172+
- `kind::Symbol`: The kind of system vector to gather.
173+
"""
174+
function gathersysvec(self::F, kind::Symbol) where {F<:AbstractField}
175+
if kind == :f
176+
return gathersysvec(self, DOF_KIND_FREE)
177+
elseif kind == :d
178+
return gathersysvec(self, DOF_KIND_DATA)
179+
else
180+
return gathersysvec(self, DOF_KIND_ALL)
181+
end
182+
end
183+
156184
"""
157185
gathersysvec!(self::F,
158186
vec::Vector{T}, which = :f) where {F<:AbstractField, T}

src/FinEtools.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ export FENodeToFEMap
121121

122122
using .FieldModule:
123123
AbstractField,
124+
KIND_INT,
124125
DOF_KIND_ALL,
125126
DOF_KIND_FREE,
126127
DOF_KIND_DATA,
@@ -147,6 +148,7 @@ using .FieldModule:
147148
incrscattersysvec!
148149
# Exported: abstract field type, methods for the abstract field type (retrieval of data from a field, setting of data in the field)
149150
export AbstractField,
151+
KIND_INT,
150152
DOF_KIND_ALL,
151153
DOF_KIND_FREE,
152154
DOF_KIND_DATA,

src/GeneralFieldModule.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __precompile__(true)
99

1010
import ..FieldModule.AbstractField
1111
import ..FieldModule.@add_Field_fields
12+
import ..FieldModule.KIND_INT
1213
import ..FieldModule.DOF_KIND_FREE
1314

1415
"""

src/NodalFieldModule.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ __precompile__(true)
99

1010
import ..FieldModule: AbstractField, nents
1111
import ..FieldModule.@add_Field_fields
12+
import ..FieldModule.KIND_INT
1213
import ..FieldModule.DOF_KIND_FREE
1314

1415
"""

test/test_basics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ using FinEtools
2626
using Test
2727
using LinearAlgebra
2828
function test()
29-
DOF_KIND_INTERFACE = 3
29+
DOF_KIND_INTERFACE::KIND_INT = 3
3030
ua = rand(50, 3)
3131
u = NodalField(ua)
3232
for i in [1, 4, 7, 10, 13, 16, 19, 22, 25]

0 commit comments

Comments
 (0)