@@ -16,21 +16,21 @@ Return a vector of all elementary entities making up a domain.
1616"""
1717entities (Ω:: Domain ) = Ω. entities
1818
19- Domain (ω:: AbstractEntity ) = Domain ([ω, ])
19+ Domain (ω:: AbstractEntity ) = Domain ([ω])
2020Domain () = Domain (AbstractEntity[])
2121
22- function Base. show (io:: IO ,d:: Domain )
22+ function Base. show (io:: IO , d:: Domain )
2323 ents = entities (d)
2424 n = length (entities (d))
25- n == 1 ? print (io," Domain with $n entity:\n " ) : print (io," Domain with $n entities:" )
25+ n == 1 ? print (io, " Domain with $n entity:\n " ) : print (io, " Domain with $n entities:" )
2626 for ent in ents
27- print (io," \n\t $(ent) " )
27+ print (io, " \n\t $(ent) " )
2828 end
2929 return io
3030end
3131
3232function geometric_dimension (Ω:: Domain )
33- l,u = extrema (geometric_dimension (ent) for ent in entities (Ω))
33+ l, u = extrema (geometric_dimension (ent) for ent in entities (Ω))
3434 @assert l == u " geometric dimension of entities in a domain not equal"
3535 return u
3636end
@@ -51,9 +51,9 @@ Return all the boundaries of the domain, i.e. the domain's skeleton.
5151function skeleton (Ω:: Domain )
5252 ents = AbstractEntity[]
5353 for ent in entities (Ω)
54- append! (ents,boundary (ent))
54+ append! (ents, boundary (ent))
5555 end
56- Domain (unique! (ents))
56+ return Domain (unique! (ents))
5757end
5858
5959"""
6262Two `Domain`s are equal if all their entities are equal (regardless of order).
6363"""
6464function Base.:(== )(Ω1:: Domain , Ω2:: Domain )
65- return issetequal (entities (Ω1),entities (Ω2))
65+ return issetequal (entities (Ω1), entities (Ω2))
6666end
6767
6868"""
@@ -77,7 +77,7 @@ function Base.in(ω::ElementaryEntity, Ω::Domain)
7777 # TODO : should we really recurse on the boundary of the entities composing
7878 # the domain for determining if an entity is in a domain.
7979 for ent in ents
80- in (ω,Domain (boundary (ent))) && (return true )
80+ in (ω, Domain (boundary (ent))) && (return true )
8181 end
8282 return false
8383end
@@ -97,22 +97,23 @@ function Base.iterate(Ω::Domain, state=1)
9797 return nothing
9898 end
9999 # Return (result, state)
100- return (Ω[state], state+ 1 )
100+ return (Ω[state], state + 1 )
101101end
102102
103103Base. isempty (Ω:: Domain ) = length (entities (Ω)) == 0
104104
105105function Base. setdiff (Ω1:: Domain , Ω2:: Domain )
106- Domain (setdiff (entities (Ω1), entities (Ω2)))
106+ return Domain (setdiff (entities (Ω1), entities (Ω2)))
107107end
108108
109- function Base. union (Ω1:: Domain ,Ωs:: Domain... )
110- ents = vcat (entities (Ω1),entities .(Ωs)... )
111- Domain (unique! (ents))
109+ function Base. union (Ω1:: Domain , Ωs:: Domain... )
110+ ents = vcat (entities (Ω1), entities .(Ωs)... )
111+ return Domain (unique! (ents))
112112end
113113Base. union (Ω:: Domain ) = Domain (unique (entities (Ω)))
114114
115- Base. append! (Ω1,Ω2) = (append! (entities (Ω1),entities (Ω2)); Ω1)
115+ Base. append! (Ω1, Ω2) = (append! (entities (Ω1), entities (Ω2));
116+ Ω1)
116117
117118"""
118119 assertequaldim(Ω1::Domain,Ω2::Domain)
@@ -145,8 +146,8 @@ function Base.intersect(Ω1::Domain, Ω2::Domain)
145146 end
146147end
147148
148- function Base. push! (Ω:: Domain ,ent:: AbstractEntity )
149- push! (entities (Ω),ent)
149+ function Base. push! (Ω:: Domain , ent:: AbstractEntity )
150+ return push! (entities (Ω), ent)
150151end
151152
152153function Base. issubset (Ω1:: Domain , Ω2:: Domain )
@@ -163,11 +164,10 @@ Return a domain comprising the external boundary of Ω.
163164"""
164165boundary (Ω:: Domain ) = external_boundary (Ω:: Domain )
165166
166-
167167""" Return the internal boundaries inside a domain."""
168168function internal_boundary (Ω:: Domain )
169169 Ω1 = Domain (Ω[1 ])
170- γ = Domain ()
170+ γ = Domain ()
171171 for ω2 in Ω[2 : end ]
172172 Ω2 = Domain (ω2)
173173 γ1 = Domain (vcat (boundary .(entities (Ω1))... ))
180180
181181""" Return the external boundaries inside a domain."""
182182function external_boundary (Ω:: Domain )
183- return setdiff (skeleton (Ω),internal_boundary (Ω))
183+ return setdiff (skeleton (Ω), internal_boundary (Ω))
184184end
185185
186186"""
@@ -192,20 +192,22 @@ function Base.keys(Ω::Domain, d::Integer)
192192 elseif d == geometric_dimension (Ω)
193193 return Vector {Tuple{Int64,Int64}} (vcat (key .(entities (Ω))))
194194 elseif d < geometric_dimension (Ω)
195- return unique (keys (skeleton (Ω),d))
195+ return unique (keys (skeleton (Ω), d))
196196 else
197197 error (" Asking for tags with dimension > dimension of domain" )
198198 end
199199end
200200function Base. keys (Ω:: Domain )
201- isempty (Ω) ? Tuple{Int64, Int64}[] : keys (Ω, geometric_dimension (Ω))
201+ return isempty (Ω) ? Tuple{Int64,Int64}[] : keys (Ω, geometric_dimension (Ω))
202202end
203203
204204"""
205205Return all tags of the elementary entities in the domain `Ω` corresponding to the dimensions contained in `dims`.
206206"""
207- function Base. keys (Ω:: Domain , dims:: Vector{T} ) where T <: Integer
208- tgs = Vector {Tuple{Int64, Int64}} (undef, 0 )
209- for d in dims push! (tgs, keys (Ω, d)... ) end
207+ function Base. keys (Ω:: Domain , dims:: Vector{T} ) where {T<: Integer }
208+ tgs = Vector {Tuple{Int64,Int64}} (undef, 0 )
209+ for d in dims
210+ push! (tgs, keys (Ω, d)... )
211+ end
210212 return tgs
211213end
0 commit comments