MODFLOW 6  version 6.5.0.dev2
MODFLOW 6 Code Documentation
connectionsmodule Module Reference

Data Types

type  connectionstype
 

Functions/Subroutines

subroutine con_da (this)
 Deallocate connection variables. More...
 
subroutine allocate_scalars (this, name_model)
 Allocate scalars for ConnectionsType. More...
 
subroutine allocate_arrays (this)
 Allocate arrays for ConnectionsType. More...
 
subroutine con_finalize (this, ihctemp, cl12temp, hwvatemp, angldegx)
 Finalize connection data. More...
 
subroutine read_connectivity_from_block (this, name_model, nodes, nja, iout)
 Read and process IAC and JA from an an input block called CONNECTIONDATA. More...
 
subroutine set_cl1_cl2_from_fleng (this, fleng)
 Using a vector of cell lengths, calculate the cl1 and cl2 arrays. More...
 
subroutine disconnections (this, name_model, nodes, ncol, nrow, nlay, nrsize, delr, delc, top, bot, nodereduced, nodeuser)
 Construct the connectivity arrays for a structured three-dimensional grid. More...
 
subroutine disvconnections (this, name_model, nodes, ncpl, nlay, nrsize, nvert, vertex, iavert, javert, cellxy, top, bot, nodereduced, nodeuser)
 Construct the connectivity arrays using cell disv information. More...
 
subroutine disuconnections (this, name_model, nodes, nodesuser, nrsize, nodereduced, nodeuser, iainp, jainp, ihcinp, cl12inp, hwvainp, angldegxinp, iangledegx)
 Construct the connectivity arrays using disu information. Grid may be reduced. More...
 
subroutine disv1dconnections_verts (this, name_model, nodes, nodesuser, nrsize, nvert, vertices, iavert, javert, cellxyz, cellfdc, nodereduced, nodeuser, reach_length)
 Fill the connections object for a disv1d package from vertices. More...
 
subroutine fill_disv1d_symarrays (ia, ja, jas, reach_length, ihc, cl1, cl2)
 Fill symmetric connection arrays for disv1d. More...
 
subroutine iajausr (this, nrsize, nodesuser, nodereduced, nodeuser)
 Fill iausr and jausr if reduced grid, otherwise point them to ia and ja. More...
 
integer(i4b) function getjaindex (this, node1, node2)
 Get the index in the JA array corresponding to the connection between two nodes of interest. More...
 
subroutine, public fillisym (neq, nja, ia, ja, isym)
 Function to fill the isym array. More...
 
subroutine, public filljas (neq, nja, ia, ja, isym, jas)
 Function to fill the jas array. More...
 
subroutine vertexconnect (nodes, nrsize, maxnnz, nlay, ncpl, sparse, vertcellspm, cell1, cell2, nodereduced)
 Routine to make cell connections from vertices. More...
 
subroutine vertexconnectl (nodes, nrsize, maxnnz, nodeuser, sparse, iavertcells, javertcells, nodereduced)
 Routine to make cell connections from vertices for a linear network. More...
 
subroutine set_mask (this, ipos, maskval)
 routine to set a value in the mask array (which has the same shape as thisja) More...
 
subroutine, public iac_to_ia (iac, ia)
 Convert an iac array into an ia array. More...
 

Function/Subroutine Documentation

◆ allocate_arrays()

subroutine connectionsmodule::allocate_arrays ( class(connectionstype this)

Definition at line 139 of file Connections.f90.

141  ! -- dummy
142  class(ConnectionsType) :: this
143  !
144  ! -- allocate space for connection arrays
145  call mem_allocate(this%ia, this%nodes + 1, 'IA', this%memoryPath)
146  call mem_allocate(this%ja, this%nja, 'JA', this%memoryPath)
147  call mem_allocate(this%isym, this%nja, 'ISYM', this%memoryPath)
148  call mem_allocate(this%jas, this%nja, 'JAS', this%memoryPath)
149  call mem_allocate(this%hwva, this%njas, 'HWVA', this%memoryPath)
150  call mem_allocate(this%anglex, this%njas, 'ANGLEX', this%memoryPath)
151  call mem_allocate(this%ihc, this%njas, 'IHC', this%memoryPath)
152  call mem_allocate(this%cl1, this%njas, 'CL1', this%memoryPath)
153  call mem_allocate(this%cl2, this%njas, 'CL2', this%memoryPath)
154  call mem_allocate(this%iausr, 1, 'IAUSR', this%memoryPath)
155  call mem_allocate(this%jausr, 1, 'JAUSR', this%memoryPath)
156  !
157  ! -- let mask point to ja, which is always nonzero,
158  ! until someone decides to do a 'set_mask'
159  this%mask => this%ja
160  !
161  ! -- Return
162  return

◆ allocate_scalars()

subroutine connectionsmodule::allocate_scalars ( class(connectionstype this,
character(len=*), intent(in)  name_model 
)

Definition at line 111 of file Connections.f90.

112  ! -- modules
115  ! -- dummy
116  class(ConnectionsType) :: this
117  character(len=*), intent(in) :: name_model
118  !
119  ! -- allocate
120  allocate (this%name_model)
121  !
122  this%memoryPath = create_mem_path(name_model, 'CON')
123  call mem_allocate(this%nodes, 'NODES', this%memoryPath)
124  call mem_allocate(this%nja, 'NJA', this%memoryPath)
125  call mem_allocate(this%njas, 'NJAS', this%memoryPath)
126  call mem_allocate(this%ianglex, 'IANGLEX', this%memoryPath)
127  this%name_model = name_model
128  this%nodes = 0
129  this%nja = 0
130  this%njas = 0
131  this%ianglex = 0
132  !
133  ! -- Return
134  return
character(len=lenmempath) function create_mem_path(component, subcomponent, context)
returns the path to the memory object
Here is the call graph for this function:

◆ con_da()

subroutine connectionsmodule::con_da ( class(connectionstype this)
private

Definition at line 61 of file Connections.f90.

62  ! -- modules
64  ! -- dummy
65  class(ConnectionsType) :: this
66  !
67  ! -- Strings
68  deallocate (this%name_model)
69  !
70  ! -- Scalars
71  call mem_deallocate(this%nodes)
72  call mem_deallocate(this%nja)
73  call mem_deallocate(this%njas)
74  call mem_deallocate(this%ianglex)
75  !
76  ! -- iausr and jausr
77  if (associated(this%iausr, this%ia)) then
78  nullify (this%iausr)
79  else
80  call mem_deallocate(this%iausr)
81  end if
82  if (associated(this%jausr, this%ja)) then
83  nullify (this%jausr)
84  else
85  call mem_deallocate(this%jausr)
86  end if
87  ! -- mask
88  if (associated(this%mask, this%ja)) then
89  nullify (this%mask)
90  else
91  call mem_deallocate(this%mask)
92  end if
93  !
94  ! -- Arrays
95  call mem_deallocate(this%ia)
96  call mem_deallocate(this%ja)
97  call mem_deallocate(this%isym)
98  call mem_deallocate(this%jas)
99  call mem_deallocate(this%hwva)
100  call mem_deallocate(this%anglex)
101  call mem_deallocate(this%ihc)
102  call mem_deallocate(this%cl1)
103  call mem_deallocate(this%cl2)
104  !
105  ! -- Return
106  return

◆ con_finalize()

subroutine connectionsmodule::con_finalize ( class(connectionstype this,
integer(i4b), dimension(:), intent(in)  ihctemp,
real(dp), dimension(:), intent(in)  cl12temp,
real(dp), dimension(:), intent(in)  hwvatemp,
real(dp), dimension(:), intent(in)  angldegx 
)

Definition at line 167 of file Connections.f90.

168  ! -- modules
171  ! -- dummy
172  class(ConnectionsType) :: this
173  integer(I4B), dimension(:), intent(in) :: ihctemp
174  real(DP), dimension(:), intent(in) :: cl12temp
175  real(DP), dimension(:), intent(in) :: hwvatemp
176  real(DP), dimension(:), intent(in) :: angldegx
177  ! -- local
178  integer(I4B) :: ii, n, m
179  integer(I4B), parameter :: nname = 6
180  character(len=24), dimension(nname) :: aname(nname)
181  ! -- formats
182  character(len=*), parameter :: fmtsymerr = &
183  &"('Error in array: ',a,'.', &
184  &' Array is not symmetric in positions: ',i0,' and ',i0,'.', &
185  &' Values in these positions are: ',1pg15.6,' and ', 1pg15.6, &
186  &' For node ',i0,' connected to node ',i0)"
187  character(len=*), parameter :: fmtsymerrja = &
188  &"('Error in array: ',a,'.', &
189  &' Array does not have symmetric counterpart in position ',i0, &
190  &' for cell ',i0,' connected to cell ',i0)"
191  character(len=*), parameter :: fmtjanmerr = &
192  &"('Error in array: ',a,'.', &
193  &' First value for cell : ',i0,' must equal ',i0,'.', &
194  &' Found ',i0,' instead.')"
195  character(len=*), parameter :: fmtjasorterr = &
196  &"('Error in array: ',a,'.', &
197  &' Entries not sorted for row: ',i0,'.', &
198  &' Offending entries are: ',i0,' and ',i0)"
199  character(len=*), parameter :: fmtihcerr = &
200  "('IHC must be 0, 1, or 2. Found: ',i0)"
201  ! -- data
202  data aname(1)/' IAC'/
203  data aname(2)/' JA'/
204  data aname(3)/' IHC'/
205  data aname(4)/' CL12'/
206  data aname(5)/' HWVA'/
207  data aname(6)/' ANGLDEGX'/
208  !
209  ! -- Convert any negative ja numbers to positive
210  do ii = 1, this%nja
211  if (this%ja(ii) < 0) this%ja(ii) = -this%ja(ii)
212  end do
213  !
214  ! -- Ensure ja is sorted with the row column listed first
215  do n = 1, this%nodes
216  m = this%ja(this%ia(n))
217  if (n /= m) then
218  write (errmsg, fmtjanmerr) trim(adjustl(aname(2))), n, n, m
219  call store_error(errmsg)
220  end if
221  do ii = this%ia(n) + 1, this%ia(n + 1) - 2
222  m = this%ja(ii)
223  if (m > this%ja(ii + 1)) then
224  write (errmsg, fmtjasorterr) trim(adjustl(aname(2))), n, &
225  m, this%ja(ii + 1)
226  call store_error(errmsg)
227  end if
228  end do
229  end do
230  if (count_errors() > 0) then
231  call this%parser%StoreErrorUnit()
232  end if
233  !
234  ! -- fill the isym arrays
235  call fillisym(this%nodes, this%nja, this%ia, this%ja, this%isym)
236  !
237  ! -- check for symmetry in ja (isym value of zero indicates there is no
238  ! symmetric connection
239  do n = 1, this%nodes
240  do ii = this%ia(n), this%ia(n + 1) - 1
241  m = this%ja(ii)
242  if (this%isym(ii) == 0) then
243  write (errmsg, fmtsymerrja) trim(adjustl(aname(2))), ii, n, m
244  call store_error(errmsg)
245  end if
246  end do
247  end do
248  if (count_errors() > 0) then
249  call this%parser%StoreErrorUnit()
250  end if
251  !
252  ! -- Fill the jas array, which maps any connection to upper triangle
253  call filljas(this%nodes, this%nja, this%ia, this%ja, this%isym, this%jas)
254  !
255  ! -- Put into symmetric array
256  do n = 1, this%nodes
257  do ii = this%ia(n) + 1, this%ia(n + 1) - 1
258  m = this%ja(ii)
259  if (ihctemp(ii) /= ihctemp(this%isym(ii))) then
260  write (errmsg, fmtsymerr) trim(adjustl(aname(3))), ii, this%isym(ii), &
261  ihctemp(ii), ihctemp(this%isym(ii)), n, m
262  call store_error(errmsg)
263  else
264  this%ihc(this%jas(ii)) = ihctemp(ii)
265  end if
266  end do
267  end do
268  if (count_errors() > 0) then
269  call this%parser%StoreErrorUnit()
270  end if
271  !
272  ! -- Put cl12 into symmetric arrays cl1 and cl2
273  do n = 1, this%nodes
274  do ii = this%ia(n) + 1, this%ia(n + 1) - 1
275  m = this%ja(ii)
276  if (m > n) then
277  this%cl1(this%jas(ii)) = cl12temp(ii)
278  elseif (n > m) then
279  this%cl2(this%jas(ii)) = cl12temp(ii)
280  end if
281  end do
282  end do
283  !
284  ! -- Put HWVA into symmetric array based on the value of IHC
285  ! IHC = 0, vertical connection, HWVA is vertical flow area
286  ! IHC = 1, horizontal connection, HWVA is the width perpendicular to
287  ! flow
288  ! IHC = 2, horizontal connection for a vertically staggered grid.
289  ! HWVA is the width perpendicular to flow.
290  do n = 1, this%nodes
291  do ii = this%ia(n) + 1, this%ia(n + 1) - 1
292  m = this%ja(ii)
293  if (hwvatemp(ii) /= hwvatemp(this%isym(ii))) then
294  write (errmsg, fmtsymerr) trim(adjustl(aname(5))), ii, this%isym(ii), &
295  hwvatemp(ii), hwvatemp(this%isym(ii)), n, m
296  call store_error(errmsg)
297  end if
298  if (ihctemp(ii) < 0 .or. ihctemp(ii) > 2) then
299  write (errmsg, fmtihcerr) ihctemp(ii)
300  call store_error(errmsg)
301  end if
302  this%hwva(this%jas(ii)) = hwvatemp(ii)
303  end do
304  end do
305  if (count_errors() > 0) then
306  call this%parser%StoreErrorUnit()
307  end if
308  !
309  ! -- Put anglextemp into this%anglex; store only upper triangle
310  if (this%ianglex /= 0) then
311  do n = 1, this%nodes
312  do ii = this%ia(n) + 1, this%ia(n + 1) - 1
313  m = this%ja(ii)
314  if (n > m) cycle
315  this%anglex(this%jas(ii)) = angldegx(ii) * dpio180
316  end do
317  end do
318  else
319  do n = 1, size(this%anglex)
320  this%anglex(n) = dnodata
321  end do
322  end if
323  !
324  ! -- Return
325  return
This module contains simulation constants.
Definition: Constants.f90:9
integer(i4b), parameter linelength
maximum length of a standard line
Definition: Constants.f90:44
real(dp), parameter dnodata
real no data constant
Definition: Constants.f90:94
real(dp), parameter dhalf
real constant 1/2
Definition: Constants.f90:67
real(dp), parameter dpio180
real constant
Definition: Constants.f90:129
real(dp), parameter done
real constant 1
Definition: Constants.f90:75
This module contains simulation methods.
Definition: Sim.f90:10
subroutine, public store_error(msg, terminate)
Store an error message.
Definition: Sim.f90:92
integer(i4b) function, public count_errors()
Return number of errors.
Definition: Sim.f90:59
subroutine, public store_error_unit(iunit, terminate)
Store the file unit number.
Definition: Sim.f90:168
Here is the call graph for this function:

◆ disconnections()

subroutine connectionsmodule::disconnections ( class(connectionstype this,
character(len=*), intent(in)  name_model,
integer(i4b), intent(in)  nodes,
integer(i4b), intent(in)  ncol,
integer(i4b), intent(in)  nrow,
integer(i4b), intent(in)  nlay,
integer(i4b), intent(in)  nrsize,
real(dp), dimension(ncol), intent(in)  delr,
real(dp), dimension(nrow), intent(in)  delc,
real(dp), dimension(nodes), intent(in)  top,
real(dp), dimension(nodes), intent(in)  bot,
integer(i4b), dimension(:), intent(in), target  nodereduced,
integer(i4b), dimension(:), intent(in)  nodeuser 
)

Definition at line 479 of file Connections.f90.

482  ! -- modules
483  use constantsmodule, only: dhalf, dzero, dthree, dtwo, dpi
484  use sparsemodule, only: sparsematrix
485  ! -- dummy
486  class(ConnectionsType) :: this
487  character(len=*), intent(in) :: name_model
488  integer(I4B), intent(in) :: nodes
489  integer(I4B), intent(in) :: ncol
490  integer(I4B), intent(in) :: nrow
491  integer(I4B), intent(in) :: nlay
492  integer(I4B), intent(in) :: nrsize
493  real(DP), dimension(ncol), intent(in) :: delr
494  real(DP), dimension(nrow), intent(in) :: delc
495  real(DP), dimension(nodes), intent(in) :: top
496  real(DP), dimension(nodes), intent(in) :: bot
497  integer(I4B), dimension(:), target, intent(in) :: nodereduced
498  integer(I4B), dimension(:), intent(in) :: nodeuser
499  ! -- local
500  integer(I4B), dimension(:, :, :), pointer :: nrdcd_ptr => null() !non-contiguous because is a slice
501  integer(I4B), dimension(:), allocatable :: rowmaxnnz
502  type(sparsematrix) :: sparse
503  integer(I4B) :: i, j, k, kk, ierror, isympos, nodesuser
504  integer(I4B) :: nr, mr
505  !
506  ! -- Allocate scalars
507  call this%allocate_scalars(name_model)
508  !
509  ! -- Set scalars
510  this%nodes = nodes
511  this%ianglex = 1
512  !
513  ! -- Setup the sparse matrix object
514  allocate (rowmaxnnz(this%nodes))
515  do i = 1, this%nodes
516  rowmaxnnz(i) = 6
517  end do
518  call sparse%init(this%nodes, this%nodes, rowmaxnnz)
519  !
520  ! -- Create a 3d pointer to nodereduced for easier processing
521  if (nrsize /= 0) then
522  nrdcd_ptr(1:ncol, 1:nrow, 1:nlay) => nodereduced
523  end if
524  !
525  ! -- Add connections to sparse
526  do k = 1, nlay
527  do i = 1, nrow
528  do j = 1, ncol
529  !
530  ! -- Find the reduced node number and then cycle if the
531  ! node is always inactive
532  if (nrsize == 0) then
533  nr = get_node(k, i, j, nlay, nrow, ncol)
534  else
535  nr = nrdcd_ptr(j, i, k)
536  end if
537  if (nr <= 0) cycle
538  !
539  ! -- Process diagonal
540  call sparse%addconnection(nr, nr, 1)
541  !
542  ! -- Up direction
543  if (k > 1) then
544  do kk = k - 1, 1, -1
545  if (nrsize == 0) then
546  mr = get_node(kk, i, j, nlay, nrow, ncol)
547  else
548  mr = nrdcd_ptr(j, i, kk)
549  end if
550  if (mr >= 0) exit
551  end do
552  if (mr > 0) then
553  call sparse%addconnection(nr, mr, 1)
554  end if
555  end if
556  !
557  ! -- Back direction
558  if (i > 1) then
559  if (nrsize == 0) then
560  mr = get_node(k, i - 1, j, nlay, nrow, ncol)
561  else
562  mr = nrdcd_ptr(j, i - 1, k)
563  end if
564  if (mr > 0) then
565  call sparse%addconnection(nr, mr, 1)
566  end if
567  end if
568  !
569  ! -- Left direction
570  if (j > 1) then
571  if (nrsize == 0) then
572  mr = get_node(k, i, j - 1, nlay, nrow, ncol)
573  else
574  mr = nrdcd_ptr(j - 1, i, k)
575  end if
576  if (mr > 0) then
577  call sparse%addconnection(nr, mr, 1)
578  end if
579  end if
580  !
581  ! -- Right direction
582  if (j < ncol) then
583  if (nrsize == 0) then
584  mr = get_node(k, i, j + 1, nlay, nrow, ncol)
585  else
586  mr = nrdcd_ptr(j + 1, i, k)
587  end if
588  if (mr > 0) then
589  call sparse%addconnection(nr, mr, 1)
590  end if
591  end if
592  !
593  ! -- Front direction
594  if (i < nrow) then !front
595  if (nrsize == 0) then
596  mr = get_node(k, i + 1, j, nlay, nrow, ncol)
597  else
598  mr = nrdcd_ptr(j, i + 1, k)
599  end if
600  if (mr > 0) then
601  call sparse%addconnection(nr, mr, 1)
602  end if
603  end if
604  !
605  ! -- Down direction
606  if (k < nlay) then
607  do kk = k + 1, nlay
608  if (nrsize == 0) then
609  mr = get_node(kk, i, j, nlay, nrow, ncol)
610  else
611  mr = nrdcd_ptr(j, i, kk)
612  end if
613  if (mr >= 0) exit
614  end do
615  if (mr > 0) then
616  call sparse%addconnection(nr, mr, 1)
617  end if
618  end if
619  end do
620  end do
621  end do
622  this%nja = sparse%nnz
623  this%njas = (this%nja - this%nodes) / 2
624  !
625  ! -- Allocate index arrays of size nja and symmetric arrays
626  call this%allocate_arrays()
627  !
628  ! -- Fill the IA and JA arrays from sparse, then destroy sparse
629  call sparse%filliaja(this%ia, this%ja, ierror)
630  call sparse%destroy()
631  !
632  ! -- fill the isym and jas arrays
633  call fillisym(this%nodes, this%nja, this%ia, this%ja, this%isym)
634  call filljas(this%nodes, this%nja, this%ia, this%ja, this%isym, this%jas)
635  !
636  ! -- Fill symmetric discretization arrays (ihc,cl1,cl2,hwva,anglex)
637  isympos = 1
638  do k = 1, nlay
639  do i = 1, nrow
640  do j = 1, ncol
641  !
642  ! -- cycle if node is always inactive
643  if (nrsize == 0) then
644  nr = get_node(k, i, j, nlay, nrow, ncol)
645  else
646  nr = nrdcd_ptr(j, i, k)
647  end if
648  if (nr <= 0) cycle
649  !
650  ! -- right connection
651  if (j < ncol) then
652  if (nrsize == 0) then
653  mr = get_node(k, i, j + 1, nlay, nrow, ncol)
654  else
655  mr = nrdcd_ptr(j + 1, i, k)
656  end if
657  if (mr > 0) then
658  this%ihc(isympos) = 1
659  this%cl1(isympos) = dhalf * delr(j)
660  this%cl2(isympos) = dhalf * delr(j + 1)
661  this%hwva(isympos) = delc(i)
662  this%anglex(isympos) = dzero
663  isympos = isympos + 1
664  end if
665  end if
666  !
667  ! -- front connection
668  if (i < nrow) then
669  if (nrsize == 0) then
670  mr = get_node(k, i + 1, j, nlay, nrow, ncol)
671  else
672  mr = nrdcd_ptr(j, i + 1, k)
673  end if
674  if (mr > 0) then
675  this%ihc(isympos) = 1
676  this%cl1(isympos) = dhalf * delc(i)
677  this%cl2(isympos) = dhalf * delc(i + 1)
678  this%hwva(isympos) = delr(j)
679  this%anglex(isympos) = dthree / dtwo * dpi
680  isympos = isympos + 1
681  end if
682  end if
683  !
684  ! -- down connection
685  if (k < nlay) then
686  do kk = k + 1, nlay
687  if (nrsize == 0) then
688  mr = get_node(kk, i, j, nlay, nrow, ncol)
689  else
690  mr = nrdcd_ptr(j, i, kk)
691  end if
692  if (mr >= 0) exit
693  end do
694  if (mr > 0) then
695  this%ihc(isympos) = 0
696  this%cl1(isympos) = dhalf * (top(nr) - bot(nr))
697  this%cl2(isympos) = dhalf * (top(mr) - bot(mr))
698  this%hwva(isympos) = delr(j) * delc(i)
699  this%anglex(isympos) = dzero
700  isympos = isympos + 1
701  end if
702  end if
703  end do
704  end do
705  end do
706  !
707  ! -- Deallocate temporary arrays
708  deallocate (rowmaxnnz)
709  !
710  ! -- If reduced system, then need to build iausr and jausr, otherwise point
711  ! them to ia and ja.
712  nodesuser = nlay * nrow * ncol
713  call this%iajausr(nrsize, nodesuser, nodereduced, nodeuser)
714  !
715  ! -- Return
716  return
real(dp), parameter dpi
real constant
Definition: Constants.f90:127
real(dp), parameter dzero
real constant zero
Definition: Constants.f90:64
real(dp), parameter dtwo
real constant 2
Definition: Constants.f90:78
real(dp), parameter dthree
real constant 3
Definition: Constants.f90:79
Here is the call graph for this function:

◆ disuconnections()

subroutine connectionsmodule::disuconnections ( class(connectionstype this,
character(len=*), intent(in)  name_model,
integer(i4b), intent(in)  nodes,
integer(i4b), intent(in)  nodesuser,
integer(i4b), intent(in)  nrsize,
integer(i4b), dimension(:), intent(in), contiguous  nodereduced,
integer(i4b), dimension(:), intent(in), contiguous  nodeuser,
integer(i4b), dimension(:), intent(in), contiguous  iainp,
integer(i4b), dimension(:), intent(in), contiguous  jainp,
integer(i4b), dimension(:), intent(in), contiguous  ihcinp,
real(dp), dimension(:), intent(in), contiguous  cl12inp,
real(dp), dimension(:), intent(in), contiguous  hwvainp,
real(dp), dimension(:), intent(in), contiguous  angldegxinp,
integer(i4b), intent(in)  iangledegx 
)

Definition at line 823 of file Connections.f90.

827  ! -- modules
828  use constantsmodule, only: dhalf, dzero, dthree, dtwo, dpi
829  use sparsemodule, only: sparsematrix
831  ! -- dummy
832  class(ConnectionsType) :: this
833  character(len=*), intent(in) :: name_model
834  integer(I4B), intent(in) :: nodes
835  integer(I4B), intent(in) :: nodesuser
836  integer(I4B), intent(in) :: nrsize
837  integer(I4B), dimension(:), contiguous, intent(in) :: nodereduced
838  integer(I4B), dimension(:), contiguous, intent(in) :: nodeuser
839  integer(I4B), dimension(:), contiguous, intent(in) :: iainp
840  integer(I4B), dimension(:), contiguous, intent(in) :: jainp
841  integer(I4B), dimension(:), contiguous, intent(in) :: ihcinp
842  real(DP), dimension(:), contiguous, intent(in) :: cl12inp
843  real(DP), dimension(:), contiguous, intent(in) :: hwvainp
844  real(DP), dimension(:), contiguous, intent(in) :: angldegxinp
845  integer(I4B), intent(in) :: iangledegx
846  ! -- local
847  integer(I4B), dimension(:), allocatable :: ihctemp
848  real(DP), dimension(:), allocatable :: cl12temp
849  real(DP), dimension(:), allocatable :: hwvatemp
850  real(DP), dimension(:), allocatable :: angldegxtemp
851  integer(I4B) :: nr, nu, mr, mu, ipos, iposr, ierror
852  integer(I4B), dimension(:), allocatable :: rowmaxnnz
853  type(sparsematrix) :: sparse
854  !
855  ! -- Allocate scalars
856  call this%allocate_scalars(name_model)
857  !
858  ! -- Set scalars
859  this%nodes = nodes
860  this%ianglex = iangledegx
861  !
862  ! -- If not a reduced grid, then copy and finalize, otherwise more
863  ! processing is required
864  if (nrsize == 0) then
865  this%nodes = nodes
866  this%nja = size(jainp)
867  this%njas = (this%nja - this%nodes) / 2
868  call this%allocate_arrays()
869  do nu = 1, nodes + 1
870  this%ia(nu) = iainp(nu)
871  end do
872  do ipos = 1, this%nja
873  this%ja(ipos) = jainp(ipos)
874  end do
875  !
876  ! -- Call con_finalize to check inp arrays and push larger arrays
877  ! into compressed symmetric arrays
878  call this%con_finalize(ihcinp, cl12inp, hwvainp, angldegxinp)
879  !
880  else
881  ! -- reduced system requires more work
882  !
883  ! -- Setup the sparse matrix object
884  allocate (rowmaxnnz(this%nodes))
885  do nr = 1, this%nodes
886  nu = nodeuser(nr)
887  rowmaxnnz(nr) = iainp(nu + 1) - iainp(nu)
888  end do
889  call sparse%init(this%nodes, this%nodes, rowmaxnnz)
890  !
891  ! -- go through user connectivity and create sparse
892  do nu = 1, nodesuser
893  nr = nodereduced(nu)
894  if (nr > 0) call sparse%addconnection(nr, nr, 1)
895  do ipos = iainp(nu) + 1, iainp(nu + 1) - 1
896  mu = jainp(ipos)
897  mr = nodereduced(mu)
898  if (nr < 1) cycle
899  if (mr < 1) cycle
900  call sparse%addconnection(nr, mr, 1)
901  end do
902  end do
903  this%nja = sparse%nnz
904  this%njas = (this%nja - this%nodes) / 2
905  !
906  ! -- Allocate index arrays of size nja and symmetric arrays
907  call this%allocate_arrays()
908  !
909  ! -- Fill the IA and JA arrays from sparse, then destroy sparse
910  call sparse%sort()
911  call sparse%filliaja(this%ia, this%ja, ierror)
912  call sparse%destroy()
913  deallocate (rowmaxnnz)
914  !
915  ! -- At this point, need to reduce ihc, cl12, hwva, and angldegx
916  allocate (ihctemp(this%nja))
917  allocate (cl12temp(this%nja))
918  allocate (hwvatemp(this%nja))
919  allocate (angldegxtemp(this%nja))
920  !
921  ! -- Compress user arrays into reduced arrays
922  iposr = 1
923  do nu = 1, nodesuser
924  nr = nodereduced(nu)
925  do ipos = iainp(nu), iainp(nu + 1) - 1
926  mu = jainp(ipos)
927  mr = nodereduced(mu)
928  if (nr < 1 .or. mr < 1) cycle
929  ihctemp(iposr) = ihcinp(ipos)
930  cl12temp(iposr) = cl12inp(ipos)
931  hwvatemp(iposr) = hwvainp(ipos)
932  angldegxtemp(iposr) = angldegxinp(ipos)
933  iposr = iposr + 1
934  end do
935  end do
936  !
937  ! -- call finalize
938  call this%con_finalize(ihctemp, cl12temp, hwvatemp, angldegxtemp)
939  !
940  ! -- deallocate temporary arrays
941  deallocate (ihctemp)
942  deallocate (cl12temp)
943  deallocate (hwvatemp)
944  deallocate (angldegxtemp)
945  end if
946  !
947  ! -- If reduced system, then need to build iausr and jausr, otherwise point
948  ! them to ia and ja.
949  call this%iajausr(nrsize, nodesuser, nodereduced, nodeuser)
950  !
951  ! -- Return
952  return

◆ disv1dconnections_verts()

subroutine connectionsmodule::disv1dconnections_verts ( class(connectionstype this,
character(len=*), intent(in)  name_model,
integer(i4b), intent(in)  nodes,
integer(i4b), intent(in)  nodesuser,
integer(i4b), intent(in)  nrsize,
integer(i4b), intent(in)  nvert,
real(dp), dimension(3, nvert), intent(in)  vertices,
integer(i4b), dimension(:), intent(in)  iavert,
integer(i4b), dimension(:), intent(in)  javert,
real(dp), dimension(3, nodesuser), intent(in)  cellxyz,
real(dp), dimension(nodesuser), intent(in)  cellfdc,
integer(i4b), dimension(:), intent(in)  nodereduced,
integer(i4b), dimension(:), intent(in)  nodeuser,
real(dp), dimension(:), intent(in)  reach_length 
)

todo: Still need to handle hwva todo: Only unreduced disv1d grids are allowed at the moment

Parameters
[in]reach_lengthlength of each reach

Definition at line 961 of file Connections.f90.

966  ! -- modules
967  use constantsmodule, only: dhalf, dzero, dthree, dtwo, dpi
968  use sparsemodule, only: sparsematrix
969  use geomutilmodule, only: get_node
971  ! -- dummy
972  class(ConnectionsType) :: this
973  character(len=*), intent(in) :: name_model
974  integer(I4B), intent(in) :: nodes
975  integer(I4B), intent(in) :: nodesuser
976  integer(I4B), intent(in) :: nrsize
977  integer(I4B), intent(in) :: nvert
978  real(DP), dimension(3, nvert), intent(in) :: vertices
979  integer(I4B), dimension(:), intent(in) :: iavert
980  integer(I4B), dimension(:), intent(in) :: javert
981  real(DP), dimension(3, nodesuser), intent(in) :: cellxyz
982  !integer(I4B), dimension(2, nodesuser), intent(in) :: centerverts
983  real(DP), dimension(nodesuser), intent(in) :: cellfdc
984  integer(I4B), dimension(:), intent(in) :: nodereduced
985  integer(I4B), dimension(:), intent(in) :: nodeuser
986  real(DP), dimension(:), intent(in) :: reach_length !< length of each reach
987  ! -- local
988  integer(I4B), dimension(:), allocatable :: itemp
989  integer(I4B), dimension(:), allocatable :: iavertcells
990  integer(I4B), dimension(:), allocatable :: javertcells
991  type(sparsematrix) :: sparse, vertcellspm
992  integer(I4B) :: n, m, i, j, ierror
993  !
994  ! -- Allocate scalars
995  call this%allocate_scalars(name_model)
996  !
997  ! -- Set scalars
998  this%nodes = nodes
999  this%ianglex = 1
1000  !
1001  ! -- Create a sparse matrix array with a row for each vertex. The columns
1002  ! in the sparse matrix contains the cells that include that vertex.
1003  ! This array will be used to determine cell connectivity.
1004  allocate (itemp(nvert))
1005  do i = 1, nvert
1006  itemp(i) = 4
1007  end do
1008  call vertcellspm%init(nvert, nodes, itemp)
1009  deallocate (itemp)
1010  do j = 1, nodes
1011  do i = iavert(j), iavert(j + 1) - 1
1012  call vertcellspm%addconnection(javert(i), j, 1)
1013  end do
1014  end do
1015  call vertcellspm%sort()
1016  allocate (iavertcells(nvert + 1))
1017  allocate (javertcells(vertcellspm%nnz))
1018  call vertcellspm%filliaja(iavertcells, javertcells, ierror)
1019  call vertcellspm%destroy()
1020  !
1021  ! -- Call routine to build a sparse matrix of the connections
1022  call vertexconnectl(this%nodes, nrsize, 6, nodes, sparse, &
1023  iavertcells, javertcells, nodereduced)
1024  n = sparse%nnz
1025  m = this%nodes
1026  this%nja = sparse%nnz
1027  this%njas = (this%nja - this%nodes) / 2
1028  !
1029  ! -- cleanup memory
1030  deallocate (iavertcells)
1031  deallocate (javertcells)
1032  !
1033  ! -- Allocate index arrays of size nja and symmetric arrays
1034  call this%allocate_arrays()
1035  !
1036  ! -- Fill the IA and JA arrays from sparse, then destroy sparse
1037  call sparse%sort()
1038  call sparse%filliaja(this%ia, this%ja, ierror)
1039  call sparse%destroy()
1040  !
1041  ! -- fill the isym and jas arrays
1042  call fillisym(this%nodes, this%nja, this%ia, this%ja, this%isym)
1043  call filljas(this%nodes, this%nja, this%ia, this%ja, this%isym, this%jas)
1044 
1045  ! Fill disv1d symmetric arrays
1046  ! todo: need to handle cell center shifted from center of reach
1047  call fill_disv1d_symarrays(this%ia, this%ja, this%jas, reach_length, &
1048  this%ihc, this%cl1, this%cl2)
1049 
1050  !
1051  ! -- Fill symmetric discretization arrays (ihc,cl1,cl2,hwva,anglex)
1052  ! do n = 1, this%nodes
1053  ! do ipos = this%ia(n) + 1, this%ia(n + 1) - 1
1054  ! m = this%ja(ipos)
1055  ! if(m < n) cycle
1056  ! call geol%cprops(n, m, this%hwva(this%jas(ipos)), &
1057  ! this%cl1(this%jas(ipos)), this%cl2(this%jas(ipos)))
1058  ! enddo
1059  ! enddo
1060 
1061  !
1062  ! -- If reduced system, then need to build iausr and jausr, otherwise point
1063  ! them to ia and ja.
1064  call this%iajausr(nrsize, nodesuser, nodereduced, nodeuser)
1065  !
1066  ! -- Return
1067  return
integer(i4b) function, public get_node(ilay, irow, icol, nlay, nrow, ncol)
Get node number, given layer, row, and column indices for a structured grid. If any argument is inval...
Definition: GeomUtil.f90:80
Here is the call graph for this function:

◆ disvconnections()

subroutine connectionsmodule::disvconnections ( class(connectionstype this,
character(len=*), intent(in)  name_model,
integer(i4b), intent(in)  nodes,
integer(i4b), intent(in)  ncpl,
integer(i4b), intent(in)  nlay,
integer(i4b), intent(in)  nrsize,
integer(i4b), intent(in)  nvert,
real(dp), dimension(2, nvert), intent(in)  vertex,
integer(i4b), dimension(:), intent(in)  iavert,
integer(i4b), dimension(:), intent(in)  javert,
real(dp), dimension(2, ncpl), intent(in)  cellxy,
real(dp), dimension(nodes), intent(in)  top,
real(dp), dimension(nodes), intent(in)  bot,
integer(i4b), dimension(:), intent(in)  nodereduced,
integer(i4b), dimension(:), intent(in)  nodeuser 
)

Definition at line 721 of file Connections.f90.

724  ! -- modules
725  use constantsmodule, only: dhalf, dzero, dthree, dtwo, dpi
726  use sparsemodule, only: sparsematrix
727  use disvgeom, only: disvgeomtype
729  ! -- dummy
730  class(ConnectionsType) :: this
731  character(len=*), intent(in) :: name_model
732  integer(I4B), intent(in) :: nodes
733  integer(I4B), intent(in) :: ncpl
734  integer(I4B), intent(in) :: nlay
735  integer(I4B), intent(in) :: nrsize
736  integer(I4B), intent(in) :: nvert
737  real(DP), dimension(2, nvert), intent(in) :: vertex
738  integer(I4B), dimension(:), intent(in) :: iavert
739  integer(I4B), dimension(:), intent(in) :: javert
740  real(DP), dimension(2, ncpl), intent(in) :: cellxy
741  real(DP), dimension(nodes), intent(in) :: top
742  real(DP), dimension(nodes), intent(in) :: bot
743  integer(I4B), dimension(:), intent(in) :: nodereduced
744  integer(I4B), dimension(:), intent(in) :: nodeuser
745  ! -- local
746  integer(I4B), dimension(:), allocatable :: itemp
747  type(sparsematrix) :: sparse, vertcellspm
748  integer(I4B) :: n, m, ipos, i, j, ierror, nodesuser
749  type(DisvGeomType) :: cell1, cell2
750  !
751  ! -- Allocate scalars
752  call this%allocate_scalars(name_model)
753  !
754  ! -- Set scalars
755  this%nodes = nodes
756  this%ianglex = 1
757  !
758  ! -- Initialize DisvGeomType objects
759  call cell1%init(nlay, ncpl, nodes, top, bot, iavert, javert, vertex, &
760  cellxy, nodereduced, nodeuser)
761  call cell2%init(nlay, ncpl, nodes, top, bot, iavert, javert, vertex, &
762  cellxy, nodereduced, nodeuser)
763  !
764  ! -- Create a sparse matrix array with a row for each vertex. The columns
765  ! in the sparse matrix contains the cells that include that vertex.
766  ! This array will be used to determine horizontal cell connectivity.
767  allocate (itemp(nvert))
768  do i = 1, nvert
769  itemp(i) = 4
770  end do
771  call vertcellspm%init(nvert, ncpl, itemp)
772  deallocate (itemp)
773  do j = 1, ncpl
774  do i = iavert(j), iavert(j + 1) - 1
775  call vertcellspm%addconnection(javert(i), j, 1)
776  end do
777  end do
778  !
779  ! -- Call routine to build a sparse matrix of the connections
780  call vertexconnect(this%nodes, nrsize, 6, nlay, ncpl, sparse, &
781  vertcellspm, cell1, cell2, nodereduced)
782  this%nja = sparse%nnz
783  this%njas = (this%nja - this%nodes) / 2
784  !
785  ! -- Allocate index arrays of size nja and symmetric arrays
786  call this%allocate_arrays()
787  !
788  ! -- Fill the IA and JA arrays from sparse, then destroy sparse
789  call sparse%sort()
790  call sparse%filliaja(this%ia, this%ja, ierror)
791  call sparse%destroy()
792  !
793  ! -- fill the isym and jas arrays
794  call fillisym(this%nodes, this%nja, this%ia, this%ja, this%isym)
795  call filljas(this%nodes, this%nja, this%ia, this%ja, this%isym, this%jas)
796  !
797  ! -- Fill symmetric discretization arrays (ihc,cl1,cl2,hwva,anglex)
798  do n = 1, this%nodes
799  call cell1%set_nodered(n)
800  do ipos = this%ia(n) + 1, this%ia(n + 1) - 1
801  m = this%ja(ipos)
802  if (m < n) cycle
803  call cell2%set_nodered(m)
804  call cell1%cprops(cell2, this%hwva(this%jas(ipos)), &
805  this%cl1(this%jas(ipos)), this%cl2(this%jas(ipos)), &
806  this%anglex(this%jas(ipos)), &
807  this%ihc(this%jas(ipos)))
808  end do
809  end do
810  !
811  ! -- If reduced system, then need to build iausr and jausr, otherwise point
812  ! them to ia and ja.
813  nodesuser = nlay * ncpl
814  call this%iajausr(nrsize, nodesuser, nodereduced, nodeuser)
815  !
816  ! -- Return
817  return
Here is the call graph for this function:

◆ fill_disv1d_symarrays()

subroutine connectionsmodule::fill_disv1d_symarrays ( integer(i4b), dimension(:), intent(in)  ia,
integer(i4b), dimension(:), intent(in)  ja,
integer(i4b), dimension(:), intent(in)  jas,
real(dp), dimension(:), intent(in)  reach_length,
integer(i4b), dimension(:), intent(out)  ihc,
real(dp), dimension(:), intent(out)  cl1,
real(dp), dimension(:), intent(out)  cl2 
)
Parameters
[in]iacsr pointer array
[in]jacsr array
[in]jascsr symmetric array
[in]reach_lengthlength of each reach
[out]ihchorizontal connection flag
[out]cl1distance from n to shared face with m
[out]cl2distance from m to shared face with n

Definition at line 1072 of file Connections.f90.

1073  ! dummy
1074  integer(I4B), dimension(:), intent(in) :: ia !< csr pointer array
1075  integer(I4B), dimension(:), intent(in) :: ja !< csr array
1076  integer(I4B), dimension(:), intent(in) :: jas !< csr symmetric array
1077  real(DP), dimension(:), intent(in) :: reach_length !< length of each reach
1078  integer(I4B), dimension(:), intent(out) :: ihc !< horizontal connection flag
1079  real(DP), dimension(:), intent(out) :: cl1 !< distance from n to shared face with m
1080  real(DP), dimension(:), intent(out) :: cl2 !< distance from m to shared face with n
1081  ! local
1082  integer(I4B) :: n
1083  integer(I4B) :: m
1084  integer(I4B) :: ipos
1085  integer(I4B) :: isympos
1086 
1087  ! loop through and set array values
1088  do n = 1, size(reach_length)
1089  do ipos = ia(n) + 1, ia(n + 1) - 1
1090  m = ja(ipos)
1091  if (m < n) cycle
1092  isympos = jas(ipos)
1093  ihc(isympos) = 1
1094  cl1(isympos) = dhalf * reach_length(n)
1095  cl2(isympos) = dhalf * reach_length(m)
1096  end do
1097  end do
Here is the caller graph for this function:

◆ fillisym()

subroutine, public connectionsmodule::fillisym ( integer(i4b), intent(in)  neq,
integer(i4b), intent(in)  nja,
integer(i4b), dimension(neq + 1), intent(in)  ia,
integer(i4b), dimension(nja), intent(in)  ja,
integer(i4b), dimension(nja), intent(inout)  isym 
)

Definition at line 1200 of file Connections.f90.

1201  ! -- dummy
1202  integer(I4B), intent(in) :: neq
1203  integer(I4B), intent(in) :: nja
1204  integer(I4B), intent(inout), dimension(nja) :: isym
1205  ! -- local
1206  integer(I4B), intent(in), dimension(neq + 1) :: ia
1207  integer(I4B), intent(in), dimension(nja) :: ja
1208  integer(I4B) :: n, m, ii, jj
1209  !
1210  do n = 1, neq
1211  do ii = ia(n), ia(n + 1) - 1
1212  m = ja(ii)
1213  if (m /= n) then
1214  isym(ii) = 0
1215  search: do jj = ia(m), ia(m + 1) - 1
1216  if (ja(jj) == n) then
1217  isym(ii) = jj
1218  exit search
1219  end if
1220  end do search
1221  else
1222  isym(ii) = ii
1223  end if
1224  end do
1225  end do
1226  !
1227  ! -- Return
1228  return
Here is the caller graph for this function:

◆ filljas()

subroutine, public connectionsmodule::filljas ( integer(i4b), intent(in)  neq,
integer(i4b), intent(in)  nja,
integer(i4b), dimension(neq + 1), intent(in)  ia,
integer(i4b), dimension(nja), intent(in)  ja,
integer(i4b), dimension(nja), intent(in)  isym,
integer(i4b), dimension(nja), intent(inout)  jas 
)

Definition at line 1233 of file Connections.f90.

1234  ! -- dummy
1235  integer(I4B), intent(in) :: neq
1236  integer(I4B), intent(in) :: nja
1237  integer(I4B), intent(in), dimension(neq + 1) :: ia
1238  integer(I4B), intent(in), dimension(nja) :: ja
1239  integer(I4B), intent(in), dimension(nja) :: isym
1240  integer(I4B), intent(inout), dimension(nja) :: jas
1241  ! -- local
1242  integer(I4B) :: n, m, ii, ipos
1243  !
1244  ! -- set diagonal to zero and fill upper
1245  ipos = 1
1246  do n = 1, neq
1247  jas(ia(n)) = 0
1248  do ii = ia(n) + 1, ia(n + 1) - 1
1249  m = ja(ii)
1250  if (m > n) then
1251  jas(ii) = ipos
1252  ipos = ipos + 1
1253  end if
1254  end do
1255  end do
1256  !
1257  ! -- fill lower
1258  do n = 1, neq
1259  do ii = ia(n), ia(n + 1) - 1
1260  m = ja(ii)
1261  if (m < n) then
1262  jas(ii) = jas(isym(ii))
1263  end if
1264  end do
1265  end do
1266  !
1267  ! -- Return
1268  return
Here is the caller graph for this function:

◆ getjaindex()

integer(i4b) function connectionsmodule::getjaindex ( class(connectionstype this,
integer(i4b), intent(in)  node1,
integer(i4b), intent(in)  node2 
)

Node1 is used as the index in the IA array, and IA(Node1) is the row index in the (nodes x nodes) matrix represented by the compressed sparse row format.

-1 is returned if either node number is invalid. 0 is returned if the two nodes are not connected.

Definition at line 1162 of file Connections.f90.

1163  ! -- return
1164  integer(I4B) :: getjaindex
1165  ! -- dummy
1166  class(ConnectionsType) :: this
1167  integer(I4B), intent(in) :: node1, node2 ! nodes of interest
1168  ! -- local
1169  integer(I4B) :: i
1170  !
1171  ! -- error checking
1172  if (node1 < 1 .or. node1 > this%nodes .or. node2 < 1 .or. &
1173  node2 > this%nodes) then
1174  getjaindex = -1 ! indicates error (an invalid node number)
1175  return
1176  end if
1177  !
1178  ! -- If node1==node2, just return the position for the diagonal.
1179  if (node1 == node2) then
1180  getjaindex = this%ia(node1)
1181  return
1182  end if
1183  !
1184  ! -- Look for connection among nonzero elements defined for row node1.
1185  do i = this%ia(node1) + 1, this%ia(node1 + 1) - 1
1186  if (this%ja(i) == node2) then
1187  getjaindex = i
1188  return
1189  end if
1190  end do
1191  !
1192  ! -- If execution reaches here, no connection exists
1193  ! between nodes of interest.
1194  getjaindex = 0 ! indicates no connection exists
1195  return

◆ iac_to_ia()

subroutine, public connectionsmodule::iac_to_ia ( integer(i4b), dimension(:), intent(in), pointer, contiguous  iac,
integer(i4b), dimension(:), intent(inout), contiguous  ia 
)

Definition at line 1462 of file Connections.f90.

1463  ! -- dummy
1464  integer(I4B), dimension(:), contiguous, pointer, intent(in) :: iac
1465  integer(I4B), dimension(:), contiguous, intent(inout) :: ia
1466  ! -- local
1467  integer(I4B) :: n, nodes
1468  !
1469  ! -- Convert iac to ia
1470  nodes = size(iac)
1471  ia(1) = iac(1)
1472  do n = 2, size(ia) ! size(ia) == size(iac) + 1
1473  if (n < size(ia)) then
1474  ia(n) = iac(n) + ia(n - 1)
1475  else
1476  ia(n) = ia(n) + ia(n - 1)
1477  end if
1478  end do
1479  do n = nodes + 1, 2, -1
1480  ia(n) = ia(n - 1) + 1
1481  end do
1482  ia(1) = 1
1483  !
1484  ! -- Return
1485  return
Here is the caller graph for this function:

◆ iajausr()

subroutine connectionsmodule::iajausr ( class(connectionstype this,
integer(i4b), intent(in)  nrsize,
integer(i4b), intent(in)  nodesuser,
integer(i4b), dimension(:), intent(in)  nodereduced,
integer(i4b), dimension(:), intent(in)  nodeuser 
)
private

Definition at line 1103 of file Connections.f90.

1104  ! -- modules
1106  ! -- dummy
1107  class(ConnectionsType) :: this
1108  integer(I4B), intent(in) :: nrsize
1109  integer(I4B), intent(in) :: nodesuser
1110  integer(I4B), dimension(:), intent(in) :: nodereduced
1111  integer(I4B), dimension(:), intent(in) :: nodeuser
1112  ! -- local
1113  integer(I4B) :: n, nr, ipos
1114  !
1115  ! -- If reduced system, then need to build iausr and jausr, otherwise point
1116  ! them to ia and ja.
1117  if (nrsize > 0) then
1118  !
1119  ! -- Create the iausr array of size nodesuser + 1. For excluded cells,
1120  ! iausr(n) and iausr(n + 1) should be equal to indicate no connections.
1121  call mem_reallocate(this%iausr, nodesuser + 1, 'IAUSR', this%memoryPath)
1122  this%iausr(nodesuser + 1) = this%ia(this%nodes + 1)
1123  do n = nodesuser, 1, -1
1124  nr = nodereduced(n)
1125  if (nr < 1) then
1126  this%iausr(n) = this%iausr(n + 1)
1127  else
1128  this%iausr(n) = this%ia(nr)
1129  end if
1130  end do
1131  !
1132  ! -- Create the jausr array, which is the same size as ja, but it
1133  ! contains user node numbers instead of reduced node numbers
1134  call mem_reallocate(this%jausr, this%nja, 'JAUSR', this%memoryPath)
1135  do ipos = 1, this%nja
1136  nr = this%ja(ipos)
1137  n = nodeuser(nr)
1138  this%jausr(ipos) = n
1139  end do
1140  else
1141  ! -- iausr and jausr will be pointers
1142  call mem_deallocate(this%iausr)
1143  call mem_deallocate(this%jausr)
1144  call mem_setptr(this%iausr, 'IA', this%memoryPath)
1145  call mem_setptr(this%jausr, 'JA', this%memoryPath)
1146  end if
1147  !
1148  ! -- Return
1149  return

◆ read_connectivity_from_block()

subroutine connectionsmodule::read_connectivity_from_block ( class(connectionstype this,
character(len=*), intent(in)  name_model,
integer(i4b), intent(in)  nodes,
integer(i4b), intent(in)  nja,
integer(i4b), intent(in)  iout 
)

Definition at line 331 of file Connections.f90.

332  ! -- modules
333  use constantsmodule, only: linelength
335  ! -- dummy
336  class(ConnectionsType) :: this
337  character(len=*), intent(in) :: name_model
338  integer(I4B), intent(in) :: nodes
339  integer(I4B), intent(in) :: nja
340  integer(I4B), intent(in) :: iout
341  ! -- local
342  character(len=LINELENGTH) :: line
343  character(len=LINELENGTH) :: keyword
344  integer(I4B) :: ii, n, m
345  integer(I4B) :: ierr
346  logical :: isfound, endOfBlock
347  integer(I4B), parameter :: nname = 2
348  logical, dimension(nname) :: lname
349  character(len=24), dimension(nname) :: aname(nname)
350  ! -- formats
351  character(len=*), parameter :: fmtsymerr = &
352  &"(/,'Error in array: ',(a),/, &
353  &'Array is not symmetric in positions: ',2i9,/, &
354  &'Values in these positions are: ', 2(1pg15.6))"
355  character(len=*), parameter :: fmtihcerr = &
356  &"(/,'IHC must be 0, 1, or 2. Found: ',i0)"
357  ! -- data
358  data aname(1)/' IAC'/
359  data aname(2)/' JA'/
360  !
361  ! -- Allocate and initialize dimensions
362  call this%allocate_scalars(name_model)
363  this%nodes = nodes
364  this%nja = nja
365  this%njas = (this%nja - this%nodes) / 2
366  !
367  ! -- Allocate space for connection arrays
368  call this%allocate_arrays()
369  !
370  ! -- get connectiondata block
371  call this%parser%GetBlock('CONNECTIONDATA', isfound, ierr)
372  lname(:) = .false.
373  if (isfound) then
374  write (iout, '(1x,a)') 'PROCESSING CONNECTIONDATA'
375  do
376  call this%parser%GetNextLine(endofblock)
377  if (endofblock) exit
378  call this%parser%GetStringCaps(keyword)
379  select case (keyword)
380  case ('IAC')
381  call readarray(this%parser%iuactive, this%ia, aname(1), 1, &
382  this%nodes, iout, 0)
383  lname(1) = .true.
384  case ('JA')
385  call readarray(this%parser%iuactive, this%ja, aname(2), 1, &
386  this%nja, iout, 0)
387  lname(2) = .true.
388  case default
389  write (errmsg, '(a,a)') &
390  'Unknown CONNECTIONDATA tag: ', trim(keyword)
391  call store_error(errmsg)
392  call this%parser%StoreErrorUnit()
393  end select
394  end do
395  write (iout, '(1x,a)') 'END PROCESSING CONNECTIONDATA'
396  else
397  call store_error('Required CONNECTIONDATA block not found.')
398  call this%parser%StoreErrorUnit()
399  end if
400  !
401  ! -- verify all items were read
402  do n = 1, nname
403  if (.not. lname(n)) then
404  write (errmsg, '(a,a)') &
405  'Required input was not specified: ', aname(n)
406  call store_error(errmsg)
407  end if
408  end do
409  if (count_errors() > 0) then
410  call this%parser%StoreErrorUnit()
411  end if
412  !
413  ! -- Convert iac to ia
414  do n = 2, this%nodes + 1
415  this%ia(n) = this%ia(n) + this%ia(n - 1)
416  end do
417  do n = this%nodes + 1, 2, -1
418  this%ia(n) = this%ia(n - 1) + 1
419  end do
420  this%ia(1) = 1
421  !
422  ! -- Convert any negative ja numbers to positive
423  do ii = 1, this%nja
424  if (this%ja(ii) < 0) this%ja(ii) = -this%ja(ii)
425  end do
426  !
427  ! -- fill the isym and jas arrays
428  call fillisym(this%nodes, this%nja, this%ia, this%ja, this%isym)
429  call filljas(this%nodes, this%nja, this%ia, this%ja, this%isym, &
430  this%jas)
431  !
432  ! -- check for symmetry in ja
433  do n = 1, this%nodes
434  do ii = this%ia(n), this%ia(n + 1) - 1
435  m = this%ja(ii)
436  if (n /= this%ja(this%isym(ii))) then
437  write (line, fmtsymerr) aname(2), ii, this%isym(ii)
438  call write_message(line)
439  call this%parser%StoreErrorUnit()
440  end if
441  end do
442  end do
443  !
444  if (count_errors() > 0) then
445  call this%parser%StoreErrorUnit()
446  end if
447  !
448  ! -- Return
449  return
Here is the call graph for this function:

◆ set_cl1_cl2_from_fleng()

subroutine connectionsmodule::set_cl1_cl2_from_fleng ( class(connectionstype this,
real(dp), dimension(:), intent(in)  fleng 
)

Definition at line 454 of file Connections.f90.

455  ! -- modules
456  use constantsmodule, only: dhalf
457  ! -- dummy
458  class(ConnectionsType) :: this
459  real(DP), dimension(:), intent(in) :: fleng
460  ! -- local
461  integer(I4B) :: n, m, ii
462  !
463  ! -- Fill symmetric arrays cl1 and cl2 from fleng of the node
464  do n = 1, this%nodes
465  do ii = this%ia(n) + 1, this%ia(n + 1) - 1
466  m = this%ja(ii)
467  this%cl1(this%jas(ii)) = fleng(n) * dhalf
468  this%cl2(this%jas(ii)) = fleng(m) * dhalf
469  end do
470  end do
471  !
472  ! -- Return
473  return

◆ set_mask()

subroutine connectionsmodule::set_mask ( class(connectionstype this,
integer(i4b), intent(in)  ipos,
integer(i4b), intent(in)  maskval 
)

Definition at line 1434 of file Connections.f90.

1435  ! -- modules
1437  ! -- dummy
1438  class(ConnectionsType) :: this
1439  integer(I4B), intent(in) :: ipos
1440  integer(I4B), intent(in) :: maskval
1441  ! -- local
1442  integer(I4B) :: i
1443  !
1444  ! if we still point to this%ja, we first need to allocate space
1445  if (associated(this%mask, this%ja)) then
1446  call mem_allocate(this%mask, this%nja, 'MASK', this%memoryPath)
1447  ! and initialize with unmasked
1448  do i = 1, this%nja
1449  this%mask(i) = 1
1450  end do
1451  end if
1452  !
1453  ! -- set the mask value
1454  this%mask(ipos) = maskval
1455  !
1456  ! -- Return
1457  return

◆ vertexconnect()

subroutine connectionsmodule::vertexconnect ( integer(i4b), intent(in)  nodes,
integer(i4b), intent(in)  nrsize,
integer(i4b), intent(in)  maxnnz,
integer(i4b), intent(in)  nlay,
integer(i4b), intent(in)  ncpl,
type(sparsematrix), intent(inout)  sparse,
type(sparsematrix), intent(inout)  vertcellspm,
type(disvgeomtype), intent(inout)  cell1,
type(disvgeomtype), intent(inout)  cell2,
integer(i4b), dimension(:), intent(in)  nodereduced 
)
private

Definition at line 1273 of file Connections.f90.

1275  ! -- modules
1276  use sparsemodule, only: sparsematrix
1277  use disvgeom, only: disvgeomtype
1278  ! -- dummy
1279  integer(I4B), intent(in) :: nodes
1280  integer(I4B), intent(in) :: nrsize
1281  integer(I4B), intent(in) :: maxnnz
1282  integer(I4B), intent(in) :: nlay
1283  integer(I4B), intent(in) :: ncpl
1284  type(SparseMatrix), intent(inout) :: sparse
1285  type(SparseMatrix), intent(inout) :: vertcellspm
1286  integer(I4B), dimension(:), intent(in) :: nodereduced
1287  type(DisvGeomType), intent(inout) :: cell1, cell2
1288  ! -- local
1289  integer(I4B), dimension(:), allocatable :: rowmaxnnz
1290  integer(I4B) :: i, j, k, kk, nr, mr, j1, j2, icol1, icol2, nvert
1291  !
1292  ! -- Allocate and fill the ia and ja arrays
1293  allocate (rowmaxnnz(nodes))
1294  do i = 1, nodes
1295  rowmaxnnz(i) = maxnnz
1296  end do
1297  call sparse%init(nodes, nodes, rowmaxnnz)
1298  deallocate (rowmaxnnz)
1299  do k = 1, nlay
1300  do j = 1, ncpl
1301  !
1302  ! -- Find the reduced node number and then cycle if the
1303  ! node is always inactive
1304  nr = get_node(k, 1, j, nlay, 1, ncpl)
1305  if (nrsize > 0) nr = nodereduced(nr)
1306  if (nr <= 0) cycle
1307  !
1308  ! -- Process diagonal
1309  call sparse%addconnection(nr, nr, 1)
1310  !
1311  ! -- Up direction
1312  if (k > 1) then
1313  do kk = k - 1, 1, -1
1314  mr = get_node(kk, 1, j, nlay, 1, ncpl)
1315  if (nrsize > 0) mr = nodereduced(mr)
1316  if (mr >= 0) exit
1317  end do
1318  if (mr > 0) then
1319  call sparse%addconnection(nr, mr, 1)
1320  end if
1321  end if
1322  !
1323  ! -- Down direction
1324  if (k < nlay) then
1325  do kk = k + 1, nlay
1326  mr = get_node(kk, 1, j, nlay, 1, ncpl)
1327  if (nrsize > 0) mr = nodereduced(mr)
1328  if (mr >= 0) exit
1329  end do
1330  if (mr > 0) then
1331  call sparse%addconnection(nr, mr, 1)
1332  end if
1333  end if
1334  end do
1335  end do
1336  !
1337  ! -- Go through each vertex and connect up all the cells that use
1338  ! this vertex in their definition and share an edge.
1339  nvert = vertcellspm%nrow
1340  do i = 1, nvert
1341  do icol1 = 1, vertcellspm%row(i)%nnz
1342  j1 = vertcellspm%row(i)%icolarray(icol1)
1343  do k = 1, nlay
1344  nr = get_node(k, 1, j1, nlay, 1, ncpl)
1345  if (nrsize > 0) nr = nodereduced(nr)
1346  if (nr <= 0) cycle
1347  call cell1%set_nodered(nr)
1348  do icol2 = 1, vertcellspm%row(i)%nnz
1349  j2 = vertcellspm%row(i)%icolarray(icol2)
1350  if (j1 == j2) cycle
1351  mr = get_node(k, 1, j2, nlay, 1, ncpl)
1352  if (nrsize > 0) mr = nodereduced(mr)
1353  if (mr <= 0) cycle
1354  call cell2%set_nodered(mr)
1355  if (cell1%shares_edge(cell2)) then
1356  call sparse%addconnection(nr, mr, 1)
1357  end if
1358  end do
1359  end do
1360  end do
1361  end do
1362  !
1363  ! -- Return
1364  return
Here is the call graph for this function:
Here is the caller graph for this function:

◆ vertexconnectl()

subroutine connectionsmodule::vertexconnectl ( integer(i4b), intent(in)  nodes,
integer(i4b), intent(in)  nrsize,
integer(i4b), intent(in)  maxnnz,
integer(i4b), intent(in)  nodeuser,
type(sparsematrix), intent(inout)  sparse,
integer(i4b), dimension(:), intent(in)  iavertcells,
integer(i4b), dimension(:), intent(in)  javertcells,
integer(i4b), dimension(:), intent(in)  nodereduced 
)

Definition at line 1370 of file Connections.f90.

1373  ! -- modules
1374  use sparsemodule, only: sparsematrix
1375  use geomutilmodule, only: get_node
1376  ! -- dummy
1377  integer(I4B), intent(in) :: nodes
1378  integer(I4B), intent(in) :: nrsize
1379  integer(I4B), intent(in) :: maxnnz
1380  integer(I4B), intent(in) :: nodeuser
1381  type(SparseMatrix), intent(inout) :: sparse
1382  integer(I4B), dimension(:), intent(in) :: nodereduced
1383  integer(I4B), dimension(:), intent(in) :: iavertcells
1384  integer(I4B), dimension(:), intent(in) :: javertcells
1385  ! -- local
1386  integer(I4B), dimension(:), allocatable :: rowmaxnnz
1387  integer(I4B) :: i, k, nr, mr, nvert
1388  integer(I4B) :: con
1389  !
1390  ! -- Allocate and fill the ia and ja arrays
1391  allocate (rowmaxnnz(nodes))
1392  do i = 1, nodes
1393  rowmaxnnz(i) = maxnnz
1394  end do
1395  call sparse%init(nodes, nodes, rowmaxnnz)
1396  deallocate (rowmaxnnz)
1397  do nr = 1, nodes
1398  !
1399  ! -- Process diagonal
1400  mr = nr
1401  if (nrsize > 0) mr = nodereduced(mr)
1402  if (mr <= 0) cycle
1403  call sparse%addconnection(mr, mr, 1)
1404  end do
1405  !
1406  ! -- Go through each vertex and connect up all the cells that use
1407  ! this vertex in their definition.
1408  nvert = size(iavertcells) - 1
1409 
1410  do i = 1, nvert
1411  ! loop through cells that share the vertex
1412  do k = iavertcells(i), iavertcells(i + 1) - 2
1413  ! loop again through connected cells that share vertex
1414  do con = k + 1, iavertcells(i + 1) - 1
1415  nr = javertcells(k)
1416  if (nrsize > 0) nr = nodereduced(nr)
1417  if (nr <= 0) cycle
1418  mr = javertcells(con)
1419  if (nrsize > 0) mr = nodereduced(mr)
1420  if (mr <= 0) cycle
1421  call sparse%addconnection(nr, mr, 1)
1422  call sparse%addconnection(mr, nr, 1)
1423  end do
1424  end do
1425  end do
1426  !
1427  ! -- return
1428  return
Here is the call graph for this function:
Here is the caller graph for this function: