condition.F90 coverage: 89.74 %func 62.14 %block
1) module Condition_module
2)
3) ! use Reaction_Aux_module
4) ! use Reactive_Transport_Aux_module
5) use Global_Aux_module
6) use Dataset_Base_class
7) use Dataset_Ascii_class
8) use Time_Storage_module
9)
10) use Transport_Constraint_module
11) ! use Reaction_Surface_Complexation_Aux_module
12) ! use Reaction_Mineral_Aux_module
13)
14) use PFLOTRAN_Constants_module
15)
16) implicit none
17)
18) private
19)
20) #include "petsc/finclude/petscsys.h"
21)
22) type, public :: flow_condition_type
23) PetscInt :: id ! id from which condition can be referenced
24) PetscBool :: is_transient
25) PetscBool :: sync_time_with_update
26) character(len=MAXWORDLENGTH) :: name ! name of condition (e.g. initial, recharge)
27) PetscInt :: num_sub_conditions
28) PetscInt :: iphase
29) PetscInt, pointer :: itype(:)
30) character(len=MAXWORDLENGTH) :: time_units
31) character(len=MAXWORDLENGTH) :: length_units
32) type(time_storage_type), pointer :: default_time_storage
33) class(dataset_base_type), pointer :: datum
34) type(flow_sub_condition_type), pointer :: pressure
35) type(flow_sub_condition_type), pointer :: saturation
36) type(flow_sub_condition_type), pointer :: rate
37) type(flow_sub_condition_type), pointer :: well
38) type(flow_sub_condition_type), pointer :: temperature
39) type(flow_sub_condition_type), pointer :: concentration
40) type(flow_sub_condition_type), pointer :: enthalpy
41) type(flow_sub_condition_type), pointer :: energy_rate
42) type(flow_sub_condition_type), pointer :: energy_flux
43) type(flow_general_condition_type), pointer :: general
44) type(flow_toil_ims_condition_type), pointer :: toil_ims
45) ! any new sub conditions must be added to FlowConditionIsTransient
46) type(sub_condition_ptr_type), pointer :: sub_condition_ptr(:)
47) type(flow_condition_type), pointer :: next ! pointer to next condition_type for linked-lists
48) end type flow_condition_type
49)
50) ! data structure for general phase
51) type, public :: flow_general_condition_type
52) type(flow_sub_condition_type), pointer :: liquid_pressure
53) type(flow_sub_condition_type), pointer :: gas_pressure
54) type(flow_sub_condition_type), pointer :: gas_saturation
55) type(flow_sub_condition_type), pointer :: mole_fraction
56) type(flow_sub_condition_type), pointer :: relative_humidity
57) type(flow_sub_condition_type), pointer :: temperature
58) type(flow_sub_condition_type), pointer :: rate
59) type(flow_sub_condition_type), pointer :: liquid_flux
60) type(flow_sub_condition_type), pointer :: gas_flux
61) type(flow_sub_condition_type), pointer :: energy_flux
62) ! any new sub conditions must be added to FlowConditionIsTransient
63) end type flow_general_condition_type
64)
65) ! data structure for toil_ims
66) type, public :: flow_toil_ims_condition_type
67) !type(flow_sub_condition_type), pointer :: liquid_pressure
68) !type(flow_sub_condition_type), pointer :: oil_pressure
69) !type(flow_sub_condition_type), pointer :: oil_saturation
70) type(flow_sub_condition_type), pointer :: pressure
71) type(flow_sub_condition_type), pointer :: saturation
72) type(flow_sub_condition_type), pointer :: temperature
73) type(flow_sub_condition_type), pointer :: enthalpy
74) type(flow_sub_condition_type), pointer :: rate
75) !PO: to add well when adding well capabilities.
76) type(flow_sub_condition_type), pointer :: liquid_flux
77) type(flow_sub_condition_type), pointer :: oil_flux
78) type(flow_sub_condition_type), pointer :: energy_flux
79) type(flow_sub_condition_type), pointer :: owc ! oil water contact
80) type(flow_sub_condition_type), pointer :: liq_press_grad ! water piezometric head gradient
81) ! any new sub conditions must be added to FlowConditionIsTransient
82) end type flow_toil_ims_condition_type
83)
84) type, public :: flow_sub_condition_type
85) PetscInt :: itype ! integer describing type of condition
86) PetscInt :: isubtype
87) character(len=MAXWORDLENGTH) :: ctype ! character string describing type of condition
88) character(len=MAXWORDLENGTH) :: units ! units
89) character(len=MAXWORDLENGTH) :: name
90) PetscReal :: aux_real(2)
91) class(dataset_base_type), pointer :: gradient
92) class(dataset_base_type), pointer :: dataset
93) end type flow_sub_condition_type
94)
95) type, public :: sub_condition_ptr_type
96) type(flow_sub_condition_type), pointer :: ptr
97) end type sub_condition_ptr_type
98)
99) type, public :: condition_ptr_type
100) type(flow_condition_type), pointer :: ptr
101) end type condition_ptr_type
102)
103) type, public :: condition_list_type
104) PetscInt :: num_conditions
105) type(flow_condition_type), pointer :: first
106) type(flow_condition_type), pointer :: last
107) type(flow_condition_type), pointer :: array(:)
108) end type condition_list_type
109)
110) type, public :: tran_condition_type
111) PetscInt :: id ! id from which condition can be referenced
112) PetscInt :: itype ! integer describing type of condition
113) PetscBool :: is_transient
114) character(len=MAXWORDLENGTH) :: name ! name of condition (e.g. initial, recharge)
115) type(tran_constraint_coupler_type), pointer :: constraint_coupler_list
116) type(tran_constraint_coupler_type), pointer :: cur_constraint_coupler
117) type(tran_condition_type), pointer :: next
118) end type tran_condition_type
119)
120) type, public :: tran_condition_ptr_type
121) type(tran_condition_type), pointer :: ptr
122) end type tran_condition_ptr_type
123)
124) type, public :: tran_condition_list_type
125) PetscInt :: num_conditions
126) type(tran_condition_type), pointer :: first
127) type(tran_condition_type), pointer :: last
128) type(tran_condition_ptr_type), pointer :: array(:)
129) end type tran_condition_list_type
130)
131) public :: FlowConditionCreate, FlowConditionDestroy, FlowConditionRead, &
132) FlowConditionGeneralRead, FlowConditionTOilImsRead, &
133) FlowConditionAddToList, FlowConditionInitList, &
134) FlowConditionDestroyList, &
135) FlowConditionGetPtrFromList, FlowConditionUpdate, &
136) FlowConditionPrint, &
137) TranConditionCreate, &
138) TranConditionAddToList, TranConditionInitList, &
139) TranConditionDestroyList, TranConditionGetPtrFromList, &
140) TranConstraintAddToList, TranConstraintInitList, &
141) TranConstraintDestroyList, TranConstraintGetPtrFromList, &
142) TranConditionRead, TranConstraintRead, &
143) TranConditionUpdate, &
144) FlowConditionIsTransient, &
145) ConditionReadValues, &
146) GetSubConditionName, &
147) FlowConditionUnknownItype, &
148) FlowCondInputRecord, &
149) TranCondInputRecord
150)
151) contains
152)
153) ! ************************************************************************** !
154)
155) function FlowConditionCreate(option)
156) !
157) ! Creates a condition
158) !
159) ! Author: Glenn Hammond
160) ! Date: 10/23/07
161) !
162)
163) use Option_module
164)
165) implicit none
166)
167) type(option_type) :: option
168) type(flow_condition_type), pointer :: FlowConditionCreate
169)
170) type(flow_condition_type), pointer :: condition
171)
172) allocate(condition)
173) nullify(condition%pressure)
174) nullify(condition%saturation)
175) nullify(condition%rate)
176) nullify(condition%energy_rate)
177) nullify(condition%energy_flux)
178) nullify(condition%well)
179) nullify(condition%temperature)
180) nullify(condition%concentration)
181) nullify(condition%enthalpy)
182) nullify(condition%sub_condition_ptr)
183) nullify(condition%general)
184) nullify(condition%toil_ims)
185) nullify(condition%itype)
186) nullify(condition%next)
187) nullify(condition%datum)
188) nullify(condition%default_time_storage)
189) condition%is_transient = PETSC_FALSE
190) condition%sync_time_with_update = PETSC_FALSE
191) condition%time_units = ''
192) condition%length_units = ''
193) condition%id = 0
194) condition%iphase = 0
195) condition%num_sub_conditions = 0
196) condition%name = ''
197)
198) FlowConditionCreate => condition
199)
200) end function FlowConditionCreate
201)
202) ! ************************************************************************** !
203)
204) function TranConditionCreate(option)
205) !
206) ! Creates a transport condition
207) !
208) ! Author: Glenn Hammond
209) ! Date: 10/23/07
210) !
211)
212) use Option_module
213)
214) implicit none
215)
216) type(option_type) :: option
217) type(tran_condition_type), pointer :: TranConditionCreate
218)
219) type(tran_condition_type), pointer :: condition
220)
221) allocate(condition)
222) nullify(condition%constraint_coupler_list)
223) nullify(condition%cur_constraint_coupler)
224) nullify(condition%next)
225) condition%id = 0
226) condition%itype = 0
227) condition%name = ''
228)
229) TranConditionCreate => condition
230)
231) end function TranConditionCreate
232)
233) ! ************************************************************************** !
234)
235) function FlowGeneralConditionCreate(option)
236) !
237) ! Creates a condition for general mode
238) !
239) ! Author: Glenn Hammond
240) ! Date: 05/26/11
241) !
242)
243) use Option_module
244)
245) implicit none
246)
247) type(option_type) :: option
248) type(flow_general_condition_type), pointer :: FlowGeneralConditionCreate
249)
250) type(flow_general_condition_type), pointer :: general_condition
251)
252) allocate(general_condition)
253) nullify(general_condition%liquid_pressure)
254) nullify(general_condition%gas_pressure)
255) nullify(general_condition%gas_saturation)
256) nullify(general_condition%relative_humidity)
257) nullify(general_condition%mole_fraction)
258) nullify(general_condition%temperature)
259) nullify(general_condition%liquid_flux)
260) nullify(general_condition%gas_flux)
261) nullify(general_condition%energy_flux)
262) nullify(general_condition%rate)
263)
264) FlowGeneralConditionCreate => general_condition
265)
266) end function FlowGeneralConditionCreate
267)
268) ! ************************************************************************** !
269)
270) function FlowTOilImsConditionCreate(option)
271) !
272) ! Creates a condition for toil_ims mode
273) !
274) ! Author: Paolo Orsini (OGS)
275) ! Date: 09/9/2015
276) !
277)
278) use Option_module
279)
280) implicit none
281)
282) type(option_type) :: option
283) type(flow_toil_ims_condition_type), pointer :: FlowTOilImsConditionCreate
284)
285) type(flow_toil_ims_condition_type), pointer :: toil_ims_condition
286)
287) allocate(toil_ims_condition)
288) nullify(toil_ims_condition%pressure)
289) nullify(toil_ims_condition%saturation)
290) nullify(toil_ims_condition%temperature)
291) nullify(toil_ims_condition%enthalpy)
292) nullify(toil_ims_condition%rate)
293) nullify(toil_ims_condition%liquid_flux)
294) nullify(toil_ims_condition%oil_flux)
295) nullify(toil_ims_condition%energy_flux)
296) nullify(toil_ims_condition%owc)
297) nullify(toil_ims_condition%liq_press_grad)
298)
299) FlowTOilImsConditionCreate => toil_ims_condition
300)
301) end function FlowTOilImsConditionCreate
302)
303) ! ************************************************************************** !
304)
305) function FlowGeneralSubConditionPtr(sub_condition_name,general, &
306) option)
307) !
308) ! Returns a pointer to a subcondition, creating
309) ! them if necessary
310) !
311) ! Author: Glenn Hammond
312) ! Date: 06/09/11
313) !
314)
315) use Option_module
316) use Input_Aux_module, only : InputKeywordUnrecognized
317)
318) implicit none
319)
320) character(len=MAXWORDLENGTH) :: sub_condition_name
321) type(flow_general_condition_type) :: general
322) type(option_type) :: option
323)
324) type(flow_sub_condition_type), pointer :: FlowGeneralSubConditionPtr
325) type(flow_sub_condition_type), pointer :: sub_condition_ptr
326)
327) select case(sub_condition_name)
328) case('LIQUID_PRESSURE')
329) if (associated(general%liquid_pressure)) then
330) sub_condition_ptr => general%liquid_pressure
331) else
332) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
333) general%liquid_pressure => sub_condition_ptr
334) endif
335) case('GAS_PRESSURE')
336) if (associated(general%gas_pressure)) then
337) sub_condition_ptr => general%gas_pressure
338) else
339) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
340) general%gas_pressure => sub_condition_ptr
341) endif
342) case('LIQUID_SATURATION','GAS_SATURATION')
343) if (associated(general%gas_saturation)) then
344) sub_condition_ptr => general%gas_saturation
345) else
346) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
347) general%gas_saturation => sub_condition_ptr
348) endif
349) case('TEMPERATURE')
350) if (associated(general%temperature)) then
351) sub_condition_ptr => general%temperature
352) else
353) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
354) general%temperature => sub_condition_ptr
355) endif
356) case('RELATIVE_HUMIDITY')
357) if (associated(general%relative_humidity)) then
358) sub_condition_ptr => general%relative_humidity
359) else
360) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
361) general%relative_humidity => sub_condition_ptr
362) endif
363) case('MOLE_FRACTION')
364) if (associated(general%mole_fraction)) then
365) sub_condition_ptr => general%mole_fraction
366) else
367) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
368) general%mole_fraction => sub_condition_ptr
369) endif
370) case('LIQUID_FLUX')
371) if (associated(general%liquid_flux)) then
372) sub_condition_ptr => general%liquid_flux
373) else
374) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
375) general%liquid_flux => sub_condition_ptr
376) endif
377) case('GAS_FLUX')
378) if (associated(general%gas_flux)) then
379) sub_condition_ptr => general%gas_flux
380) else
381) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
382) general%gas_flux => sub_condition_ptr
383) endif
384) case('ENERGY_FLUX')
385) if (associated(general%energy_flux)) then
386) sub_condition_ptr => general%energy_flux
387) else
388) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
389) general%energy_flux => sub_condition_ptr
390) endif
391) case('RATE')
392) if (associated(general%rate)) then
393) sub_condition_ptr => general%rate
394) else
395) sub_condition_ptr => FlowSubConditionCreate(THREE_INTEGER)
396) general%rate => sub_condition_ptr
397) endif
398) case default
399) call InputKeywordUnrecognized(sub_condition_name, &
400) 'general condition,type',option)
401) end select
402)
403) FlowGeneralSubConditionPtr => sub_condition_ptr
404)
405) end function FlowGeneralSubConditionPtr
406)
407) ! ************************************************************************** !
408)
409) function FlowTOilImsSubConditionPtr(sub_condition_name,toil_ims, &
410) option)
411) !
412) ! Returns a pointer to a subcondition, creating
413) ! them if necessary for toil_ims flow mode
414) !
415) ! Author: Paolo Orsini (OGS)
416) ! Date: 09/09/2015
417) !
418)
419) use Option_module
420) use Input_Aux_module, only : InputKeywordUnrecognized
421)
422) implicit none
423)
424) character(len=MAXWORDLENGTH) :: sub_condition_name
425) type(flow_toil_ims_condition_type) :: toil_ims
426) type(option_type) :: option
427)
428) type(flow_sub_condition_type), pointer :: FlowTOilImsSubConditionPtr
429) type(flow_sub_condition_type), pointer :: sub_condition_ptr
430)
431) select case(sub_condition_name)
432) case('PRESSURE','OIL_PRESSURE','WATER_PRESSURE')
433) if (associated(toil_ims%pressure)) then
434) sub_condition_ptr => toil_ims%pressure
435) else
436) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
437) toil_ims%pressure => sub_condition_ptr
438) endif
439) case('LIQUID_SATURATION','OIL_SATURATION')
440) if (associated(toil_ims%saturation)) then
441) sub_condition_ptr => toil_ims%saturation
442) else
443) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
444) toil_ims%saturation => sub_condition_ptr
445) endif
446) case('TEMPERATURE')
447) if (associated(toil_ims%temperature)) then
448) sub_condition_ptr => toil_ims%temperature
449) else
450) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
451) toil_ims%temperature => sub_condition_ptr
452) endif
453) case('ENTHALPY')
454) if (associated(toil_ims%enthalpy)) then
455) sub_condition_ptr => toil_ims%enthalpy
456) else
457) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
458) toil_ims%enthalpy => sub_condition_ptr
459) endif
460) case('LIQUID_FLUX')
461) if (associated(toil_ims%liquid_flux)) then
462) sub_condition_ptr => toil_ims%liquid_flux
463) else
464) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
465) toil_ims%liquid_flux => sub_condition_ptr
466) endif
467) case('OIL_FLUX')
468) if (associated(toil_ims%oil_flux)) then
469) sub_condition_ptr => toil_ims%oil_flux
470) else
471) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
472) toil_ims%oil_flux => sub_condition_ptr
473) endif
474) case('ENERGY_FLUX')
475) if (associated(toil_ims%energy_flux)) then
476) sub_condition_ptr => toil_ims%energy_flux
477) else
478) sub_condition_ptr => FlowSubConditionCreate(ONE_INTEGER)
479) toil_ims%energy_flux => sub_condition_ptr
480) endif
481) case('OWC')
482) if (associated(toil_ims%owc)) then
483) sub_condition_ptr => toil_ims%owc
484) else
485) ! energy rate is loaded in the third record
486) sub_condition_ptr => FlowSubConditionCreate(THREE_INTEGER)
487) toil_ims%owc => sub_condition_ptr
488) endif
489) case('WATER_PRESSURE_GRAD')
490) if (associated(toil_ims%liq_press_grad)) then
491) sub_condition_ptr => toil_ims%liq_press_grad
492) else
493) ! energy rate is loaded in the third record
494) sub_condition_ptr => FlowSubConditionCreate(THREE_INTEGER)
495) toil_ims%liq_press_grad => sub_condition_ptr
496) endif
497) case('RATE')
498) if (associated(toil_ims%rate)) then
499) sub_condition_ptr => toil_ims%rate
500) else
501) ! energy rate is loaded in the third record
502) sub_condition_ptr => FlowSubConditionCreate(THREE_INTEGER)
503) toil_ims%rate => sub_condition_ptr
504) endif
505) ! to add well for multiple
506) case default
507) call InputKeywordUnrecognized(sub_condition_name, &
508) 'toil_ims condition,type',option)
509) end select
510)
511) FlowTOilImsSubConditionPtr => sub_condition_ptr
512)
513) end function FlowTOilImsSubConditionPtr
514)
515) ! ************************************************************************** !
516)
517) function FlowSubConditionCreate(ndof)
518) !
519) ! Creates a sub_condition
520) !
521) ! Author: Glenn Hammond
522) ! Date: 02/04/08
523) !
524)
525) use Dataset_Ascii_class
526) use Option_module
527)
528) implicit none
529)
530) type(flow_sub_condition_type), pointer :: FlowSubConditionCreate
531)
532) PetscInt :: ndof
533)
534) type(flow_sub_condition_type), pointer :: sub_condition
535) class(dataset_ascii_type), pointer :: dataset_ascii
536)
537) allocate(sub_condition)
538) sub_condition%units = ''
539) sub_condition%itype = 0
540) sub_condition%isubtype = 0
541) sub_condition%ctype = ''
542) sub_condition%name = ''
543) sub_condition%aux_real = UNINITIALIZED_DOUBLE
544) nullify(sub_condition%gradient)
545) nullify(sub_condition%dataset)
546)
547) ! by default, all dataset are of type dataset_ascii_type, unless overwritten
548) dataset_ascii => DatasetAsciiCreate()
549) call DatasetAsciiInit(dataset_ascii)
550) dataset_ascii%array_width = ndof
551) dataset_ascii%data_type = DATASET_REAL
552) sub_condition%dataset => dataset_ascii
553) nullify(dataset_ascii)
554)
555) FlowSubConditionCreate => sub_condition
556)
557) end function FlowSubConditionCreate
558)
559) ! ************************************************************************** !
560)
561) function GetFlowSubCondFromArrayByName(sub_condition_ptr_list,name)
562) !
563) ! returns a pointer to a subcondition with
564) ! matching name
565) !
566) ! Author: Glenn Hammond
567) ! Date: 06/02/08
568) !
569)
570) use Input_Aux_module
571) use String_module
572)
573) implicit none
574)
575) type(flow_sub_condition_type), pointer :: GetFlowSubCondFromArrayByName
576) type(sub_condition_ptr_type), pointer :: sub_condition_ptr_list(:)
577) character(len=MAXWORDLENGTH) :: name
578)
579) PetscInt :: idof
580) PetscInt :: length
581)
582) nullify(GetFlowSubCondFromArrayByName)
583) length = len_trim(name)
584) do idof = 1, size(sub_condition_ptr_list)
585) if (length == len_trim(sub_condition_ptr_list(idof)%ptr%name) .and. &
586) StringCompare(name,sub_condition_ptr_list(idof)%ptr%name,length)) then
587) GetFlowSubCondFromArrayByName => sub_condition_ptr_list(idof)%ptr
588) return
589) endif
590) enddo
591)
592) print *, 'GetFlowSubCondFromArrayByName() needs to be updated to include' // &
593) 'the general_condition_type.'
594) stop
595)
596) end function GetFlowSubCondFromArrayByName
597)
598) ! ************************************************************************** !
599)
600) subroutine FlowSubConditionVerify(option, condition, sub_condition_name, &
601) sub_condition, default_time_storage, &
602) destroy_if_null)
603) !
604) ! Verifies the data in a subcondition
605) !
606) ! Author: Glenn Hammond
607) ! Date: 02/04/08
608) !
609) use Time_Storage_module
610) use Option_module
611) use Dataset_module
612)
613) implicit none
614)
615) type(option_type) :: option
616) type(flow_condition_type) :: condition
617) character(len=MAXWORDLENGTH) :: sub_condition_name
618) type(flow_sub_condition_type), pointer :: sub_condition
619) type(time_storage_type), pointer :: default_time_storage
620) PetscBool :: destroy_if_null
621)
622) if (.not.associated(sub_condition)) return
623)
624) ! dataset is not optional
625) if (.not.(associated(sub_condition%dataset%rarray) .or. &
626) associated(sub_condition%dataset%rbuffer) .or. &
627) ! if a dataset name is read, instead of data at this point
628) len_trim(sub_condition%dataset%name) > 0)) then
629) if (destroy_if_null) call FlowSubConditionDestroy(sub_condition)
630) return
631) endif
632)
633) if (len_trim(sub_condition%ctype) == NULL_CONDITION) then
634) option%io_buffer = 'TYPE of condition ' // trim(condition%name) // &
635) ' ' // trim(sub_condition_name) // ' dataset not defined.'
636) call printErrMsg(option)
637) endif
638)
639) call DatasetVerify(sub_condition%dataset,default_time_storage,option)
640) call DatasetVerify(sub_condition%gradient,default_time_storage,option)
641)
642) end subroutine FlowSubConditionVerify
643)
644) ! ************************************************************************** !
645)
646) subroutine FlowConditionRead(condition,input,option)
647) !
648) ! Reads a condition from the input file
649) !
650) ! Author: Glenn Hammond
651) ! Date: 10/31/07
652) !
653)
654) use Option_module
655) use Input_Aux_module
656) use String_module
657) use Logging_module
658) use Time_Storage_module
659) use Dataset_module
660)
661) implicit none
662)
663) type(flow_condition_type) :: condition
664) type(input_type), pointer :: input
665) type(option_type) :: option
666)
667) character(len=MAXSTRINGLENGTH) :: string
668) character(len=MAXWORDLENGTH) :: word
669) character(len=MAXWORDLENGTH) :: rate_string
670) character(len=MAXWORDLENGTH) :: internal_units
671) type(flow_sub_condition_type), pointer :: pressure, flux, temperature, &
672) concentration, enthalpy, rate, well,&
673) sub_condition_ptr, saturation, &
674) energy_rate, energy_flux
675) PetscReal :: default_time
676) PetscInt :: default_iphase
677) PetscInt :: idof
678) type(time_storage_type), pointer :: default_time_storage
679) class(dataset_ascii_type), pointer :: dataset_ascii
680)
681) PetscErrorCode :: ierr
682)
683) call PetscLogEventBegin(logging%event_flow_condition_read, &
684) ierr);CHKERRQ(ierr)
685)
686) default_time = 0.d0
687) default_iphase = 0
688)
689) default_time_storage => TimeStorageCreate()
690) default_time_storage%is_cyclic = PETSC_FALSE
691) default_time_storage%time_interpolation_method = INTERPOLATION_STEP
692)
693) rate_string = 'not_assigned'
694) internal_units = 'not_assigned'
695)
696) pressure => FlowSubConditionCreate(option%nphase)
697) pressure%name = 'pressure'
698) flux => pressure
699) rate => FlowSubConditionCreate(option%nflowspec)
700) rate%name = 'rate'
701) energy_rate => FlowSubConditionCreate(ONE_INTEGER)
702) energy_rate%name = 'energy_rate'
703) energy_flux => FlowSubConditionCreate(ONE_INTEGER)
704) energy_flux%name = 'energy_flux'
705) well => FlowSubConditionCreate(7 + option%nflowspec)
706) well%name = 'well'
707) saturation => FlowSubConditionCreate(option%nphase)
708) saturation%name = 'saturation'
709) temperature => FlowSubConditionCreate(ONE_INTEGER)
710) temperature%name = 'temperature'
711) concentration => FlowSubConditionCreate(ONE_INTEGER)
712) concentration%name = 'concentration'
713) enthalpy => FlowSubConditionCreate(option%nphase)
714) enthalpy%name = 'enthalpy'
715)
716) condition%time_units = 'yr'
717) condition%length_units = 'm'
718) pressure%units = 'Pa'
719) rate%units = 'kg/s'
720) energy_rate%units = 'W'
721) energy_flux%units = 'W/m^2'
722) well%units = 'Pa'
723) saturation%units = ' '
724) temperature%units = 'C'
725) concentration%units = 'M'
726) enthalpy%units = 'kJ/mol'
727)
728) ! read the condition
729) input%ierr = 0
730) do
731)
732) call InputReadPflotranString(input,option)
733) call InputReadStringErrorMsg(input,option,'CONDITION')
734)
735) if (InputCheckExit(input,option)) exit
736)
737) call InputReadWord(input,option,word,PETSC_TRUE)
738) call InputErrorMsg(input,option,'keyword','CONDITION')
739)
740) select case(trim(word))
741)
742) case('UNITS') ! read default units for condition arguments
743) do
744) call InputReadWord(input,option,word,PETSC_TRUE)
745) if (InputError(input)) exit
746) select case(trim(word))
747) case('s','sec','min','hr','d','day','y','yr')
748) condition%time_units = trim(word)
749) case('mm','cm','m','met','meter','dm','km')
750) condition%length_units = trim(word)
751) case('Pa','KPa')
752) pressure%units = trim(word)
753) case('kg/s','kg/yr')
754) rate%units = trim(word)
755) case('W','J/yr')
756) energy_rate%units = trim(word)
757) case('W/m^2','J/m^2/yr')
758) energy_flux%units = trim(word)
759) case('m/s','m/yr')
760) flux%units = trim(word)
761) case('C','K')
762) temperature%units = trim(word)
763) case('M','mol/L')
764) concentration%units = trim(word)
765) case('kJ/mol')
766) enthalpy%units = trim(word)
767) case default
768) call InputKeywordUnrecognized(word,'condition,units',option)
769) end select
770) enddo
771) case('CYCLIC')
772) ! by default, is_cyclic is set to PETSC_FALSE
773) default_time_storage%is_cyclic = PETSC_TRUE
774) case('SYNC_TIMESTEP_WITH_UPDATE')
775) condition%sync_time_with_update = PETSC_TRUE
776) case('INTERPOLATION')
777) call InputReadWord(input,option,word,PETSC_TRUE)
778) call InputErrorMsg(input,option,'INTERPOLATION','CONDITION')
779) call StringToLower(word)
780) select case(word)
781) case('step')
782) default_time_storage%time_interpolation_method = &
783) INTERPOLATION_STEP
784) case('linear')
785) default_time_storage%time_interpolation_method = &
786) INTERPOLATION_LINEAR
787) case default
788) call InputKeywordUnrecognized(word,'condition,interpolation', &
789) option)
790) end select
791) case('TYPE') ! read condition type (dirichlet, neumann, etc) for each dof
792) do
793) call InputReadPflotranString(input,option)
794) call InputReadStringErrorMsg(input,option,'CONDITION')
795)
796) if (InputCheckExit(input,option)) exit
797)
798) if (InputError(input)) exit
799) call InputReadWord(input,option,word,PETSC_TRUE)
800) call InputErrorMsg(input,option,'keyword','CONDITION,TYPE')
801) call StringToUpper(word)
802) select case(trim(word))
803) case('PRESSURE')
804) sub_condition_ptr => pressure
805) internal_units = 'Pa'
806) case('RATE')
807) sub_condition_ptr => rate
808) internal_units = 'unitless/sec'
809) case('ENERGY_RATE')
810) sub_condition_ptr => energy_rate
811) internal_units = 'MJ/sec|MW'
812) case('WELL')
813) sub_condition_ptr => well
814) internal_units = 'Pa'
815) case('FLUX')
816) sub_condition_ptr => flux
817) internal_units = 'meter/sec'
818) case('ENERGY_FLUX')
819) sub_condition_ptr => energy_flux
820) internal_units = 'MW/m^2|MJ/sec-m^2'
821) case('SATURATION')
822) sub_condition_ptr => saturation
823) internal_units = 'unitless'
824) case('TEMPERATURE')
825) sub_condition_ptr => temperature
826) internal_units = 'C'
827) case('CONCENTRATION')
828) sub_condition_ptr => concentration
829) internal_units = 'unitless'
830) case('ENTHALPY')
831) sub_condition_ptr => enthalpy
832) internal_units = 'MJ/mol'
833) case default
834) call InputKeywordUnrecognized(word,'condition,type',option)
835) end select
836) call InputReadWord(input,option,word,PETSC_TRUE)
837) call InputErrorMsg(input,option,'TYPE','CONDITION')
838) call StringToLower(word)
839) sub_condition_ptr%ctype = word
840) select case(word)
841) case('dirichlet')
842) sub_condition_ptr%itype = DIRICHLET_BC
843) case('neumann')
844) sub_condition_ptr%itype = NEUMANN_BC
845) case('mass_rate')
846) sub_condition_ptr%itype = MASS_RATE_SS
847) rate_string = 'kg/sec'
848) case('energy_rate')
849) sub_condition_ptr%itype = ENERGY_RATE_SS
850) rate_string = 'MJ/sec|MW'
851) case('heterogeneous_energy_rate')
852) sub_condition_ptr%itype = HET_ENERGY_RATE_SS
853) rate_string = 'MJ/sec|MW'
854) case('scaled_mass_rate','scaled_volumetric_rate', &
855) 'scaled_energy_rate')
856) select case(word)
857) case('scaled_mass_rate')
858) sub_condition_ptr%itype = SCALED_MASS_RATE_SS
859) rate_string = 'kg/sec'
860) case('scaled_volumetric_rate')
861) sub_condition_ptr%itype = SCALED_VOLUMETRIC_RATE_SS
862) rate_string = 'm^3/sec'
863) case('scaled_energy_rate')
864) sub_condition_ptr%itype = SCALED_ENERGY_RATE_SS
865) rate_string = 'MW|MJ/sec'
866) end select
867) ! store name of type for error messaging below.
868) string = word
869) call InputReadWord(input,option,word,PETSC_TRUE)
870) if (input%ierr == 0) then
871) call StringToLower(word)
872) sub_condition_ptr%ctype = trim(sub_condition_ptr%ctype) // word
873) select case(word)
874) case('neighbor_perm')
875) sub_condition_ptr%isubtype = SCALE_BY_NEIGHBOR_PERM
876) case('volume')
877) sub_condition_ptr%isubtype = SCALE_BY_VOLUME
878) case('perm')
879) sub_condition_ptr%isubtype = SCALE_BY_PERM
880) case default
881) string = 'flow condition "' // trim(condition%name) // &
882) '" ' // trim(string)
883) call InputKeywordUnrecognized(word,string,option)
884) end select
885) else
886) option%io_buffer = 'Specify one of NEIGHBOR_PERM, ' // &
887) 'VOLUME, PERM subtypes in '// &
888) 'flow condition "' // trim(condition%name) // &
889) '" ' // trim(string)
890) call printErrMsg(option)
891) endif
892) case('hydrostatic')
893) sub_condition_ptr%itype = HYDROSTATIC_BC
894) case('conductance')
895) sub_condition_ptr%itype = CONDUCTANCE_BC
896) case('zero_gradient')
897) sub_condition_ptr%itype = ZERO_GRADIENT_BC
898) case('well','production_well', 'injection_well')
899) sub_condition_ptr%itype = WELL_SS
900) case('seepage')
901) sub_condition_ptr%itype = SEEPAGE_BC
902) case('volumetric_rate')
903) sub_condition_ptr%itype = VOLUMETRIC_RATE_SS
904) rate_string = 'm^3/sec'
905) case('equilibrium')
906) sub_condition_ptr%itype = EQUILIBRIUM_SS
907) case('unit_gradient')
908) if (.not.associated(sub_condition_ptr,pressure)) then
909) option%io_buffer = 'unit_gradient flow condition type may ' // &
910) 'only be associated with a PRESSURE flow condition.'
911) call printErrMsg(option)
912) endif
913) sub_condition_ptr%itype = UNIT_GRADIENT_BC
914) case('heterogeneous_volumetric_rate')
915) sub_condition_ptr%itype = HET_VOL_RATE_SS
916) rate_string = 'm^3/sec'
917) case('heterogeneous_mass_rate')
918) sub_condition_ptr%itype = HET_MASS_RATE_SS
919) rate_string = 'kg/sec'
920) case('heterogeneous_dirichlet')
921) sub_condition_ptr%itype = HET_DIRICHLET
922) case('heterogeneous_surface_seepage')
923) sub_condition_ptr%itype = HET_SURF_SEEPAGE_BC
924) case('spillover')
925) sub_condition_ptr%itype = SPILLOVER_BC
926) case default
927) call InputKeywordUnrecognized(word,'condition bc type',option)
928) end select
929) enddo
930) case('TIME','TIMES')
931) call InputReadDouble(input,option,default_time)
932) call InputErrorMsg(input,option,'TIME','CONDITION')
933) case('IPHASE')
934) call InputReadInt(input,option,default_iphase)
935) call InputErrorMsg(input,option,'IPHASE','CONDITION')
936) case('DATUM')
937) dataset_ascii => DatasetAsciiCreate()
938) call DatasetAsciiInit(dataset_ascii)
939) dataset_ascii%array_width = 3
940) dataset_ascii%data_type = DATASET_REAL
941) condition%datum => dataset_ascii
942) nullify(dataset_ascii)
943) internal_units = 'meter'
944) call ConditionReadValues(input,option,word, &
945) condition%datum,word,internal_units)
946) case('GRADIENT','GRAD')
947) do
948) call InputReadPflotranString(input,option)
949) call InputReadStringErrorMsg(input,option,'CONDITION')
950)
951) if (InputCheckExit(input,option)) exit
952)
953) if (InputError(input)) exit
954) call InputReadWord(input,option,word,PETSC_TRUE)
955) call InputErrorMsg(input,option,'keyword','CONDITION,TYPE')
956) select case(trim(word))
957) case('PRES','PRESS','PRESSURE')
958) sub_condition_ptr => pressure
959) internal_units = 'Pa/meter'
960) case('RATE')
961) sub_condition_ptr => rate
962) internal_units = 'kg/sec-meter'
963) case('ENERGY_RATE')
964) sub_condition_ptr => energy_rate
965) internal_units = 'MW/meter|MJ/sec-meter'
966) case('WELL')
967) sub_condition_ptr => well
968) internal_units = 'Pa/meter'
969) case('FLUX')
970) sub_condition_ptr => flux
971) internal_units = 'm/sec-m|unitless/sec'
972) case('SATURATION')
973) sub_condition_ptr => saturation
974) internal_units = 'unitless/meter'
975) case('TEMP','TEMPERATURE')
976) sub_condition_ptr => temperature
977) internal_units = 'temperature/m'
978) case('CONC','CONCENTRATION')
979) sub_condition_ptr => concentration
980) internal_units = 'unitless'
981) case('H','ENTHALPY')
982) sub_condition_ptr => enthalpy
983) internal_units = 'kJ/mol-meter'
984) case default
985) call InputKeywordUnrecognized(word, &
986) 'FLOW CONDITION,GRADIENT,TYPE',option)
987) end select
988) dataset_ascii => DatasetAsciiCreate()
989) call DatasetAsciiInit(dataset_ascii)
990) dataset_ascii%array_width = 3
991) dataset_ascii%data_type = DATASET_REAL
992) sub_condition_ptr%gradient => dataset_ascii
993) nullify(dataset_ascii)
994) call ConditionReadValues(input,option,word, &
995) sub_condition_ptr%gradient, &
996) word,internal_units)
997) nullify(sub_condition_ptr)
998) enddo
999) case('TEMPERATURE','TEMP')
1000) internal_units = 'C'
1001) call ConditionReadValues(input,option,word, &
1002) temperature%dataset, &
1003) temperature%units,internal_units)
1004) case('ENTHALPY','H')
1005) internal_units = 'kJ/mol'
1006) call ConditionReadValues(input,option,word, &
1007) enthalpy%dataset, &
1008) enthalpy%units,internal_units)
1009) case('PRESSURE','PRES','PRESS')
1010) internal_units = 'Pa'
1011) call ConditionReadValues(input,option,word, &
1012) pressure%dataset, &
1013) pressure%units,internal_units)
1014) case('RATE')
1015) internal_units = rate_string
1016) call ConditionReadValues(input,option,word, &
1017) rate%dataset, &
1018) rate%units,internal_units)
1019) case('ENERGY_FLUX')
1020) input%force_units = PETSC_TRUE
1021) internal_units = 'MW/m^2|MJ/m^2-sec'
1022) call ConditionReadValues(input,option,word, &
1023) energy_flux%dataset, &
1024) energy_flux%units,internal_units)
1025) input%force_units = PETSC_FALSE
1026) case('ENERGY_RATE')
1027) input%force_units = PETSC_TRUE
1028) internal_units = 'MJ/sec|MW'
1029) input%err_buf = word
1030) call ConditionReadValues(input,option,word, &
1031) energy_rate%dataset, &
1032) energy_rate%units,internal_units)
1033) input%force_units = PETSC_FALSE
1034) case('WELL')
1035) internal_units = 'Pa'
1036) call ConditionReadValues(input,option,word, &
1037) well%dataset, &
1038) well%units,internal_units)
1039) case('FLUX','VELOCITY','VEL')
1040) internal_units = 'meter/sec'
1041) call ConditionReadValues(input,option,word, &
1042) pressure%dataset, &
1043) pressure%units,internal_units)
1044) case('CONC','CONCENTRATION')
1045) internal_units = 'unitless'
1046) call ConditionReadValues(input,option,word, &
1047) concentration%dataset, &
1048) concentration%units,internal_units)
1049) case('SAT','SATURATION')
1050) internal_units = 'unitless'
1051) call ConditionReadValues(input,option,word, &
1052) saturation%dataset, &
1053) saturation%units,internal_units)
1054) case('CONDUCTANCE')
1055) call InputReadDouble(input,option,pressure%aux_real(1))
1056) call InputErrorMsg(input,option,'CONDUCTANCE','CONDITION')
1057) case default
1058) call InputKeywordUnrecognized(word,'flow condition',option)
1059) end select
1060)
1061) enddo
1062)
1063) ! check whether
1064) if (default_iphase == 0) then
1065) option%io_buffer = '"iphase" not set in condition; set to 1'
1066) call printWrnMsg(option)
1067) condition%iphase = 1
1068) else
1069) condition%iphase = default_iphase
1070) endif
1071)
1072) ! datum is not required
1073) call DatasetVerify(condition%datum,default_time_storage,option)
1074)
1075) ! check to ensure that a rate condition is not of type pressure
1076) if (associated(rate)) then
1077) select case(rate%itype)
1078) case(DIRICHLET_BC,NEUMANN_BC,HYDROSTATIC_BC,UNIT_GRADIENT_BC, &
1079) CONDUCTANCE_BC,ZERO_GRADIENT_BC,SEEPAGE_BC)
1080) option%io_buffer = 'RATE condition must not be of type: dirichlet, ' // &
1081) 'neumann, zero_gradient, dirichlet_zero_gradient, hydrostatic, ' // &
1082) 'seepage, or conductance".'
1083) call printErrMsg(option)
1084) end select
1085) endif
1086) ! check to ensure that a pressure condition is not of type rate
1087) if (associated(pressure)) then
1088) select case(pressure%itype)
1089) case(MASS_RATE_SS,SCALED_MASS_RATE_SS,VOLUMETRIC_RATE_SS, &
1090) SCALED_VOLUMETRIC_RATE_SS,EQUILIBRIUM_SS)
1091) option%io_buffer = 'PRESSURE or FLUX condition must not be of type: ' // &
1092) 'mass_rate, scaled_mass_rate, volumetric_rate, ' // &
1093) 'scaled_volumetric_rate, equilibrium, or production_well.'
1094) call printErrMsg(option)
1095) end select
1096) endif
1097)
1098) ! verify the datasets
1099) word = 'pressure/flux'
1100) call FlowSubConditionVerify(option,condition,word,pressure, &
1101) default_time_storage, &
1102) PETSC_TRUE)
1103) word = 'rate'
1104) call FlowSubConditionVerify(option,condition,word,rate, &
1105) default_time_storage, &
1106) PETSC_TRUE)
1107) word = 'energy_flux'
1108) call FlowSubConditionVerify(option,condition,word,energy_flux, &
1109) default_time_storage, &
1110) PETSC_TRUE)
1111) word = 'energy_rate'
1112) call FlowSubConditionVerify(option,condition,word,energy_rate, &
1113) default_time_storage, &
1114) PETSC_TRUE)
1115) word = 'well'
1116) call FlowSubConditionVerify(option,condition,word,well, &
1117) default_time_storage, &
1118) PETSC_TRUE)
1119) word = 'temperature'
1120) call FlowSubConditionVerify(option,condition,word,temperature, &
1121) default_time_storage, &
1122) PETSC_TRUE)
1123) word = 'saturation'
1124) call FlowSubConditionVerify(option,condition,word,saturation, &
1125) default_time_storage, &
1126) PETSC_TRUE)
1127)
1128) word = 'concentration'
1129) call FlowSubConditionVerify(option,condition,word,concentration, &
1130) default_time_storage, &
1131) PETSC_TRUE)
1132) word = 'enthalpy'
1133) call FlowSubConditionVerify(option,condition,word,enthalpy, &
1134) default_time_storage, &
1135) PETSC_TRUE)
1136)
1137) select case(option%iflowmode)
1138) case(G_MODE)
1139) option%io_buffer = 'General mode not supported in original FlowConditionRead.'
1140) call printMsg(option)
1141) case(TOIL_IMS_MODE)
1142) option%io_buffer = 'TOilIms mode not supported in original FlowConditionRead.'
1143) call printMsg(option)
1144) case(MPH_MODE,IMS_MODE,FLASH2_MODE)
1145) if (.not.associated(pressure) .and. .not.associated(rate)&
1146) .and. .not.associated(well) .and. .not.associated(saturation)) then
1147) option%io_buffer = 'pressure, rate and saturation condition null in ' // &
1148) 'condition: ' // trim(condition%name)
1149) call printErrMsg(option)
1150) endif
1151)
1152) if (associated(pressure)) then
1153) condition%pressure => pressure
1154) endif
1155) if (associated(rate)) then
1156) condition%rate => rate
1157) endif
1158) if (associated(well)) then
1159) condition%well => well
1160) endif
1161) if (associated(saturation)) then
1162) condition%saturation => saturation
1163) endif
1164)
1165)
1166) if (.not.associated(temperature) .and. .not.associated(energy_rate)) then
1167) option%io_buffer = 'temperature and energy rate condition null in condition: ' // &
1168) trim(condition%name)
1169) call printErrMsg(option)
1170) endif
1171) if (associated(temperature)) then
1172) condition%temperature => temperature
1173) endif
1174) if (associated(energy_flux)) then
1175) condition%energy_flux => energy_flux
1176) endif
1177) if (associated(energy_rate)) then
1178) condition%energy_rate => energy_rate
1179) endif
1180)
1181) if (.not.associated(concentration)) then
1182) option%io_buffer = 'concentration condition null in condition: ' // &
1183) trim(condition%name)
1184) call printErrMsg(option)
1185) endif
1186) condition%concentration => concentration
1187)
1188) if (.not.associated(enthalpy)) then
1189) option%io_buffer = 'enthalpy condition null in condition: ' // &
1190) trim(condition%name)
1191) call printErrMsg(option)
1192) endif
1193) condition%enthalpy => enthalpy
1194)
1195) condition%num_sub_conditions = 4
1196) allocate(condition%sub_condition_ptr(condition%num_sub_conditions))
1197) do idof = 1, 4
1198) nullify(condition%sub_condition_ptr(idof)%ptr)
1199) enddo
1200)
1201) ! must be in this order, which matches the dofs i problem
1202) if (associated(pressure)) condition%sub_condition_ptr(ONE_INTEGER)%ptr => pressure
1203) if (associated(rate)) condition%sub_condition_ptr(ONE_INTEGER)%ptr => rate
1204) if (associated(well)) condition%sub_condition_ptr(ONE_INTEGER)%ptr => well
1205) if (associated(saturation)) condition%sub_condition_ptr(ONE_INTEGER)%ptr &
1206) => saturation
1207) condition%sub_condition_ptr(TWO_INTEGER)%ptr => temperature
1208) condition%sub_condition_ptr(THREE_INTEGER)%ptr => concentration
1209) if (associated(enthalpy)) condition%sub_condition_ptr(FOUR_INTEGER)%ptr => enthalpy
1210) if (associated(energy_rate)) &
1211) condition%sub_condition_ptr(FOUR_INTEGER)%ptr => energy_rate
1212)
1213) allocate(condition%itype(FIVE_INTEGER))
1214) condition%itype = 0
1215) if (associated(pressure)) condition%itype(ONE_INTEGER) = pressure%itype
1216) if (associated(rate)) condition%itype(ONE_INTEGER) = rate%itype
1217) if (associated(well)) condition%itype(ONE_INTEGER) = well%itype
1218) if (associated(saturation)) condition%itype(ONE_INTEGER) = &
1219) saturation%itype
1220) condition%itype(TWO_INTEGER) = temperature%itype
1221) condition%itype(THREE_INTEGER) = concentration%itype
1222) if (associated(enthalpy)) condition%itype(FOUR_INTEGER) = concentration%itype
1223) if (associated(energy_rate)) condition%itype(FOUR_INTEGER) = energy_rate%itype
1224)
1225) case(TH_MODE)
1226) if (.not.associated(pressure) .and. .not.associated(rate)&
1227) .and. .not.associated(well) .and. .not.associated(saturation)) then
1228) option%io_buffer = 'pressure, rate and saturation condition null in ' // &
1229) 'condition: ' // trim(condition%name)
1230) call printErrMsg(option)
1231) endif
1232)
1233) if (associated(pressure)) then
1234) condition%pressure => pressure
1235) endif
1236) if (associated(rate)) then
1237) condition%rate => rate
1238) endif
1239) if (associated(well)) then
1240) condition%well => well
1241) endif
1242) if (associated(saturation)) then
1243) condition%saturation => saturation
1244) endif
1245)
1246) if (.not.associated(temperature) .and. .not.associated(energy_rate) &
1247) .and. .not.associated(energy_flux)) then
1248) option%io_buffer = 'temperature, energy_flux, and energy_rate ' // &
1249) 'condition null in condition: ' // trim(condition%name)
1250) call printErrMsg(option)
1251) endif
1252) if (associated(temperature) .and. associated(energy_rate) ) then
1253) option%io_buffer = 'Both, temperature and energy_rate cannot be ' // &
1254) 'specified in condition: ' // trim(condition%name)
1255) call printErrMsg(option)
1256) endif
1257) if (associated(temperature)) condition%temperature => temperature
1258) if (associated(energy_flux)) condition%energy_flux => energy_flux
1259) if (associated(energy_rate)) condition%energy_rate => energy_rate
1260)
1261) if (associated(enthalpy)) then
1262) option%io_buffer = 'enthalpy condition not supported in TH mode: ' // &
1263) trim(condition%name)
1264) call printErrMsg(option)
1265) endif
1266) if (associated(enthalpy)) condition%enthalpy => enthalpy
1267)
1268) condition%num_sub_conditions = TWO_INTEGER
1269) allocate(condition%sub_condition_ptr(condition%num_sub_conditions))
1270) do idof = 1, 2
1271) nullify(condition%sub_condition_ptr(idof)%ptr)
1272) enddo
1273)
1274) ! must be in this order, which matches the dofs i problem
1275) if (associated(pressure)) condition%sub_condition_ptr(ONE_INTEGER)%ptr => pressure
1276) if (associated(rate)) condition%sub_condition_ptr(ONE_INTEGER)%ptr => rate
1277) if (associated(well)) condition%sub_condition_ptr(ONE_INTEGER)%ptr => well
1278) if (associated(saturation)) condition%sub_condition_ptr(ONE_INTEGER)%ptr &
1279) => saturation
1280) if ( associated(temperature)) &
1281) condition%sub_condition_ptr(TWO_INTEGER)%ptr => temperature
1282) if (associated(energy_flux)) condition%sub_condition_ptr(TWO_INTEGER)%ptr => energy_flux
1283) if (associated(energy_rate)) condition%sub_condition_ptr(TWO_INTEGER)%ptr => energy_rate
1284)
1285) allocate(condition%itype(TWO_INTEGER))
1286) condition%itype = 0
1287) if (associated(pressure)) condition%itype(ONE_INTEGER) = pressure%itype
1288) if (associated(rate)) condition%itype(ONE_INTEGER) = rate%itype
1289) if (associated(well)) condition%itype(ONE_INTEGER) = well%itype
1290) if (associated(saturation)) condition%itype(ONE_INTEGER) = &
1291) saturation%itype
1292) if (associated(temperature)) condition%itype(TWO_INTEGER) = temperature%itype
1293) if (associated(energy_flux)) condition%itype(TWO_INTEGER) = energy_flux%itype
1294) if (associated(energy_rate)) condition%itype(TWO_INTEGER) = energy_rate%itype
1295)
1296) !#if 0
1297) case(MIS_MODE)
1298) if (.not.associated(pressure) .and. .not.associated(rate)&
1299) .and. .not.associated(well)) then
1300) option%io_buffer = 'pressure and rate condition null in ' // &
1301) 'condition: ' // trim(condition%name)
1302) call printErrMsg(option)
1303) endif
1304)
1305) if (associated(pressure)) then
1306) condition%pressure => pressure
1307) endif
1308) if (associated(rate)) then
1309) condition%rate => rate
1310) endif
1311) if (associated(well)) then
1312) condition%well => well
1313) endif
1314)
1315) if (.not.associated(concentration)) then
1316) option%io_buffer = 'concentration condition null in condition: ' // &
1317) trim(condition%name)
1318) call printErrMsg(option)
1319) endif
1320) condition%concentration => concentration
1321)
1322) #if 0
1323) if (.not.associated(temperature)) then
1324) option%io_buffer = 'temperature condition null in condition: ' // &
1325) trim(condition%name)
1326) call printErrMsg(option)
1327) endif
1328) condition%temperature => temperature
1329)
1330) if (.not.associated(enthalpy)) then
1331) option%io_buffer = 'enthalpy condition null in condition: ' // &
1332) trim(condition%name)
1333) call printErrMsg(option)
1334) endif
1335) condition%enthalpy => enthalpy
1336) #endif
1337)
1338) condition%num_sub_conditions = 2
1339) allocate(condition%sub_condition_ptr(condition%num_sub_conditions))
1340) do idof = 1, 2
1341) nullify(condition%sub_condition_ptr(idof)%ptr)
1342) enddo
1343)
1344) ! must be in this order, which matches the dofs in problem
1345) if (associated(pressure)) condition%sub_condition_ptr(ONE_INTEGER)%ptr => pressure
1346) if (associated(rate)) condition%sub_condition_ptr(ONE_INTEGER)%ptr => rate
1347) if (associated(well)) condition%sub_condition_ptr(ONE_INTEGER)%ptr => well
1348) ! condition%sub_condition_ptr(TWO_INTEGER)%ptr => temperature
1349) condition%sub_condition_ptr(TWO_INTEGER)%ptr => concentration
1350) ! if (associated(enthalpy)) condition%sub_condition_ptr(FOUR_INTEGER)%ptr => enthalpy
1351)
1352) allocate(condition%itype(TWO_INTEGER))
1353) condition%itype = 0
1354) if (associated(pressure)) condition%itype(ONE_INTEGER) = pressure%itype
1355) if (associated(rate)) condition%itype(ONE_INTEGER) = rate%itype
1356) if (associated(well)) condition%itype(ONE_INTEGER) = well%itype
1357) condition%itype(TWO_INTEGER) = concentration%itype
1358) !#endif
1359)
1360) case(RICHARDS_MODE)
1361) if (.not.associated(pressure) .and. .not.associated(rate) .and. &
1362) .not.associated(saturation) .and. .not.associated(well)) then
1363) option%io_buffer = 'pressure, rate and saturation condition null in ' // &
1364) 'condition: ' // trim(condition%name)
1365) call printErrMsg(option)
1366) endif
1367)
1368) if (associated(saturation)) then
1369) condition%saturation => saturation
1370) endif
1371) if (associated(pressure)) then
1372) condition%pressure => pressure
1373) endif
1374) if (associated(rate)) then
1375) condition%rate => rate
1376) endif
1377) if (associated(well)) then
1378) condition%well => well
1379) endif
1380)
1381) condition%num_sub_conditions = 1
1382) allocate(condition%sub_condition_ptr(condition%num_sub_conditions))
1383) if (associated(pressure)) then
1384) condition%sub_condition_ptr(ONE_INTEGER)%ptr => pressure
1385) elseif (associated(saturation)) then
1386) condition%sub_condition_ptr(ONE_INTEGER)%ptr => saturation
1387) elseif (associated(rate)) then
1388) condition%sub_condition_ptr(ONE_INTEGER)%ptr => rate
1389) elseif (associated(well)) then
1390) condition%sub_condition_ptr(ONE_INTEGER)%ptr => well
1391) endif
1392)
1393) allocate(condition%itype(ONE_INTEGER))
1394) if (associated(pressure)) then
1395) condition%itype(ONE_INTEGER) = pressure%itype
1396) else if (associated(saturation)) then
1397) condition%itype(ONE_INTEGER) = saturation%itype
1398) else if (associated(rate)) then
1399) condition%itype(ONE_INTEGER) = rate%itype
1400) else if (associated(well)) then
1401) condition%itype(ONE_INTEGER) = well%itype
1402) endif
1403)
1404) ! these are not used with richards
1405) if (associated(temperature)) call FlowSubConditionDestroy(temperature)
1406) if (associated(enthalpy)) call FlowSubConditionDestroy(enthalpy)
1407)
1408) end select
1409)
1410) condition%default_time_storage => default_time_storage
1411)
1412) call PetscLogEventEnd(logging%event_flow_condition_read,ierr);CHKERRQ(ierr)
1413)
1414) end subroutine FlowConditionRead
1415)
1416) ! ************************************************************************** !
1417)
1418) subroutine FlowConditionGeneralRead(condition,input,option)
1419) !
1420) ! Reads a condition from the input file for
1421) ! general mode
1422) !
1423) ! Author: Glenn Hammond
1424) ! Date: 09/14/11
1425) !
1426)
1427) use Option_module
1428) use Input_Aux_module
1429) use String_module
1430) use Logging_module
1431) use Time_Storage_module
1432) use Dataset_module
1433)
1434) use General_Aux_module
1435)
1436) implicit none
1437)
1438) type(flow_condition_type) :: condition
1439) type(input_type), pointer :: input
1440) type(option_type) :: option
1441)
1442) character(len=MAXSTRINGLENGTH) :: string
1443) character(len=MAXWORDLENGTH) :: rate_string, internal_units
1444) character(len=MAXWORDLENGTH) :: word
1445) type(flow_general_condition_type), pointer :: general
1446) type(flow_sub_condition_type), pointer :: sub_condition_ptr
1447) PetscReal :: default_time
1448) PetscInt :: default_iphase
1449) class(dataset_base_type), pointer :: default_flow_dataset
1450) class(dataset_base_type), pointer :: default_gradient
1451) PetscInt :: idof, i
1452) PetscBool :: default_is_cyclic
1453) type(time_storage_type), pointer :: default_time_storage
1454) class(dataset_ascii_type), pointer :: dataset_ascii
1455) PetscErrorCode :: ierr
1456)
1457) call PetscLogEventBegin(logging%event_flow_condition_read, &
1458) ierr);CHKERRQ(ierr)
1459)
1460) rate_string = 'not_assigned'
1461) internal_units = 'not_assigned'
1462)
1463) default_time = 0.d0
1464) default_iphase = 0
1465)
1466) default_time_storage => TimeStorageCreate()
1467) default_time_storage%is_cyclic = PETSC_FALSE
1468) default_time_storage%time_interpolation_method = INTERPOLATION_STEP
1469)
1470) select case(option%iflowmode)
1471) case(G_MODE)
1472) general => FlowGeneralConditionCreate(option)
1473) condition%general => general
1474) end select
1475)
1476) ! read the condition
1477) input%ierr = 0
1478) do
1479)
1480) call InputReadPflotranString(input,option)
1481) call InputReadStringErrorMsg(input,option,'CONDITION')
1482)
1483) if (InputCheckExit(input,option)) exit
1484)
1485) call InputReadWord(input,option,word,PETSC_TRUE)
1486) call InputErrorMsg(input,option,'keyword','CONDITION')
1487)
1488) select case(trim(word))
1489)
1490) case('CYCLIC')
1491) ! by default, is_cyclic is set to PETSC_FALSE
1492) default_time_storage%is_cyclic = PETSC_TRUE
1493) case('SYNC_TIMESTEP_WITH_UPDATE')
1494) condition%sync_time_with_update = PETSC_TRUE
1495) case('INTERPOLATION')
1496) call InputReadWord(input,option,word,PETSC_TRUE)
1497) call InputErrorMsg(input,option,'INTERPOLATION','CONDITION')
1498) call StringToLower(word)
1499) select case(word)
1500) case('step')
1501) default_time_storage%time_interpolation_method = &
1502) INTERPOLATION_STEP
1503) case('linear')
1504) default_time_storage%time_interpolation_method = &
1505) INTERPOLATION_LINEAR
1506) end select
1507) case('TYPE') ! read condition type (dirichlet, neumann, etc) for each dof
1508) do
1509) call InputReadPflotranString(input,option)
1510) call InputReadStringErrorMsg(input,option,'CONDITION')
1511)
1512) if (InputCheckExit(input,option)) exit
1513)
1514) if (InputError(input)) exit
1515) call InputReadWord(input,option,word,PETSC_TRUE)
1516) call InputErrorMsg(input,option,'keyword','CONDITION,TYPE')
1517) call StringToUpper(word)
1518) select case(option%iflowmode)
1519) case(G_MODE)
1520) sub_condition_ptr => FlowGeneralSubConditionPtr(word,general, &
1521) option)
1522) end select
1523) call InputReadWord(input,option,word,PETSC_TRUE)
1524) call InputErrorMsg(input,option,'TYPE','CONDITION')
1525) call StringToLower(word)
1526) sub_condition_ptr%ctype = word
1527) select case(word)
1528) case('dirichlet')
1529) sub_condition_ptr%itype = DIRICHLET_BC
1530) case('neumann')
1531) sub_condition_ptr%itype = NEUMANN_BC
1532) case('hydrostatic')
1533) sub_condition_ptr%itype = HYDROSTATIC_BC
1534) case('conductance')
1535) sub_condition_ptr%itype = CONDUCTANCE_BC
1536) case('seepage')
1537) sub_condition_ptr%itype = SEEPAGE_BC
1538) case('mass_rate')
1539) sub_condition_ptr%itype = MASS_RATE_SS
1540) rate_string = 'kg/sec'
1541) case('scaled_mass_rate')
1542) sub_condition_ptr%itype = SCALED_MASS_RATE_SS
1543) rate_string = 'kg/sec'
1544) call InputReadWord(input,option,word,PETSC_TRUE)
1545) if (input%ierr == 0) then
1546) call StringToLower(word)
1547) sub_condition_ptr%ctype = trim(sub_condition_ptr%ctype) // word
1548) select case(word)
1549) case('neighbor_perm')
1550) sub_condition_ptr%isubtype = SCALE_BY_NEIGHBOR_PERM
1551) case('volume')
1552) sub_condition_ptr%isubtype = SCALE_BY_VOLUME
1553) case('perm')
1554) sub_condition_ptr%isubtype = SCALE_BY_PERM
1555) case default
1556) string = 'flow condition "' // trim(condition%name) // &
1557) '" scaled_mass_rate type'
1558) call InputKeywordUnrecognized(word,string,option)
1559) end select
1560) else
1561) option%io_buffer = 'Specify one of NEIGHBOR_PERM, ' // &
1562) 'VOLUME, PERM subtypes in '// &
1563) 'flow condition "' // trim(condition%name) // &
1564) '" scaled_mass_rate type'
1565) call printErrMsg(option)
1566) endif
1567) case('volumetric_rate')
1568) sub_condition_ptr%itype = VOLUMETRIC_RATE_SS
1569) rate_string = 'm^3/sec'
1570) case('scaled_volumetric_rate')
1571) sub_condition_ptr%itype = SCALED_VOLUMETRIC_RATE_SS
1572) rate_string = 'm^3/sec'
1573) call InputReadWord(input,option,word,PETSC_TRUE)
1574) if (input%ierr == 0) then
1575) call StringToLower(word)
1576) sub_condition_ptr%ctype = trim(sub_condition_ptr%ctype) // word
1577) select case(word)
1578) case('neighbor_perm')
1579) sub_condition_ptr%isubtype = SCALE_BY_NEIGHBOR_PERM
1580) case('volume')
1581) sub_condition_ptr%isubtype = SCALE_BY_VOLUME
1582) case('perm')
1583) sub_condition_ptr%isubtype = SCALE_BY_PERM
1584) case default
1585) string = 'flow condition "' // trim(condition%name) // &
1586) '" scaled_volumetric_rate type'
1587) call InputKeywordUnrecognized(word,string,option)
1588) end select
1589) else
1590) option%io_buffer = 'Specify one of NEIGHBOR_PERM, ' // &
1591) 'VOLUME, PERM subtypes in '// &
1592) 'flow condition "' // trim(condition%name) // &
1593) '" scaled_volumetric_rate type'
1594) call printErrMsg(option)
1595) endif
1596) case('heterogeneous_volumetric_rate')
1597) sub_condition_ptr%itype = HET_VOL_RATE_SS
1598) rate_string = 'm^3/sec'
1599) case('heterogeneous_mass_rate')
1600) sub_condition_ptr%itype = HET_MASS_RATE_SS
1601) rate_string = 'kg/sec'
1602) case('heterogeneous_dirichlet')
1603) sub_condition_ptr%itype = HET_DIRICHLET
1604) case('heterogeneous_surface_seepage')
1605) sub_condition_ptr%itype = HET_SURF_SEEPAGE_BC
1606) case default
1607) call InputKeywordUnrecognized(word,'flow condition,type',option)
1608) end select
1609) enddo
1610) case('DATUM')
1611) dataset_ascii => DatasetAsciiCreate()
1612) call DatasetAsciiInit(dataset_ascii)
1613) dataset_ascii%array_width = 3
1614) dataset_ascii%data_type = DATASET_REAL
1615) condition%datum => dataset_ascii
1616) nullify(dataset_ascii)
1617) internal_units = 'meter'
1618) call ConditionReadValues(input,option,word,condition%datum, &
1619) word,internal_units)
1620) case('GRADIENT')
1621) do
1622) call InputReadPflotranString(input,option)
1623) call InputReadStringErrorMsg(input,option,'CONDITION')
1624)
1625) if (InputCheckExit(input,option)) exit
1626)
1627) if (InputError(input)) exit
1628) call InputReadWord(input,option,word,PETSC_TRUE)
1629) call InputErrorMsg(input,option,'keyword','CONDITION,TYPE')
1630) call StringToUpper(word)
1631) select case(option%iflowmode)
1632) case(G_MODE)
1633) sub_condition_ptr => FlowGeneralSubConditionPtr(word,general, &
1634) option)
1635) end select
1636) dataset_ascii => DatasetAsciiCreate()
1637) call DatasetAsciiInit(dataset_ascii)
1638) dataset_ascii%array_width = 3
1639) dataset_ascii%data_type = DATASET_REAL
1640) sub_condition_ptr%gradient => dataset_ascii
1641) nullify(dataset_ascii)
1642) internal_units = 'unitless/meter'
1643) call ConditionReadValues(input,option,word, &
1644) sub_condition_ptr%gradient, &
1645) word,internal_units)
1646) nullify(sub_condition_ptr)
1647) enddo
1648) case('CONDUCTANCE')
1649) word = 'LIQUID_PRESSURE'
1650) select case(option%iflowmode)
1651) case(G_MODE)
1652) sub_condition_ptr => FlowGeneralSubConditionPtr(word,general, &
1653) option)
1654) end select
1655) call InputReadDouble(input,option,sub_condition_ptr%aux_real(1))
1656) call InputErrorMsg(input,option,'LIQUID_CONDUCTANCE','CONDITION')
1657) case('LIQUID_PRESSURE','GAS_PRESSURE','LIQUID_SATURATION', &
1658) 'GAS_SATURATION','TEMPERATURE','MOLE_FRACTION','RATE', &
1659) 'LIQUID_FLUX','GAS_FLUX','ENERGY_FLUX','RELATIVE_HUMIDITY')
1660) select case(option%iflowmode)
1661) case(G_MODE)
1662) sub_condition_ptr => FlowGeneralSubConditionPtr(word,general, &
1663) option)
1664) end select
1665) select case(trim(word))
1666) case('LIQUID_PRESSURE','GAS_PRESSURE')
1667) internal_units = 'Pa'
1668) case('LIQUID_SATURATION','GAS_SATURATION','MOLE_FRACTION', &
1669) 'RELATIVE_HUMIDITY')
1670) internal_units = 'unitless'
1671) case('TEMPERATURE')
1672) internal_units = 'C'
1673) case('RATE')
1674) input%force_units = PETSC_TRUE
1675) input%err_buf = word
1676) internal_units = trim(rate_string) // ',' // trim(rate_string) //&
1677) ',MJ/sec|MW'
1678) case('LIQUID_FLUX','GAS_FLUX')
1679) internal_units = 'meter/sec'
1680) case('ENERGY_FLUX')
1681) input%force_units = PETSC_TRUE
1682) input%err_buf = word
1683) internal_units = 'MW/m^2|MJ/m^2-sec'
1684) end select
1685) call ConditionReadValues(input,option,word, &
1686) sub_condition_ptr%dataset, &
1687) sub_condition_ptr%units,internal_units)
1688) input%force_units = PETSC_FALSE
1689) select case(word)
1690) case('LIQUID_SATURATION') ! convert to gas saturation
1691) if (associated(sub_condition_ptr%dataset%rbuffer)) then
1692) sub_condition_ptr%dataset%rbuffer(:) = 1.d0 - &
1693) sub_condition_ptr%dataset%rbuffer(:)
1694) endif
1695) sub_condition_ptr%dataset%rarray(:) = 1.d0 - &
1696) sub_condition_ptr%dataset%rarray(:)
1697) end select
1698) case default
1699) call InputKeywordUnrecognized(word,'flow condition',option)
1700) end select
1701)
1702) enddo
1703)
1704) ! datum is not required
1705) call DatasetVerify(condition%datum,default_time_storage,option)
1706)
1707) ! need mole fraction and some sort of saturation
1708) if (.false.) then
1709) ! neumann or mass/volumetric flux
1710) ! need temperature
1711) ! condition%sub_condition_ptr(GENERAL_FLUX_DOF)%ptr => general%flux
1712) if (.not.associated(general%mole_fraction) .and. &
1713) .not.associated(general%gas_saturation)) then
1714) option%io_buffer = 'General Phase flux condition must include ' // &
1715) 'a MOLE_FRACTION or GAS/LIQUID_SATURATION.'
1716) call printErrMsg(option)
1717) endif
1718) if (associated(general%mole_fraction) .and. &
1719) associated(general%gas_saturation)) then
1720) option%io_buffer = 'General Phase flux condition must include ' // &
1721) 'only a MOLE_FRACTION or GAS/LIQUID_SATURATION, not both.'
1722) call printErrMsg(option)
1723) endif
1724) if (.not.associated(general%temperature)) then
1725) option%io_buffer = 'General Phase flux condition must include ' // &
1726) 'a temperature'
1727) call printErrMsg(option)
1728) endif
1729) else
1730) if (associated(general%rate)) then
1731) condition%iphase = ANY_STATE
1732) elseif (associated(general%liquid_flux) .and. &
1733) associated(general%gas_flux) .and. &
1734) (associated(general%energy_flux) .or. &
1735) associated(general%temperature))) then
1736) condition%iphase = ANY_STATE
1737) else
1738) ! some sort of dirichlet-based pressure, temperature, etc.
1739) if (.not.associated(general%liquid_pressure) .and. &
1740) .not.associated(general%gas_pressure)) then
1741) option%io_buffer = 'General Phase non-rate condition must ' // &
1742) 'include a liquid or gas pressure'
1743) call printErrMsg(option)
1744) endif
1745) if (.not.associated(general%mole_fraction) .and. &
1746) .not.associated(general%relative_humidity) .and. &
1747) .not.associated(general%gas_saturation)) then
1748) option%io_buffer = 'General Phase non-rate condition must ' // &
1749) 'include mole fraction, relative humidity, or gas/liquid saturation'
1750) call printErrMsg(option)
1751) endif
1752) if (.not.associated(general%temperature)) then
1753) option%io_buffer = 'General Phase non-rate condition must ' // &
1754) 'include temperature'
1755) call printErrMsg(option)
1756) endif
1757) if (associated(general%gas_pressure) .and. &
1758) associated(general%gas_saturation)) then
1759) ! two phase condition
1760) condition%iphase = TWO_PHASE_STATE
1761) else if (associated(general%liquid_pressure) .and. &
1762) associated(general%mole_fraction)) then
1763) ! liquid phase condition
1764) condition%iphase = LIQUID_STATE
1765) else if (associated(general%gas_pressure) .and. &
1766) (associated(general%mole_fraction) .or. &
1767) associated(general%relative_humidity))) then
1768) ! gas phase condition
1769) condition%iphase = GAS_STATE
1770) endif
1771) endif
1772) if (condition%iphase == NULL_STATE) then
1773) option%io_buffer = 'General Phase non-rate/flux condition contains ' // &
1774) 'an unsupported combination of primary dependent variables.'
1775) call printErrMsg(option)
1776) endif
1777) endif
1778)
1779) ! verify the datasets
1780) word = 'liquid pressure'
1781) call FlowSubConditionVerify(option,condition,word,general%liquid_pressure, &
1782) default_time_storage, &
1783) PETSC_TRUE)
1784) word = 'gas pressure'
1785) call FlowSubConditionVerify(option,condition,word,general%gas_pressure, &
1786) default_time_storage, &
1787) PETSC_TRUE)
1788) word = 'gas saturation'
1789) call FlowSubConditionVerify(option,condition,word,general%gas_saturation, &
1790) default_time_storage, &
1791) PETSC_TRUE)
1792) word = 'relative humidity'
1793) call FlowSubConditionVerify(option,condition,word,general%relative_humidity, &
1794) default_time_storage, &
1795) PETSC_TRUE)
1796) word = 'mole fraction'
1797) call FlowSubConditionVerify(option,condition,word,general%mole_fraction, &
1798) default_time_storage, &
1799) PETSC_TRUE)
1800) word = 'temperature'
1801) call FlowSubConditionVerify(option,condition,word,general%temperature, &
1802) default_time_storage, &
1803) PETSC_TRUE)
1804) word = 'liquid flux'
1805) call FlowSubConditionVerify(option,condition,word,general%liquid_flux, &
1806) default_time_storage, &
1807) PETSC_TRUE)
1808) word = 'gas flux'
1809) call FlowSubConditionVerify(option,condition,word,general%gas_flux, &
1810) default_time_storage, &
1811) PETSC_TRUE)
1812) word = 'energy flux'
1813) call FlowSubConditionVerify(option,condition,word,general%energy_flux, &
1814) default_time_storage, &
1815) PETSC_TRUE)
1816) word = 'rate'
1817) call FlowSubConditionVerify(option,condition,word,general%rate, &
1818) default_time_storage, &
1819) PETSC_TRUE)
1820)
1821) condition%num_sub_conditions = 0
1822) i = 0
1823) if (associated(general%liquid_pressure)) &
1824) i = i + 1
1825) if (associated(general%gas_pressure)) &
1826) i = i + 1
1827) if (associated(general%gas_saturation)) &
1828) i = i + 1
1829) if (associated(general%relative_humidity)) &
1830) i = i + 1
1831) if (associated(general%mole_fraction)) &
1832) i = i + 1
1833) if (associated(general%temperature)) &
1834) i = i + 1
1835) if (associated(general%liquid_flux)) &
1836) i = i + 1
1837) if (associated(general%gas_flux)) &
1838) i = i + 1
1839) if (associated(general%energy_flux)) &
1840) i = i + 1
1841) if (associated(general%rate)) &
1842) i = i + 1
1843) condition%num_sub_conditions = i
1844) allocate(condition%sub_condition_ptr(condition%num_sub_conditions))
1845) do idof = 1, condition%num_sub_conditions
1846) nullify(condition%sub_condition_ptr(idof)%ptr)
1847) enddo
1848) i = 0
1849) if (associated(general%liquid_pressure)) then
1850) i = i + 1
1851) condition%sub_condition_ptr(i)%ptr => general%liquid_pressure
1852) endif
1853) if (associated(general%gas_pressure)) then
1854) i = i + 1
1855) condition%sub_condition_ptr(i)%ptr => general%gas_pressure
1856) endif
1857) if (associated(general%gas_saturation)) then
1858) i = i + 1
1859) condition%sub_condition_ptr(i)%ptr => general%gas_saturation
1860) endif
1861) if (associated(general%relative_humidity)) then
1862) i = i + 1
1863) condition%sub_condition_ptr(i)%ptr => general%relative_humidity
1864) endif
1865) if (associated(general%mole_fraction)) then
1866) i = i + 1
1867) condition%sub_condition_ptr(i)%ptr => general%mole_fraction
1868) endif
1869) if (associated(general%temperature)) then
1870) i = i + 1
1871) condition%sub_condition_ptr(i)%ptr => general%temperature
1872) endif
1873) if (associated(general%liquid_flux)) then
1874) i = i + 1
1875) condition%sub_condition_ptr(i)%ptr => general%liquid_flux
1876) endif
1877) if (associated(general%gas_flux)) then
1878) i = i + 1
1879) condition%sub_condition_ptr(i)%ptr => general%gas_flux
1880) endif
1881) if (associated(general%energy_flux)) then
1882) i = i + 1
1883) condition%sub_condition_ptr(i)%ptr => general%energy_flux
1884) endif
1885) if (associated(general%rate)) then
1886) i = i + 1
1887) condition%sub_condition_ptr(i)%ptr => general%rate
1888) endif
1889)
1890) ! set condition types
1891) allocate(condition%itype(condition%num_sub_conditions))
1892) do idof = 1, condition%num_sub_conditions
1893) condition%itype(idof) = condition%sub_condition_ptr(idof)%ptr%itype
1894) enddo
1895)
1896) condition%default_time_storage => default_time_storage
1897)
1898) call PetscLogEventEnd(logging%event_flow_condition_read,ierr);CHKERRQ(ierr)
1899)
1900) end subroutine FlowConditionGeneralRead
1901)
1902) ! ************************************************************************** !
1903)
1904) subroutine FlowConditionTOilImsRead(condition,input,option)
1905) !
1906) ! Reads a condition from the input file for
1907) ! toil_ims mode
1908) !
1909) ! Author: Paolo Orsini (OGS)
1910) ! Date: 9/9/2015
1911) !
1912)
1913) use Option_module
1914) use Input_Aux_module
1915) use String_module
1916) use Logging_module
1917) use Time_Storage_module
1918) use Dataset_module
1919)
1920) use TOilIms_Aux_module
1921)
1922) implicit none
1923)
1924) type(flow_condition_type) :: condition
1925) type(input_type), pointer :: input
1926) type(option_type) :: option
1927)
1928) character(len=MAXSTRINGLENGTH) :: string
1929) character(len=MAXWORDLENGTH) :: rate_string, internal_units
1930) character(len=MAXWORDLENGTH) :: word
1931) type(flow_toil_ims_condition_type), pointer :: toil_ims
1932) type(flow_sub_condition_type), pointer :: sub_condition_ptr
1933) PetscReal :: default_time
1934) PetscInt :: default_iphase
1935) class(dataset_base_type), pointer :: default_flow_dataset
1936) class(dataset_base_type), pointer :: default_gradient
1937) PetscInt :: idof, i
1938) PetscBool :: default_is_cyclic
1939) type(time_storage_type), pointer :: default_time_storage
1940) class(dataset_ascii_type), pointer :: dataset_ascii
1941) PetscErrorCode :: ierr
1942)
1943) call PetscLogEventBegin(logging%event_flow_condition_read, &
1944) ierr);CHKERRQ(ierr)
1945)
1946) rate_string = 'not_assigned'
1947) internal_units = 'not_assigned'
1948)
1949) default_time = 0.d0
1950) default_iphase = 0
1951)
1952) default_time_storage => TimeStorageCreate()
1953) default_time_storage%is_cyclic = PETSC_FALSE
1954) default_time_storage%time_interpolation_method = INTERPOLATION_STEP
1955)
1956) select case(option%iflowmode)
1957) ! do we really need this select case??
1958) case(TOIL_IMS_MODE)
1959) toil_ims => FlowTOilImsConditionCreate(option)
1960) condition%toil_ims => toil_ims
1961) end select
1962)
1963) ! read the condition
1964) input%ierr = 0
1965) do
1966)
1967) call InputReadPflotranString(input,option)
1968) call InputReadStringErrorMsg(input,option,'CONDITION')
1969)
1970) if (InputCheckExit(input,option)) exit
1971)
1972) call InputReadWord(input,option,word,PETSC_TRUE)
1973) call InputErrorMsg(input,option,'keyword','CONDITION')
1974)
1975) select case(trim(word))
1976)
1977) case('CYCLIC')
1978) ! by default, is_cyclic is set to PETSC_FALSE
1979) default_time_storage%is_cyclic = PETSC_TRUE
1980) case('SYNC_TIMESTEP_WITH_UPDATE')
1981) condition%sync_time_with_update = PETSC_TRUE
1982) case('INTERPOLATION')
1983) call InputReadWord(input,option,word,PETSC_TRUE)
1984) call InputErrorMsg(input,option,'INTERPOLATION','CONDITION')
1985) call StringToLower(word)
1986) select case(word)
1987) case('step')
1988) default_time_storage%time_interpolation_method = &
1989) INTERPOLATION_STEP
1990) case('linear')
1991) default_time_storage%time_interpolation_method = &
1992) INTERPOLATION_LINEAR
1993) end select
1994) case('TYPE') ! read condition type (dirichlet, neumann, etc) for each dof
1995) do
1996) call InputReadPflotranString(input,option)
1997) call InputReadStringErrorMsg(input,option,'CONDITION')
1998)
1999) if (InputCheckExit(input,option)) exit
2000)
2001) if (InputError(input)) exit
2002) call InputReadWord(input,option,word,PETSC_TRUE)
2003) call InputErrorMsg(input,option,'keyword','CONDITION,TYPE')
2004) call StringToUpper(word)
2005) select case(option%iflowmode)
2006) ! do we need this select case?
2007) case(TOIL_IMS_MODE)
2008) sub_condition_ptr => FlowTOilImsSubConditionPtr(word,toil_ims, &
2009) option)
2010) end select
2011) call InputReadWord(input,option,word,PETSC_TRUE)
2012) call InputErrorMsg(input,option,'TYPE','CONDITION')
2013) call StringToLower(word)
2014) sub_condition_ptr%ctype = word
2015) select case(word)
2016) case('dirichlet')
2017) sub_condition_ptr%itype = DIRICHLET_BC
2018) case('neumann')
2019) sub_condition_ptr%itype = NEUMANN_BC
2020) case('hydrostatic')
2021) sub_condition_ptr%itype = HYDROSTATIC_BC
2022) case('conductance')
2023) sub_condition_ptr%itype = CONDUCTANCE_BC
2024) case('seepage')
2025) sub_condition_ptr%itype = SEEPAGE_BC
2026) case('zero_gradient')
2027) sub_condition_ptr%itype = ZERO_GRADIENT_BC
2028) case('mass_rate')
2029) sub_condition_ptr%itype = MASS_RATE_SS
2030) rate_string = 'kg/sec'
2031) !case('mass_rate_enthalpy')
2032) ! sub_condition_ptr%itype = MASS_RATE_ENTHALPY_SS
2033) case('scaled_mass_rate')
2034) sub_condition_ptr%itype = SCALED_MASS_RATE_SS
2035) rate_string = 'kg/sec'
2036) call InputReadWord(input,option,word,PETSC_TRUE)
2037) if (input%ierr == 0) then
2038) call StringToLower(word)
2039) sub_condition_ptr%ctype = trim(sub_condition_ptr%ctype) // word
2040) select case(word)
2041) case('neighbor_perm')
2042) sub_condition_ptr%isubtype = SCALE_BY_NEIGHBOR_PERM
2043) case('volume')
2044) sub_condition_ptr%isubtype = SCALE_BY_VOLUME
2045) case('perm')
2046) sub_condition_ptr%isubtype = SCALE_BY_PERM
2047) case default
2048) string = 'flow condition "' // trim(condition%name) // &
2049) '" scaled_mass_rate type'
2050) call InputKeywordUnrecognized(word,string,option)
2051) end select
2052) else
2053) option%io_buffer = 'Specify one of NEIGHBOR_PERM, ' // &
2054) 'VOLUME, PERM subtypes in '// &
2055) 'flow condition "' // trim(condition%name) // &
2056) '" scaled_mass_rate type'
2057) call printErrMsg(option)
2058) endif
2059) case('volumetric_rate')
2060) sub_condition_ptr%itype = VOLUMETRIC_RATE_SS
2061) rate_string = 'm^3/sec'
2062) case('scaled_volumetric_rate')
2063) sub_condition_ptr%itype = SCALED_VOLUMETRIC_RATE_SS
2064) rate_string = 'm^3/sec'
2065) call InputReadWord(input,option,word,PETSC_TRUE)
2066) if (input%ierr == 0) then
2067) call StringToLower(word)
2068) sub_condition_ptr%ctype = trim(sub_condition_ptr%ctype) // word
2069) select case(word)
2070) case('neighbor_perm')
2071) sub_condition_ptr%isubtype = SCALE_BY_NEIGHBOR_PERM
2072) case('volume')
2073) sub_condition_ptr%isubtype = SCALE_BY_VOLUME
2074) case('perm')
2075) sub_condition_ptr%isubtype = SCALE_BY_PERM
2076) case default
2077) string = 'flow condition "' // trim(condition%name) // &
2078) '" scaled_volumetric_rate type'
2079) call InputKeywordUnrecognized(word,string,option)
2080) end select
2081) else
2082) option%io_buffer = 'Specify one of NEIGHBOR_PERM, ' // &
2083) 'VOLUME, PERM subtypes in '// &
2084) 'flow condition "' // trim(condition%name) // &
2085) '" scaled_volumetric_rate type'
2086) call printErrMsg(option)
2087) endif
2088) case('heterogeneous_volumetric_rate')
2089) sub_condition_ptr%itype = HET_VOL_RATE_SS
2090) rate_string = 'm^3/sec'
2091) case('heterogeneous_mass_rate')
2092) sub_condition_ptr%itype = HET_MASS_RATE_SS
2093) rate_string = 'kg/sec'
2094) case('heterogeneous_dirichlet')
2095) sub_condition_ptr%itype = HET_DIRICHLET
2096) case('heterogeneous_surface_seepage')
2097) sub_condition_ptr%itype = HET_SURF_SEEPAGE_BC
2098) case default
2099) call InputKeywordUnrecognized(word,'flow condition,type',option)
2100) end select
2101) enddo
2102) case('DATUM')
2103) dataset_ascii => DatasetAsciiCreate()
2104) call DatasetAsciiInit(dataset_ascii)
2105) dataset_ascii%array_width = 3
2106) dataset_ascii%data_type = DATASET_REAL
2107) condition%datum => dataset_ascii
2108) nullify(dataset_ascii)
2109) internal_units = 'meter'
2110) call ConditionReadValues(input,option,word,condition%datum, &
2111) word,internal_units)
2112) case('GRADIENT')
2113) do
2114) call InputReadPflotranString(input,option)
2115) call InputReadStringErrorMsg(input,option,'CONDITION')
2116)
2117) if (InputCheckExit(input,option)) exit
2118)
2119) if (InputError(input)) exit
2120) call InputReadWord(input,option,word,PETSC_TRUE)
2121) call InputErrorMsg(input,option,'keyword','CONDITION,TYPE')
2122) call StringToUpper(word)
2123) select case(option%iflowmode)
2124) case(TOIL_IMS_MODE)
2125) sub_condition_ptr => &
2126) FlowTOilImsSubConditionPtr(word,toil_ims,option)
2127) end select
2128) dataset_ascii => DatasetAsciiCreate()
2129) call DatasetAsciiInit(dataset_ascii)
2130) dataset_ascii%array_width = 3
2131) dataset_ascii%data_type = DATASET_REAL
2132) sub_condition_ptr%gradient => dataset_ascii
2133) nullify(dataset_ascii)
2134) internal_units = 'unitless/meter'
2135) call ConditionReadValues(input,option,word, &
2136) sub_condition_ptr%gradient, &
2137) word, internal_units)
2138) nullify(sub_condition_ptr)
2139) enddo
2140) case('CONDUCTANCE')
2141) word = 'PRESSURE'
2142) select case(option%iflowmode)
2143) case(TOIL_IMS_MODE)
2144) sub_condition_ptr => FlowTOilImsSubConditionPtr(word,toil_ims, &
2145) option)
2146) end select
2147) call InputReadDouble(input,option,sub_condition_ptr%aux_real(1))
2148) call InputErrorMsg(input,option,'LIQUID_CONDUCTANCE','CONDITION')
2149) case('PRESSURE','OIL_PRESSURE','WATER_PRESSURE','LIQUID_SATURATION', &
2150) 'OIL_SATURATION','TEMPERATURE','RATE', 'LIQUID_FLUX','OIL_FLUX', &
2151) 'ENERGY_FLUX','ENTHALPY','OWC','WATER_PRESSURE_GRAD')
2152) select case(option%iflowmode)
2153) case(TOIL_IMS_MODE)
2154) sub_condition_ptr => FlowTOilImsSubConditionPtr(word,toil_ims, &
2155) option)
2156) end select
2157)
2158) select case(trim(word))
2159) !give a type to pass FlowSubConditionVerify.
2160) case('OWC','WATER_PRESSURE_GRAD')
2161) sub_condition_ptr%itype = DIRICHLET_BC
2162) sub_condition_ptr%ctype = 'dirichlet'
2163) end select
2164)
2165) select case(trim(word))
2166) case('PRESSURE','OIL_PRESSURE','WATER_PRESSURE')
2167) internal_units = 'Pa'
2168) case('LIQUID_SATURATION','OIL_SATURATION')
2169) internal_units = 'unitless'
2170) case('TEMPERATURE')
2171) internal_units = 'C'
2172) case('OWC')
2173) internal_units = 'meter'
2174) case('WATER_PRESSURE_GRAD')
2175) internal_units = 'Pa/meter'
2176) case('RATE')
2177) input%force_units = PETSC_TRUE
2178) input%err_buf = word
2179) internal_units = trim(rate_string) // ',' // trim(rate_string) //&
2180) ',MJ/sec|MW'
2181) case('LIQUID_FLUX','GAS_FLUX')
2182) internal_units = 'meter/sec'
2183) case('ENERGY_FLUX')
2184) input%force_units = PETSC_TRUE
2185) input%err_buf = word
2186) internal_units = 'MW/m^2|MJ/sec-m^2'
2187) case('ENTHALPY')
2188) internal_units = 'MJ/mol'
2189) end select
2190) call ConditionReadValues(input,option,word, &
2191) sub_condition_ptr%dataset, &
2192) sub_condition_ptr%units,internal_units)
2193) input%force_units = PETSC_FALSE
2194) select case(word)
2195) case('LIQUID_SATURATION') ! convert to oil saturation
2196) if (associated(sub_condition_ptr%dataset%rbuffer)) then
2197) sub_condition_ptr%dataset%rbuffer(:) = 1.d0 - &
2198) sub_condition_ptr%dataset%rbuffer(:)
2199) endif
2200) sub_condition_ptr%dataset%rarray(:) = 1.d0 - &
2201) sub_condition_ptr%dataset%rarray(:)
2202) end select
2203) case default
2204) call InputKeywordUnrecognized(word,'flow condition',option)
2205) end select
2206)
2207) enddo
2208)
2209) ! datum, owc, and liq_press_grad are not required
2210) call DatasetVerify(condition%datum,default_time_storage,option)
2211)
2212) ! phase condition should never be used in TOilIms
2213) condition%iphase = ZERO_INTEGER
2214)
2215) ! unless the coondtion is rate:
2216) ! - pressure is required
2217) ! - water or oil saturation is required
2218) ! - temperature is required
2219) if (.not.associated(toil_ims%rate)) then
2220) ! this branch is executed for sub_conditions that are not a rate
2221) ! some sort of dirichlet-based pressure, temperature, etc.
2222) if (.not.associated(toil_ims%pressure)) then
2223) option%io_buffer = 'TOilIms Phase non-rate condition must ' // &
2224) 'include a pressure'
2225) call printErrMsg(option)
2226) endif
2227)
2228) if (.not.associated(toil_ims%saturation) ) then
2229) option%io_buffer = 'TOilIms Phase non-rate condition must ' // &
2230) 'include liquid or oil saturation'
2231) call printErrMsg(option)
2232) endif
2233) if (.not.associated(toil_ims%temperature)) then
2234) option%io_buffer = 'TOilIms Phase non-rate condition must ' // &
2235) 'include temperature'
2236) call printErrMsg(option)
2237) endif
2238) endif
2239)
2240) ! control that enthalpy is used for src/sink only
2241) if ( (.not.associated(toil_ims%rate)) .and. &
2242) associated(toil_ims%enthalpy) ) then
2243) option%io_buffer = 'TOilIms Enthlapy condition is not' // &
2244) 'currently supported for boundary & initial conditions'
2245) call printErrMsg(option)
2246) end if
2247) ! within a src/sink either temp or enthalpy can be defined
2248) if (associated(toil_ims%rate)) then
2249) if ( associated(toil_ims%temperature).and. &
2250) associated(toil_ims%enthalpy) &
2251) ) then
2252) option%io_buffer = 'TOilIms Rate condition can ' // &
2253) 'have either temp or enthalpy'
2254) call printErrMsg(option)
2255) end if
2256) ! only dirich condition supported for src/sink temp or enthalpy
2257) if ( ( associated(toil_ims%temperature).and. &
2258) (toil_ims%temperature%itype /= DIRICHLET_BC) &
2259) ) .or. &
2260) ( associated(toil_ims%enthalpy).and. &
2261) (toil_ims%enthalpy%itype /= DIRICHLET_BC ) &
2262) ) &
2263) ) then
2264) option%io_buffer = 'TOilIms Src/Sink; only dirichlet type ' // &
2265) 'is supported for temperature and enthalpy conditions'
2266) call printErrMsg(option)
2267) end if
2268)
2269) ! in the casew below enthalpy or temperature overwrite energy rate
2270) !if ( ( associated(toil_ims%temperature).or. &
2271) ! associated(toil_ims%enthalpy) &
2272) ! ) .and. &
2273) ! ( size(toil_ims%rate%dataset%rarray) == THREE_INTEGER ) &
2274) ! ) then
2275) ! option%io_buffer = 'TOilIms Src/Sink error: ' // &
2276) ! 'either define enery rate or temperature/enthalpy value'
2277) ! call printErrMsg(option)
2278) !end if
2279) end if ! end if rate
2280)
2281)
2282) ! verify the datasets
2283) word = 'pressure'
2284) call FlowSubConditionVerify(option,condition,word,toil_ims%pressure, &
2285) default_time_storage, &
2286) PETSC_TRUE)
2287) word = 'oil saturation'
2288) call FlowSubConditionVerify(option,condition,word,toil_ims%saturation, &
2289) default_time_storage, &
2290) PETSC_TRUE)
2291) word = 'temperature'
2292) call FlowSubConditionVerify(option,condition,word,toil_ims%temperature, &
2293) default_time_storage, &
2294) PETSC_TRUE)
2295) word = 'enthalpy'
2296) call FlowSubConditionVerify(option,condition,word,toil_ims%enthalpy, &
2297) default_time_storage, &
2298) PETSC_TRUE)
2299) word = 'liquid flux'
2300) call FlowSubConditionVerify(option,condition,word,toil_ims%liquid_flux, &
2301) default_time_storage, &
2302) PETSC_TRUE)
2303) word = 'oil flux'
2304) call FlowSubConditionVerify(option,condition,word,toil_ims%oil_flux, &
2305) default_time_storage, &
2306) PETSC_TRUE)
2307) word = 'energy flux'
2308) call FlowSubConditionVerify(option,condition,word,toil_ims%energy_flux, &
2309) default_time_storage, &
2310) PETSC_TRUE)
2311) word = 'oil water contact'
2312) call FlowSubConditionVerify(option,condition,word,toil_ims%owc, &
2313) default_time_storage, &
2314) PETSC_TRUE)
2315) word = 'water pressure gradient'
2316) call FlowSubConditionVerify(option,condition,word,toil_ims%liq_press_grad, &
2317) default_time_storage, &
2318) PETSC_TRUE)
2319) word = 'rate'
2320) call FlowSubConditionVerify(option,condition,word,toil_ims%rate, &
2321) default_time_storage, &
2322) PETSC_TRUE)
2323)
2324) condition%num_sub_conditions = 0
2325) i = 0
2326) if (associated(toil_ims%pressure)) &
2327) i = i + 1
2328) if (associated(toil_ims%saturation)) &
2329) i = i + 1
2330) if (associated(toil_ims%temperature)) &
2331) i = i + 1
2332) if (associated(toil_ims%enthalpy)) &
2333) i = i + 1
2334) if (associated(toil_ims%liquid_flux)) &
2335) i = i + 1
2336) if (associated(toil_ims%oil_flux)) &
2337) i = i + 1
2338) if (associated(toil_ims%energy_flux)) &
2339) i = i + 1
2340) if (associated(toil_ims%owc)) &
2341) i = i + 1
2342) if (associated(toil_ims%liq_press_grad)) &
2343) i = i + 1
2344) if (associated(toil_ims%rate)) &
2345) i = i + 1
2346) ! assing number of sub_condition
2347) condition%num_sub_conditions = i
2348) allocate(condition%sub_condition_ptr(condition%num_sub_conditions))
2349) do idof = 1, condition%num_sub_conditions
2350) nullify(condition%sub_condition_ptr(idof)%ptr)
2351) enddo
2352) i = 0
2353) if (associated(toil_ims%pressure)) then
2354) i = i + 1
2355) condition%sub_condition_ptr(i)%ptr => toil_ims%pressure
2356) endif
2357) if (associated(toil_ims%saturation)) then
2358) i = i + 1
2359) condition%sub_condition_ptr(i)%ptr => toil_ims%saturation
2360) endif
2361) if (associated(toil_ims%temperature)) then
2362) i = i + 1
2363) condition%sub_condition_ptr(i)%ptr => toil_ims%temperature
2364) endif
2365) if (associated(toil_ims%enthalpy)) then
2366) i = i + 1
2367) condition%sub_condition_ptr(i)%ptr => toil_ims%enthalpy
2368) endif
2369) if (associated(toil_ims%liquid_flux)) then
2370) i = i + 1
2371) condition%sub_condition_ptr(i)%ptr => toil_ims%liquid_flux
2372) endif
2373) if (associated(toil_ims%oil_flux)) then
2374) i = i + 1
2375) condition%sub_condition_ptr(i)%ptr => toil_ims%oil_flux
2376) endif
2377) if (associated(toil_ims%energy_flux)) then
2378) i = i + 1
2379) condition%sub_condition_ptr(i)%ptr => toil_ims%energy_flux
2380) endif
2381) if (associated(toil_ims%owc)) then
2382) i = i + 1
2383) condition%sub_condition_ptr(i)%ptr => toil_ims%owc
2384) endif
2385) if (associated(toil_ims%liq_press_grad)) then
2386) i = i + 1
2387) condition%sub_condition_ptr(i)%ptr => toil_ims%liq_press_grad
2388) endif
2389) if (associated(toil_ims%rate)) then
2390) i = i + 1
2391) condition%sub_condition_ptr(i)%ptr => toil_ims%rate
2392) endif
2393)
2394) ! set condition types
2395) allocate(condition%itype(condition%num_sub_conditions))
2396) do idof = 1, condition%num_sub_conditions
2397) condition%itype(idof) = condition%sub_condition_ptr(idof)%ptr%itype
2398) enddo
2399)
2400) condition%default_time_storage => default_time_storage
2401)
2402) call PetscLogEventEnd(logging%event_flow_condition_read,ierr);CHKERRQ(ierr)
2403)
2404) end subroutine FlowConditionTOilImsRead
2405)
2406) ! ************************************************************************** !
2407)
2408) subroutine TranConditionRead(condition,constraint_list,reaction,input,option)
2409) !
2410) ! Reads a transport condition from the input file
2411) !
2412) ! Author: Glenn Hammond
2413) ! Date: 10/14/08
2414) !
2415)
2416) use Option_module
2417) use Input_Aux_module
2418) use String_module
2419) use Logging_module
2420) use Units_module
2421) use Reaction_Aux_module
2422)
2423) implicit none
2424)
2425) type(tran_condition_type) :: condition
2426) type(tran_constraint_list_type) :: constraint_list
2427) type(reaction_type) :: reaction
2428) type(input_type), pointer :: input
2429) type(option_type) :: option
2430)
2431) type(tran_constraint_type), pointer :: constraint
2432) type(tran_constraint_coupler_type), pointer :: constraint_coupler, cur_coupler
2433) character(len=MAXSTRINGLENGTH) :: string
2434) character(len=MAXWORDLENGTH) :: word, internal_units
2435) PetscReal :: default_time
2436) character(len=MAXWORDLENGTH) :: default_time_units
2437) PetscInt :: default_iphase
2438) PetscInt :: default_itype
2439) PetscBool :: found
2440) PetscInt :: icomp
2441) PetscBool :: minerals_exist
2442) PetscErrorCode :: ierr
2443) PetscReal :: conversion
2444)
2445) call PetscLogEventBegin(logging%event_tran_condition_read, &
2446) ierr);CHKERRQ(ierr)
2447)
2448) default_time = 0.d0
2449) default_iphase = 0
2450) default_time_units = ''
2451)
2452) ! read the condition
2453) input%ierr = 0
2454) do
2455)
2456) call InputReadPflotranString(input,option)
2457) call InputReadStringErrorMsg(input,option,'CONDITION')
2458)
2459) if (InputCheckExit(input,option)) exit
2460)
2461) call InputReadWord(input,option,word,PETSC_TRUE)
2462) call InputErrorMsg(input,option,'keyword','CONDITION')
2463)
2464) select case(trim(word))
2465)
2466) case('TYPE') ! read condition type (dirichlet, neumann, etc) for each dof
2467) call InputReadWord(input,option,word,PETSC_TRUE)
2468) call InputErrorMsg(input,option,'TYPE','CONDITION')
2469) call StringToLower(word)
2470) select case(word)
2471) case('dirichlet')
2472) condition%itype = DIRICHLET_BC
2473) case('dirichlet_zero_gradient')
2474) condition%itype = DIRICHLET_ZERO_GRADIENT_BC
2475) case('equilibrium')
2476) condition%itype = EQUILIBRIUM_SS
2477) case('neumann')
2478) condition%itype = NEUMANN_BC
2479) case('mole','mole_rate')
2480) condition%itype = MASS_RATE_SS
2481) case('zero_gradient')
2482) condition%itype = ZERO_GRADIENT_BC
2483) case default
2484) call InputKeywordUnrecognized(word,'transport condition type', &
2485) option)
2486) end select
2487) case('TIME')
2488) call InputReadDouble(input,option,default_time)
2489) call InputErrorMsg(input,option,'TIME','CONDITION')
2490) case('TIME_UNITS')
2491) call InputReadWord(input,option,word,PETSC_TRUE)
2492) call InputErrorMsg(input,option,'UNITS','CONDITION')
2493) select case(trim(word))
2494) case('s','sec','min','m','hr','h','d','day','y','yr')
2495) default_time_units = trim(word)
2496) case default
2497) option%io_buffer = 'Units "' // trim(word) // '" not recognized.'
2498) call printErrMsg(option)
2499) end select
2500) case('CONSTRAINT_LIST')
2501) do
2502) call InputReadPflotranString(input,option)
2503) call InputReadStringErrorMsg(input,option,'CONSTRAINT')
2504)
2505) if (InputCheckExit(input,option)) exit
2506)
2507) constraint_coupler => TranConstraintCouplerCreate(option)
2508) call InputReadDouble(input,option,constraint_coupler%time)
2509) call InputErrorMsg(input,option,'time','CONSTRAINT_LIST')
2510) ! time units are optional
2511) call InputReadWord(input,option,word,PETSC_TRUE)
2512) call InputErrorMsg(input,option,'constraint name','CONSTRAINT_LIST')
2513) ! read constraint name
2514) call InputReadWord(input,option,constraint_coupler%constraint_name, &
2515) PETSC_TRUE)
2516) if (InputError(input)) then
2517) constraint_coupler%time_units = default_time_units
2518) constraint_coupler%constraint_name = trim(word)
2519) else
2520) constraint_coupler%time_units = word
2521) endif
2522) ! convert time units
2523) if (len_trim(constraint_coupler%time_units) > 0) then
2524) internal_units = 'sec'
2525) constraint_coupler%time = constraint_coupler%time* &
2526) UnitsConvertToInternal(constraint_coupler%time_units, &
2527) internal_units,option)
2528) endif
2529) ! add to end of list
2530) if (.not.associated(condition%constraint_coupler_list)) then
2531) condition%constraint_coupler_list => constraint_coupler
2532) else
2533) cur_coupler => condition%constraint_coupler_list
2534) do
2535) if (.not.associated(cur_coupler%next)) exit
2536) cur_coupler => cur_coupler%next
2537) enddo
2538) cur_coupler%next => constraint_coupler
2539) endif
2540) enddo
2541) case('CONSTRAINT')
2542) constraint => TranConstraintCreate(option)
2543) constraint_coupler => TranConstraintCouplerCreate(option)
2544) call InputReadWord(input,option,constraint%name,PETSC_TRUE)
2545) call InputErrorMsg(input,option,'constraint','name')
2546) option%io_buffer = 'Constraint: ' // trim(constraint%name)
2547) call printMsg(option)
2548) call TranConstraintRead(constraint,reaction,input,option)
2549) call TranConstraintAddToList(constraint,constraint_list)
2550) constraint_coupler%aqueous_species => constraint%aqueous_species
2551) constraint_coupler%minerals => constraint%minerals
2552) constraint_coupler%surface_complexes => constraint%surface_complexes
2553) constraint_coupler%colloids => constraint%colloids
2554) constraint_coupler%immobile_species => constraint%immobile_species
2555) constraint_coupler%time = default_time
2556) ! add to end of coupler list
2557) if (.not.associated(condition%constraint_coupler_list)) then
2558) condition%constraint_coupler_list => constraint_coupler
2559) else
2560) cur_coupler => condition%constraint_coupler_list
2561) do
2562) if (.not.associated(cur_coupler%next)) exit
2563) cur_coupler => cur_coupler%next
2564) enddo
2565) cur_coupler%next => constraint_coupler
2566) endif
2567) case default
2568) call InputKeywordUnrecognized(word,'transport condition',option)
2569) end select
2570)
2571) enddo
2572)
2573) if (.not.associated(condition%constraint_coupler_list)) then
2574) option%io_buffer = 'No CONSTRAINT or CONSTRAINT_LIST defined in &
2575) &Transport Condition "' // trim(condition%name) // '".'
2576) call printErrMsg(option)
2577) endif
2578)
2579) if (len_trim(default_time_units) > 0) then
2580) internal_units = 'sec'
2581) conversion = UnitsConvertToInternal(default_time_units,internal_units, &
2582) option)
2583) cur_coupler => condition%constraint_coupler_list
2584) do
2585) if (.not.associated(cur_coupler)) exit
2586) if (len_trim(cur_coupler%time_units) == 0) then
2587) cur_coupler%time = cur_coupler%time*conversion
2588) endif
2589) cur_coupler => cur_coupler%next
2590) enddo
2591) endif
2592)
2593) call PetscLogEventEnd(logging%event_tran_condition_read,ierr);CHKERRQ(ierr)
2594)
2595) end subroutine TranConditionRead
2596)
2597) ! ************************************************************************** !
2598)
2599) subroutine ConditionReadValues(input,option,keyword,dataset_base,units, &
2600) data_internal_units)
2601) !
2602) ! Read the value(s) of a condition variable
2603) !
2604) ! Author: Glenn Hammond
2605) ! Date: 10/31/07
2606) !
2607)
2608) use Input_Aux_module
2609) use String_module
2610) use Option_module
2611) use Logging_module
2612) use HDF5_Aux_module
2613) use Units_module
2614) use Dataset_module
2615) use Dataset_Base_class
2616) use Dataset_Ascii_class
2617) #if defined(PETSC_HAVE_HDF5)
2618) use hdf5
2619) #endif
2620)
2621) implicit none
2622)
2623) type(input_type), pointer :: input
2624) type(option_type) :: option
2625) character(len=MAXWORDLENGTH) :: keyword
2626) class(dataset_base_type), pointer :: dataset_base
2627) character(len=MAXWORDLENGTH) :: units
2628) character(len=MAXSTRINGLENGTH), pointer :: internal_unit_strings(:)
2629) character(len=MAXWORDLENGTH) :: data_internal_units
2630)
2631) class(dataset_ascii_type), pointer :: dataset_ascii
2632) character(len=MAXSTRINGLENGTH) :: string2, filename, hdf5_path
2633) character(len=MAXWORDLENGTH) :: word, realization_word
2634) character(len=MAXSTRINGLENGTH) :: error_string
2635) PetscInt :: length, i, icount
2636) PetscInt :: icol
2637) PetscInt :: ndims
2638) PetscInt, pointer :: dims(:)
2639) PetscReal, pointer :: real_buffer(:)
2640) type(input_type), pointer :: input2
2641) PetscErrorCode :: ierr
2642)
2643) #if defined(PETSC_HAVE_HDF5)
2644) integer(HID_T) :: file_id
2645) integer(HID_T) :: prop_id
2646) PetscMPIInt :: hdf5_err
2647) #endif
2648)
2649) call PetscLogEventBegin(logging%event_flow_condition_read_values, &
2650) ierr);CHKERRQ(ierr)
2651)
2652) ! dataset_base, though of type dataset_base_type, should always be created
2653) ! as dataset_ascii_type.
2654) dataset_ascii => DatasetAsciiCast(dataset_base)
2655) if (.not.associated(dataset_ascii)) then
2656) ! The dataset was not of type dataset_asci and was likely set to a different
2657) ! type. There is a bug in the input file.
2658) option%io_buffer = 'Dataset associated with ' // trim(keyword) // &
2659) ' in the input file is already associated with a different dataset ' // &
2660) 'type. Check for duplicate definitions of ' // trim(keyword) // '.'
2661) call printErrMsg(option)
2662) endif
2663)
2664) nullify(input2)
2665) filename = ''
2666) realization_word = ''
2667) hdf5_path = ''
2668)
2669) internal_unit_strings => StringSplit(data_internal_units,',')
2670)
2671) input%ierr = 0
2672) string2 = trim(input%buf)
2673) call InputReadWord(input,option,word,PETSC_TRUE)
2674) call InputErrorMsg(input,option,'file or value','CONDITION')
2675) call StringToLower(word)
2676) length = len_trim(word)
2677) if (StringStartsWithAlpha(word)) then
2678) if (length == FOUR_INTEGER .and. StringCompare(word,'file',FOUR_INTEGER)) then
2679) input%err_buf2 = trim(keyword) // ', FILE'
2680) input%err_buf = 'keyword'
2681) call InputReadNChars(input,option,string2,MAXSTRINGLENGTH,PETSC_TRUE)
2682) if (input%ierr == 0) then
2683) filename = string2
2684) else
2685) option%io_buffer = 'The ability to read realization dependent ' // &
2686) 'datasets outside the DATASET block is no longer supported'
2687) call printErrMsg(option)
2688) endif
2689)
2690) if (len_trim(filename) < 2) then
2691) option%io_buffer = 'No filename listed under Flow_Condition: ' // &
2692) trim(keyword)
2693) call printErrMsg(option)
2694) endif
2695)
2696) if (index(filename,'.h5') > 0) then
2697) write(option%io_buffer,'("Reading of HDF5 datasets for flow ", &
2698) &"conditions not currently supported.")')
2699) call printErrMsg(option)
2700) #if 0
2701) #if !defined(PETSC_HAVE_HDF5)
2702) write(option%io_buffer,'("PFLOTRAN must be compiled with HDF5 to ", &
2703) &"read HDF5 formatted flow conditions.")')
2704) call printErrMsg(option)
2705) #else
2706) if (len_trim(hdf5_path) < 1) then
2707) option%io_buffer = 'No hdf5 path listed under Flow_Condition: ' // &
2708) trim(keyword)
2709) call printErrMsg(option)
2710) endif
2711)
2712) call h5open_f(hdf5_err)
2713) option%io_buffer = 'Opening hdf5 file: ' // trim(filename)
2714) call printMsg(option)
2715) call h5pcreate_f(H5P_FILE_ACCESS_F,prop_id,hdf5_err)
2716) #ifndef SERIAL_HDF5
2717) call h5pset_fapl_mpio_f(prop_id,option%mycomm,MPI_INFO_NULL,hdf5_err)
2718) #endif
2719) call HDF5OpenFileReadOnly(filename,file_id,prop_id,option)
2720) call h5pclose_f(prop_id,hdf5_err)
2721)
2722) hdf5_path = trim(hdf5_path) // trim(realization_word)
2723) call HDF5ReadNDimRealArray(option,file_id,hdf5_path,ndims,dims, &
2724) real_buffer)
2725) option%io_buffer = 'Closing hdf5 file: ' // trim(filename)
2726) call printMsg(option)
2727) call h5fclose_f(file_id,hdf5_err)
2728) call h5close_f(hdf5_err)
2729)
2730) ! dims(1) = size of array
2731) ! dims(2) = number of data point in time
2732) if (dims(1)-1 == flow_dataset%time_series%rank) then
2733) ! alright, the 2d data is layed out in C-style. now place it in
2734) ! the appropriate arrays
2735) allocate(flow_dataset%time_series%times(dims(2)))
2736) flow_dataset%time_series%times = UNINITIALIZED_DOUBLE
2737) allocate(flow_dataset%time_series%values(flow_dataset%time_series%rank,dims(2)))
2738) flow_dataset%time_series%values = UNINITIALIZED_DOUBLE
2739) icount = 1
2740) do i = 1, dims(2)
2741) flow_dataset%time_series%times(i) = real_buffer(icount)
2742) icount = icount + 1
2743) do icol = 1, flow_dataset%time_series%rank
2744) flow_dataset%time_series%values(icol,i) = real_buffer(icount)
2745) icount = icount + 1
2746) enddo
2747) enddo
2748) else
2749) option%io_buffer = 'HDF condition data set rank does not match' // &
2750) 'rank of internal data set. Email Glenn for additions'
2751) call printErrMsg(option)
2752) endif
2753) if (associated(dims)) deallocate(dims)
2754) nullify(dims)
2755) if (associated(real_buffer)) deallocate(real_buffer)
2756) nullify(real_buffer)
2757) #endif
2758) #endif
2759) ! if 0
2760) else
2761) i = index(filename,'.',PETSC_TRUE)
2762) if (i > 2) then
2763) filename = filename(1:i-1) // trim(realization_word) // filename(i:)
2764) else
2765) filename = trim(filename) // trim(realization_word)
2766) endif
2767) input2 => InputCreate(IUNIT_TEMP,filename,option)
2768) input2%force_units = input%force_units
2769) call DatasetAsciiRead(dataset_ascii,input2,data_internal_units,option)
2770) dataset_ascii%filename = filename
2771) call InputDestroy(input2)
2772) endif
2773) else if (StringCompare(word,'dataset')) then
2774) call InputReadWord(input,option,word,PETSC_TRUE)
2775) input%err_buf2 = trim(keyword) // ', DATASET'
2776) input%err_buf = 'dataset name'
2777) call InputErrorMsg(input,option)
2778) call DatasetDestroy(dataset_base)
2779) dataset_base => DatasetBaseCreate()
2780) dataset_base%name = word
2781) else if (length==FOUR_INTEGER .and. StringCompare(word,'list',length)) then
2782) call DatasetAsciiRead(dataset_ascii,input,data_internal_units,option)
2783) else
2784) option%io_buffer = 'Keyword "' // trim(word) // &
2785) '" not recognized in when reading condition values for "' // &
2786) trim(keyword) // '".'
2787) call printErrMsg(option)
2788) endif
2789) else
2790) input%buf = trim(string2)
2791) allocate(dataset_ascii%rarray(dataset_ascii%array_width))
2792) do icol=1,dataset_ascii%array_width
2793) call InputReadDouble(input,option,dataset_ascii%rarray(icol))
2794) write(input%err_buf,'(a,i2)') trim(keyword) // &
2795) ' dataset_values, icol = ', icol
2796) input%err_buf2 = 'CONDITION'
2797) call InputErrorMsg(input,option)
2798) enddo
2799) string2 = input%buf
2800) call InputReadWord(input,option,word,PETSC_TRUE)
2801) if (InputError(input)) then
2802) call InputCheckMandatoryUnits(input,option)
2803) word = trim(keyword) // ' UNITS'
2804) call InputDefaultMsg(input,option,word)
2805) else
2806) input%buf = string2
2807) units = ''
2808) do icol=1,dataset_ascii%array_width
2809) call InputReadWord(input,option,word,PETSC_TRUE)
2810) call InputErrorMsg(input,option,keyword,'CONDITION')
2811) dataset_ascii%rarray(icol) = UnitsConvertToInternal(word, &
2812) internal_unit_strings(icol),option) * &
2813) dataset_ascii%rarray(icol)
2814) units = trim(units) // ' ' // trim(word)
2815) enddo
2816) endif
2817) endif
2818)
2819) deallocate(internal_unit_strings)
2820) nullify(internal_unit_strings)
2821)
2822) call PetscLogEventEnd(logging%event_flow_condition_read_values, &
2823) ierr);CHKERRQ(ierr)
2824)
2825) end subroutine ConditionReadValues
2826)
2827) ! ************************************************************************** !
2828)
2829) subroutine FlowConditionPrint(condition,option)
2830) !
2831) ! Prints flow condition info
2832) !
2833) ! Author: Glenn Hammond
2834) ! Date: 12/04/08
2835) !
2836)
2837) use Option_module
2838) use Dataset_module
2839)
2840) implicit none
2841)
2842) type(flow_condition_type) :: condition
2843) type(option_type) :: option
2844)
2845) character(len=MAXSTRINGLENGTH) :: string
2846) PetscInt :: i
2847)
2848) 99 format(/,80('-'))
2849)
2850) write(option%fid_out,'(/,2x,''Flow Condition: '',a)') trim(condition%name)
2851)
2852) if (condition%sync_time_with_update) then
2853) string = 'yes'
2854) else
2855) string = 'no'
2856) endif
2857) write(option%fid_out,'(4x,''Synchronize time with update: '', a)') trim(string)
2858) write(option%fid_out,'(4x,''Time units: '', a)') trim(condition%time_units)
2859) write(option%fid_out,'(4x,''Length units: '', a)') trim(condition%length_units)
2860)
2861) 100 format(6x,a)
2862) write(option%fid_out,100) 'Datum:'
2863) if (associated(condition%datum)) then
2864) call DatasetPrint(condition%datum,option)
2865) endif
2866)
2867) do i=1, condition%num_sub_conditions
2868) call FlowConditionPrintSubCondition(condition%sub_condition_ptr(i)%ptr, &
2869) option)
2870) enddo
2871) write(option%fid_out,99)
2872)
2873) end subroutine FlowConditionPrint
2874)
2875) ! ************************************************************************** !
2876)
2877) subroutine FlowConditionPrintSubCondition(subcondition,option)
2878) !
2879) ! Prints flow subcondition info
2880) !
2881) ! Author: Glenn Hammond
2882) ! Date: 12/04/08
2883) !
2884)
2885) use Option_module
2886) use Dataset_module
2887)
2888) implicit none
2889)
2890) type(flow_sub_condition_type) :: subcondition
2891) type(option_type) :: option
2892)
2893) character(len=MAXSTRINGLENGTH) :: string
2894)
2895) write(option%fid_out,'(/,4x,''Sub Condition: '',a)') trim(subcondition%name)
2896) string = GetSubConditionName(subcondition%itype)
2897)
2898) 105 format(6x,'Type: ',a)
2899) write(option%fid_out,105) trim(string)
2900)
2901) 110 format(6x,a)
2902)
2903) write(option%fid_out,110) 'Gradient:'
2904) if (associated(subcondition%gradient)) then
2905) call DatasetPrint(subcondition%gradient,option)
2906) endif
2907)
2908) write(option%fid_out,110) 'Data:'
2909) if (associated(subcondition%dataset)) then
2910) call DatasetPrint(subcondition%dataset,option)
2911) endif
2912)
2913) end subroutine FlowConditionPrintSubCondition
2914)
2915) ! ************************************************************************** !
2916)
2917) function GetSubConditionName(subcon_itype)
2918) !
2919) ! SubConditionName: Return name of subcondition
2920) !
2921) ! Author: Gautam Bisht
2922) ! Date: 10/16/13
2923) !
2924)
2925) implicit none
2926)
2927) PetscInt :: subcon_itype
2928)
2929) character(len=MAXSTRINGLENGTH) :: string
2930) character(len=MAXSTRINGLENGTH) :: GetSubConditionName
2931)
2932) select case(subcon_itype)
2933) case(DIRICHLET_BC)
2934) string = 'dirichlet'
2935) case(NEUMANN_BC)
2936) string = 'neumann'
2937) case(DIRICHLET_ZERO_GRADIENT_BC)
2938) string = 'dirichlet-zero gradient'
2939) case(MASS_RATE_SS)
2940) string = 'mass_rate'
2941) case(WELL_SS)
2942) string = 'well'
2943) case(HYDROSTATIC_BC)
2944) string = 'hydrostatic'
2945) case(CONDUCTANCE_BC)
2946) string = 'conductance'
2947) case(ZERO_GRADIENT_BC)
2948) string = 'zero gradient'
2949) case(SEEPAGE_BC)
2950) string = 'seepage'
2951) case(VOLUMETRIC_RATE_SS)
2952) string = 'volumetric rate'
2953) case(EQUILIBRIUM_SS)
2954) string = 'equilibrium'
2955) case(UNIT_GRADIENT_BC)
2956) string = 'unit gradient'
2957) case(SCALED_MASS_RATE_SS)
2958) string = 'scaled mass rate'
2959) case(SCALED_VOLUMETRIC_RATE_SS)
2960) string = 'scaled volumetric rate'
2961) case(HET_VOL_RATE_SS)
2962) string = 'heterogeneous volumetric rate'
2963) case(HET_MASS_RATE_SS)
2964) string = 'heterogeneous mass rate'
2965) case(HET_DIRICHLET)
2966) string = 'heterogeneous dirichlet'
2967) case(ENERGY_RATE_SS)
2968) string = 'energy rate'
2969) case(SCALED_ENERGY_RATE_SS)
2970) string = 'scaled energy rate'
2971) case(HET_ENERGY_RATE_SS)
2972) string = 'heterogeneous energy rate'
2973) case(HET_SURF_SEEPAGE_BC)
2974) string = 'heterogeneous surface seepage'
2975) case(SPILLOVER_BC)
2976) string = 'spillover'
2977) end select
2978)
2979) GetSubConditionName = trim(string)
2980)
2981) end function GetSubConditionName
2982)
2983) ! ************************************************************************** !
2984)
2985) subroutine FlowConditionUpdate(condition_list,option,time)
2986) !
2987) ! Updates a transient condition
2988) !
2989) ! Author: Glenn Hammond
2990) ! Date: 11/02/07
2991) !
2992)
2993) use Option_module
2994) use Dataset_module
2995)
2996) implicit none
2997)
2998) type(condition_list_type) :: condition_list
2999) type(option_type) :: option
3000) PetscReal :: time
3001)
3002) type(flow_condition_type), pointer :: condition
3003) type(flow_sub_condition_type), pointer :: sub_condition
3004) PetscInt :: isub_condition
3005)
3006) condition => condition_list%first
3007) do
3008) if (.not.associated(condition)) exit
3009)
3010) call DatasetUpdate(condition%datum,time,option)
3011) do isub_condition = 1, condition%num_sub_conditions
3012)
3013) sub_condition => condition%sub_condition_ptr(isub_condition)%ptr
3014)
3015) if (associated(sub_condition)) then
3016) call DatasetUpdate(sub_condition%dataset,time,option)
3017) call DatasetUpdate(sub_condition%gradient,time,option)
3018) endif
3019)
3020) enddo
3021)
3022) condition => condition%next
3023)
3024) enddo
3025)
3026) end subroutine FlowConditionUpdate
3027)
3028) ! ************************************************************************** !
3029)
3030) subroutine TranConditionUpdate(condition_list,option,time)
3031) !
3032) ! Updates a transient transport condition
3033) !
3034) ! Author: Glenn Hammond
3035) ! Date: 11/02/07
3036) !
3037)
3038) use Option_module
3039)
3040) implicit none
3041)
3042) type(tran_condition_list_type) :: condition_list
3043) type(option_type) :: option
3044) PetscReal :: time
3045)
3046) type(tran_condition_type), pointer :: condition
3047)
3048) condition => condition_list%first
3049) do
3050) if (.not.associated(condition)) exit
3051)
3052) do
3053) if (associated(condition%cur_constraint_coupler%next)) then
3054) if (time >= condition%cur_constraint_coupler%next%time) then
3055) condition%cur_constraint_coupler => &
3056) condition%cur_constraint_coupler%next
3057) else
3058) exit
3059) endif
3060) else
3061) exit
3062) endif
3063) enddo
3064) condition => condition%next
3065)
3066) enddo
3067)
3068) end subroutine TranConditionUpdate
3069)
3070) ! ************************************************************************** !
3071)
3072) subroutine FlowConditionInitList(list)
3073) !
3074) ! Initializes a condition list
3075) !
3076) ! Author: Glenn Hammond
3077) ! Date: 11/01/07
3078) !
3079)
3080) implicit none
3081)
3082) type(condition_list_type) :: list
3083)
3084) nullify(list%first)
3085) nullify(list%last)
3086) nullify(list%array)
3087) list%num_conditions = 0
3088)
3089) end subroutine FlowConditionInitList
3090)
3091) ! ************************************************************************** !
3092)
3093) subroutine FlowConditionAddToList(new_condition,list)
3094) !
3095) ! Adds a new condition to a condition list
3096) !
3097) ! Author: Glenn Hammond
3098) ! Date: 11/01/07
3099) !
3100)
3101) implicit none
3102)
3103) type(flow_condition_type), pointer :: new_condition
3104) type(condition_list_type) :: list
3105)
3106) list%num_conditions = list%num_conditions + 1
3107) new_condition%id = list%num_conditions
3108) if (.not.associated(list%first)) list%first => new_condition
3109) if (associated(list%last)) list%last%next => new_condition
3110) list%last => new_condition
3111)
3112) end subroutine FlowConditionAddToList
3113)
3114) ! ************************************************************************** !
3115)
3116) function FlowConditionGetPtrFromList(condition_name,condition_list)
3117) !
3118) ! Returns a pointer to the condition matching &
3119) ! condition_name
3120) !
3121) ! Author: Glenn Hammond
3122) ! Date: 11/01/07
3123) !
3124)
3125) use String_module
3126)
3127) implicit none
3128)
3129) type(flow_condition_type), pointer :: FlowConditionGetPtrFromList
3130) character(len=MAXWORDLENGTH) :: condition_name
3131) type(condition_list_type) :: condition_list
3132)
3133) PetscInt :: length
3134) type(flow_condition_type), pointer :: condition
3135)
3136) nullify(FlowConditionGetPtrFromList)
3137) condition => condition_list%first
3138)
3139) do
3140) if (.not.associated(condition)) exit
3141) length = len_trim(condition_name)
3142) if (length == len_trim(condition%name) .and. &
3143) StringCompare(condition%name,condition_name, &
3144) length)) then
3145) FlowConditionGetPtrFromList => condition
3146) return
3147) endif
3148) condition => condition%next
3149) enddo
3150)
3151) end function FlowConditionGetPtrFromList
3152)
3153) ! ************************************************************************** !
3154)
3155) subroutine TranConditionInitList(list)
3156) !
3157) ! Initializes a transport condition list
3158) !
3159) ! Author: Glenn Hammond
3160) ! Date: 10/13/08
3161) !
3162)
3163) implicit none
3164)
3165) type(tran_condition_list_type) :: list
3166)
3167) nullify(list%first)
3168) nullify(list%last)
3169) nullify(list%array)
3170) list%num_conditions = 0
3171)
3172) end subroutine TranConditionInitList
3173)
3174) ! ************************************************************************** !
3175)
3176) subroutine TranConditionAddToList(new_condition,list)
3177) !
3178) ! Adds a new condition to a transport condition list
3179) !
3180) ! Author: Glenn Hammond
3181) ! Date: 10/13/08
3182) !
3183)
3184) implicit none
3185)
3186) type(tran_condition_type), pointer :: new_condition
3187) type(tran_condition_list_type) :: list
3188)
3189) list%num_conditions = list%num_conditions + 1
3190) new_condition%id = list%num_conditions
3191) if (.not.associated(list%first)) list%first => new_condition
3192) if (associated(list%last)) list%last%next => new_condition
3193) list%last => new_condition
3194)
3195) end subroutine TranConditionAddToList
3196)
3197) ! ************************************************************************** !
3198)
3199) function TranConditionGetPtrFromList(condition_name,condition_list)
3200) !
3201) ! Returns a pointer to the condition matching
3202) ! condition_name
3203) !
3204) ! Author: Glenn Hammond
3205) ! Date: 10/13/08
3206) !
3207)
3208) use String_module
3209)
3210) implicit none
3211)
3212) type(tran_condition_type), pointer :: TranConditionGetPtrFromList
3213) character(len=MAXWORDLENGTH) :: condition_name
3214) type(tran_condition_list_type) :: condition_list
3215)
3216) PetscInt :: length
3217) type(tran_condition_type), pointer :: condition
3218)
3219) nullify(TranConditionGetPtrFromList)
3220) condition => condition_list%first
3221)
3222) do
3223) if (.not.associated(condition)) exit
3224) length = len_trim(condition_name)
3225) if (length == len_trim(condition%name) .and. &
3226) StringCompare(condition%name,condition_name, &
3227) length)) then
3228) TranConditionGetPtrFromList => condition
3229) return
3230) endif
3231) condition => condition%next
3232) enddo
3233)
3234) end function TranConditionGetPtrFromList
3235)
3236) ! ************************************************************************** !
3237)
3238) function FlowConditionIsTransient(condition)
3239) !
3240) ! Returns PETSC_TRUE
3241) !
3242) ! Author: Glenn Hammond
3243) ! Date: 01/12/11
3244) !
3245)
3246) use Dataset_module
3247)
3248) implicit none
3249)
3250) type(flow_condition_type) :: condition
3251)
3252) PetscBool :: FlowConditionIsTransient
3253)
3254) FlowConditionIsTransient = PETSC_FALSE
3255)
3256) if (DatasetIsTransient(condition%datum) .or. &
3257) FlowSubConditionIsTransient(condition%pressure) .or. &
3258) FlowSubConditionIsTransient(condition%temperature) .or. &
3259) FlowSubConditionIsTransient(condition%concentration) .or. &
3260) FlowSubConditionIsTransient(condition%saturation) .or. &
3261) FlowSubConditionIsTransient(condition%rate) .or. &
3262) FlowSubConditionIsTransient(condition%well) .or. &
3263) FlowSubConditionIsTransient(condition%enthalpy) .or. &
3264) FlowSubConditionIsTransient(condition%energy_rate) .or. &
3265) FlowSubConditionIsTransient(condition%energy_flux) .or. &
3266) FlowConditionTOilImsIsTransient(condition%toil_ims) .or. &
3267) FlowConditionGeneralIsTransient(condition%general)) then
3268) FlowConditionIsTransient = PETSC_TRUE
3269) endif
3270)
3271) end function FlowConditionIsTransient
3272)
3273) ! ************************************************************************** !
3274)
3275) function FlowConditionGeneralIsTransient(condition)
3276) !
3277) ! Returns PETSC_TRUE
3278) !
3279) ! Author: Glenn Hammond
3280) ! Date: 01/12/11
3281) !
3282)
3283) use Dataset_module
3284)
3285) implicit none
3286)
3287) type(flow_general_condition_type), pointer :: condition
3288)
3289) PetscBool :: FlowConditionGeneralIsTransient
3290)
3291) FlowConditionGeneralIsTransient = PETSC_FALSE
3292)
3293) if (.not.associated(condition)) return
3294)
3295) if (FlowSubConditionIsTransient(condition%liquid_pressure) .or. &
3296) FlowSubConditionIsTransient(condition%gas_pressure) .or. &
3297) FlowSubConditionIsTransient(condition%gas_saturation) .or. &
3298) FlowSubConditionIsTransient(condition%relative_humidity) .or. &
3299) FlowSubConditionIsTransient(condition%mole_fraction) .or. &
3300) FlowSubConditionIsTransient(condition%temperature) .or. &
3301) FlowSubConditionIsTransient(condition%rate) .or. &
3302) FlowSubConditionIsTransient(condition%liquid_flux) .or. &
3303) FlowSubConditionIsTransient(condition%gas_flux) .or. &
3304) FlowSubConditionIsTransient(condition%energy_flux)) then
3305) FlowConditionGeneralIsTransient = PETSC_TRUE
3306) endif
3307)
3308) end function FlowConditionGeneralIsTransient
3309)
3310) ! ************************************************************************** !
3311)
3312) function FlowConditionTOilImsIsTransient(condition)
3313) !
3314) ! Returns PETSC_TRUE
3315) !
3316) ! Author: Paolo Orsini
3317) ! Date: 10/20/15
3318) !
3319)
3320) use Dataset_module
3321)
3322) implicit none
3323)
3324) type(flow_toil_ims_condition_type), pointer :: condition
3325)
3326) PetscBool :: FlowConditionTOilImsIsTransient
3327)
3328) FlowConditionTOilImsIsTransient = PETSC_FALSE
3329)
3330) if (.not.associated(condition)) return
3331)
3332) if (FlowSubConditionIsTransient(condition%pressure) .or. &
3333) FlowSubConditionIsTransient(condition%saturation) .or. &
3334) FlowSubConditionIsTransient(condition%temperature) .or. &
3335) FlowSubConditionIsTransient(condition%enthalpy) .or. &
3336) FlowSubConditionIsTransient(condition%rate) .or. &
3337) FlowSubConditionIsTransient(condition%liquid_flux) .or. &
3338) FlowSubConditionIsTransient(condition%oil_flux) .or. &
3339) FlowSubConditionIsTransient(condition%energy_flux) .or. &
3340) FlowSubConditionIsTransient(condition%owc) .or. &
3341) FlowSubConditionIsTransient(condition%liq_press_grad)) then
3342) FlowConditionTOilImsIsTransient = PETSC_TRUE
3343) endif
3344)
3345) end function FlowConditionTOilImsIsTransient
3346)
3347) ! ************************************************************************** !
3348)
3349) function FlowSubConditionIsTransient(sub_condition)
3350) !
3351) ! Returns PETSC_TRUE
3352) !
3353) ! Author: Glenn Hammond
3354) ! Date: 10/26/11
3355) !
3356)
3357) use Dataset_module
3358)
3359) implicit none
3360)
3361) type(flow_sub_condition_type), pointer :: sub_condition
3362)
3363) PetscBool :: FlowSubConditionIsTransient
3364)
3365) FlowSubConditionIsTransient = PETSC_FALSE
3366)
3367) if (associated(sub_condition)) then
3368) if (DatasetIsTransient(sub_condition%dataset) .or. &
3369) DatasetIsTransient(sub_condition%gradient)) then
3370) FlowSubConditionIsTransient = PETSC_TRUE
3371) endif
3372) endif
3373)
3374) end function FlowSubConditionIsTransient
3375)
3376) ! ************************************************************************** !
3377)
3378) function FlowConditionUnknownItype(condition,message,type_name)
3379) !
3380) ! Returns a string indicating which flow condition has a wrong type.
3381) !
3382) ! Author: Glenn Hammond
3383) ! Date: 03/21/16
3384) !
3385) implicit none
3386)
3387) type(flow_condition_type) :: condition
3388) character(len=*) :: message
3389) character(len=*) :: type_name
3390)
3391) character(len=MAXSTRINGLENGTH) :: FlowConditionUnknownItype
3392)
3393) FlowConditionUnknownItype = 'Unknown TYPE (' // trim(type_name) // &
3394) ') for ' // trim(message) // ' within FLOW_CONDITION "' // &
3395) trim(condition%name) // '".'
3396)
3397) end function FlowConditionUnknownItype
3398)
3399) ! **************************************************************************** !
3400)
3401) subroutine FlowCondInputRecord(flow_condition_list,option)
3402) !
3403) ! Prints ingested flow condition information to
3404) ! the input record file.
3405) !
3406) ! Author: Jenn Frederick
3407) ! Date: 04/19/2016
3408) !
3409) use Option_module
3410) use Dataset_Base_class
3411)
3412) implicit none
3413)
3414) type(condition_list_type), pointer :: flow_condition_list
3415) type(option_type), pointer :: option
3416)
3417) type(flow_condition_type), pointer :: cur_fc
3418) character(len=MAXWORDLENGTH) :: word1, word2
3419) character(len=MAXSTRINGLENGTH) :: string
3420) PetscInt :: k
3421) PetscInt :: id = INPUT_RECORD_UNIT
3422)
3423) write(id,'(a)') ' '
3424) write(id,'(a)') '---------------------------------------------------------&
3425) &-----------------------'
3426) write(id,'(a29)',advance='no') '---------------------------: '
3427) write(id,'(a)') 'FLOW CONDITIONS'
3428)
3429) cur_fc => flow_condition_list%first
3430) do
3431) if (.not.associated(cur_fc)) exit
3432) write(id,'(a29)',advance='no') 'flow condition name: '
3433) write(id,'(a)') adjustl(trim(cur_fc%name))
3434) if (cur_fc%num_sub_conditions > 0) then
3435) do k = 1,cur_fc%num_sub_conditions
3436) write(id,'(a29)',advance='no') 'sub condition name: '
3437) write(id,'(a)') adjustl(trim(cur_fc%sub_condition_ptr(k)%ptr%name))
3438) write(id,'(a29)',advance='no') 'sub condition type: '
3439) write(id,'(a)') adjustl(trim(cur_fc%sub_condition_ptr(k)%ptr%ctype))
3440) if (associated(cur_fc%sub_condition_ptr(k)%ptr%dataset)) then
3441) call DatasetBasePrint(cur_fc%sub_condition_ptr(k)%ptr%dataset,option)
3442) ! DatasetBasePrint doesn't seem to do anything?
3443) endif
3444) if (associated(cur_fc%sub_condition_ptr(k)%ptr%gradient)) then
3445) call DatasetBasePrint(cur_fc%sub_condition_ptr(k)%ptr%gradient,option)
3446) endif
3447) enddo
3448) endif
3449)
3450) write(id,'(a29)') '---------------------------: '
3451) cur_fc => cur_fc%next
3452) enddo
3453)
3454) end subroutine FlowCondInputRecord
3455)
3456) ! **************************************************************************** !
3457)
3458) subroutine TranCondInputRecord(tran_condition_list,option)
3459) !
3460) ! Prints ingested transport condition information to
3461) ! the input record file.
3462) !
3463) ! Author: Jenn Frederick
3464) ! Date: 04/19/2016
3465) !
3466) use Option_module
3467) use Dataset_Base_class
3468) Use Transport_Constraint_module
3469)
3470) implicit none
3471)
3472) type(tran_condition_list_type), pointer :: tran_condition_list
3473) type(option_type), pointer :: option
3474)
3475) type(tran_constraint_coupler_type), pointer :: cur_tcon_coupler
3476) type(tran_condition_type), pointer :: cur_tc
3477) character(len=MAXWORDLENGTH) :: word1, word2
3478) character(len=MAXSTRINGLENGTH) :: string
3479) PetscInt :: k
3480) PetscInt :: id = INPUT_RECORD_UNIT
3481)
3482) write(id,'(a)') ' '
3483) write(id,'(a)') '---------------------------------------------------------&
3484) &-----------------------'
3485) write(id,'(a29)',advance='no') '---------------------------: '
3486) write(id,'(a)') 'TRANSPORT CONDITIONS'
3487)
3488) cur_tc => tran_condition_list%first
3489) do
3490) if (.not.associated(cur_tc)) exit
3491) write(id,'(a29)',advance='no') 'transport condition name: '
3492) write(id,'(a)') adjustl(trim(cur_tc%name))
3493) write(id,'(a29)',advance='no') 'transport condition type: '
3494) select case (cur_tc%itype)
3495) case(DIRICHLET_BC)
3496) write(id,'(a)') 'dirichlet'
3497) case(DIRICHLET_ZERO_GRADIENT_BC)
3498) write(id,'(a)') 'dirichlet_zero_gradient'
3499) case(EQUILIBRIUM_SS)
3500) write(id,'(a)') 'equilibrium'
3501) case(NEUMANN_BC)
3502) write(id,'(a)') 'neumann'
3503) case(MASS_RATE_SS)
3504) write(id,'(a)') 'mole_rate'
3505) case(ZERO_GRADIENT_BC)
3506) write(id,'(a)') 'zero_gradient'
3507) end select
3508) write(id,'(a29)',advance='no') 'is transient?: '
3509) if (cur_tc%is_transient) then
3510) write(id,'(a)') 'YES'
3511) else
3512) write(id,'(a)') 'NO'
3513) endif
3514) cur_tcon_coupler => cur_tc%constraint_coupler_list
3515) do
3516) if (.not.associated(cur_tcon_coupler)) exit
3517) write(id,'(a29)',advance='no') 'transport constraint name: '
3518) write(id,'(a)') adjustl(trim(cur_tcon_coupler%constraint_name))
3519)
3520) ! aqueous species concentraion constraint
3521) if (associated(cur_tcon_coupler%aqueous_species)) then
3522) do k = 1,size(cur_tcon_coupler%aqueous_species%names)
3523) write(id,'(a29)',advance='no') 'aqueous species constraint: '
3524) write(string,*) trim(cur_tcon_coupler%aqueous_species%names(k))
3525) select case (cur_tcon_coupler%aqueous_species%constraint_type(k))
3526) case(CONSTRAINT_FREE)
3527) string = trim(string) // ', free'
3528) case(CONSTRAINT_TOTAL)
3529) string = trim(string) // ', total'
3530) case(CONSTRAINT_TOTAL_SORB)
3531) string = trim(string) // ', total_sorb'
3532) case(CONSTRAINT_PH)
3533) string = trim(string) // ', ph'
3534) case(CONSTRAINT_LOG)
3535) string = trim(string) // ', log'
3536) case(CONSTRAINT_MINERAL)
3537) string = trim(string) // ', mineral'
3538) case(CONSTRAINT_GAS)
3539) string = trim(string) // ', gas'
3540) case(CONSTRAINT_SUPERCRIT_CO2)
3541) string = trim(string) // ', super critical CO2'
3542) case(CONSTRAINT_CHARGE_BAL)
3543) string = trim(string) // ', charge balance'
3544) end select
3545) write(word1,*) cur_tcon_coupler%aqueous_species%constraint_conc(k)
3546) write(id,'(a)') trim(string) // ', ' // adjustl(trim(word1)) &
3547) // ' mol'
3548) enddo
3549) endif
3550)
3551) ! free-ion guess constraint
3552) if (associated(cur_tcon_coupler%free_ion_guess)) then
3553) do k = 1,size(cur_tcon_coupler%free_ion_guess%names)
3554) write(id,'(a29)',advance='no') 'free ion guess constraint: '
3555) write(string,*) trim(cur_tcon_coupler%free_ion_guess%names(k))
3556) write(word1,*) cur_tcon_coupler%free_ion_guess%conc(k)
3557) write(id,'(a)') trim(string) // ', ' // adjustl(trim(word1)) &
3558) // ' mol'
3559) enddo
3560) endif
3561)
3562) ! mineral constraint
3563) if (associated(cur_tcon_coupler%minerals)) then
3564) do k = 1,size(cur_tcon_coupler%minerals%names)
3565) write(id,'(a29)',advance='no') 'mineral vol. frac. constraint: '
3566) write(string,*) trim(cur_tcon_coupler%minerals%names(k))
3567) write(word1,*) cur_tcon_coupler%minerals%constraint_vol_frac(k)
3568) write(id,'(a)') trim(string) // ', ' // adjustl(trim(word1)) &
3569) // ' m^3/m^3'
3570) write(id,'(a29)',advance='no') 'mineral area constraint: '
3571) write(string,*) trim(cur_tcon_coupler%minerals%names(k))
3572) write(word1,*) cur_tcon_coupler%minerals%constraint_area(k)
3573) write(id,'(a)') trim(string) // ', ' // adjustl(trim(word1)) &
3574) // ' m^2/m^3'
3575) enddo
3576) endif
3577)
3578) ! surface complexes constraint
3579) if (associated(cur_tcon_coupler%surface_complexes)) then
3580) do k = 1,size(cur_tcon_coupler%surface_complexes%names)
3581) write(id,'(a29)',advance='no') 'surface complex constraint: '
3582) write(string,*) trim(cur_tcon_coupler%surface_complexes%names(k))
3583) write(word1,*) cur_tcon_coupler%surface_complexes%constraint_conc(k)
3584) write(id,'(a)') trim(string) // ', ' // adjustl(trim(word1)) &
3585) // ' mol/m^3'
3586) enddo
3587) endif
3588)
3589) ! colloids constraint
3590) if (associated(cur_tcon_coupler%colloids)) then
3591) do k = 1,size(cur_tcon_coupler%colloids%names)
3592) write(id,'(a29)',advance='no') 'colloid mobile constraint: '
3593) write(string,*) trim(cur_tcon_coupler%colloids%names(k))
3594) write(word1,*) cur_tcon_coupler%colloids%constraint_conc_mob(k)
3595) write(id,'(a)') trim(string) // ', ' // adjustl(trim(word1)) &
3596) // ' mol'
3597) write(id,'(a29)',advance='no') 'colloid immobile constraint: '
3598) write(string,*) trim(cur_tcon_coupler%colloids%names(k))
3599) write(word1,*) cur_tcon_coupler%colloids%constraint_conc_imb(k)
3600) write(id,'(a)') trim(string) // ', ' // adjustl(trim(word1)) &
3601) // ' mol'
3602) enddo
3603) endif
3604)
3605) ! immobile species constraint
3606) if (associated(cur_tcon_coupler%immobile_species)) then
3607) do k = 1,size(cur_tcon_coupler%immobile_species%names)
3608) write(id,'(a29)',advance='no') 'immobile species constraint: '
3609) write(string,*) trim(cur_tcon_coupler%immobile_species%names(k))
3610) write(word1,*) cur_tcon_coupler%immobile_species%constraint_conc(k)
3611) write(id,'(a)') trim(string) // ', ' // adjustl(trim(word1)) &
3612) // ' mol/m^3'
3613) enddo
3614) endif
3615)
3616) cur_tcon_coupler => cur_tcon_coupler%next
3617) enddo
3618)
3619) write(id,'(a29)') '---------------------------: '
3620) cur_tc => cur_tc%next
3621) enddo
3622)
3623) end subroutine TranCondInputRecord
3624)
3625) ! ************************************************************************** !
3626)
3627) subroutine FlowConditionDestroyList(condition_list)
3628) !
3629) ! Deallocates a list of conditions
3630) !
3631) ! Author: Glenn Hammond
3632) ! Date: 11/01/07
3633) !
3634)
3635) implicit none
3636)
3637) type(condition_list_type), pointer :: condition_list
3638)
3639) type(flow_condition_type), pointer :: condition, prev_condition
3640)
3641) if (.not.associated(condition_list)) return
3642)
3643) condition => condition_list%first
3644) do
3645) if (.not.associated(condition)) exit
3646) prev_condition => condition
3647) condition => condition%next
3648) call FlowConditionDestroy(prev_condition)
3649) enddo
3650)
3651) condition_list%num_conditions = 0
3652) nullify(condition_list%first)
3653) nullify(condition_list%last)
3654) if (associated(condition_list%array)) deallocate(condition_list%array)
3655) nullify(condition_list%array)
3656)
3657) deallocate(condition_list)
3658) nullify(condition_list)
3659)
3660) end subroutine FlowConditionDestroyList
3661)
3662) ! ************************************************************************** !
3663)
3664) subroutine FlowConditionDestroy(condition)
3665) !
3666) ! Deallocates a condition
3667) !
3668) ! Author: Glenn Hammond
3669) ! Date: 10/23/07
3670) !
3671)
3672) use Dataset_module
3673) use Dataset_Ascii_class
3674) use Utility_module
3675)
3676) implicit none
3677)
3678) type(flow_condition_type), pointer :: condition
3679)
3680) class(dataset_ascii_type), pointer :: dataset_ascii
3681) PetscInt :: i
3682)
3683) if (.not.associated(condition)) return
3684)
3685) ! if dataset_ascii_type, destroy. Otherwise, they are in another list
3686) dataset_ascii => DatasetAsciiCast(condition%datum)
3687) ! dataset_ascii will be NULL if not dataset_ascii_type
3688) call DatasetAsciiDestroy(dataset_ascii)
3689)
3690) if (associated(condition%sub_condition_ptr)) then
3691) ! only nullify the pointers; don't destroy as they are destroyed below
3692) do i=1,condition%num_sub_conditions
3693) nullify(condition%sub_condition_ptr(i)%ptr)
3694) enddo
3695) deallocate(condition%sub_condition_ptr)
3696) nullify(condition%sub_condition_ptr)
3697) endif
3698)
3699) call DeallocateArray(condition%itype)
3700)
3701) call FlowSubConditionDestroy(condition%pressure)
3702) call FlowSubConditionDestroy(condition%saturation)
3703) call FlowSubConditionDestroy(condition%rate)
3704) call FlowSubConditionDestroy(condition%well)
3705) call FlowSubConditionDestroy(condition%temperature)
3706) call FlowSubConditionDestroy(condition%concentration)
3707) call FlowSubConditionDestroy(condition%enthalpy)
3708) call FlowSubConditionDestroy(condition%energy_rate)
3709)
3710) call TimeStorageDestroy(condition%default_time_storage)
3711) call FlowGeneralConditionDestroy(condition%general)
3712) call FlowToilConditionDestroy(condition%toil_ims)
3713)
3714) nullify(condition%next)
3715)
3716) deallocate(condition)
3717) nullify(condition)
3718)
3719) end subroutine FlowConditionDestroy
3720)
3721) ! ************************************************************************** !
3722)
3723) subroutine FlowGeneralConditionDestroy(general_condition)
3724) !
3725) ! Destroys a general mode condition
3726) !
3727) ! Author: Glenn Hammond
3728) ! Date: 05/26/11
3729) !
3730)
3731) use Option_module
3732)
3733) implicit none
3734)
3735) type(flow_general_condition_type), pointer :: general_condition
3736)
3737) if (.not.associated(general_condition)) return
3738)
3739) call FlowSubConditionDestroy(general_condition%liquid_pressure)
3740) call FlowSubConditionDestroy(general_condition%gas_pressure)
3741) call FlowSubConditionDestroy(general_condition%gas_saturation)
3742) call FlowSubConditionDestroy(general_condition%relative_humidity)
3743) call FlowSubConditionDestroy(general_condition%mole_fraction)
3744) call FlowSubConditionDestroy(general_condition%temperature)
3745) call FlowSubConditionDestroy(general_condition%liquid_flux)
3746) call FlowSubConditionDestroy(general_condition%gas_flux)
3747) call FlowSubConditionDestroy(general_condition%energy_flux)
3748) call FlowSubConditionDestroy(general_condition%rate)
3749)
3750) deallocate(general_condition)
3751) nullify(general_condition)
3752)
3753) end subroutine FlowGeneralConditionDestroy
3754)
3755) ! ************************************************************************** !
3756)
3757) subroutine FlowToilConditionDestroy(toil_ims_condition)
3758) !
3759) ! Destroys a toil_ims mode condition
3760) !
3761) ! Author: Paolo Orsini (OGS)
3762) ! Date: 10/06/15
3763) !
3764)
3765) use Option_module
3766)
3767) implicit none
3768)
3769) type(flow_toil_ims_condition_type), pointer :: toil_ims_condition
3770)
3771) if (.not.associated(toil_ims_condition)) return
3772)
3773) call FlowSubConditionDestroy(toil_ims_condition%pressure)
3774) call FlowSubConditionDestroy(toil_ims_condition%saturation)
3775) call FlowSubConditionDestroy(toil_ims_condition%temperature)
3776) call FlowSubConditionDestroy(toil_ims_condition%enthalpy)
3777) call FlowSubConditionDestroy(toil_ims_condition%liquid_flux)
3778) call FlowSubConditionDestroy(toil_ims_condition%oil_flux)
3779) call FlowSubConditionDestroy(toil_ims_condition%energy_flux)
3780) call FlowSubConditionDestroy(toil_ims_condition%rate)
3781) call FlowSubConditionDestroy(toil_ims_condition%owc)
3782) call FlowSubConditionDestroy(toil_ims_condition%liq_press_grad)
3783)
3784) deallocate(toil_ims_condition)
3785) nullify(toil_ims_condition)
3786)
3787) end subroutine FlowToilConditionDestroy
3788)
3789) ! ************************************************************************** !
3790)
3791) subroutine FlowSubConditionDestroy(sub_condition)
3792) !
3793) ! Destroys a sub_condition
3794) !
3795) ! Author: Glenn Hammond
3796) ! Date: 02/04/08
3797) !
3798)
3799) use Dataset_module
3800) use Dataset_Ascii_class
3801)
3802) implicit none
3803)
3804) type(flow_sub_condition_type), pointer :: sub_condition
3805)
3806) class(dataset_ascii_type), pointer :: dataset_ascii
3807)
3808) if (.not.associated(sub_condition)) return
3809)
3810) ! if dataset_ascii_type, destroy. Otherwise, they are in another list
3811) dataset_ascii => DatasetAsciiCast(sub_condition%dataset)
3812) ! dataset_ascii will be NULL if not dataset_ascii_type
3813) call DatasetAsciiDestroy(dataset_ascii)
3814) dataset_ascii => DatasetAsciiCast(sub_condition%gradient)
3815) call DatasetAsciiDestroy(dataset_ascii)
3816)
3817) deallocate(sub_condition)
3818) nullify(sub_condition)
3819)
3820) end subroutine FlowSubConditionDestroy
3821)
3822) ! ************************************************************************** !
3823)
3824) subroutine TranConditionDestroyList(condition_list)
3825) !
3826) ! Deallocates a list of conditions
3827) !
3828) ! Author: Glenn Hammond
3829) ! Date: 11/01/07
3830) !
3831)
3832) implicit none
3833)
3834) type(tran_condition_list_type), pointer :: condition_list
3835)
3836) type(tran_condition_type), pointer :: condition, prev_condition
3837)
3838) if (.not.associated(condition_list)) return
3839)
3840) condition => condition_list%first
3841) do
3842) if (.not.associated(condition)) exit
3843) prev_condition => condition
3844) condition => condition%next
3845) call TranConditionDestroy(prev_condition)
3846) enddo
3847)
3848) condition_list%num_conditions = 0
3849) nullify(condition_list%first)
3850) nullify(condition_list%last)
3851) if (associated(condition_list%array)) deallocate(condition_list%array)
3852) nullify(condition_list%array)
3853)
3854) deallocate(condition_list)
3855) nullify(condition_list)
3856)
3857) end subroutine TranConditionDestroyList
3858)
3859) ! ************************************************************************** !
3860)
3861) subroutine TranConditionDestroy(condition)
3862) !
3863) ! Deallocates a condition
3864) !
3865) ! Author: Glenn Hammond
3866) ! Date: 10/23/07
3867) !
3868)
3869) implicit none
3870)
3871) type(tran_condition_type), pointer :: condition
3872)
3873) if (.not.associated(condition)) return
3874)
3875) if (associated(condition%constraint_coupler_list)) &
3876) call TranConstraintCouplerDestroy(condition%constraint_coupler_list)
3877)
3878) deallocate(condition)
3879) nullify(condition)
3880)
3881) end subroutine TranConditionDestroy
3882)
3883) end module Condition_module