Mercurial > repos > public > sbplib_julia
comparison diffOp.jl @ 173:fabd475bb258 boundary_conditions
Move definition of BoundaryValue before definition of Laplace
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 21 May 2019 16:31:19 +0200 |
parents | a8bc71608588 |
children | 187295479984 |
comparison
equal
deleted
inserted
replaced
172:a8bc71608588 | 173:fabd475bb258 |
---|---|
128 elseif r == Upper | 128 elseif r == Upper |
129 return d.grid.inverse_spacing[dim(d.bId)]*d.op.dClosure[N_i-j]*v[j] | 129 return d.grid.inverse_spacing[dim(d.bId)]*d.op.dClosure[N_i-j]*v[j] |
130 end | 130 end |
131 end | 131 end |
132 | 132 |
133 struct BoundaryValue{N,M,K} | |
134 op::D2{Float64,N,M,K} | |
135 grid::EquidistantGrid | |
136 bId::CartesianBoundary | |
137 end | |
138 | |
139 function apply(e::BoundaryValue, v::AbstractArray, I::Tuple{Integer,Integer}) | |
140 i = I[dim(e.bId)] | |
141 j = I[3-dim(e.bId)] | |
142 N_i = e.grid.size[dim(e.bId)] | |
143 | |
144 r = getregion(i, closureSize(e.op), N_i) | |
145 | |
146 if r != region(e.bId) | |
147 return 0 | |
148 end | |
149 | |
150 if r == Lower | |
151 # Note, closures are indexed by offset. Fix this D:< | |
152 return e.op.eClosure[i-1]*v[j] | |
153 elseif r == Upper | |
154 return e.op.eClosure[N_i-j]*v[j] | |
155 end | |
156 end | |
157 | |
158 function apply_transpose(e::BoundaryValue, v::AbstractArray, I::Integer) | |
159 u = selectdim(v,3-dim(e.bId),I) | |
160 return apply_e(e.op, u, region(e.bId)) | |
161 end | |
162 | |
133 struct Laplace{Dim,T<:Real,N,M,K} <: DiffOpCartesian{Dim} | 163 struct Laplace{Dim,T<:Real,N,M,K} <: DiffOpCartesian{Dim} |
134 grid::EquidistantGrid{Dim,T} | 164 grid::EquidistantGrid{Dim,T} |
135 a::T | 165 a::T |
136 op::D2{Float64,N,M,K} | 166 op::D2{Float64,N,M,K} |
137 # e::BoundaryValue | 167 e::BoundaryValue |
138 d::NormalDerivative | 168 d::NormalDerivative |
139 end | 169 end |
140 | 170 |
141 function apply(L::Laplace{Dim}, v::AbstractArray{T,Dim} where T, I::CartesianIndex{Dim}) where Dim | 171 function apply(L::Laplace{Dim}, v::AbstractArray{T,Dim} where T, I::CartesianIndex{Dim}) where Dim |
142 error("not implemented") | 172 error("not implemented") |
166 | 196 |
167 struct BoundaryOperator | 197 struct BoundaryOperator |
168 | 198 |
169 end | 199 end |
170 | 200 |
171 struct BoundaryValue{N,M,K} | |
172 op::D2{Float64,N,M,K} | |
173 grid::EquidistantGrid | |
174 bId::CartesianBoundary | |
175 end | |
176 | |
177 function apply(e::BoundaryValue, v::AbstractArray, I::Tuple{Integer,Integer}) | |
178 i = I[dim(e.bId)] | |
179 j = I[3-dim(e.bId)] | |
180 N_i = e.grid.size[dim(e.bId)] | |
181 | |
182 r = getregion(i, closureSize(e.op), N_i) | |
183 | |
184 if r != region(e.bId) | |
185 return 0 | |
186 end | |
187 | |
188 if r == Lower | |
189 # Note, closures are indexed by offset. Fix this D:< | |
190 return e.op.eClosure[i-1]*v[j] | |
191 elseif r == Upper | |
192 return e.op.eClosure[N_i-j]*v[j] | |
193 end | |
194 end | |
195 | |
196 function apply_transpose(e::BoundaryValue, v::AbstractArray, I::Integer) | |
197 u = selectdim(v,3-dim(e.bId),I) | |
198 return apply_e(e.op, u, region(e.bId)) | |
199 end | |
200 | |
201 | 201 |
202 """ | 202 """ |
203 A BoundaryCondition should implement the method | 203 A BoundaryCondition should implement the method |
204 sat(::DiffOp, v::AbstractArray, data::AbstractArray, ...) | 204 sat(::DiffOp, v::AbstractArray, data::AbstractArray, ...) |
205 """ | 205 """ |