44 integer,
allocatable,
public :: map(:)
47 integer,
allocatable :: position(:)
48 real(real64),
allocatable :: val(:)
49 real(real64),
allocatable :: volume(:)
51 real(real64),
allocatable :: population(:)
58 type(basins_t),
intent(out) :: this
59 type(namespace_t),
intent(in) :: namespace
60 class(mesh_t),
intent(in) :: mesh
64 if (mesh%parallel_in_domains)
then
68 safe_allocate(this%map(1:mesh%np))
69 this%map(1:mesh%np) = -1
77 type(basins_t),
intent(inout) :: this
81 assert(
allocated(this%map))
82 safe_deallocate_a(this%map)
84 safe_deallocate_a(this%position)
85 safe_deallocate_a(this%val)
86 safe_deallocate_a(this%volume)
87 safe_deallocate_a(this%population)
94 subroutine basins_analyze(this, namespace, mesh, f, rho, threshold)
95 type(basins_t),
intent(inout) :: this
96 type(namespace_t),
intent(in) :: namespace
97 class(mesh_t),
intent(in) :: mesh
98 real(real64),
intent(in) :: f(:)
99 real(real64),
intent(in) :: rho(:, :)
100 real(real64),
intent(in) :: threshold
102 integer :: jj, xmax, ymax, zmax
103 integer :: cur_color, dum
107 assert(
allocated(this%map))
114 if (mesh%box%dim < 3) zmax = 0
115 if (mesh%box%dim < 2) ymax = 0
118 if (this%map(jj) == -1)
then
130 recursive integer function steep_fill(ii)
result(color)
131 integer,
intent(in) :: ii
137 if (this%map(ii) >= 0)
then
144 if (ii_max == -1)
then
145 ii_max =
get_max(ii, threshold)
148 if (ii_max /= -1)
then
152 cur_color = cur_color + 1
160 integer function get_max(ii, threshold)
161 integer,
intent(in) :: ii
162 real(real64),
intent(in) :: threshold
164 real(real64) :: f_max
165 integer :: xx, yy, zz, index
166 integer :: point(3), point2(3)
178 if (xx == 0 .and. yy == 0 .and. zz == 0) cycle
181 point2(1) = point2(1) + xx
182 point2(2) = point2(2) + yy
183 point2(3) = point2(3) + zz
187 if (index <= 0 .or. index > mesh%np) cycle
188 if (this%map(index) == -2) cycle
190 if (f_max <= f(index) + threshold)
then
207 integer :: ii, jj, ii_max
208 real(real64) :: f_max
212 this%number = maxval(this%map) + 1
213 if (this%number <= 0)
then
214 message(1) =
"Internal error analysing basins of attraction"
218 safe_allocate(this%position (1:this%number))
219 safe_allocate(this%val (1:this%number))
220 safe_allocate(this%volume (1:this%number))
221 safe_allocate(this%population(1:this%number))
223 this%position(:) = -1
226 this%population(:) =
m_zero
227 do ii = 1, this%number
232 if (this%map(jj) /= ii-1) cycle
233 if (f_max <= f(jj))
then
238 if (mesh%use_curvilinear)
then
239 this%volume(ii) = this%volume(ii) + mesh%vol_pp(jj)
240 this%population(ii) = this%population(ii) + mesh%vol_pp(jj)*sum(rho(jj, :))
242 this%volume(ii) = this%volume(ii) + mesh%volume_element
243 this%population(ii) = this%population(ii) + mesh%volume_element*sum(rho(jj, :))
247 this%position(ii) = ii_max
260 class(
mesh_t),
intent(in) :: mesh
261 integer,
intent(in) :: iunit
265 real(real64) :: xx(1:mesh%box%dim)
269 unit_vol =
units_out%length**mesh%box%dim
271 write(iunit,
'(a,i5)')
'Number of basins = ', this%number
274 do ii = 1, this%number
275 write(iunit,
'(a,i5)')
'# ', ii
277 write(iunit,
'(a,3(f12.6,a), a)')
' position = (', &
279 write(iunit,
'(a,f12.6)')
' value = ', this%val(ii)
281 write(iunit,
'(a,f12.6)')
' population = ', this%population(ii)
integer function get_max(ii, threshold)
recursive integer function steep_fill(ii)
subroutine analyze(namespace)
subroutine, public basins_write(this, mesh, iunit)
subroutine, public basins_init(this, namespace, mesh)
subroutine, public basins_analyze(this, namespace, mesh, f, rho, threshold)
subroutine, public basins_end(this)
real(real64), parameter, public m_zero
This module defines the meshes, which are used in Octopus.
integer function, public mesh_local_index_from_coords(mesh, ix)
This function returns the local index of the point for a given vector of integer coordinates.
subroutine, public mesh_local_index_to_coords(mesh, ip, ix)
Given a local point index, this function returns the set of integer coordinates of the point.
character(len=256), dimension(max_lines), public message
to be output by fatal, warning
subroutine, public messages_fatal(no_lines, only_root_writes, namespace)
subroutine, public messages_experimental(name, namespace)
Some general things and nomenclature:
brief This module defines the class unit_t which is used by the unit_systems_oct_m module.
character(len=20) pure function, public units_abbrev(this)
This module defines the unit system, used for input and output.
type(unit_system_t), public units_out
Describes mesh distribution to nodes.