-
Notifications
You must be signed in to change notification settings - Fork 98
/
CellDataInterface.jl
59 lines (48 loc) · 1.72 KB
/
CellDataInterface.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""
Trait that signals if a CellDatum type is implemented in the physical or the reference domain
"""
abstract type DomainStyle end
struct ReferenceDomain <: DomainStyle end
struct PhysicalDomain <: DomainStyle end
"""
Data associated with the cells of a Triangulation.
CellDatum objects behave as if they are defined in the physical space of the triangulation.
But in some cases they are implemented as reference quantities plus some transformation to the physical domain.
"""
abstract type CellDatum <: GridapType end
"""
Get the stored array of cell-wise data. It can be defined in the physical or the reference domain.
"""
get_data(a::CellDatum) = @abstractmethod
"""
Tell if the stored array is in the reference or physical domain
"""
DomainStyle(::Type{<:CellDatum}) = @abstractmethod
"""
Return the underlying Triangulation object
"""
get_triangulation(a::CellDatum) = @abstractmethod
"""
Change the underlying data to the target domain
"""
change_domain(a::CellDatum,target_domain::DomainStyle) = change_domain(a,DomainStyle(a),target_domain)
change_domain(a::CellDatum,input_domain::T,target_domain::T) where T<: DomainStyle = a
change_domain(a::CellDatum,input_domain::DomainStyle,target_domain::DomainStyle) = @abstractmethod
# Tester
"""
"""
function test_cell_datum(a::CellDatum)
@test isa(get_data(a),AbstractArray)
@test isa(get_triangulation(a),Triangulation)
@test isa(DomainStyle(a),DomainStyle)
end
# Some API
DomainStyle(::T) where T<:CellDatum = DomainStyle(T)
"""
Get the raw array of cell data defined in the physical space.
"""
get_array(a::CellDatum) = get_data(change_domain(a,PhysicalDomain()))
"""
"""
#Base.length(a::CellDatum) = num_cells(get_triangulation(a))
num_cells(a::CellDatum) = num_cells(get_triangulation(a))