• R/O
  • SSH

treelm: Commit

Repository of the treelm library.


Commit MetaInfo

Revisione350b9fa10b81b0c729ac656bb9f45c00c79c8f7 (tree)
Time2019-08-30 00:37:54
AuthorHarald Klimach <harald.klimach@uni-...>
CommiterHarald Klimach

Log Message

Added the possibility to append solver specific variable types that may be defined by the user in the configuration.

Change Summary

Incremental Difference

diff -r 2f316dd775e1 -r e350b9fa10b8 source/tem_derived_module.fpp
--- a/source/tem_derived_module.fpp Thu Aug 29 10:49:37 2019 +0200
+++ b/source/tem_derived_module.fpp Thu Aug 29 17:37:54 2019 +0200
@@ -76,10 +76,18 @@
7676 & solverData_evalElem = solverData_evalElem )
7777
7878 case default
79- write(logUnit(1),*) 'WARNING: varType: ' // trim(luaVar(iVar)%varType) &
80- & // ' not supported. Variable ' // trim(luaVar(iVar)%label) &
81- & // ' is not appended.'
82- cycle ! go to next variable
79+ if (associated(luaVar(iVar)%append_solverVar)) then
80+ call luaVar(iVar)%append_solverVar( &
81+ & varSys = varSys, &
82+ & solverData_evalElem = solverData_evalElem )
83+ else
84+ write(logUnit(1),*) 'WARNING: varType: ' &
85+ & // trim(luaVar(iVar)%varType) &
86+ & // ' not supported. Variable ' &
87+ & // trim(luaVar(iVar)%label) &
88+ & // ' is not appended.'
89+ cycle ! go to next variable
90+ end if
8391 end select
8492
8593 end do !iVar
diff -r 2f316dd775e1 -r e350b9fa10b8 source/variables/tem_variable_module.f90
--- a/source/variables/tem_variable_module.f90 Thu Aug 29 10:49:37 2019 +0200
+++ b/source/variables/tem_variable_module.f90 Thu Aug 29 17:37:54 2019 +0200
@@ -46,6 +46,7 @@
4646 !!```
4747
4848 module tem_variable_module
49+ use iso_c_binding, only: c_ptr, c_null_ptr
4950 use env_module, only: labelLen
5051
5152 use aotus_module, only: flu_State, aot_get_val, &
@@ -71,6 +72,8 @@
7172 use tem_reduction_transient_module, only: &
7273 & tem_reduction_transient_config_type, &
7374 & tem_reduction_transient_load
75+ use tem_varSys_module, only: tem_varSys_type, &
76+ & tem_varSys_solverData_evalElem_type
7477
7578 implicit none
7679
@@ -117,10 +120,58 @@
117120 !! evaluation type the ordering of the space time functions in the variable
118121 !! definition is important.
119122 character(len=labelLen) :: evalType
123+
124+ !> A method to append the read solver specific variable to the varSys
125+ procedure(tem_append_solverVar_method), pointer :: append_solverVar &
126+ & => NULL()
127+ type(c_ptr) :: solver_specifics = C_NULL_PTR
120128 end type tem_variable_type
121129 ! **************************************************************************** !
122130
123131
132+ interface
133+ subroutine tem_append_solverVar_method(var, varSys, pos, &
134+ & solverData_evalElem)
135+ import :: tem_variable_type, &
136+ & tem_varSys_type, &
137+ & tem_varSys_solverData_evalElem_type
138+ !> Data to describe the solver specific variable
139+ class(tem_variable_type), intent(in) :: var
140+
141+ !> Variable system to append the variable to.
142+ type(tem_varSys_type), intent(inout) :: varSys
143+
144+ !> Position of the appended variable in the varSys.
145+ integer, optional, intent(out) :: pos
146+ !> A setter routin that allows the caller to define a routine for the
147+ !! construction of an element representation.
148+ type(tem_varSys_solverData_evalElem_type), &
149+ & optional, intent(in) :: solverData_evalElem
150+ end subroutine tem_append_solverVar_method
151+
152+ subroutine tem_load_solverVar_method(L, parent, specifics, appender, iError)
153+ import :: flu_State, &
154+ & c_ptr, &
155+ & tem_append_solverVar_method
156+ !> Lua script to load the variable data from.
157+ type(flu_State) :: L
158+
159+ !> Parent table in the lua script to read the vairable from.
160+ integer, intent(in) :: parent
161+
162+ !> Data to read for the solver specific variable
163+ type(c_ptr), intent(out) :: specifics
164+
165+ !> Function pointer to use for appending the solver variable.
166+ procedure(tem_append_solverVar_method), pointer :: appender
167+
168+ !> Indication whether the attempted reading was successful.
169+ integer, intent(out) :: iError
170+
171+ end subroutine tem_load_solverVar_method
172+ end interface
173+
174+
124175 ! **************************************************************************** !
125176 interface tem_variable_load
126177 module procedure tem_variable_load_vector
@@ -264,7 +315,7 @@
264315 ! **************************************************************************** !
265316 !> Reading a single variable from the Lua configuration.
266317 subroutine tem_variable_load_single( me, conf, parent, iError, key, nComp, &
267- & openTable )
318+ & openTable, load_solvervar )
268319 ! --------------------------------------------------------------------------!
269320 !> The variable to read from the Lua script(conf) and fill
270321 type(tem_variable_type), intent(out) :: me
@@ -290,6 +341,7 @@
290341
291342 ! if variable table is already opened then openTable = .false.
292343 logical, optional, intent(in) :: openTable
344+ procedure(tem_load_solvervar_method), optional :: load_solvervar
293345 ! --------------------------------------------------------------------------!
294346 integer :: local_thandle, local_error
295347 logical :: openTable_loc
@@ -441,9 +493,19 @@
441493 end if
442494
443495 case default
444- call tem_abort( 'Error: varType ' &
445- & // trim(me%varType) &
446- & // ' not supported! Supported varType are "st_fun" and "operation"' )
496+ iError = 1
497+ if (present(load_solverVar)) then
498+ call load_solverVar(L = conf, &
499+ & parent = local_thandle, &
500+ & specifics = me%solver_specifics, &
501+ & appender = me%append_solvervar, &
502+ & iError = iError )
503+ end if
504+ if (iError /= 0) then
505+ call tem_abort( 'Error: varType ' &
506+ & // trim(me%varType) &
507+ & // ' not supported! Supported varType are "st_fun" and "operation"' )
508+ end if
447509 end select
448510
449511 if (present(key)) call aot_table_close( L = conf, thandle = local_thandle)
Show on old repository browser