@@ -49,20 +49,20 @@ Base.convert(T::Type{ElectricField}, x::NamedTuple) = T(x)
4949
5050
5151
52- function ElectricField (epot:: ElectricPotential{T, 3, S} , point_types:: PointTypes{T} ) where {T, S}
53- return ElectricField {T, 3, S, typeof(grid.axes)} (get_electric_field_from_potential ( epot, point_types ), epot. grid)
52+ function ElectricField (epot:: ElectricPotential{T, 3, S} , point_types:: PointTypes{T} ; use_nthreads :: Int = Base . Threads . nthreads () ) where {T, S}
53+ return ElectricField {T, 3, S, typeof(grid.axes)} (get_electric_field_from_potential ( epot, point_types; use_nthreads ), epot. grid)
5454end
5555
5656
57- function get_electric_field_from_potential (epot:: ElectricPotential{T, 3, Cylindrical} , point_types:: PointTypes{T} , fieldvector_coordinates = :xyz ):: ElectricField{T, 3, Cylindrical} where {T <: SSDFloat }
57+ function get_electric_field_from_potential (epot:: ElectricPotential{T, 3, Cylindrical} , point_types:: PointTypes{T} ; use_nthreads :: Int = Base . Threads . threadid () ):: ElectricField{T, 3, Cylindrical} where {T <: SSDFloat }
5858 p = epot. data
5959 axr:: Vector{T} = collect (epot. grid. axes[1 ])
6060 axφ:: Vector{T} = collect (epot. grid. axes[2 ])
6161 axz:: Vector{T} = collect (epot. grid. axes[3 ])
6262
6363 cyclic:: T = epot. grid. axes[2 ]. interval. right
6464 ef = Array {SVector{3, T}} (undef, size (p)... )
65- for iz in 1 : size (ef, 3 )
65+ @onthreads 1 : use_nthreads for iz in workpart ( 1 : size (ef, 3 ), 1 : use_nthreads, Base . Threads . threadid () )
6666 for iφ in 1 : size (ef, 2 )
6767 for ir in 1 : size (ef, 1 )
6868 # ## r ###
@@ -157,9 +157,7 @@ function get_electric_field_from_potential(epot::ElectricPotential{T, 3, Cylindr
157157 end
158158 end
159159 end
160- if fieldvector_coordinates == :xyz
161- ef = convert_field_vectors_to_xyz (ef, axφ)
162- end
160+ ef = convert_field_vectors_to_xyz (ef, axφ)
163161 return ElectricField (ef, point_types. grid)
164162end
165163
@@ -177,6 +175,7 @@ function convert_field_vectors_to_xyz(field::Array{SArray{Tuple{3},T,1,3},3}, φ
177175end
178176
179177
178+
180179function interpolated_scalarfield (spot:: ScalarPotential{T, 3, Cylindrical} ) where {T}
181180 @inbounds knots = spot. grid. axes[1 ]. ticks, cat (spot. grid. axes[2 ]. ticks,T (2 π),dims= 1 ), spot. grid. axes[3 ]. ticks
182181 ext_data = cat (spot. data, spot. data[:,1 : 1 ,:], dims= 2 )
@@ -212,17 +211,17 @@ end
212211
213212
214213
215- function get_electric_field_from_potential (epot:: ElectricPotential{T, 3, Cartesian} , point_types:: PointTypes{T} ):: ElectricField{T, 3, Cartesian} where {T <: SSDFloat }
214+ function get_electric_field_from_potential (epot:: ElectricPotential{T, 3, Cartesian} , point_types:: PointTypes{T} ; use_nthreads :: Int = Base . Threads . nthreads () ):: ElectricField{T, 3, Cartesian} where {T <: SSDFloat }
216215 axx:: Vector{T} = collect (epot. grid. axes[1 ])
217216 axy:: Vector{T} = collect (epot. grid. axes[2 ])
218217 axz:: Vector{T} = collect (epot. grid. axes[3 ])
219- axx_ext:: Vector{T} = get_extended_ticks (epot. grid. axes[1 ])
220- axy_ext:: Vector{T} = get_extended_ticks (epot. grid. axes[2 ])
221- axz_ext:: Vector{T} = get_extended_ticks (epot. grid. axes[3 ])
218+ # axx_ext::Vector{T} = get_extended_ticks(epot.grid.axes[1])
219+ # axy_ext::Vector{T} = get_extended_ticks(epot.grid.axes[2])
220+ # axz_ext::Vector{T} = get_extended_ticks(epot.grid.axes[3])
222221
223222 ef:: Array{SVector{3, T}} = Array {SVector{3, T}} (undef, size (epot. data))
224223
225- for ix in eachindex (axx)
224+ @onthreads 1 : use_nthreads for ix in workpart ( eachindex (axx), 1 : use_nthreads, Base . Threads . threadid () )
226225 for iy in eachindex (axy)
227226 for iz in eachindex (axz)
228227 if ix - 1 < 1
0 commit comments