50 USE cellml_model_definition
79 #include "petscversion.h" 371 SUBROUTINE solver_dae_external_integrate(NUMBER_OF_DOFS,START_TIME,END_TIME,INITIAL_STEP, &
372 & only_one_model_index,models_data,number_of_state,state_data,number_of_parameters, &
373 & parameters_data,number_of_intermediate,intermediate_data,err) bind(c, name=
"SolverDAEExternalIntegrate")
377 INTEGER(C_INT),
VALUE,
INTENT(IN) :: NUMBER_OF_DOFS
378 REAL(C_DOUBLE),
VALUE,
INTENT(IN) :: START_TIME
379 REAL(C_DOUBLE),
VALUE,
INTENT(IN) :: END_TIME
380 REAL(C_DOUBLE),
INTENT(INOUT) :: INITIAL_STEP
381 INTEGER(C_INT),
VALUE,
INTENT(IN) :: ONLY_ONE_MODEL_INDEX
382 INTEGER(C_INT),
INTENT(IN) :: MODELS_DATA(*)
383 INTEGER(C_INT),
VALUE,
INTENT(IN) :: NUMBER_OF_STATE
384 REAL(C_DOUBLE),
INTENT(INOUT) :: STATE_DATA(*)
385 INTEGER(C_INT),
VALUE,
INTENT(IN) :: NUMBER_OF_PARAMETERS
386 REAL(C_DOUBLE),
INTENT(IN) :: PARAMETERS_DATA(*)
387 INTEGER(C_INT),
VALUE,
INTENT(IN) :: NUMBER_OF_INTERMEDIATE
388 REAL(C_DOUBLE),
INTENT(OUT) :: INTERMEDIATE_DATA(*)
389 INTEGER(C_INT),
INTENT(OUT) :: ERR
391 END SUBROUTINE solver_dae_external_integrate
725 INTEGER(INTG),
INTENT(OUT) :: CELLML_INDEX
726 INTEGER(INTG),
INTENT(OUT) :: ERR
729 INTEGER(INTG) :: cellml_idx
733 enters(
"CELLML_EQUATIONS_CELLML_ADD",err,error,*999)
735 IF(
ASSOCIATED(cellml_equations))
THEN 736 IF(cellml_equations%CELLML_EQUATIONS_FINISHED)
THEN 737 CALL flagerror(
"CellML equations has already been finished.",err,error,*999)
739 solver=>cellml_equations%SOLVER
740 IF(
ASSOCIATED(solver))
THEN 741 IF(
ASSOCIATED(cellml))
THEN 742 IF(cellml%CELLML_FINISHED)
THEN 743 ALLOCATE(new_cellml_environments(cellml_equations%NUMBER_OF_CELLML_ENVIRONMENTS+1),stat=err)
744 IF(err/=0)
CALL flagerror(
"Could not allocate new CellML environments.",err,error,*999)
745 DO cellml_idx=1,cellml_equations%NUMBER_OF_CELLML_ENVIRONMENTS
746 new_cellml_environments(cellml_idx)%PTR=>cellml_equations%CELLML_ENVIRONMENTS(cellml_idx)%PTR
748 new_cellml_environments(cellml_equations%NUMBER_OF_CELLML_ENVIRONMENTS+1)%PTR=>cellml
749 CALL move_alloc(new_cellml_environments,cellml_equations%CELLML_ENVIRONMENTS)
750 cellml_equations%NUMBER_OF_CELLML_ENVIRONMENTS=cellml_equations%NUMBER_OF_CELLML_ENVIRONMENTS+1
751 cellml_index=cellml_equations%NUMBER_OF_CELLML_ENVIRONMENTS
753 CALL flagerror(
"CellML environment has not been finished.",err,error,*999)
756 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
759 CALL flagerror(
"CellML equations solver is not associated.",err,error,*999)
763 CALL flagerror(
"CellML equations is not associated.",err,error,*999)
766 exits(
"CELLML_EQUATIONS_CELLML_ADD")
768 999
IF(
ALLOCATED(new_cellml_environments))
DEALLOCATE(new_cellml_environments)
769 errorsexits(
"CELLML_EQUATIONS_CELLML_ADD",err,error)
783 INTEGER(INTG),
INTENT(OUT) :: ERR
788 enters(
"CELLML_EQUATIONS_CREATE_FINISH",err,error,*999)
790 IF(
ASSOCIATED(cellml_equations))
THEN 791 IF(cellml_equations%CELLML_EQUATIONS_FINISHED)
THEN 792 CALL flagerror(
"CellML equations has already been finished.",err,error,*999)
794 solver=>cellml_equations%SOLVER
795 IF(
ASSOCIATED(solver))
THEN 796 cellml_equations%CELLML_EQUATIONS_FINISHED=.true.
798 CALL flagerror(
"CellML equations solver is not associated.",err,error,*999)
802 CALL flagerror(
"CellML equations is not associated.",err,error,*999)
805 exits(
"CELLML_EQUATIONS_CREATE_FINISH")
807 999 errorsexits(
"CELLML_EQUATIONS_CREATE_FINISH",err,error)
822 INTEGER(INTG),
INTENT(OUT) :: ERR
826 enters(
"CELLML_EQUATIONS_CREATE_START",err,error,*999)
828 IF(
ASSOCIATED(solver))
THEN 829 IF(
ASSOCIATED(cellml_equations))
THEN 830 CALL flagerror(
"CellML equations is already associated.",err,error,*999)
832 NULLIFY(cellml_equations)
834 cellml_equations=>solver%CELLML_EQUATIONS
837 CALL flagerror(
"Solver is not associated.",err,error,*999)
840 exits(
"CELLML_EQUATIONS_CREATE_START")
842 999 errorsexits(
"CELLML_EQUATIONS_CREATE_START",err,error)
856 INTEGER(INTG),
INTENT(OUT) :: ERR
860 enters(
"CELLML_EQUATIONS_DESTROY",err,error,*999)
862 IF(
ASSOCIATED(cellml_equations))
THEN 865 CALL flagerror(
"CellML equations is not associated.",err,error,*999)
868 exits(
"CELLML_EQUATIONS_DESTROY")
870 999 errorsexits(
"CELLML_EQUATIONS_DESTROY",err,error)
884 INTEGER(INTG),
INTENT(OUT) :: ERR
888 enters(
"CELLML_EQUATIONS_FINALISE",err,error,*999)
890 IF(
ASSOCIATED(cellml_equations))
THEN 891 IF(
ALLOCATED(cellml_equations%CELLML_ENVIRONMENTS))
DEALLOCATE(cellml_equations%CELLML_ENVIRONMENTS)
892 DEALLOCATE(cellml_equations)
895 exits(
"CELLML_EQUATIONS_FINALISE")
897 999 errorsexits(
"CELLML_EQUATIONS_FINALISE",err,error)
911 INTEGER(INTG),
INTENT(OUT) :: ERR
914 INTEGER(INTG) :: DUMMY_ERR
917 enters(
"CELLML_EQUATIONS_INITIALISE",err,error,*998)
919 IF(
ASSOCIATED(solver))
THEN 920 IF(
ASSOCIATED(solver%CELLML_EQUATIONS))
THEN 921 CALL flagerror(
"CellML equations is already associated for this solver.",err,error,*998)
923 ALLOCATE(solver%CELLML_EQUATIONS,stat=err)
924 IF(err/=0)
CALL flagerror(
"Could not allocate CellML equations.",err,error,*999)
925 solver%CELLML_EQUATIONS%SOLVER=>solver
926 solver%CELLML_EQUATIONS%CELLML_EQUATIONS_FINISHED=.false.
927 solver%CELLML_EQUATIONS%NUMBER_OF_CELLML_ENVIRONMENTS=0
930 CALL flagerror(
"Solver is not associated.",err,error,*998)
933 exits(
"CELLML_EQUATIONS_INITIALISE")
936 998 errorsexits(
"CELLML_EQUATIONS_INITIALISE",err,error)
951 INTEGER(INTG),
INTENT(OUT) :: ERR
955 enters(
"SOLVER_CELLML_EQUATIONS_GET",err,error,*998)
957 IF(
ASSOCIATED(solver))
THEN 958 IF(
ASSOCIATED(cellml_equations))
THEN 959 CALL flagerror(
"CellML equations is already associated.",err,error,*998)
961 cellml_equations=>solver%CELLML_EQUATIONS
962 IF(.NOT.
ASSOCIATED(cellml_equations))
CALL flagerror(
"CellML equations is not associated.",err,error,*999)
968 CALL flagerror(
"Solver is not associated.",err,error,*998)
971 exits(
"SOLVER_CELLML_EQUATIONS_GET")
973 999
NULLIFY(cellml_equations)
974 998 errorsexits(
"SOLVER_CELLML_EQUATIONS_GET",err,error)
988 INTEGER(INTG),
INTENT(OUT) :: ERR
992 enters(
"SOLVER_CELLML_EVALUATOR_CREATE_FINISH",err,error,*999)
994 IF(
ASSOCIATED(cellml_evaluator_solver))
THEN 995 CALL flagerror(
"Not implemented.",err,error,*999)
997 CALL flagerror(
"CellML evaluastor solver is not associated.",err,error,*999)
1000 exits(
"SOLVER_CELLML_EVALUATOR_CREATE_FINISH")
1002 999 errorsexits(
"SOLVER_CELLML_EVALUATOR_CREATE_FINISH",err,error)
1016 INTEGER(INTG),
INTENT(OUT) :: ERR
1020 enters(
"SOLVER_CELLML_EVALUATOR_FINALISE",err,error,*999)
1022 IF(
ASSOCIATED(cellml_evaluator_solver))
THEN 1023 DEALLOCATE(cellml_evaluator_solver)
1026 exits(
"SOLVER_CELLML_EVALUATOR_FINALISE")
1028 999 errorsexits(
"SOLVER_CELLML_EVALUATOR_FINALISE",err,error)
1042 INTEGER(INTG),
INTENT(OUT) :: ERR
1045 INTEGER(INTG) :: DUMMY_ERR
1048 enters(
"SOLVER_CELLML_EVALUATOR_INITIALISE",err,error,*998)
1050 IF(
ASSOCIATED(solver))
THEN 1051 IF(
ASSOCIATED(solver%CELLML_EVALUATOR_SOLVER))
THEN 1052 CALL flagerror(
"CellML evaluator solver is already associated for this solver.",err,error,*998)
1054 ALLOCATE(solver%CELLML_EVALUATOR_SOLVER,stat=err)
1055 IF(err/=0)
CALL flagerror(
"Could not allocate solver CellML evaluator solver.",err,error,*999)
1056 solver%CELLML_EVALUATOR_SOLVER%SOLVER=>solver
1058 solver%CELLML_EVALUATOR_SOLVER%CURRENT_TIME=0.0_dp
1061 CALL flagerror(
"Solver is not associated.",err,error,*998)
1064 exits(
"SOLVER_CELLML_EVALUATOR_INITIALISE")
1067 998 errorsexits(
"SOLVER_CELLML_EVALUATOR_INITIALISE",err,error)
1081 INTEGER(INTG),
INTENT(OUT) :: SOLVER_LIBRARY_TYPE
1082 INTEGER(INTG),
INTENT(OUT) :: ERR
1086 enters(
"SOLVER_CELLML_EVALUATOR_LIBRARY_TYPE_GET",err,error,*999)
1088 IF(
ASSOCIATED(cellml_evaluator_solver))
THEN 1089 solver_library_type=cellml_evaluator_solver%SOLVER_LIBRARY
1091 CALL flagerror(
"CellML evaluator solver is not associated.",err,error,*999)
1094 exits(
"SOLVER_CELLML_EVALUATOR_LIBRARY_TYPE_GET")
1096 999 errorsexits(
"SOLVER_CELLML_EVALUATOR_LIBRARY_TYPE_GET",err,error)
1110 INTEGER(INTG),
INTENT(IN) :: SOLVER_LIBRARY_TYPE
1111 INTEGER(INTG),
INTENT(OUT) :: ERR
1116 enters(
"SOLVER_CELLML_EVALUATOR_LIBRARY_TYPE_SET",err,error,*999)
1118 IF(
ASSOCIATED(cellml_evaluator_solver))
THEN 1119 SELECT CASE(solver_library_type)
1121 CALL flagerror(
"Not implemented.",err,error,*999)
1123 local_error=
"The specified solver library type of "//
trim(
numbertovstring(solver_library_type,
"*",err,error))// &
1124 &
" is invalid for a CellML evaluator solver." 1125 CALL flagerror(local_error,err,error,*999)
1128 CALL flagerror(
"CellML evaluator solver is not associated.",err,error,*999)
1131 exits(
"SOLVER_CELLML_EVALUATOR_LIBRARY_TYPE_SET")
1133 999 errorsexits(
"SOLVER_CELLML_EVALUATOR_LIBRARY_TYPE_SET",err,error)
1147 REAL(DP),
INTENT(OUT) :: TIME
1148 INTEGER(INTG),
INTENT(OUT) :: ERR
1152 enters(
"SOLVER_CELLML_EVALUATOR_TIME_GET",err,error,*999)
1154 IF(
ASSOCIATED(cellml_evaluator_solver))
THEN 1155 time=cellml_evaluator_solver%CURRENT_TIME
1157 CALL flagerror(
"CellML evaluator solver is not associated.",err,error,*999)
1160 exits(
"SOLVER_CELLML_EVALUATOR_TIME_GET")
1162 999 errorsexits(
"SOLVER_CELLML_EVALUATOR_TIME_GET",err,error)
1176 REAL(DP),
INTENT(IN) :: TIME
1177 INTEGER(INTG),
INTENT(OUT) :: ERR
1180 enters(
"SOLVER_CELLML_EVALUATOR_TIME_SET",err,error,*999)
1182 IF(
ASSOCIATED(cellml_evaluator_solver))
THEN 1183 cellml_evaluator_solver%CURRENT_TIME=time
1185 CALL flagerror(
"CellML evaluator solver is not associated.",err,error,*999)
1188 exits(
"SOLVER_CELLML_EVALUATOR_TIME_SET")
1190 999 errorsexits(
"SOLVER_CELLML_EVALUATOR_TIME_SET",err,error)
1204 INTEGER(INTG),
INTENT(OUT) :: ERR
1207 INTEGER(INTG) :: cellml_idx
1208 INTEGER(INTG),
POINTER :: MODELS_DATA(:)
1209 REAL(DP),
POINTER :: INTERMEDIATE_DATA(:),PARAMETERS_DATA(:),STATE_DATA(:)
1214 TYPE(
field_type),
POINTER :: MODELS_FIELD,STATE_FIELD,PARAMETERS_FIELD,INTERMEDIATE_FIELD
1218 enters(
"SOLVER_CELLML_EVALUATOR_SOLVE",err,error,*999)
1220 NULLIFY(models_data)
1221 NULLIFY(intermediate_data)
1222 NULLIFY(parameters_data)
1225 NULLIFY(models_variable)
1226 NULLIFY(state_field)
1227 NULLIFY(parameters_field)
1228 NULLIFY(intermediate_field)
1230 IF(
ASSOCIATED(cellml_evaluator_solver))
THEN 1231 solver=>cellml_evaluator_solver%SOLVER
1232 IF(
ASSOCIATED(solver))
THEN 1233 cellml_equations=>solver%CELLML_EQUATIONS
1234 IF(
ASSOCIATED(cellml_equations))
THEN 1235 DO cellml_idx=1,cellml_equations%NUMBER_OF_CELLML_ENVIRONMENTS
1236 cellml_environment=>cellml_equations%CELLML_ENVIRONMENTS(cellml_idx)%PTR
1237 IF(
ASSOCIATED(cellml_environment))
THEN 1238 cellml_models_field=>cellml_environment%MODELS_FIELD
1239 IF(
ASSOCIATED(cellml_models_field))
THEN 1240 models_field=>cellml_models_field%MODELS_FIELD
1241 IF(
ASSOCIATED(models_field))
THEN 1248 CALL field_variable_get(models_field,field_u_variable_type,models_variable,err,error,*999)
1249 CALL field_parameter_set_data_get(models_field,field_u_variable_type,field_values_set_type, &
1250 & models_data,err,error,*999)
1253 IF(
ASSOCIATED(cellml_environment%STATE_FIELD))
THEN 1254 state_field=>cellml_environment%STATE_FIELD%STATE_FIELD
1255 IF(
ASSOCIATED(state_field))
THEN 1256 CALL field_parameter_set_data_get(state_field,field_u_variable_type,field_values_set_type, &
1257 & state_data,err,error,*999)
1262 IF(
ASSOCIATED(cellml_environment%PARAMETERS_FIELD))
THEN 1263 parameters_field=>cellml_environment%PARAMETERS_FIELD%PARAMETERS_FIELD
1264 IF(
ASSOCIATED(parameters_field))
THEN 1265 CALL field_parameter_set_data_get(parameters_field,field_u_variable_type,field_values_set_type, &
1266 & parameters_data,err,error,*999)
1271 IF(
ASSOCIATED(cellml_environment%INTERMEDIATE_FIELD))
THEN 1272 intermediate_field=>cellml_environment%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD
1273 IF(
ASSOCIATED(intermediate_field))
THEN 1274 CALL field_parameter_set_data_get(intermediate_field,field_u_variable_type,field_values_set_type, &
1275 & intermediate_data,err,error,*999)
1280 SELECT CASE(cellml_evaluator_solver%SOLVER_LIBRARY)
1282 CALL solver_cellml_evaluate(cellml_evaluator_solver,cellml_environment,models_variable%TOTAL_NUMBER_OF_DOFS, &
1283 & cellml_environment%MODELS_FIELD%ONLY_ONE_MODEL_INDEX,models_data,cellml_environment% &
1284 & maximum_number_of_state,state_data,cellml_environment%MAXIMUM_NUMBER_OF_PARAMETERS, &
1285 & parameters_data,cellml_environment%MAXIMUM_NUMBER_OF_INTERMEDIATE,intermediate_data,err,error,*999)
1287 CALL flagerror(
"Solver library not implemented.",err,error,*999)
1291 CALL field_parameter_set_data_restore(models_field,field_u_variable_type,field_values_set_type, &
1292 & models_data,err,error,*999)
1293 IF(
ASSOCIATED(state_field))
CALL field_parameter_set_data_restore(state_field,field_u_variable_type, &
1294 & field_values_set_type,state_data,err,error,*999)
1295 IF(
ASSOCIATED(parameters_field))
CALL field_parameter_set_data_restore(parameters_field, &
1296 & field_u_variable_type,field_values_set_type,parameters_data,err,error,*999)
1297 IF(
ASSOCIATED(intermediate_field))
CALL field_parameter_set_data_restore(intermediate_field, &
1298 & field_u_variable_type,field_values_set_type,intermediate_data,err,error,*999)
1304 local_error=
"The CellML models field is not associated for CellML index "// &
1306 CALL flagerror(local_error,err,error,*999)
1309 local_error=
"The CellML models field is not associated for CellML index "// &
1311 CALL flagerror(local_error,err,error,*999)
1314 local_error=
"The CellML enviroment is not associated for for CellML index "// &
1316 CALL flagerror(local_error,err,error,*999)
1320 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
1323 CALL flagerror(
"Solver is not associated.",err,error,*999)
1326 CALL flagerror(
"CellML evaluator solver is not associated.",err,error,*999)
1329 exits(
"SOLVER_CELLML_EVALUATOR_SOLVE")
1331 999 errorsexits(
"SOLVER_CELLML_EVALUATOR_SOLVE",err,error)
1341 SUBROUTINE solver_cellml_evaluate(CELLML_EVALUATOR_SOLVER,CELLML,N, ONLY_ONE_MODEL_INDEX,MODELS_DATA,MAX_NUMBER_STATES, &
1342 & state_data,max_number_parameters,parameters_data,max_number_intermediates,intermediate_data,err,error,*)
1347 INTEGER(INTG),
INTENT(IN) :: N
1348 INTEGER(INTG),
INTENT(IN) :: ONLY_ONE_MODEL_INDEX
1349 INTEGER(INTG),
POINTER :: MODELS_DATA(:)
1350 INTEGER(INTG),
INTENT(IN) :: MAX_NUMBER_STATES
1351 REAL(DP),
POINTER :: STATE_DATA(:)
1352 INTEGER(INTG),
INTENT(IN) :: MAX_NUMBER_PARAMETERS
1353 REAL(DP),
POINTER :: PARAMETERS_DATA(:)
1354 INTEGER(INTG),
INTENT(IN) :: MAX_NUMBER_INTERMEDIATES
1355 REAL(DP),
POINTER :: INTERMEDIATE_DATA(:)
1356 INTEGER(INTG),
INTENT(OUT) :: ERR
1359 INTEGER(INTG) :: dof_idx,DOF_ORDER_TYPE,INTERMEDIATE_END_DOF,intermediate_idx,INTERMEDIATE_START_DOF,model_idx, &
1360 & NUMBER_INTERMEDIATES,NUMBER_PARAMETERS,NUMBER_STATES,PARAMETER_END_DOF,parameter_idx,PARAMETER_START_DOF, &
1361 & STATE_END_DOF,state_idx,STATE_START_DOF
1362 REAL(DP) :: INTERMEDIATES(max(1,max_number_intermediates)),PARAMETERS(max(1,max_number_parameters)), &
1363 & RATES(MAX(1,MAX_NUMBER_STATES)),STATES(MAX(1,MAX_NUMBER_STATES))
1367 enters(
"SOLVER_CELLML_EVALUATE",err,error,*999)
1369 IF(
ASSOCIATED(cellml_evaluator_solver))
THEN 1370 IF(
ASSOCIATED(cellml))
THEN 1371 IF(
ASSOCIATED(cellml%MODELS_FIELD))
THEN 1372 CALL field_dof_order_type_get(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type,dof_order_type,err,error,*999)
1373 IF(dof_order_type==field_separated_component_dof_order)
THEN 1378 model_idx=models_data(dof_idx)
1379 IF(model_idx.GT.0)
THEN 1380 model=>cellml%MODELS(model_idx)%PTR
1381 IF(
ASSOCIATED(model))
THEN 1382 number_states=model%NUMBER_OF_STATE
1383 number_intermediates=model%NUMBER_OF_INTERMEDIATE
1384 number_parameters=model%NUMBER_OF_PARAMETERS
1387 DO state_idx=1,number_states
1388 states(state_idx)=state_data((dof_idx-1)*n+state_idx)
1390 DO parameter_idx=1,number_parameters
1391 parameters(parameter_idx)=parameters_data((dof_idx-1)*n+parameter_idx)
1395 CALL cellml_model_definition_call_rhs_routine(model%PTR,0.0_dp,states,rates,intermediates, &
1398 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1402 DO intermediate_idx=1,number_intermediates
1403 intermediate_data((dof_idx-1)*n+intermediate_idx)=intermediates(intermediate_idx)
1405 DO state_idx=1,number_states
1406 state_data((dof_idx-1)*n+state_idx)=states(state_idx)
1410 local_error=
"CellML environment model is not associated for model index "// &
1411 &
trim(
numbertovstring(only_one_model_index,
"*",err,error))//
" belonging to dof index "// &
1413 CALL flagerror(local_error,err,error,*999)
1419 model=>cellml%MODELS(only_one_model_index)%PTR
1420 IF(
ASSOCIATED(model))
THEN 1421 number_states=model%NUMBER_OF_STATE
1422 number_intermediates=model%NUMBER_OF_INTERMEDIATE
1423 number_parameters=model%NUMBER_OF_PARAMETERS
1425 model_idx=models_data(dof_idx)
1426 IF(model_idx.GT.0)
THEN 1429 DO state_idx=1,number_states
1430 states(state_idx)=state_data((dof_idx-1)*n+state_idx)
1432 DO parameter_idx=1,number_parameters
1433 parameters(parameter_idx)=parameters_data((dof_idx-1)*n+parameter_idx)
1437 CALL cellml_model_definition_call_rhs_routine(model%PTR,0.0_dp,states,rates,intermediates, &
1440 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1444 DO intermediate_idx=1,number_intermediates
1445 intermediate_data((dof_idx-1)*n+intermediate_idx)=intermediates(intermediate_idx)
1447 DO state_idx=1,number_states
1448 state_data((dof_idx-1)*n+state_idx)=states(state_idx)
1453 local_error=
"CellML environment model is not associated for model index "// &
1455 CALL flagerror(local_error,err,error,*999)
1466 model_idx=models_data(dof_idx)
1467 IF(model_idx.GT.0)
THEN 1468 model=>cellml%MODELS(model_idx)%PTR
1469 IF(
ASSOCIATED(model))
THEN 1470 number_states=model%NUMBER_OF_STATE
1471 number_intermediates=model%NUMBER_OF_INTERMEDIATE
1472 number_parameters=model%NUMBER_OF_PARAMETERS
1475 IF(number_states>0)
THEN 1476 IF(number_intermediates>0)
THEN 1477 IF(number_parameters>0)
THEN 1479 state_start_dof=(dof_idx-1)*max_number_states+1
1480 state_end_dof=state_start_dof+number_states-1
1481 intermediate_start_dof=(dof_idx-1)*max_number_intermediates+1
1482 intermediate_end_dof=intermediate_start_dof+number_intermediates-1
1483 parameter_start_dof=(dof_idx-1)*max_number_parameters+1
1484 parameter_end_dof=parameter_start_dof+number_parameters-1
1486 CALL cellml_model_definition_call_rhs_routine(model%PTR,0.0_dp, &
1487 & state_data(state_start_dof:state_end_dof), &
1488 & rates,intermediate_data(intermediate_start_dof:intermediate_end_dof),parameters_data( &
1489 & parameter_start_dof:parameter_end_dof))
1493 state_start_dof=(dof_idx-1)*max_number_states+1
1494 state_end_dof=state_start_dof+number_states-1
1495 intermediate_start_dof=(dof_idx-1)*max_number_intermediates+1
1496 intermediate_end_dof=intermediate_start_dof+number_intermediates-1
1498 CALL cellml_model_definition_call_rhs_routine(model%PTR,0.0_dp, &
1499 & state_data(state_start_dof:state_end_dof), &
1500 & rates,intermediate_data(intermediate_start_dof:intermediate_end_dof),parameters)
1504 IF(number_parameters>0)
THEN 1506 state_start_dof=(dof_idx-1)*max_number_states+1
1507 state_end_dof=state_start_dof+number_states-1
1508 parameter_start_dof=(dof_idx-1)*max_number_parameters+1
1509 parameter_end_dof=parameter_start_dof+number_parameters-1
1511 CALL cellml_model_definition_call_rhs_routine(model%PTR,0.0_dp, &
1512 & state_data(state_start_dof:state_end_dof), &
1513 & rates,intermediates,parameters_data(parameter_start_dof:parameter_end_dof))
1517 state_start_dof=(dof_idx-1)*max_number_states+1
1518 state_end_dof=state_start_dof+number_states-1
1520 CALL cellml_model_definition_call_rhs_routine(model%PTR,0.0_dp, &
1521 & state_data(state_start_dof:state_end_dof), &
1522 & rates,intermediates,parameters)
1527 IF(number_intermediates>0)
THEN 1528 IF(number_parameters>0)
THEN 1530 intermediate_start_dof=(dof_idx-1)*max_number_intermediates+1
1531 intermediate_end_dof=intermediate_start_dof+number_intermediates-1
1532 parameter_start_dof=(dof_idx-1)*max_number_parameters+1
1533 parameter_end_dof=parameter_start_dof+number_parameters-1
1535 CALL cellml_model_definition_call_rhs_routine(model%PTR,0.0_dp,states,rates, &
1536 & intermediate_data(intermediate_start_dof:intermediate_end_dof),parameters_data( &
1537 & parameter_start_dof:parameter_end_dof))
1540 intermediate_start_dof=(dof_idx-1)*max_number_intermediates+1
1541 intermediate_end_dof=intermediate_start_dof+number_intermediates-1
1543 CALL cellml_model_definition_call_rhs_routine(model%PTR,0.0_dp,states,rates, &
1544 & intermediate_data(intermediate_start_dof:intermediate_end_dof),parameters)
1548 CALL flagerror(
"Invalid CellML model - there are no states or intermediates.",err,error,*999)
1554 local_error=
"CellML environment model is not associated for model index "// &
1555 &
trim(
numbertovstring(only_one_model_index,
"*",err,error))//
" belonging to dof index "// &
1557 CALL flagerror(local_error,err,error,*999)
1562 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1567 model=>cellml%MODELS(only_one_model_index)%PTR
1568 IF(
ASSOCIATED(model))
THEN 1569 number_states=model%NUMBER_OF_STATE
1570 number_intermediates=model%NUMBER_OF_INTERMEDIATE
1571 number_parameters=model%NUMBER_OF_PARAMETERS
1575 IF(number_states>0)
THEN 1576 IF(number_intermediates>0)
THEN 1577 IF(number_parameters>0)
THEN 1580 model_idx=models_data(dof_idx)
1581 IF(model_idx.GT.0)
THEN 1582 state_start_dof=(dof_idx-1)*max_number_states+1
1583 state_end_dof=state_start_dof+number_states-1
1584 intermediate_start_dof=(dof_idx-1)*max_number_intermediates+1
1585 intermediate_end_dof=intermediate_start_dof+number_intermediates-1
1586 parameter_start_dof=(dof_idx-1)*max_number_parameters+1
1587 parameter_end_dof=parameter_start_dof+number_parameters-1
1589 CALL cellml_model_definition_call_rhs_routine(model%PTR,0.0_dp, &
1590 & state_data(state_start_dof:state_end_dof), &
1591 & rates,intermediate_data(intermediate_start_dof:intermediate_end_dof),parameters_data( &
1592 & parameter_start_dof:parameter_end_dof))
1598 model_idx=models_data(dof_idx)
1599 IF(model_idx.GT.0)
THEN 1600 state_start_dof=(dof_idx-1)*max_number_states+1
1601 state_end_dof=state_start_dof+number_states-1
1602 intermediate_start_dof=(dof_idx-1)*max_number_intermediates+1
1603 intermediate_end_dof=intermediate_start_dof+number_intermediates-1
1605 CALL cellml_model_definition_call_rhs_routine(model%PTR,0.0_dp, &
1606 & state_data(state_start_dof:state_end_dof), &
1607 & rates,intermediate_data(intermediate_start_dof:intermediate_end_dof),parameters)
1613 IF(number_parameters>0)
THEN 1616 model_idx=models_data(dof_idx)
1617 IF(model_idx.GT.0)
THEN 1619 state_start_dof=(dof_idx-1)*max_number_states+1
1620 state_end_dof=state_start_dof+number_states-1
1621 parameter_start_dof=(dof_idx-1)*max_number_parameters+1
1622 parameter_end_dof=parameter_start_dof+number_parameters-1
1624 CALL cellml_model_definition_call_rhs_routine(model%PTR,0.0_dp, &
1625 & state_data(state_start_dof:state_end_dof), &
1626 & rates,intermediates,parameters_data(parameter_start_dof:parameter_end_dof))
1632 model_idx=models_data(dof_idx)
1633 IF(model_idx.GT.0)
THEN 1635 state_start_dof=(dof_idx-1)*max_number_states+1
1636 state_end_dof=state_start_dof+number_states-1
1638 CALL cellml_model_definition_call_rhs_routine(model%PTR,0.0_dp,&
1639 & state_data(state_start_dof:state_end_dof), &
1640 & rates,intermediates,parameters)
1646 IF(number_intermediates>0)
THEN 1647 IF(number_parameters>0)
THEN 1650 model_idx=models_data(dof_idx)
1651 IF(model_idx.GT.0)
THEN 1653 intermediate_start_dof=(dof_idx-1)*max_number_intermediates+1
1654 intermediate_end_dof=intermediate_start_dof+number_intermediates-1
1655 parameter_start_dof=(dof_idx-1)*max_number_parameters+1
1656 parameter_end_dof=parameter_start_dof+number_parameters-1
1658 CALL cellml_model_definition_call_rhs_routine(model%PTR,0.0_dp,states,rates, &
1659 & intermediate_data(intermediate_start_dof:intermediate_end_dof),parameters_data( &
1660 & parameter_start_dof:parameter_end_dof))
1666 model_idx=models_data(dof_idx)
1667 IF(model_idx.GT.0)
THEN 1669 intermediate_start_dof=(dof_idx-1)*max_number_intermediates+1
1670 intermediate_end_dof=intermediate_start_dof+number_intermediates-1
1672 CALL cellml_model_definition_call_rhs_routine(model%PTR,0.0_dp,states,rates, &
1673 & intermediate_data(intermediate_start_dof:intermediate_end_dof),parameters)
1678 CALL flagerror(
"Invalid CellML model - there are no states or intermediates.",err,error,*999)
1682 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
1685 local_error=
"CellML environment model is not associated for model index "// &
1687 CALL flagerror(local_error,err,error,*999)
1692 CALL flagerror(
"CellML environment models field is not associated.",err,error,*999)
1695 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
1698 CALL flagerror(
"CellML evaluator solver is not associated.",err,error,*999)
1701 exits(
"SOLVER_CELLML_EVALUATE")
1703 999 errorsexits(
"SOLVER_CELLML_EVALUATE",err,error)
1717 INTEGER(INTG),
INTENT(OUT) :: ERR
1720 INTEGER(INTG) :: solver_idx
1722 enters(
"SOLVER_CREATE_FINISH",err,error,*999)
1724 IF(
ASSOCIATED(solver))
THEN 1725 IF(solver%SOLVER_FINISHED)
THEN 1726 CALL flagerror(
"Solver has already been finished.",err,error,*999)
1729 DO solver_idx=1,solver%NUMBER_OF_LINKED_SOLVERS
1730 solver%LINKED_SOLVERS(solver_idx)%PTR%SOLVER_FINISHED=.true.
1733 solver%SOLVER_FINISHED=.true.
1736 CALL flagerror(
"Solver is not associated.",err,error,*999)
1739 exits(
"SOLVER_CREATE_FINISH")
1741 999 errorsexits(
"SOLVER_CREATE_FINISH",err,error)
1755 INTEGER(INTG),
INTENT(OUT) :: ERR
1759 enters(
"SOLVER_DAE_ADAMS_MOULTON_FINALISE",err,error,*999)
1761 IF(
ASSOCIATED(adams_moulton_solver))
THEN 1762 DEALLOCATE(adams_moulton_solver)
1765 exits(
"SOLVER_DAE_ADAMS_MOULTON_FINALISE")
1767 999 errorsexits(
"SOLVER_DAE_ADAMS_MOULTON_FINALISE",err,error)
1781 INTEGER(INTG),
INTENT(OUT) :: ERR
1784 INTEGER(INTG) :: DUMMY_ERR
1787 enters(
"SOLVER_DAE_ADAMS_MOULTON_INITIALISE",err,error,*998)
1789 IF(
ASSOCIATED(dae_solver))
THEN 1790 IF(
ASSOCIATED(dae_solver%ADAMS_MOULTON_SOLVER))
THEN 1791 CALL flagerror(
"Adams-Moulton solver is already associated for this differential-algebraic equation solver.", &
1795 ALLOCATE(dae_solver%ADAMS_MOULTON_SOLVER,stat=err)
1796 IF(err/=0)
CALL flagerror(
"Could not allocate Adams-Moulton solver.",err,error,*999)
1798 dae_solver%ADAMS_MOULTON_SOLVER%DAE_SOLVER=>dae_solver
1799 dae_solver%ADAMS_MOULTON_SOLVER%SOLVER_LIBRARY=0
1803 CALL flagerror(
"Differential-algebraic equation solver is not associated.",err,error,*998)
1806 exits(
"SOLVER_DAE_ADAMS_MOULTON_INITIALISE")
1809 998 errorsexits(
"SOLVER_DAE_ADAMS_MOULTON_INITIALISE",err,error)
1823 INTEGER(INTG),
INTENT(OUT) :: ERR
1827 enters(
"SOLVER_DAE_ADAMS_MOULTON_SOLVE",err,error,*999)
1829 IF(
ASSOCIATED(adams_moulton_solver))
THEN 1830 CALL flagerror(
"Not implemented.",err,error,*999)
1832 CALL flagerror(
"Adams-Moulton differential-algebraic equation solver is not associated.",err,error,*999)
1835 exits(
"SOLVER_DAE_ADAMS_MOULTON_SOLVE")
1837 999 errorsexits(
"SOLVER_DAE_ADAMS_MOULTON_SOLVE",err,error)
1851 INTEGER(INTG),
INTENT(OUT) :: ERR
1855 enters(
"SOLVER_DAE_CREATE_FINISH",err,error,*999)
1857 IF(
ASSOCIATED(dae_solver))
THEN 1858 CALL flagerror(
"Not implemented.",err,error,*999)
1860 CALL flagerror(
"Differential-algebraic equation solver is not associated.",err,error,*999)
1863 exits(
"SOLVER_DAE_CREATE_FINISH")
1865 999 errorsexits(
"SOLVER_DAE_CREATE_FINISH",err,error)
1879 INTEGER(INTG),
INTENT(OUT) :: ERR
1883 enters(
"SOLVER_DAE_EULER_BACKWARD_FINALISE",err,error,*999)
1885 IF(
ASSOCIATED(backward_euler_solver))
THEN 1886 DEALLOCATE(backward_euler_solver)
1889 exits(
"SOLVER_DAE_EULER_BACKWARD_FINALISE")
1891 999 errorsexits(
"SOLVER_DAE_EULER_BACKWARD_FINALISE",err,error)
1905 INTEGER(INTG),
INTENT(OUT) :: ERR
1908 INTEGER(INTG) :: DUMMY_ERR
1911 enters(
"SOLVER_DAE_EULER_BACKWARD_INITIALISE",err,error,*998)
1913 IF(
ASSOCIATED(euler_dae_solver))
THEN 1914 IF(
ASSOCIATED(euler_dae_solver%BACKWARD_EULER_SOLVER))
THEN 1915 CALL flagerror(
"Backward Euler solver is already associated for this Euler differential-algebraic equation solver.", &
1919 ALLOCATE(euler_dae_solver%BACKWARD_EULER_SOLVER,stat=err)
1920 IF(err/=0)
CALL flagerror(
"Could not allocate backward Euler solver.",err,error,*999)
1922 euler_dae_solver%BACKWARD_EULER_SOLVER%EULER_DAE_SOLVER=>euler_dae_solver
1923 euler_dae_solver%BACKWARD_EULER_SOLVER%SOLVER_LIBRARY=0
1927 CALL flagerror(
"Euler differential-algebraic equation solver is not associated.",err,error,*998)
1930 exits(
"SOLVER_DAE_EULER_BACKWARD_INITIALISE")
1933 998 errorsexits(
"SOLVER_DAE_EULER_BACKWARD_INITIALISE",err,error)
1947 INTEGER(INTG),
INTENT(OUT) :: ERR
1951 enters(
"SOLVER_DAE_EULER_BACKWARD_SOLVE",err,error,*999)
1953 IF(
ASSOCIATED(backward_euler_solver))
THEN 1954 CALL flagerror(
"Not implemented.",err,error,*999)
1956 CALL flagerror(
"Backward Euler differential-algebraic equation solver is not associated.",err,error,*999)
1959 exits(
"SOLVER_DAE_EULER_BACKWARD_SOLVE")
1961 999 errorsexits(
"SOLVER_DAE_EULER_BACKWARD_SOLVE",err,error)
1975 INTEGER(INTG),
INTENT(OUT) :: ERR
1979 enters(
"SOLVER_DAE_EULER_FINALISE",err,error,*999)
1981 IF(
ASSOCIATED(euler_solver))
THEN 1985 DEALLOCATE(euler_solver)
1988 exits(
"SOLVER_DAE_EULER_FINALISE")
1990 999 errorsexits(
"SOLVER_DAE_EULER_FINALISE",err,error)
2004 INTEGER(INTG),
INTENT(OUT) :: ERR
2008 enters(
"SOLVER_DAE_EULER_FORWARD_FINALISE",err,error,*999)
2010 IF(
ASSOCIATED(forward_euler_solver))
THEN 2011 DEALLOCATE(forward_euler_solver)
2014 exits(
"SOLVER_DAE_EULER_FORWARD_FINALISE")
2016 999 errorsexits(
"SOLVER_DAE_EULER_FORWARD_FINALISE",err,error)
2030 INTEGER(INTG),
INTENT(OUT) :: ERR
2033 INTEGER(INTG) :: DUMMY_ERR
2036 enters(
"SOLVER_DAE_EULER_FORWARD_INITIALISE",err,error,*998)
2038 IF(
ASSOCIATED(euler_dae_solver))
THEN 2039 IF(
ASSOCIATED(euler_dae_solver%FORWARD_EULER_SOLVER))
THEN 2040 CALL flagerror(
"Forward Euler solver is already associated for this Euler differential-algebraic equation solver.", &
2044 ALLOCATE(euler_dae_solver%FORWARD_EULER_SOLVER,stat=err)
2045 IF(err/=0)
CALL flagerror(
"Could not allocate forward Euler solver.",err,error,*999)
2047 euler_dae_solver%FORWARD_EULER_SOLVER%EULER_DAE_SOLVER=>euler_dae_solver
2052 CALL flagerror(
"Euler differential-algebraic equation solver is not associated.",err,error,*998)
2055 exits(
"SOLVER_DAE_EULER_FORWARD_INITIALISE")
2058 998 errorsexits(
"SOLVER_DAE_EULER_FORWARD_INITIALISE",err,error)
2069 & only_one_model_index,models_data,max_number_states,state_data,max_number_parameters,parameters_data, &
2070 & max_number_intermediates,intermediate_data,err,error,*)
2075 INTEGER(INTG),
INTENT(IN) :: N
2076 REAL(DP),
INTENT(IN) :: START_TIME
2077 REAL(DP),
INTENT(IN) :: END_TIME
2078 REAL(DP),
INTENT(INOUT) :: TIME_INCREMENT
2079 INTEGER(INTG),
INTENT(IN) :: ONLY_ONE_MODEL_INDEX
2080 INTEGER(INTG),
POINTER :: MODELS_DATA(:)
2081 INTEGER(INTG),
INTENT(IN) :: MAX_NUMBER_STATES
2082 REAL(DP),
POINTER :: STATE_DATA(:)
2083 INTEGER(INTG),
INTENT(IN) :: MAX_NUMBER_PARAMETERS
2084 REAL(DP),
POINTER :: PARAMETERS_DATA(:)
2085 INTEGER(INTG),
INTENT(IN) :: MAX_NUMBER_INTERMEDIATES
2086 REAL(DP),
POINTER :: INTERMEDIATE_DATA(:)
2087 INTEGER(INTG),
INTENT(OUT) :: ERR
2090 INTEGER(INTG) :: dof_idx,DOF_ORDER_TYPE,INTERMEDIATE_END_DOF,intermediate_idx,INTERMEDIATE_START_DOF,model_idx, &
2091 & NUMBER_INTERMEDIATES,NUMBER_PARAMETERS,NUMBER_STATES,PARAMETER_END_DOF,parameter_idx,PARAMETER_START_DOF, &
2092 & STATE_END_DOF,state_idx,STATE_START_DOF
2093 REAL(DP) :: INTERMEDIATES(max(1,max_number_intermediates)),PARAMETERS(max(1,max_number_parameters)), &
2094 & RATES(MAX(1,MAX_NUMBER_STATES)),STATES(MAX(1,MAX_NUMBER_STATES)),TIME
2098 enters(
"SOLVER_DAE_EULER_FORWARD_INTEGRATE",err,error,*999)
2100 IF(
ASSOCIATED(forward_euler_solver))
THEN 2101 IF(
ASSOCIATED(cellml))
THEN 2102 IF(
ASSOCIATED(cellml%MODELS_FIELD))
THEN 2103 CALL field_dof_order_type_get(cellml%MODELS_FIELD%MODELS_FIELD,field_u_variable_type,dof_order_type,err,error,*999)
2104 IF(dof_order_type==field_separated_component_dof_order)
THEN 2108 DO WHILE(time<=end_time)
2110 model_idx=models_data(dof_idx)
2111 IF(model_idx.GT.0)
THEN 2112 model=>cellml%MODELS(model_idx)%PTR
2113 IF(
ASSOCIATED(model))
THEN 2114 number_states=model%NUMBER_OF_STATE
2115 number_intermediates=model%NUMBER_OF_INTERMEDIATE
2116 number_parameters=model%NUMBER_OF_PARAMETERS
2119 DO state_idx=1,number_states
2120 states(state_idx)=state_data((dof_idx-1)*n+state_idx)
2122 DO parameter_idx=1,number_parameters
2123 parameters(parameter_idx)=parameters_data((dof_idx-1)*n+parameter_idx)
2127 CALL cellml_model_definition_call_rhs_routine(model%PTR,time,states,rates,intermediates, &
2130 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
2134 DO intermediate_idx=1,number_intermediates
2135 intermediate_data((dof_idx-1)*n+intermediate_idx)=intermediates(intermediate_idx)
2137 DO state_idx=1,number_states
2138 state_data((dof_idx-1)*n+state_idx)=states(state_idx)+time_increment*rates(state_idx)
2142 local_error=
"CellML environment model is not associated for model index "// &
2143 &
trim(
numbertovstring(only_one_model_index,
"*",err,error))//
" belonging to dof index "// &
2145 CALL flagerror(local_error,err,error,*999)
2149 time=time+time_increment
2153 model=>cellml%MODELS(only_one_model_index)%PTR
2154 IF(
ASSOCIATED(model))
THEN 2155 number_states=model%NUMBER_OF_STATE
2156 number_intermediates=model%NUMBER_OF_INTERMEDIATE
2157 number_parameters=model%NUMBER_OF_PARAMETERS
2159 DO WHILE(time<=end_time)
2162 model_idx=models_data(dof_idx)
2163 IF(model_idx.GT.0)
THEN 2165 DO state_idx=1,number_states
2166 states(state_idx)=state_data((dof_idx-1)*n+state_idx)
2168 DO parameter_idx=1,number_parameters
2169 parameters(parameter_idx)=parameters_data((dof_idx-1)*n+parameter_idx)
2173 CALL cellml_model_definition_call_rhs_routine(model%PTR,time,states,rates,intermediates, &
2176 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
2180 DO intermediate_idx=1,number_intermediates
2181 intermediate_data((dof_idx-1)*n+intermediate_idx)=intermediates(intermediate_idx)
2183 DO state_idx=1,number_states
2184 state_data((dof_idx-1)*n+state_idx)=states(state_idx)+time_increment*rates(state_idx)
2188 time=time+time_increment
2191 local_error=
"CellML environment model is not associated for model index "// &
2193 CALL flagerror(local_error,err,error,*999)
2201 DO WHILE(time<=end_time)
2203 model_idx=models_data(dof_idx)
2204 IF(model_idx==0)
THEN 2206 ELSE IF(model_idx > 0 .AND. model_idx <= cellml%NUMBER_OF_MODELS)
THEN 2207 model=>cellml%MODELS(model_idx)%PTR
2208 IF(
ASSOCIATED(model))
THEN 2209 number_states=model%NUMBER_OF_STATE
2210 number_intermediates=model%NUMBER_OF_INTERMEDIATE
2211 number_parameters=model%NUMBER_OF_PARAMETERS
2216 IF(number_states>0)
THEN 2217 IF(number_intermediates>0)
THEN 2218 IF(number_parameters>0)
THEN 2221 state_start_dof=(dof_idx-1)*max_number_states+1
2222 state_end_dof=state_start_dof+number_states-1
2223 intermediate_start_dof=(dof_idx-1)*max_number_intermediates+1
2224 intermediate_end_dof=intermediate_start_dof+number_intermediates-1
2225 parameter_start_dof=(dof_idx-1)*max_number_parameters+1
2226 parameter_end_dof=parameter_start_dof+number_parameters-1
2228 CALL cellml_model_definition_call_rhs_routine(model%PTR,time,state_data(state_start_dof: &
2229 & state_end_dof),rates,intermediate_data(intermediate_start_dof:intermediate_end_dof), &
2230 & parameters_data(parameter_start_dof:parameter_end_dof))
2235 state_start_dof=(dof_idx-1)*max_number_states+1
2236 state_end_dof=state_start_dof+number_states-1
2237 intermediate_start_dof=(dof_idx-1)*max_number_intermediates+1
2238 intermediate_end_dof=intermediate_start_dof+number_intermediates-1
2240 CALL cellml_model_definition_call_rhs_routine(model%PTR,time,state_data(state_start_dof: &
2241 & state_end_dof),rates,intermediate_data(intermediate_start_dof:intermediate_end_dof), &
2246 IF(number_parameters>0)
THEN 2248 state_start_dof=(dof_idx-1)*max_number_states+1
2249 state_end_dof=state_start_dof+number_states-1
2250 parameter_start_dof=(dof_idx-1)*max_number_parameters+1
2251 parameter_end_dof=parameter_start_dof+number_parameters-1
2253 CALL cellml_model_definition_call_rhs_routine(model%PTR,time,state_data(state_start_dof: &
2254 & state_end_dof),rates,intermediates,parameters_data(parameter_start_dof:parameter_end_dof))
2258 state_start_dof=(dof_idx-1)*max_number_states+1
2259 state_end_dof=state_start_dof+number_states-1
2261 CALL cellml_model_definition_call_rhs_routine(model%PTR,time,state_data(state_start_dof: &
2262 & state_end_dof),rates,intermediates,parameters)
2267 CALL flagerror(
"Invalid CellML model for integration - there are no states.",err,error,*999)
2271 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
2273 state_data(state_start_dof:state_end_dof)=state_data(state_start_dof:state_end_dof)+ &
2274 & time_increment*rates(1:number_states)
2276 local_error=
"CellML environment model is not associated for model index "// &
2277 &
trim(
numbertovstring(only_one_model_index,
"*",err,error))//
" belonging to dof index "// &
2279 CALL flagerror(local_error,err,error,*999)
2282 local_error=
"Invalid CellML model index: "// &
2283 &
trim(
numbertovstring(model_idx,
"*",err,error))//
". The specified index should be between 1 and "// &
2285 CALL flagerror(local_error,err,error,*999)
2288 time=time+time_increment
2292 model=>cellml%MODELS(only_one_model_index)%PTR
2293 IF(
ASSOCIATED(model))
THEN 2294 number_states=model%NUMBER_OF_STATE
2295 number_intermediates=model%NUMBER_OF_INTERMEDIATE
2296 number_parameters=model%NUMBER_OF_PARAMETERS
2301 IF(number_states>0)
THEN 2302 IF(number_intermediates>0)
THEN 2303 IF(number_parameters>0)
THEN 2307 DO WHILE(time<=end_time)
2309 model_idx=models_data(dof_idx)
2310 IF(model_idx.GT.0)
THEN 2312 state_start_dof=(dof_idx-1)*max_number_states+1
2313 state_end_dof=state_start_dof+number_states-1
2314 intermediate_start_dof=(dof_idx-1)*max_number_intermediates+1
2315 intermediate_end_dof=intermediate_start_dof+number_intermediates-1
2316 parameter_start_dof=(dof_idx-1)*max_number_parameters+1
2317 parameter_end_dof=parameter_start_dof+number_parameters-1
2319 CALL cellml_model_definition_call_rhs_routine(model%PTR,time, &
2320 & state_data(state_start_dof:state_end_dof), &
2321 & rates,intermediate_data(intermediate_start_dof:intermediate_end_dof),parameters_data( &
2322 & parameter_start_dof:parameter_end_dof))
2324 state_data(state_start_dof:state_end_dof)=state_data(state_start_dof:state_end_dof)+ &
2325 & time_increment*rates(1:number_states)
2328 time=time+time_increment
2333 DO WHILE(time<=end_time)
2335 model_idx=models_data(dof_idx)
2336 IF(model_idx.GT.0)
THEN 2338 state_start_dof=(dof_idx-1)*max_number_states+1
2339 state_end_dof=state_start_dof+number_states-1
2340 intermediate_start_dof=(dof_idx-1)*max_number_intermediates+1
2341 intermediate_end_dof=intermediate_start_dof+number_intermediates-1
2343 CALL cellml_model_definition_call_rhs_routine(model%PTR,time, &
2344 & state_data(state_start_dof:state_end_dof), &
2345 & rates,intermediate_data(intermediate_start_dof:intermediate_end_dof),parameters)
2347 state_data(state_start_dof:state_end_dof)=state_data(state_start_dof:state_end_dof)+ &
2348 & time_increment*rates(1:number_states)
2351 time=time+time_increment
2355 IF(number_parameters>0)
THEN 2359 DO WHILE(time<=end_time)
2361 model_idx=models_data(dof_idx)
2362 IF(model_idx.GT.0)
THEN 2364 state_start_dof=(dof_idx-1)*max_number_states+1
2365 state_end_dof=state_start_dof+number_states-1
2366 parameter_start_dof=(dof_idx-1)*max_number_parameters+1
2367 parameter_end_dof=parameter_start_dof+number_parameters-1
2369 CALL cellml_model_definition_call_rhs_routine(model%PTR,time, &
2370 & state_data(state_start_dof:state_end_dof), &
2371 & rates,intermediates,parameters_data(parameter_start_dof:parameter_end_dof))
2373 state_data(state_start_dof:state_end_dof)=state_data(state_start_dof:state_end_dof)+ &
2374 & time_increment*rates(1:number_states)
2377 time=time+time_increment
2382 DO WHILE(time<=end_time)
2384 model_idx=models_data(dof_idx)
2385 IF(model_idx.GT.0)
THEN 2387 state_start_dof=(dof_idx-1)*max_number_states+1
2388 state_end_dof=state_start_dof+number_states-1
2390 CALL cellml_model_definition_call_rhs_routine(model%PTR,time, &
2391 & state_data(state_start_dof:state_end_dof), &
2392 & rates,intermediates,parameters)
2394 state_data(state_start_dof:state_end_dof)=state_data(state_start_dof:state_end_dof)+ &
2395 & time_increment*rates(1:number_states)
2398 time=time+time_increment
2403 CALL flagerror(
"Invalid CellML model for integration - there are no states.",err,error,*999)
2407 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
2411 local_error=
"CellML environment model is not associated for model index "// &
2413 CALL flagerror(local_error,err,error,*999)
2418 CALL flagerror(
"CellML environment models field is not associated.",err,error,*999)
2421 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
2424 CALL flagerror(
"Forward Euler solver is not associated.",err,error,*999)
2427 exits(
"SOLVER_DAE_EULER_FORWARD_INTEGRATE")
2429 999 errorsexits(
"SOLVER_DAE_EULER_FORWARD_INTEGRATE",err,error)
2443 INTEGER(INTG),
INTENT(OUT) :: ERR
2446 INTEGER(INTG) :: cellml_idx
2447 INTEGER(INTG),
POINTER :: MODELS_DATA(:)
2448 REAL(DP),
POINTER :: INTERMEDIATE_DATA(:),PARAMETERS_DATA(:),STATE_DATA(:)
2455 TYPE(
field_type),
POINTER :: MODELS_FIELD,STATE_FIELD,PARAMETERS_FIELD,INTERMEDIATE_FIELD
2459 enters(
"SOLVER_DAE_EULER_FORWARD_SOLVE",err,error,*999)
2461 NULLIFY(models_data)
2462 NULLIFY(intermediate_data)
2463 NULLIFY(parameters_data)
2465 NULLIFY(models_variable)
2466 NULLIFY(models_field)
2467 NULLIFY(state_field)
2468 NULLIFY(parameters_field)
2469 NULLIFY(intermediate_field)
2471 IF(
ASSOCIATED(forward_euler_solver))
THEN 2472 euler_solver=>forward_euler_solver%EULER_DAE_SOLVER
2473 IF(
ASSOCIATED(euler_solver))
THEN 2474 dae_solver=>euler_solver%DAE_SOLVER
2475 IF(
ASSOCIATED(dae_solver))
THEN 2476 solver=>dae_solver%SOLVER
2477 IF(
ASSOCIATED(solver))
THEN 2478 cellml_equations=>solver%CELLML_EQUATIONS
2479 IF(
ASSOCIATED(cellml_equations))
THEN 2480 DO cellml_idx=1,cellml_equations%NUMBER_OF_CELLML_ENVIRONMENTS
2481 cellml_environment=>cellml_equations%CELLML_ENVIRONMENTS(cellml_idx)%PTR
2482 IF(
ASSOCIATED(cellml_environment))
THEN 2483 cellml_models_field=>cellml_environment%MODELS_FIELD
2484 IF(
ASSOCIATED(cellml_models_field))
THEN 2485 models_field=>cellml_models_field%MODELS_FIELD
2486 IF(
ASSOCIATED(models_field))
THEN 2493 CALL field_variable_get(models_field,field_u_variable_type,models_variable,err,error,*999)
2494 CALL field_parameter_set_data_get(models_field,field_u_variable_type,field_values_set_type, &
2495 & models_data,err,error,*999)
2498 IF(
ASSOCIATED(cellml_environment%STATE_FIELD))
THEN 2499 state_field=>cellml_environment%STATE_FIELD%STATE_FIELD
2500 IF(
ASSOCIATED(state_field))
THEN 2501 CALL field_parameter_set_data_get(state_field,field_u_variable_type,field_values_set_type, &
2502 & state_data,err,error,*999)
2507 IF(
ASSOCIATED(cellml_environment%PARAMETERS_FIELD))
THEN 2508 parameters_field=>cellml_environment%PARAMETERS_FIELD%PARAMETERS_FIELD
2509 IF(
ASSOCIATED(parameters_field))
THEN 2510 CALL field_parameter_set_data_get(parameters_field,field_u_variable_type,field_values_set_type, &
2511 & parameters_data,err,error,*999)
2516 IF(
ASSOCIATED(cellml_environment%INTERMEDIATE_FIELD))
THEN 2517 intermediate_field=>cellml_environment%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD
2518 IF(
ASSOCIATED(intermediate_field))
THEN 2519 CALL field_parameter_set_data_get(intermediate_field,field_u_variable_type,field_values_set_type, &
2520 & intermediate_data,err,error,*999)
2526 & total_number_of_dofs,dae_solver%START_TIME,dae_solver%END_TIME,dae_solver%INITIAL_STEP, &
2527 & cellml_environment%MODELS_FIELD%ONLY_ONE_MODEL_INDEX,models_data,cellml_environment% &
2528 & maximum_number_of_state,state_data,cellml_environment%MAXIMUM_NUMBER_OF_PARAMETERS, &
2529 & parameters_data,cellml_environment%MAXIMUM_NUMBER_OF_INTERMEDIATE,intermediate_data,err,error,*999)
2532 CALL field_parameter_set_data_restore(models_field,field_u_variable_type,field_values_set_type, &
2533 & models_data,err,error,*999)
2534 IF(
ASSOCIATED(state_field))
CALL field_parameter_set_data_restore(state_field,field_u_variable_type, &
2535 & field_values_set_type,state_data,err,error,*999)
2536 IF(
ASSOCIATED(parameters_field))
CALL field_parameter_set_data_restore(parameters_field, &
2537 & field_u_variable_type,field_values_set_type,parameters_data,err,error,*999)
2538 IF(
ASSOCIATED(intermediate_field))
CALL field_parameter_set_data_restore(intermediate_field, &
2539 & field_u_variable_type,field_values_set_type,intermediate_data,err,error,*999)
2545 local_error=
"The CellML models field is not associated for CellML index "// &
2547 CALL flagerror(local_error,err,error,*999)
2550 local_error=
"The CellML models field is not associated for CellML index "// &
2552 CALL flagerror(local_error,err,error,*999)
2555 local_error=
"The CellML enviroment is not associated for for CellML index "// &
2557 CALL flagerror(local_error,err,error,*999)
2561 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
2564 CALL flagerror(
"Solver is not associated.",err,error,*999)
2567 CALL flagerror(
"Differential-algebraic equation solver is not associated.",err,error,*999)
2570 CALL flagerror(
"Euler differential-algebraic equation solver is not associated.",err,error,*999)
2573 CALL flagerror(
"Forward Euler differential-algebraic equation solver is not associated.",err,error,*999)
2576 exits(
"SOLVER_DAE_EULER_FORWARD_SOLVE")
2578 999 errorsexits(
"SOLVER_DAE_EULER_FORWARD_SOLVE",err,error)
2592 INTEGER(INTG),
INTENT(OUT) :: ERR
2596 enters(
"SOLVER_DAE_EULER_IMPROVED_FINALISE",err,error,*999)
2598 IF(
ASSOCIATED(improved_euler_solver))
THEN 2599 DEALLOCATE(improved_euler_solver)
2602 exits(
"SOLVER_DAE_EULER_IMPROVED_FINALISE")
2604 999 errorsexits(
"SOLVER_DAE_EULER_IMPROVED_FINALISE",err,error)
2618 INTEGER(INTG),
INTENT(OUT) :: ERR
2621 INTEGER(INTG) :: DUMMY_ERR
2624 enters(
"SOLVER_DAE_EULER_IMPROVED_INITIALISE",err,error,*998)
2626 IF(
ASSOCIATED(euler_dae_solver))
THEN 2627 IF(
ASSOCIATED(euler_dae_solver%IMPROVED_EULER_SOLVER))
THEN 2628 CALL flagerror(
"Improved Euler solver is already associated for this Euler differential-algebraic equation solver.", &
2632 ALLOCATE(euler_dae_solver%IMPROVED_EULER_SOLVER,stat=err)
2633 IF(err/=0)
CALL flagerror(
"Could not allocate improved Euler solver.",err,error,*999)
2635 euler_dae_solver%IMPROVED_EULER_SOLVER%EULER_DAE_SOLVER=>euler_dae_solver
2636 euler_dae_solver%IMPROVED_EULER_SOLVER%SOLVER_LIBRARY=0
2640 CALL flagerror(
"Euler differential-algebraic equation solver is not associated.",err,error,*998)
2643 exits(
"SOLVER_DAE_EULER_IMPROVED_INITIALISE")
2646 998 errorsexits(
"SOLVER_DAE_EULER_IMPROVED_INITIALISE",err,error)
2660 INTEGER(INTG),
INTENT(OUT) :: ERR
2664 enters(
"SOLVER_DAE_EULER_IMPROVED_SOLVE",err,error,*999)
2666 IF(
ASSOCIATED(improved_euler_solver))
THEN 2667 CALL flagerror(
"Not implemented.",err,error,*999)
2669 CALL flagerror(
"Improved Euler differential-algebraic equation solver is not associated.",err,error,*999)
2672 exits(
"SOLVER_DAE_EULER_IMPROVED_SOLVE")
2674 999 errorsexits(
"SOLVER_DAE_EULER_IMPROVED_SOLVE",err,error)
2688 INTEGER(INTG),
INTENT(OUT) :: ERR
2691 INTEGER(INTG) :: DUMMY_ERR
2694 enters(
"SOLVER_DAE_EULER_INITIALISE",err,error,*998)
2696 IF(
ASSOCIATED(dae_solver))
THEN 2697 IF(
ASSOCIATED(dae_solver%EULER_SOLVER))
THEN 2698 CALL flagerror(
"Euler solver is already associated for this differential-algebraic equation solver.",err,error,*998)
2701 ALLOCATE(dae_solver%EULER_SOLVER,stat=err)
2702 IF(err/=0)
CALL flagerror(
"Could not allocate Euler solver.",err,error,*999)
2704 dae_solver%EULER_SOLVER%DAE_SOLVER=>dae_solver
2705 NULLIFY(dae_solver%EULER_SOLVER%FORWARD_EULER_SOLVER)
2706 NULLIFY(dae_solver%EULER_SOLVER%BACKWARD_EULER_SOLVER)
2707 NULLIFY(dae_solver%EULER_SOLVER%IMPROVED_EULER_SOLVER)
2713 CALL flagerror(
"Differential-algebraic equation solver is not associated.",err,error,*998)
2716 exits(
"SOLVER_DAE_EULER_INITIALISE")
2719 998 errorsexits(
"SOLVER_DAE_EULER_INITIALISE",err,error)
2733 INTEGER(INTG),
INTENT(OUT) :: SOLVER_LIBRARY_TYPE
2734 INTEGER(INTG),
INTENT(OUT) :: ERR
2742 enters(
"SOLVER_DAE_EULER_LIBRARY_TYPE_GET",err,error,*999)
2744 IF(
ASSOCIATED(euler_dae_solver))
THEN 2745 SELECT CASE(euler_dae_solver%EULER_TYPE)
2747 forward_euler_dae_solver=>euler_dae_solver%FORWARD_EULER_SOLVER
2748 IF(
ASSOCIATED(forward_euler_dae_solver))
THEN 2749 solver_library_type=forward_euler_dae_solver%SOLVER_LIBRARY
2751 CALL flagerror(
"The forward Euler differntial-algebraic equations solver is not associated.",err,error,*999)
2754 backward_euler_dae_solver=>euler_dae_solver%BACKWARD_EULER_SOLVER
2755 IF(
ASSOCIATED(backward_euler_dae_solver))
THEN 2756 solver_library_type=backward_euler_dae_solver%SOLVER_LIBRARY
2758 CALL flagerror(
"The backward Euler differntial-algebraic equations solver is not associated.",err,error,*999)
2761 improved_euler_dae_solver=>euler_dae_solver%IMPROVED_EULER_SOLVER
2762 IF(
ASSOCIATED(improved_euler_dae_solver))
THEN 2763 solver_library_type=improved_euler_dae_solver%SOLVER_LIBRARY
2765 CALL flagerror(
"The improved Euler differntial-algebraic equations solver is not associated.",err,error,*999)
2768 local_error=
"The Euler differential-algebraic equations solver type of "// &
2770 CALL flagerror(local_error,err,error,*999)
2773 CALL flagerror(
"Euler DAE solver is not associated.",err,error,*999)
2776 exits(
"SOLVER_DAE_EULER_LIBRARY_TYPE_GET")
2778 999 errorsexits(
"SOLVER_DAE_EULER_LIBRARY_TYPE_GET",err,error)
2792 INTEGER(INTG),
INTENT(IN) :: SOLVER_LIBRARY_TYPE
2793 INTEGER(INTG),
INTENT(OUT) :: ERR
2801 enters(
"SOLVER_DAE_EULER_LIBRARY_TYPE_SET",err,error,*999)
2803 IF(
ASSOCIATED(euler_dae_solver))
THEN 2804 SELECT CASE(euler_dae_solver%EULER_TYPE)
2806 forward_euler_dae_solver=>euler_dae_solver%FORWARD_EULER_SOLVER
2807 IF(
ASSOCIATED(forward_euler_dae_solver))
THEN 2808 SELECT CASE(solver_library_type)
2810 CALL flagerror(
"Not implemented.",err,error,*999)
2812 CALL flagerror(
"Not implemented.",err,error,*999)
2814 local_error=
"The solver library type of "//
trim(
numbertovstring(solver_library_type,
"*",err,error))// &
2815 &
" is invalid for a forward Euler DAE solver." 2816 CALL flagerror(local_error,err,error,*999)
2819 CALL flagerror(
"The forward Euler differential-algebraic equation solver is not associated.",err,error,*999)
2822 backward_euler_dae_solver=>euler_dae_solver%BACKWARD_EULER_SOLVER
2823 IF(
ASSOCIATED(backward_euler_dae_solver))
THEN 2824 SELECT CASE(solver_library_type)
2826 CALL flagerror(
"Not implemented.",err,error,*999)
2828 CALL flagerror(
"Not implemented.",err,error,*999)
2830 local_error=
"The solver library type of "//
trim(
numbertovstring(solver_library_type,
"*",err,error))// &
2831 &
" is invalid for a backward Euler DAE solver." 2832 CALL flagerror(local_error,err,error,*999)
2835 CALL flagerror(
"The backward Euler differential-algebraic equation solver is not associated.",err,error,*999)
2838 improved_euler_dae_solver=>euler_dae_solver%IMPROVED_EULER_SOLVER
2839 IF(
ASSOCIATED(improved_euler_dae_solver))
THEN 2840 SELECT CASE(solver_library_type)
2842 CALL flagerror(
"Not implemented.",err,error,*999)
2844 CALL flagerror(
"Not implemented.",err,error,*999)
2846 local_error=
"The solver library type of "//
trim(
numbertovstring(solver_library_type,
"*",err,error))// &
2847 &
" is invalid for an improved Euler DAE solver." 2848 CALL flagerror(local_error,err,error,*999)
2851 CALL flagerror(
"The improved Euler differential-algebraic equation solver is not associated.",err,error,*999)
2854 local_error=
"The Euler differential-algebraic equations solver type of "// &
2856 CALL flagerror(local_error,err,error,*999)
2859 CALL flagerror(
"The Euler differential-algebraic equation solver is not associated.",err,error,*999)
2862 exits(
"SOLVER_DAE_EULER_LIBRARY_TYPE_SET")
2864 999 errorsexits(
"SOLVER_DAE_EULER_LIBRARY_TYPE_SET",err,error)
2878 INTEGER(INTG),
INTENT(OUT) :: ERR
2883 enters(
"SOLVER_DAE_EULER_SOLVE",err,error,*999)
2885 IF(
ASSOCIATED(euler_solver))
THEN 2886 SELECT CASE(euler_solver%EULER_TYPE)
2894 local_error=
"The Euler differential-algebraic equation solver type of "// &
2896 CALL flagerror(local_error,err,error,*999)
2899 CALL flagerror(
"Euler differential-algebraic equation solver is not associated.",err,error,*999)
2902 exits(
"SOLVER_DAE_EULER_SOLVE")
2904 999 errorsexits(
"SOLVER_DAE_EULER_SOLVE",err,error)
2918 INTEGER(INTG),
INTENT(OUT) :: DAE_EULER_TYPE
2919 INTEGER(INTG),
INTENT(OUT) :: ERR
2925 enters(
"SOLVER_DAE_EULER_SOLVER_TYPE_GET",err,error,*999)
2927 IF(
ASSOCIATED(solver))
THEN 2928 IF(solver%SOLVER_FINISHED)
THEN 2930 dae_solver=>solver%DAE_SOLVER
2931 IF(
ASSOCIATED(dae_solver))
THEN 2933 euler_dae_solver=>dae_solver%EULER_SOLVER
2934 IF(
ASSOCIATED(euler_dae_solver))
THEN 2935 dae_euler_type=euler_dae_solver%EULER_TYPE
2937 CALL flagerror(
"The differential-algebraic equation solver Euler solver is not associated.",err,error,*999)
2940 CALL flagerror(
"The solver differential-algebraic equation solver is not an Euler differential-algebraic "// &
2941 &
"equation solver.",err,error,*999)
2944 CALL flagerror(
"The solver differential-algebraic equation solver is not associated.",err,error,*999)
2947 CALL flagerror(
"The solver is not a differential-algebraic equation solver.",err,error,*999)
2950 CALL flagerror(
"Solver has not been finished.",err,error,*999)
2953 CALL flagerror(
"Solver is not associated.",err,error,*999)
2956 exits(
"SOLVER_DAE_EULER_SOLVER_TYPE_GET")
2958 999 errorsexits(
"SOLVER_DAE_EULER_SOLVER_TYPE_GET",err,error)
2972 INTEGER(INTG),
INTENT(IN) :: DAE_EULER_TYPE
2973 INTEGER(INTG),
INTENT(OUT) :: ERR
2980 enters(
"SOLVER_DAE_EULER_SOLVER_TYPE_SET",err,error,*999)
2982 IF(
ASSOCIATED(solver))
THEN 2983 IF(solver%SOLVER_FINISHED)
THEN 2984 CALL flagerror(
"Solver has already been finished.",err,error,*999)
2987 dae_solver=>solver%DAE_SOLVER
2988 IF(
ASSOCIATED(dae_solver))
THEN 2990 euler_dae_solver=>dae_solver%EULER_SOLVER
2991 IF(
ASSOCIATED(euler_dae_solver))
THEN 2992 IF(dae_euler_type/=euler_dae_solver%EULER_TYPE)
THEN 2994 SELECT CASE(dae_euler_type)
3002 local_error=
"The specified Euler differential-algebraic equation solver type of "// &
3004 CALL flagerror(local_error,err,error,*999)
3007 SELECT CASE(euler_dae_solver%EULER_TYPE)
3015 local_error=
"The Euler differential-algebraic equation solver type of "// &
3017 CALL flagerror(local_error,err,error,*999)
3019 euler_dae_solver%EULER_TYPE=dae_euler_type
3022 CALL flagerror(
"The differential-algebraic equation solver Euler solver is not associated.",err,error,*999)
3025 CALL flagerror(
"The solver differential-algebraic equation solver is not an Euler differential-algebraic "// &
3026 &
"equation solver.",err,error,*999)
3029 CALL flagerror(
"The solver differential-algebraic equation solver is not associated.",err,error,*999)
3032 CALL flagerror(
"The solver is not a differential-algebraic equation solver.",err,error,*999)
3036 CALL flagerror(
"Solver is not associated.",err,error,*999)
3039 exits(
"SOLVER_DAE_EULER_SOLVER_TYPE_SET")
3041 999 errorsexits(
"SOLVER_DAE_EULER_SOLVER_TYPE_SET",err,error)
3055 INTEGER(INTG),
INTENT(OUT) :: ERR
3059 enters(
"SOLVER_DAE_FINALISE",err,error,*999)
3061 IF(
ASSOCIATED(dae_solver))
THEN 3069 DEALLOCATE(dae_solver)
3072 exits(
"SOLVER_DAE_FINALISE")
3074 999 errorsexits(
"SOLVER_DAE_FINALISE",err,error)
3088 INTEGER(INTG),
INTENT(OUT) :: ERR
3091 INTEGER(INTG) :: DUMMY_ERR
3094 enters(
"SOLVER_DAE_INITIALISE",err,error,*998)
3096 IF(
ASSOCIATED(solver))
THEN 3097 IF(
ASSOCIATED(solver%DAE_SOLVER))
THEN 3098 CALL flagerror(
"Differential-algebraic equation solver is already associated for this solver.",err,error,*998)
3101 ALLOCATE(solver%DAE_SOLVER,stat=err)
3102 IF(err/=0)
CALL flagerror(
"Could not allocate solver differential-algebraic equation solver.",err,error,*999)
3104 solver%DAE_SOLVER%SOLVER=>solver
3105 solver%DAE_SOLVER%DAE_TYPE=0
3106 solver%DAE_SOLVER%DAE_SOLVE_TYPE=0
3107 solver%DAE_SOLVER%START_TIME=0.0_dp
3108 solver%DAE_SOLVER%END_TIME=0.1_dp
3109 solver%DAE_SOLVER%INITIAL_STEP=0.1_dp
3110 NULLIFY(solver%DAE_SOLVER%EULER_SOLVER)
3111 NULLIFY(solver%DAE_SOLVER%CRANK_NICOLSON_SOLVER)
3112 NULLIFY(solver%DAE_SOLVER%RUNGE_KUTTA_SOLVER)
3113 NULLIFY(solver%DAE_SOLVER%ADAMS_MOULTON_SOLVER)
3114 NULLIFY(solver%DAE_SOLVER%BDF_SOLVER)
3115 NULLIFY(solver%DAE_SOLVER%RUSH_LARSON_SOLVER)
3116 NULLIFY(solver%DAE_SOLVER%EXTERNAL_SOLVER)
3122 CALL flagerror(
"Solver is not associated.",err,error,*998)
3125 exits(
"SOLVER_DAE_INITIALISE")
3128 998 errorsexits(
"SOLVER_DAE_INITIALISE",err,error)
3142 INTEGER(INTG),
INTENT(OUT) :: SOLVER_LIBRARY_TYPE
3143 INTEGER(INTG),
INTENT(OUT) :: ERR
3154 enters(
"SOLVER_DAE_LIBRARY_TYPE_GET",err,error,*999)
3156 IF(
ASSOCIATED(dae_solver))
THEN 3157 SELECT CASE(dae_solver%DAE_SOLVE_TYPE)
3159 euler_dae_solver=>dae_solver%EULER_SOLVER
3160 IF(
ASSOCIATED(euler_dae_solver))
THEN 3163 CALL flagerror(
"Euler differential-algebraic solver is not associated.",err,error,*999)
3166 crank_nicolson_dae_solver=>dae_solver%CRANK_NICOLSON_SOLVER
3167 IF(
ASSOCIATED(crank_nicolson_dae_solver))
THEN 3168 solver_library_type=crank_nicolson_dae_solver%SOLVER_LIBRARY
3170 CALL flagerror(
"The Crank-Nicolson differntial-algebraic equations solver is not associated.",err,error,*999)
3173 runge_kutta_dae_solver=>dae_solver%RUNGE_KUTTA_SOLVER
3174 IF(
ASSOCIATED(runge_kutta_dae_solver))
THEN 3175 solver_library_type=runge_kutta_dae_solver%SOLVER_LIBRARY
3177 CALL flagerror(
"The Runge-Kutta differntial-algebraic equations solver is not associated.",err,error,*999)
3180 adams_moulton_dae_solver=>dae_solver%ADAMS_MOULTON_SOLVER
3181 IF(
ASSOCIATED(adams_moulton_dae_solver))
THEN 3182 solver_library_type=adams_moulton_dae_solver%SOLVER_LIBRARY
3184 CALL flagerror(
"The Adams-Moulton differntial-algebraic equations solver is not associated.",err,error,*999)
3187 bdf_dae_solver=>dae_solver%BDF_SOLVER
3188 IF(
ASSOCIATED(bdf_dae_solver))
THEN 3189 solver_library_type=bdf_dae_solver%SOLVER_LIBRARY
3191 CALL flagerror(
"The BDF differntial-algebraic equations solver is not associated.",err,error,*999)
3194 rush_larson_dae_solver=>dae_solver%RUSH_LARSON_SOLVER
3195 IF(
ASSOCIATED(rush_larson_dae_solver))
THEN 3196 solver_library_type=rush_larson_dae_solver%SOLVER_LIBRARY
3198 CALL flagerror(
"The Rush-Larson differntial-algebraic equations solver is not associated.",err,error,*999)
3201 CALL flagerror(
"Can not get the solver library for an external differntial-algebraic equations solver.",err,error,*999)
3203 local_error=
"The differential-algebraic equations solver type of "// &
3205 CALL flagerror(local_error,err,error,*999)
3208 CALL flagerror(
"DAE solver is not associated.",err,error,*999)
3211 exits(
"SOLVER_DAE_LIBRARY_TYPE_GET")
3213 999 errorsexits(
"SOLVER_DAE_LIBRARY_TYPE_GET",err,error)
3227 INTEGER(INTG),
INTENT(IN) :: SOLVER_LIBRARY_TYPE
3228 INTEGER(INTG),
INTENT(OUT) :: ERR
3242 enters(
"SOLVER_DAE_LIBRARY_TYPE_SET",err,error,*999)
3244 IF(
ASSOCIATED(dae_solver))
THEN 3245 SELECT CASE(dae_solver%DAE_SOLVE_TYPE)
3247 euler_dae_solver=>dae_solver%EULER_SOLVER
3248 IF(
ASSOCIATED(euler_dae_solver))
THEN 3249 SELECT CASE(euler_dae_solver%EULER_TYPE)
3251 forward_euler_dae_solver=>euler_dae_solver%FORWARD_EULER_SOLVER
3252 IF(
ASSOCIATED(forward_euler_dae_solver))
THEN 3253 SELECT CASE(solver_library_type)
3257 CALL flagerror(
"Not implemented.",err,error,*999)
3259 local_error=
"The solver library type of "//
trim(
numbertovstring(solver_library_type,
"*",err,error))// &
3261 CALL flagerror(local_error,err,error,*999)
3264 CALL flagerror(
"The forward Euler differential-algebraic equation solver is not associated.",err,error,*999)
3267 backward_euler_dae_solver=>euler_dae_solver%BACKWARD_EULER_SOLVER
3268 IF(
ASSOCIATED(backward_euler_dae_solver))
THEN 3269 SELECT CASE(solver_library_type)
3271 CALL flagerror(
"Not implemented.",err,error,*999)
3273 CALL flagerror(
"Not implemented.",err,error,*999)
3275 local_error=
"The solver library type of "//
trim(
numbertovstring(solver_library_type,
"*",err,error))// &
3277 CALL flagerror(local_error,err,error,*999)
3280 CALL flagerror(
"The backward Euler differential-algebraic equation solver is not associated.",err,error,*999)
3283 improved_euler_dae_solver=>euler_dae_solver%IMPROVED_EULER_SOLVER
3284 IF(
ASSOCIATED(improved_euler_dae_solver))
THEN 3285 SELECT CASE(solver_library_type)
3287 CALL flagerror(
"Not implemented.",err,error,*999)
3289 CALL flagerror(
"Not implemented.",err,error,*999)
3291 local_error=
"The solver library type of "//
trim(
numbertovstring(solver_library_type,
"*",err,error))// &
3293 CALL flagerror(local_error,err,error,*999)
3296 CALL flagerror(
"The improved Euler differential-algebraic equation solver is not associated.",err,error,*999)
3299 local_error=
"The Euler differential-algebraic equations solver type of "// &
3301 CALL flagerror(local_error,err,error,*999)
3304 CALL flagerror(
"The Euler differential-algebraic equation solver is not associated.",err,error,*999)
3307 crank_nicolson_dae_solver=>dae_solver%CRANK_NICOLSON_SOLVER
3308 IF(
ASSOCIATED(crank_nicolson_dae_solver))
THEN 3309 SELECT CASE(solver_library_type)
3311 CALL flagerror(
"Not implemented.",err,error,*999)
3313 CALL flagerror(
"Not implemented.",err,error,*999)
3315 local_error=
"The solver library type of "//
trim(
numbertovstring(solver_library_type,
"*",err,error))// &
3317 CALL flagerror(local_error,err,error,*999)
3320 CALL flagerror(
"The Crank-Nicolson differential-algebraic equation solver is not associated.",err,error,*999)
3323 runge_kutta_dae_solver=>dae_solver%RUNGE_KUTTA_SOLVER
3324 IF(
ASSOCIATED(runge_kutta_dae_solver))
THEN 3325 SELECT CASE(solver_library_type)
3327 CALL flagerror(
"Not implemented.",err,error,*999)
3329 CALL flagerror(
"Not implemented.",err,error,*999)
3331 local_error=
"The solver library type of "//
trim(
numbertovstring(solver_library_type,
"*",err,error))// &
3333 CALL flagerror(local_error,err,error,*999)
3336 CALL flagerror(
"The Runge-Kutta differential-algebraic equation solver is not associated.",err,error,*999)
3339 adams_moulton_dae_solver=>dae_solver%ADAMS_MOULTON_SOLVER
3340 IF(
ASSOCIATED(adams_moulton_dae_solver))
THEN 3341 SELECT CASE(solver_library_type)
3343 CALL flagerror(
"Not implemented.",err,error,*999)
3345 CALL flagerror(
"Not implemented.",err,error,*999)
3347 local_error=
"The solver library type of "//
trim(
numbertovstring(solver_library_type,
"*",err,error))// &
3349 CALL flagerror(local_error,err,error,*999)
3352 CALL flagerror(
"The Adams-Moulton differential-algebraic equation solver is not associated.",err,error,*999)
3355 bdf_dae_solver=>dae_solver%BDF_SOLVER
3356 IF(
ASSOCIATED(bdf_dae_solver))
THEN 3357 SELECT CASE(solver_library_type)
3359 CALL flagerror(
"Not implemented.",err,error,*999)
3363 local_error=
"The solver library type of "//
trim(
numbertovstring(solver_library_type,
"*",err,error))// &
3365 CALL flagerror(local_error,err,error,*999)
3368 CALL flagerror(
"The BDF differential-algebraic equation solver is not associated.",err,error,*999)
3371 rush_larson_dae_solver=>dae_solver%RUSH_LARSON_SOLVER
3372 IF(
ASSOCIATED(rush_larson_dae_solver))
THEN 3373 SELECT CASE(solver_library_type)
3375 CALL flagerror(
"Not implemented.",err,error,*999)
3377 CALL flagerror(
"Not implemented.",err,error,*999)
3379 local_error=
"The solver library type of "//
trim(
numbertovstring(solver_library_type,
"*",err,error))// &
3381 CALL flagerror(local_error,err,error,*999)
3384 CALL flagerror(
"The Rush-Larson differential-algebraic equation solver is not associated.",err,error,*999)
3387 CALL flagerror(
"Can not set the library type for an external differential-algebraic equation solver is not associated.", &
3390 local_error=
"The differential-algebraic equations solver type of "// &
3392 CALL flagerror(local_error,err,error,*999)
3395 CALL flagerror(
"DAE solver is not associated.",err,error,*999)
3398 exits(
"SOLVER_DAE_LIBRARY_TYPE_SET")
3400 999 errorsexits(
"SOLVER_DAE_LIBRARY_TYPE_SET",err,error)
3414 INTEGER(INTG),
INTENT(OUT) :: ERR
3418 enters(
"SOLVER_DAE_BDF_FINALISE",err,error,*999)
3420 IF(
ASSOCIATED(bdf_solver))
THEN 3421 DEALLOCATE(bdf_solver)
3424 exits(
"SOLVER_DAE_BDF_FINALISE")
3426 999 errorsexits(
"SOLVER_DAE_BDF_FINALISE",err,error)
3440 INTEGER(INTG),
INTENT(OUT) :: ERR
3443 INTEGER(INTG) :: DUMMY_ERR
3446 enters(
"SOLVER_DAE_BDF_INITIALISE",err,error,*998)
3448 IF(
ASSOCIATED(dae_solver))
THEN 3449 IF(
ASSOCIATED(dae_solver%BDF_SOLVER))
THEN 3450 CALL flagerror(
"BDF solver is already associated for this differential-algebraic equation solver.",err,error,*998)
3453 ALLOCATE(dae_solver%BDF_SOLVER,stat=err)
3454 IF(err/=0)
CALL flagerror(
"Could not allocate BDF solver.",err,error,*999)
3456 dae_solver%BDF_SOLVER%DAE_SOLVER=>dae_solver
3461 CALL flagerror(
"Differential-algebraic equation solver is not associated.",err,error,*998)
3464 exits(
"SOLVER_DAE_BDF_INITIALISE")
3467 998 errorsexits(
"SOLVER_DAE_BDF_INITIALISE",err,error)
3480 INTEGER(INTG),
INTENT(OUT) :: err
3484 enters(
"Solver_DAECellMLPETScContextFinalise",err,error,*999)
3486 IF(
ASSOCIATED(ctx))
THEN 3487 IF(
ASSOCIATED(ctx%rates))
DEALLOCATE(ctx%rates)
3488 IF(
ALLOCATED(ctx%ratesIndices))
DEALLOCATE(ctx%ratesIndices)
3492 exits(
"Solver_DAECellMLPETScContextFinalise")
3494 999 errorsexits(
"Solver_DAECellMLPETScContextFinalise",err,error)
3509 INTEGER(INTG),
INTENT(OUT) :: err
3512 INTEGER(INTG) :: dummyErr
3515 enters(
"Solver_DAECellMLPETScContextInitialise",err,error,*998)
3517 IF(
ASSOCIATED(ctx))
THEN 3518 CALL flagerror(
"Context is already associated.",err,error,*998)
3521 ALLOCATE(ctx,stat=err)
3522 IF(err/=0)
CALL flagerror(
"Could not allocate context.",err,error,*999)
3530 exits(
"Solver_DAECellMLPETScContextInitialise")
3533 998 errorsexits(
"Solver_DAECellMLPETScContextInitialise",err,error)
3548 INTEGER(INTG),
INTENT(IN) :: dofIdx
3549 INTEGER(INTG),
INTENT(OUT) :: err
3552 INTEGER(INTG) :: arrayIdx,dummyErr
3555 enters(
"Solver_DAECellMLPETScContextSet",err,error,*998)
3557 IF(
ASSOCIATED(ctx))
THEN 3558 IF(
ASSOCIATED(solver))
THEN 3559 IF(
ASSOCIATED(cellml))
THEN 3564 ALLOCATE(ctx%rates(cellml%MAXIMUM_NUMBER_OF_STATE),stat=err)
3565 IF(err/=0)
CALL flagerror(
"Could not allocate context rates.",err,error,*999)
3566 ALLOCATE(ctx%ratesIndices(cellml%MAXIMUM_NUMBER_OF_STATE),stat=err)
3567 IF(err/=0)
CALL flagerror(
"Could not allocate context rates.",err,error,*999)
3568 ctx%ratesIndices=[(arrayidx,arrayidx=0,(cellml%MAXIMUM_NUMBER_OF_STATE-1))]
3570 CALL flagerror(
"CellML environment is not associated.",err,error,*999)
3573 CALL flagerror(
"Solver is not associated.",err,error,*998)
3576 CALL flagerror(
"ctx is not associated.",err,error,*998)
3579 exits(
"Solver_DAECellMLPETScContextSet")
3582 998 errorsexits(
"Solver_DAECellMLPETScContextSet",err,error)
3592 & only_one_model_index,models_data,max_number_states,state_data,max_number_parameters,parameters_data, &
3593 & max_number_intermediates,intermediate_data,err,error,*)
3598 INTEGER(INTG),
INTENT(IN) :: N
3599 REAL(DP),
INTENT(IN) :: START_TIME
3600 REAL(DP),
INTENT(IN) :: END_TIME
3601 REAL(DP),
INTENT(INOUT) :: TIME_INCREMENT
3602 INTEGER(INTG),
INTENT(IN) :: ONLY_ONE_MODEL_INDEX
3603 INTEGER(INTG),
POINTER,
INTENT(IN) :: MODELS_DATA(:)
3604 INTEGER(INTG),
INTENT(IN) :: MAX_NUMBER_STATES
3605 REAL(DP),
POINTER,
INTENT (INOUT) :: STATE_DATA(:)
3606 INTEGER(INTG),
INTENT(IN) :: MAX_NUMBER_PARAMETERS
3607 REAL(DP),
POINTER,
INTENT(INOUT) :: PARAMETERS_DATA(:)
3608 INTEGER(INTG),
INTENT(IN) :: MAX_NUMBER_INTERMEDIATES
3609 REAL(DP),
POINTER,
INTENT(INOUT) :: INTERMEDIATE_DATA(:)
3610 INTEGER(INTG),
INTENT(OUT) :: ERR
3614 REAL(DP) :: FINALSOLVEDTIME,TIMESTEP
3617 INTEGER(INTG) :: dof_idx,DOF_ORDER_TYPE,model_idx, NUMBER_STATES,STATE_END_DOF,state_idx,STATE_START_DOF,array_idx
3618 REAL(DP),
ALLOCATABLE :: STATES_TEMP(:),RATES_TEMP(:)
3619 INTEGER(INTG),
ALLOCATABLE :: ARRAY_INDICES(:)
3623 EXTERNAL :: problem_solverdaecellmlrhspetsc
3626 enters(
"SOLVER_DAE_BFD_INTEGRATE",err,error,*999)
3629 timestep=end_time-start_time
3630 IF(
ASSOCIATED(bdf_solver))
THEN 3631 IF(
ASSOCIATED(cellml))
THEN 3632 IF(
ASSOCIATED(cellml%MODELS_FIELD))
THEN 3633 SELECT CASE(bdf_solver%SOLVER_LIBRARY)
3635 CALL field_dof_order_type_get(cellml%MODELS_FIELD%MODELS_FIELD, &
3636 & field_u_variable_type,dof_order_type,err,error,*999)
3637 IF(dof_order_type==field_separated_component_dof_order)
THEN 3643 model=>cellml%MODELS(only_one_model_index)%PTR
3644 IF(
ASSOCIATED(model))
THEN 3646 number_states = model%NUMBER_OF_STATE
3647 ALLOCATE(states_temp(0:number_states-1),stat=err)
3648 ALLOCATE(rates_temp(0:number_states-1),stat=err)
3649 ALLOCATE(array_indices(0:number_states-1),stat=err)
3650 array_indices = (/(array_idx,array_idx=0,(number_states-1))/)
3656 model_idx = models_data(dof_idx)
3657 IF(model_idx>0)
THEN 3659 state_start_dof=(dof_idx-1)*max_number_states+1
3660 state_end_dof=state_start_dof+number_states-1
3661 DO state_idx=1,number_states
3662 states_temp(state_idx-1) = state_data(state_start_dof+state_idx-1)
3667 & number_states,petsc_current_states,err,error,*999)
3674 & number_states,petsc_rates,err,error,*999)
3685 & 0.0000001_dp,err,error,*999)
3688 & array_indices,states_temp, &
3689 & petsc_insert_values,err,error,*999)
3708 CALL petsc_tssolve(ts,petsc_current_states,finalsolvedtime,err,error,*999)
3711 & finalsolvedtime,err,error,*999)
3719 & number_states, array_indices, &
3723 DO state_idx=1,number_states
3724 state_data(state_start_dof+state_idx-1)= &
3725 & states_temp(state_idx-1)
3734 CALL flagerror(
"Cellml model is not associated.",err,error,*999)
3739 local_error=
"The BDF solver library type of "// &
3741 CALL flagerror(local_error,err,error,*999)
3744 CALL flagerror(
"CELLML models field is not associated.",err,error,*999)
3747 CALL flagerror(
"CELLML environment is not associated.",err,error,*999)
3750 CALL flagerror(
"BDF solver is not associated.",err,error,*999)
3753 exits(
"SOLVER_DAE_BDF_INTEGRATE")
3755 999 errorsexits(
"SOLVER_DAE_BDF_INTEGRATE",err,error)
3768 INTEGER(INTG),
INTENT(OUT) :: ERR
3771 INTEGER(INTG) :: cellml_idx
3772 INTEGER(INTG),
POINTER :: MODELS_DATA(:)
3773 REAL(DP),
POINTER :: INTERMEDIATE_DATA(:),PARAMETERS_DATA(:),STATE_DATA(:)
3779 TYPE(
field_type),
POINTER :: MODELS_FIELD,STATE_FIELD,PARAMETERS_FIELD,INTERMEDIATE_FIELD
3783 enters(
"SOLVER_DAE_BDF_SOLVE",err,error,*999)
3785 NULLIFY(models_data)
3786 NULLIFY(intermediate_data)
3787 NULLIFY(parameters_data)
3789 NULLIFY(models_variable)
3791 IF(
ASSOCIATED(bdf_solver))
THEN 3792 dae_solver=>bdf_solver%DAE_SOLVER
3793 IF(
ASSOCIATED(dae_solver))
THEN 3794 solver=>dae_solver%SOLVER
3795 IF(
ASSOCIATED(solver))
THEN 3796 cellml_equations=>solver%CELLML_EQUATIONS
3797 IF(
ASSOCIATED(cellml_equations))
THEN 3798 DO cellml_idx=1,cellml_equations%NUMBER_OF_CELLML_ENVIRONMENTS
3799 cellml_environment=>cellml_equations%CELLML_ENVIRONMENTS(cellml_idx)%PTR
3800 IF(
ASSOCIATED(cellml_environment))
THEN 3801 cellml_models_field=>cellml_environment%MODELS_FIELD
3802 IF(
ASSOCIATED(cellml_models_field))
THEN 3803 models_field=>cellml_models_field%MODELS_FIELD
3804 IF(
ASSOCIATED(models_field))
THEN 3811 CALL field_variable_get(models_field,field_u_variable_type,models_variable,err,error,*999)
3812 CALL field_parameter_set_data_get(models_field,field_u_variable_type,field_values_set_type, &
3813 & models_data,err,error,*999)
3816 IF(
ASSOCIATED(cellml_environment%STATE_FIELD))
THEN 3817 state_field=>cellml_environment%STATE_FIELD%STATE_FIELD
3818 IF(
ASSOCIATED(state_field))
THEN 3819 CALL field_parameter_set_data_get(state_field,field_u_variable_type,field_values_set_type, &
3820 & state_data,err,error,*999)
3825 IF(
ASSOCIATED(cellml_environment%PARAMETERS_FIELD))
THEN 3826 parameters_field=>cellml_environment%PARAMETERS_FIELD%PARAMETERS_FIELD
3827 IF(
ASSOCIATED(parameters_field))
THEN 3828 CALL field_parameter_set_data_get(parameters_field,field_u_variable_type,field_values_set_type, &
3829 & parameters_data,err,error,*999)
3834 IF(
ASSOCIATED(cellml_environment%INTERMEDIATE_FIELD))
THEN 3835 intermediate_field=>cellml_environment%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD
3836 IF(
ASSOCIATED(intermediate_field))
THEN 3837 CALL field_parameter_set_data_get(intermediate_field,field_u_variable_type,field_values_set_type, &
3838 & intermediate_data,err,error,*999)
3845 & total_number_of_dofs,dae_solver%START_TIME,dae_solver%END_TIME,dae_solver%INITIAL_STEP, &
3846 & cellml_environment%MODELS_FIELD%ONLY_ONE_MODEL_INDEX,models_data,cellml_environment% &
3847 & maximum_number_of_state,state_data,cellml_environment%MAXIMUM_NUMBER_OF_PARAMETERS, &
3848 & parameters_data,cellml_environment%MAXIMUM_NUMBER_OF_INTERMEDIATE,intermediate_data,err,error,*999)
3851 CALL field_parameter_set_data_restore(models_field,field_u_variable_type,field_values_set_type, &
3852 & models_data,err,error,*999)
3853 IF(
ASSOCIATED(state_field))
CALL field_parameter_set_data_restore(state_field,field_u_variable_type, &
3854 & field_values_set_type,state_data,err,error,*999)
3855 IF(
ASSOCIATED(parameters_field))
CALL field_parameter_set_data_restore(parameters_field, &
3856 & field_u_variable_type,field_values_set_type,parameters_data,err,error,*999)
3857 IF(
ASSOCIATED(intermediate_field))
CALL field_parameter_set_data_restore(intermediate_field, &
3858 & field_u_variable_type,field_values_set_type,intermediate_data,err,error,*999)
3864 local_error=
"The CellML models field is not associated for CellML index "// &
3866 CALL flagerror(local_error,err,error,*999)
3869 local_error=
"The CellML models field is not associated for CellML index "// &
3871 CALL flagerror(local_error,err,error,*999)
3874 local_error=
"The CellML enviroment is not associated for for CellML index "// &
3876 CALL flagerror(local_error,err,error,*999)
3880 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
3883 CALL flagerror(
"Solver is not associated.",err,error,*999)
3886 CALL flagerror(
"Differential-algebraic equation solver is not associated.",err,error,*999)
3889 CALL flagerror(
"BDF differential-algebraic equation solver is not associated.",err,error,*999)
3892 exits(
"SOLVER_DAE_BDF_SOLVE")
3894 999 errorsexits(
"SOLVER_DAE_BDF_SOLVE",err,error)
3908 INTEGER(INTG),
INTENT(OUT) :: ERR
3912 enters(
"SOLVER_DAE_CRANK_NICOLSON_FINALISE",err,error,*999)
3914 IF(
ASSOCIATED(crank_nicolson_solver))
THEN 3915 DEALLOCATE(crank_nicolson_solver)
3918 exits(
"SOLVER_DAE_CRANK_NICOLSON_FINALISE")
3920 999 errorsexits(
"SOLVER_DAE_CRANK_NICOLSON_FINALISE",err,error)
3934 INTEGER(INTG),
INTENT(OUT) :: ERR
3937 INTEGER(INTG) :: DUMMY_ERR
3940 enters(
"SOLVER_DAE_CRANK_NICOLSON_INITIALISE",err,error,*998)
3942 IF(
ASSOCIATED(dae_solver))
THEN 3943 IF(
ASSOCIATED(dae_solver%CRANK_NICOLSON_SOLVER))
THEN 3944 CALL flagerror(
"Crank-Nicolson solver is already associated for this differential-algebraic equation solver.", &
3948 ALLOCATE(dae_solver%CRANK_NICOLSON_SOLVER,stat=err)
3949 IF(err/=0)
CALL flagerror(
"Could not allocate Crank-Nicolson solver.",err,error,*999)
3951 dae_solver%CRANK_NICOLSON_SOLVER%DAE_SOLVER=>dae_solver
3952 dae_solver%CRANK_NICOLSON_SOLVER%SOLVER_LIBRARY=0
3956 CALL flagerror(
"Differential-algebraic equation solver is not associated.",err,error,*998)
3959 exits(
"SOLVER_DAE_CRANK_NICOLSON_INITIALISE")
3962 998 errorsexits(
"SOLVER_DAE_CRANK_NICOLSON_INITIALISE",err,error)
3976 INTEGER(INTG),
INTENT(OUT) :: ERR
3980 enters(
"SOLVER_DAE_CRANK_NICOLSON_SOLVE",err,error,*999)
3982 IF(
ASSOCIATED(crank_nicolson_solver))
THEN 3983 CALL flagerror(
"Not implemented.",err,error,*999)
3985 CALL flagerror(
"Crank-Nicolson differential-algebraic equation solver is not associated.",err,error,*999)
3988 exits(
"SOLVER_DAE_CRANK_NICOLSON_SOLVE")
3990 999 errorsexits(
"SOLVER_DAE_CRANK_NICOLSON_SOLVE",err,error)
4004 INTEGER(INTG),
INTENT(OUT) :: ERR
4008 enters(
"SOLVER_DAE_EXTERNAL_FINALISE",err,error,*999)
4010 IF(
ASSOCIATED(external_solver))
THEN 4011 DEALLOCATE(external_solver)
4014 exits(
"SOLVER_DAE_CRANK_NICOLSON_FINALISE")
4016 999 errorsexits(
"SOLVER_DAE_CRANK_NICOLSON_FINALISE",err,error)
4030 INTEGER(INTG),
INTENT(OUT) :: ERR
4033 INTEGER(INTG) :: DUMMY_ERR
4036 enters(
"SOLVER_DAE_EXTERNAL_INITIALISE",err,error,*998)
4038 IF(
ASSOCIATED(dae_solver))
THEN 4039 IF(
ASSOCIATED(dae_solver%EXTERNAL_SOLVER))
THEN 4040 CALL flagerror(
"External solver is already associated for this differential-algebraic equation solver.", &
4044 ALLOCATE(dae_solver%EXTERNAL_SOLVER,stat=err)
4045 IF(err/=0)
CALL flagerror(
"Could not allocate external solver.",err,error,*999)
4047 dae_solver%EXTERNAL_SOLVER%DAE_SOLVER=>dae_solver
4051 CALL flagerror(
"Differential-algebraic equation solver is not associated.",err,error,*998)
4054 exits(
"SOLVER_DAE_EXTERNAL_INITIALISE")
4057 998 errorsexits(
"SOLVER_DAE_EXTERNAL_INITIALISE",err,error)
4071 INTEGER(INTG),
INTENT(OUT) :: ERR
4074 INTEGER(INTG) :: cellml_idx
4075 INTEGER(INTG),
POINTER :: MODELS_DATA(:)
4076 REAL(DP),
POINTER :: INTERMEDIATE_DATA(:),PARAMETERS_DATA(:),STATE_DATA(:)
4081 TYPE(
field_type),
POINTER :: MODELS_FIELD,STATE_FIELD,PARAMETERS_FIELD,INTERMEDIATE_FIELD
4085 enters(
"SOLVER_DAE_EXTERNAL_SOLVE",err,error,*999)
4087 NULLIFY(models_data)
4088 NULLIFY(intermediate_data)
4089 NULLIFY(parameters_data)
4092 IF(
ASSOCIATED(external_solver))
THEN 4093 dae_solver=>external_solver%DAE_SOLVER
4094 IF(
ASSOCIATED(dae_solver))
THEN 4095 solver=>dae_solver%SOLVER
4096 IF(
ASSOCIATED(solver))
THEN 4097 cellml_equations=>solver%CELLML_EQUATIONS
4098 IF(
ASSOCIATED(cellml_equations))
THEN 4099 DO cellml_idx=1,cellml_equations%NUMBER_OF_CELLML_ENVIRONMENTS
4100 cellml_environment=>cellml_equations%CELLML_ENVIRONMENTS(cellml_idx)%PTR
4101 IF(
ASSOCIATED(cellml_environment))
THEN 4102 IF(
ASSOCIATED(cellml_environment%MODELS_FIELD))
THEN 4103 models_field=>cellml_environment%MODELS_FIELD%MODELS_FIELD
4104 IF(
ASSOCIATED(models_field))
THEN 4109 NULLIFY(models_variable)
4110 CALL field_variable_get(models_field,field_u_variable_type,models_variable,err,error,*999)
4111 CALL field_parameter_set_data_get(models_field,field_u_variable_type,field_values_set_type, &
4112 & models_data,err,error,*999)
4115 IF(
ASSOCIATED(cellml_environment%STATE_FIELD))
THEN 4116 state_field=>cellml_environment%STATE_FIELD%STATE_FIELD
4117 IF(
ASSOCIATED(state_field))
THEN 4118 CALL field_parameter_set_data_get(state_field,field_u_variable_type,field_values_set_type, &
4119 & state_data,err,error,*999)
4128 IF(
ASSOCIATED(cellml_environment%PARAMETERS_FIELD))
THEN 4129 parameters_field=>cellml_environment%PARAMETERS_FIELD%PARAMETERS_FIELD
4130 IF(
ASSOCIATED(parameters_field))
THEN 4131 CALL field_parameter_set_data_get(parameters_field,field_u_variable_type,field_values_set_type, &
4132 & parameters_data,err,error,*999)
4134 NULLIFY(parameters_data)
4137 NULLIFY(parameters_data)
4141 IF(
ASSOCIATED(cellml_environment%INTERMEDIATE_FIELD))
THEN 4142 intermediate_field=>cellml_environment%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD
4143 IF(
ASSOCIATED(intermediate_field))
THEN 4144 CALL field_parameter_set_data_get(intermediate_field,field_u_variable_type,field_values_set_type, &
4145 & intermediate_data,err,error,*999)
4147 NULLIFY(intermediate_data)
4150 NULLIFY(intermediate_data)
4154 CALL solver_dae_external_integrate(models_variable%TOTAL_NUMBER_OF_DOFS,dae_solver%START_TIME, &
4155 & dae_solver%END_TIME,dae_solver%INITIAL_STEP,cellml_environment%MODELS_FIELD% &
4156 & only_one_model_index,models_data,cellml_environment%MAXIMUM_NUMBER_OF_STATE,state_data, &
4157 & cellml_environment%MAXIMUM_NUMBER_OF_PARAMETERS,parameters_data,cellml_environment% &
4158 & maximum_number_of_intermediate,intermediate_data,err)
4160 error=
"Error from external solver integrate." 4165 CALL field_parameter_set_data_restore(models_field,field_u_variable_type,field_values_set_type, &
4166 & models_data,err,error,*999)
4167 IF(
ASSOCIATED(state_field))
CALL field_parameter_set_data_restore(state_field,field_u_variable_type, &
4168 & field_values_set_type,state_data,err,error,*999)
4169 IF(
ASSOCIATED(parameters_field))
CALL field_parameter_set_data_restore(parameters_field, &
4170 & field_u_variable_type,field_values_set_type,parameters_data,err,error,*999)
4171 IF(
ASSOCIATED(intermediate_field))
CALL field_parameter_set_data_restore(intermediate_field, &
4172 & field_u_variable_type,field_values_set_type,intermediate_data,err,error,*999)
4178 local_error=
"The CellML models field is not associated for CellML index "// &
4180 CALL flagerror(local_error,err,error,*999)
4183 local_error=
"The CellML models field is not associated for CellML index "// &
4185 CALL flagerror(local_error,err,error,*999)
4188 local_error=
"The CellML enviroment is not associated for for CellML index "// &
4190 CALL flagerror(local_error,err,error,*999)
4194 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
4197 CALL flagerror(
"Solver is not associated.",err,error,*999)
4200 CALL flagerror(
"Differential-algebraic equation solver is not associated.",err,error,*999)
4203 CALL flagerror(
"External Euler differential-algebraic equation solver is not associated.",err,error,*999)
4206 exits(
"SOLVER_DAE_EXTERNAL_SOLVE")
4208 999 errorsexits(
"SOLVER_DAE_EXTERNAL_SOLVE",err,error)
4218 SUBROUTINE solver_daecellmlrhsevaluate(model,time,stateStartIdx,stateDataOffset,stateData,parameterStartIdx,parameterDataOffset, &
4219 & parameterdata,intermediatestartidx,intermediatedataoffset,intermediatedata,ratestartidx,ratedataoffset,ratedata,err,error,*)
4223 REAL(DP),
INTENT(IN) :: time
4224 INTEGER(INTG),
INTENT(IN) :: stateStartIdx
4225 INTEGER(INTG),
INTENT(IN) :: stateDataOffset
4226 REAL(DP),
POINTER :: stateData(:)
4227 INTEGER(INTG),
INTENT(IN) :: parameterStartIdx
4228 INTEGER(INTG),
INTENT(IN) :: parameterDataOffset
4229 REAL(DP),
POINTER :: parameterData(:)
4230 INTEGER(INTG),
INTENT(IN) :: intermediateStartIdx
4231 INTEGER(INTG),
INTENT(IN) :: intermediateDataOffset
4232 REAL(DP),
POINTER :: intermediateData(:)
4233 INTEGER(INTG),
INTENT(IN) :: rateStartIdx
4234 INTEGER(INTG),
INTENT(IN) :: rateDataOffset
4235 REAL(DP),
POINTER :: rateData(:)
4236 INTEGER(INTG),
INTENT(OUT) :: err
4239 INTEGER(INTG) :: intermediateIdx,intermediateEndDOF,intermediateStartDOF,numberOfIntermediates,numberOfParameters, &
4240 & numberOfStates,parameterIdx,parameterEndDOF,parameterStartDOF,rateIdx,rateEndDOF,rateStartDOF,stateIdx,stateEndDOF, &
4242 REAL(DP) :: intermediates(max(1,intermediatedataoffset)),parameters(max(1,parameterdataoffset)),rates(max(1,ratedataoffset)), &
4243 & states(MAX(1,stateDataOffset))
4245 enters(
"Solver_DAECellMLRHSEvaluate",err,error,*999)
4249 IF(
ASSOCIATED(model))
THEN 4250 numberofstates=model%NUMBER_OF_STATE
4251 numberofintermediates=model%NUMBER_OF_INTERMEDIATE
4252 numberofparameters=model%NUMBER_OF_PARAMETERS
4253 IF(numberofstates>0)
THEN 4254 IF(.NOT.
ASSOCIATED(statedata))
CALL flagerror(
"State data is not associated.",err,error,*999)
4255 IF(.NOT.
ASSOCIATED(ratedata))
CALL flagerror(
"Rate data is not associated.",err,error,*999)
4257 IF(numberofparameters>0)
THEN 4258 IF(.NOT.
ASSOCIATED(parameterdata))
CALL flagerror(
"Parameter data is not associated.",err,error,*999)
4260 IF(numberofintermediates>0)
THEN 4261 IF(.NOT.
ASSOCIATED(intermediatedata))
CALL flagerror(
"Intermediate data is not associated.",err,error,*999)
4263 IF(statedataoffset>1.OR.numberofstates==0)
THEN 4267 DO stateidx=1,numberofstates
4268 states(stateidx)=statedata((statestartidx-1)*statedataoffset+stateidx)
4271 IF(parameterdataoffset>1.OR.numberofparameters==0)
THEN 4275 DO parameteridx=1,numberofparameters
4276 parameters(parameteridx)=parameterdata((parameterstartidx-1)*parameterdataoffset+parameteridx)
4279 IF(intermediatedataoffset>1.OR.numberofintermediates==0)
THEN 4282 IF(ratedataoffset>1.OR.numberofstates==0)
THEN 4285 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states,rates,intermediates,parameters)
4288 DO intermediateidx=1,numberofintermediates
4289 intermediatedata((intermediatestartidx-1)*intermediatedataoffset+intermediateidx)=intermediates(intermediateidx)
4293 DO rateidx=1,numberofstates
4294 ratedata((ratestartidx-1)*ratedataoffset+rateidx)=rates(rateidx)
4300 ratestartdof=(ratestartidx-1)*ratedataoffset+1
4301 rateenddof=ratestartdof+numberofstates-1
4303 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states,ratedata(ratestartdof:rateenddof), &
4304 & intermediates,parameters)
4307 DO intermediateidx=1,numberofintermediates
4308 intermediatedata((intermediatestartidx-1)*intermediatedataoffset+intermediateidx)=intermediates(intermediateidx)
4316 intermediatestartdof=(intermediatestartidx-1)*intermediatedataoffset+1
4317 intermediateenddof=intermediatestartdof+numberofintermediates-1
4319 IF(ratedataoffset>1.OR.numberofstates==0)
THEN 4322 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states,rates, &
4323 & intermediatedata(intermediatestartdof:intermediateenddof),parameters)
4326 DO rateidx=1,numberofstates
4327 ratedata((ratestartidx-1)*ratedataoffset+rateidx)=rates(rateidx)
4333 ratestartdof=(ratestartidx-1)*ratedataoffset+1
4334 rateenddof=ratestartdof+numberofstates-1
4336 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states,ratedata(ratestartdof:rateenddof), &
4337 & intermediatedata(intermediatestartdof:intermediateenddof),parameters)
4344 parameterstartdof=(parameterstartidx-1)*parameterdataoffset+1
4345 parameterenddof=parameterstartdof+numberofparameters-1
4347 IF(intermediatedataoffset>1.OR.numberofintermediates==0)
THEN 4350 IF(ratedataoffset>1.OR.numberofstates==0)
THEN 4353 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states,rates,intermediates, &
4354 & parameters(parameterstartdof:parameterenddof))
4357 DO intermediateidx=1,numberofintermediates
4358 intermediatedata((intermediatestartidx-1)*intermediatedataoffset+intermediateidx)=intermediates(intermediateidx)
4362 DO rateidx=1,numberofstates
4363 ratedata((ratestartidx-1)*ratedataoffset+rateidx)=rates(rateidx)
4369 ratestartdof=(ratestartidx-1)*ratedataoffset+1
4370 rateenddof=ratestartdof+numberofstates-1
4372 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states,ratedata(ratestartdof:rateenddof), &
4373 & intermediates,parameters(parameterstartdof:parameterenddof))
4376 DO intermediateidx=1,numberofintermediates
4377 intermediatedata((intermediatestartidx-1)*intermediatedataoffset+intermediateidx)=intermediates(intermediateidx)
4385 intermediatestartdof=(intermediatestartidx-1)*intermediatedataoffset+1
4386 intermediateenddof=intermediatestartdof+numberofintermediates-1
4388 IF(ratedataoffset>1.OR.numberofstates==0)
THEN 4391 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states,rates, &
4392 & intermediatedata(intermediatestartdof:intermediateenddof), &
4393 & parameters(parameterstartdof:parameterenddof))
4396 DO rateidx=1,numberofstates
4397 ratedata((ratestartidx-1)*ratedataoffset+rateidx)=rates(rateidx)
4403 ratestartdof=(ratestartidx-1)*ratedataoffset+1
4404 rateenddof=ratestartdof+numberofstates-1
4406 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states,ratedata(ratestartdof:rateenddof), &
4407 & intermediatedata(intermediatestartdof:intermediateenddof), &
4408 & parameters(parameterstartdof:parameterenddof))
4416 statestartdof=(statestartidx-1)*statedataoffset+1
4417 stateenddof=statestartdof+numberofstates-1
4419 IF(parameterdataoffset>1.OR.numberofparameters==0)
THEN 4423 DO parameteridx=1,numberofparameters
4424 parameters(parameteridx)=parameterdata((parameterstartidx-1)*parameterdataoffset+parameteridx)
4427 IF(intermediatedataoffset>1.OR.numberofintermediates==0)
THEN 4430 IF(ratedataoffset>1.OR.numberofstates==0)
THEN 4433 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states(statestartdof:stateenddof), &
4434 & rates,intermediates,parameters)
4437 DO intermediateidx=1,numberofintermediates
4438 intermediatedata((intermediatestartidx-1)*intermediatedataoffset+intermediateidx)=intermediates(intermediateidx)
4442 DO rateidx=1,numberofstates
4443 ratedata((ratestartidx-1)*ratedataoffset+rateidx)=rates(rateidx)
4449 ratestartdof=(ratestartidx-1)*ratedataoffset+1
4450 rateenddof=ratestartdof+numberofstates-1
4452 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states(statestartdof:stateenddof), &
4453 & ratedata(ratestartdof:rateenddof),intermediates,parameters)
4456 DO intermediateidx=1,numberofintermediates
4457 intermediatedata((intermediatestartidx-1)*intermediatedataoffset+intermediateidx)=intermediates(intermediateidx)
4465 intermediatestartdof=(intermediatestartidx-1)*intermediatedataoffset+1
4466 intermediateenddof=intermediatestartdof+numberofintermediates-1
4468 IF(ratedataoffset>1.OR.numberofstates==0)
THEN 4471 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states(statestartdof:stateenddof),rates, &
4472 & intermediatedata(intermediatestartdof:intermediateenddof),parameters)
4475 DO rateidx=1,numberofstates
4476 ratedata((ratestartidx-1)*ratedataoffset+rateidx)=rates(rateidx)
4482 ratestartdof=(ratestartidx-1)*ratedataoffset+1
4483 rateenddof=ratestartdof+numberofstates-1
4485 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states(statestartdof:stateenddof), &
4486 & ratedata(ratestartdof:rateenddof),intermediatedata(intermediatestartdof:intermediateenddof), &
4494 parameterstartdof=(parameterstartidx-1)*parameterdataoffset+1
4495 parameterenddof=parameterstartdof+numberofparameters-1
4497 IF(intermediatedataoffset>1.OR.numberofintermediates==0)
THEN 4500 IF(ratedataoffset>1.OR.numberofstates==0)
THEN 4503 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states(statestartdof:stateenddof), &
4504 & rates,intermediates,parameters(parameterstartdof:parameterenddof))
4507 DO intermediateidx=1,numberofintermediates
4508 intermediatedata((intermediatestartidx-1)*intermediatedataoffset+intermediateidx)=intermediates(intermediateidx)
4512 DO rateidx=1,numberofstates
4513 ratedata((ratestartidx-1)*ratedataoffset+rateidx)=rates(rateidx)
4519 ratestartdof=(ratestartidx-1)*ratedataoffset+1
4520 rateenddof=ratestartdof+numberofstates-1
4522 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states(statestartdof:stateenddof), &
4523 & ratedata(ratestartdof:rateenddof),intermediates,parameters(parameterstartdof:parameterenddof))
4526 DO intermediateidx=1,numberofintermediates
4527 intermediatedata((intermediatestartidx-1)*intermediatedataoffset+intermediateidx)=intermediates(intermediateidx)
4535 intermediatestartdof=(intermediatestartidx-1)*intermediatedataoffset+1
4536 intermediateenddof=intermediatestartdof+numberofintermediates-1
4538 IF(ratedataoffset>1.OR.numberofstates==0)
THEN 4541 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states(statestartdof:stateenddof), &
4542 & rates,intermediatedata(intermediatestartdof:intermediateenddof), &
4543 & parameters(parameterstartdof:parameterenddof))
4546 DO rateidx=1,numberofstates
4547 ratedata((ratestartidx-1)*ratedataoffset+rateidx)=rates(rateidx)
4553 ratestartdof=(ratestartidx-1)*ratedataoffset+1
4554 rateenddof=ratestartdof+numberofstates-1
4556 CALL cellml_model_definition_call_rhs_routine(model%ptr,time,states(statestartdof:stateenddof), &
4557 & ratedata(ratestartdof:rateenddof),intermediatedata(intermediatestartdof:intermediateenddof), &
4558 & parameters(parameterstartdof:parameterenddof))
4565 CALL flagerror(
"Model is not associated.",err,error,*999)
4569 CALL flagerror(
"Must compile with WITH_CELLML ON to use CellML functionality.",err,error,*999)
4572 exits(
"Solver_DAECellMLRHSEvaluate")
4574 999 errorsexits(
"Solver_DAECellMLRHSEvaluate",err,error)
4588 INTEGER(INTG),
INTENT(OUT) :: ERR
4592 enters(
"SOLVER_DAE_RUNGE_KUTTA_FINALISE",err,error,*999)
4594 IF(
ASSOCIATED(runge_kutta_solver))
THEN 4595 DEALLOCATE(runge_kutta_solver)
4598 exits(
"SOLVER_DAE_RUNGE_KUTTA_FINALISE")
4600 999 errorsexits(
"SOLVER_DAE_RUNGE_KUTTA_FINALISE",err,error)
4614 INTEGER(INTG),
INTENT(OUT) :: ERR
4617 INTEGER(INTG) :: DUMMY_ERR
4620 enters(
"SOLVER_DAE_RUNGE_KUTTA_INITIALISE",err,error,*998)
4622 IF(
ASSOCIATED(dae_solver))
THEN 4623 IF(
ASSOCIATED(dae_solver%RUNGE_KUTTA_SOLVER))
THEN 4624 CALL flagerror(
"Runge-Kutta solver is already associated for this differential-algebraic equation solver.",err,error,*998)
4627 ALLOCATE(dae_solver%RUNGE_KUTTA_SOLVER,stat=err)
4628 IF(err/=0)
CALL flagerror(
"Could not allocate Runge-Kutta solver.",err,error,*999)
4630 dae_solver%RUNGE_KUTTA_SOLVER%DAE_SOLVER=>dae_solver
4631 dae_solver%RUNGE_KUTTA_SOLVER%SOLVER_LIBRARY=0
4635 CALL flagerror(
"Differential-algebraic equation solver is not associated.",err,error,*998)
4638 exits(
"SOLVER_DAE_RUNGE_KUTTA_INITIALISE")
4641 998 errorsexits(
"SOLVER_DAE_RUNGE_KUTTA_INITIALISE",err,error)
4655 INTEGER(INTG),
INTENT(OUT) :: ERR
4659 enters(
"SOLVER_DAE_RUNGE_KUTTA_SOLVE",err,error,*999)
4661 IF(
ASSOCIATED(runge_kutta_solver))
THEN 4662 CALL flagerror(
"Not implemented.",err,error,*999)
4664 CALL flagerror(
"Runge-Kutta differential-algebraic equation solver is not associated.",err,error,*999)
4667 exits(
"SOLVER_DAE_RUNGE_KUTTA_SOLVE")
4669 999 errorsexits(
"SOLVER_DAE_RUNGE_KUTTA_SOLVE",err,error)
4683 INTEGER(INTG),
INTENT(OUT) :: ERR
4687 enters(
"SOLVER_DAE_RUSH_LARSON_FINALISE",err,error,*999)
4689 IF(
ASSOCIATED(rush_larson_solver))
THEN 4690 DEALLOCATE(rush_larson_solver)
4693 exits(
"SOLVER_DAE_RUSH_LARSON_FINALISE")
4695 999 errorsexits(
"SOLVER_DAE_RUSH_LARSON_FINALISE",err,error)
4709 INTEGER(INTG),
INTENT(OUT) :: ERR
4712 INTEGER(INTG) :: DUMMY_ERR
4715 enters(
"SOLVER_DAE_RUSH_LARSON_INITIALISE",err,error,*998)
4717 IF(
ASSOCIATED(dae_solver))
THEN 4718 IF(
ASSOCIATED(dae_solver%RUSH_LARSON_SOLVER))
THEN 4719 CALL flagerror(
"Rush-Larson solver is already associated for this differential-algebraic equation solver.",err,error,*998)
4722 ALLOCATE(dae_solver%RUSH_LARSON_SOLVER,stat=err)
4723 IF(err/=0)
CALL flagerror(
"Could not allocate Rush-Larson solver.",err,error,*999)
4725 dae_solver%RUSH_LARSON_SOLVER%DAE_SOLVER=>dae_solver
4726 dae_solver%RUSH_LARSON_SOLVER%SOLVER_LIBRARY=0
4730 CALL flagerror(
"Differential-algebraic equation solver is not associated.",err,error,*998)
4733 exits(
"SOLVER_DAE_RUSH_LARSON_INITIALISE")
4736 998 errorsexits(
"SOLVER_DAE_RUSH_LARSON_INITIALISE",err,error)
4750 INTEGER(INTG),
INTENT(OUT) :: ERR
4754 enters(
"SOLVER_DAE_RUSH_LARSON_SOLVE",err,error,*999)
4756 IF(
ASSOCIATED(rush_larson_solver))
THEN 4757 CALL flagerror(
"Not implemented.",err,error,*999)
4759 CALL flagerror(
"Rush-Larson differential-algebraic equation solver is not associated.",err,error,*999)
4762 exits(
"SOLVER_DAE_RUSH_LARSON_SOLVE")
4764 999 errorsexits(
"SOLVER_DAE_RUSH_LARSON_SOLVE",err,error)
4778 INTEGER(INTG),
INTENT(OUT) :: ERR
4781 INTEGER(INTG) :: cellml_idx
4788 enters(
"SOLVER_DAE_SOLVE",err,error,*999)
4790 IF(
ASSOCIATED(dae_solver))
THEN 4791 solver=>dae_solver%SOLVER
4792 IF(
ASSOCIATED(solver))
THEN 4793 SELECT CASE(dae_solver%DAE_SOLVE_TYPE)
4809 local_error=
"The differential-algebraic equation solver solve type of "// &
4811 CALL flagerror(local_error,err,error,*999)
4815 CALL tau_static_phase_start(
"Solution Output Phase")
4817 cellml_equations=>solver%CELLML_EQUATIONS
4818 IF(
ASSOCIATED(cellml_equations))
THEN 4822 & number_of_cellml_environments,err,error,*999)
4823 DO cellml_idx=1,cellml_equations%NUMBER_OF_CELLML_ENVIRONMENTS
4824 cellml=>cellml_equations%CELLML_ENVIRONMENTS(cellml_idx)%PTR
4825 IF(
ASSOCIATED(cellml))
THEN 4826 cellml_state_field=>cellml%STATE_FIELD
4827 IF(
ASSOCIATED(cellml_state_field))
THEN 4829 CALL field_parameter_set_output(
general_output_type,cellml_state_field%STATE_FIELD,field_u_variable_type, &
4830 & field_values_set_type,err,error,*999)
4832 CALL flagerror(
"CellML environment state field is not associated.",err,error,*999)
4835 local_error=
"CellML environment is not associated for CellML index "// &
4837 CALL flagerror(local_error,err,error,*999)
4842 CALL flagerror(
"Solver CellML equations is not associated.",err,error,*999)
4845 CALL tau_static_phase_stop(
"Solution Output Phase")
4849 CALL flagerror(
"Differential-algebraic solver solver is not associated.",err,error,*999)
4852 CALL flagerror(
"Differential-algebraic equation solver is not associated.",err,error,*999)
4855 exits(
"SOLVER_DAE_SOLVE")
4857 999 errorsexits(
"SOLVER_DAE_SOLVE",err,error)
4871 INTEGER(INTG),
INTENT(OUT) :: DAE_SOLVE_TYPE
4872 INTEGER(INTG),
INTENT(OUT) :: ERR
4877 enters(
"SOLVER_DAE_SOLVER_TYPE_GET",err,error,*999)
4879 IF(
ASSOCIATED(solver))
THEN 4880 IF(solver%SOLVER_FINISHED)
THEN 4882 dae_solver=>solver%DAE_SOLVER
4883 IF(
ASSOCIATED(dae_solver))
THEN 4884 dae_solve_type=dae_solver%DAE_SOLVE_TYPE
4886 CALL flagerror(
"The solver differential-algebraic equation solver is not associated.",err,error,*999)
4889 CALL flagerror(
"The solver is not a differential-algebraic equation solver.",err,error,*999)
4892 CALL flagerror(
"Solver has not been finished.",err,error,*999)
4895 CALL flagerror(
"Solver is not associated.",err,error,*999)
4898 exits(
"SOLVER_DAE_SOLVER_TYPE_GET")
4900 999 errorsexits(
"SOLVER_DAE_SOLVER_TYPE_GET",err,error)
4914 INTEGER(INTG),
INTENT(IN) :: DAE_SOLVE_TYPE
4915 INTEGER(INTG),
INTENT(OUT) :: ERR
4921 enters(
"SOLVER_DAE_SOLVER_TYPE_SET",err,error,*999)
4923 IF(
ASSOCIATED(solver))
THEN 4924 IF(solver%SOLVER_FINISHED)
THEN 4925 CALL flagerror(
"Solver has already been finished.",err,error,*999)
4928 dae_solver=>solver%DAE_SOLVER
4929 IF(
ASSOCIATED(dae_solver))
THEN 4930 IF(dae_solve_type/=dae_solver%DAE_SOLVE_TYPE)
THEN 4932 SELECT CASE(dae_solve_type)
4948 local_error=
"The specified differential-algebraic equation solver type of "// &
4950 CALL flagerror(local_error,err,error,*999)
4953 SELECT CASE(dae_solver%DAE_SOLVE_TYPE)
4969 local_error=
"The differential-algebraic equation solve type of "// &
4971 CALL flagerror(local_error,err,error,*999)
4973 dae_solver%DAE_SOLVE_TYPE=dae_solve_type
4976 CALL flagerror(
"The solver differential-algebraic equation solver is not associated.",err,error,*999)
4979 CALL flagerror(
"The solver is not a differential-algebraic equation solver.",err,error,*999)
4983 CALL flagerror(
"Solver is not associated.",err,error,*999)
4986 exits(
"SOLVER_DAE_SOLVER_TYPE_SET")
4988 999 errorsexits(
"SOLVER_DAE_SOLVER_TYPE_SET",err,error)
5002 REAL(DP),
INTENT(IN) :: START_TIME
5003 REAL(DP),
INTENT(IN) :: END_TIME
5004 INTEGER(INTG),
INTENT(OUT) :: ERR
5010 enters(
"SOLVER_DAE_TIMES_SET",err,error,*999)
5012 IF(
ASSOCIATED(solver))
THEN 5014 dae_solver=>solver%DAE_SOLVER
5015 IF(
ASSOCIATED(dae_solver))
THEN 5016 IF(end_time>start_time)
THEN 5017 dae_solver%START_TIME=start_time
5018 dae_solver%END_TIME=end_time
5020 local_error=
"The specified end time of "//
trim(
numbertovstring(end_time,
"*",err,error))// &
5021 &
" is not > than the specified start time of "//
trim(
numbertovstring(start_time,
"*",err,error))//
"." 5022 CALL flagerror(local_error,err,error,*999)
5025 CALL flagerror(
"Differential-algebraic equation solver is not associated.",err,error,*999)
5028 CALL flagerror(
"The solver is not a differential-algebraic equation solver.",err,error,*999)
5031 CALL flagerror(
"Solver is not associated.",err,error,*999)
5034 exits(
"SOLVER_DAE_TIMES_SET")
5036 999 errorsexits(
"SOLVER_DAE_TIMES_SET",err,error)
5050 REAL(DP),
INTENT(IN) :: TIME_STEP
5051 INTEGER(INTG),
INTENT(OUT) :: ERR
5057 enters(
"SOLVER_DAE_TIME_STEP_SET",err,error,*999)
5059 IF(
ASSOCIATED(solver))
THEN 5061 dae_solver=>solver%DAE_SOLVER
5062 IF(
ASSOCIATED(dae_solver))
THEN 5064 local_error=
"The specified time step of "//
trim(
numbertovstring(time_step,
"*",err,error))// &
5065 &
" is invalid. The time step must not be zero." 5066 CALL flagerror(local_error,err,error,*999)
5068 dae_solver%INITIAL_STEP=time_step
5071 CALL flagerror(
"Differential-algebraic equation solver is not associated.",err,error,*999)
5074 CALL flagerror(
"The solver is not a differential-algebraic equation solver.",err,error,*999)
5077 CALL flagerror(
"Solver is not associated.",err,error,*999)
5080 exits(
"SOLVER_DAE_TIME_STEP_SET")
5082 999 errorsexits(
"SOLVER_DAE_TIME_STEP_SET",err,error)
5096 INTEGER(INTG),
INTENT(OUT) :: ERR
5100 enters(
"SOLVER_DESTROY",err,error,*999)
5102 IF(
ASSOCIATED(solver))
THEN 5103 CALL flagerror(
"Not implemented.",err,error,*999)
5105 CALL flagerror(
"Solver is not associated.",err,error,*999)
5108 exits(
"SOLVER_DESTROY")
5110 999 errorsexits(
"SOLVER_DESTROY",err,error)
5124 INTEGER(INTG),
INTENT(OUT) :: ERR
5127 INTEGER(INTG) :: DYNAMIC_VARIABLE_TYPE,equations_matrix_idx,equations_set_idx,LINEAR_LIBRARY_TYPE,NONLINEAR_LIBRARY_TYPE
5128 INTEGER(INTG) :: VariableType=0
5141 TYPE(
solver_type),
POINTER :: SOLVER,LINEAR_SOLVER,NONLINEAR_SOLVER
5147 enters(
"SOLVER_DYNAMIC_CREATE_FINISH",err,error,*999)
5149 IF(
ASSOCIATED(dynamic_solver))
THEN 5150 solver=>dynamic_solver%SOLVER
5151 IF(
ASSOCIATED(solver))
THEN 5152 solver_equations=>solver%SOLVER_EQUATIONS
5153 IF(
ASSOCIATED(solver_equations))
THEN 5154 SELECT CASE(dynamic_solver%SOLVER_LIBRARY)
5157 solver_equations=>solver%SOLVER_EQUATIONS
5158 IF(
ASSOCIATED(solver_equations))
THEN 5159 solver_mapping=>solver_equations%SOLVER_MAPPING
5160 IF(
ASSOCIATED(solver_mapping))
THEN 5162 dynamic_solver%EXPLICIT=abs(dynamic_solver%THETA(dynamic_solver%DEGREE))<
zero_tolerance 5164 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
5165 equations=>solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)%EQUATIONS
5166 IF(
ASSOCIATED(equations))
THEN 5167 equations_set=>equations%EQUATIONS_SET
5168 IF(
ASSOCIATED(equations_set))
THEN 5169 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
5170 IF(
ASSOCIATED(dependent_field))
THEN 5171 equations_mapping=>equations%EQUATIONS_MAPPING
5172 IF(
ASSOCIATED(equations_mapping))
THEN 5173 dynamic_mapping=>equations_mapping%DYNAMIC_MAPPING
5174 IF(
ASSOCIATED(dynamic_mapping))
THEN 5175 dynamic_variable=>dynamic_mapping%DYNAMIC_VARIABLE
5176 dynamic_variable_type=dynamic_mapping%DYNAMIC_VARIABLE_TYPE
5177 IF(
ASSOCIATED(dynamic_variable))
THEN 5185 CALL field_parametersetensurecreated(dependent_field,dynamic_variable_type, &
5186 & field_velocity_values_set_type,err,error,*999)
5187 CALL field_parametersetensurecreated(dependent_field,dynamic_variable_type, &
5188 & field_previous_velocity_set_type,err,error,*999)
5189 CALL field_parametersetensurecreated(dependent_field, &
5190 & dynamic_variable_type,field_mean_predicted_velocity_set_type,err,error,*999)
5193 CALL field_parametersetensurecreated(dependent_field,dynamic_variable_type, &
5194 & field_acceleration_values_set_type,err,error,*999)
5195 CALL field_parametersetensurecreated(dependent_field,dynamic_variable_type, &
5196 & field_previous_acceleration_set_type,err,error,*999)
5197 CALL field_parametersetensurecreated( &
5198 & dependent_field,dynamic_variable_type,field_mean_predicted_acceleration_set_type, &
5206 equations_matrices=>equations%EQUATIONS_MATRICES
5207 IF(
ASSOCIATED(equations_matrices))
THEN 5208 dynamic_matrices=>equations_matrices%DYNAMIC_MATRICES
5209 IF(
ASSOCIATED(dynamic_matrices))
THEN 5210 IF(.NOT.
ASSOCIATED(dynamic_matrices%TEMP_VECTOR))
THEN 5212 & dynamic_matrices%TEMP_VECTOR,err,error,*999)
5218 IF(abs(dynamic_solver%THETA(dynamic_solver%DEGREE))<
zero_tolerance)
THEN 5219 IF(dynamic_mapping%DAMPING_MATRIX_NUMBER/=0)
THEN 5220 damping_matrix=>dynamic_matrices%MATRICES(dynamic_mapping%DAMPING_MATRIX_NUMBER)%PTR
5221 IF(
ASSOCIATED(damping_matrix))
THEN 5222 dynamic_solver%EXPLICIT=dynamic_solver%EXPLICIT.AND.damping_matrix%LUMPED
5224 CALL flagerror(
"Damping matrix is not associated.",err,error,*999)
5227 IF(dynamic_mapping%MASS_MATRIX_NUMBER/=0)
THEN 5228 mass_matrix=>dynamic_matrices%MATRICES(dynamic_mapping%MASS_MATRIX_NUMBER)%PTR
5229 IF(
ASSOCIATED(mass_matrix))
THEN 5230 dynamic_solver%EXPLICIT=dynamic_solver%EXPLICIT.AND.mass_matrix%LUMPED
5232 CALL flagerror(
"Mass matrix is not associated.",err,error,*999)
5237 CALL flagerror(
"Equations matrices dynamic matrices are not associated.",err,error,*999)
5240 CALL flagerror(
"Equations equations matrices is not associated.",err,error,*999)
5242 variabletype=dynamic_variable_type
5244 CALL flagerror(
"Dynamic mapping dynamic variable is not associated.",err,error,*999)
5249 IF(variabletype==0)
THEN 5251 nonlinearmapping=>equations_mapping%NONLINEAR_MAPPING
5252 IF(
ASSOCIATED(nonlinearmapping))
THEN 5255 residualvariable=>nonlinearmapping%RESIDUAL_VARIABLES(1)%PTR
5256 IF(
ASSOCIATED(residualvariable))
THEN 5257 variabletype=residualvariable%VARIABLE_TYPE
5259 CALL flagerror(
"Residual variable is not associated.",err,error,*999)
5262 local_error=
"The specified dynamic solver linearity type of "// &
5264 &
" is invalid for a nonlinear equations mapping." 5265 CALL flagerror(local_error,err,error,*999)
5269 CALL field_parametersetensurecreated(dependent_field,variabletype, &
5270 & field_previous_values_set_type,err,error,*999)
5271 CALL field_parametersetensurecreated(dependent_field,variabletype, &
5272 & field_mean_predicted_displacement_set_type,err,error,*999)
5274 CALL field_parametersetensurecreated(dependent_field,variabletype, &
5275 & field_incremental_values_set_type,err,error,*999)
5276 CALL field_parametersetensurecreated(dependent_field,variabletype, &
5277 & field_predicted_displacement_set_type,err,error,*999)
5278 CALL field_parametersetensurecreated(dependent_field,variabletype, &
5279 & field_residual_set_type,err,error,*999)
5280 CALL field_parametersetensurecreated(dependent_field,variabletype, &
5281 & field_previous_residual_set_type,err,error,*999)
5285 linear_mapping=>equations_mapping%LINEAR_MAPPING
5286 IF(
ASSOCIATED(linear_mapping))
THEN 5288 equations_matrices=>equations%EQUATIONS_MATRICES
5289 IF(
ASSOCIATED(equations_matrices))
THEN 5290 linear_matrices=>equations_matrices%LINEAR_MATRICES
5291 IF(
ASSOCIATED(linear_matrices))
THEN 5292 DO equations_matrix_idx=1,linear_matrices%NUMBER_OF_LINEAR_MATRICES
5293 equations_matrix=>linear_matrices%MATRICES(equations_matrix_idx)%PTR
5294 IF(
ASSOCIATED(equations_matrix))
THEN 5295 IF(.NOT.
ASSOCIATED(equations_matrix%TEMP_VECTOR))
THEN 5296 linear_variable=>linear_mapping%EQUATIONS_MATRIX_TO_VAR_MAPS(equations_matrix_idx)%VARIABLE
5297 IF(
ASSOCIATED(linear_variable))
THEN 5299 & equations_matrix%TEMP_VECTOR,err,error,*999)
5304 CALL flagerror(
"Linear mapping linear variable is not associated.",err,error,*999)
5308 CALL flagerror(
"Equations matrix is not associated.",err,error,*999)
5312 CALL flagerror(
"Equations matrices linear matrices is not associated.",err,error,*999)
5315 CALL flagerror(
"Equations equations matrices is not associated.",err,error,*999)
5319 CALL flagerror(
"Equations equations mapping is not associated.",err,error,*999)
5322 local_error=
"Equations set dependent field is not associated for equations set index "// &
5324 CALL flagerror(local_error,err,error,*999)
5327 local_error=
"Equations equations set is not associated for equations set index "// &
5329 CALL flagerror(local_error,err,error,*999)
5332 local_error=
"Equations is not associated for equations set index "// &
5334 CALL flagerror(local_error,err,error,*999)
5339 linear_solver=>dynamic_solver%LINEAR_SOLVER
5340 IF(
ASSOCIATED(linear_solver))
THEN 5341 NULLIFY(solver_matrices)
5345 IF(dynamic_solver%EXPLICIT)
THEN 5349 SELECT CASE(solver_equations%SPARSITY_TYPE)
5357 local_error=
"The specified solver equations sparsity type of "// &
5360 CALL flagerror(local_error,err,error,*999)
5365 linear_solver%SOLVER_EQUATIONS=>solver%SOLVER_EQUATIONS
5369 CALL flagerror(
"Dynamic solver linear solver is not associated.",err,error,*999)
5372 nonlinear_solver=>dynamic_solver%NONLINEAR_SOLVER
5373 IF(
ASSOCIATED(nonlinear_solver))
THEN 5374 NULLIFY(solver_matrices)
5378 IF(dynamic_solver%EXPLICIT)
THEN 5382 SELECT CASE(solver_equations%SPARSITY_TYPE)
5390 local_error=
"The specified solver equations sparsity type of "// &
5393 CALL flagerror(local_error,err,error,*999)
5398 nonlinear_solver%SOLVER_EQUATIONS=>solver%SOLVER_EQUATIONS
5402 CALL flagerror(
"Dynamic solver linear solver is not associated.",err,error,*999)
5406 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
5409 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
5412 CALL flagerror(
"Not implemented.",err,error,*999)
5414 local_error=
"The solver library type of "// &
5416 CALL flagerror(local_error,err,error,*999)
5419 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
5422 CALL flagerror(
"Dynamic solver solver is not associated.",err,error,*999)
5425 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
5428 exits(
"SOLVER_DYNAMIC_CREATE_FINISH")
5430 999 errorsexits(
"SOLVER_DYNAMIC_CREATE_FINISH",err,error)
5444 INTEGER(INTG),
INTENT(OUT) :: DEGREE
5445 INTEGER(INTG),
INTENT(OUT) :: ERR
5450 enters(
"SOLVER_DYNAMIC_DEGREE_GET",err,error,*999)
5452 IF(
ASSOCIATED(solver))
THEN 5453 IF(solver%SOLVER_FINISHED)
THEN 5455 dynamic_solver=>solver%DYNAMIC_SOLVER
5456 IF(
ASSOCIATED(dynamic_solver))
THEN 5457 degree=dynamic_solver%DEGREE
5459 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
5462 CALL flagerror(
"The specified solver is not a dynamic solver.",err,error,*999)
5465 CALL flagerror(
"The solver has not been finished.",err,error,*999)
5468 CALL flagerror(
"Solver is not associated.",err,error,*999)
5471 exits(
"SOLVER_DYNAMIC_DEGREE_GET")
5473 999 errorsexits(
"SOLVER_DYNAMIC_DEGREE_GET",err,error)
5487 INTEGER(INTG),
INTENT(IN) :: DEGREE
5488 INTEGER(INTG),
INTENT(OUT) :: ERR
5491 INTEGER(INTG) :: degree_idx
5492 REAL(DP),
ALLOCATABLE :: OLD_THETA(:)
5496 enters(
"SOLVER_DYNAMIC_DEGREE_SET",err,error,*999)
5498 IF(
ASSOCIATED(solver))
THEN 5499 IF(solver%SOLVER_FINISHED)
THEN 5500 CALL flagerror(
"The solver has already been finished.",err,error,*999)
5503 dynamic_solver=>solver%DYNAMIC_SOLVER
5504 IF(
ASSOCIATED(dynamic_solver))
THEN 5505 IF(degree/=dynamic_solver%DEGREE)
THEN 5506 IF(degree>=dynamic_solver%ORDER)
THEN 5509 ALLOCATE(old_theta(dynamic_solver%DEGREE),stat=err)
5510 IF(err/=0)
CALL flagerror(
"Could not allocate old theta.",err,error,*999)
5511 old_theta(1:dynamic_solver%DEGREE)=dynamic_solver%THETA(1:dynamic_solver%DEGREE)
5512 IF(
ALLOCATED(dynamic_solver%THETA))
DEALLOCATE(dynamic_solver%THETA)
5513 ALLOCATE(dynamic_solver%THETA(degree),stat=err)
5514 IF(err/=0)
CALL flagerror(
"Could not allocate theta.",err,error,*999)
5515 IF(degree>dynamic_solver%DEGREE)
THEN 5516 DO degree_idx=1,dynamic_solver%DEGREE
5517 dynamic_solver%THETA(degree_idx)=old_theta(degree_idx)
5519 DO degree_idx=dynamic_solver%DEGREE+1,degree
5520 dynamic_solver%THETA(degree_idx)=1.0_dp
5523 DO degree_idx=1,degree
5524 dynamic_solver%THETA(degree_idx)=old_theta(degree_idx)
5527 IF(
ALLOCATED(old_theta))
DEALLOCATE(old_theta)
5528 dynamic_solver%DEGREE=degree
5530 local_error=
"The specified degree of "//
trim(
numbertovstring(degree,
"*",err,error))//
" is invalid." 5531 CALL flagerror(local_error,err,error,*999)
5534 local_error=
"Invalid dynamic solver setup. The specfied degree of "// &
5535 &
trim(
numbertovstring(degree,
"*",err,error))//
" must be >= the current dynamic order of "// &
5537 CALL flagerror(local_error,err,error,*999)
5541 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
5544 CALL flagerror(
"The specified solver is not a dynamic solver.",err,error,*999)
5548 CALL flagerror(
"Solver is not associated.",err,error,*999)
5551 exits(
"SOLVER_DYNAMIC_DEGREE_SET")
5553 999
IF(
ALLOCATED(old_theta))
DEALLOCATE(old_theta)
5554 errorsexits(
"SOLVER_DYNAMIC_DEGREE_SET",err,error)
5567 INTEGER(INTG),
INTENT(OUT) :: ERR
5571 enters(
"SOLVER_DYNAMIC_FINALISE",err,error,*999)
5572 IF(
ASSOCIATED(dynamic_solver))
THEN 5573 IF(
ALLOCATED(dynamic_solver%THETA))
THEN 5576 DEALLOCATE(dynamic_solver%THETA)
5580 DEALLOCATE(dynamic_solver)
5583 exits(
"SOLVER_DYNAMIC_FINALISE")
5585 999 errorsexits(
"SOLVER_DYNAMIC_FINALISE",err,error)
5599 INTEGER(INTG),
INTENT(OUT) :: ERR
5605 enters(
"SOLVER_DYNAMIC_INITIALISE",err,error,*999)
5607 IF(
ASSOCIATED(solver))
THEN 5608 IF(
ASSOCIATED(solver%DYNAMIC_SOLVER))
THEN 5609 CALL flagerror(
"Dynamic solver is already associated for this solver.",err,error,*999)
5612 ALLOCATE(solver%DYNAMIC_SOLVER,stat=err)
5613 IF(err/=0)
CALL flagerror(
"Could not allocate solver dynamic solver.",err,error,*999)
5614 dynamic_solver=>solver%DYNAMIC_SOLVER
5615 dynamic_solver%SOLVER=>solver
5617 dynamic_solver%SOLVER_INITIALISED=.false.
5621 ALLOCATE(solver%DYNAMIC_SOLVER%THETA(1),stat=err)
5622 IF(err/=0)
CALL flagerror(
"Could not allocate theta.",err,error,*999)
5623 dynamic_solver%THETA(1)=1.0_dp/2.0_dp
5624 dynamic_solver%EXPLICIT=.false.
5625 dynamic_solver%RESTART=.false.
5626 dynamic_solver%ALE=.true.
5627 dynamic_solver%FSI=.false.
5628 dynamic_solver%UPDATE_BC=.true.
5629 dynamic_solver%CURRENT_TIME=0.0_dp
5630 dynamic_solver%TIME_INCREMENT=0.01_dp
5631 NULLIFY(dynamic_solver%LINEAR_SOLVER)
5632 NULLIFY(dynamic_solver%NONLINEAR_SOLVER)
5637 CALL flagerror(
"Solver is not associated.",err,error,*999)
5640 exits(
"SOLVER_DYNAMIC_INITIALISE")
5642 999 errorsexits(
"SOLVER_DYNAMIC_INITIALISE",err,error)
5656 INTEGER(INTG),
INTENT(OUT) :: SOLVER_LIBRARY_TYPE
5657 INTEGER(INTG),
INTENT(OUT) :: ERR
5661 enters(
"SOLVER_DYNAMIC_LIBRARY_TYPE_GET",err,error,*999)
5663 IF(
ASSOCIATED(dynamic_solver))
THEN 5664 solver_library_type=dynamic_solver%SOLVER_LIBRARY
5666 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
5669 exits(
"SOLVER_DYNAMIC_LIBRARY_TYPE_GET")
5671 999 errorsexits(
"SOLVER_DYNAMIC_LIBRARY_TYPE_GET",err,error)
5685 INTEGER(INTG),
INTENT(IN) :: SOLVER_LIBRARY_TYPE
5686 INTEGER(INTG),
INTENT(OUT) :: ERR
5691 enters(
"SOLVER_DYNAMIC_LIBRARY_TYPE_SET",err,error,*999)
5693 IF(
ASSOCIATED(dynamic_solver))
THEN 5694 SELECT CASE(solver_library_type)
5698 local_error=
"The solver library type of "//
trim(
numbertovstring(solver_library_type,
"*",err,error))// &
5699 &
" is invalid for a dynamic solver." 5700 CALL flagerror(local_error,err,error,*999)
5703 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
5706 exits(
"SOLVER_DYNAMIC_LIBRARY_TYPE_SET")
5708 999 errorsexits(
"SOLVER_DYNAMIC_LIBRARY_TYPE_SET",err,error)
5722 INTEGER(INTG),
INTENT(OUT) :: LINEARITY_TYPE
5723 INTEGER(INTG),
INTENT(OUT) :: ERR
5728 enters(
"SOLVER_DYNAMIC_LINEARITY_TYPE_GET",err,error,*999)
5730 IF(
ASSOCIATED(solver))
THEN 5731 IF(solver%SOLVER_FINISHED)
THEN 5732 dynamic_solver=>solver%DYNAMIC_SOLVER
5733 IF(
ASSOCIATED(dynamic_solver))
THEN 5734 linearity_type=dynamic_solver%LINEARITY
5736 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
5739 CALL flagerror(
"Solver has not been finished.",err,error,*999)
5742 CALL flagerror(
"Solver is not associated.",err,error,*999)
5745 exits(
"SOLVER_DYNAMIC_LINEARITY_TYPE_GET")
5747 999 errorsexits(
"SOLVER_DYNAMIC_LINEARITY_TYPE_GET",err,error)
5761 INTEGER(INTG),
INTENT(IN) :: LINEARITY_TYPE
5762 INTEGER(INTG),
INTENT(OUT) :: ERR
5768 enters(
"SOLVER_DYNAMIC_LINEARITY_TYPE_SET",err,error,*999)
5770 IF(
ASSOCIATED(solver))
THEN 5771 IF(solver%SOLVER_FINISHED)
THEN 5772 CALL flagerror(
"Solver has already been finished.",err,error,*999)
5774 dynamic_solver=>solver%DYNAMIC_SOLVER
5775 IF(
ASSOCIATED(dynamic_solver))
THEN 5781 SELECT CASE(linearity_type)
5783 ALLOCATE(dynamic_solver%LINEAR_SOLVER,stat=err)
5784 IF(err/=0)
CALL flagerror(
"Could not allocate solver linear solver.",err,error,*999)
5785 NULLIFY(dynamic_solver%LINEAR_SOLVER%SOLVERS)
5796 ALLOCATE(dynamic_solver%NONLINEAR_SOLVER,stat=err)
5797 IF(err/=0)
CALL flagerror(
"Could not allocate solver nonlinear solver.",err,error,*999)
5798 NULLIFY(dynamic_solver%NONLINEAR_SOLVER%SOLVERS)
5807 IF(dynamic_solver%NONLINEAR_SOLVER%NONLINEAR_SOLVER%NEWTON_SOLVER%LINEAR_SOLVER%LINEAR_SOLVER%LINEAR_SOLVE_TYPE== &
5814 local_error=
"The specified solver equations linearity type of "// &
5816 CALL flagerror(local_error,err,error,*999)
5819 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
5823 CALL flagerror(
"Solver is not associated.",err,error,*999)
5826 exits(
"SOLVER_DYNAMIC_LINEARITY_TYPE_SET")
5828 999 errorsexits(
"SOLVER_DYNAMIC_LINEARITY_TYPE_SET",err,error)
5843 INTEGER(INTG),
INTENT(OUT) :: ERR
5848 enters(
"SOLVER_DYNAMIC_NONLINEAR_SOLVER_GET",err,error,*999)
5850 IF(
ASSOCIATED(solver))
THEN 5851 IF(
ASSOCIATED(nonlinear_solver))
THEN 5852 CALL flagerror(
"Nonlinear solver is already associated.",err,error,*999)
5854 NULLIFY(nonlinear_solver)
5856 dynamic_solver=>solver%DYNAMIC_SOLVER
5857 IF(
ASSOCIATED(dynamic_solver))
THEN 5858 nonlinear_solver=>dynamic_solver%NONLINEAR_SOLVER
5859 IF(.NOT.
ASSOCIATED(nonlinear_solver))
CALL flagerror(
"Dynamic solver nonlinear solver is not associated.", &
5862 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
5865 CALL flagerror(
"The specified solver is not a dynamic solver.",err,error,*999)
5869 CALL flagerror(
"Solver is not associated.",err,error,*999)
5872 exits(
"SOLVER_DYNAMIC_NONLINEAR_SOLVER_GET")
5874 999 errorsexits(
"SOLVER_DYNAMIC_NONLINEAR_SOLVER_GET",err,error)
5889 INTEGER(INTG),
INTENT(OUT) :: ERR
5894 enters(
"SOLVER_DYNAMIC_LINEAR_SOLVER_GET",err,error,*999)
5896 IF(
ASSOCIATED(solver))
THEN 5897 IF(
ASSOCIATED(linear_solver))
THEN 5898 CALL flagerror(
"Linear solver is already associated.",err,error,*999)
5900 NULLIFY(linear_solver)
5902 dynamic_solver=>solver%DYNAMIC_SOLVER
5903 IF(
ASSOCIATED(dynamic_solver))
THEN 5904 linear_solver=>dynamic_solver%LINEAR_SOLVER
5905 IF(.NOT.
ASSOCIATED(linear_solver))
CALL flagerror(
"Dynamic solver linear solver is not associated.",err,error,*999)
5907 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
5910 CALL flagerror(
"The specified solver is not a dynamic solver.",err,error,*999)
5914 CALL flagerror(
"Solver is not associated.",err,error,*999)
5917 exits(
"SOLVER_DYNAMIC_LINEAR_SOLVER_GET")
5919 999 errorsexits(
"SOLVER_DYNAMIC_LINEAR_SOLVER_GET",err,error)
5933 INTEGER(INTG),
INTENT(OUT) :: ERR
5936 INTEGER(INTG) :: DYNAMIC_VARIABLE_TYPE,equations_set_idx
5937 REAL(DP) :: DELTA_T,FIRST_MEAN_PREDICTION_FACTOR, SECOND_MEAN_PREDICTION_FACTOR,THIRD_MEAN_PREDICTION_FACTOR
5938 REAL(DP) :: FIRST_PREDICTION_FACTOR, SECOND_PREDICTION_FACTOR,THIRD_PREDICTION_FACTOR
5952 enters(
"SOLVER_DYNAMIC_MEAN_PREDICTED_CALCULATE",err,error,*999)
5954 IF(
ASSOCIATED(solver))
THEN 5955 dynamic_solver=>solver%DYNAMIC_SOLVER
5956 IF(
ASSOCIATED(dynamic_solver))
THEN 5957 IF(dynamic_solver%SOLVER_INITIALISED)
THEN 5958 delta_t=dynamic_solver%TIME_INCREMENT
5959 SELECT CASE(dynamic_solver%DEGREE)
5961 first_mean_prediction_factor=1.0_dp
5962 first_prediction_factor=1.0_dp
5964 first_mean_prediction_factor=1.0_dp
5965 second_mean_prediction_factor=dynamic_solver%THETA(1)*delta_t
5966 first_prediction_factor=1.0_dp
5967 second_prediction_factor=delta_t
5969 first_mean_prediction_factor=1.0_dp
5970 second_mean_prediction_factor=dynamic_solver%THETA(1)*delta_t
5971 third_mean_prediction_factor=dynamic_solver%THETA(2)*delta_t*delta_t
5972 first_prediction_factor=1.0_dp
5973 second_prediction_factor=delta_t
5974 third_prediction_factor=delta_t*delta_t
5976 local_error=
"The dynamic solver degree of "//
trim(
numbertovstring(dynamic_solver%DEGREE,
"*",err,error))// &
5978 CALL flagerror(local_error,err,error,*999)
5981 solver_equations=>solver%SOLVER_EQUATIONS
5982 IF(
ASSOCIATED(solver_equations))
THEN 5983 solver_mapping=>solver_equations%SOLVER_MAPPING
5984 IF(
ASSOCIATED(solver_mapping))
THEN 5985 solver_matrices=>solver_equations%SOLVER_MATRICES
5986 IF(
ASSOCIATED(solver_matrices))
THEN 5987 IF(dynamic_solver%SOLVER_INITIALISED.OR.(.NOT.dynamic_solver%SOLVER_INITIALISED.AND. &
5992 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
5993 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
5994 IF(
ASSOCIATED(equations_set))
THEN 5995 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
5996 equations=>equations_set%EQUATIONS
5997 IF(
ASSOCIATED(equations))
THEN 5998 equations_matrices=>equations%EQUATIONS_MATRICES
5999 IF(
ASSOCIATED(equations_matrices))
THEN 6000 equations_mapping=>equations%EQUATIONS_MAPPING
6001 IF(
ASSOCIATED(equations_mapping))
THEN 6002 dynamic_mapping=>equations_mapping%DYNAMIC_MAPPING
6003 IF(
ASSOCIATED(dynamic_mapping))
THEN 6004 dynamic_variable_type=dynamic_mapping%DYNAMIC_VARIABLE_TYPE
6005 IF(dynamic_solver%SOLVER_INITIALISED)
THEN 6010 CALL field_parameter_sets_copy(dependent_field,dynamic_variable_type,field_values_set_type, &
6011 & field_previous_values_set_type,1.0_dp,err,error,*999)
6013 CALL field_parameter_sets_copy(dependent_field,dynamic_variable_type, &
6014 & field_residual_set_type,field_previous_residual_set_type,1.0_dp, &
6018 SELECT CASE(dynamic_solver%DEGREE)
6021 CALL field_parameter_sets_copy(dependent_field,dynamic_variable_type, &
6022 & field_previous_values_set_type,field_mean_predicted_displacement_set_type,1.0_dp, &
6026 CALL field_parameter_sets_copy(dependent_field,dynamic_variable_type, &
6027 & field_previous_values_set_type,field_predicted_displacement_set_type,1.0_dp, &
6032 CALL field_parameter_sets_add(dependent_field,dynamic_variable_type, &
6033 & [first_mean_prediction_factor,second_mean_prediction_factor], &
6034 & [field_previous_values_set_type,field_previous_velocity_set_type], &
6035 & field_mean_predicted_displacement_set_type,err,error,*999)
6037 CALL field_parameter_sets_copy(dependent_field,dynamic_variable_type, &
6038 & field_previous_velocity_set_type,field_mean_predicted_velocity_set_type,1.0_dp,err,error,*999)
6041 CALL field_parameter_sets_add(dependent_field,dynamic_variable_type, &
6042 & [first_prediction_factor,second_prediction_factor], &
6043 & [field_previous_values_set_type,field_previous_velocity_set_type], &
6044 & field_predicted_displacement_set_type,err,error,*999)
6049 CALL field_parameter_sets_add(dependent_field,dynamic_variable_type, &
6050 & [first_mean_prediction_factor,second_mean_prediction_factor, &
6051 & third_mean_prediction_factor],[field_previous_values_set_type, &
6052 & field_previous_velocity_set_type,field_previous_acceleration_set_type], &
6053 & field_mean_predicted_displacement_set_type,err,error,*999)
6055 CALL field_parameter_sets_add(dependent_field,dynamic_variable_type, &
6056 & [first_mean_prediction_factor,second_mean_prediction_factor], &
6057 & [field_previous_velocity_set_type,field_previous_acceleration_set_type], &
6058 & field_mean_predicted_velocity_set_type,err,error,*999)
6060 CALL field_parameter_sets_copy(dependent_field,dynamic_variable_type, &
6061 & field_previous_acceleration_set_type,field_mean_predicted_acceleration_set_type,1.0_dp, &
6066 CALL field_parameter_sets_add(dependent_field,dynamic_variable_type, &
6067 & [first_prediction_factor,second_prediction_factor, &
6068 & third_prediction_factor],[field_previous_values_set_type, &
6069 & field_previous_velocity_set_type,field_previous_acceleration_set_type], &
6070 & field_predicted_displacement_set_type,err,error,*999)
6073 local_error=
"The dynamic solver degree of "// &
6075 CALL flagerror(local_error,err,error,*999)
6080 nonlinear_mapping=>equations_mapping%NONLINEAR_MAPPING
6081 IF(
ASSOCIATED(nonlinear_mapping))
THEN 6082 dynamic_variable_type=field_u_variable_type
6083 IF(dynamic_solver%SOLVER_INITIALISED)
THEN 6088 CALL field_parameter_sets_copy(dependent_field,dynamic_variable_type,field_values_set_type, &
6089 & field_previous_values_set_type,1.0_dp,err,error,*999)
6091 CALL field_parameter_sets_copy(dependent_field,dynamic_variable_type, &
6092 & field_residual_set_type,field_previous_residual_set_type,1.0_dp, &
6096 SELECT CASE(dynamic_solver%DEGREE)
6099 CALL field_parameter_sets_copy(dependent_field,dynamic_variable_type, &
6100 & field_previous_values_set_type,field_mean_predicted_displacement_set_type,1.0_dp, &
6104 CALL field_parameter_sets_copy(dependent_field,dynamic_variable_type, &
6105 & field_previous_values_set_type,field_predicted_displacement_set_type,1.0_dp, &
6110 CALL field_parameter_sets_add(dependent_field,dynamic_variable_type, &
6111 & [first_mean_prediction_factor,second_mean_prediction_factor], &
6112 & [field_previous_values_set_type,field_previous_velocity_set_type], &
6113 & field_mean_predicted_displacement_set_type,err,error,*999)
6115 CALL field_parameter_sets_copy(dependent_field,dynamic_variable_type, &
6116 & field_previous_velocity_set_type,field_mean_predicted_velocity_set_type,1.0_dp,err,error,*999)
6119 CALL field_parameter_sets_add(dependent_field,dynamic_variable_type, &
6120 & [first_prediction_factor,second_prediction_factor], &
6121 & [field_previous_values_set_type,field_previous_velocity_set_type], &
6122 & field_predicted_displacement_set_type,err,error,*999)
6127 CALL field_parameter_sets_add(dependent_field,dynamic_variable_type, &
6128 & [first_mean_prediction_factor,second_mean_prediction_factor, &
6129 & third_mean_prediction_factor],[field_previous_values_set_type, &
6130 & field_previous_velocity_set_type,field_previous_acceleration_set_type], &
6131 & field_mean_predicted_displacement_set_type,err,error,*999)
6133 CALL field_parameter_sets_add(dependent_field,dynamic_variable_type, &
6134 & [first_mean_prediction_factor,second_mean_prediction_factor], &
6135 & [field_previous_velocity_set_type,field_previous_acceleration_set_type], &
6136 & field_mean_predicted_velocity_set_type,err,error,*999)
6138 CALL field_parameter_sets_copy(dependent_field,dynamic_variable_type, &
6139 & field_previous_acceleration_set_type,field_mean_predicted_acceleration_set_type,1.0_dp, &
6144 CALL field_parameter_sets_add(dependent_field,dynamic_variable_type, &
6145 & [first_prediction_factor,second_prediction_factor, &
6146 & third_prediction_factor],[field_previous_values_set_type, &
6147 & field_previous_velocity_set_type,field_previous_acceleration_set_type], &
6148 & field_predicted_displacement_set_type,err,error,*999)
6151 local_error=
"The dynamic solver degree of "// &
6153 CALL flagerror(local_error,err,error,*999)
6156 NULLIFY(nonlinear_mapping)
6158 local_error=
"Neither equations mapping dynamic mapping nor equations mapping nonlinear "// &
6159 &
"mapping is associated for equations set index number "// &
6161 CALL flagerror(local_error,err,error,*999)
6165 CALL flagerror(
"Equations equations mapping is not associated.",err,error,*999)
6168 CALL flagerror(
"Equations equations matrices is not associated.",err,error,*999)
6171 CALL flagerror(
"Equations set equations is not associated.",err,error,*999)
6174 CALL flagerror(
"Equations set is not associated.",err,error,*999)
6179 CALL flagerror(
"Solver solver matrices is not associated.",err,error,*999)
6182 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
6185 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
6188 CALL flagerror(
"Solver dynamic solver is not associated.",err,error,*999)
6191 CALL flagerror(
"Solver is not associated.",err,error,*999)
6194 exits(
"SOLVER_DYNAMIC_MEAN_PREDICTED_CALCULATE")
6196 999 errorsexits(
"SOLVER_DYNAMIC_MEAN_PREDICTED_CALCULATE",err,error)
6208 TYPE(solver_type),
POINTER :: SOLVER
6209 LOGICAL,
INTENT(OUT) :: RESTART
6210 INTEGER(INTG),
INTENT(OUT) :: ERR
6211 TYPE(varying_string),
INTENT(OUT) :: ERROR
6213 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
6215 enters(
"SOLVER_DYNAMIC_RESTART_GET",err,error,*999)
6217 IF(
ASSOCIATED(solver))
THEN 6218 IF(solver%SOLVER_FINISHED)
THEN 6220 dynamic_solver=>solver%DYNAMIC_SOLVER
6221 IF(
ASSOCIATED(dynamic_solver))
THEN 6222 restart=dynamic_solver%RESTART
6224 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
6227 CALL flagerror(
"The specified solver is not a dynamic solver.",err,error,*999)
6230 CALL flagerror(
"The solver has not been finished.",err,error,*999)
6233 CALL flagerror(
"Solver is not associated.",err,error,*999)
6236 exits(
"SOLVER_DYNAMIC_RESTART_GET")
6238 999 errorsexits(
"SOLVER_DYNAMIC_RESTART_GET",err,error)
6251 TYPE(solver_type),
POINTER :: SOLVER
6252 LOGICAL,
INTENT(IN) :: RESTART
6253 INTEGER(INTG),
INTENT(OUT) :: ERR
6254 TYPE(varying_string),
INTENT(OUT) :: ERROR
6256 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
6258 enters(
"SOLVER_DYNAMIC_RESTART_SET",err,error,*999)
6260 IF(
ASSOCIATED(solver))
THEN 6261 IF(solver%SOLVER_FINISHED)
THEN 6262 CALL flagerror(
"The solver has already been finished.",err,error,*999)
6265 dynamic_solver=>solver%DYNAMIC_SOLVER
6266 IF(
ASSOCIATED(dynamic_solver))
THEN 6267 dynamic_solver%RESTART=restart
6269 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
6272 CALL flagerror(
"The specified solver is not a dynamic solver.",err,error,*999)
6276 CALL flagerror(
"Solver is not associated.",err,error,*999)
6279 exits(
"SOLVER_DYNAMIC_RESTART_SET")
6281 999 errorsexits(
"SOLVER_DYNAMIC_RESTART_SET",err,error)
6294 TYPE(dae_solver_type),
POINTER :: DAE_SOLVER
6295 INTEGER(INTG),
INTENT(IN) :: STEPS
6296 REAL(DP),
INTENT(IN) :: TIME
6297 INTEGER(INTG),
INTENT(OUT) :: ERR
6298 TYPE(varying_string),
INTENT(OUT) :: ERROR
6301 enters(
"SOLVER_TIME_STEPPING_MONITOR",err,error,*999)
6303 IF(
ASSOCIATED(dae_solver))
THEN 6305 CALL write_string(general_output_type,
"",err,error,*999)
6306 CALL write_string(general_output_type,
"Differential-algebraic equations solve monitor: ",err,error,*999)
6307 CALL write_string(general_output_type,
"",err,error,*999)
6308 CALL write_string_value(general_output_type,
" Number of steps = ",steps,err,error,*999)
6309 CALL write_string_value(general_output_type,
" Current time = ",time,err,error,*999)
6312 CALL flagerror(
"Differential-algebraic equations solver is not associated.",err,error,*999)
6315 exits(
"SOLVER_TIME_STEPPING_MONITOR")
6317 999 errorsexits(
"SOLVER_TIME_STEPPING_MONITOR",err,error)
6329 TYPE(solver_type),
POINTER :: SOLVER
6330 INTEGER(INTG),
INTENT(IN) :: ORDER
6331 INTEGER(INTG),
INTENT(OUT) :: ERR
6332 TYPE(varying_string),
INTENT(OUT) :: ERROR
6334 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
6335 TYPE(varying_string) :: LOCAL_ERROR
6337 enters(
"SOLVER_DYNAMIC_ORDER_SET",err,error,*999)
6339 IF(
ASSOCIATED(solver))
THEN 6340 IF(solver%SOLVER_FINISHED)
THEN 6341 CALL flagerror(
"The solver has already been finished.",err,error,*999)
6344 dynamic_solver=>solver%DYNAMIC_SOLVER
6345 IF(
ASSOCIATED(dynamic_solver))
THEN 6347 local_error=
"Invalid dynamic solver degree. You must have at least a second degree polynomial "// &
6348 &
"interpolation for a second order dynamic solver." 6349 CALL flagerror(local_error,err,error,*999)
6357 local_error=
"The specified order of "//trim(numbertovstring(order,
"*",err,error))//
" is invalid." 6358 CALL flagerror(local_error,err,error,*999)
6362 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
6365 CALL flagerror(
"The specified solver is not a dynamic solver.",err,error,*999)
6369 CALL flagerror(
"Solver is not associated.",err,error,*999)
6372 exits(
"SOLVER_DYNAMIC_ORDER_SET")
6374 999 errorsexits(
"SOLVER_DYNAMIC_ORDER_SET",err,error)
6386 TYPE(solver_type),
POINTER :: SOLVER
6387 INTEGER(INTG),
INTENT(IN) :: SCHEME
6388 INTEGER(INTG),
INTENT(OUT) :: ERR
6389 TYPE(varying_string),
INTENT(OUT) :: ERROR
6391 REAL(DP) :: ALPHA,BETA,GAMMA,THETA
6392 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
6393 TYPE(varying_string) :: LOCAL_ERROR
6395 enters(
"SOLVER_DYNAMIC_SCHEME_SET",err,error,*999)
6397 IF(
ASSOCIATED(solver))
THEN 6398 IF(solver%SOLVER_FINISHED)
THEN 6399 CALL flagerror(
"The solver has already been finished.",err,error,*999)
6402 dynamic_solver=>solver%DYNAMIC_SOLVER
6403 IF(
ASSOCIATED(dynamic_solver))
THEN 6505 beta=1.0_dp/6.0_dp-1.0_dp/2.0_dp*alpha
6506 gamma=1.0_dp/2.0_dp-alpha
6516 & 6.0_dp*beta*(1.0_dp+alpha)],err,error,*999)
6525 & 6.0_dp*beta*(1.0_dp+alpha)],err,error,*999)
6529 local_error=
"The specified scheme of "//trim(numbertovstring(scheme,
"*",err,error))//
" is invalid." 6530 CALL flagerror(local_error,err,error,*999)
6533 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
6536 CALL flagerror(
"The specified solver is not a dynamic solver.",err,error,*999)
6540 CALL flagerror(
"Solver is not associated.",err,error,*999)
6543 exits(
"SOLVER_DYNAMIC_SCHEME_SET")
6545 999 errorsexits(
"SOLVER_DYNAMIC_SCHEME_SET",err,error)
6557 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
6558 INTEGER(INTG),
INTENT(OUT) :: ERR
6559 TYPE(varying_string),
INTENT(OUT) :: ERROR
6561 INTEGER(INTG) :: solver_matrix_idx
6562 TYPE(solver_type),
POINTER :: LINEAR_SOLVER,SOLVER,NONLINEAR_SOLVER
6563 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
6564 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
6565 TYPE(varying_string) :: LOCAL_ERROR
6567 enters(
"SOLVER_DYNAMIC_SOLVE",err,error,*999)
6569 IF(
ASSOCIATED(dynamic_solver))
THEN 6570 SELECT CASE(dynamic_solver%SOLVER_LIBRARY)
6572 solver=>dynamic_solver%SOLVER
6573 IF(
ASSOCIATED(solver))
THEN 6574 SELECT CASE(dynamic_solver%LINEARITY)
6577 linear_solver=>dynamic_solver%LINEAR_SOLVER
6578 IF(
ASSOCIATED(linear_solver))
THEN 6579 IF(dynamic_solver%SOLVER_INITIALISED)
THEN 6600 dynamic_solver%SOLVER_INITIALISED=.true.
6603 CALL flagerror(
"Dynamic solver linear solver is not associated.",err,error,*999)
6607 nonlinear_solver=>dynamic_solver%NONLINEAR_SOLVER
6608 IF(
ASSOCIATED(nonlinear_solver))
THEN 6609 IF(dynamic_solver%SOLVER_INITIALISED)
THEN 6623 dynamic_solver%SOLVER_INITIALISED=.true.
6626 CALL flagerror(
"Dynamic solver nonlinear solver is not associated.",err,error,*999)
6629 local_error=
"The dynamic solver linearity type of "// &
6630 & trim(numbertovstring(dynamic_solver%LINEARITY,
"*",err,error))//
" is invalid." 6631 CALL flagerror(local_error,err,error,*999)
6637 CALL tau_static_phase_start(
"Solution Output Phase")
6639 solver_equations=>solver%SOLVER_EQUATIONS
6640 IF(
ASSOCIATED(solver_equations))
THEN 6641 solver_matrices=>solver_equations%SOLVER_MATRICES
6642 IF(
ASSOCIATED(solver_matrices))
THEN 6643 CALL write_string(general_output_type,
"",err,error,*999)
6644 CALL write_string(general_output_type,
"Solver solution vectors:",err,error,*999)
6645 CALL write_string_value(general_output_type,
"Number of solution vectors = ",solver_matrices%NUMBER_OF_MATRICES, &
6647 DO solver_matrix_idx=1,solver_matrices%NUMBER_OF_MATRICES
6648 CALL write_string_value(general_output_type,
"Solution vector for solver matrix : ",solver_matrix_idx, &
6650 CALL distributed_vector_output(general_output_type,solver_matrices%MATRICES(solver_matrix_idx)%PTR% &
6651 & solver_vector,err,error,*999)
6654 CALL flagerror(
"Solver equations solver matrices is not associated.",err,error,*999)
6657 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
6661 CALL tau_static_phase_stop(
"Solution Output Phase")
6665 CALL flagerror(
"Dynamic solver solver is not associated.",err,error,*999)
6668 CALL flagerror(
"Not implemented.",err,error,*999)
6670 local_error=
"The solver library type of "// &
6671 & trim(numbertovstring(dynamic_solver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid." 6672 CALL flagerror(local_error,err,error,*999)
6675 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
6678 exits(
"SOLVER_DYNAMIC_SOLVE")
6680 999 errorsexits(
"SOLVER_DYNAMIC_SOLVE",err,error)
6693 TYPE(solver_type),
POINTER :: SOLVER
6694 REAL(DP),
INTENT(IN) :: THETA
6695 INTEGER(INTG),
INTENT(OUT) :: ERR
6696 TYPE(varying_string),
INTENT(OUT) :: ERROR
6699 enters(
"SOLVER_DYNAMIC_THETA_SET_DP1",err,error,*999)
6703 exits(
"SOLVER_DYNAMIC_THETA_SET_DP1")
6705 999 errorsexits(
"SOLVER_DYNAMIC_THETA_SET_DP1",err,error)
6717 TYPE(solver_type),
POINTER :: SOLVER
6718 REAL(DP),
INTENT(IN) :: THETA(:)
6719 INTEGER(INTG),
INTENT(OUT) :: ERR
6720 TYPE(varying_string),
INTENT(OUT) :: ERROR
6722 INTEGER(INTG) :: degree_idx
6723 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
6724 TYPE(varying_string) :: LOCAL_ERROR
6726 enters(
"SOLVER_DYNAMIC_THETA_SET_DP",err,error,*999)
6728 IF(
ASSOCIATED(solver))
THEN 6729 IF(solver%SOLVER_FINISHED)
THEN 6730 CALL flagerror(
"The solver has already been finished.",err,error,*999)
6733 dynamic_solver=>solver%DYNAMIC_SOLVER
6734 IF(
ASSOCIATED(dynamic_solver))
THEN 6735 IF(
SIZE(theta,1)>=dynamic_solver%DEGREE)
THEN 6736 DO degree_idx=1,dynamic_solver%DEGREE
6737 IF(theta(degree_idx)>=0.0_dp)
THEN 6738 dynamic_solver%THETA(degree_idx)=theta(degree_idx)
6740 local_error=
"The specified theta "//trim(numbertovstring(degree_idx,
"*",err,error))// &
6741 &
" value of "//trim(numbertovstring(theta(degree_idx),
"*",err,error))// &
6742 &
" is invalid. The theta value must be >= 0.0." 6743 CALL flagerror(local_error,err,error,*999)
6747 local_error=
"Invalid number of the thetas. The supplied number of thetas ("// &
6748 & trim(numbertovstring(
SIZE(theta,1),
"*",err,error))//
") must be equal to the interpolation degree ("// &
6749 & trim(numbertovstring(dynamic_solver%DEGREE,
"*",err,error))//
")." 6750 CALL flagerror(local_error,err,error,*999)
6753 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
6756 CALL flagerror(
"The specified solver is not a dynamic solver.",err,error,*999)
6760 CALL flagerror(
"Solver is not associated.",err,error,*999)
6763 exits(
"SOLVER_DYNAMIC_THETA_SET_DP")
6765 999 errorsexits(
"SOLVER_DYNAMIC_THETA_SET_DP",err,error)
6777 TYPE(solver_type),
POINTER :: SOLVER
6779 INTEGER(INTG),
INTENT(OUT) :: ERR
6780 TYPE(varying_string),
INTENT(OUT) :: ERROR
6783 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
6786 enters(
"SOLVER_DYNAMIC_ALE_SET",err,error,*999)
6788 IF(
ASSOCIATED(solver))
THEN 6789 IF(solver%SOLVER_FINISHED)
THEN 6790 CALL flagerror(
"The solver has already been finished.",err,error,*999)
6793 dynamic_solver=>solver%DYNAMIC_SOLVER
6794 IF(
ASSOCIATED(dynamic_solver))
THEN 6795 dynamic_solver%ALE=ale
6797 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
6800 CALL flagerror(
"The specified solver is not a dynamic solver.",err,error,*999)
6804 CALL flagerror(
"Solver is not associated.",err,error,*999)
6807 exits(
"SOLVER_DYNAMIC_ALE_SET")
6809 999 errorsexits(
"SOLVER_DYNAMIC_ALE_SET",err,error)
6821 TYPE(solver_type),
POINTER :: SOLVER
6822 LOGICAL :: UPDATE_BC
6823 INTEGER(INTG),
INTENT(OUT) :: ERR
6824 TYPE(varying_string),
INTENT(OUT) :: ERROR
6827 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
6830 enters(
"SOLVER_DYNAMIC_UPDATE_BC_SET",err,error,*999)
6832 IF(
ASSOCIATED(solver))
THEN 6833 IF(solver%SOLVER_FINISHED)
THEN 6834 CALL flagerror(
"The solver has already been finished.",err,error,*999)
6837 dynamic_solver=>solver%DYNAMIC_SOLVER
6838 IF(
ASSOCIATED(dynamic_solver))
THEN 6839 dynamic_solver%UPDATE_BC=update_bc
6841 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
6844 CALL flagerror(
"The specified solver is not a dynamic solver.",err,error,*999)
6848 CALL flagerror(
"Solver is not associated.",err,error,*999)
6851 exits(
"SOLVER_DYNAMIC_UPDATE_BC_SET")
6853 999 errorsexits(
"SOLVER_DYNAMIC_UPDATE_BC_SET",err,error)
6865 TYPE(solver_type),
POINTER :: SOLVER
6866 REAL(DP),
INTENT(IN) :: CURRENT_TIME
6867 REAL(DP),
INTENT(IN) :: TIME_INCREMENT
6868 INTEGER(INTG),
INTENT(OUT) :: ERR
6869 TYPE(varying_string),
INTENT(OUT) :: ERROR
6871 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
6872 TYPE(varying_string) :: LOCAL_ERROR
6874 enters(
"SOLVER_DYNAMIC_TIMES_SET",err,error,*999)
6876 IF(
ASSOCIATED(solver))
THEN 6879 dynamic_solver=>solver%DYNAMIC_SOLVER
6880 IF(
ASSOCIATED(dynamic_solver))
THEN 6881 IF(abs(time_increment)<=zero_tolerance)
THEN 6882 local_error=
"The specified time increment of "//trim(numbertovstring(time_increment,
"*",err,error))// &
6883 &
" is invalid. The time increment must not be zero." 6884 CALL flagerror(local_error,err,error,*999)
6886 dynamic_solver%CURRENT_TIME=current_time
6887 dynamic_solver%TIME_INCREMENT=time_increment
6890 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
6893 CALL flagerror(
"The specified solver is not a dynamic solver.",err,error,*999)
6896 CALL flagerror(
"Solver is not associated.",err,error,*999)
6899 exits(
"SOLVER_DYNAMIC_TIMES_SET")
6901 999 errorsexits(
"SOLVER_DYNAMIC_TIMES_SET",err,error)
6913 TYPE(eigenproblem_solver_type),
POINTER :: EIGENPROBLEM_SOLVER
6914 INTEGER(INTG),
INTENT(OUT) :: ERR
6915 TYPE(varying_string),
INTENT(OUT) :: ERROR
6918 enters(
"SOLVER_EIGENPROBLEM_CREATE_FINISH",err,error,*999)
6920 IF(
ASSOCIATED(eigenproblem_solver))
THEN 6921 CALL flagerror(
"Not implemented.",err,error,*999)
6923 CALL flagerror(
"Eigenproblem solver is not associated.",err,error,*999)
6926 exits(
"SOLVER_EIGENPROBLEM_CREATE_FINISH")
6928 999 errorsexits(
"SOLVER_EIGENPROBLEM_CREATE_FINISH",err,error)
6941 TYPE(eigenproblem_solver_type),
POINTER :: EIGENPROBLEM_SOLVER
6942 INTEGER(INTG),
INTENT(OUT) :: ERR
6943 TYPE(varying_string),
INTENT(OUT) :: ERROR
6946 enters(
"SOLVER_EIGENPROBLEM_FINALISE",err,error,*999)
6948 IF(
ASSOCIATED(eigenproblem_solver))
THEN 6949 DEALLOCATE(eigenproblem_solver)
6952 exits(
"SOLVER_EIGENPROBLEM_FINALISE")
6954 999 errorsexits(
"SOLVER_EIGENPROBLEM_FINALISE",err,error)
6967 TYPE(solver_type),
POINTER :: SOLVER
6968 INTEGER(INTG),
INTENT(OUT) :: ERR
6969 TYPE(varying_string),
INTENT(OUT) :: ERROR
6971 INTEGER(INTG) :: DUMMY_ERR
6972 TYPE(varying_string) :: DUMMY_ERROR
6974 enters(
"SOLVER_EIGENPROBLEM_INITIALISE",err,error,*998)
6976 IF(
ASSOCIATED(solver))
THEN 6977 IF(
ASSOCIATED(solver%EIGENPROBLEM_SOLVER))
THEN 6978 CALL flagerror(
"Eigenproblem solver is already associated for this solver.",err,error,*998)
6980 ALLOCATE(solver%EIGENPROBLEM_SOLVER,stat=err)
6981 IF(err/=0)
CALL flagerror(
"Could not allocate solver eigenproblem solver.",err,error,*999)
6982 solver%EIGENPROBLEM_SOLVER%SOLVER=>solver
6984 solver%EIGENPROBLEM_SOLVER%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
6987 CALL flagerror(
"Solver is not associated.",err,error,*998)
6990 exits(
"SOLVER_EIGENPROBLEM_INITIALISE")
6993 998 errorsexits(
"SOLVER_EIGENPROBLEM_INITIALISE",err,error)
7006 TYPE(eigenproblem_solver_type),
POINTER :: EIGENPROBLEM_SOLVER
7007 INTEGER(INTG),
INTENT(OUT) :: SOLVER_LIBRARY_TYPE
7008 INTEGER(INTG),
INTENT(OUT) :: ERR
7009 TYPE(varying_string),
INTENT(OUT) :: ERROR
7012 enters(
"SOLVER_EIGENPROBLEM_LIBRARY_TYPE_GET",err,error,*999)
7014 IF(
ASSOCIATED(eigenproblem_solver))
THEN 7015 solver_library_type=eigenproblem_solver%SOLVER_LIBRARY
7017 CALL flagerror(
"Eigenproblem solver is not associated.",err,error,*999)
7020 exits(
"SOLVER_EIGENPROBLEM_LIBRARY_TYPE_GET")
7022 999 errorsexits(
"SOLVER_EIGENPROBLEM_LIBRARY_TYPE_GET",err,error)
7035 TYPE(eigenproblem_solver_type),
POINTER :: EIGENPROBLEM_SOLVER
7036 INTEGER(INTG),
INTENT(IN) :: SOLVER_LIBRARY_TYPE
7037 INTEGER(INTG),
INTENT(OUT) :: ERR
7038 TYPE(varying_string),
INTENT(OUT) :: ERROR
7040 TYPE(varying_string) :: LOCAL_ERROR
7042 enters(
"SOLVER_EIGENPROBLEM_LIBRARY_TYPE_SET",err,error,*999)
7044 IF(
ASSOCIATED(eigenproblem_solver))
THEN 7045 SELECT CASE(solver_library_type)
7047 CALL flagerror(
"Not implemented.",err,error,*999)
7049 local_error=
"The specified solver library type of "//trim(numbertovstring(solver_library_type,
"*",err,error))// &
7050 &
" is invalid for an eigenproblem solver." 7051 CALL flagerror(local_error,err,error,*999)
7054 CALL flagerror(
"Dynamic solver is not associated.",err,error,*999)
7057 exits(
"SOLVER_EIGENPROBLEM_LIBRARY_TYPE_SET")
7059 999 errorsexits(
"SOLVER_EIGENPROBLEM_LIBRARY_TYPE_SET",err,error)
7072 TYPE(eigenproblem_solver_type),
POINTER :: EIGENPROBLEM_SOLVER
7073 INTEGER(INTG),
INTENT(OUT) :: MATRICES_LIBRARY_TYPE
7074 INTEGER(INTG),
INTENT(OUT) :: ERR
7075 TYPE(varying_string),
INTENT(OUT) :: ERROR
7078 enters(
"Solver_EigenproblemMatricesLibraryTypeGet",err,error,*999)
7080 IF(
ASSOCIATED(eigenproblem_solver))
THEN 7081 matrices_library_type=eigenproblem_solver%SOLVER_MATRICES_LIBRARY
7083 CALL flagerror(
"Eigenproblem solver is not associated.",err,error,*999)
7086 exits(
"Solver_EigenproblemMatricesLibraryTypeGet")
7088 999 errorsexits(
"Solver_EigenproblemMatricesLibraryTypeGet",err,error)
7101 TYPE(eigenproblem_solver_type),
POINTER :: EIGENPROBLEM_SOLVER
7102 INTEGER(INTG),
INTENT(OUT) :: ERR
7103 TYPE(varying_string),
INTENT(OUT) :: ERROR
7106 enters(
"SOLVER_EIGENPROBLEM_SOLVE",err,error,*999)
7108 IF(
ASSOCIATED(eigenproblem_solver))
THEN 7109 CALL flagerror(
"Not implemented.",err,error,*999)
7111 CALL flagerror(
"Eigenproblem solver is not associated.",err,error,*999)
7114 exits(
"SOLVER_EIGENPROBLEM_SOLVE")
7116 999 errorsexits(
"SOLVER_EIGENPROBLEM_SOLVE",err,error)
7129 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
7130 TYPE(boundary_conditions_type),
POINTER :: BOUNDARY_CONDITIONS
7131 INTEGER(INTG),
INTENT(OUT) :: ERR
7132 TYPE(varying_string),
INTENT(OUT) :: ERROR
7135 enters(
"SOLVER_EQUATIONS_BOUNDARY_CONDITIONS_GET",err,error,*999)
7137 IF(
ASSOCIATED(solver_equations))
THEN 7138 IF(solver_equations%SOLVER_EQUATIONS_FINISHED)
THEN 7139 IF(
ASSOCIATED(boundary_conditions))
THEN 7140 CALL flagerror(
"Boundary conditions is already associated.",err,error,*999)
7142 boundary_conditions=>solver_equations%BOUNDARY_CONDITIONS
7143 IF(.NOT.
ASSOCIATED(boundary_conditions))
CALL flagerror(
"Solver equations boundary conditions is not associated.", &
7147 CALL flagerror(
"Solver equations has not been finished.",err,error,*999)
7150 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
7153 exits(
"SOLVER_EQUATIONS_BOUNDARY_CONDITIONS_GET")
7155 999 errorsexits(
"SOLVER_EQUATIONS_BOUNDARY_CONDITIONS_GET",err,error)
7168 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
7169 INTEGER(INTG),
INTENT(OUT) :: ERR
7170 TYPE(varying_string),
INTENT(OUT) :: ERROR
7172 TYPE(solver_type),
POINTER :: SOLVER
7174 enters(
"SOLVER_EQUATIONS_CREATE_FINISH",err,error,*998)
7176 IF(
ASSOCIATED(solver_equations))
THEN 7177 IF(solver_equations%SOLVER_EQUATIONS_FINISHED)
THEN 7178 CALL flagerror(
"Solver equations has already been finished.",err,error,*998)
7180 solver=>solver_equations%SOLVER
7181 IF(
ASSOCIATED(solver))
THEN 7182 IF(
ASSOCIATED(solver%LINKING_SOLVER))
THEN 7183 CALL flagerror(
"Can not finish solver equations creation for a solver that has been linked.",err,error,*999)
7185 solver_equations%SOLVER_EQUATIONS_FINISHED=.true.
7188 CALL flagerror(
"Solver equations solver is not associated.",err,error,*999)
7192 CALL flagerror(
"Solver equations is not associated.",err,error,*998)
7195 exits(
"SOLVER_EQUATIONS_CREATE_FINISH")
7198 998 errorsexits(
"SOLVER_EQUATIONS_CREATE_FINISH",err,error)
7211 TYPE(solver_type),
POINTER :: SOLVER
7212 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
7213 INTEGER(INTG),
INTENT(OUT) :: ERR
7214 TYPE(varying_string),
INTENT(OUT) :: ERROR
7216 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
7217 TYPE(varying_string) :: LOCAL_ERROR
7219 enters(
"SOLVER_EQUATIONS_CREATE_START",err,error,*999)
7221 IF(
ASSOCIATED(solver))
THEN 7222 IF(solver%SOLVER_FINISHED)
THEN 7223 IF(
ASSOCIATED(solver%LINKING_SOLVER))
THEN 7224 CALL flagerror(
"Can not start solver equations creation for a solver that has been linked.",err,error,*999)
7226 IF(
ASSOCIATED(solver_equations))
THEN 7227 CALL flagerror(
"Solver equations is already associated.",err,error,*999)
7229 NULLIFY(solver_equations)
7231 NULLIFY(solver_mapping)
7232 CALL solver_mapping_create_start(solver%SOLVER_EQUATIONS,solver_mapping,err,error,*999)
7233 SELECT CASE(solver%SOLVE_TYPE)
7235 CALL solver_mapping_solver_matrices_number_set(solver_mapping,1,err,error,*999)
7237 CALL solver_mapping_solver_matrices_number_set(solver_mapping,1,err,error,*999)
7239 CALL solver_mapping_solver_matrices_number_set(solver_mapping,1,err,error,*999)
7241 CALL solver_mapping_solver_matrices_number_set(solver_mapping,0,err,error,*999)
7243 CALL solver_mapping_solver_matrices_number_set(solver_mapping,2,err,error,*999)
7245 local_error=
"The solver type of "//trim(numbertovstring(solver%SOLVE_TYPE,
"*",err,error))//
" is invalid." 7246 CALL flagerror(local_error,err,error,*999)
7248 solver_equations=>solver%SOLVER_EQUATIONS
7252 CALL flagerror(
"Solver has not been finished.",err,error,*999)
7255 CALL flagerror(
"Solver is not associated.",err,error,*999)
7258 exits(
"SOLVER_EQUATIONS_CREATE_START")
7260 999 errorsexits(
"SOLVER_EQUATIONS_CREATE_START",err,error)
7273 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
7274 INTEGER(INTG),
INTENT(OUT) :: ERR
7275 TYPE(varying_string),
INTENT(OUT) :: ERROR
7278 enters(
"SOLVER_EQUATIONS_DESTROY",err,error,*999)
7280 IF(
ASSOCIATED(solver_equations))
THEN 7283 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
7286 exits(
"SOLVER_EQUATIONS_DESTROY")
7288 999 errorsexits(
"SOLVER_EQUATIONS_DESTROY",err,error)
7301 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
7302 TYPE(equations_set_type),
POINTER :: EQUATIONS_SET
7303 INTEGER(INTG),
INTENT(OUT) :: EQUATIONS_SET_INDEX
7304 INTEGER(INTG),
INTENT(OUT) :: ERR
7305 TYPE(varying_string),
INTENT(OUT) :: ERROR
7307 TYPE(equations_type),
POINTER :: EQUATIONS
7308 TYPE(solver_type),
POINTER :: SOLVER
7309 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
7310 TYPE(varying_string) :: LOCAL_ERROR
7311 LOGICAL :: TIME_COMPATIBLE,LINEARITY_COMPATIBLE
7313 enters(
"SOLVER_EQUATIONS_EQUATIONS_SET_ADD",err,error,*999)
7315 IF(
ASSOCIATED(solver_equations))
THEN 7316 IF(solver_equations%SOLVER_EQUATIONS_FINISHED)
THEN 7317 CALL flagerror(
"Solver equations has already been finished.",err,error,*999)
7319 solver=>solver_equations%SOLVER
7320 IF(
ASSOCIATED(solver))
THEN 7321 IF(
ASSOCIATED(solver%LINKING_SOLVER))
THEN 7322 CALL flagerror(
"Can not add an equations set for a solver that has been linked.",err,error,*999)
7324 solver_mapping=>solver_equations%SOLVER_MAPPING
7325 IF(
ASSOCIATED(solver_mapping))
THEN 7326 IF(
ASSOCIATED(equations_set))
THEN 7327 equations=>equations_set%EQUATIONS
7328 IF(
ASSOCIATED(equations))
THEN 7329 time_compatible=.true.
7330 linearity_compatible=.true.
7332 SELECT CASE(solver_equations%TIME_DEPENDENCE)
7333 CASE(solver_equations_static,solver_equations_quasistatic)
7334 SELECT CASE(equations%TIME_DEPENDENCE)
7335 CASE(equations_static,equations_quasistatic)
7338 time_compatible=.false.
7340 CASE(solver_equations_first_order_dynamic)
7341 SELECT CASE(equations%TIME_DEPENDENCE)
7343 CASE(equations_static)
7346 CASE(equations_quasistatic)
7348 time_compatible=.false.
7349 local_error=
"Static equations set equations with dynamic solver equations is not yet implemented." 7350 CALL flagerror(local_error,err,error,*999)
7351 CASE(equations_first_order_dynamic)
7354 time_compatible=.false.
7356 CASE(solver_equations_second_order_dynamic)
7357 SELECT CASE(equations%TIME_DEPENDENCE)
7358 CASE(equations_static,equations_quasistatic,equations_first_order_dynamic)
7360 time_compatible=.false.
7361 local_error=
"Static or first order dynamic equations set equations with a second order dynamic "// &
7362 &
"solver equations is not yet implemented." 7363 CALL flagerror(local_error,err,error,*999)
7364 CASE(equations_second_order_dynamic)
7367 time_compatible=.false.
7370 time_compatible=.false.
7371 local_error=
"Invalid time dependence for solver equations, "// &
7372 & trim(numbertovstring(solver_equations%TIME_DEPENDENCE,
"*",err,error))//
"." 7373 CALL flagerror(local_error,err,error,*999)
7375 IF (.NOT. time_compatible)
THEN 7376 local_error=
"Invalid equations set up. The time dependence of the equations set to add ("// &
7377 & trim(numbertovstring(equations%TIME_DEPENDENCE,
"*",err,error))// &
7378 &
") is not compatible with the solver equations time dependence ("// &
7379 & trim(numbertovstring(solver_equations%TIME_DEPENDENCE,
"*",err,error))//
")." 7380 CALL flagerror(local_error,err,error,*999)
7383 SELECT CASE(solver_equations%LINEARITY)
7384 CASE(solver_equations_linear)
7385 SELECT CASE(equations%LINEARITY)
7386 CASE(equations_linear)
7389 linearity_compatible=.false.
7391 CASE(solver_equations_nonlinear)
7392 SELECT CASE(equations%LINEARITY)
7393 CASE(equations_linear,equations_nonlinear)
7396 linearity_compatible=.false.
7399 linearity_compatible=.false.
7400 local_error=
"Invalid linearity for solver equations, "// &
7401 & trim(numbertovstring(solver_equations%LINEARITY,
"*",err,error))//
"." 7402 CALL flagerror(local_error,err,error,*999)
7404 IF (.NOT. linearity_compatible)
THEN 7405 local_error=
"Invalid equations set up. The linearity of the equations set to add ("// &
7406 & trim(numbertovstring(equations%TIME_DEPENDENCE,
"*",err,error))// &
7407 &
") is not compatible with the solver equations linearity ("// &
7408 & trim(numbertovstring(solver_equations%TIME_DEPENDENCE,
"*",err,error))//
")." 7409 CALL flagerror(local_error,err,error,*999)
7411 IF (time_compatible .AND. linearity_compatible)
THEN 7412 CALL solver_mapping_equations_set_add(solver_mapping,equations_set,equations_set_index,err,error,*999)
7415 CALL flagerror(
"Equations set equations is not associated.",err,error,*999)
7418 CALL flagerror(
"Equations set is not associated.",err,error,*999)
7421 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
7425 CALL flagerror(
"Solver equations solver is not associated.",err,error,*999)
7429 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
7432 exits(
"SOLVER_EQUATIONS_EQUATIONS_SET_ADD")
7434 999 errorsexits(
"SOLVER_EQUATIONS_EQUATIONS_SET_ADD",err,error)
7447 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
7448 INTEGER(INTG),
INTENT(OUT) :: ERR
7449 TYPE(varying_string),
INTENT(OUT) :: ERROR
7452 enters(
"SOLVER_EQUATIONS_FINALISE",err,error,*999)
7454 IF(
ASSOCIATED(solver_equations))
THEN 7455 IF(
ASSOCIATED(solver_equations%SOLVER_MAPPING))
CALL solver_mapping_destroy(solver_equations%SOLVER_MAPPING,err,error,*999)
7456 IF(
ASSOCIATED(solver_equations%SOLVER_MATRICES))
CALL solver_matrices_destroy(solver_equations%SOLVER_MATRICES,err,error,*999)
7457 IF(
ASSOCIATED(solver_equations%BOUNDARY_CONDITIONS))
CALL boundary_conditions_destroy( &
7458 & solver_equations%BOUNDARY_CONDITIONS,err,error,*999)
7461 exits(
"SOLVER_EQUATIONS_FINALISE")
7463 999 errorsexits(
"SOLVER_EQUATIONS_FINALISE",err,error)
7476 TYPE(solver_type),
POINTER :: SOLVER
7477 INTEGER(INTG),
INTENT(OUT) :: ERR
7478 TYPE(varying_string),
INTENT(OUT) :: ERROR
7480 INTEGER(INTG) :: DUMMY_ERR
7481 TYPE(varying_string) :: DUMMY_ERROR
7483 enters(
"SOLVER_EQUATIONS_INITIALISE",err,error,*998)
7485 IF(
ASSOCIATED(solver))
THEN 7486 IF(
ASSOCIATED(solver%SOLVER_EQUATIONS))
THEN 7487 CALL flagerror(
"Solver equations is already associated for this solver.",err,error,*998)
7489 ALLOCATE(solver%SOLVER_EQUATIONS,stat=err)
7490 IF(err/=0)
CALL flagerror(
"Could not allocate solver equations.",err,error,*999)
7491 solver%SOLVER_EQUATIONS%SOLVER=>solver
7492 solver%SOLVER_EQUATIONS%SOLVER_EQUATIONS_FINISHED=.false.
7494 NULLIFY(solver%SOLVER_EQUATIONS%SOLVER_MAPPING)
7495 NULLIFY(solver%SOLVER_EQUATIONS%SOLVER_MATRICES)
7496 NULLIFY(solver%SOLVER_EQUATIONS%BOUNDARY_CONDITIONS)
7499 CALL flagerror(
"Solver is not associated.",err,error,*998)
7502 exits(
"SOLVER_EQUATIONS_INITIALISE")
7505 998 errorsexits(
"SOLVER_EQUATIONS_INITIALISE",err,error)
7518 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
7519 TYPE(interface_condition_type),
POINTER :: INTERFACE_CONDITION
7520 INTEGER(INTG),
INTENT(OUT) :: INTERFACE_CONDITION_INDEX
7521 INTEGER(INTG),
INTENT(OUT) :: ERR
7522 TYPE(varying_string),
INTENT(OUT) :: ERROR
7524 TYPE(interface_equations_type),
POINTER :: INTERFACE_EQUATIONS
7525 TYPE(solver_type),
POINTER :: SOLVER
7526 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
7528 enters(
"SOLVER_EQUATIONS_INTERFACE_CONDITION_ADD",err,error,*999)
7530 IF(
ASSOCIATED(solver_equations))
THEN 7531 IF(solver_equations%SOLVER_EQUATIONS_FINISHED)
THEN 7532 CALL flagerror(
"Solver equations has already been finished.",err,error,*999)
7534 solver=>solver_equations%SOLVER
7535 IF(
ASSOCIATED(solver))
THEN 7536 IF(
ASSOCIATED(solver%LINKING_SOLVER))
THEN 7537 CALL flagerror(
"Can not add an equations set for a solver that has been linked.",err,error,*999)
7539 solver_mapping=>solver_equations%SOLVER_MAPPING
7540 IF(
ASSOCIATED(solver_mapping))
THEN 7541 IF(
ASSOCIATED(interface_condition))
THEN 7542 interface_equations=>interface_condition%INTERFACE_EQUATIONS
7543 IF(
ASSOCIATED(interface_equations))
THEN 7544 CALL solver_mapping_interface_condition_add(solver_mapping,interface_condition,interface_condition_index, &
7547 CALL flagerror(
"Interface condition interface equations is not associated.",err,error,*999)
7550 CALL flagerror(
"Interface condition is not associated.",err,error,*999)
7553 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
7557 CALL flagerror(
"Solver equations solver is not associated.",err,error,*999)
7561 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
7564 exits(
"SOLVER_EQUATIONS_INTERFACE_CONDITION_ADD")
7566 999 errorsexits(
"SOLVER_EQUATIONS_INTERFACE_CONDITION_ADD",err,error)
7579 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
7580 INTEGER(INTG),
INTENT(IN) :: LINEARITY_TYPE
7581 INTEGER(INTG),
INTENT(OUT) :: ERR
7582 TYPE(varying_string),
INTENT(OUT) :: ERROR
7584 TYPE(solver_type),
POINTER :: SOLVER
7585 TYPE(varying_string) :: LOCAL_ERROR
7587 enters(
"SOLVER_EQUATIONS_LINEARITY_TYPE_SET",err,error,*999)
7589 IF(
ASSOCIATED(solver_equations))
THEN 7590 IF(solver_equations%SOLVER_EQUATIONS_FINISHED)
THEN 7591 CALL flagerror(
"Solver equations has already been finished.",err,error,*999)
7593 solver=>solver_equations%SOLVER
7594 IF(
ASSOCIATED(solver))
THEN 7595 IF(
ASSOCIATED(solver%LINKING_SOLVER))
THEN 7596 CALL flagerror(
"Can not set equations linearity for a solver that has been linked.",err,error,*999)
7598 SELECT CASE(linearity_type)
7599 CASE(solver_equations_linear)
7600 solver_equations%LINEARITY=solver_equations_linear
7601 CASE(solver_equations_nonlinear)
7602 solver_equations%LINEARITY=solver_equations_nonlinear
7604 local_error=
"The specified solver equations linearity type of "// &
7605 & trim(numbertovstring(linearity_type,
"*",err,error))//
" is invalid." 7606 CALL flagerror(local_error,err,error,*999)
7610 CALL flagerror(
"Solver equations solver is not associated.",err,error,*999)
7614 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
7617 exits(
"SOLVER_EQUATIONS_LINEARITY_TYPE_SET")
7619 999 errorsexits(
"SOLVER_EQUATIONS_LINEARITY_TYPE_SET",err,error)
7632 TYPE(solver_equations_type),
POINTER,
INTENT(IN) :: SOLVER_EQUATIONS
7633 INTEGER(INTG),
INTENT(OUT) :: ERR
7634 TYPE(varying_string),
INTENT(OUT) :: ERROR
7636 TYPE(boundary_conditions_type),
POINTER :: BOUNDARY_CONDITIONS
7637 TYPE(solver_type),
POINTER :: SOLVER
7638 TYPE(varying_string) :: LOCAL_ERROR
7640 enters(
"SolverEquations_BoundaryConditionsCreateFinish",err,error,*999)
7642 IF(
ASSOCIATED(solver_equations))
THEN 7643 IF(solver_equations%SOLVER_EQUATIONS_FINISHED)
THEN 7644 boundary_conditions=>solver_equations%BOUNDARY_CONDITIONS
7645 IF(
ASSOCIATED(boundary_conditions))
THEN 7646 CALL boundary_conditions_create_finish(boundary_conditions,err,error,*999)
7647 solver=>solver_equations%SOLVER
7648 IF(
ASSOCIATED(solver))
THEN 7649 IF(
ASSOCIATED(solver%LINKING_SOLVER))
THEN 7650 CALL flagerror(
"Can not finish solver equations creation for a solver that has been linked.",err,error,*999)
7653 CALL solver_mapping_create_finish(solver_equations%SOLVER_MAPPING,err,error,*999)
7655 SELECT CASE(solver%SOLVE_TYPE)
7667 local_error=
"The solver type of "//trim(numbertovstring(solver%SOLVE_TYPE,
"*",err,error))//
" is invalid." 7668 CALL flagerror(local_error,err,error,*999)
7673 CALL flagerror(
"Solver equations boundary conditions is not associated.",err,error,*999)
7676 CALL flagerror(
"Solver equations are not finished.",err,error,*999)
7679 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
7682 exits(
"SolverEquations_BoundaryConditionsCreateFinish")
7684 999 errors(
"SolverEquations_BoundaryConditionsCreateFinish",err,error)
7685 exits(
"SolverEquations_BoundaryConditionsCreateFinish")
7698 TYPE(solver_equations_type),
POINTER,
INTENT(IN) :: SOLVER_EQUATIONS
7699 TYPE(boundary_conditions_type),
POINTER,
INTENT(OUT) :: BOUNDARY_CONDITIONS
7700 INTEGER(INTG),
INTENT(OUT) :: ERR
7701 TYPE(varying_string),
INTENT(OUT) :: ERROR
7704 enters(
"SolverEquations_BoundaryConditionsCreateStart",err,error,*999)
7706 IF(
ASSOCIATED(solver_equations))
THEN 7707 IF(solver_equations%SOLVER_EQUATIONS_FINISHED)
THEN 7708 IF(.NOT.
ASSOCIATED(solver_equations%BOUNDARY_CONDITIONS))
THEN 7709 CALL boundary_conditions_create_start(solver_equations,boundary_conditions,err,error,*999)
7711 CALL flagerror(
"Solver equations boundary conditions is already associated.",err,error,*999)
7714 CALL flagerror(
"Solver equations are not finished.",err,error,*999)
7717 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
7720 exits(
"SolverEquations_BoundaryConditionsCreateStart")
7722 999 errors(
"SolverEquations_BoundaryConditionsCreateStart",err,error)
7723 exits(
"SolverEquations_BoundaryConditionsCreateStart")
7736 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
7737 INTEGER(INTG),
INTENT(IN) :: SPARSITY_TYPE
7738 INTEGER(INTG),
INTENT(OUT) :: ERR
7739 TYPE(varying_string),
INTENT(OUT) :: ERROR
7741 TYPE(solver_type),
POINTER :: SOLVER
7742 TYPE(varying_string) :: LOCAL_ERROR
7744 enters(
"SOLVER_EQUATIONS_SPARSITY_TYPE_SET",err,error,*999)
7746 IF(
ASSOCIATED(solver_equations))
THEN 7747 IF(solver_equations%SOLVER_EQUATIONS_FINISHED)
THEN 7748 CALL flagerror(
"Solver equations has already been finished.",err,error,*999)
7750 solver=>solver_equations%SOLVER
7751 IF(
ASSOCIATED(solver))
THEN 7752 IF(
ASSOCIATED(solver%LINKING_SOLVER))
THEN 7753 CALL flagerror(
"Can not set equations sparsity for a solver that has been linked.",err,error,*999)
7756 SELECT CASE(sparsity_type)
7762 local_error=
"The specified solver equations sparsity type of "// &
7763 & trim(numbertovstring(sparsity_type,
"*",err,error))//
" is invalid." 7764 CALL flagerror(local_error,err,error,*999)
7768 CALL flagerror(
"Solver equations solver is not associated.",err,error,*999)
7772 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
7775 exits(
"SOLVER_EQUATIONS_SPARSITY_TYPE_SET")
7777 999 errorsexits(
"SOLVER_EQUATIONS_SPARSITY_TYPE_SET",err,error)
7790 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
7791 INTEGER(INTG),
INTENT(IN) :: TIME_DEPENDENCE_TYPE
7792 INTEGER(INTG),
INTENT(OUT) :: ERR
7793 TYPE(varying_string),
INTENT(OUT) :: ERROR
7795 TYPE(solver_type),
POINTER :: SOLVER
7796 TYPE(varying_string) :: LOCAL_ERROR
7798 enters(
"SOLVER_EQUATIONS_TIME_DEPENDENCE_TYPE_SET",err,error,*999)
7800 IF(
ASSOCIATED(solver_equations))
THEN 7801 IF(solver_equations%SOLVER_EQUATIONS_FINISHED)
THEN 7802 CALL flagerror(
"Solver equations has already been finished.",err,error,*999)
7804 solver=>solver_equations%SOLVER
7805 IF(
ASSOCIATED(solver))
THEN 7806 IF(
ASSOCIATED(solver%LINKING_SOLVER))
THEN 7807 CALL flagerror(
"Can not set equations time dependence for a solver that has been linked.",err,error,*999)
7809 SELECT CASE(time_dependence_type)
7810 CASE(solver_equations_static)
7811 solver_equations%TIME_DEPENDENCE=solver_equations_static
7812 CASE(solver_equations_quasistatic)
7813 solver_equations%TIME_DEPENDENCE=solver_equations_quasistatic
7814 CASE(solver_equations_first_order_dynamic)
7815 solver_equations%TIME_DEPENDENCE=solver_equations_first_order_dynamic
7816 CASE(solver_equations_second_order_dynamic)
7817 solver_equations%TIME_DEPENDENCE=solver_equations_second_order_dynamic
7819 local_error=
"The specified solver equations time dependence type of "// &
7820 & trim(numbertovstring(time_dependence_type,
"*",err,error))//
" is invalid." 7821 CALL flagerror(local_error,err,error,*999)
7825 CALL flagerror(
"Solver equations solver is not associated.",err,error,*999)
7829 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
7832 exits(
"SOLVER_EQUATIONS_TIME_DEPENDENCE_TYPE_SET")
7834 999 errorsexits(
"SOLVER_EQUATIONS_TIME_DEPENDENCE_TYPE_SET",err,error)
7847 TYPE(solver_equations_type),
POINTER,
INTENT(IN) :: solverEquations
7848 INTEGER(INTG),
INTENT(OUT) :: numberOfMatrices
7849 INTEGER(INTG),
INTENT(OUT) :: err
7850 TYPE(varying_string),
INTENT(OUT) :: error
7852 TYPE(solver_matrices_type),
POINTER :: solverMatrices
7854 enters(
"SolverEquations_NumberOfMatricesGet",err,error,*999)
7856 IF(
ASSOCIATED(solverequations))
THEN 7857 solvermatrices=>solverequations%solver_matrices
7858 IF(
ASSOCIATED(solvermatrices))
THEN 7859 numberofmatrices=solvermatrices%number_of_matrices
7861 CALL flagerror(
"Solver equations solver matrices are not associated.",err,error,*999)
7864 CALL flagerror(
"Solver equations are not associated.",err,error,*999)
7867 exits(
"SolverEquations_NumberOfMatricesGet")
7869 999 errorsexits(
"SolverEquations_NumberOfMatricesGet",err,error)
7882 TYPE(solver_equations_type),
POINTER,
INTENT(IN) :: solverEquations
7883 INTEGER(INTG),
INTENT(IN) :: matrixIndex
7884 TYPE(distributed_matrix_type),
POINTER,
INTENT(INOUT) :: matrix
7885 INTEGER(INTG),
INTENT(OUT) :: err
7886 TYPE(varying_string),
INTENT(OUT) :: error
7888 INTEGER(INTG) :: numberOfMatrices
7889 TYPE(solver_matrices_type),
POINTER :: solverMatrices
7890 TYPE(solver_matrix_type),
POINTER :: solverMatrix
7892 enters(
"SolverEquations_MatrixGet",err,error,*999)
7894 IF(
ASSOCIATED(solverequations))
THEN 7895 solvermatrices=>solverequations%solver_matrices
7896 IF(
ASSOCIATED(solvermatrices))
THEN 7897 IF(.NOT.
ASSOCIATED(matrix))
THEN 7898 numberofmatrices=solvermatrices%number_of_matrices
7899 IF(matrixindex>0.AND.matrixindex<=numberofmatrices)
THEN 7900 solvermatrix=>solvermatrices%matrices(matrixindex)%ptr
7901 IF(
ASSOCIATED(solvermatrix))
THEN 7902 matrix=>solvermatrix%matrix
7904 CALL flagerror(
"Solver matrices solver matrix is not associated",err,error,*999)
7907 CALL flagerror(
"Invalid matrix index. The matrix index must be greater than zero and less than or equal to "// &
7908 & trim(numbertovstring(numberofmatrices,
"*",err,error))//
".",err,error,*999)
7911 CALL flagerror(
"The matrix is already associated.",err,error,*999)
7914 CALL flagerror(
"Solver equations solver matrices are not associated.",err,error,*999)
7917 CALL flagerror(
"Solver equations are not associated.",err,error,*999)
7920 exits(
"SolverEquations_MatrixGet")
7922 999 errorsexits(
"SolverEquations_MatrixGet",err,error)
7935 TYPE(solver_equations_type),
POINTER,
INTENT(IN) :: solverEquations
7936 TYPE(distributed_matrix_type),
POINTER,
INTENT(INOUT) :: matrix
7937 INTEGER(INTG),
INTENT(OUT) :: err
7938 TYPE(varying_string),
INTENT(OUT) :: error
7940 enters(
"SolverEquations_JacobianMatrixGet",err,error,*999)
7942 IF(
ASSOCIATED(solverequations))
THEN 7943 IF(solverequations%linearity==solver_equations_nonlinear)
THEN 7946 CALL flagerror(
"Solver equations linearity is not nonlinear.",err,error,*999)
7949 CALL flagerror(
"Solver equations are not associated.",err,error,*999)
7952 exits(
"SolverEquations_JacobianMatrixGet")
7954 999 errorsexits(
"SolverEquations_JacobianMatrixGet",err,error)
7967 TYPE(solver_equations_type),
POINTER,
INTENT(IN) :: solverEquations
7968 INTEGER(INTG),
INTENT(IN) :: matrixIndex
7969 TYPE(distributed_vector_type),
POINTER,
INTENT(INOUT) :: vector
7970 INTEGER(INTG),
INTENT(OUT) :: err
7971 TYPE(varying_string),
INTENT(OUT) :: error
7973 INTEGER(INTG) :: numberOfMatrices
7974 TYPE(solver_matrices_type),
POINTER :: solverMatrices
7975 TYPE(solver_matrix_type),
POINTER :: solverMatrix
7977 enters(
"SolverEquations_VectorGet",err,error,*999)
7979 IF(
ASSOCIATED(solverequations))
THEN 7980 solvermatrices=>solverequations%solver_matrices
7981 IF(
ASSOCIATED(solvermatrices))
THEN 7982 IF(.NOT.
ASSOCIATED(vector))
THEN 7983 numberofmatrices=solvermatrices%number_of_matrices
7984 IF(matrixindex>0.AND.matrixindex<=numberofmatrices)
THEN 7985 solvermatrix=>solvermatrices%matrices(matrixindex)%ptr
7986 IF(
ASSOCIATED(solvermatrix))
THEN 7987 IF(
ASSOCIATED(solvermatrix%solver_vector))
THEN 7988 vector=>solvermatrix%solver_vector
7990 CALL flagerror(
"There is no vector associated with this solve matrix.",err,error,*999)
7993 CALL flagerror(
"Solver matrices solver matrix is not associated",err,error,*999)
7996 CALL flagerror(
"Invalid matrix index. The matrix index must be greater than zero and less than or equal to "// &
7997 & trim(numbertovstring(numberofmatrices,
"*",err,error))//
".",err,error,*999)
8000 CALL flagerror(
"The vector is already associated.",err,error,*999)
8003 CALL flagerror(
"Solver equations solver matrices are not associated.",err,error,*999)
8006 CALL flagerror(
"Solver equations are not associated.",err,error,*999)
8009 exits(
"SolverEquations_VectorGet")
8011 999 errorsexits(
"SolverEquations_VectorGet",err,error)
8024 TYPE(solver_equations_type),
POINTER,
INTENT(IN) :: solverEquations
8025 TYPE(distributed_vector_type),
POINTER,
INTENT(INOUT) :: residualVector
8026 INTEGER(INTG),
INTENT(OUT) :: err
8027 TYPE(varying_string),
INTENT(OUT) :: error
8029 TYPE(solver_matrices_type),
POINTER :: solverMatrices
8031 enters(
"SolverEquations_ResidualVectorGet",err,error,*999)
8033 IF(
ASSOCIATED(solverequations))
THEN 8034 solvermatrices=>solverequations%solver_matrices
8035 IF(
ASSOCIATED(solvermatrices))
THEN 8036 IF(.NOT.
ASSOCIATED(residualvector))
THEN 8037 IF(
ASSOCIATED(solvermatrices%residual))
THEN 8038 residualvector=>solvermatrices%residual
8040 CALL flagerror(
"The solver matrices residual vector is not associated.",err,error,*999)
8043 CALL flagerror(
"The residual vector is already associated.",err,error,*999)
8046 CALL flagerror(
"Solver equations solver matrices are not associated.",err,error,*999)
8049 CALL flagerror(
"Solver equations are not associated.",err,error,*999)
8052 exits(
"SolverEquations_ResidualVectorGet")
8054 999 errorsexits(
"SolverEquations_ResidualVectorGet",err,error)
8067 TYPE(solver_equations_type),
POINTER,
INTENT(IN) :: solverEquations
8068 TYPE(distributed_vector_type),
POINTER,
INTENT(INOUT) :: rhsVector
8069 INTEGER(INTG),
INTENT(OUT) :: err
8070 TYPE(varying_string),
INTENT(OUT) :: error
8072 TYPE(solver_matrices_type),
POINTER :: solverMatrices
8074 enters(
"SolverEquations_RhsVectorGet",err,error,*999)
8076 IF(
ASSOCIATED(solverequations))
THEN 8077 solvermatrices=>solverequations%solver_matrices
8078 IF(
ASSOCIATED(solvermatrices))
THEN 8079 IF(.NOT.
ASSOCIATED(rhsvector))
THEN 8080 IF(
ASSOCIATED(solvermatrices%rhs_vector))
THEN 8081 rhsvector=>solvermatrices%rhs_vector
8083 CALL flagerror(
"The solver matrices right hand side vector is not associated.",err,error,*999)
8086 CALL flagerror(
"The right hand side vector is already associated.",err,error,*999)
8089 CALL flagerror(
"Solver equations solver matrices are not associated.",err,error,*999)
8092 CALL flagerror(
"Solver equations are not associated.",err,error,*999)
8095 exits(
"SolverEquations_RhsVectorGet")
8097 999 errorsexits(
"SolverEquations_RhsVectorGet",err,error)
8110 TYPE(solver_type),
POINTER :: SOLVER
8111 INTEGER(INTG),
INTENT(OUT) :: ERR
8112 TYPE(varying_string),
INTENT(OUT) :: ERROR
8115 enters(
"SOLVER_FINALISE",err,error,*999)
8117 IF(
ASSOCIATED(solver))
THEN 8127 IF(.NOT.
ASSOCIATED(solver%LINKING_SOLVER)) &
8129 IF(
ALLOCATED(solver%LINKED_SOLVER_TYPE_MAP))
DEALLOCATE(solver%LINKED_SOLVER_TYPE_MAP)
8130 IF(
ALLOCATED(solver%LINKED_SOLVERS))
DEALLOCATE(solver%LINKED_SOLVERS)
8134 exits(
"SOLVER_FINALISE")
8136 999 errorsexits(
"SOLVER_FINALISE",err,error)
8149 TYPE(solver_type),
POINTER :: solver
8150 LOGICAL,
INTENT(IN) :: arbitraryPath
8151 INTEGER(INTG),
INTENT(OUT) :: err
8152 TYPE(varying_string),
INTENT(OUT) :: error
8155 enters(
"Solver_GeometricTransformationArbitraryPathSet",err,error,*999)
8157 IF(
ASSOCIATED(solver))
THEN 8158 IF(
ASSOCIATED(solver%geometricTransformationSolver))
THEN 8159 solver%geometricTransformationSolver%arbitraryPath=arbitrarypath
8161 CALL flagerror(
"Geometric transformation solver is not associated for this solver.",err,error,*999)
8164 CALL flagerror(
"Solver is not associated.",err,error,*999)
8167 exits(
"Solver_GeometricTransformationArbitraryPathSet")
8169 999 errors(
"Solver_GeometricTransformationArbitraryPathSet",err,error)
8170 exits(
"Solver_GeometricTransformationArbitraryPathSet")
8183 TYPE(solver_type),
POINTER :: solver
8184 INTEGER(INTG),
INTENT(OUT) :: err
8185 TYPE(varying_string),
INTENT(OUT) :: error
8187 INTEGER(INTG) :: incrementIdx,i
8189 enters(
"Solver_GeometricTransformationClear",err,error,*999)
8191 IF(
ASSOCIATED(solver))
THEN 8192 IF(
ASSOCIATED(solver%geometricTransformationSolver))
THEN 8193 solver%geometricTransformationSolver%transformationMatrices=0.0_dp
8194 DO incrementidx=1,solver%geometricTransformationSolver%numberOfIncrements
8195 DO i=1,
SIZE(solver%geometricTransformationSolver%transformationMatrices,1)
8196 solver%geometricTransformationSolver%transformationMatrices(i,i,incrementidx)=1.0_dp
8199 IF(
ALLOCATED(solver%geometricTransformationSolver%scalings))
DEALLOCATE(solver%geometricTransformationSolver%scalings)
8201 CALL flagerror(
"Geometric transformation solver is not associated for this solver.",err,error,*999)
8204 CALL flagerror(
"Solver is not associated.",err,error,*999)
8207 exits(
"Solver_GeometricTransformationClear")
8210 999 errorsexits(
"Solver_GeometricTransformationClear",err,error)
8223 TYPE(solver_type),
POINTER :: solver
8224 TYPE(field_type),
POINTER :: field
8225 INTEGER(INTG),
INTENT(IN) :: variableType
8226 INTEGER(INTG),
INTENT(OUT) :: err
8227 TYPE(varying_string),
INTENT(OUT) :: error
8229 TYPE(field_variable_type),
POINTER :: fieldVariable,geometricFieldVariable
8230 INTEGER(INTG) :: numberOfGeoemtricComponents,i,j
8232 enters(
"Solver_GeometricTransformationFieldSet",err,error,*999)
8234 IF(
ASSOCIATED(solver))
THEN 8235 IF(
ASSOCIATED(solver%geometricTransformationSolver))
THEN 8236 IF(
ASSOCIATED(field))
THEN 8237 fieldvariable=>field%VARIABLE_TYPE_MAP(variabletype)%PTR
8238 IF(
ASSOCIATED(fieldvariable))
THEN 8239 IF(
ASSOCIATED(field%GEOMETRIC_FIELD))
THEN 8240 geometricfieldvariable=>field%GEOMETRIC_FIELD%VARIABLE_TYPE_MAP(1)%PTR
8241 IF(
ASSOCIATED(geometricfieldvariable))
THEN 8242 numberofgeoemtriccomponents=geometricfieldvariable%NUMBER_OF_COMPONENTS
8243 IF(solver%geometricTransformationSolver%arbitraryPath)
THEN 8244 ALLOCATE(solver%geometricTransformationSolver%transformationMatrices(numberofgeoemtriccomponents+1, &
8245 & numberofgeoemtriccomponents+1,solver%geometricTransformationSolver%numberOfIncrements),stat=err)
8246 IF(err/=0)
CALL flagerror(
"Could not allocate transform matrices for geometric transformation sovler", &
8249 ALLOCATE(solver%geometricTransformationSolver%transformationMatrices(numberofgeoemtriccomponents+1, &
8250 & numberofgeoemtriccomponents+1,1),stat=err)
8251 IF(err/=0)
CALL flagerror(
"Could not allocate transform matrices for geometric transformation sovler", &
8254 solver%geometricTransformationSolver%transformationMatrices=0.0_dp
8256 DO i=1,
SIZE(solver%geometricTransformationSolver%transformationMatrices,3)
8257 DO j=1,numberofgeoemtriccomponents+1
8258 solver%geometricTransformationSolver%transformationMatrices(j,j,i)=1.0_dp
8261 solver%geometricTransformationSolver%field=>field
8262 solver%geometricTransformationSolver%fieldVariableType=variabletype
8264 CALL flagerror(
"Field's geometric field variable is not associated.",err,error,*999)
8267 CALL flagerror(
"Field's geometric field is not associated.",err,error,*999)
8270 CALL flagerror(
"Field variable to be transformed is not associated.",err,error,*999)
8273 CALL flagerror(
"Field is not associated.",err,error,*999)
8276 CALL flagerror(
"Geometric transformation solver is not associated for this solver.",err,error,*999)
8279 CALL flagerror(
"Solver is not associated.",err,error,*999)
8282 exits(
"Solver_GeometricTransformationFieldSet")
8285 999 errorsexits(
"Solver_GeometricTransformationFieldSet",err,error)
8298 TYPE(solver_type),
POINTER :: solver
8299 REAL(DP),
INTENT(IN) :: matrix(:,:)
8300 INTEGER(INTG),
INTENT(IN) :: incrementIdx
8301 INTEGER(INTG),
INTENT(OUT) :: err
8302 TYPE(varying_string),
INTENT(OUT) :: error
8305 enters(
"Solver_GeometricTransformationMatrixSet",err,error,*999)
8307 IF(
ASSOCIATED(solver))
THEN 8308 IF(
ASSOCIATED(solver%geometricTransformationSolver))
THEN 8309 IF(
ASSOCIATED(solver%geometricTransformationSolver%field))
THEN 8310 IF(incrementidx>0 .AND. incrementidx<=solver%geometricTransformationSolver%numberOfIncrements)
THEN 8311 IF(
SIZE(matrix)==
SIZE(solver%geometricTransformationSolver%transformationMatrices(:,:,incrementidx)))
THEN 8312 solver%geometricTransformationSolver%transformationMatrices(:,:,incrementidx)=matrix
8314 CALL flagerror(
"Size of matrix input does not match the transformation matrix size.", &
8318 CALL flagerror(
"Load increment number out of range.",err,error,*999)
8321 CALL flagerror(
"Field is not associated for this geometric transformation solver.",err,error,*999)
8324 CALL flagerror(
"Geometric transformation solver is not associated for this solver.",err,error,*999)
8327 CALL flagerror(
"Solver is not associated.",err,error,*999)
8330 exits(
"Solver_GeometricTransformationMatrixSet")
8333 999 errorsexits(
"Solver_GeometricTransformationMatrixSet",err,error)
8346 TYPE(solver_type),
POINTER :: solver
8347 INTEGER(INTG),
INTENT(IN) :: numberOfIncrements
8348 INTEGER(INTG),
INTENT(OUT) :: err
8349 TYPE(varying_string),
INTENT(OUT) :: error
8352 enters(
"Solver_GeometricTransformationFieldSet",err,error,*999)
8354 IF(
ASSOCIATED(solver))
THEN 8355 IF(
ASSOCIATED(solver%geometricTransformationSolver))
THEN 8356 solver%geometricTransformationSolver%numberOfIncrements=numberofincrements
8358 CALL flagerror(
"Geometric transformation solver is not associated for this solver.",err,error,*999)
8361 CALL flagerror(
"Solver is not associated.",err,error,*999)
8364 exits(
"Solver_GeometricTransformationNumberOfLoadIncrementsSet")
8367 999 errors(
"Solver_GeometricTransformationNumberOfLoadIncrementsSet",err,error)
8368 exits(
"Solver_GeometricTransformationNumberOfLoadIncrementsSet")
8381 TYPE(solver_type),
POINTER :: solver
8382 REAL(DP),
INTENT(IN) :: pt(:)
8383 REAL(DP),
INTENT(IN) :: axis(:)
8384 REAL(DP),
INTENT(IN) :: theta
8385 INTEGER(INTG),
INTENT(IN) :: incrementIdx
8386 INTEGER(INTG),
INTENT(OUT) :: err
8387 TYPE(varying_string),
INTENT(OUT) :: error
8389 INTEGER(INTG) :: numberOfGeomComp
8390 REAL(DP) :: u,v,w,vectorLength,rotationMatrix(4,4),transformationMatrix(4,4)
8392 enters(
"Solver_GeometricTransformationRotationSet",err,error,*999)
8394 IF(
ASSOCIATED(solver))
THEN 8395 IF(
ASSOCIATED(solver%geometricTransformationSolver))
THEN 8396 IF(
ASSOCIATED(solver%geometricTransformationSolver%field))
THEN 8397 IF(incrementidx>0 .AND. incrementidx<=solver%geometricTransformationSolver%numberOfIncrements)
THEN 8398 IF(incrementidx>1 .AND. .NOT.solver%geometricTransformationSolver%arbitraryPath) &
8399 &
CALL flagerror(
"Rotating a field through multiple load increments must be specified through arbitrary path.", &
8401 numberofgeomcomp=
SIZE(solver%geometricTransformationSolver%transformationMatrices,1)-1
8403 IF(
SIZE(pt,1)==numberofgeomcomp)
THEN 8404 IF(
SIZE(axis,1)==numberofgeomcomp)
THEN 8405 SELECT CASE(numberofgeomcomp)
8410 vectorlength=sqrt(axis(1)**2+axis(2)**2+axis(3)**2)
8411 u=axis(1)/vectorlength
8412 v=axis(2)/vectorlength
8413 w=axis(3)/vectorlength
8414 rotationmatrix=0.0_dp
8415 rotationmatrix(1,1)=u**2+(v**2+w**2)*cos(theta)
8416 rotationmatrix(1,2)=u*v*(1.0_dp-cos(theta))-w*sin(theta)
8417 rotationmatrix(1,3)=u*w*(1-cos(theta))+v*sin(theta)
8418 rotationmatrix(2,1)=u*v*(1-cos(theta))+w*sin(theta)
8419 rotationmatrix(2,2)=v**2+(u**2+w**2)*cos(theta)
8420 rotationmatrix(2,3)=v*w*(1-cos(theta))-u*sin(theta)
8421 rotationmatrix(3,1)=u*w*(1-cos(theta))-v*sin(theta)
8422 rotationmatrix(3,2)=v*w*(1-cos(theta))+u*sin(theta)
8423 rotationmatrix(3,3)=w**2+(u**2+v**2)*cos(theta)
8424 rotationmatrix(1,4)=(pt(1)*(v**2+w**2)-u*(pt(2)*v+pt(3)*w))*(1-cos(theta))+(pt(2)*w-pt(3)*v)*sin(theta)
8425 rotationmatrix(2,4)=(pt(2)*(u**2+w**2)-v*(pt(1)*u+pt(3)*w))*(1-cos(theta))+(pt(3)*u-pt(1)*w)*sin(theta)
8426 rotationmatrix(3,4)=(pt(3)*(u**2+v**2)-w*(pt(1)*u+pt(2)*v))*(1-cos(theta))+(pt(1)*v-pt(2)*u)*sin(theta)
8427 rotationmatrix(4,4)=1.0_dp
8429 CALL flagerror(
"Number of geometric components out of range.",err,error,*999)
8432 transformationmatrix(1:numberofgeomcomp+1,1:numberofgeomcomp+1)=matmul(solver%geometricTransformationSolver% &
8433 & transformationmatrices(:,:,incrementidx),rotationmatrix(1:numberofgeomcomp+1,1:numberofgeomcomp+1))
8435 solver%geometricTransformationSolver%transformationMatrices(:,:,incrementidx)= &
8436 & transformationmatrix(1:numberofgeomcomp+1,1:numberofgeomcomp+1)
8438 CALL flagerror(
"Dimension of the rotation axis does not match no. field geometric components.", &
8442 CALL flagerror(
"Dimension of the pivot point does not match no. field geometric components.", &
8446 CALL flagerror(
"Load increment number out of range.",err,error,*999)
8449 CALL flagerror(
"Field is not associated for this geometric transformation solver.",err,error,*999)
8452 CALL flagerror(
"Geometric transformation solver is not associated for this solver.",err,error,*999)
8455 CALL flagerror(
"Solver is not associated.",err,error,*999)
8458 exits(
"Solver_GeometricTransformationRotationSet")
8461 999 errorsexits(
"Solver_GeometricTransformationRotationSet",err,error)
8474 TYPE(solver_type),
POINTER :: solver
8475 REAL(DP),
INTENT(IN) :: scalings(:)
8476 INTEGER(INTG),
INTENT(OUT) :: err
8477 TYPE(varying_string),
INTENT(OUT) :: error
8480 enters(
"Solver_GeometricTransformationScalingsSet",err,error,*999)
8482 IF(
ASSOCIATED(solver))
THEN 8483 IF(
ASSOCIATED(solver%geometricTransformationSolver))
THEN 8484 IF(solver%geometricTransformationSolver%arbitraryPath)
THEN 8485 CALL flagerror(
"Transformation with arbitrary path does not have uni-directional scalings.",err,error,*999)
8487 IF(solver%geometricTransformationSolver%numberOfIncrements==
SIZE(scalings))
THEN 8488 IF(
ALLOCATED(solver%geometricTransformationSolver%scalings)) &
8489 &
DEALLOCATE(solver%geometricTransformationSolver%scalings)
8490 ALLOCATE(solver%geometricTransformationSolver%scalings(
SIZE(scalings)),stat=err)
8491 IF(err/=0)
CALL flagerror(
"Could not allocate scalings for geometric transformation sovler",err,error,*999)
8492 solver%geometricTransformationSolver%scalings(1:
SIZE(scalings))=scalings(1:
SIZE(scalings))
8494 CALL flagerror(
"Number of scalings does not match the number of increments.",err,error,*999)
8498 CALL flagerror(
"Geometric transformation solver is not associated for this solver.",err,error,*999)
8501 CALL flagerror(
"Solver is not associated.",err,error,*999)
8504 exits(
"Solver_GeometricTransformationScalingsSet")
8507 999 errorsexits(
"Solver_GeometricTransformationScalingsSet",err,error)
8520 TYPE(solver_type),
POINTER :: solver
8521 REAL(DP),
INTENT(IN) :: translation(:)
8522 INTEGER(INTG),
INTENT(IN) :: incrementIdx
8523 INTEGER(INTG),
INTENT(OUT) :: err
8524 TYPE(varying_string),
INTENT(OUT) :: error
8526 INTEGER(INTG) :: numberOfGeomComp,i
8527 REAL(DP) :: transformationMatrix(4,4),translationMatrix(4,4)
8529 enters(
"Solver_GeometricTransformationTranslationSet",err,error,*999)
8531 IF(
ASSOCIATED(solver))
THEN 8532 IF(
ASSOCIATED(solver%geometricTransformationSolver))
THEN 8533 IF(
ASSOCIATED(solver%geometricTransformationSolver%field))
THEN 8534 IF(incrementidx>0 .AND. incrementidx<=solver%geometricTransformationSolver%numberOfIncrements)
THEN 8535 numberofgeomcomp=
SIZE(solver%geometricTransformationSolver%transformationMatrices,incrementidx)-1
8537 translationmatrix=0.0_dp
8538 transformationmatrix=0.0_dp
8540 translationmatrix(i,i)=1.0_dp
8542 IF(
SIZE(translation,1)==numberofgeomcomp)
THEN 8543 translationmatrix(1:numberofgeomcomp,numberofgeomcomp+1)=translation
8545 transformationmatrix=matmul(solver%geometricTransformationSolver%transformationMatrices(:,:,incrementidx), &
8546 & translationmatrix(1:1+numberofgeomcomp,1:1+numberofgeomcomp))
8548 solver%geometricTransformationSolver%transformationMatrices(:,:,incrementidx)= &
8549 & transformationmatrix(1:1+numberofgeomcomp,1:1+numberofgeomcomp)
8551 CALL flagerror(
"Number of components for translation vector does not match no. field geometric components.", &
8555 CALL flagerror(
"Load increment number out of range.",err,error,*999)
8558 CALL flagerror(
"Field is not associated for this geometric transformation solver.",err,error,*999)
8561 CALL flagerror(
"Geometric transformation solver is not associated for this solver.",err,error,*999)
8564 CALL flagerror(
"Solver is not associated.",err,error,*999)
8567 exits(
"Solver_GeometricTransformationTranslationSet")
8569 999 errors(
"Solver_GeometricTransformationTranslationSet",err,error)
8570 exits(
"Solver_GeometricTransformationTranslationSet")
8583 TYPE(geometrictransformationsolvertype),
POINTER :: geometricTransformationSolver
8584 INTEGER(INTG),
INTENT(OUT) :: err
8585 TYPE(varying_string),
INTENT(OUT) :: error
8588 enters(
"Solver_GeometricTransformationFinalise",err,error,*999)
8590 IF(
ASSOCIATED(geometrictransformationsolver))
THEN 8591 NULLIFY(geometrictransformationsolver%solver)
8592 IF(
ASSOCIATED(geometrictransformationsolver%field))
NULLIFY(geometrictransformationsolver%field)
8593 geometrictransformationsolver%arbitraryPath=.false.
8594 IF(
ALLOCATED(geometrictransformationsolver%scalings))
DEALLOCATE(geometrictransformationsolver%scalings)
8595 IF(
ALLOCATED(geometrictransformationsolver%transformationMatrices)) &
8596 &
DEALLOCATE(geometrictransformationsolver%transformationMatrices)
8597 geometrictransformationsolver%numberOfIncrements=0
8598 geometrictransformationsolver%fieldVariableType=0
8599 DEALLOCATE(geometrictransformationsolver)
8602 exits(
"Solver_GeometricTransformationFinalise")
8604 999 errorsexits(
"Solver_GeometricTransformationFinalise",err,error)
8617 TYPE(solver_type),
POINTER :: solver
8618 INTEGER(INTG),
INTENT(OUT) :: err
8619 TYPE(varying_string),
INTENT(OUT) :: error
8621 TYPE(solvers_type),
POINTER :: solvers
8622 TYPE(control_loop_type),
POINTER :: controlLoop
8623 TYPE(control_loop_while_type),
POINTER :: whileLoop
8624 TYPE(control_loop_load_increment_type),
POINTER :: loadIncrementLoop
8625 INTEGER(INTG) :: dummyErr
8626 TYPE(varying_string) :: dummyError
8628 enters(
"Solver_GeometricTransformationInitialise",err,error,*998)
8630 IF(
ASSOCIATED(solver))
THEN 8631 IF(
ASSOCIATED(solver%geometricTransformationSolver))
THEN 8632 CALL flagerror(
"Geometric transformation solver is already associated for this solver.",err,error,*998)
8635 ALLOCATE(solver%geometricTransformationSolver,stat=err)
8636 IF(err/=0)
CALL flagerror(
"Could not allocate solver geometric transformation solver.",err,error,*999)
8637 solver%geometricTransformationSolver%solver=>solver
8638 solver%geometricTransformationSolver%arbitraryPath=.false.
8640 solvers=>solver%SOLVERS
8641 IF(
ASSOCIATED(solvers))
THEN 8642 controlloop=>solvers%CONTROL_LOOP
8643 IF(
ASSOCIATED(controlloop))
THEN 8644 IF(controlloop%LOOP_TYPE==problem_control_while_loop_type)
THEN 8645 whileloop=>controlloop%WHILE_LOOP
8646 IF(
ASSOCIATED(whileloop))
THEN 8647 solver%geometricTransformationSolver%numberOfIncrements=whileloop%MAXIMUM_NUMBER_OF_ITERATIONS
8649 CALL flagerror(
"Control loop while loop is not associated.",err,error,*999)
8651 ELSEIF(controlloop%LOOP_TYPE==problem_control_load_increment_loop_type)
THEN 8652 loadincrementloop=>controlloop%LOAD_INCREMENT_LOOP
8653 IF(
ASSOCIATED(loadincrementloop))
THEN 8654 solver%geometricTransformationSolver%numberOfIncrements=loadincrementloop%MAXIMUM_NUMBER_OF_ITERATIONS
8656 CALL flagerror(
"Control loop load increment loop is not associated.",err,error,*999)
8659 solver%geometricTransformationSolver%numberOfIncrements=1
8662 CALL flagerror(
"control loop is not associated.",err,error,*998)
8665 CALL flagerror(
"Solvers is not associated.",err,error,*998)
8668 NULLIFY(solver%geometricTransformationSolver%field)
8669 solver%geometricTransformationSolver%fieldVariableType=0
8672 CALL flagerror(
"Solver is not associated.",err,error,*998)
8675 exits(
"Solver_GeometricTransformationInitialise")
8678 998 errorsexits(
"Solver_GeometricTransformationInitialise",err,error)
8691 TYPE(solver_type),
POINTER :: SOLVER
8692 TYPE(solver_type),
POINTER :: CELLML_SOLVER
8693 INTEGER(INTG),
INTENT(OUT) :: ERR
8694 TYPE(varying_string),
INTENT(OUT) :: ERROR
8696 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
8697 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
8699 NULLIFY(cellml_solver)
8701 enters(
"SOLVER_NEWTON_CELLML_EVALUATOR_CREATE",err,error,*999)
8703 IF(
ASSOCIATED(solver))
THEN 8704 NULLIFY(nonlinear_solver)
8705 IF(
ASSOCIATED(solver%DYNAMIC_SOLVER))
THEN 8706 nonlinear_solver=>solver%DYNAMIC_SOLVER%NONLINEAR_SOLVER%NONLINEAR_SOLVER
8708 nonlinear_solver=>solver%NONLINEAR_SOLVER
8710 IF(
ASSOCIATED(nonlinear_solver))
THEN 8711 newton_solver=>nonlinear_solver%NEWTON_SOLVER
8712 IF(
ASSOCIATED(newton_solver))
THEN 8714 ALLOCATE(newton_solver%CELLML_EVALUATOR_SOLVER,stat=err)
8715 IF(err/=0)
CALL flagerror(
"Cannot allocate CellML evaluator solver.",err,error,*999)
8716 cellml_solver=>newton_solver%CELLML_EVALUATOR_SOLVER
8717 NULLIFY(cellml_solver%SOLVERS)
8721 CALL flagerror(
"Newton solver is not associated.",err,error,*999)
8724 CALL flagerror(
"Nonlinear solver is not associated.",err,error,*999)
8727 CALL flagerror(
"Solver is not associated.",err,error,*999)
8730 exits(
"SOLVER_NEWTON_CELLML_EVALUATOR_CREATE")
8732 999 errorsexits(
"SOLVER_NEWTON_CELLML_EVALUATOR_CREATE",err,error)
8745 TYPE(solvers_type),
POINTER :: SOLVERS
8746 INTEGER(INTG),
INTENT(IN) :: SOLVER_INDEX
8747 INTEGER(INTG),
INTENT(OUT) :: ERR
8748 TYPE(varying_string),
INTENT(OUT) :: ERROR
8750 INTEGER(INTG) :: DUMMY_ERR
8751 TYPE(varying_string) :: DUMMY_ERROR,LOCAL_ERROR
8753 enters(
"SOLVER_INITIALISE",err,error,*998)
8755 IF(
ASSOCIATED(solvers))
THEN 8756 IF(solver_index>0.AND.solver_index<=solvers%NUMBER_OF_SOLVERS)
THEN 8757 IF(
ALLOCATED(solvers%SOLVERS))
THEN 8758 IF(
ASSOCIATED(solvers%SOLVERS(solver_index)%PTR))
THEN 8759 CALL flagerror(
"Solver pointer is already associated for this solver index.",err,error,*998)
8761 ALLOCATE(solvers%SOLVERS(solver_index)%PTR,stat=err)
8762 IF(err/=0)
CALL flagerror(
"Could not allocate solver.",err,error,*999)
8763 solvers%SOLVERS(solver_index)%PTR%SOLVERS=>solvers
8765 solvers%SOLVERS(solver_index)%PTR%GLOBAL_NUMBER=solver_index
8771 CALL flagerror(
"Solvers solvers is not allocated.",err,error,*998)
8774 local_error=
"The solver index of "//trim(numbertovstring(solver_index,
"*",err,error))// &
8775 &
" is invalid. The solver index must be > 0 and <= "// &
8776 & trim(numbertovstring(solvers%NUMBER_OF_SOLVERS,
"*",err,error))//
"." 8777 CALL flagerror(local_error,err,error,*998)
8780 CALL flagerror(
"Solvers is not associated.",err,error,*998)
8783 exits(
"SOLVER_INITIALISE")
8785 999
CALL solver_finalise(solvers%SOLVERS(solver_index)%PTR,dummy_err,dummy_error,*998)
8786 998 errorsexits(
"SOLVER_INITIALISE",err,error)
8799 TYPE(solver_type),
POINTER :: SOLVER
8800 INTEGER(INTG),
INTENT(OUT) :: ERR
8801 TYPE(varying_string),
INTENT(OUT) :: ERROR
8803 INTEGER(INTG) :: solver_idx
8805 enters(
"SOLVER_INITIALISE_PTR",err,error,*999)
8807 IF(
ASSOCIATED(solver))
THEN 8808 NULLIFY(solver%LINKING_SOLVER)
8810 IF(err/=0)
CALL flagerror(
"Could not allocate linked solver type map.",err,error,*999)
8812 NULLIFY(solver%LINKED_SOLVER_TYPE_MAP(solver_idx)%PTR)
8814 solver%NUMBER_OF_LINKED_SOLVERS=0
8815 solver%SOLVER_FINISHED=.false.
8818 NULLIFY(solver%LINEAR_SOLVER)
8819 NULLIFY(solver%NONLINEAR_SOLVER)
8820 NULLIFY(solver%DYNAMIC_SOLVER)
8821 NULLIFY(solver%DAE_SOLVER)
8822 NULLIFY(solver%EIGENPROBLEM_SOLVER)
8823 NULLIFY(solver%OPTIMISER_SOLVER)
8824 NULLIFY(solver%CELLML_EVALUATOR_SOLVER)
8825 NULLIFY(solver%SOLVER_EQUATIONS)
8826 NULLIFY(solver%CELLML_EQUATIONS)
8827 NULLIFY(solver%geometricTransformationSolver)
8829 CALL flagerror(
"Solver is not associated.",err,error,*999)
8832 exits(
"SOLVER_INITIALISE_PTR")
8834 999 errorsexits(
"SOLVER_INITIALISE_PTR",err,error)
8847 TYPE(solver_type),
POINTER :: SOLVER
8848 CHARACTER(LEN=*),
INTENT(OUT) :: LABEL
8849 INTEGER(INTG),
INTENT(OUT) :: ERR
8850 TYPE(varying_string),
INTENT(OUT) :: ERROR
8852 INTEGER(INTG) :: C_LENGTH,VS_LENGTH
8854 enters(
"SOLVER_LABEL_GET_C",err,error,*999)
8856 IF(
ASSOCIATED(solver))
THEN 8858 vs_length=len_trim(solver%LABEL)
8859 IF(c_length>vs_length)
THEN 8860 label=char(solver%LABEL,vs_length)
8862 label=char(solver%LABEL,c_length)
8865 CALL flagerror(
"Solver is not associated.",err,error,*999)
8868 exits(
"SOLVER_LABEL_GET_C")
8870 999 errorsexits(
"SOLVER_LABEL_GET_C",err,error)
8883 TYPE(solver_type),
POINTER :: SOLVER
8884 TYPE(varying_string),
INTENT(OUT) :: LABEL
8885 INTEGER(INTG),
INTENT(OUT) :: ERR
8886 TYPE(varying_string),
INTENT(OUT) :: ERROR
8889 enters(
"SOLVER_LABEL_GET_VS",err,error,*999)
8891 IF(
ASSOCIATED(solver))
THEN 8892 label=var_str(char(solver%LABEL))
8894 CALL flagerror(
"Solver is not associated.",err,error,*999)
8897 exits(
"SOLVER_LABEL_GET_VS")
8899 999 errorsexits(
"SOLVER_LABEL_GET_VS",err,error)
8912 TYPE(solver_type),
POINTER :: SOLVER
8913 CHARACTER(LEN=*),
INTENT(IN) :: LABEL
8914 INTEGER(INTG),
INTENT(OUT) :: ERR
8915 TYPE(varying_string),
INTENT(OUT) :: ERROR
8918 enters(
"SOLVER_LABEL_SET_C",err,error,*999)
8920 IF(
ASSOCIATED(solver))
THEN 8921 IF(solver%SOLVER_FINISHED)
THEN 8922 CALL flagerror(
"Solver has been finished.",err,error,*999)
8927 CALL flagerror(
"Solver is not associated.",err,error,*999)
8930 exits(
"SOLVER_LABEL_SET_C")
8932 999 errorsexits(
"SOLVER_LABEL_SET_C",err,error)
8945 TYPE(solver_type),
POINTER :: SOLVER
8946 TYPE(varying_string),
INTENT(IN) :: LABEL
8947 INTEGER(INTG),
INTENT(OUT) :: ERR
8948 TYPE(varying_string),
INTENT(OUT) :: ERROR
8951 enters(
"SOLVER_LABEL_SET_VS",err,error,*999)
8953 IF(
ASSOCIATED(solver))
THEN 8954 IF(solver%SOLVER_FINISHED)
THEN 8955 CALL flagerror(
"Solver has been finished.",err,error,*999)
8960 CALL flagerror(
"Solver is not associated.",err,error,*999)
8963 exits(
"SOLVER_LABEL_SET_VS")
8965 999 errorsexits(
"SOLVER_LABEL_SET_VS",err,error)
8977 TYPE(solver_type),
POINTER :: SOLVER
8978 INTEGER(INTG),
INTENT(OUT) :: SOLVER_LIBRARY_TYPE
8979 INTEGER(INTG),
INTENT(OUT) :: ERR
8980 TYPE(varying_string),
INTENT(OUT) :: ERROR
8982 TYPE(dae_solver_type),
POINTER :: DAE_SOLVER
8983 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
8984 TYPE(eigenproblem_solver_type),
POINTER :: EIGENPROBLEM_SOLVER
8985 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
8986 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
8987 TYPE(optimiser_solver_type),
POINTER :: OPTIMISER_SOLVER
8988 TYPE(cellml_evaluator_solver_type),
POINTER :: CELLML_EVALUATOR_SOLVER
8989 TYPE(varying_string) :: LOCAL_ERROR
8991 enters(
"SOLVER_LIBRARY_TYPE_GET",err,error,*999)
8993 IF(
ASSOCIATED(solver))
THEN 8994 SELECT CASE(solver%SOLVE_TYPE)
8996 linear_solver=>solver%LINEAR_SOLVER
8997 IF(
ASSOCIATED(linear_solver))
THEN 9000 CALL flagerror(
"Solver linear solver is not associated.",err,error,*999)
9003 nonlinear_solver=>solver%NONLINEAR_SOLVER
9004 IF(
ASSOCIATED(nonlinear_solver))
THEN 9007 CALL flagerror(
"Solver nonlinear solver is not associated.",err,error,*999)
9010 dynamic_solver=>solver%DYNAMIC_SOLVER
9011 IF(
ASSOCIATED(dynamic_solver))
THEN 9013 solver_library_type=dynamic_solver%SOLVER_LIBRARY
9015 CALL flagerror(
"Solver dynamic solver is not associated.",err,error,*999)
9018 dae_solver=>solver%DAE_SOLVER
9019 IF(
ASSOCIATED(dae_solver))
THEN 9022 CALL flagerror(
"Solver differential-algebraic solver is not associated.",err,error,*999)
9025 eigenproblem_solver=>solver%EIGENPROBLEM_SOLVER
9026 IF(
ASSOCIATED(eigenproblem_solver))
THEN 9028 CALL flagerror(
"Not implemented.",err,error,*999)
9030 CALL flagerror(
"Solver eigenproblem solver is not associated.",err,error,*999)
9033 optimiser_solver=>solver%OPTIMISER_SOLVER
9034 IF(
ASSOCIATED(optimiser_solver))
THEN 9037 CALL flagerror(
"Solver optimiser solver is not associated.",err,error,*999)
9040 cellml_evaluator_solver=>solver%CELLML_EVALUATOR_SOLVER
9041 IF(
ASSOCIATED(cellml_evaluator_solver))
THEN 9044 CALL flagerror(
"Solver CellML evaluator solver is not associated.",err,error,*999)
9047 local_error=
"The solver type of "//trim(numbertovstring(solver%SOLVE_TYPE,
"*",err,error))//
" is invalid." 9048 CALL flagerror(local_error,err,error,*999)
9051 CALL flagerror(
"Solver is not associated.",err,error,*999)
9054 exits(
"SOLVER_LIBRARY_TYPE_GET")
9056 999 errorsexits(
"SOLVER_LIBRARY_TYPE_GET",err,error)
9069 TYPE(solver_type),
POINTER :: SOLVER
9070 INTEGER(INTG),
INTENT(IN) :: SOLVER_LIBRARY_TYPE
9071 INTEGER(INTG),
INTENT(OUT) :: ERR
9072 TYPE(varying_string),
INTENT(OUT) :: ERROR
9074 TYPE(dae_solver_type),
POINTER :: DAE_SOLVER
9075 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
9076 TYPE(eigenproblem_solver_type),
POINTER :: EIGENPROBLEM_SOLVER
9077 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
9078 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
9079 TYPE(optimiser_solver_type),
POINTER :: OPTIMISER_SOLVER
9080 TYPE(cellml_evaluator_solver_type),
POINTER :: CELLML_EVALUATOR_SOLVER
9081 TYPE(varying_string) :: LOCAL_ERROR
9083 enters(
"SOLVER_LIBRARY_TYPE_SET",err,error,*999)
9085 IF(
ASSOCIATED(solver))
THEN 9086 IF(solver%SOLVER_FINISHED)
THEN 9087 CALL flagerror(
"Solver has alredy been finished.",err,error,*999)
9089 SELECT CASE(solver%SOLVE_TYPE)
9091 linear_solver=>solver%LINEAR_SOLVER
9092 IF(
ASSOCIATED(linear_solver))
THEN 9095 CALL flagerror(
"Solver linear solver is not associated.",err,error,*999)
9098 nonlinear_solver=>solver%NONLINEAR_SOLVER
9099 IF(
ASSOCIATED(nonlinear_solver))
THEN 9102 CALL flagerror(
"Solver nonlinear solver is not associated.",err,error,*999)
9105 dynamic_solver=>solver%DYNAMIC_SOLVER
9106 IF(
ASSOCIATED(dynamic_solver))
THEN 9109 CALL flagerror(
"Solver dynamic solver is not associated.",err,error,*999)
9112 dae_solver=>solver%DAE_SOLVER
9113 IF(
ASSOCIATED(dae_solver))
THEN 9116 CALL flagerror(
"Solver differential-algebraic equation solver is not associated.",err,error,*999)
9119 eigenproblem_solver=>solver%EIGENPROBLEM_SOLVER
9120 IF(
ASSOCIATED(eigenproblem_solver))
THEN 9122 SELECT CASE(solver_library_type)
9124 CALL flagerror(
"Not implemented.",err,error,*999)
9126 CALL flagerror(
"Not implemented.",err,error,*999)
9128 local_error=
"The solver library type of "//trim(numbertovstring(solver_library_type,
"*",err,error))//
" is invalid." 9129 CALL flagerror(local_error,err,error,*999)
9132 CALL flagerror(
"Solver eigenproblem solver is not associated.",err,error,*999)
9135 optimiser_solver=>solver%OPTIMISER_SOLVER
9136 IF(
ASSOCIATED(optimiser_solver))
THEN 9139 CALL flagerror(
"Solver optimiser solver is not associated.",err,error,*999)
9142 cellml_evaluator_solver=>solver%CELLML_EVALUATOR_SOLVER
9143 IF(
ASSOCIATED(cellml_evaluator_solver))
THEN 9146 CALL flagerror(
"Solver CellML evaluator solver is not associated.",err,error,*999)
9149 local_error=
"The solver type of "//trim(numbertovstring(solver%SOLVE_TYPE,
"*",err,error))//
" is invalid." 9150 CALL flagerror(local_error,err,error,*999)
9154 CALL flagerror(
"Solver is not associated.",err,error,*999)
9157 exits(
"SOLVER_LIBRARY_TYPE_SET")
9159 999 errorsexits(
"SOLVER_LIBRARY_TYPE_SET",err,error)
9172 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
9173 INTEGER(INTG),
INTENT(OUT) :: ERR
9174 TYPE(varying_string),
INTENT(OUT) :: ERROR
9176 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
9177 TYPE(newton_linesearch_solver_type),
POINTER :: NEWTON_LINESEARCH_SOLVER
9178 TYPE(newton_trustregion_solver_type),
POINTER :: NEWTON_TRUSTREGION_SOLVER
9179 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
9180 TYPE(quasi_newton_linesearch_solver_type),
POINTER :: QUASI_NEWTON_LINESEARCH_SOLVER
9181 TYPE(quasi_newton_trustregion_solver_type),
POINTER :: QUASI_NEWTON_TRUSTREGION_SOLVER
9182 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
9183 TYPE(solver_type),
POINTER :: LINKING_SOLVER,SOLVER
9184 TYPE(varying_string) :: LOCAL_ERROR
9186 enters(
"SOLVER_LINEAR_CREATE_FINISH",err,error,*999)
9188 IF(
ASSOCIATED(linear_solver))
THEN 9189 solver=>linear_solver%SOLVER
9190 IF(
ASSOCIATED(solver))
THEN 9191 linking_solver=>solver%LINKING_SOLVER
9192 IF(
ASSOCIATED(linking_solver))
THEN 9194 nonlinear_solver=>linking_solver%NONLINEAR_SOLVER
9195 IF(
ASSOCIATED(nonlinear_solver))
THEN 9197 newton_solver=>nonlinear_solver%NEWTON_SOLVER
9198 IF(
ASSOCIATED(newton_solver))
THEN 9199 SELECT CASE(newton_solver%NEWTON_SOLVE_TYPE)
9201 newton_linesearch_solver=>newton_solver%LINESEARCH_SOLVER
9202 IF(
ASSOCIATED(newton_linesearch_solver))
THEN 9203 linear_solver%LINKED_NEWTON_PETSC_SOLVER=newton_linesearch_solver%SOLVER_LIBRARY==
solver_petsc_library 9205 CALL flagerror(
"Newton solver linesearch solver is not associated.",err,error,*999)
9208 newton_trustregion_solver=>newton_solver%TRUSTREGION_SOLVER
9209 IF(
ASSOCIATED(newton_trustregion_solver))
THEN 9210 linear_solver%LINKED_NEWTON_PETSC_SOLVER= &
9213 CALL flagerror(
"Newton solver linesearch solver is not associated.",err,error,*999)
9216 local_error=
"The Newton solve type of "// &
9217 & trim(numbertovstring(newton_solver%NEWTON_SOLVE_TYPE,
"*",err,error))//
"is invalid." 9218 CALL flagerror(local_error,err,error,*999)
9221 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
9224 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
9225 IF(
ASSOCIATED(quasi_newton_solver))
THEN 9226 SELECT CASE(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE)
9228 quasi_newton_linesearch_solver=>quasi_newton_solver%LINESEARCH_SOLVER
9229 IF(
ASSOCIATED(quasi_newton_linesearch_solver))
THEN 9230 linear_solver%LINKED_NEWTON_PETSC_SOLVER= &
9233 CALL flagerror(
"Quasi-Newton solver linesearch solver is not associated.",err,error,*999)
9236 quasi_newton_trustregion_solver=>quasi_newton_solver%TRUSTREGION_SOLVER
9237 IF(
ASSOCIATED(quasi_newton_trustregion_solver))
THEN 9238 linear_solver%LINKED_NEWTON_PETSC_SOLVER= &
9241 CALL flagerror(
"Quasi-Newton solver linesearch solver is not associated.",err,error,*999)
9244 local_error=
"The Quasi-Newton solve type of "// &
9245 & trim(numbertovstring(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE,
"*",err,error))//
"is invalid." 9246 CALL flagerror(local_error,err,error,*999)
9249 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
9253 CALL flagerror(
"Linking solver nonlinear solver is not associated.",err,error,*999)
9257 SELECT CASE(linear_solver%LINEAR_SOLVE_TYPE)
9263 local_error=
"The linear solver type of "//trim(numbertovstring(linear_solver%LINEAR_SOLVE_TYPE,
"*",err,error))// &
9265 CALL flagerror(local_error,err,error,*999)
9268 CALL flagerror(
"Linear solver solver is not associated.",err,error,*999)
9271 CALL flagerror(
"Linear solver is not associated.",err,error,*999)
9274 exits(
"SOLVER_LINEAR_CREATE_FINISH")
9276 999 errorsexits(
"SOLVER_LINEAR_CREATE_FINISH",err,error)
9289 TYPE(linear_direct_solver_type),
POINTER :: DIRECT_SOLVER
9290 INTEGER(INTG),
INTENT(OUT) :: ERR
9291 TYPE(varying_string),
INTENT(OUT) :: ERROR
9294 enters(
"SOLVER_LINEAR_DIRECT_CHOLESKY_FINALISE",err,error,*999)
9296 IF(
ASSOCIATED(direct_solver))
THEN 9297 CALL flagerror(
"Not implemented.",err,error,*999)
9300 exits(
"SOLVER_LINEAR_DIRECT_CHOLESKY_FINALISE")
9302 999 errorsexits(
"SOLVER_LINEAR_DIRECT_CHOLESKY_FINALISE",err,error)
9315 TYPE(linear_direct_solver_type),
POINTER :: DIRECT_SOLVER
9316 INTEGER(INTG),
INTENT(OUT) :: ERR
9317 TYPE(varying_string),
INTENT(OUT) :: ERROR
9320 enters(
"SOLVER_LINEAR_DIRECT_CHOLESKY_INITIALISE",err,error,*999)
9322 IF(
ASSOCIATED(direct_solver))
THEN 9323 CALL flagerror(
"Not implemented.",err,error,*999)
9325 CALL flagerror(
"Direct linear solver is not associated.",err,error,*999)
9328 exits(
"SOLVER_LINEAR_DIRECT_CHOLESKY_INITIALISE")
9330 999 errorsexits(
"SOLVER_LINEAR_DIRECT_CHOLESKY_INITIALISE",err,error)
9343 TYPE(linear_direct_solver_type),
POINTER :: LINEAR_DIRECT_SOLVER
9344 INTEGER(INTG),
INTENT(OUT) :: ERR
9345 TYPE(varying_string),
INTENT(OUT) :: ERROR
9347 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
9348 TYPE(distributed_matrix_type),
POINTER :: SOLVER_MATRIX
9349 TYPE(solver_type),
POINTER :: SOLVER
9350 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
9351 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
9352 TYPE(varying_string) :: LOCAL_ERROR
9354 enters(
"SOLVER_LINEAR_DIRECT_CREATE_FINISH",err,error,*999)
9356 IF(
ASSOCIATED(linear_direct_solver))
THEN 9357 linear_solver=>linear_direct_solver%LINEAR_SOLVER
9358 IF(
ASSOCIATED(linear_solver))
THEN 9359 solver=>linear_solver%SOLVER
9360 IF(
ASSOCIATED(solver))
THEN 9361 SELECT CASE(linear_direct_solver%DIRECT_SOLVER_TYPE)
9363 IF(
ASSOCIATED(solver%LINKING_SOLVER))
THEN 9365 SELECT CASE(linear_direct_solver%SOLVER_LIBRARY)
9367 CALL flagerror(
"Non-PETSc linear solver cannot be linked to PETSc nonlinear solver.",err,error,*999)
9369 solver_equations=>solver%LINKING_SOLVER%SOLVER_EQUATIONS
9370 IF(
ASSOCIATED(solver_equations))
THEN 9371 solver_matrices=>solver_equations%SOLVER_MATRICES
9372 IF(.NOT.
ASSOCIATED(solver_matrices)) &
9373 &
CALL flagerror(
"Linked solver equation solver matrices is not associated.",err,error,*999)
9375 CALL flagerror(
"Linked solver solver equations is not associated.",err,error,*999)
9379 solver_equations=>solver%SOLVER_EQUATIONS
9380 IF(
ASSOCIATED(solver_equations))
THEN 9382 NULLIFY(solver_matrices)
9383 CALL solver_matrices_create_start(solver_equations,solver_matrices,err,error,*999)
9386 SELECT CASE(linear_direct_solver%SOLVER_LIBRARY)
9394 CALL flagerror(
"Not implemented.",err,error,*999)
9396 local_error=
"The solver library type of "// &
9397 & trim(numbertovstring(linear_direct_solver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid." 9398 CALL flagerror(local_error,err,error,*999)
9401 SELECT CASE(solver_equations%SPARSITY_TYPE)
9403 CALL solver_matrices_storage_type_set(solver_matrices,[distributed_matrix_compressed_row_storage_type], &
9406 CALL solver_matrices_storage_type_set(solver_matrices,[distributed_matrix_block_storage_type], &
9409 local_error=
"The specified solver equations sparsity type of "// &
9410 & trim(numbertovstring(solver_equations%SPARSITY_TYPE,
"*",err,error))// &
9412 CALL flagerror(local_error,err,error,*999)
9414 CALL solver_matrices_create_finish(solver_matrices,err,error,*999)
9416 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
9421 SELECT CASE(linear_direct_solver%SOLVER_LIBRARY)
9426 CALL petsc_kspcreate(computational_environment%MPI_COMM,linear_direct_solver%KSP,err,error,*999)
9429 CALL petsc_kspsetfromoptions(linear_direct_solver%KSP,err,error,*999)
9431 IF(solver_matrices%NUMBER_OF_MATRICES==1)
THEN 9432 solver_matrix=>solver_matrices%MATRICES(1)%PTR%MATRIX
9433 IF(
ASSOCIATED(solver_matrix))
THEN 9434 IF(
ASSOCIATED(solver_matrix%PETSC))
THEN 9435 CALL petsc_kspsetoperators(linear_direct_solver%KSP,solver_matrix%PETSC%MATRIX,solver_matrix%PETSC%MATRIX, &
9438 SELECT CASE(solver_equations%SPARSITY_TYPE)
9440 SELECT CASE(linear_direct_solver%SOLVER_LIBRARY)
9442 CALL flagerror(
"Solver library does not support full matrices. Please use sparse matrices "// &
9443 &
"or select the LAPACK library type for the linear direct solver.",err,error,*999)
9446 SELECT CASE(linear_direct_solver%SOLVER_LIBRARY)
9448 CALL flagerror(
"Solver library does not support sparse matrices. Please use full matrices "// &
9449 &
"or select another solver library type for the linear direct solver.",err,error,*999)
9453 CALL petsc_kspsettype(linear_direct_solver%KSP,petsc_ksppreonly,err,error,*999)
9455 CALL petsc_kspgetpc(linear_direct_solver%KSP,linear_direct_solver%PC,err,error,*999)
9457 CALL petsc_pcsettype(linear_direct_solver%PC,petsc_pclu,err,error,*999)
9458 SELECT CASE(linear_direct_solver%SOLVER_LIBRARY)
9461 CALL petsc_pcfactorsetmatsolverpackage(linear_direct_solver%PC,petsc_mat_solver_mumps,err,error,*999)
9464 CALL petsc_pcfactorsetmatsolverpackage(linear_direct_solver%PC,petsc_mat_solver_superlu_dist, &
9467 CALL flagerror(
"LAPACK not available in this version of PETSc.",err,error,*999)
9470 CALL petsc_pcfactorsetmatsolverpackage(linear_direct_solver%PC,petsc_mat_solver_pastix,err,error,*999)
9473 CALL flagerror(
"Solver matrix PETSc is not associated.",err,error,*999)
9476 CALL flagerror(
"Solver matrices distributed matrix is not associated.",err,error,*999)
9479 local_error=
"The given number of solver matrices of "// &
9480 & trim(numbertovstring(solver_matrices%NUMBER_OF_MATRICES,
"*",err,error))// &
9481 &
" is invalid. There should only be one solver matrix for a linear direct solver." 9482 CALL flagerror(local_error,err,error,*999)
9485 CALL flagerror(
"Not implemented.",err,error,*999)
9487 CALL flagerror(
"Not implemented.",err,error,*999)
9489 CALL flagerror(
"Not implemented.",err,error,*999)
9491 CALL flagerror(
"Not implemented.",err,error,*999)
9493 local_error=
"The solver library type of "// &
9494 & trim(numbertovstring(linear_direct_solver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid." 9495 CALL flagerror(local_error,err,error,*999)
9498 CALL flagerror(
"Not implemented.",err,error,*999)
9500 CALL flagerror(
"Not implemented.",err,error,*999)
9502 local_error=
"The direct solver type of "// &
9503 & trim(numbertovstring(linear_direct_solver%DIRECT_SOLVER_TYPE,
"*",err,error))// &
9505 CALL flagerror(local_error,err,error,*999)
9508 CALL flagerror(
"Linear solver solver is not associated.",err,error,*999)
9511 CALL flagerror(
"Linear direct solver linear solver is not associated.",err,error,*999)
9514 CALL flagerror(
"Linear direct solver is not associated.",err,error,*999)
9517 exits(
"SOLVER_LINEAR_DIRECT_CREATE_FINISH")
9519 999 errorsexits(
"SOLVER_LINEAR_DIRECT_CREATE_FINISH",err,error)
9532 TYPE(linear_direct_solver_type),
POINTER :: LINEAR_DIRECT_SOLVER
9533 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
9534 INTEGER(INTG),
INTENT(OUT) :: ERR
9535 TYPE(varying_string),
INTENT(OUT) :: ERROR
9538 enters(
"SOLVER_LINEAR_DIRECT_FINALISE",err,error,*999)
9540 IF(
ASSOCIATED(linear_direct_solver))
THEN 9541 linear_solver=>linear_direct_solver%LINEAR_SOLVER
9542 IF(
ASSOCIATED(linear_solver))
THEN 9543 IF(.NOT.linear_solver%LINKED_NEWTON_PETSC_SOLVER)
THEN 9547 DEALLOCATE(linear_direct_solver)
9550 exits(
"SOLVER_LINEAR_DIRECT_FINALISE")
9552 999 errorsexits(
"SOLVER_LINEAR_DIRECT_FINALISE",err,error)
9565 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
9566 INTEGER(INTG),
INTENT(OUT) :: ERR
9567 TYPE(varying_string),
INTENT(OUT) :: ERROR
9569 INTEGER(INTG) :: DUMMY_ERR
9570 TYPE(varying_string) :: DUMMY_ERROR
9572 enters(
"SOLVER_LINEAR_DIRECT_INITIALISE",err,error,*998)
9574 IF(
ASSOCIATED(linear_solver))
THEN 9575 IF(
ASSOCIATED(linear_solver%DIRECT_SOLVER))
THEN 9576 CALL flagerror(
"Direct solver is already associated for this linear solver.",err,error,*998)
9578 ALLOCATE(linear_solver%DIRECT_SOLVER,stat=err)
9579 IF(err/=0)
CALL flagerror(
"Could not allocate linear solver direct solver.",err,error,*999)
9580 linear_solver%DIRECT_SOLVER%LINEAR_SOLVER=>linear_solver
9586 CALL flagerror(
"Linear solver is not associated.",err,error,*998)
9589 exits(
"SOLVER_LINEAR_DIRECT_INITIALISE")
9592 998 errorsexits(
"SOLVER_LINEAR_DIRECT_INITIALISE",err,error)
9605 TYPE(linear_direct_solver_type),
POINTER :: DIRECT_SOLVER
9606 INTEGER(INTG),
INTENT(OUT) :: SOLVER_LIBRARY_TYPE
9607 INTEGER(INTG),
INTENT(OUT) :: ERR
9608 TYPE(varying_string),
INTENT(OUT) :: ERROR
9610 TYPE(varying_string) :: LOCAL_ERROR
9612 enters(
"SOLVER_LINEAR_DIRECT_LIBRARY_TYPE_GET",err,error,*999)
9614 IF(
ASSOCIATED(direct_solver))
THEN 9615 SELECT CASE(direct_solver%DIRECT_SOLVER_TYPE)
9617 solver_library_type=direct_solver%SOLVER_LIBRARY
9619 solver_library_type=direct_solver%SOLVER_LIBRARY
9621 solver_library_type=direct_solver%SOLVER_LIBRARY
9623 local_error=
"The direct linear solver type of "// &
9624 & trim(numbertovstring(direct_solver%DIRECT_SOLVER_TYPE,
"*",err,error))//
" is invalid." 9625 CALL flagerror(local_error,err,error,*999)
9628 CALL flagerror(
"Direct linear solver is not associated.",err,error,*999)
9631 exits(
"SOLVER_LINEAR_DIRECT_LIBRARY_TYPE_GET")
9633 999 errorsexits(
"SOLVER_LINEAR_DIRECT_LIBRARY_TYPE_GET",err,error)
9646 TYPE(linear_direct_solver_type),
POINTER :: DIRECT_SOLVER
9647 INTEGER(INTG),
INTENT(IN) :: SOLVER_LIBRARY_TYPE
9648 INTEGER(INTG),
INTENT(OUT) :: ERR
9649 TYPE(varying_string),
INTENT(OUT) :: ERROR
9651 TYPE(varying_string) :: LOCAL_ERROR
9653 enters(
"SOLVER_LINEAR_DIRECT_LIBRARY_TYPE_SET",err,error,*999)
9655 IF(
ASSOCIATED(direct_solver))
THEN 9656 SELECT CASE(direct_solver%DIRECT_SOLVER_TYPE)
9658 SELECT CASE(solver_library_type)
9660 CALL flagerror(
"Not implemeted.",err,error,*999)
9663 direct_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
9666 direct_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
9668 CALL flagerror(
"Not implemeted.",err,error,*999)
9670 CALL flagerror(
"Not implemeted.",err,error,*999)
9672 CALL flagerror(
"Not implemeted.",err,error,*999)
9675 direct_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
9678 direct_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
9680 local_error=
"The specified solver library type of "// &
9681 & trim(numbertovstring(solver_library_type,
"*",err,error))// &
9682 &
" is invalid for a LU direct linear solver." 9683 CALL flagerror(local_error,err,error,*999)
9686 CALL flagerror(
"Not implemented.",err,error,*999)
9688 CALL flagerror(
"Not implemented.",err,error,*999)
9690 local_error=
"The direct linear solver type of "// &
9691 & trim(numbertovstring(direct_solver%DIRECT_SOLVER_TYPE,
"*",err,error))//
" is invalid." 9692 CALL flagerror(local_error,err,error,*999)
9695 CALL flagerror(
"Direct linear solver is not associated.",err,error,*999)
9698 exits(
"SOLVER_LINEAR_DIRECT_LIBRARY_TYPE_SET")
9700 999 errorsexits(
"SOLVER_LINEAR_DIRECT_LIBRARY_TYPE_SET",err,error)
9713 TYPE(linear_direct_solver_type),
POINTER :: DIRECT_SOLVER
9714 INTEGER(INTG),
INTENT(OUT) :: ERR
9715 TYPE(varying_string),
INTENT(OUT) :: ERROR
9717 TYPE(varying_string) :: LOCAL_ERROR
9719 enters(
"SOLVER_LINEAR_DIRECT_LU_FINALISE",err,error,*999)
9721 IF(
ASSOCIATED(direct_solver))
THEN 9722 SELECT CASE(direct_solver%SOLVER_LIBRARY)
9724 CALL flagerror(
"Not implemented.",err,error,*999)
9727 CALL petsc_pcfinalise(direct_solver%PC,err,error,*999)
9728 CALL petsc_kspfinalise(direct_solver%KSP,err,error,*999)
9731 CALL petsc_pcfinalise(direct_solver%PC,err,error,*999)
9732 CALL petsc_kspfinalise(direct_solver%KSP,err,error,*999)
9734 CALL flagerror(
"Not implemented.",err,error,*999)
9736 CALL flagerror(
"Not implemented.",err,error,*999)
9738 CALL flagerror(
"Not implemented.",err,error,*999)
9740 CALL flagerror(
"Not implemented.",err,error,*999)
9743 CALL petsc_pcfinalise(direct_solver%PC,err,error,*999)
9744 CALL petsc_kspfinalise(direct_solver%KSP,err,error,*999)
9747 CALL petsc_pcfinalise(direct_solver%PC,err,error,*999)
9748 CALL petsc_kspfinalise(direct_solver%KSP,err,error,*999)
9750 local_error=
"The solver library type of "// &
9751 & trim(numbertovstring(direct_solver%SOLVER_LIBRARY,
"*",err,error))// &
9752 &
" is invalid for a LU direct linear solver." 9753 CALL flagerror(local_error,err,error,*999)
9757 exits(
"SOLVER_LINEAR_DIRECT_LU_FINALISE")
9759 999 errorsexits(
"SOLVER_LINEAR_DIRECT_LU_FINALISE",err,error)
9772 TYPE(linear_direct_solver_type),
POINTER :: DIRECT_SOLVER
9773 INTEGER(INTG),
INTENT(OUT) :: ERR
9774 TYPE(varying_string),
INTENT(OUT) :: ERROR
9776 INTEGER(INTG) :: DUMMY_ERR
9777 TYPE(varying_string) :: DUMMY_ERROR
9779 enters(
"SOLVER_LINEAR_DIRECT_LU_INITIALISE",err,error,*998)
9781 IF(
ASSOCIATED(direct_solver))
THEN 9785 direct_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
9786 CALL petsc_pcinitialise(direct_solver%PC,err,error,*999)
9787 CALL petsc_kspinitialise(direct_solver%KSP,err,error,*999)
9789 CALL flagerror(
"Direct linear solver is not associated.",err,error,*998)
9792 exits(
"SOLVER_LINEAR_DIRECT_LU_INITIALISE")
9795 998 errorsexits(
"SOLVER_LINEAR_DIRECT_LU_INITIALISE",err,error)
9808 TYPE(linear_direct_solver_type),
POINTER :: DIRECT_SOLVER
9809 INTEGER(INTG),
INTENT(OUT) :: MATRICES_LIBRARY_TYPE
9810 INTEGER(INTG),
INTENT(OUT) :: ERR
9811 TYPE(varying_string),
INTENT(OUT) :: ERROR
9814 enters(
"Solver_LinearDirectMatricesLibraryTypeGet",err,error,*999)
9816 IF(
ASSOCIATED(direct_solver))
THEN 9817 matrices_library_type=direct_solver%SOLVER_MATRICES_LIBRARY
9819 CALL flagerror(
"Direct linear solver is not associated.",err,error,*999)
9822 exits(
"Solver_LinearDirectMatricesLibraryTypeGet")
9824 999 errorsexits(
"Solver_LinearDirectMatricesLibraryTypeGet",err,error)
9839 TYPE(solver_type),
POINTER :: solver
9840 INTEGER(INTG),
INTENT(IN) :: icntl
9841 INTEGER(INTG),
INTENT(IN) :: ivalue
9842 INTEGER(INTG),
INTENT(OUT) :: err
9843 TYPE(varying_string),
INTENT(OUT) :: error
9845 TYPE(linear_solver_type),
POINTER :: linearSolver
9846 TYPE(distributed_matrix_type),
POINTER :: solverMatrix
9847 TYPE(linear_direct_solver_type),
POINTER :: linearDirectSolver
9848 TYPE(solver_type),
POINTER :: linkingSolver
9849 TYPE(solver_equations_type),
POINTER :: linkingSolverEquations,solverEquations
9850 TYPE(solver_matrices_type),
POINTER :: solverMatrices
9851 TYPE(petscmattype) :: petscFactoredMatrix
9852 TYPE(varying_string) :: localError
9854 enters(
"Solver_MumpsSetIcntl",err,error,*999)
9856 IF(
ASSOCIATED(solver))
THEN 9858 linearsolver=>solver%LINEAR_SOLVER
9859 IF(
ASSOCIATED(linearsolver))
THEN 9861 lineardirectsolver=>linearsolver%DIRECT_SOLVER
9862 IF(
ASSOCIATED(lineardirectsolver))
THEN 9863 SELECT CASE(lineardirectsolver%DIRECT_SOLVER_TYPE)
9865 SELECT CASE(lineardirectsolver%SOLVER_LIBRARY)
9867 solverequations=>solver%SOLVER_EQUATIONS
9868 NULLIFY(solvermatrices)
9869 IF(
ASSOCIATED(solverequations))
THEN 9871 solvermatrices=>solverequations%SOLVER_MATRICES
9874 linkingsolver=>solver%LINKING_SOLVER
9875 IF(
ASSOCIATED(linkingsolver))
THEN 9876 linkingsolverequations=>linkingsolver%SOLVER_EQUATIONS
9877 IF(
ASSOCIATED(linkingsolverequations))
THEN 9878 solvermatrices=>linkingsolverequations%SOLVER_MATRICES
9880 CALL flagerror(
"Solver equations is not associated for the linking solver.",err,error,*999)
9884 IF(
ASSOCIATED(solvermatrices))
THEN 9885 IF(solvermatrices%NUMBER_OF_MATRICES==1)
THEN 9886 solvermatrix=>solvermatrices%MATRICES(1)%PTR%MATRIX
9887 IF(
ASSOCIATED(solvermatrix))
THEN 9888 IF(
ASSOCIATED(solvermatrix%PETSC))
THEN 9890 CALL petsc_pcfactorsetupmatsolverpackage(lineardirectsolver%pc,err,error,*999)
9891 CALL petsc_pcfactorgetmatrix(lineardirectsolver%pc,petscfactoredmatrix,err,error,*999)
9893 CALL petsc_matmumpsseticntl(petscfactoredmatrix,icntl,ivalue,err,error,*999)
9895 CALL flagerror(
"Solver matrix PETSc is not associated.",err,error,*999)
9898 CALL flagerror(
"Solver matrices distributed matrix is not associated.",err,error,*999)
9901 localerror=
"The given number of solver matrices of "// &
9902 & trim(numbertovstring(solvermatrices%NUMBER_OF_MATRICES,
"*",err,error))// &
9903 &
" is invalid. There should only be one solver matrix for a linear direct solver." 9904 CALL flagerror(localerror,err,error,*999)
9907 CALL flagerror(
"Solver matrices not associated.",err,error,*999)
9910 localerror=
"The solver library type of "// &
9911 & trim(numbertovstring(lineardirectsolver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid. "// &
9912 &
"Use MUMPS library when calling Solver_MumpsSetIcntl" 9913 CALL flagerror(localerror,err,error,*999)
9916 CALL flagerror(
"Not implemented.",err,error,*999)
9918 CALL flagerror(
"Not implemented.",err,error,*999)
9920 localerror=
"The direct solver type of "// &
9921 & trim(numbertovstring(lineardirectsolver%DIRECT_SOLVER_TYPE,
"*",err,error))// &
9923 CALL flagerror(localerror,err,error,*999)
9926 CALL flagerror(
"Linear solver direct solver is not associated.",err,error,*999)
9929 CALL flagerror(
"Solver is not a direct linear solver.",err,error,*999)
9932 CALL flagerror(
"Solver linear solver is not associated.",err,error,*999)
9935 CALL flagerror(
"Solver is not a linear solver.",err,error,*999)
9938 CALL flagerror(
"Solver is not associated.",err,error,*999)
9941 exits(
"Solver_MumpsSetIcntl")
9943 999 errorsexits(
"Solver_MumpsSetIcntl",err,error)
9958 TYPE(solver_type),
POINTER :: solver
9959 INTEGER(INTG),
INTENT(IN) :: icntl
9960 REAL(DP),
INTENT(IN) :: val
9961 INTEGER(INTG),
INTENT(OUT) :: err
9962 TYPE(varying_string),
INTENT(OUT) :: error
9964 TYPE(linear_solver_type),
POINTER :: linearSolver
9965 TYPE(distributed_matrix_type),
POINTER :: solverMatrix
9966 TYPE(linear_direct_solver_type),
POINTER :: linearDirectSolver
9967 TYPE(solver_type),
POINTER :: linkingSolver
9968 TYPE(solver_equations_type),
POINTER :: linkingSolverEquations,solverEquations
9969 TYPE(solver_matrices_type),
POINTER :: solverMatrices
9970 TYPE(petscmattype) :: petscFactoredMatrix
9971 TYPE(varying_string) :: localError
9973 enters(
"Solver_MumpsSetCntl",err,error,*999)
9975 IF(
ASSOCIATED(solver))
THEN 9976 linearsolver=>solver%LINEAR_SOLVER
9977 IF(
ASSOCIATED(linearsolver))
THEN 9978 lineardirectsolver=>linearsolver%DIRECT_SOLVER
9979 IF(
ASSOCIATED(lineardirectsolver))
THEN 9980 SELECT CASE(lineardirectsolver%DIRECT_SOLVER_TYPE)
9982 SELECT CASE(lineardirectsolver%SOLVER_LIBRARY)
9984 solverequations=>solver%SOLVER_EQUATIONS
9985 NULLIFY(solvermatrices)
9986 IF(
ASSOCIATED(solverequations))
THEN 9988 solvermatrices=>solverequations%SOLVER_MATRICES
9991 linkingsolver=>solver%LINKING_SOLVER
9992 IF(
ASSOCIATED(linkingsolver))
THEN 9993 linkingsolverequations=>linkingsolver%SOLVER_EQUATIONS
9994 IF(
ASSOCIATED(linkingsolverequations))
THEN 9995 solvermatrices=>linkingsolverequations%SOLVER_MATRICES
9997 CALL flagerror(
"Solver equations is not associated for the linking solver.",err,error,*999)
10001 IF(
ASSOCIATED(solvermatrices))
THEN 10002 IF(solvermatrices%NUMBER_OF_MATRICES==1)
THEN 10003 solvermatrix=>solvermatrices%MATRICES(1)%PTR%MATRIX
10004 IF(
ASSOCIATED(solvermatrix))
THEN 10005 IF(
ASSOCIATED(solvermatrix%PETSC))
THEN 10007 CALL petsc_pcfactorsetupmatsolverpackage(lineardirectsolver%PC,err,error,*999)
10008 CALL petsc_pcfactorgetmatrix(lineardirectsolver%PC,petscfactoredmatrix,err,error,*999)
10010 CALL petsc_matmumpssetcntl(petscfactoredmatrix,icntl,val,err,error,*999)
10012 CALL flagerror(
"Solver matrix PETSc is not associated.",err,error,*999)
10015 CALL flagerror(
"Solver matrices distributed matrix is not associated.",err,error,*999)
10018 localerror=
"The given number of solver matrices of "// &
10019 & trim(numbertovstring(solvermatrices%NUMBER_OF_MATRICES,
"*",err,error))// &
10020 &
" is invalid. There should only be one solver matrix for a linear direct solver." 10021 CALL flagerror(localerror,err,error,*999)
10024 CALL flagerror(
"Solver matrices not associated.",err,error,*999)
10027 localerror=
"The solver library type of "// &
10028 & trim(numbertovstring(lineardirectsolver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid. "// &
10029 &
"Use MUMPS library when calling Solver_MumpsSetCntl" 10030 CALL flagerror(localerror,err,error,*999)
10033 CALL flagerror(
"Not implemented.",err,error,*999)
10035 CALL flagerror(
"Not implemented.",err,error,*999)
10037 localerror=
"The direct solver type of "// &
10038 & trim(numbertovstring(lineardirectsolver%DIRECT_SOLVER_TYPE,
"*",err,error))// &
10040 CALL flagerror(localerror,err,error,*999)
10043 CALL flagerror(
"Linear solver solver is not associated.",err,error,*999)
10046 CALL flagerror(
"Linear direct solver linear solver is not associated.",err,error,*999)
10049 CALL flagerror(
"Linear direct solver is not associated.",err,error,*999)
10052 exits(
"Solver_MumpsSetCntl")
10054 999 errorsexits(
"Solver_MumpsSetCntl",err,error)
10067 TYPE(linear_direct_solver_type),
POINTER :: LINEAR_DIRECT_SOLVER
10068 INTEGER(INTG),
INTENT(OUT) :: ERR
10069 TYPE(varying_string),
INTENT(OUT) :: ERROR
10071 INTEGER(INTG) :: global_row,local_row,STORAGE_TYPE
10072 REAL(DP) :: SOLVER_VALUE,VALUE
10073 REAL(DP),
POINTER :: RHS_DATA(:)
10074 TYPE(distributed_vector_type),
POINTER :: RHS_VECTOR,SOLVER_VECTOR
10075 TYPE(domain_mapping_type),
POINTER :: ROW_DOFS_MAPPING
10076 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
10077 TYPE(solver_type),
POINTER :: SOLVER
10078 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
10079 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
10080 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
10081 TYPE(solver_matrix_type),
POINTER :: SOLVER_MATRIX
10082 TYPE(varying_string) :: LOCAL_ERROR
10084 enters(
"SOLVER_LINEAR_DIRECT_SOLVE",err,error,*999)
10086 IF(
ASSOCIATED(linear_direct_solver))
THEN 10087 linear_solver=>linear_direct_solver%LINEAR_SOLVER
10088 IF(
ASSOCIATED(linear_solver))
THEN 10089 solver=>linear_solver%SOLVER
10090 IF(
ASSOCIATED(solver))
THEN 10091 solver_equations=>solver%SOLVER_EQUATIONS
10092 IF(
ASSOCIATED(solver_equations))
THEN 10093 solver_matrices=>solver_equations%SOLVER_MATRICES
10094 IF(
ASSOCIATED(solver_matrices))
THEN 10095 IF(solver_matrices%NUMBER_OF_MATRICES==1)
THEN 10096 solver_matrix=>solver_matrices%MATRICES(1)%PTR
10097 IF(
ASSOCIATED(solver_matrix))
THEN 10098 rhs_vector=>solver_matrices%RHS_VECTOR
10099 IF(
ASSOCIATED(rhs_vector))
THEN 10100 solver_vector=>solver_matrices%MATRICES(1)%PTR%SOLVER_VECTOR
10101 IF(
ASSOCIATED(solver_vector))
THEN 10102 CALL distributed_matrix_storage_type_get(solver_matrix%MATRIX,storage_type,err,error,*999)
10103 IF(storage_type==distributed_matrix_diagonal_storage_type)
THEN 10104 solver_mapping=>solver_equations%SOLVER_MAPPING
10105 IF(
ASSOCIATED(solver_mapping))
THEN 10106 row_dofs_mapping=>solver_mapping%ROW_DOFS_MAPPING
10107 IF(
ASSOCIATED(row_dofs_mapping))
THEN 10108 CALL distributed_vector_data_get(rhs_vector,rhs_data,err,error,*999)
10109 DO local_row=1,solver_mapping%NUMBER_OF_ROWS
10110 global_row=row_dofs_mapping%LOCAL_TO_GLOBAL_MAP(local_row)
10111 CALL distributed_matrix_values_get(solver_matrix%MATRIX,local_row,global_row,
VALUE,err,error,*999)
10112 IF(abs(
VALUE)>zero_tolerance)
THEN 10113 solver_value=rhs_data(local_row)/
VALUE 10114 CALL distributed_vector_values_set(solver_vector,local_row,solver_value,err,error,*999)
10116 local_error=
"The linear solver matrix has a zero pivot on row "// &
10117 & trim(numbertovstring(local_row,
"*",err,error))//
"." 10118 CALL flagerror(local_error,err,error,*999)
10121 CALL distributed_vector_data_restore(rhs_vector,rhs_data,err,error,*999)
10123 CALL flagerror(
"Solver mapping row dofs mapping is not associated.",err,error,*999)
10126 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
10129 SELECT CASE(linear_direct_solver%DIRECT_SOLVER_TYPE)
10131 SELECT CASE(linear_direct_solver%SOLVER_LIBRARY)
10133 CALL flagerror(
"Not implemented.",err,error,*999)
10136 IF(
ASSOCIATED(rhs_vector%PETSC))
THEN 10137 IF(
ASSOCIATED(solver_vector%PETSC))
THEN 10138 IF(
ASSOCIATED(solver_matrix%MATRIX))
THEN 10139 IF(
ASSOCIATED(solver_matrix%MATRIX%PETSC))
THEN 10140 IF(solver_matrix%UPDATE_MATRIX)
THEN 10141 CALL petsc_kspsetoperators(linear_direct_solver%KSP,solver_matrix%MATRIX%PETSC%MATRIX, &
10142 & solver_matrix%MATRIX%PETSC%MATRIX,err,error,*999)
10144 CALL petsc_pcsetreusepreconditioner(linear_direct_solver%PC,.true.,err,error,*999)
10147 CALL petsc_kspsolve(linear_direct_solver%KSP,rhs_vector%PETSC%VECTOR, &
10148 & solver_vector%PETSC%VECTOR,err,error,*999)
10150 CALL flagerror(
"Solver matrix PETSc is not associated.",err,error,*999)
10153 CALL flagerror(
"Solver matrix distributed matrix is not associated.",err,error,*999)
10156 CALL flagerror(
"Solver vector PETSc vector is not associated.",err,error,*999)
10159 CALL flagerror(
"RHS vector petsc PETSc is not associated.",err,error,*999)
10163 IF(
ASSOCIATED(rhs_vector%PETSC))
THEN 10164 IF(
ASSOCIATED(solver_vector%PETSC))
THEN 10165 IF(
ASSOCIATED(solver_matrix%MATRIX))
THEN 10166 IF(
ASSOCIATED(solver_matrix%MATRIX%PETSC))
THEN 10167 IF(solver_matrix%UPDATE_MATRIX)
THEN 10168 CALL petsc_kspsetoperators(linear_direct_solver%KSP,solver_matrix%MATRIX%PETSC%MATRIX, &
10169 & solver_matrix%MATRIX%PETSC%MATRIX,err,error,*999)
10171 CALL petsc_pcsetreusepreconditioner(linear_direct_solver%PC,petsc_true,err,error,*999)
10174 CALL petsc_kspsolve(linear_direct_solver%KSP,rhs_vector%PETSC%VECTOR, &
10175 & solver_vector%PETSC%VECTOR,err,error,*999)
10177 CALL flagerror(
"Solver matrix PETSc is not associated.",err,error,*999)
10180 CALL flagerror(
"Solver matrix distributed matrix is not associated.",err,error,*999)
10183 CALL flagerror(
"Solver vector PETSc vector is not associated.",err,error,*999)
10186 CALL flagerror(
"RHS vector petsc PETSc is not associated.",err,error,*999)
10189 CALL flagerror(
"Not implemented.",err,error,*999)
10191 CALL flagerror(
"Not implemented.",err,error,*999)
10193 CALL flagerror(
"Not implemented.",err,error,*999)
10195 CALL flagerror(
"Not implemented.",err,error,*999)
10198 IF(
ASSOCIATED(rhs_vector%PETSC))
THEN 10199 IF(
ASSOCIATED(solver_vector%PETSC))
THEN 10200 IF(
ASSOCIATED(solver_matrix%MATRIX))
THEN 10201 IF(
ASSOCIATED(solver_matrix%MATRIX%PETSC))
THEN 10202 IF(solver_matrix%UPDATE_MATRIX)
THEN 10203 CALL petsc_kspsetoperators(linear_direct_solver%KSP,solver_matrix%MATRIX%PETSC%MATRIX, &
10204 & solver_matrix%MATRIX%PETSC%MATRIX,err,error,*999)
10206 CALL petsc_pcsetreusepreconditioner(linear_direct_solver%PC,.true.,err,error,*999)
10209 CALL petsc_kspsolve(linear_direct_solver%KSP,rhs_vector%PETSC%VECTOR, &
10210 & solver_vector%PETSC%VECTOR,err,error,*999)
10212 CALL flagerror(
"Solver matrix PETSc is not associated.",err,error,*999)
10215 CALL flagerror(
"Solver matrix distributed matrix is not associated.",err,error,*999)
10218 CALL flagerror(
"Solver vector PETSc vector is not associated.",err,error,*999)
10221 CALL flagerror(
"RHS vector petsc PETSc is not associated.",err,error,*999)
10225 IF(
ASSOCIATED(rhs_vector%PETSC))
THEN 10226 IF(
ASSOCIATED(solver_vector%PETSC))
THEN 10227 IF(
ASSOCIATED(solver_matrix%MATRIX))
THEN 10228 IF(
ASSOCIATED(solver_matrix%MATRIX%PETSC))
THEN 10229 IF(solver_matrix%UPDATE_MATRIX)
THEN 10230 CALL petsc_kspsetoperators(linear_direct_solver%KSP,solver_matrix%MATRIX%PETSC%MATRIX, &
10231 & solver_matrix%MATRIX%PETSC%MATRIX,err,error,*999)
10233 CALL petsc_pcsetreusepreconditioner(linear_direct_solver%PC,.true.,err,error,*999)
10236 CALL petsc_kspsolve(linear_direct_solver%KSP,rhs_vector%PETSC%VECTOR, &
10237 & solver_vector%PETSC%VECTOR,err,error,*999)
10239 CALL flagerror(
"Solver matrix PETSc is not associated.",err,error,*999)
10242 CALL flagerror(
"Solver matrix distributed matrix is not associated.",err,error,*999)
10245 CALL flagerror(
"Solver vector PETSc vector is not associated.",err,error,*999)
10248 CALL flagerror(
"RHS vector petsc PETSc is not associated.",err,error,*999)
10251 local_error=
"The solver library type of "// &
10252 & trim(numbertovstring(linear_direct_solver%SOLVER_LIBRARY,
"*",err,error))// &
10253 &
" is invalid for a LU direct linear solver." 10254 CALL flagerror(local_error,err,error,*999)
10257 CALL flagerror(
"Not implemented.",err,error,*999)
10259 CALL flagerror(
"Not implemented.",err,error,*999)
10261 local_error=
"The direct linear solver type of "// &
10262 & trim(numbertovstring(linear_direct_solver%DIRECT_SOLVER_TYPE,
"*",err,error))// &
10264 CALL flagerror(local_error,err,error,*999)
10268 CALL flagerror(
"Solver vector is not associated.",err,error,*999)
10271 CALL flagerror(
"RHS vector is not associated.",err,error,*999)
10274 CALL flagerror(
"Solver matrix is not associated.",err,error,*999)
10277 local_error=
"The number of solver matrices of "// &
10278 & trim(numbertovstring(solver_matrices%NUMBER_OF_MATRICES,
"*",err,error))// &
10279 &
" is invalid. There should only be one solver matrix for a linear direct solver." 10280 CALL flagerror(local_error,err,error,*999)
10283 CALL flagerror(
"Solver equations solver matrices is not associated.",err,error,*999)
10286 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
10289 CALL flagerror(
"Linear solver solver is not associated.",err,error,*999)
10292 CALL flagerror(
"Linear direct solver linear solver is not associated.",err,error,*999)
10295 CALL flagerror(
"Linear direct solver is not associated.",err,error,*999)
10298 exits(
"SOLVER_LINEAR_DIRECT_SOLVE")
10300 999 errorsexits(
"SOLVER_LINEAR_DIRECT_SOLVE",err,error)
10313 TYPE(linear_direct_solver_type),
POINTER :: LINEAR_DIRECT_SOLVER
10314 INTEGER(INTG),
INTENT(OUT) :: ERR
10315 TYPE(varying_string),
INTENT(OUT) :: ERROR
10318 enters(
"SOLVER_LINEAR_DIRECT_SVD_FINALISE",err,error,*999)
10320 IF(
ASSOCIATED(linear_direct_solver))
THEN 10321 CALL flagerror(
"Not implemented.",err,error,*999)
10324 exits(
"SOLVER_LINEAR_DIRECT_SVD_FINALISE")
10326 999 errorsexits(
"SOLVER_LINEAR_DIRECT_SVD_FINALISE",err,error)
10339 TYPE(linear_direct_solver_type),
POINTER :: DIRECT_SOLVER
10340 INTEGER(INTG),
INTENT(OUT) :: ERR
10341 TYPE(varying_string),
INTENT(OUT) :: ERROR
10344 enters(
"SOLVER_LINEAR_DIRECT_SVD_INITIALISE",err,error,*999)
10346 IF(
ASSOCIATED(direct_solver))
THEN 10347 CALL flagerror(
"Not implemented.",err,error,*999)
10349 CALL flagerror(
"Direct linear solver is not associated.",err,error,*999)
10352 exits(
"SOLVER_LINEAR_DIRECT_SVD_INITIALISE")
10354 999 errorsexits(
"SOLVER_LINEAR_DIRECT_SVD_INITIALISE",err,error)
10367 TYPE(solver_type),
POINTER :: SOLVER
10368 INTEGER(INTG),
INTENT(IN) :: DIRECT_SOLVER_TYPE
10369 INTEGER(INTG),
INTENT(OUT) :: ERR
10370 TYPE(varying_string),
INTENT(OUT) :: ERROR
10372 TYPE(varying_string) :: LOCAL_ERROR
10374 enters(
"SOLVER_LINEAR_DIRECT_TYPE_SET",err,error,*999)
10376 IF(
ASSOCIATED(solver))
THEN 10377 IF(solver%SOLVER_FINISHED)
THEN 10378 CALL flagerror(
"Solver has already been finished.",err,error,*999)
10381 IF(
ASSOCIATED(solver%LINEAR_SOLVER))
THEN 10383 IF(
ASSOCIATED(solver%LINEAR_SOLVER%DIRECT_SOLVER))
THEN 10384 IF(direct_solver_type/=solver%LINEAR_SOLVER%DIRECT_SOLVER%DIRECT_SOLVER_TYPE)
THEN 10386 SELECT CASE(solver%LINEAR_SOLVER%DIRECT_SOLVER%SOLVER_LIBRARY)
10394 local_error=
"The direct solver type of "//trim(numbertovstring(direct_solver_type,
"*",err,error))// &
10396 CALL flagerror(local_error,err,error,*999)
10399 SELECT CASE(direct_solver_type)
10407 local_error=
"The direct solver type of "//trim(numbertovstring(direct_solver_type,
"*",err,error))// &
10409 CALL flagerror(local_error,err,error,*999)
10413 CALL flagerror(
"The solver linear solver direct solver is not associated.",err,error,*999)
10416 CALL flagerror(
"The solver is not a linear direct solver.",err,error,*999)
10419 CALL flagerror(
"The solver linear solver is not associated.",err,error,*999)
10422 CALL flagerror(
"The solver is not a linear solver.",err,error,*999)
10426 CALL flagerror(
"Solver is not associated.",err,error,*999)
10429 exits(
"SOLVER_LINEAR_DIRECT_TYPE_SET")
10431 999 errorsexits(
"SOLVER_LINEAR_DIRECT_TYPE_SET",err,error)
10444 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
10445 INTEGER(INTG),
INTENT(OUT) :: ERR
10446 TYPE(varying_string),
INTENT(OUT) :: ERROR
10449 enters(
"SOLVER_LINEAR_FINALISE",err,error,*999)
10451 IF(
ASSOCIATED(linear_solver))
THEN 10454 DEALLOCATE(linear_solver)
10457 exits(
"SOLVER_LINEAR_FINALISE")
10459 999 errorsexits(
"SOLVER_LINEAR_FINALISE",err,error)
10472 TYPE(solver_type),
POINTER :: SOLVER
10473 INTEGER(INTG),
INTENT(OUT) :: ERR
10474 TYPE(varying_string),
INTENT(OUT) :: ERROR
10476 INTEGER(INTG) :: DUMMY_ERR
10477 TYPE(varying_string) :: DUMMY_ERROR
10479 enters(
"SOLVER_LINEAR_INITIALISE",err,error,*998)
10481 IF(
ASSOCIATED(solver))
THEN 10482 IF(
ASSOCIATED(solver%LINEAR_SOLVER))
THEN 10483 CALL flagerror(
"Linear solver is already associated for this solver.",err,error,*998)
10486 ALLOCATE(solver%LINEAR_SOLVER,stat=err)
10487 IF(err/=0)
CALL flagerror(
"Could not allocate solver linear solver.",err,error,*999)
10488 solver%LINEAR_SOLVER%SOLVER=>solver
10489 solver%LINEAR_SOLVER%LINKED_NEWTON_PETSC_SOLVER=.false.
10490 NULLIFY(solver%LINEAR_SOLVER%DIRECT_SOLVER)
10491 NULLIFY(solver%LINEAR_SOLVER%ITERATIVE_SOLVER)
10497 CALL flagerror(
"Solver is not associated.",err,error,*998)
10500 exits(
"SOLVER_LINEAR_INITIALISE")
10503 998 errorsexits(
"SOLVER_LINEAR_INITIALISE",err,error)
10516 TYPE(solver_type),
POINTER :: SOLVER
10517 REAL(DP),
INTENT(IN) :: ABSOLUTE_TOLERANCE
10518 INTEGER(INTG),
INTENT(OUT) :: ERR
10519 TYPE(varying_string),
INTENT(OUT) :: ERROR
10521 TYPE(varying_string) :: LOCAL_ERROR
10523 enters(
"Solver_LinearIterativeAbsoluteToleranceSet",err,error,*999)
10525 IF(
ASSOCIATED(solver))
THEN 10526 IF(solver%SOLVER_FINISHED)
THEN 10527 CALL flagerror(
"Solver has already been finished.",err,error,*999)
10530 IF(
ASSOCIATED(solver%LINEAR_SOLVER))
THEN 10532 IF(
ASSOCIATED(solver%LINEAR_SOLVER%ITERATIVE_SOLVER))
THEN 10533 IF(absolute_tolerance>zero_tolerance)
THEN 10534 solver%LINEAR_SOLVER%ITERATIVE_SOLVER%ABSOLUTE_TOLERANCE=absolute_tolerance
10536 local_error=
"The specified absolute tolerance of "//trim(numbertovstring(absolute_tolerance,
"*",err,error))// &
10537 &
" is invalid. The absolute tolerance must be > 0." 10538 CALL flagerror(local_error,err,error,*999)
10541 CALL flagerror(
"The solver linear solver iterative solver is not associated.",err,error,*999)
10544 CALL flagerror(
"The solver is not a linear iterative solver.",err,error,*999)
10547 CALL flagerror(
"The solver linear solver is not associated.",err,error,*999)
10550 CALL flagerror(
"The solver is not a linear solver.",err,error,*999)
10554 CALL flagerror(
"Solver is not associated.",err,error,*999)
10557 exits(
"Solver_LinearIterativeAbsoluteToleranceSet")
10559 999 errorsexits(
"Solver_LinearIterativeAbsoluteToleranceSet",err,error)
10572 TYPE(linear_iterative_solver_type),
POINTER :: LINEAR_ITERATIVE_SOLVER
10573 INTEGER(INTG),
INTENT(OUT) :: ERR
10574 TYPE(varying_string),
INTENT(OUT) :: ERROR
10576 TYPE(distributed_matrix_type),
POINTER :: SOLVER_MATRIX
10577 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
10578 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
10579 TYPE(newton_linesearch_solver_type),
POINTER :: NEWTON_LINESEARCH_SOLVER
10580 TYPE(newton_trustregion_solver_type),
POINTER :: NEWTON_TRUSTREGION_SOLVER
10581 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
10582 TYPE(quasi_newton_linesearch_solver_type),
POINTER :: QUASI_NEWTON_LINESEARCH_SOLVER
10583 TYPE(quasi_newton_trustregion_solver_type),
POINTER :: QUASI_NEWTON_TRUSTREGION_SOLVER
10584 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
10585 TYPE(solver_type),
POINTER :: LINKING_SOLVER,SOLVER
10586 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
10587 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
10588 TYPE(varying_string) :: LOCAL_ERROR
10590 enters(
"SOLVER_LINEAR_ITERATIVE_CREATE_FINISH",err,error,*999)
10592 IF(
ASSOCIATED(linear_iterative_solver))
THEN 10593 linear_solver=>linear_iterative_solver%LINEAR_SOLVER
10594 IF(
ASSOCIATED(linear_solver))
THEN 10595 solver=>linear_solver%SOLVER
10596 IF(
ASSOCIATED(solver))
THEN 10598 SELECT CASE(linear_iterative_solver%SOLVER_LIBRARY)
10600 CALL flagerror(
"Not implemented.",err,error,*999)
10602 IF(
ASSOCIATED(solver%LINKING_SOLVER))
THEN 10603 solver_equations=>solver%LINKING_SOLVER%SOLVER_EQUATIONS
10604 IF(
ASSOCIATED(solver_equations))
THEN 10605 solver_matrices=>solver_equations%SOLVER_MATRICES
10606 IF(.NOT.
ASSOCIATED(solver_matrices)) &
10607 &
CALL flagerror(
"Linked solver equation solver matrices is not associated.",err,error,*999)
10609 CALL flagerror(
"Linked solver solver equations is not associated.",err,error,*999)
10612 solver_equations=>solver%SOLVER_EQUATIONS
10613 IF(
ASSOCIATED(solver_equations))
THEN 10615 NULLIFY(solver_matrices)
10616 CALL solver_matrices_create_start(solver_equations,solver_matrices,err,error,*999)
10618 SELECT CASE(solver_equations%SPARSITY_TYPE)
10620 CALL solver_matrices_storage_type_set(solver_matrices,[distributed_matrix_compressed_row_storage_type], &
10623 CALL solver_matrices_storage_type_set(solver_matrices,[distributed_matrix_block_storage_type], &
10626 local_error=
"The specified solver equations sparsity type of "// &
10627 & trim(numbertovstring(solver_equations%SPARSITY_TYPE,
"*",err,error))// &
10629 CALL flagerror(local_error,err,error,*999)
10631 CALL solver_matrices_create_finish(solver_matrices,err,error,*999)
10633 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
10637 IF(linear_solver%LINKED_NEWTON_PETSC_SOLVER)
THEN 10638 linking_solver=>solver%LINKING_SOLVER
10639 IF(
ASSOCIATED(linking_solver))
THEN 10640 nonlinear_solver=>linking_solver%NONLINEAR_SOLVER
10641 IF(
ASSOCIATED(nonlinear_solver))
THEN 10643 newton_solver=>nonlinear_solver%NEWTON_SOLVER
10644 IF(
ASSOCIATED(newton_solver))
THEN 10645 SELECT CASE(newton_solver%NEWTON_SOLVE_TYPE)
10647 newton_linesearch_solver=>newton_solver%LINESEARCH_SOLVER
10648 IF(
ASSOCIATED(newton_linesearch_solver))
THEN 10649 CALL petsc_snesgetksp(newton_linesearch_solver%snes,linear_iterative_solver%KSP,err,error,*999)
10651 CALL flagerror(
"Newton solver linesearch solver is not associated.",err,error,*999)
10654 newton_trustregion_solver=>newton_solver%TRUSTREGION_SOLVER
10655 IF(
ASSOCIATED(newton_trustregion_solver))
THEN 10656 CALL petsc_snesgetksp(newton_trustregion_solver%snes,linear_iterative_solver%KSP,err,error,*999)
10658 CALL flagerror(
"Newton solver linesearch solver is not associated.",err,error,*999)
10661 local_error=
"The Newton solve type of "// &
10662 & trim(numbertovstring(newton_solver%NEWTON_SOLVE_TYPE,
"*",err,error))//
"is invalid." 10663 CALL flagerror(local_error,err,error,*999)
10666 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
10669 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
10670 IF(
ASSOCIATED(quasi_newton_solver))
THEN 10671 SELECT CASE(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE)
10673 quasi_newton_linesearch_solver=>quasi_newton_solver%LINESEARCH_SOLVER
10674 IF(
ASSOCIATED(quasi_newton_linesearch_solver))
THEN 10675 CALL petsc_snesgetksp(quasi_newton_linesearch_solver%snes,linear_iterative_solver%KSP,err,error,*999)
10677 CALL flagerror(
"Quasi-Newton solver linesearch solver is not associated.",err,error,*999)
10680 quasi_newton_trustregion_solver=>quasi_newton_solver%TRUSTREGION_SOLVER
10681 IF(
ASSOCIATED(quasi_newton_trustregion_solver))
THEN 10682 CALL petsc_snesgetksp(quasi_newton_trustregion_solver%snes,linear_iterative_solver%KSP,err,error,*999)
10684 CALL flagerror(
"Quasi-Newton solver linesearch solver is not associated.",err,error,*999)
10687 local_error=
"The Quasi-Newton solve type of "// &
10688 & trim(numbertovstring(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE,
"*",err,error))//
"is invalid." 10689 CALL flagerror(local_error,err,error,*999)
10692 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
10696 CALL flagerror(
"Linking solver nonlinear solver is not associated.",err,error,*999)
10699 CALL flagerror(
"Solver linking solve is not associated.",err,error,*999)
10702 CALL petsc_kspcreate(computational_environment%MPI_COMM,linear_iterative_solver%KSP,err,error,*999)
10705 SELECT CASE(linear_iterative_solver%ITERATIVE_SOLVER_TYPE)
10707 CALL petsc_kspsettype(linear_iterative_solver%KSP,petsc_ksprichardson,err,error,*999)
10709 CALL petsc_kspsettype(linear_iterative_solver%KSP,petsc_kspchebyshev,err,error,*999)
10711 CALL petsc_kspsettype(linear_iterative_solver%KSP,petsc_kspcg,err,error,*999)
10713 CALL petsc_kspsettype(linear_iterative_solver%KSP,petsc_kspbicg,err,error,*999)
10715 CALL petsc_kspsettype(linear_iterative_solver%KSP,petsc_kspgmres,err,error,*999)
10716 CALL petsc_kspgmressetrestart(linear_iterative_solver%KSP,linear_iterative_solver%GMRES_RESTART,err,error,*999)
10718 CALL petsc_kspsettype(linear_iterative_solver%KSP,petsc_kspbcgs,err,error,*999)
10720 CALL petsc_kspsettype(linear_iterative_solver%KSP,petsc_kspcgs,err,error,*999)
10722 local_error=
"The iterative solver type of "// &
10723 & trim(numbertovstring(linear_iterative_solver%ITERATIVE_SOLVER_TYPE,
"*",err,error))//
" is invalid." 10724 CALL flagerror(local_error,err,error,*999)
10727 CALL petsc_kspgetpc(linear_iterative_solver%KSP,linear_iterative_solver%PC,err,error,*999)
10729 SELECT CASE(linear_iterative_solver%ITERATIVE_PRECONDITIONER_TYPE)
10731 CALL petsc_pcsettype(linear_iterative_solver%PC,petsc_pcnone,err,error,*999)
10733 CALL petsc_pcsettype(linear_iterative_solver%PC,petsc_pcjacobi,err,error,*999)
10735 CALL petsc_pcsettype(linear_iterative_solver%PC,petsc_pcbjacobi,err,error,*999)
10737 CALL petsc_pcsettype(linear_iterative_solver%PC,petsc_pcsor,err,error,*999)
10739 CALL petsc_pcsettype(linear_iterative_solver%PC,petsc_pcicc,err,error,*999)
10741 CALL petsc_pcsettype(linear_iterative_solver%PC,petsc_pcilu,err,error,*999)
10743 CALL petsc_pcsettype(linear_iterative_solver%PC,petsc_pcasm,err,error,*999)
10745 local_error=
"The iterative preconditioner type of "// &
10746 & trim(numbertovstring(linear_iterative_solver%ITERATIVE_PRECONDITIONER_TYPE,
"*",err,error))//
" is invalid." 10747 CALL flagerror(local_error,err,error,*999)
10750 CALL petsc_kspsettolerances(linear_iterative_solver%KSP,linear_iterative_solver%RELATIVE_TOLERANCE, &
10751 & linear_iterative_solver%ABSOLUTE_TOLERANCE,linear_iterative_solver%DIVERGENCE_TOLERANCE, &
10752 & linear_iterative_solver%MAXIMUM_NUMBER_OF_ITERATIONS,err,error,*999)
10754 CALL petsc_kspsetfromoptions(linear_iterative_solver%KSP,err,error,*999)
10756 IF(solver_matrices%NUMBER_OF_MATRICES==1)
THEN 10757 solver_matrix=>solver_matrices%MATRICES(1)%PTR%MATRIX
10758 IF(
ASSOCIATED(solver_matrix))
THEN 10759 IF(
ASSOCIATED(solver_matrix%PETSC))
THEN 10760 CALL petsc_kspsetoperators(linear_iterative_solver%KSP,solver_matrix%PETSC%MATRIX,solver_matrix%PETSC%MATRIX, &
10763 CALL flagerror(
"Solver matrix PETSc is not associated.",err,error,*999)
10766 CALL flagerror(
"Solver matrices distributed matrix is not associated.",err,error,*999)
10769 local_error=
"The given number of solver matrices of "// &
10770 & trim(numbertovstring(solver_matrices%NUMBER_OF_MATRICES,
"*",err,error))// &
10771 &
" is invalid. There should only be one solver matrix for a linear iterative solver." 10772 CALL flagerror(local_error,err,error,*999)
10775 local_error=
"The solver library type of "// &
10776 & trim(numbertovstring(linear_iterative_solver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid." 10777 CALL flagerror(local_error,err,error,*999)
10780 CALL flagerror(
"Linear solver solver is not associated.",err,error,*999)
10783 CALL flagerror(
"Linear iterative solver linear solver is not associated.",err,error,*999)
10786 CALL flagerror(
"Linear iterative solver is not associated.",err,error,*999)
10789 exits(
"SOLVER_LINEAR_ITERATIVE_CREATE_FINISH")
10791 999 errorsexits(
"SOLVER_LINEAR_ITERATIVE_CREATE_FINISH",err,error)
10804 TYPE(solver_type),
POINTER :: SOLVER
10805 REAL(DP),
INTENT(IN) :: DIVERGENCE_TOLERANCE
10806 INTEGER(INTG),
INTENT(OUT) :: ERR
10807 TYPE(varying_string),
INTENT(OUT) :: ERROR
10809 TYPE(varying_string) :: LOCAL_ERROR
10811 enters(
"Solver_LinearIterativeDivergenceToleranceSet",err,error,*999)
10813 IF(
ASSOCIATED(solver))
THEN 10814 IF(solver%SOLVER_FINISHED)
THEN 10815 CALL flagerror(
"Solver has already been finished.",err,error,*999)
10818 IF(
ASSOCIATED(solver%LINEAR_SOLVER))
THEN 10820 IF(
ASSOCIATED(solver%LINEAR_SOLVER%ITERATIVE_SOLVER))
THEN 10821 IF(divergence_tolerance>zero_tolerance)
THEN 10822 solver%LINEAR_SOLVER%ITERATIVE_SOLVER%DIVERGENCE_TOLERANCE=divergence_tolerance
10824 local_error=
"The specified divergence tolerance of "// &
10825 & trim(numbertovstring(divergence_tolerance,
"*",err,error))// &
10826 &
" is invalid. The divergence tolerance must be > 0." 10827 CALL flagerror(local_error,err,error,*999)
10830 CALL flagerror(
"The solver linear solver iterative solver is not associated.",err,error,*999)
10833 CALL flagerror(
"The solver is not a linear iterative solver.",err,error,*999)
10836 CALL flagerror(
"The solver linear solver is not associated.",err,error,*999)
10839 CALL flagerror(
"The solver is not a linear solver.",err,error,*999)
10843 CALL flagerror(
"Solver is not associated.",err,error,*999)
10846 exits(
"Solver_LinearIterativeDivergenceToleranceSet")
10848 999 errors(
"Solver_LinearIterativeDivergenceToleranceSet",err,error)
10849 exits(
"Solver_LinearIterativeDivergenceToleranceSet")
10862 TYPE(linear_iterative_solver_type),
POINTER :: LINEAR_ITERATIVE_SOLVER
10863 INTEGER(INTG),
INTENT(OUT) :: ERR
10864 TYPE(varying_string),
INTENT(OUT) :: ERROR
10866 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
10868 enters(
"SOLVER_LINEAR_ITERATIVE_FINALISE",err,error,*999)
10870 IF(
ASSOCIATED(linear_iterative_solver))
THEN 10871 linear_solver=>linear_iterative_solver%LINEAR_SOLVER
10872 IF(
ASSOCIATED(linear_solver))
THEN 10873 IF(.NOT.linear_solver%LINKED_NEWTON_PETSC_SOLVER)
THEN 10874 CALL petsc_pcfinalise(linear_iterative_solver%PC,err,error,*999)
10875 CALL petsc_kspfinalise(linear_iterative_solver%KSP,err,error,*999)
10878 DEALLOCATE(linear_iterative_solver)
10881 exits(
"SOLVER_LINEAR_ITERATIVE_FINALISE")
10883 999 errorsexits(
"SOLVER_LINEAR_ITERATIVE_FINALISE",err,error)
10896 TYPE(solver_type),
POINTER :: SOLVER
10897 INTEGER(INTG),
INTENT(IN) :: GMRES_RESTART
10898 INTEGER(INTG),
INTENT(OUT) :: ERR
10899 TYPE(varying_string),
INTENT(OUT) :: ERROR
10901 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
10902 TYPE(linear_iterative_solver_type),
POINTER :: ITERATIVE_SOLVER
10903 TYPE(varying_string) :: LOCAL_ERROR
10905 enters(
"SOLVER_LINEAR_ITERATIVE_GMRES_RESTART_SET",err,error,*999)
10907 IF(
ASSOCIATED(solver))
THEN 10908 IF(solver%SOLVER_FINISHED)
THEN 10909 CALL flagerror(
"Solver has already been finished.",err,error,*999)
10912 linear_solver=>solver%LINEAR_SOLVER
10913 IF(
ASSOCIATED(linear_solver))
THEN 10915 iterative_solver=>linear_solver%ITERATIVE_SOLVER
10916 IF(
ASSOCIATED(iterative_solver))
THEN 10918 IF(gmres_restart>0)
THEN 10919 iterative_solver%GMRES_RESTART=gmres_restart
10921 local_error=
"The specified GMRES restart value of "//trim(numbertovstring(gmres_restart,
"*",err,error))// &
10922 &
" is invalid. The GMRES restart value must be > 0." 10923 CALL flagerror(local_error,err,error,*999)
10926 CALL flagerror(
"The linear iterative solver is not a GMRES linear iterative solver.",err,error,*999)
10929 CALL flagerror(
"The solver linear solver iterative solver is not associated.",err,error,*999)
10932 CALL flagerror(
"The solver is not a linear iterative solver.",err,error,*999)
10935 CALL flagerror(
"The solver linear solver is not associated.",err,error,*999)
10938 CALL flagerror(
"The solver is not a linear solver.",err,error,*999)
10942 CALL flagerror(
"Solver is not associated.",err,error,*999)
10945 exits(
"SOLVER_LINEAR_ITERATIVE_GMRES_RESTART_SET")
10947 999 errorsexits(
"SOLVER_LINEAR_ITERATIVE_GMRES_RESTART_SET",err,error)
10960 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
10961 INTEGER(INTG),
INTENT(OUT) :: ERR
10962 TYPE(varying_string),
INTENT(OUT) :: ERROR
10964 INTEGER(INTG) :: DUMMY_ERR
10965 TYPE(varying_string) :: DUMMY_ERROR
10967 enters(
"SOLVER_LINEAR_ITERATIVE_INITIALISE",err,error,*998)
10969 IF(
ASSOCIATED(linear_solver))
THEN 10970 IF(
ASSOCIATED(linear_solver%ITERATIVE_SOLVER))
THEN 10971 CALL flagerror(
"Iterative solver is already associated for this linear solver.",err,error,*998)
10974 ALLOCATE(linear_solver%ITERATIVE_SOLVER,stat=err)
10975 IF(err/=0)
CALL flagerror(
"Could not allocate linear solver iterative solver.",err,error,*999)
10976 linear_solver%ITERATIVE_SOLVER%LINEAR_SOLVER=>linear_solver
10978 linear_solver%ITERATIVE_SOLVER%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
10982 linear_solver%ITERATIVE_SOLVER%MAXIMUM_NUMBER_OF_ITERATIONS=100000
10983 linear_solver%ITERATIVE_SOLVER%RELATIVE_TOLERANCE=1.0e-05_dp
10984 linear_solver%ITERATIVE_SOLVER%ABSOLUTE_TOLERANCE=1.0e-10_dp
10985 linear_solver%ITERATIVE_SOLVER%DIVERGENCE_TOLERANCE=1.0e5_dp
10986 linear_solver%ITERATIVE_SOLVER%GMRES_RESTART=30
10987 CALL petsc_pcinitialise(linear_solver%ITERATIVE_SOLVER%PC,err,error,*999)
10988 CALL petsc_kspinitialise(linear_solver%ITERATIVE_SOLVER%KSP,err,error,*999)
10991 CALL flagerror(
"Linear solver is not associated.",err,error,*998)
10994 exits(
"SOLVER_LINEAR_ITERATIVE_INITIALISE")
10997 998 errorsexits(
"SOLVER_LINEAR_ITERATIVE_INITIALISE",err,error)
11010 TYPE(linear_iterative_solver_type),
POINTER :: ITERATIVE_SOLVER
11011 INTEGER(INTG),
INTENT(OUT) :: SOLVER_LIBRARY_TYPE
11012 INTEGER(INTG),
INTENT(OUT) :: ERR
11013 TYPE(varying_string),
INTENT(OUT) :: ERROR
11015 TYPE(varying_string) :: LOCAL_ERROR
11017 enters(
"SOLVER_LINEAR_ITERATIVE_LIBRARY_TYPE_GET",err,error,*999)
11019 IF(
ASSOCIATED(iterative_solver))
THEN 11020 SELECT CASE(iterative_solver%ITERATIVE_SOLVER_TYPE)
11022 solver_library_type=iterative_solver%SOLVER_LIBRARY
11024 solver_library_type=iterative_solver%SOLVER_LIBRARY
11026 solver_library_type=iterative_solver%SOLVER_LIBRARY
11028 solver_library_type=iterative_solver%SOLVER_LIBRARY
11030 solver_library_type=iterative_solver%SOLVER_LIBRARY
11032 solver_library_type=iterative_solver%SOLVER_LIBRARY
11034 local_error=
"The iterative linear solver type of "// &
11035 & trim(numbertovstring(iterative_solver%ITERATIVE_SOLVER_TYPE,
"*",err,error))//
" is invalid." 11036 CALL flagerror(local_error,err,error,*999)
11039 CALL flagerror(
"Iterative linear solver is not associated.",err,error,*999)
11042 exits(
"SOLVER_LINEAR_ITERATIVE_LIBRARY_TYPE_GET")
11044 999 errorsexits(
"SOLVER_LINEAR_ITERATIVE_LIBRARY_TYPE_GET",err,error)
11057 TYPE(linear_iterative_solver_type),
POINTER :: ITERATIVE_SOLVER
11058 INTEGER(INTG),
INTENT(IN) :: SOLVER_LIBRARY_TYPE
11059 INTEGER(INTG),
INTENT(OUT) :: ERR
11060 TYPE(varying_string),
INTENT(OUT) :: ERROR
11062 TYPE(varying_string) :: LOCAL_ERROR
11064 enters(
"SOLVER_LINEAR_ITERATIVE_LIBRARY_TYPE_SET",err,error,*999)
11066 IF(
ASSOCIATED(iterative_solver))
THEN 11067 SELECT CASE(iterative_solver%ITERATIVE_SOLVER_TYPE)
11069 SELECT CASE(solver_library_type)
11071 CALL flagerror(
"Not implemented.",err,error,*999)
11074 iterative_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
11076 local_error=
"The specified solver library type of "// &
11077 & trim(numbertovstring(solver_library_type,
"*",err,error))// &
11078 &
" is invalid for a Richardson iterative linear solver." 11081 SELECT CASE(solver_library_type)
11083 CALL flagerror(
"Not implemented.",err,error,*999)
11086 iterative_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
11088 local_error=
"The specified solver library type of "// &
11089 & trim(numbertovstring(solver_library_type,
"*",err,error))// &
11090 &
" is invalid for a Chebychev iterative linear solver." 11093 SELECT CASE(solver_library_type)
11095 CALL flagerror(
"Not implemented.",err,error,*999)
11098 iterative_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
11100 local_error=
"The specified solver library type of "// &
11101 & trim(numbertovstring(solver_library_type,
"*",err,error))// &
11102 &
" is invalid for a Conjugate gradient iterative linear solver." 11105 SELECT CASE(solver_library_type)
11107 CALL flagerror(
"Not implemented.",err,error,*999)
11110 iterative_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
11112 local_error=
"The specified solver library type of "// &
11113 & trim(numbertovstring(solver_library_type,
"*",err,error))// &
11114 &
" is invalid for a GMRES iterative linear solver." 11117 SELECT CASE(solver_library_type)
11119 CALL flagerror(
"Not implemented.",err,error,*999)
11122 iterative_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
11124 local_error=
"The specified solver library type of "// &
11125 & trim(numbertovstring(solver_library_type,
"*",err,error))// &
11126 &
" is invalid for a BiCGSTAB iterative linear solver." 11129 SELECT CASE(solver_library_type)
11131 CALL flagerror(
"Not implemented.",err,error,*999)
11134 iterative_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
11136 local_error=
"The specified solver library type of "// &
11137 & trim(numbertovstring(solver_library_type,
"*",err,error))// &
11138 &
" is invalid for a Conjugate gradient squared iterative linear solver." 11141 local_error=
"The iterative linear solver type of "// &
11142 & trim(numbertovstring(iterative_solver%ITERATIVE_SOLVER_TYPE,
"*",err,error))//
" is invalid." 11143 CALL flagerror(local_error,err,error,*999)
11146 CALL flagerror(
"Iterative linear solver is not associated.",err,error,*999)
11149 exits(
"SOLVER_LINEAR_ITERATIVE_LIBRARY_TYPE_SET")
11151 999 errorsexits(
"SOLVER_LINEAR_ITERATIVE_LIBRARY_TYPE_SET",err,error)
11164 TYPE(linear_iterative_solver_type),
POINTER :: ITERATIVE_SOLVER
11165 INTEGER(INTG),
INTENT(OUT) :: MATRICES_LIBRARY_TYPE
11166 INTEGER(INTG),
INTENT(OUT) :: ERR
11167 TYPE(varying_string),
INTENT(OUT) :: ERROR
11170 enters(
"Solver_LinearIterativeMatricesLibraryTypeGet",err,error,*999)
11172 IF(
ASSOCIATED(iterative_solver))
THEN 11173 matrices_library_type=iterative_solver%SOLVER_MATRICES_LIBRARY
11175 CALL flagerror(
"Iterative linear solver is not associated.",err,error,*999)
11178 exits(
"Solver_LinearIterativeMatricesLibraryTypeGet")
11180 999 errors(
"Solver_LinearIterativeMatricesLibraryTypeGet",err,error)
11181 exits(
"Solver_LinearIterativeMatricesLibraryTypeGet")
11194 TYPE(solver_type),
POINTER :: SOLVER
11195 INTEGER(INTG),
INTENT(IN) :: MAXIMUM_ITERATIONS
11196 INTEGER(INTG),
INTENT(OUT) :: ERR
11197 TYPE(varying_string),
INTENT(OUT) :: ERROR
11199 TYPE(varying_string) :: LOCAL_ERROR
11201 enters(
"Solver_LinearIterativeMaximumIterationsSet",err,error,*999)
11203 IF(
ASSOCIATED(solver))
THEN 11204 IF(solver%SOLVER_FINISHED)
THEN 11205 CALL flagerror(
"Solver has already been finished.",err,error,*999)
11208 IF(
ASSOCIATED(solver%LINEAR_SOLVER))
THEN 11210 IF(
ASSOCIATED(solver%LINEAR_SOLVER%ITERATIVE_SOLVER))
THEN 11211 IF(maximum_iterations>0)
THEN 11212 solver%LINEAR_SOLVER%ITERATIVE_SOLVER%MAXIMUM_NUMBER_OF_ITERATIONS=maximum_iterations
11214 local_error=
"The specified maximum iterations of "//trim(numbertovstring(maximum_iterations,
"*",err,error))// &
11215 &
" is invalid. The maximum number of iterations must be > 0." 11216 CALL flagerror(local_error,err,error,*999)
11219 CALL flagerror(
"The solver linear solver iterative solver is not associated.",err,error,*999)
11222 CALL flagerror(
"The solver is not a linear iterative solver.",err,error,*999)
11225 CALL flagerror(
"The solver linear solver is not associated.",err,error,*999)
11228 CALL flagerror(
"The solver is not a linear solver.",err,error,*999)
11232 CALL flagerror(
"Solver is not associated.",err,error,*999)
11235 exits(
"Solver_LinearIterativeMaximumIterationsSet")
11237 999 errorsexits(
"Solver_LinearIterativeMaximumIterationsSet",err,error)
11250 TYPE(solver_type),
POINTER :: SOLVER
11251 INTEGER(INTG),
INTENT(IN) :: ITERATIVE_PRECONDITIONER_TYPE
11252 INTEGER(INTG),
INTENT(OUT) :: ERR
11253 TYPE(varying_string),
INTENT(OUT) :: ERROR
11255 TYPE(varying_string) :: LOCAL_ERROR
11257 enters(
"Solver_LinearIterativePreconditionerTypeSet",err,error,*999)
11259 IF(
ASSOCIATED(solver))
THEN 11260 IF(solver%SOLVER_FINISHED)
THEN 11261 CALL flagerror(
"Solver has already been finished.",err,error,*999)
11264 IF(
ASSOCIATED(solver%LINEAR_SOLVER))
THEN 11266 IF(
ASSOCIATED(solver%LINEAR_SOLVER%ITERATIVE_SOLVER))
THEN 11267 IF(iterative_preconditioner_type/=solver%LINEAR_SOLVER%ITERATIVE_SOLVER%ITERATIVE_PRECONDITIONER_TYPE)
THEN 11269 SELECT CASE(solver%LINEAR_SOLVER%ITERATIVE_SOLVER%SOLVER_LIBRARY)
11271 SELECT CASE(iterative_preconditioner_type)
11275 CALL flagerror(
"Iterative Jacobi preconditioning is not implemented for a PETSc library.",err,error,*999)
11277 solver%LINEAR_SOLVER%ITERATIVE_SOLVER%ITERATIVE_PRECONDITIONER_TYPE= &
11280 solver%LINEAR_SOLVER%ITERATIVE_SOLVER%ITERATIVE_PRECONDITIONER_TYPE= &
11283 solver%LINEAR_SOLVER%ITERATIVE_SOLVER%ITERATIVE_PRECONDITIONER_TYPE= &
11286 solver%LINEAR_SOLVER%ITERATIVE_SOLVER%ITERATIVE_PRECONDITIONER_TYPE= &
11289 solver%LINEAR_SOLVER%ITERATIVE_SOLVER%ITERATIVE_PRECONDITIONER_TYPE= &
11292 local_error=
"The iterative preconditioner type of "// &
11293 & trim(numbertovstring(iterative_preconditioner_type,
"*",err,error))//
" is invalid." 11294 CALL flagerror(local_error,err,error,*999)
11297 local_error=
"The solver library type of "// &
11298 & trim(numbertovstring(solver%LINEAR_SOLVER%ITERATIVE_SOLVER%SOLVER_LIBRARY,
"*",err,error))// &
11300 CALL flagerror(local_error,err,error,*999)
11304 CALL flagerror(
"The solver linear solver iterative solver is not associated.",err,error,*999)
11307 CALL flagerror(
"The solver is not a linear iterative solver.",err,error,*999)
11310 CALL flagerror(
"The solver linear solver is not associated.",err,error,*999)
11313 CALL flagerror(
"The solver is not a linear solver.",err,error,*999)
11317 CALL flagerror(
"Solver is not associated.",err,error,*999)
11320 exits(
"Solver_LinearIterativePreconditionerTypeSet")
11322 999 errorsexits(
"Solver_LinearIterativePreconditionerTypeSet",err,error)
11335 TYPE(solver_type),
POINTER :: SOLVER
11336 REAL(DP),
INTENT(IN) :: RELATIVE_TOLERANCE
11337 INTEGER(INTG),
INTENT(OUT) :: ERR
11338 TYPE(varying_string),
INTENT(OUT) :: ERROR
11340 TYPE(varying_string) :: LOCAL_ERROR
11342 enters(
"Solver_LinearIterativeRelativeToleranceSet",err,error,*999)
11344 IF(
ASSOCIATED(solver))
THEN 11345 IF(solver%SOLVER_FINISHED)
THEN 11346 CALL flagerror(
"Solver has already been finished.",err,error,*999)
11349 IF(
ASSOCIATED(solver%LINEAR_SOLVER))
THEN 11351 IF(
ASSOCIATED(solver%LINEAR_SOLVER%ITERATIVE_SOLVER))
THEN 11352 IF(relative_tolerance>zero_tolerance)
THEN 11353 solver%LINEAR_SOLVER%ITERATIVE_SOLVER%RELATIVE_TOLERANCE=relative_tolerance
11355 local_error=
"The specified relative tolerance of "//trim(numbertovstring(relative_tolerance,
"*",err,error))// &
11356 &
" is invalid. The relative tolerance must be > 0." 11357 CALL flagerror(local_error,err,error,*999)
11360 CALL flagerror(
"The solver linear solver iterative solver is not associated.",err,error,*999)
11363 CALL flagerror(
"The solver is not a linear iterative solver.",err,error,*999)
11366 CALL flagerror(
"The solver linear solver is not associated.",err,error,*999)
11369 CALL flagerror(
"The solver is not a linear solver.",err,error,*999)
11373 CALL flagerror(
"Solver is not associated.",err,error,*999)
11376 exits(
"Solver_LinearIterativeRelativeToleranceSet")
11378 999 errorsexits(
"Solver_LinearIterativeRelativeToleranceSet",err,error)
11391 TYPE(solver_type),
POINTER :: SOLVER
11392 INTEGER(INTG),
INTENT(IN) :: SOLUTION_INITIALISE_TYPE
11393 INTEGER(INTG),
INTENT(OUT) :: ERR
11394 TYPE(varying_string),
INTENT(OUT) :: ERROR
11396 TYPE(varying_string) :: LOCAL_ERROR
11398 enters(
"Solver_LinearIterativeSolutionInitTypeSet",err,error,*999)
11400 IF(
ASSOCIATED(solver))
THEN 11401 IF(solver%SOLVER_FINISHED)
THEN 11402 CALL flagerror(
"Solver has already been finished.",err,error,*999)
11405 IF(
ASSOCIATED(solver%LINEAR_SOLVER))
THEN 11407 IF(
ASSOCIATED(solver%LINEAR_SOLVER%ITERATIVE_SOLVER))
THEN 11408 SELECT CASE(solution_initialise_type)
11416 local_error=
"The specified solution initialise type of "// &
11417 & trim(numbertovstring(solution_initialise_type,
"*",err,error))//
" is invalid." 11418 CALL flagerror(local_error,err,error,*999)
11421 CALL flagerror(
"The solver linear solver iterative solver is not associated.",err,error,*999)
11424 CALL flagerror(
"The solver is not a linear iterative solver.",err,error,*999)
11427 CALL flagerror(
"The solver linear solver is not associated.",err,error,*999)
11430 CALL flagerror(
"The solver is not a linear solver.",err,error,*999)
11434 CALL flagerror(
"Solver is not associated.",err,error,*999)
11437 exits(
"Solver_LinearIterativeSolutionInitTypeSet")
11439 999 errorsexits(
"Solver_LinearIterativeSolutionInitTypeSet",err,error)
11452 TYPE(linear_iterative_solver_type),
POINTER :: LINEAR_ITERATIVE_SOLVER
11453 INTEGER(INTG),
INTENT(OUT) :: ERR
11454 TYPE(varying_string),
INTENT(OUT) :: ERROR
11456 INTEGER(INTG) :: CONVERGED_REASON,global_row,local_row,NUMBER_ITERATIONS,STORAGE_TYPE
11457 REAL(DP) :: RESIDUAL_NORM,SOLVER_VALUE,VALUE
11458 REAL(DP),
POINTER :: RHS_DATA(:)
11459 TYPE(distributed_vector_type),
POINTER :: RHS_VECTOR,SOLVER_VECTOR
11460 TYPE(domain_mapping_type),
POINTER :: ROW_DOFS_MAPPING
11461 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
11462 TYPE(solver_type),
POINTER :: SOLVER
11463 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
11464 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
11465 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
11466 TYPE(solver_matrix_type),
POINTER :: SOLVER_MATRIX
11467 TYPE(varying_string) :: LOCAL_ERROR
11469 enters(
"SOLVER_LINEAR_ITERATIVE_SOLVE",err,error,*999)
11471 IF(
ASSOCIATED(linear_iterative_solver))
THEN 11472 linear_solver=>linear_iterative_solver%LINEAR_SOLVER
11473 IF(
ASSOCIATED(linear_solver))
THEN 11474 solver=>linear_solver%SOLVER
11475 IF(
ASSOCIATED(solver))
THEN 11476 solver_equations=>solver%SOLVER_EQUATIONS
11477 IF(
ASSOCIATED(solver_equations))
THEN 11478 solver_matrices=>solver_equations%SOLVER_MATRICES
11479 IF(
ASSOCIATED(solver_matrices))
THEN 11480 IF(solver_matrices%NUMBER_OF_MATRICES==1)
THEN 11481 solver_matrix=>solver_matrices%MATRICES(1)%PTR
11482 IF(
ASSOCIATED(solver_matrix))
THEN 11483 rhs_vector=>solver_matrices%RHS_VECTOR
11484 IF(
ASSOCIATED(rhs_vector))
THEN 11485 solver_vector=>solver_matrices%MATRICES(1)%PTR%SOLVER_VECTOR
11486 IF(
ASSOCIATED(solver_vector))
THEN 11487 CALL distributed_matrix_storage_type_get(solver_matrix%MATRIX,storage_type,err,error,*999)
11488 IF(storage_type==distributed_matrix_diagonal_storage_type)
THEN 11489 solver_mapping=>solver_equations%SOLVER_MAPPING
11490 IF(
ASSOCIATED(solver_mapping))
THEN 11491 row_dofs_mapping=>solver_mapping%ROW_DOFS_MAPPING
11492 IF(
ASSOCIATED(row_dofs_mapping))
THEN 11493 CALL distributed_vector_data_get(rhs_vector,rhs_data,err,error,*999)
11494 DO local_row=1,solver_mapping%NUMBER_OF_ROWS
11495 global_row=row_dofs_mapping%LOCAL_TO_GLOBAL_MAP(local_row)
11496 CALL distributed_matrix_values_get(solver_matrix%MATRIX,local_row,global_row,
VALUE,err,error,*999)
11497 IF(abs(
VALUE)>zero_tolerance)
THEN 11498 solver_value=rhs_data(local_row)/
VALUE 11499 CALL distributed_vector_values_set(solver_vector,local_row,solver_value,err,error,*999)
11501 local_error=
"The linear solver matrix has a zero pivot on row "// &
11502 & trim(numbertovstring(local_row,
"*",err,error))//
"." 11503 CALL flagerror(local_error,err,error,*999)
11506 CALL distributed_vector_data_restore(rhs_vector,rhs_data,err,error,*999)
11508 CALL flagerror(
"Solver mapping row dofs mapping is not associated.",err,error,*999)
11511 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
11514 SELECT CASE(linear_iterative_solver%SOLVER_LIBRARY)
11516 CALL flagerror(
"Not implemented.",err,error,*999)
11518 IF(
ASSOCIATED(rhs_vector%PETSC))
THEN 11519 IF(
ASSOCIATED(solver_vector%PETSC))
THEN 11520 SELECT CASE(linear_iterative_solver%SOLUTION_INITIALISE_TYPE)
11523 CALL distributed_vector_all_values_set(solver_vector,0.0_dp,err,error,*999)
11525 CALL petsc_kspsetinitialguessnonzero(linear_iterative_solver%KSP,.false.,err,error,*999)
11530 CALL petsc_kspsetinitialguessnonzero(linear_iterative_solver%KSP,.true.,err,error,*999)
11534 local_error=
"The linear iterative solver solution initialise type of "// &
11535 & trim(numbertovstring(linear_iterative_solver%SOLUTION_INITIALISE_TYPE,
"*",err,error))// &
11537 CALL flagerror(local_error,err,error,*999)
11541 CALL tau_static_phase_start(
"KSPSOLVE")
11543 CALL petsc_kspsolve(linear_iterative_solver%KSP,rhs_vector%PETSC%VECTOR,solver_vector%PETSC%VECTOR, &
11546 CALL tau_static_phase_stop(
"KSPSOLVE")
11549 CALL petsc_kspgetconvergedreason(linear_iterative_solver%KSP,converged_reason,err,error,*999)
11550 SELECT CASE(converged_reason)
11551 CASE(petsc_ksp_diverged_null)
11552 CALL flag_warning(
"Linear iterative solver did not converge. PETSc diverged null.",err,error,*999)
11553 CASE(petsc_ksp_diverged_its)
11554 CALL flag_warning(
"Linear iterative solver did not converge. PETSc diverged its.",err,error,*999)
11555 CASE(petsc_ksp_diverged_dtol)
11556 CALL flag_warning(
"Linear iterative solver did not converge. PETSc diverged dtol.",err,error,*999)
11557 CASE(petsc_ksp_diverged_breakdown)
11558 CALL flag_warning(
"Linear iterative solver did not converge. PETSc diverged breakdown.", &
11560 CASE(petsc_ksp_diverged_breakdown_bicg)
11561 CALL flag_warning(
"Linear iterative solver did not converge. PETSc diverged breakdown BiCG.", &
11563 CASE(petsc_ksp_diverged_nonsymmetric)
11564 CALL flag_warning(
"Linear iterative solver did not converge. PETSc diverged nonsymmetric.", &
11566 CASE(petsc_ksp_diverged_indefinite_pc)
11567 CALL flag_warning(
"Linear iterative solver did not converge. PETSc diverged indefinite PC.", &
11569 CASE(petsc_ksp_diverged_nanorinf)
11570 CALL flag_warning(
"Linear iterative solver did not converge. PETSc diverged NaN or Inf.", &
11572 CASE(petsc_ksp_diverged_indefinite_mat)
11573 CALL flag_warning(
"Linear iterative solver did not converge. PETSc diverged indefinite mat.", &
11578 CALL write_string(general_output_type,
"",err,error,*999)
11579 CALL write_string(general_output_type,
"Linear iterative solver parameters:",err,error,*999)
11580 CALL petsc_kspgetiterationnumber(linear_iterative_solver%KSP,number_iterations,err,error,*999)
11581 CALL write_string_value(general_output_type,
"Final number of iterations = ",number_iterations, &
11583 CALL petsc_kspgetresidualnorm(linear_iterative_solver%KSP,residual_norm,err,error,*999)
11584 CALL write_string_value(general_output_type,
"Final residual norm = ",residual_norm, &
11586 SELECT CASE(converged_reason)
11587 CASE(petsc_ksp_converged_rtol)
11588 CALL write_string(general_output_type,
"Converged Reason = PETSc converged RTol",err,error,*999)
11589 CASE(petsc_ksp_converged_atol)
11590 CALL write_string(general_output_type,
"Converged Reason = PETSc converged ATol",err,error,*999)
11591 CASE(petsc_ksp_converged_its)
11592 CALL write_string(general_output_type,
"Converged Reason = PETSc converged its",err,error,*999)
11593 CASE(petsc_ksp_converged_cg_neg_curve)
11594 CALL write_string(general_output_type,
"Converged Reason = PETSc converged CG neg curve", &
11596 CASE(petsc_ksp_converged_cg_constrained)
11597 CALL write_string(general_output_type,
"Converged Reason = PETSc converged CG constrained", &
11599 CASE(petsc_ksp_converged_step_length)
11600 CALL write_string(general_output_type,
"Converged Reason = PETSc converged step length", &
11602 CASE(petsc_ksp_converged_happy_breakdown)
11603 CALL write_string(general_output_type,
"Converged Reason = PETSc converged happy breakdown", &
11605 CASE(petsc_ksp_converged_iterating)
11606 CALL write_string(general_output_type,
"Converged Reason = PETSc converged iterating", &
11611 CALL flagerror(
"Solver vector PETSc vector is not associated.",err,error,*999)
11614 CALL flagerror(
"RHS vector petsc PETSc is not associated.",err,error,*999)
11617 local_error=
"The solver library type of "// &
11618 & trim(numbertovstring(linear_iterative_solver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid." 11619 CALL flagerror(local_error,err,error,*999)
11623 CALL flagerror(
"Solver vector is not associated.",err,error,*999)
11626 CALL flagerror(
"RHS vector is not associated.",err,error,*999)
11629 CALL flagerror(
"Solver matrix is not associated.",err,error,*999)
11632 local_error=
"The given number of solver matrices of "// &
11633 & trim(numbertovstring(solver_matrices%NUMBER_OF_MATRICES,
"*",err,error))// &
11634 &
" is invalid. There should only be one solver matrix for a linear iterative solver." 11635 CALL flagerror(local_error,err,error,*999)
11638 CALL flagerror(
"Solver solver matrices is not associated.",err,error,*999)
11641 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
11644 CALL flagerror(
"Linear solver solver is not associated.",err,error,*999)
11647 CALL flagerror(
"Linear itreative solver linear solver is not associated.",err,error,*999)
11650 CALL flagerror(
"Linear iterative solver is not associated.",err,error,*999)
11653 exits(
"SOLVER_LINEAR_ITERATIVE_SOLVE")
11655 999 errorsexits(
"SOLVER_LINEAR_ITERATIVE_SOLVE",err,error)
11668 TYPE(solver_type),
POINTER :: SOLVER
11669 INTEGER(INTG),
INTENT(IN) :: ITERATIVE_SOLVER_TYPE
11670 INTEGER(INTG),
INTENT(OUT) :: ERR
11671 TYPE(varying_string),
INTENT(OUT) :: ERROR
11673 TYPE(varying_string) :: LOCAL_ERROR
11675 enters(
"SOLVER_LINEAR_ITERATIVE_TYPE_SET",err,error,*999)
11677 IF(
ASSOCIATED(solver))
THEN 11678 IF(solver%SOLVER_FINISHED)
THEN 11679 CALL flagerror(
"Solver has already been finished.",err,error,*999)
11682 IF(
ASSOCIATED(solver%LINEAR_SOLVER))
THEN 11684 IF(
ASSOCIATED(solver%LINEAR_SOLVER%ITERATIVE_SOLVER))
THEN 11685 IF(iterative_solver_type/=solver%LINEAR_SOLVER%ITERATIVE_SOLVER%ITERATIVE_SOLVER_TYPE)
THEN 11687 SELECT CASE(solver%LINEAR_SOLVER%ITERATIVE_SOLVER%SOLVER_LIBRARY)
11689 SELECT CASE(iterative_solver_type)
11705 local_error=
"The iterative solver type of "//trim(numbertovstring(iterative_solver_type,
"*",err,error))// &
11707 CALL flagerror(local_error,err,error,*999)
11710 local_error=
"The solver library type of "// &
11711 & trim(numbertovstring(solver%LINEAR_SOLVER%ITERATIVE_SOLVER%SOLVER_LIBRARY,
"*",err,error))// &
11713 CALL flagerror(local_error,err,error,*999)
11717 CALL flagerror(
"The solver linear solver iterative solver is not associated.",err,error,*999)
11720 CALL flagerror(
"The solver is not a linear iterative solver.",err,error,*999)
11723 CALL flagerror(
"The solver linear solver is not associated.",err,error,*999)
11726 CALL flagerror(
"The solver is not a linear solver.",err,error,*999)
11730 CALL flagerror(
"Solver is not associated.",err,error,*999)
11733 exits(
"SOLVER_LINEAR_ITERATIVE_TYPE_SET")
11735 999 errorsexits(
"SOLVER_LINEAR_ITERATIVE_TYPE_SET",err,error)
11748 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
11749 INTEGER(INTG),
INTENT(OUT) :: SOLVER_LIBRARY_TYPE
11750 INTEGER(INTG),
INTENT(OUT) :: ERR
11751 TYPE(varying_string),
INTENT(OUT) :: ERROR
11753 TYPE(linear_direct_solver_type),
POINTER :: DIRECT_SOLVER
11754 TYPE(linear_iterative_solver_type),
POINTER :: ITERATIVE_SOLVER
11755 TYPE(varying_string) :: LOCAL_ERROR
11757 enters(
"SOLVER_LINEAR_LIBRARY_TYPE_GET",err,error,*999)
11759 IF(
ASSOCIATED(linear_solver))
THEN 11760 SELECT CASE(linear_solver%LINEAR_SOLVE_TYPE)
11762 direct_solver=>linear_solver%DIRECT_SOLVER
11763 IF(
ASSOCIATED(direct_solver))
THEN 11766 CALL flagerror(
"Linear solver direct solver is not associated.",err,error,*999)
11769 iterative_solver=>linear_solver%ITERATIVE_SOLVER
11770 IF(
ASSOCIATED(iterative_solver))
THEN 11773 CALL flagerror(
"Linear solver iterative solver is not associated.",err,error,*999)
11776 local_error=
"The linear solver type of "//trim(numbertovstring(linear_solver%LINEAR_SOLVE_TYPE,
"*",err,error))// &
11778 CALL flagerror(local_error,err,error,*999)
11781 CALL flagerror(
"Linear solver is not associated.",err,error,*999)
11784 exits(
"SOLVER_LINEAR_LIBRARY_TYPE_GET")
11786 999 errorsexits(
"SOLVER_LINEAR_LIBRARY_TYPE_GET",err,error)
11799 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
11800 INTEGER(INTG),
INTENT(IN) :: SOLVER_LIBRARY_TYPE
11801 INTEGER(INTG),
INTENT(OUT) :: ERR
11802 TYPE(varying_string),
INTENT(OUT) :: ERROR
11804 TYPE(linear_direct_solver_type),
POINTER :: DIRECT_SOLVER
11805 TYPE(linear_iterative_solver_type),
POINTER :: ITERATIVE_SOLVER
11806 TYPE(varying_string) :: LOCAL_ERROR
11808 enters(
"SOLVER_LINEAR_LIBRARY_TYPE_SET",err,error,*999)
11810 IF(
ASSOCIATED(linear_solver))
THEN 11811 SELECT CASE(linear_solver%LINEAR_SOLVE_TYPE)
11813 direct_solver=>linear_solver%DIRECT_SOLVER
11814 IF(
ASSOCIATED(direct_solver))
THEN 11817 CALL flagerror(
"Linear solver direct solver is not associated.",err,error,*999)
11820 iterative_solver=>linear_solver%ITERATIVE_SOLVER
11821 IF(
ASSOCIATED(iterative_solver))
THEN 11824 CALL flagerror(
"Linear solver iterative solver is not associated.",err,error,*999)
11827 local_error=
"The linear solver type of "//trim(numbertovstring(linear_solver%LINEAR_SOLVE_TYPE,
"*",err,error))// &
11829 CALL flagerror(local_error,err,error,*999)
11832 CALL flagerror(
"Linear solver is not associated.",err,error,*999)
11835 exits(
"SOLVER_LINEAR_LIBRARY_TYPE_SET")
11837 999 errorsexits(
"SOLVER_LINEAR_LIBRARY_TYPE_SET",err,error)
11850 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
11851 INTEGER(INTG),
INTENT(OUT) :: MATRICES_LIBRARY_TYPE
11852 INTEGER(INTG),
INTENT(OUT) :: ERR
11853 TYPE(varying_string),
INTENT(OUT) :: ERROR
11855 TYPE(linear_direct_solver_type),
POINTER :: DIRECT_SOLVER
11856 TYPE(linear_iterative_solver_type),
POINTER :: ITERATIVE_SOLVER
11857 TYPE(varying_string) :: LOCAL_ERROR
11859 enters(
"SOLVER_LINEAR_MATRICES_LIBRARY_TYPE_GET",err,error,*999)
11861 IF(
ASSOCIATED(linear_solver))
THEN 11862 SELECT CASE(linear_solver%LINEAR_SOLVE_TYPE)
11864 direct_solver=>linear_solver%DIRECT_SOLVER
11865 IF(
ASSOCIATED(direct_solver))
THEN 11868 CALL flagerror(
"Linear solver direct solver is not associated.",err,error,*999)
11871 iterative_solver=>linear_solver%ITERATIVE_SOLVER
11872 IF(
ASSOCIATED(iterative_solver))
THEN 11875 CALL flagerror(
"Linear solver iterative solver is not associated.",err,error,*999)
11878 local_error=
"The linear solver type of "//trim(numbertovstring(linear_solver%LINEAR_SOLVE_TYPE,
"*",err,error))// &
11880 CALL flagerror(local_error,err,error,*999)
11883 CALL flagerror(
"Linear solver is not associated.",err,error,*999)
11886 exits(
"SOLVER_LINEAR_MATRICES_LIBRARY_TYPE_GET")
11888 999 errorsexits(
"SOLVER_LINEAR_MATRICES_LIBRARY_TYPE_GET",err,error)
11901 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
11902 INTEGER(INTG),
INTENT(OUT) :: ERR
11903 TYPE(varying_string),
INTENT(OUT) :: ERROR
11905 INTEGER(INTG) :: solver_matrix_idx
11906 TYPE(solver_type),
POINTER :: SOLVER
11907 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
11908 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
11909 TYPE(varying_string) :: LOCAL_ERROR
11911 enters(
"SOLVER_LINEAR_SOLVE",err,error,*999)
11913 IF(
ASSOCIATED(linear_solver))
THEN 11914 solver=>linear_solver%SOLVER
11915 IF(
ASSOCIATED(solver))
THEN 11918 CALL tau_static_phase_start(
"Solver Matrix Assembly Phase")
11920 IF(.NOT.
ASSOCIATED(solver%LINKING_SOLVER))
THEN 11928 CALL tau_static_phase_stop(
"Solver Matrix Assembly Phase")
11930 CALL tau_static_phase_start(
"Solve Phase")
11932 SELECT CASE(linear_solver%LINEAR_SOLVE_TYPE)
11938 local_error=
"The linear solver type of "//trim(numbertovstring(linear_solver%LINEAR_SOLVE_TYPE,
"*",err,error))// &
11940 CALL flagerror(local_error,err,error,*999)
11943 CALL tau_static_phase_stop(
"Solve Phase")
11949 CALL tau_static_phase_start(
"Solution Output Phase")
11952 solver_equations=>solver%SOLVER_EQUATIONS
11953 IF(
ASSOCIATED(solver_equations))
THEN 11954 solver_matrices=>solver_equations%SOLVER_MATRICES
11955 IF(
ASSOCIATED(solver_matrices))
THEN 11956 CALL write_string(general_output_type,
"",err,error,*999)
11957 CALL write_string(general_output_type,
"Solver solution vectors:",err,error,*999)
11958 CALL write_string_value(general_output_type,
"Number of solution vectors = ",solver_matrices%NUMBER_OF_MATRICES, &
11960 DO solver_matrix_idx=1,solver_matrices%NUMBER_OF_MATRICES
11961 CALL write_string_value(general_output_type,
"Solution vector for solver matrix : ",solver_matrix_idx,err,error,*999)
11962 CALL distributed_vector_output(general_output_type,solver_matrices%MATRICES(solver_matrix_idx)%PTR% &
11963 & solver_vector,err,error,*999)
11966 CALL flagerror(
"Solver equations solver matrices is not associated.",err,error,*999)
11969 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
11973 CALL tau_static_phase_stop(
"Solution Output Phase")
11977 IF(.NOT.
ASSOCIATED(solver%LINKING_SOLVER))
THEN 11980 CALL tau_static_phase_start(
"Field Update Phase")
11984 CALL tau_static_phase_stop(
"Field Update Phase")
11988 CALL flagerror(
"Linear solver solver is not associated.",err,error,*999)
11991 CALL flagerror(
"Linear solver is not associated.",err,error,*999)
11994 exits(
"SOLVER_LINEAR_SOLVE")
11996 999 errorsexits(
"SOLVER_LINEAR_SOLVE",err,error)
12009 TYPE(solver_type),
POINTER :: SOLVER
12010 INTEGER(INTG),
INTENT(IN) :: LINEAR_SOLVE_TYPE
12011 INTEGER(INTG),
INTENT(OUT) :: ERR
12012 TYPE(varying_string),
INTENT(OUT) :: ERROR
12014 INTEGER(INTG) :: DUMMY_ERR
12015 TYPE(varying_string) :: DUMMY_ERROR,LOCAL_ERROR
12017 enters(
"SOLVER_LINEAR_TYPE_SET",err,error,*998)
12019 IF(
ASSOCIATED(solver))
THEN 12020 IF(solver%SOLVER_FINISHED)
THEN 12021 CALL flagerror(
"Solver has already been finished.",err,error,*998)
12024 IF(
ASSOCIATED(solver%LINEAR_SOLVER))
THEN 12025 IF(linear_solve_type/=solver%LINEAR_SOLVER%LINEAR_SOLVE_TYPE)
THEN 12027 SELECT CASE(linear_solve_type)
12033 local_error=
"The linear solver type of "//trim(numbertovstring(linear_solve_type,
"*",err,error))//
" is invalid." 12034 CALL flagerror(local_error,err,error,*999)
12037 SELECT CASE(solver%LINEAR_SOLVER%LINEAR_SOLVE_TYPE)
12043 local_error=
"The linear solver type of "// &
12044 & trim(numbertovstring(solver%LINEAR_SOLVER%LINEAR_SOLVE_TYPE,
"*",err,error))//
" is invalid." 12045 CALL flagerror(local_error,err,error,*999)
12047 solver%LINEAR_SOLVER%LINEAR_SOLVE_TYPE=linear_solve_type
12050 CALL flagerror(
"The solver linear solver is not associated.",err,error,*998)
12053 CALL flagerror(
"The solver is not a linear solver.",err,error,*998)
12057 CALL flagerror(
"Solver is not associated.",err,error,*998)
12060 exits(
"SOLVER_LINEAR_TYPE_SET")
12062 999
SELECT CASE(linear_solve_type)
12068 998 errorsexits(
"SOLVER_LINEAR_TYPE_SET",err,error)
12081 TYPE(solver_type),
POINTER :: SOLVER
12082 INTEGER(INTG),
INTENT(IN) :: SELECTION_TYPE
12083 INTEGER(INTG),
INTENT(OUT) :: ERR
12084 TYPE(varying_string),
INTENT(OUT) :: ERROR
12086 INTEGER(INTG) :: DYNAMIC_VARIABLE_TYPE,equations_matrix_idx,equations_row_number,equations_set_idx,LINEAR_VARIABLE_TYPE, &
12087 & rhs_boundary_condition,rhs_global_dof,rhs_variable_dof,rhs_variable_type,solver_row_idx,solver_row_number, &
12088 & solver_matrix_idx,residual_variable_dof,variable_boundary_condition,variable_type,equations_matrix_idx2, &
12089 & variable_idx,variable_global_dof,variable_dof,equations_row_number2,equations_matrix_number,DEPENDENT_VARIABLE_TYPE, &
12090 & equations_column_number,dirichlet_row,dirichlet_idx, &
12091 & interface_condition_idx,interface_matrix_idx,interface_column_number,interface_row_number, &
12092 & interface_variable_type,number_of_interface_matrices
12093 REAL(SP) :: SYSTEM_ELAPSED,SYSTEM_TIME1(1),SYSTEM_TIME2(1),USER_ELAPSED,USER_TIME1(1),USER_TIME2(1)
12094 REAL(DP) :: DAMPING_MATRIX_COEFFICIENT,DELTA_T,DYNAMIC_VALUE,FIRST_UPDATE_FACTOR,RESIDUAL_VALUE, &
12095 & LINEAR_VALUE,LINEAR_VALUE_SUM,MASS_MATRIX_COEFFICIENT,RHS_VALUE,row_coupling_coefficient,PREVIOUS_RESIDUAL_VALUE, &
12096 & SECOND_UPDATE_FACTOR,SOURCE_VALUE,STIFFNESS_MATRIX_COEFFICIENT,VALUE,JACOBIAN_MATRIX_COEFFICIENT,ALPHA_VALUE, &
12097 & MATRIX_VALUE,DYNAMIC_DISPLACEMENT_FACTOR,DYNAMIC_VELOCITY_FACTOR,DYNAMIC_ACCELERATION_FACTOR,RHS_INTEGRATED_VALUE
12098 REAL(DP) :: MatrixCoefficients(2)=(/0.0_dp,0.0_dp/)
12099 REAL(DP),
POINTER :: FIELD_VALUES_VECTOR(:),PREVIOUS_VALUES_VECTOR(:),PREVIOUS_VELOCITY_VECTOR(:), &
12100 & PREVIOUS_ACCELERATION_VECTOR(:),RHS_PARAMETERS(:)
12101 LOGICAL :: HAS_INTEGRATED_VALUES
12102 TYPE(boundary_conditions_type),
POINTER :: BOUNDARY_CONDITIONS
12103 TYPE(boundary_conditions_variable_type),
POINTER :: RHS_BOUNDARY_CONDITIONS,DEPENDENT_BOUNDARY_CONDITIONS
12104 TYPE(distributed_matrix_type),
POINTER :: PREVIOUS_SOLVER_DISTRIBUTED_MATRIX,SOLVER_DISTRIBUTED_MATRIX
12105 TYPE(distributed_vector_type),
POINTER :: DEPENDENT_VECTOR,DYNAMIC_TEMP_VECTOR,EQUATIONS_RHS_VECTOR,DISTRIBUTED_SOURCE_VECTOR, &
12106 & LINEAR_TEMP_VECTOR,PREDICTED_MEAN_ACCELERATION_VECTOR,PREDICTED_MEAN_DISPLACEMENT_VECTOR,PREDICTED_MEAN_VELOCITY_VECTOR, &
12107 & SOLVER_RHS_VECTOR, SOLVER_RESIDUAL_VECTOR,RESIDUAL_VECTOR,INCREMENTAL_VECTOR,INTERFACE_TEMP_VECTOR, &
12109 TYPE(domain_mapping_type),
POINTER :: RHS_DOMAIN_MAPPING,VARIABLE_DOMAIN_MAPPING
12110 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
12111 TYPE(equations_type),
POINTER :: EQUATIONS
12112 TYPE(equations_mapping_type),
POINTER :: EQUATIONS_MAPPING
12113 TYPE(equations_mapping_dynamic_type),
POINTER :: DYNAMIC_MAPPING
12114 TYPE(equations_mapping_linear_type),
POINTER :: LINEAR_MAPPING
12115 TYPE(equations_mapping_nonlinear_type),
POINTER :: NONLINEAR_MAPPING
12116 TYPE(equations_mapping_rhs_type),
POINTER :: RHS_MAPPING
12117 TYPE(equations_mapping_source_type),
POINTER :: SOURCE_MAPPING
12118 TYPE(equations_matrices_type),
POINTER :: EQUATIONS_MATRICES
12119 TYPE(equations_matrices_dynamic_type),
POINTER :: DYNAMIC_MATRICES
12120 TYPE(equations_matrices_linear_type),
POINTER :: LINEAR_MATRICES
12121 TYPE(equations_matrices_nonlinear_type),
POINTER :: NONLINEAR_MATRICES
12122 TYPE(equations_matrices_rhs_type),
POINTER :: RHS_VECTOR
12123 TYPE(equations_matrices_source_type),
POINTER :: SOURCE_VECTOR
12124 TYPE(equations_matrix_type),
POINTER :: DAMPING_MATRIX,LINEAR_MATRIX,MASS_MATRIX,STIFFNESS_MATRIX,EQUATIONS_MATRIX
12125 TYPE(equations_jacobian_type),
POINTER :: JACOBIAN_MATRIX
12126 TYPE(jacobian_to_solver_map_type),
POINTER :: JACOBIAN_TO_SOLVER_MAP
12127 TYPE(equations_set_type),
POINTER :: EQUATIONS_SET
12128 TYPE(field_type),
POINTER :: DEPENDENT_FIELD,LAGRANGE_FIELD
12129 TYPE(field_variable_type),
POINTER :: DYNAMIC_VARIABLE,LINEAR_VARIABLE,RHS_VARIABLE,INTERFACE_VARIABLE
12130 TYPE(field_variable_type),
POINTER :: DEPENDENT_VARIABLE
12131 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
12132 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
12133 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
12134 TYPE(solver_matrix_type),
POINTER :: SOLVER_MATRIX
12135 TYPE(varying_string) :: LOCAL_ERROR
12136 TYPE(boundary_conditions_sparsity_indices_type),
POINTER :: SPARSITY_INDICES
12138 TYPE(interface_condition_type),
POINTER :: INTERFACE_CONDITION
12139 TYPE(interface_equations_type),
POINTER :: INTERFACE_EQUATIONS
12140 TYPE(interface_lagrange_type),
POINTER :: INTERFACE_LAGRANGE
12141 TYPE(interface_mapping_type),
POINTER :: INTERFACE_MAPPING
12142 TYPE(interface_mapping_rhs_type),
POINTER :: INTERFACE_RHS_MAPPING
12143 TYPE(interface_matrices_type),
POINTER :: INTERFACE_MATRICES
12144 TYPE(interface_matrix_type),
POINTER :: INTERFACE_MATRIX
12145 TYPE(interface_rhs_type),
POINTER :: INTERFACE_RHS_VECTOR
12146 TYPE(interface_to_solver_maps_type),
POINTER :: INTERFACE_TO_SOLVER_MAP
12148 REAL(DP),
POINTER :: CHECK_DATA(:),PREVIOUS_RESIDUAL_PARAMETERS(:),CHECK_DATA2(:)
12150 LOGICAL :: STABILITY_TEST
12154 stability_test=.false.
12156 enters(
"SOLVER_MATRICES_DYNAMIC_ASSEMBLE",err,error,*999)
12158 IF(
ASSOCIATED(solver))
THEN 12159 IF(
ASSOCIATED(dynamic_solver))
NULLIFY(dynamic_solver)
12160 IF(
ASSOCIATED(solver_equations))
NULLIFY(solver_equations)
12161 IF(
ASSOCIATED(solver_mapping))
NULLIFY(solver_mapping)
12162 IF(
ASSOCIATED(solver_matrices))
NULLIFY(solver_matrices)
12164 IF(
ASSOCIATED(boundary_conditions))
NULLIFY(boundary_conditions)
12165 IF(
ASSOCIATED(rhs_boundary_conditions))
NULLIFY(rhs_boundary_conditions)
12166 IF(
ASSOCIATED(dependent_boundary_conditions))
NULLIFY(dependent_boundary_conditions)
12167 IF(
ASSOCIATED(previous_solver_distributed_matrix))
NULLIFY(previous_solver_distributed_matrix)
12168 IF(
ASSOCIATED(solver_distributed_matrix))
NULLIFY(solver_distributed_matrix)
12169 IF(
ASSOCIATED(dependent_vector))
NULLIFY(dependent_vector)
12170 IF(
ASSOCIATED(dynamic_temp_vector))
NULLIFY(dynamic_temp_vector)
12171 IF(
ASSOCIATED(equations_rhs_vector))
NULLIFY(equations_rhs_vector)
12172 IF(
ASSOCIATED(distributed_source_vector))
NULLIFY(distributed_source_vector)
12173 IF(
ASSOCIATED(linear_temp_vector))
NULLIFY(linear_temp_vector)
12174 IF(
ASSOCIATED(predicted_mean_acceleration_vector))
NULLIFY(predicted_mean_acceleration_vector)
12175 IF(
ASSOCIATED(predicted_mean_displacement_vector))
NULLIFY(predicted_mean_displacement_vector)
12176 IF(
ASSOCIATED(predicted_mean_velocity_vector))
NULLIFY(predicted_mean_velocity_vector)
12177 IF(
ASSOCIATED(solver_rhs_vector))
NULLIFY(solver_rhs_vector)
12178 IF(
ASSOCIATED(solver_residual_vector))
NULLIFY(solver_residual_vector)
12179 IF(
ASSOCIATED(residual_vector))
NULLIFY(residual_vector)
12180 IF(
ASSOCIATED(incremental_vector))
NULLIFY(incremental_vector)
12181 IF(
ASSOCIATED(rhs_domain_mapping))
NULLIFY(rhs_domain_mapping)
12182 IF(
ASSOCIATED(variable_domain_mapping))
NULLIFY(variable_domain_mapping)
12183 IF(
ASSOCIATED(equations))
NULLIFY(equations)
12184 IF(
ASSOCIATED(equations_mapping))
NULLIFY(equations_mapping)
12185 IF(
ASSOCIATED(dynamic_mapping))
NULLIFY(dynamic_mapping)
12186 IF(
ASSOCIATED(nonlinear_mapping))
NULLIFY(nonlinear_mapping)
12187 IF(
ASSOCIATED(linear_mapping))
NULLIFY(linear_mapping)
12188 IF(
ASSOCIATED(rhs_mapping))
NULLIFY(rhs_mapping)
12189 IF(
ASSOCIATED(source_mapping))
NULLIFY(source_mapping)
12190 IF(
ASSOCIATED(equations_matrices))
NULLIFY(equations_matrices)
12191 IF(
ASSOCIATED(dynamic_matrices))
NULLIFY(dynamic_matrices)
12192 IF(
ASSOCIATED(nonlinear_matrices))
NULLIFY(nonlinear_matrices)
12193 IF(
ASSOCIATED(linear_matrices))
NULLIFY(linear_matrices)
12194 IF(
ASSOCIATED(rhs_vector))
NULLIFY(rhs_vector)
12195 IF(
ASSOCIATED(source_vector))
NULLIFY(source_vector)
12196 IF(
ASSOCIATED(damping_matrix))
NULLIFY(damping_matrix)
12197 IF(
ASSOCIATED(linear_matrix))
NULLIFY(linear_matrix)
12198 IF(
ASSOCIATED(mass_matrix))
NULLIFY(mass_matrix)
12199 IF(
ASSOCIATED(stiffness_matrix))
NULLIFY(stiffness_matrix)
12200 IF(
ASSOCIATED(equations_matrix))
NULLIFY(equations_matrix)
12201 IF(
ASSOCIATED(jacobian_matrix))
NULLIFY(jacobian_matrix)
12202 IF(
ASSOCIATED(jacobian_to_solver_map))
NULLIFY(jacobian_to_solver_map)
12203 IF(
ASSOCIATED(equations_set))
NULLIFY(equations_set)
12204 IF(
ASSOCIATED(dependent_field))
NULLIFY(dependent_field)
12205 IF(
ASSOCIATED(lagrange_field))
NULLIFY(lagrange_field)
12206 IF(
ASSOCIATED(dynamic_variable))
NULLIFY(dynamic_variable)
12207 IF(
ASSOCIATED(linear_variable))
NULLIFY(linear_variable)
12208 IF(
ASSOCIATED(rhs_variable))
NULLIFY(rhs_variable)
12209 IF(
ASSOCIATED(dependent_variable))
NULLIFY(dependent_variable)
12210 IF(
ASSOCIATED(solver_matrix))
NULLIFY(solver_matrix)
12211 IF(
ASSOCIATED(interface_condition))
NULLIFY(interface_condition)
12212 IF(
ASSOCIATED(interface_equations))
NULLIFY(interface_equations)
12213 IF(
ASSOCIATED(interface_lagrange))
NULLIFY(interface_lagrange)
12214 IF(
ASSOCIATED(interface_mapping))
NULLIFY(interface_mapping)
12215 IF(
ASSOCIATED(interface_rhs_mapping))
NULLIFY(interface_rhs_mapping)
12216 IF(
ASSOCIATED(interface_matrices))
NULLIFY(interface_matrices)
12217 IF(
ASSOCIATED(interface_matrix))
NULLIFY(interface_matrix)
12218 IF(
ASSOCIATED(interface_rhs_vector))
NULLIFY(interface_rhs_vector)
12219 IF(
ASSOCIATED(interface_to_solver_map))
NULLIFY(interface_to_solver_map)
12220 IF(
ASSOCIATED(check_data))
NULLIFY(check_data)
12221 IF(
ASSOCIATED(previous_residual_parameters))
NULLIFY(previous_residual_parameters)
12222 IF(
ASSOCIATED(check_data2))
NULLIFY(check_data2)
12226 dynamic_solver=>solver%DYNAMIC_SOLVER
12228 dynamic_solver=>solver%LINKING_SOLVER%DYNAMIC_SOLVER
12230 CALL flagerror(
"Dynamic solver solve type is not associated.",err,error,*999)
12232 IF(
ASSOCIATED(dynamic_solver))
THEN 12233 IF(dynamic_solver%SOLVER_INITIALISED)
THEN 12234 delta_t=dynamic_solver%TIME_INCREMENT
12235 SELECT CASE(dynamic_solver%DEGREE)
12237 stiffness_matrix_coefficient=1.0_dp*dynamic_solver%THETA(1)*delta_t
12238 damping_matrix_coefficient=1.0_dp
12239 mass_matrix_coefficient=0.0_dp
12240 jacobian_matrix_coefficient=stiffness_matrix_coefficient
12241 dynamic_displacement_factor=delta_t
12243 stiffness_matrix_coefficient=1.0_dp*(dynamic_solver%THETA(2)*delta_t*delta_t)/2.0_dp
12244 damping_matrix_coefficient=1.0_dp*dynamic_solver%THETA(1)*delta_t
12245 mass_matrix_coefficient=1.0_dp
12246 jacobian_matrix_coefficient=stiffness_matrix_coefficient
12247 first_update_factor=delta_t
12248 dynamic_displacement_factor=delta_t*delta_t/2.0_dp
12249 dynamic_velocity_factor=delta_t
12251 stiffness_matrix_coefficient=1.0_dp*(dynamic_solver%THETA(3)*delta_t*delta_t*delta_t)/6.0_dp
12252 damping_matrix_coefficient=1.0_dp*(dynamic_solver%THETA(2)*delta_t*delta_t)/2.0_dp
12253 mass_matrix_coefficient=1.0_dp*dynamic_solver%THETA(1)*delta_t
12254 jacobian_matrix_coefficient=stiffness_matrix_coefficient
12255 first_update_factor=delta_t
12256 second_update_factor=delta_t*delta_t/2.0_dp
12257 dynamic_displacement_factor=delta_t*delta_t*delta_t/6.0_dp
12258 dynamic_velocity_factor=delta_t*delta_t/2.0_dp
12259 dynamic_acceleration_factor=delta_t
12261 local_error=
"The dynamic solver degree of "//trim(numbertovstring(dynamic_solver%DEGREE,
"*",err,error))// &
12263 CALL flagerror(local_error,err,error,*999)
12266 solver_equations=>solver%SOLVER_EQUATIONS
12267 IF(
ASSOCIATED(solver_equations))
THEN 12268 solver_mapping=>solver_equations%SOLVER_MAPPING
12269 IF(
ASSOCIATED(solver_mapping))
THEN 12270 solver_matrices=>solver_equations%SOLVER_MATRICES
12271 IF(
ASSOCIATED(solver_matrices))
THEN 12273 NULLIFY(previous_solver_distributed_matrix)
12274 NULLIFY(solver_matrix)
12275 NULLIFY(solver_distributed_matrix)
12277 NULLIFY(equations_matrices)
12278 NULLIFY(dynamic_matrices)
12279 NULLIFY(equations_mapping)
12280 NULLIFY(dynamic_mapping)
12281 NULLIFY(stiffness_matrix)
12282 NULLIFY(damping_matrix)
12283 NULLIFY(mass_matrix)
12285 IF(selection_type==solver_matrices_all.OR. &
12286 & selection_type==solver_matrices_linear_only.OR. &
12287 & selection_type==solver_matrices_nonlinear_only.OR. &
12288 & selection_type==solver_matrices_jacobian_only)
THEN 12289 IF(dynamic_solver%SOLVER_INITIALISED.OR.(.NOT.dynamic_solver%SOLVER_INITIALISED.AND. &
12295 CALL cpu_timer(user_cpu,user_time1,err,error,*999)
12296 CALL cpu_timer(system_cpu,system_time1,err,error,*999)
12302 solver_matrix_idx=1
12303 IF(solver_mapping%NUMBER_OF_SOLVER_MATRICES==solver_matrix_idx)
THEN 12304 solver_matrix=>solver_matrices%MATRICES(1)%PTR
12305 IF(
ASSOCIATED(solver_matrix))
THEN 12306 IF(solver_matrix%UPDATE_MATRIX)
THEN 12307 solver_distributed_matrix=>solver_matrix%MATRIX
12308 IF(
ASSOCIATED(solver_distributed_matrix))
THEN 12310 CALL distributed_matrix_all_values_set(solver_distributed_matrix,0.0_dp,err,error,*999)
12312 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
12313 equations=>solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)%EQUATIONS
12314 IF(
ASSOCIATED(equations))
THEN 12315 equations_mapping=>equations%EQUATIONS_MAPPING
12316 IF(
ASSOCIATED(equations_mapping))
THEN 12317 dynamic_mapping=>equations_mapping%DYNAMIC_MAPPING
12318 IF(
ASSOCIATED(dynamic_mapping))
THEN 12319 equations_matrices=>equations%EQUATIONS_MATRICES
12320 IF(
ASSOCIATED(equations_matrices))
THEN 12321 dynamic_matrices=>equations_matrices%DYNAMIC_MATRICES
12322 IF(
ASSOCIATED(dynamic_matrices))
THEN 12323 IF(dynamic_solver%SOLVER_INITIALISED)
THEN 12325 IF(dynamic_mapping%STIFFNESS_MATRIX_NUMBER/=0)
THEN 12326 stiffness_matrix=>dynamic_matrices%MATRICES(dynamic_mapping%STIFFNESS_MATRIX_NUMBER)%PTR
12327 IF(
ASSOCIATED(stiffness_matrix))
THEN 12328 CALL solver_matrix_equations_matrix_add(solver_matrix,equations_set_idx, &
12329 & stiffness_matrix_coefficient,stiffness_matrix,err,error,*999)
12331 CALL flagerror(
"Dynamic stiffness matrix is not associated.",err,error,*999)
12335 IF(dynamic_mapping%DAMPING_MATRIX_NUMBER/=0)
THEN 12336 damping_matrix=>dynamic_matrices%MATRICES(dynamic_mapping%DAMPING_MATRIX_NUMBER)%PTR
12337 IF(
ASSOCIATED(damping_matrix))
THEN 12338 CALL solver_matrix_equations_matrix_add(solver_matrix,equations_set_idx, &
12339 & damping_matrix_coefficient,damping_matrix,err,error,*999)
12341 CALL flagerror(
"Dynamic damping matrix is not associated.",err,error,*999)
12345 IF(dynamic_mapping%MASS_MATRIX_NUMBER/=0)
THEN 12346 mass_matrix=>dynamic_matrices%MATRICES(dynamic_mapping%MASS_MATRIX_NUMBER)%PTR
12347 IF(
ASSOCIATED(mass_matrix))
THEN 12348 CALL solver_matrix_equations_matrix_add(solver_matrix,equations_set_idx, &
12349 & mass_matrix_coefficient,mass_matrix,err,error,*999)
12351 CALL flagerror(
"Dynamic mass matrix is not associated.",err,error,*999)
12358 IF(dynamic_mapping%MASS_MATRIX_NUMBER/=0)
THEN 12359 mass_matrix=>dynamic_matrices%MATRICES(dynamic_mapping%MASS_MATRIX_NUMBER)%PTR
12360 IF(
ASSOCIATED(mass_matrix))
THEN 12361 CALL solver_matrix_equations_matrix_add(solver_matrix,equations_set_idx, &
12362 & -1.0_dp,mass_matrix,err,error,*999)
12364 CALL flagerror(
"Dynamic stiffness matrix is not associated.",err,error,*999)
12367 CALL flagerror(
"Can not perform initial solve with no mass matrix.",err,error,*999)
12370 IF(dynamic_mapping%DAMPING_MATRIX_NUMBER/=0)
THEN 12371 damping_matrix=>dynamic_matrices%MATRICES(dynamic_mapping%DAMPING_MATRIX_NUMBER)%PTR
12372 IF(
ASSOCIATED(damping_matrix))
THEN 12373 CALL solver_matrix_equations_matrix_add(solver_matrix,equations_set_idx, &
12374 & -1.0_dp,damping_matrix,err,error,*999)
12376 CALL flagerror(
"Dynamic damping matrix is not associated.",err,error,*999)
12379 CALL flagerror(
"Can not perform initial solve with no damping matrix.",err,error,*999)
12384 CALL flagerror(
"Equations matrices dynamic matrices is not associated.",err,error,*999)
12387 CALL flagerror(
"Equations equations matrices is not associated.",err,error,*999)
12390 nonlinear_mapping=>equations_mapping%NONLINEAR_MAPPING
12391 IF(
ASSOCIATED(nonlinear_mapping))
THEN 12392 equations_matrices=>equations%EQUATIONS_MATRICES
12393 IF(.NOT.
ASSOCIATED(equations_matrices))
THEN 12394 CALL flagerror(
"Equations matrices not associated.",err,error,*999)
12397 CALL flagerror(
"Equations mapping dynamic mapping is not associated.",err,error,*999)
12402 CALL flagerror(
"Equations equations mapping is not associated.",err,error,*999)
12405 local_error=
"Solver mapping equations is not associated for equations set number "// &
12406 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 12407 CALL flagerror(local_error,err,error,*999)
12409 NULLIFY(jacobian_to_solver_map)
12410 NULLIFY(jacobian_matrix)
12411 IF(selection_type==solver_matrices_all.OR. &
12412 & selection_type==solver_matrices_nonlinear_only.OR. &
12413 & selection_type==solver_matrices_jacobian_only)
THEN 12416 nonlinear_matrices=>equations_matrices%NONLINEAR_MATRICES
12417 IF(
ASSOCIATED(nonlinear_matrices))
THEN 12418 DO equations_matrix_idx=1,nonlinear_matrices%NUMBER_OF_JACOBIANS
12419 jacobian_to_solver_map=>solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
12420 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%JACOBIAN_TO_SOLVER_MATRIX_MAPS( &
12421 & equations_matrix_idx)%PTR
12422 IF(
ASSOCIATED(jacobian_to_solver_map))
THEN 12423 jacobian_matrix=>jacobian_to_solver_map%JACOBIAN_MATRIX
12424 IF(
ASSOCIATED(jacobian_matrix))
THEN 12425 CALL solver_matrix_jacobian_matrix_add(solver_matrix,equations_set_idx, &
12426 & jacobian_matrix_coefficient,jacobian_matrix,err,error,*999)
12428 CALL flagerror(
"Jacobian matrix is not associated.",err,error,*999)
12431 local_error=
"Jacobian to solver map is not associated for Jacobian number "// &
12432 & trim(numbertovstring(equations_matrix_idx,
"*",err,error))//
"." 12433 CALL flagerror(local_error,err,error,*999)
12440 DO interface_condition_idx=1,solver_mapping%NUMBER_OF_INTERFACE_CONDITIONS
12442 DO interface_matrix_idx=1,solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
12443 & interface_to_solver_matrix_maps_sm(solver_matrix_idx)%NUMBER_OF_INTERFACE_MATRICES
12444 interface_to_solver_map=>solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
12445 & interface_to_solver_matrix_maps_sm(solver_matrix_idx)%INTERFACE_EQUATIONS_TO_SOLVER_MATRIX_MAPS( &
12446 & interface_matrix_idx)%PTR
12447 IF(
ASSOCIATED(interface_to_solver_map))
THEN 12448 interface_matrix=>interface_to_solver_map%INTERFACE_MATRIX
12449 IF(
ASSOCIATED(interface_matrix))
THEN 12450 SELECT CASE(interface_matrix%INTERFACE_MATRIX_TIME_DEPENDENCE_TYPE)
12451 CASE(interface_matrix_static)
12452 matrixcoefficients(1)=stiffness_matrix_coefficient
12453 CASE(interface_matrix_first_order_dynamic)
12454 matrixcoefficients(1)=damping_matrix_coefficient
12456 CALL flagerror(
"Not implemented.",err,error,*999)
12458 IF(interface_matrix%HAS_TRANSPOSE)
THEN 12459 SELECT CASE(interface_matrix%INTERFACE_MATRIX_TRANSPOSE_TIME_DEPENDENCE_TYPE)
12460 CASE(interface_matrix_static)
12461 matrixcoefficients(2)=stiffness_matrix_coefficient
12462 CASE(interface_matrix_first_order_dynamic)
12463 matrixcoefficients(2)=damping_matrix_coefficient
12465 CALL flagerror(
"Not implemented.",err,error,*999)
12468 matrixcoefficients(2)=0.0_dp
12470 CALL solver_matrix_interface_matrix_add(solver_matrix,interface_condition_idx, &
12471 & matrixcoefficients,interface_matrix,err,error,*999)
12473 CALL flagerror(
"The interface matrix is not associated.",err,error,*999)
12476 CALL flagerror(
"The interface matrix interface to solver map is not associated.",err,error,*999)
12481 CALL distributed_matrix_update_start(solver_distributed_matrix,err,error,*999)
12483 IF(
ASSOCIATED(previous_solver_distributed_matrix))
THEN 12484 CALL distributed_matrix_update_finish(previous_solver_distributed_matrix,err,error,*999)
12486 previous_solver_distributed_matrix=>solver_distributed_matrix
12488 CALL flagerror(
"Solver matrix distributed matrix is not associated.",err,error,*999)
12492 IF(dynamic_solver%SOLVER_INITIALISED) solver_matrix%UPDATE_MATRIX=.false.
12494 IF(dynamic_solver%SOLVER_INITIALISED) solver_matrix%UPDATE_MATRIX=.true.
12496 CALL flagerror(
"Dynamic solver solve type is not associated.",err,error,*999)
12501 CALL flagerror(
"Solver matrix is not associated.",err,error,*999)
12504 CALL flagerror(
"Invalid number of solver matrices.",err,error,*999)
12506 IF(
ASSOCIATED(previous_solver_distributed_matrix))
THEN 12507 CALL distributed_matrix_update_finish(previous_solver_distributed_matrix,err,error,*999)
12510 CALL cpu_timer(user_cpu,user_time2,err,error,*999)
12511 CALL cpu_timer(system_cpu,system_time2,err,error,*999)
12512 user_elapsed=user_time2(1)-user_time1(1)
12513 system_elapsed=system_time2(1)-system_time1(1)
12514 CALL write_string(general_output_type,
"",err,error,*999)
12515 CALL write_string_value(general_output_type,
"Total user time for solver matrices assembly = ",user_elapsed, &
12517 CALL write_string_value(general_output_type,
"Total System time for solver matrices assembly = ", &
12518 & system_elapsed,err,error,*999)
12523 NULLIFY(solver_rhs_vector)
12524 IF(selection_type==solver_matrices_all.OR. &
12525 & selection_type==solver_matrices_linear_only.OR. &
12526 & selection_type==solver_matrices_nonlinear_only.OR. &
12527 & selection_type==solver_matrices_rhs_residual_only.OR. &
12528 & selection_type==solver_matrices_rhs_only)
THEN 12529 IF(dynamic_solver%SOLVER_INITIALISED.OR.(.NOT.dynamic_solver%SOLVER_INITIALISED.AND. &
12535 CALL cpu_timer(user_cpu,user_time1,err,error,*999)
12536 CALL cpu_timer(system_cpu,system_time1,err,error,*999)
12538 IF(solver_matrices%UPDATE_RHS_VECTOR)
THEN 12540 solver_rhs_vector=>solver_matrices%RHS_VECTOR
12541 IF(
ASSOCIATED(solver_rhs_vector))
THEN 12543 CALL distributed_vector_all_values_set(solver_rhs_vector,0.0_dp,err,error,*999)
12545 NULLIFY(check_data)
12546 CALL distributed_vector_data_get(solver_rhs_vector,check_data,err,error,*999)
12548 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
12549 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
12550 IF(
ASSOCIATED(equations_set))
THEN 12551 NULLIFY(dependent_field)
12552 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
12553 equations=>equations_set%EQUATIONS
12554 IF(
ASSOCIATED(dependent_field))
THEN 12555 IF(
ASSOCIATED(equations))
THEN 12556 equations_matrices=>equations%EQUATIONS_MATRICES
12557 IF(
ASSOCIATED(equations_matrices))
THEN 12558 equations_mapping=>equations%EQUATIONS_MAPPING
12559 IF(
ASSOCIATED(equations_mapping))
THEN 12561 dynamic_mapping=>equations_mapping%DYNAMIC_MAPPING
12562 IF(
ASSOCIATED(dynamic_mapping))
THEN 12563 dynamic_variable_type=dynamic_mapping%DYNAMIC_VARIABLE_TYPE
12565 dynamic_variable=>dynamic_mapping%DYNAMIC_VARIABLE
12566 IF(
ASSOCIATED(dynamic_variable))
THEN 12567 dynamic_matrices=>equations_matrices%DYNAMIC_MATRICES
12568 IF(
ASSOCIATED(dynamic_matrices))
THEN 12569 dynamic_temp_vector=>dynamic_matrices%TEMP_VECTOR
12571 CALL distributed_vector_all_values_set(dynamic_temp_vector,0.0_dp,err,error,*999)
12572 IF(dynamic_mapping%STIFFNESS_MATRIX_NUMBER/=0)
THEN 12573 stiffness_matrix=>dynamic_matrices%MATRICES(dynamic_mapping%STIFFNESS_MATRIX_NUMBER)%PTR
12574 IF(
ASSOCIATED(stiffness_matrix))
THEN 12575 NULLIFY(predicted_mean_displacement_vector)
12576 CALL field_parameter_set_vector_get(dependent_field,dynamic_variable_type, &
12577 & field_mean_predicted_displacement_set_type,predicted_mean_displacement_vector, &
12579 CALL distributed_matrix_by_vector_add(distributed_matrix_vector_no_ghosts_type, &
12580 & -1.0_dp,stiffness_matrix%MATRIX, &
12582 & predicted_mean_displacement_vector,dynamic_temp_vector,err,error,*999)
12584 CALL flagerror(
"Dynamic stiffness matrix is not associated.",err,error,*999)
12587 IF(dynamic_mapping%DAMPING_MATRIX_NUMBER/=0.AND. &
12589 damping_matrix=>dynamic_matrices%MATRICES(dynamic_mapping%DAMPING_MATRIX_NUMBER)%PTR
12590 IF(
ASSOCIATED(damping_matrix))
THEN 12591 NULLIFY(predicted_mean_velocity_vector)
12592 CALL field_parameter_set_vector_get(dependent_field,dynamic_variable_type, &
12593 & field_mean_predicted_velocity_set_type,predicted_mean_velocity_vector, &
12595 CALL distributed_matrix_by_vector_add(distributed_matrix_vector_no_ghosts_type,-1.0_dp,&
12596 & damping_matrix%MATRIX,predicted_mean_velocity_vector,dynamic_temp_vector, &
12599 CALL flagerror(
"Dynamic damping matrix is not associated.",err,error,*999)
12602 IF(dynamic_mapping%MASS_MATRIX_NUMBER/=0.AND. &
12604 mass_matrix=>dynamic_matrices%MATRICES(dynamic_mapping%MASS_MATRIX_NUMBER)%PTR
12605 IF(
ASSOCIATED(mass_matrix))
THEN 12606 NULLIFY(predicted_mean_acceleration_vector)
12607 CALL field_parameter_set_vector_get(dependent_field,dynamic_variable_type, &
12608 & field_mean_predicted_acceleration_set_type,predicted_mean_acceleration_vector, &
12611 CALL flagerror(
"Dynamic mass matrix is not associated.",err,error,*999)
12615 CALL flagerror(
"Equations matrices dynamic matrices is not associated.",err,error,*999)
12618 CALL flagerror(
"Dynamic variable is not associated.",err,error,*999)
12621 nonlinear_mapping=>equations_mapping%NONLINEAR_MAPPING
12622 IF(
ASSOCIATED(nonlinear_mapping))
THEN 12624 dynamic_variable_type=field_u_variable_type
12625 IF(
ASSOCIATED(dynamic_temp_vector))
NULLIFY(dynamic_temp_vector)
12627 CALL flagerror(
"Equations mapping dynamic mapping is not associated.",err,error,*999)
12632 linear_mapping=>equations_mapping%LINEAR_MAPPING
12633 IF(
ASSOCIATED(linear_mapping))
THEN 12634 linear_matrices=>equations_matrices%LINEAR_MATRICES
12635 IF(
ASSOCIATED(linear_matrices))
THEN 12636 DO equations_matrix_idx=1,linear_matrices%NUMBER_OF_LINEAR_MATRICES
12637 linear_matrix=>linear_matrices%MATRICES(equations_matrix_idx)%PTR
12638 IF(
ASSOCIATED(linear_matrix))
THEN 12639 linear_variable_type=linear_mapping%EQUATIONS_MATRIX_TO_VAR_MAPS(equations_matrix_idx)% &
12641 linear_variable=>linear_mapping%EQUATIONS_MATRIX_TO_VAR_MAPS(equations_matrix_idx)% &
12643 IF(
ASSOCIATED(linear_variable))
THEN 12644 linear_temp_vector=>linear_matrix%TEMP_VECTOR
12646 CALL distributed_vector_all_values_set(linear_temp_vector,0.0_dp,err,error,*999)
12647 NULLIFY(dependent_vector)
12648 CALL field_parameter_set_vector_get(dependent_field,linear_variable_type, &
12649 & field_values_set_type,dependent_vector,err,error,*999)
12650 CALL distributed_matrix_by_vector_add(distributed_matrix_vector_no_ghosts_type,1.0_dp, &
12651 & linear_matrix%MATRIX,dependent_vector,linear_temp_vector,err,error,*999)
12653 CALL flagerror(
"Linear variable is not associated.",err,error,*999)
12656 local_error=
"Linear matrix is not associated for linear matrix number "// &
12657 & trim(numbertovstring(equations_matrix_idx,
"*",err,error))//
"." 12658 CALL flagerror(local_error,err,error,*999)
12662 CALL flagerror(
"Equations matrices linear matrices is not associated.",err,error,*999)
12665 source_mapping=>equations_mapping%SOURCE_MAPPING
12666 IF(
ASSOCIATED(source_mapping))
THEN 12667 source_vector=>equations_matrices%SOURCE_VECTOR
12668 IF(
ASSOCIATED(source_vector))
THEN 12669 distributed_source_vector=>source_vector%VECTOR
12671 CALL flagerror(
"Source vector vector is not associated.",err,error,*999)
12674 rhs_mapping=>equations_mapping%RHS_MAPPING
12675 IF(
ASSOCIATED(rhs_mapping))
THEN 12676 NULLIFY(rhs_parameters)
12677 rhs_variable_type=rhs_mapping%RHS_VARIABLE_TYPE
12678 CALL field_parameter_set_data_get(dependent_field,rhs_variable_type, &
12679 & field_values_set_type,rhs_parameters,err,error,*999)
12680 rhs_vector=>equations_matrices%RHS_VECTOR
12681 IF(
ASSOCIATED(rhs_vector))
THEN 12682 boundary_conditions=>solver_equations%BOUNDARY_CONDITIONS
12683 IF(
ASSOCIATED(boundary_conditions))
THEN 12685 rhs_variable_type=rhs_mapping%RHS_VARIABLE_TYPE
12686 rhs_variable=>rhs_mapping%RHS_VARIABLE
12687 rhs_domain_mapping=>rhs_variable%DOMAIN_MAPPING
12688 CALL field_parameter_set_created(rhs_variable%FIELD,rhs_variable_type, &
12689 & field_integrated_neumann_set_type,has_integrated_values,err,error,*999)
12690 equations_rhs_vector=>rhs_vector%VECTOR
12691 CALL boundary_conditions_variable_get(boundary_conditions,rhs_variable, &
12692 & rhs_boundary_conditions,err,error,*999)
12693 IF(
ASSOCIATED(rhs_boundary_conditions))
THEN 12695 CALL boundaryconditions_neumannintegrate(rhs_boundary_conditions, &
12698 DO equations_row_number=1,equations_mapping%TOTAL_NUMBER_OF_ROWS
12701 IF(
ASSOCIATED(dynamic_temp_vector))
THEN 12702 CALL distributed_vector_values_get(dynamic_temp_vector,equations_row_number, &
12703 & dynamic_value,err,error,*999)
12705 dynamic_value=0.0_dp
12709 IF(
ASSOCIATED(linear_mapping))
THEN 12710 linear_value_sum=0.0_dp
12711 DO equations_matrix_idx=1,linear_matrices%NUMBER_OF_LINEAR_MATRICES
12712 linear_matrix=>linear_matrices%MATRICES(equations_matrix_idx)%PTR
12713 linear_temp_vector=>linear_matrix%TEMP_VECTOR
12714 CALL distributed_vector_values_get(linear_temp_vector,equations_row_number, &
12715 & linear_value,err,error,*999)
12716 linear_value_sum=linear_value_sum+linear_value
12718 dynamic_value=dynamic_value+linear_value_sum
12721 IF(
ASSOCIATED(source_mapping))
THEN 12723 CALL distributed_vector_values_get(distributed_source_vector,equations_row_number, &
12724 & source_value,err,error,*999)
12725 dynamic_value=dynamic_value+source_value
12728 IF(.NOT.stability_test)
THEN 12730 nonlinear_mapping=>equations_mapping%NONLINEAR_MAPPING
12731 IF(
ASSOCIATED(nonlinear_mapping))
THEN 12732 NULLIFY(previous_residual_parameters)
12733 CALL field_parameter_set_data_get(dependent_field,dynamic_variable_type, &
12734 & field_previous_residual_set_type,previous_residual_parameters,err,error, &
12736 residual_variable_dof=nonlinear_mapping% &
12737 & equations_row_to_residual_dof_map(equations_row_number)
12738 previous_residual_value=-1.0_dp*previous_residual_parameters &
12739 & (residual_variable_dof)
12740 dynamic_value=dynamic_value+previous_residual_value*(1.0_dp-dynamic_solver% &
12746 DO solver_row_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
12747 & equations_row_to_solver_rows_maps(equations_row_number)%NUMBER_OF_SOLVER_ROWS
12748 solver_row_number=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
12749 & equations_row_to_solver_rows_maps(equations_row_number)%SOLVER_ROWS( &
12751 row_coupling_coefficient=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
12752 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS(equations_row_number)% &
12753 & coupling_coefficients(solver_row_idx)
12754 VALUE=dynamic_value*row_coupling_coefficient
12755 CALL distributed_vector_values_add(solver_rhs_vector,solver_row_number,
VALUE, &
12760 SELECT CASE(dynamic_solver%DEGREE)
12762 NULLIFY(field_values_vector)
12763 NULLIFY(previous_values_vector)
12764 CALL field_parameter_set_data_get(dependent_field,dynamic_variable_type, &
12765 field_values_set_type,field_values_vector,err,error,*999)
12766 CALL field_parameter_set_data_get(dependent_field,dynamic_variable_type, &
12767 field_previous_values_set_type,previous_values_vector,err,error,*999)
12769 NULLIFY(field_values_vector)
12770 NULLIFY(previous_values_vector)
12771 NULLIFY(previous_velocity_vector)
12772 CALL field_parameter_set_data_get(dependent_field,dynamic_variable_type, &
12773 field_values_set_type,field_values_vector,err,error,*999)
12774 CALL field_parameter_set_data_get(dependent_field,dynamic_variable_type, &
12775 field_previous_values_set_type,previous_values_vector,err,error,*999)
12776 CALL field_parameter_set_data_get(dependent_field,dynamic_variable_type, &
12777 field_previous_velocity_set_type,previous_velocity_vector,err,error,*999)
12779 NULLIFY(field_values_vector)
12780 NULLIFY(previous_values_vector)
12781 NULLIFY(previous_velocity_vector)
12782 NULLIFY(previous_acceleration_vector)
12783 CALL field_parameter_set_data_get(dependent_field,dynamic_variable_type, &
12784 field_values_set_type,field_values_vector,err,error,*999)
12785 CALL field_parameter_set_data_get(dependent_field,dynamic_variable_type, &
12786 field_previous_values_set_type,previous_values_vector,err,error,*999)
12787 CALL field_parameter_set_data_get(dependent_field,dynamic_variable_type, &
12788 field_previous_velocity_set_type,previous_velocity_vector,err,error,*999)
12789 CALL field_parameter_set_data_get(dependent_field,dynamic_variable_type, &
12790 field_previous_acceleration_set_type,previous_acceleration_vector,err,error,*999)
12792 local_error=
"The dynamic solver degree of "// &
12793 & trim(numbertovstring(dynamic_solver%DEGREE,
"*",err,error))// &
12795 CALL flagerror(local_error,err,error,*999)
12798 DO equations_row_number=1,equations_mapping%TOTAL_NUMBER_OF_ROWS
12800 rhs_variable_dof=rhs_mapping%EQUATIONS_ROW_TO_RHS_DOF_MAP(equations_row_number)
12801 rhs_global_dof=rhs_domain_mapping%LOCAL_TO_GLOBAL_MAP(rhs_variable_dof)
12802 rhs_boundary_condition=rhs_boundary_conditions%DOF_TYPES(rhs_global_dof)
12804 SELECT CASE(rhs_boundary_condition)
12805 CASE(boundary_condition_dof_free)
12807 CALL distributed_vector_values_get(equations_rhs_vector,equations_row_number, &
12808 & rhs_value,err,error,*999)
12809 IF(has_integrated_values)
THEN 12811 CALL field_parameter_set_get_local_dof(rhs_variable%FIELD,rhs_variable_type, &
12812 & field_integrated_neumann_set_type,rhs_variable_dof,rhs_integrated_value, &
12814 rhs_value=rhs_value+rhs_integrated_value
12817 DO solver_row_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
12818 & equations_row_to_solver_rows_maps(equations_row_number)%NUMBER_OF_SOLVER_ROWS
12819 solver_row_number=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
12820 & equations_row_to_solver_rows_maps(equations_row_number)%SOLVER_ROWS( &
12822 row_coupling_coefficient=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
12823 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS(equations_row_number)% &
12824 & coupling_coefficients(solver_row_idx)
12825 VALUE=rhs_value*row_coupling_coefficient
12826 CALL distributed_vector_values_add(solver_rhs_vector,solver_row_number,
VALUE, &
12837 IF(dynamic_solver%UPDATE_BC)
THEN 12846 variable_type=dynamic_mapping%DYNAMIC_VARIABLE_TYPE
12847 dependent_variable=>dynamic_mapping%VAR_TO_EQUATIONS_MATRICES_MAPS( &
12848 & variable_type)%VARIABLE
12849 dependent_variable_type=dependent_variable%VARIABLE_TYPE
12850 variable_domain_mapping=>dependent_variable%DOMAIN_MAPPING
12851 CALL boundary_conditions_variable_get(boundary_conditions,dependent_variable, &
12852 & dependent_boundary_conditions,err,error,*999)
12853 variable_dof=dynamic_mapping%EQUATIONS_ROW_TO_VARIABLE_DOF_MAPS( &
12854 & equations_row_number)
12855 variable_global_dof=variable_domain_mapping%LOCAL_TO_GLOBAL_MAP(variable_dof)
12856 variable_boundary_condition=dependent_boundary_conditions%DOF_TYPES( &
12857 & variable_global_dof)
12859 IF(variable_boundary_condition==boundary_condition_dof_fixed)
THEN 12860 SELECT CASE(dynamic_solver%DEGREE)
12862 alpha_value=(field_values_vector(variable_dof)- &
12863 & previous_values_vector(variable_dof))/ &
12864 & dynamic_displacement_factor
12866 alpha_value=(field_values_vector(variable_dof)- &
12867 & previous_values_vector(variable_dof)- &
12868 & dynamic_displacement_factor*previous_velocity_vector(variable_dof))/ &
12869 & dynamic_velocity_factor
12871 alpha_value=(field_values_vector(variable_dof)- &
12872 & previous_values_vector(variable_dof)- &
12873 & dynamic_displacement_factor*previous_velocity_vector(variable_dof) - &
12874 & dynamic_velocity_factor*previous_acceleration_vector(variable_dof))/ &
12875 & dynamic_acceleration_factor
12877 local_error=
"The dynamic solver degree of "// &
12878 & trim(numbertovstring(dynamic_solver%DEGREE,
"*",err,error))// &
12880 CALL flagerror(local_error,err,error,*999)
12884 IF(abs(alpha_value)>=zero_tolerance)
THEN 12885 DO equations_matrix_idx=1,dynamic_mapping%VAR_TO_EQUATIONS_MATRICES_MAPS( &
12886 & variable_type)%NUMBER_OF_EQUATIONS_MATRICES
12887 equations_matrix_number=dynamic_mapping%VAR_TO_EQUATIONS_MATRICES_MAPS( &
12888 & variable_type)%EQUATIONS_MATRIX_NUMBERS(equations_matrix_idx)
12889 IF(equations_matrix_number==dynamic_mapping%STIFFNESS_MATRIX_NUMBER) &
12891 alpha_value=alpha_value*stiffness_matrix_coefficient
12893 IF(equations_matrix_number==dynamic_mapping%DAMPING_MATRIX_NUMBER) &
12895 alpha_value=alpha_value*damping_matrix_coefficient
12897 IF(equations_matrix_number==dynamic_mapping%MASS_MATRIX_NUMBER) &
12899 alpha_value=alpha_value*mass_matrix_coefficient
12901 equations_matrix=>dynamic_matrices% &
12902 & matrices(equations_matrix_number)%PTR
12903 equations_column_number=dynamic_mapping% &
12904 & var_to_equations_matrices_maps(variable_type)% &
12905 & dof_to_columns_maps(equations_matrix_idx)% &
12906 & column_dof(variable_dof)
12907 IF(
ASSOCIATED(dependent_boundary_conditions% &
12908 & dirichlet_boundary_conditions))
THEN 12909 IF(dependent_boundary_conditions% &
12910 & number_of_dirichlet_conditions>0)
THEN 12911 DO dirichlet_idx=1,dependent_boundary_conditions% &
12912 & number_of_dirichlet_conditions
12913 IF(dependent_boundary_conditions% &
12914 & dirichlet_boundary_conditions% &
12915 & dirichlet_dof_indices(dirichlet_idx)== &
12916 & equations_column_number)
EXIT 12918 SELECT CASE(equations_matrix%STORAGE_TYPE)
12919 CASE(distributed_matrix_block_storage_type)
12920 DO dirichlet_row=1,equations_matrices%TOTAL_NUMBER_OF_ROWS
12921 CALL distributed_matrix_values_get(equations_matrix% &
12922 & matrix,dirichlet_row,equations_column_number, &
12923 & matrix_value,err,error,*999)
12924 IF(abs(matrix_value)>=zero_tolerance)
THEN 12925 DO solver_row_idx=1,solver_mapping% &
12926 & equations_set_to_solver_map(equations_set_idx)% &
12927 & equations_row_to_solver_rows_maps( &
12928 & dirichlet_row)%NUMBER_OF_SOLVER_ROWS
12929 solver_row_number=solver_mapping% &
12930 & equations_set_to_solver_map( &
12931 & equations_set_idx)% &
12932 & equations_row_to_solver_rows_maps( &
12933 & dirichlet_row)%SOLVER_ROWS(solver_row_idx)
12934 row_coupling_coefficient=solver_mapping% &
12935 & equations_set_to_solver_map( &
12936 & equations_set_idx)% &
12937 & equations_row_to_solver_rows_maps( &
12938 & dirichlet_row)%COUPLING_COEFFICIENTS( &
12940 VALUE=-1.0_dp*matrix_value*alpha_value* &
12941 & row_coupling_coefficient
12942 CALL distributed_vector_values_add( &
12943 & solver_rhs_vector, &
12944 & solver_row_number,
VALUE,err,error,*999)
12948 CASE(distributed_matrix_diagonal_storage_type)
12949 dirichlet_row=equations_column_number
12950 CALL distributed_matrix_values_get(equations_matrix% &
12951 & matrix,dirichlet_row,equations_column_number, &
12952 & matrix_value,err,error,*999)
12953 IF(abs(matrix_value)>=zero_tolerance)
THEN 12954 DO solver_row_idx=1,solver_mapping% &
12955 & equations_set_to_solver_map(equations_set_idx)% &
12956 & equations_row_to_solver_rows_maps( &
12957 & dirichlet_row)%NUMBER_OF_SOLVER_ROWS
12958 solver_row_number=solver_mapping% &
12959 & equations_set_to_solver_map( &
12960 & equations_set_idx)% &
12961 & equations_row_to_solver_rows_maps( &
12962 & dirichlet_row)%SOLVER_ROWS(solver_row_idx)
12963 row_coupling_coefficient=solver_mapping% &
12964 & equations_set_to_solver_map( &
12965 & equations_set_idx)% &
12966 & equations_row_to_solver_rows_maps( &
12967 & dirichlet_row)%COUPLING_COEFFICIENTS( &
12969 VALUE=-1.0_dp*matrix_value*alpha_value* &
12970 & row_coupling_coefficient
12971 CALL distributed_vector_values_add( &
12972 & solver_rhs_vector, &
12973 & solver_row_number,
VALUE,err,error,*999)
12977 CASE(distributed_matrix_column_major_storage_type)
12978 CALL flagerror(
"Not implemented.",err,error,*999)
12979 CASE(distributed_matrix_row_major_storage_type)
12980 CALL flagerror(
"Not implemented.",err,error,*999)
12981 CASE(distributed_matrix_compressed_row_storage_type)
12982 sparsity_indices=>dependent_boundary_conditions% &
12983 & dirichlet_boundary_conditions%DYNAMIC_SPARSITY_INDICES( &
12984 & equations_set_idx,equations_matrix_idx)%PTR
12985 IF(
ASSOCIATED(sparsity_indices))
THEN 12986 DO equations_row_number2=sparsity_indices% &
12987 & sparse_column_indices(dirichlet_idx), &
12988 & sparsity_indices%SPARSE_COLUMN_INDICES( &
12989 & dirichlet_idx+1)-1
12990 dirichlet_row=sparsity_indices%SPARSE_ROW_INDICES( &
12991 & equations_row_number2)
12992 CALL distributed_matrix_values_get(equations_matrix% &
12993 & matrix,dirichlet_row,equations_column_number, &
12994 & matrix_value,err,error,*999)
12995 IF(abs(matrix_value)>=zero_tolerance)
THEN 12996 DO solver_row_idx=1,solver_mapping% &
12997 & equations_set_to_solver_map(equations_set_idx)% &
12998 & equations_row_to_solver_rows_maps( &
12999 & dirichlet_row)%NUMBER_OF_SOLVER_ROWS
13000 solver_row_number=solver_mapping% &
13001 & equations_set_to_solver_map( &
13002 & equations_set_idx)% &
13003 & equations_row_to_solver_rows_maps( &
13004 & dirichlet_row)%SOLVER_ROWS(solver_row_idx)
13005 row_coupling_coefficient=solver_mapping% &
13006 & equations_set_to_solver_map( &
13007 & equations_set_idx)% &
13008 & equations_row_to_solver_rows_maps( &
13009 & dirichlet_row)%COUPLING_COEFFICIENTS( &
13011 VALUE=-1.0_dp*matrix_value*alpha_value* &
13012 & row_coupling_coefficient
13013 CALL distributed_vector_values_add( &
13014 & solver_rhs_vector, &
13015 & solver_row_number,
VALUE,err,error,*999)
13020 CALL flagerror(
"Sparsity indices are not associated.", &
13023 CASE(distributed_matrix_compressed_column_storage_type)
13024 CALL flagerror(
"Not implemented.",err,error,*999)
13025 CASE(distributed_matrix_row_column_storage_type)
13026 CALL flagerror(
"Not implemented.",err,error,*999)
13028 local_error=
"The storage type of "// &
13029 & trim(numbertovstring(equations_matrix%STORAGE_TYPE,
"*", &
13030 & err,error))//
" is invalid." 13031 CALL flagerror(local_error,err,error,*999)
13035 CALL flagerror(
"Dirichlet boundary conditions is & 13036 & not associated.",err,error,*999)
13045 CASE(boundary_condition_dof_fixed)
13048 DO solver_row_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
13049 & equations_row_to_solver_rows_maps(equations_row_number)%NUMBER_OF_SOLVER_ROWS
13050 solver_row_number=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
13051 & equations_row_to_solver_rows_maps(equations_row_number)%SOLVER_ROWS( &
13053 row_coupling_coefficient=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
13054 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS(equations_row_number)% &
13055 & coupling_coefficients(solver_row_idx)
13056 VALUE=rhs_parameters(rhs_variable_dof)*row_coupling_coefficient
13057 IF(has_integrated_values)
THEN 13059 CALL field_parameter_set_get_local_dof(rhs_variable%FIELD,rhs_variable_type, &
13060 & field_integrated_neumann_set_type,rhs_variable_dof,rhs_integrated_value, &
13062 VALUE=
VALUE+rhs_integrated_value*row_coupling_coefficient
13064 CALL distributed_vector_values_add(solver_rhs_vector,solver_row_number,
VALUE, &
13067 CASE(boundary_condition_dof_mixed)
13069 CALL flagerror(
"Mixed Boundary Conditions Not implemented.",err,error,*999)
13071 local_error=
"The RHS boundary condition of "// &
13072 & trim(numbertovstring(rhs_boundary_condition,
"*",err,error))// &
13073 &
" for RHS variable dof number "// &
13074 & trim(numbertovstring(rhs_variable_dof,
"*",err,error))//
" is invalid." 13075 CALL flagerror(local_error,err,error,*999)
13079 CALL flagerror(
"RHS boundary conditions variable is not associated.",err,error,*999)
13082 CALL flagerror(
"Equations set boundary conditions is not associated.",err,error,*999)
13085 CALL flagerror(
"Equations matrices RHS vector is not associated.",err,error,*999)
13087 CALL field_parameter_set_data_restore(dependent_field,rhs_variable_type,field_values_set_type, &
13088 & rhs_parameters,err,error,*999)
13090 CALL flagerror(
"Equations mapping RHS mapping is not associated.",err,error,*999)
13093 CALL flagerror(
"Equations equations mapping is not associated.",err,error,*999)
13096 CALL flagerror(
"Equations equations matrices is not associated.",err,error,*999)
13099 CALL flagerror(
"Equations set equations is not associated.",err,error,*999)
13102 CALL flagerror(
"Equations set dependent field is not associated.",err,error,*999)
13105 CALL flagerror(
"Equations set is not associated.",err,error,*999)
13110 DO interface_condition_idx=1,solver_mapping%NUMBER_OF_INTERFACE_CONDITIONS
13111 interface_condition=>solver_mapping%INTERFACE_CONDITIONS(interface_condition_idx)%PTR
13112 IF(
ASSOCIATED(interface_condition))
THEN 13113 SELECT CASE(interface_condition%METHOD)
13114 CASE(interface_condition_lagrange_multipliers_method,interface_condition_penalty_method)
13115 interface_equations=>interface_condition%INTERFACE_EQUATIONS
13116 IF(
ASSOCIATED(interface_equations))
THEN 13117 interface_mapping=>interface_equations%INTERFACE_MAPPING
13118 IF(
ASSOCIATED(interface_mapping))
THEN 13119 interface_lagrange=>interface_condition%LAGRANGE
13120 IF(
ASSOCIATED(interface_lagrange))
THEN 13121 lagrange_field=>interface_lagrange%LAGRANGE_FIELD
13122 IF(
ASSOCIATED(lagrange_field))
THEN 13123 interface_rhs_mapping=>interface_mapping%RHS_MAPPING
13124 IF(
ASSOCIATED(interface_rhs_mapping))
THEN 13125 interface_matrices=>interface_equations%INTERFACE_MATRICES
13126 IF(
ASSOCIATED(interface_matrices))
THEN 13127 interface_rhs_vector=>interface_matrices%RHS_VECTOR
13128 IF(
ASSOCIATED(interface_rhs_vector))
THEN 13130 DO interface_column_number=1,interface_mapping%TOTAL_NUMBER_OF_COLUMNS
13131 CALL distributed_vector_values_get(interface_rhs_vector%RHS_VECTOR, &
13132 & interface_column_number,rhs_value,err,error,*999)
13134 DO solver_row_idx=1,solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP( &
13135 & interface_condition_idx)%INTERFACE_COLUMN_TO_SOLVER_ROWS_MAPS( &
13136 & interface_column_number)%NUMBER_OF_SOLVER_ROWS
13137 solver_row_number=solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP( &
13138 & interface_condition_idx)%INTERFACE_COLUMN_TO_SOLVER_ROWS_MAPS( &
13139 & interface_column_number)%SOLVER_ROW
13140 row_coupling_coefficient=solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP( &
13141 & interface_condition_idx)%INTERFACE_COLUMN_TO_SOLVER_ROWS_MAPS( &
13142 & interface_column_number)%COUPLING_COEFFICIENT
13143 VALUE=rhs_value*row_coupling_coefficient
13144 CALL distributed_vector_values_add(solver_rhs_vector,solver_row_number,
VALUE, &
13149 CALL flagerror(
"Interface matrices RHS vector is not associated.",err,error,*999)
13152 CALL flagerror(
"Interface equations interface matrices is not associated.",err,error,*999)
13155 CALL flagerror(
"Interface mapping RHS mapping is not associated.",err,error,*999)
13158 CALL flagerror(
"Interface Lagrange field is not associated.",err,error,*999)
13161 CALL flagerror(
"Interface Lagrange is not associated.",err,error,*999)
13164 CALL flagerror(
"Interface equations interface mapping is not associated.",err,error,*999)
13167 CALL flagerror(
"Interface condition equations is not associated.",err,error,*999)
13169 CASE(interface_condition_augmented_lagrange_method)
13170 CALL flagerror(
"Not implemented.",err,error,*999)
13171 CASE(interface_condition_point_to_point_method)
13172 CALL flagerror(
"Not implemented.",err,error,*999)
13174 local_error=
"The interface condition method of "// &
13175 & trim(numbertovstring(interface_condition%METHOD,
"*",err,error))// &
13177 CALL flagerror(local_error,err,error,*999)
13180 CALL flagerror(
"Interface condition is not associated.",err,error,*999)
13185 CALL distributed_vector_update_start(solver_rhs_vector,err,error,*999)
13187 NULLIFY(check_data)
13188 CALL distributed_vector_data_get(solver_rhs_vector,check_data,err,error,*999)
13191 CALL flagerror(
"The solver RHS vector is not associated.",err,error,*999)
13195 CALL cpu_timer(user_cpu,user_time2,err,error,*999)
13196 CALL cpu_timer(system_cpu,system_time2,err,error,*999)
13197 user_elapsed=user_time2(1)-user_time1(1)
13198 system_elapsed=system_time2(1)-system_time1(1)
13199 CALL write_string(general_output_type,
"",err,error,*999)
13200 CALL write_string_value(general_output_type,
"Total user time for solver RHS assembly = ",user_elapsed, &
13202 CALL write_string_value(general_output_type,
"Total System time for solver RHS assembly = ",system_elapsed, &
13206 IF(
ASSOCIATED(solver_rhs_vector))
THEN 13207 CALL distributed_vector_update_finish(solver_rhs_vector,err,error,*999)
13211 NULLIFY(solver_residual_vector)
13212 IF(selection_type==solver_matrices_all.OR. &
13213 & selection_type==solver_matrices_nonlinear_only.OR. &
13214 & selection_type==solver_matrices_residual_only.OR. &
13215 & selection_type==solver_matrices_rhs_residual_only)
THEN 13216 IF(dynamic_solver%SOLVER_INITIALISED.OR.(.NOT.dynamic_solver%SOLVER_INITIALISED.AND. &
13222 CALL cpu_timer(user_cpu,user_time1,err,error,*999)
13223 CALL cpu_timer(system_cpu,system_time1,err,error,*999)
13225 IF(solver_matrices%UPDATE_RESIDUAL)
THEN 13226 solver_residual_vector=>solver_matrices%RESIDUAL
13227 IF(
ASSOCIATED(solver_residual_vector))
THEN 13229 CALL distributed_vector_all_values_set(solver_residual_vector,0.0_dp,err,error,*999)
13231 NULLIFY(check_data)
13232 CALL distributed_vector_data_get(solver_residual_vector,check_data,err,error,*999)
13234 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
13235 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
13236 IF(
ASSOCIATED(equations_set))
THEN 13237 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
13238 IF(
ASSOCIATED(dependent_field))
THEN 13239 equations=>equations_set%EQUATIONS
13240 IF(
ASSOCIATED(equations))
THEN 13241 equations_matrices=>equations%EQUATIONS_MATRICES
13242 IF(
ASSOCIATED(equations_matrices))
THEN 13243 equations_mapping=>equations%EQUATIONS_MAPPING
13244 IF(
ASSOCIATED(equations_mapping))
THEN 13245 dynamic_mapping=>equations_mapping%DYNAMIC_MAPPING
13246 IF(
ASSOCIATED(dynamic_mapping))
THEN 13247 dynamic_variable_type=dynamic_mapping%DYNAMIC_VARIABLE_TYPE
13249 dynamic_variable=>dynamic_mapping%DYNAMIC_VARIABLE
13250 IF(
ASSOCIATED(dynamic_variable))
THEN 13251 dynamic_matrices=>equations_matrices%DYNAMIC_MATRICES
13252 IF(
ASSOCIATED(dynamic_matrices))
THEN 13253 dynamic_temp_vector=>dynamic_matrices%TEMP_VECTOR
13255 CALL distributed_vector_all_values_set(dynamic_temp_vector,0.0_dp,err,error,*999)
13256 NULLIFY(incremental_vector)
13258 CALL field_parameter_set_vector_get(dependent_field,dynamic_variable_type, &
13259 & field_incremental_values_set_type,incremental_vector,err,error,*999)
13260 IF(dynamic_mapping%STIFFNESS_MATRIX_NUMBER/=0)
THEN 13261 stiffness_matrix=>dynamic_matrices%MATRICES(dynamic_mapping%STIFFNESS_MATRIX_NUMBER)%PTR
13262 IF(
ASSOCIATED(stiffness_matrix))
THEN 13263 CALL distributed_matrix_by_vector_add(distributed_matrix_vector_no_ghosts_type, &
13264 & stiffness_matrix_coefficient,stiffness_matrix%MATRIX,incremental_vector, &
13265 & dynamic_temp_vector,err,error,*999)
13267 CALL flagerror(
"Dynamic stiffness matrix is not associated.",err,error,*999)
13270 IF(dynamic_mapping%DAMPING_MATRIX_NUMBER/=0.AND. &
13272 damping_matrix=>dynamic_matrices%MATRICES(dynamic_mapping%DAMPING_MATRIX_NUMBER)%PTR
13273 IF(
ASSOCIATED(damping_matrix))
THEN 13274 CALL distributed_matrix_by_vector_add(distributed_matrix_vector_no_ghosts_type, &
13275 & damping_matrix_coefficient,damping_matrix%MATRIX,incremental_vector, &
13276 & dynamic_temp_vector,err,error,*999)
13278 CALL flagerror(
"Dynamic damping matrix is not associated.",err,error,*999)
13281 IF(dynamic_mapping%MASS_MATRIX_NUMBER/=0.AND. &
13283 mass_matrix=>dynamic_matrices%MATRICES(dynamic_mapping%MASS_MATRIX_NUMBER)%PTR
13284 IF(
ASSOCIATED(mass_matrix))
THEN 13285 CALL distributed_matrix_by_vector_add(distributed_matrix_vector_no_ghosts_type, &
13286 & mass_matrix_coefficient,mass_matrix%MATRIX,incremental_vector, &
13287 & dynamic_temp_vector,err,error,*999)
13289 CALL flagerror(
"Dynamic mass matrix is not associated.",err,error,*999)
13293 CALL flagerror(
"Dynamic variable is not associated.",err,error,*999)
13296 CALL flagerror(
"Equations matrices dynamic matrices is not associated.",err,error,*999)
13300 linear_mapping=>equations_mapping%LINEAR_MAPPING
13301 IF(
ASSOCIATED(linear_mapping))
THEN 13302 linear_matrices=>equations_matrices%LINEAR_MATRICES
13303 IF(
ASSOCIATED(linear_matrices))
THEN 13304 DO equations_matrix_idx=1,linear_matrices%NUMBER_OF_LINEAR_MATRICES
13305 linear_matrix=>linear_matrices%MATRICES(equations_matrix_idx)%PTR
13306 IF(
ASSOCIATED(linear_matrix))
THEN 13307 linear_variable_type=linear_mapping%EQUATIONS_MATRIX_TO_VAR_MAPS(equations_matrix_idx)% &
13309 linear_variable=>linear_mapping%EQUATIONS_MATRIX_TO_VAR_MAPS(equations_matrix_idx)% &
13311 IF(
ASSOCIATED(linear_variable))
THEN 13312 linear_temp_vector=>linear_matrix%TEMP_VECTOR
13314 CALL distributed_vector_all_values_set(linear_temp_vector,0.0_dp,err,error,*999)
13315 NULLIFY(dependent_vector)
13316 CALL field_parameter_set_vector_get(dependent_field,linear_variable_type, &
13317 & field_values_set_type,dependent_vector,err,error,*999)
13318 CALL distributed_matrix_by_vector_add(distributed_matrix_vector_no_ghosts_type, &
13319 & 1.0_dp,linear_matrix%MATRIX,dependent_vector,linear_temp_vector,err,error,*999)
13321 CALL flagerror(
"Linear variable is not associated.",err,error,*999)
13324 local_error=
"Linear matrix is not associated for linear matrix number "// &
13325 & trim(numbertovstring(equations_matrix_idx,
"*",err,error))//
"." 13326 CALL flagerror(local_error,err,error,*999)
13330 CALL flagerror(
"Equations matrices linear matrices is not associated.",err,error,*999)
13334 nonlinear_mapping=>equations_mapping%NONLINEAR_MAPPING
13335 IF(
ASSOCIATED(nonlinear_mapping))
THEN 13336 nonlinear_matrices=>equations_matrices%NONLINEAR_MATRICES
13337 IF(
ASSOCIATED(nonlinear_matrices))
THEN 13338 residual_vector=>nonlinear_matrices%RESIDUAL
13340 DO equations_row_number=1,equations_mapping%TOTAL_NUMBER_OF_ROWS
13341 IF(solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
13342 & equations_row_to_solver_rows_maps(equations_row_number)% &
13343 & number_of_solver_rows>0)
THEN 13345 CALL distributed_vector_values_get(residual_vector,equations_row_number, &
13346 & residual_value,err,error,*999)
13347 IF(stability_test)
THEN 13348 residual_value=residual_value
13350 residual_value=residual_value*dynamic_solver%THETA(1)
13353 IF(
ASSOCIATED(linear_mapping))
THEN 13354 linear_value_sum=0.0_dp
13355 DO equations_matrix_idx2=1,linear_matrices%NUMBER_OF_LINEAR_MATRICES
13356 linear_matrix=>linear_matrices%MATRICES(equations_matrix_idx2)%PTR
13357 linear_temp_vector=>linear_matrix%TEMP_VECTOR
13358 CALL distributed_vector_values_get(linear_temp_vector,equations_row_number, &
13359 & linear_value,err,error,*999)
13360 linear_value_sum=linear_value_sum+linear_value
13362 residual_value=residual_value+linear_value_sum
13364 IF(
ASSOCIATED(dynamic_mapping))
THEN 13366 CALL distributed_vector_values_get(dynamic_temp_vector,equations_row_number, &
13367 & dynamic_value,err,error,*999)
13368 residual_value=residual_value+dynamic_value
13371 DO solver_row_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
13372 & equations_row_to_solver_rows_maps(equations_row_number)%NUMBER_OF_SOLVER_ROWS
13373 solver_row_number=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
13374 & equations_row_to_solver_rows_maps(equations_row_number)%SOLVER_ROWS( &
13376 row_coupling_coefficient=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
13377 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS(equations_row_number)% &
13378 & coupling_coefficients(solver_row_idx)
13379 VALUE=residual_value*row_coupling_coefficient
13381 CALL distributed_vector_values_add(solver_residual_vector,solver_row_number,
VALUE, &
13387 CALL flagerror(
"Equations matrices nonlinear matrices is not associated.",err,error,*999)
13390 CALL flagerror(
"Equations mapping nonlinear mapping is not associated.",err,error,*999)
13393 CALL flagerror(
"Equations equations mapping is not associated.",err,error,*999)
13396 CALL flagerror(
"Equations equations matrices is not associated.",err,error,*999)
13399 CALL flagerror(
"Equations set equations is not associated.",err,error,*999)
13402 CALL flagerror(
"Equations set dependent field is not associated.",err,error,*999)
13405 CALL flagerror(
"Equations set is not associated.",err,error,*999)
13410 DO interface_condition_idx=1,solver_mapping%NUMBER_OF_INTERFACE_CONDITIONS
13411 interface_condition=>solver_mapping%INTERFACE_CONDITIONS(interface_condition_idx)%PTR
13412 IF(
ASSOCIATED(interface_condition))
THEN 13413 lagrange_field=>interface_condition%LAGRANGE%LAGRANGE_FIELD
13414 IF(
ASSOCIATED(lagrange_field))
THEN 13415 interface_equations=>interface_condition%INTERFACE_EQUATIONS
13416 IF(
ASSOCIATED(interface_equations))
THEN 13417 interface_matrices=>interface_equations%INTERFACE_MATRICES
13418 IF(
ASSOCIATED(interface_matrices))
THEN 13419 interface_mapping=>interface_equations%INTERFACE_MAPPING
13420 IF(
ASSOCIATED(interface_mapping))
THEN 13421 SELECT CASE(interface_condition%METHOD)
13422 CASE(interface_condition_lagrange_multipliers_method)
13423 number_of_interface_matrices=interface_mapping%NUMBER_OF_INTERFACE_MATRICES
13424 CASE(interface_condition_penalty_method)
13425 number_of_interface_matrices=interface_mapping%NUMBER_OF_INTERFACE_MATRICES-1
13428 DO interface_matrix_idx=1,number_of_interface_matrices
13430 interface_matrix=>interface_matrices%MATRICES(interface_matrix_idx)%PTR
13431 IF(
ASSOCIATED(interface_matrix))
THEN 13432 interface_variable_type=interface_mapping%LAGRANGE_VARIABLE_TYPE
13433 interface_variable=>interface_mapping%LAGRANGE_VARIABLE
13434 IF(
ASSOCIATED(interface_variable))
THEN 13435 interface_temp_vector=>interface_matrix%TEMP_VECTOR
13437 CALL distributed_vector_all_values_set(interface_temp_vector,0.0_dp,err,error,*999)
13438 NULLIFY(lagrange_vector)
13439 CALL field_parameter_set_vector_get(lagrange_field,interface_variable_type, &
13440 & field_values_set_type,lagrange_vector,err,error,*999)
13443 SELECT CASE(interface_matrix%INTERFACE_MATRIX_TIME_DEPENDENCE_TYPE)
13444 CASE(interface_matrix_static)
13445 matrixcoefficients(1)=stiffness_matrix_coefficient
13446 CASE(interface_matrix_first_order_dynamic)
13447 matrixcoefficients(1)=damping_matrix_coefficient
13449 CALL flagerror(
"Not implemented.",err,error,*999)
13451 IF(interface_matrix%HAS_TRANSPOSE)
THEN 13452 SELECT CASE(interface_matrix%INTERFACE_MATRIX_TRANSPOSE_TIME_DEPENDENCE_TYPE)
13453 CASE(interface_matrix_static)
13454 matrixcoefficients(2)=stiffness_matrix_coefficient
13455 CASE(interface_matrix_first_order_dynamic)
13456 matrixcoefficients(2)=damping_matrix_coefficient
13459 CALL flagerror(
"Not implemented.",err,error,*999)
13462 matrixcoefficients(2)=0.0_dp
13469 CALL distributed_matrix_by_vector_add(distributed_matrix_vector_no_ghosts_type, &
13470 & matrixcoefficients(1),interface_matrix%MATRIX,lagrange_vector,interface_temp_vector, &
13474 DO interface_row_number=1,interface_matrix%NUMBER_OF_ROWS
13475 IF(solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
13476 & interface_to_solver_matrix_maps_im(interface_matrix_idx)% &
13477 & interface_row_to_solver_rows_map(interface_row_number)%NUMBER_OF_SOLVER_ROWS>0)
THEN 13480 solver_row_number=solver_mapping% &
13481 & interface_condition_to_solver_map(interface_condition_idx)% &
13482 & interface_to_solver_matrix_maps_im(interface_matrix_idx)% &
13483 & interface_row_to_solver_rows_map(interface_row_number)%SOLVER_ROW
13484 row_coupling_coefficient=solver_mapping% &
13485 & interface_condition_to_solver_map(interface_condition_idx)% &
13486 & interface_to_solver_matrix_maps_im(interface_matrix_idx)% &
13487 & interface_row_to_solver_rows_map(interface_row_number)%COUPLING_COEFFICIENT
13488 CALL distributed_vector_values_get(interface_temp_vector,interface_row_number, &
13489 & residual_value,err,error,*999)
13490 VALUE=residual_value*row_coupling_coefficient
13492 CALL distributed_vector_values_add(solver_residual_vector,solver_row_number,
VALUE, &
13497 CALL flagerror(
"Interface variable is not associated.",err,error,*999)
13500 dependent_variable_type=interface_mapping% &
13501 & interface_matrix_rows_to_var_maps(interface_matrix_idx)%VARIABLE_TYPE
13502 dependent_variable=>interface_mapping% &
13503 & interface_matrix_rows_to_var_maps(interface_matrix_idx)%VARIABLE
13504 IF(
ASSOCIATED(dependent_variable))
THEN 13505 interface_temp_vector=>interface_matrix%TEMP_TRANSPOSE_VECTOR
13507 CALL distributed_vector_all_values_set(interface_temp_vector,0.0_dp,err,error,*999)
13508 NULLIFY(dependent_vector)
13509 dependent_field=>dependent_variable%FIELD
13513 IF(interface_matrix_idx==1)
THEN 13514 CALL field_parameter_set_vector_get(dependent_field,dependent_variable_type, &
13515 & field_incremental_values_set_type,dependent_vector,err,error,*999)
13517 CALL field_parameter_set_vector_get(dependent_field,dependent_variable_type, &
13518 & field_values_set_type,dependent_vector,err,error,*999)
13522 CALL distributed_matrix_by_vector_add(distributed_matrix_vector_no_ghosts_type, &
13523 & matrixcoefficients(2),interface_matrix%MATRIX_TRANSPOSE,dependent_vector, &
13524 & interface_temp_vector,err,error,*999)
13528 DO interface_row_number=1,interface_matrices%NUMBER_OF_COLUMNS
13529 IF(solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
13530 & interface_column_to_solver_rows_maps(interface_row_number)% &
13531 & number_of_solver_rows>0)
THEN 13534 solver_row_number=solver_mapping% &
13535 & interface_condition_to_solver_map(interface_condition_idx)% &
13536 & interface_column_to_solver_rows_maps(interface_row_number)%SOLVER_ROW
13537 row_coupling_coefficient=solver_mapping% &
13538 & interface_condition_to_solver_map(interface_condition_idx)% &
13539 & interface_column_to_solver_rows_maps(interface_row_number)%COUPLING_COEFFICIENT
13540 CALL distributed_vector_values_get(interface_temp_vector,interface_row_number, &
13541 & residual_value,err,error,*999)
13545 VALUE=residual_value*row_coupling_coefficient
13548 CALL distributed_vector_values_add(solver_residual_vector,solver_row_number,
VALUE, &
13553 CALL flagerror(
"Dependent variable is not associated.",err,error,*999)
13556 local_error=
"Interface matrix is not associated for linear matrix number "// &
13557 & trim(numbertovstring(equations_matrix_idx,
"*",err,error))//
"." 13558 CALL flagerror(local_error,err,error,*999)
13561 SELECT CASE(interface_condition%METHOD)
13562 CASE(interface_condition_penalty_method)
13563 interface_matrix_idx=interface_mapping%NUMBER_OF_INTERFACE_MATRICES
13565 interface_matrix=>interface_matrices%MATRICES(interface_matrix_idx)%PTR
13566 IF(
ASSOCIATED(interface_matrix))
THEN 13567 interface_variable_type=interface_mapping%LAGRANGE_VARIABLE_TYPE
13568 interface_variable=>interface_mapping%LAGRANGE_VARIABLE
13569 IF(
ASSOCIATED(interface_variable))
THEN 13570 interface_temp_vector=>interface_matrix%TEMP_VECTOR
13572 CALL distributed_vector_all_values_set(interface_temp_vector,0.0_dp,err,error,*999)
13573 NULLIFY(lagrange_vector)
13574 CALL field_parameter_set_vector_get(lagrange_field,interface_variable_type, &
13575 & field_values_set_type,lagrange_vector,err,error,*999)
13576 CALL distributed_matrix_by_vector_add(distributed_matrix_vector_no_ghosts_type,1.0_dp, &
13577 & interface_matrix%MATRIX,lagrange_vector,interface_temp_vector,err,error,*999)
13579 DO interface_row_number=1,interface_matrix%NUMBER_OF_ROWS
13580 IF(solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
13581 & interface_to_solver_matrix_maps_im(interface_matrix_idx)% &
13582 & interface_row_to_solver_rows_map(interface_row_number)%NUMBER_OF_SOLVER_ROWS>0)
THEN 13585 solver_row_number=solver_mapping% &
13586 & interface_condition_to_solver_map(interface_condition_idx)% &
13587 & interface_to_solver_matrix_maps_im(interface_matrix_idx)% &
13588 & interface_row_to_solver_rows_map(interface_row_number)%SOLVER_ROW
13589 row_coupling_coefficient=solver_mapping% &
13590 & interface_condition_to_solver_map(interface_condition_idx)% &
13591 & interface_to_solver_matrix_maps_im(interface_matrix_idx)% &
13592 & interface_row_to_solver_rows_map(interface_row_number)%COUPLING_COEFFICIENT
13593 CALL distributed_vector_values_get(interface_temp_vector,interface_row_number, &
13594 & residual_value,err,error,*999)
13595 VALUE=residual_value*row_coupling_coefficient
13597 CALL distributed_vector_values_add(solver_residual_vector,solver_row_number,
VALUE, &
13602 CALL flagerror(
"Interface variable is not associated.",err,error,*999)
13605 local_error=
"Interface matrix is not associated for linear matrix number "// &
13606 & trim(numbertovstring(equations_matrix_idx,
"*",err,error))//
"." 13607 CALL flagerror(local_error,err,error,*999)
13611 CALL flagerror(
"Interface mapping is not associated.",err,error,*999)
13614 CALL flagerror(
"Interface matrices is not associated.",err,error,*999)
13617 CALL flagerror(
"Interface equations is not associated.",err,error,*999)
13620 CALL flagerror(
"Interface Lagrange field is not associated.",err,error,*999)
13623 CALL flagerror(
"Interface condition is not associated.",err,error,*999)
13628 CALL distributed_vector_update_start(solver_residual_vector,err,error,*999)
13630 NULLIFY(check_data2)
13631 CALL distributed_vector_data_get(solver_residual_vector,check_data2,err,error,*999)
13634 CALL flagerror(
"The solver residual vector is not associated.",err,error,*999)
13637 IF(
ASSOCIATED(solver_residual_vector))
THEN 13638 CALL distributed_vector_update_finish(solver_residual_vector,err,error,*999)
13641 CALL cpu_timer(user_cpu,user_time2,err,error,*999)
13642 CALL cpu_timer(system_cpu,system_time2,err,error,*999)
13643 user_elapsed=user_time2(1)-user_time1(1)
13644 system_elapsed=system_time2(1)-system_time1(1)
13645 CALL write_string(general_output_type,
"",err,error,*999)
13646 CALL write_string_value(general_output_type,
"Total user time for solver residual assembly = ", &
13647 & user_elapsed,err,error,*999)
13648 CALL write_string_value(general_output_type,
"Total System time for solver residual assembly = ", &
13649 & system_elapsed,err,error,*999)
13654 IF(dynamic_solver%SOLVER_INITIALISED)
THEN 13659 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
13660 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
13661 IF(
ASSOCIATED(equations_set))
THEN 13662 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
13663 IF(
ASSOCIATED(dependent_field))
THEN 13664 equations=>equations_set%EQUATIONS
13665 IF(
ASSOCIATED(equations))
THEN 13666 equations_mapping=>equations%EQUATIONS_MAPPING
13667 IF(
ASSOCIATED(equations_mapping))
THEN 13668 dynamic_mapping=>equations_mapping%DYNAMIC_MAPPING
13669 IF(
ASSOCIATED(dynamic_mapping))
THEN 13670 dynamic_variable_type=dynamic_mapping%DYNAMIC_VARIABLE_TYPE
13671 SELECT CASE(dynamic_solver%DEGREE)
13675 CALL field_parameter_sets_add(dependent_field,dynamic_variable_type,first_update_factor, &
13676 & field_previous_velocity_set_type,field_values_set_type,err,error,*999)
13678 CALL field_parameter_sets_add(dependent_field,dynamic_variable_type,[first_update_factor, &
13679 & second_update_factor],[field_previous_velocity_set_type,field_previous_values_set_type], &
13680 & field_values_set_type,err,error,*999)
13681 CALL field_parameter_sets_add(dependent_field,dynamic_variable_type,first_update_factor, &
13682 & field_previous_acceleration_set_type,field_velocity_values_set_type,err,error,*999)
13684 local_error=
"The dynamic solver degree of "// &
13685 & trim(numbertovstring(dynamic_solver%DEGREE,
"*",err,error))//
" is invalid." 13686 CALL flagerror(local_error,err,error,*999)
13689 local_error=
"Equations mapping dynamic mapping is not associated for equations set index number "// &
13690 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 13691 CALL flagerror(local_error,err,error,*999)
13694 local_error=
"Equations equations mapping is not associated for equations set index number "// &
13695 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 13696 CALL flagerror(local_error,err,error,*999)
13699 local_error=
"Equations set equations is not associated for equations set index number "// &
13700 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 13701 CALL flagerror(local_error,err,error,*999)
13704 local_error=
"Equations set dependent field is not associated for equations set index number "// &
13705 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 13706 CALL flagerror(local_error,err,error,*999)
13709 local_error=
"Equations set is not associated for equations set index number "// &
13710 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 13711 CALL flagerror(local_error,err,error,*999)
13718 CALL solver_matrices_output(general_output_type,selection_type,solver_matrices,err,error,*999)
13721 CALL flagerror(
"Solver solver matrices is not associated.",err,error,*999)
13724 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
13727 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
13730 CALL flagerror(
"Solver dynamic solver is not associated.",err,error,*999)
13733 CALL flagerror(
"Solver is not associated.",err,error,*999)
13736 exits(
"SOLVER_MATRICES_DYNAMIC_ASSEMBLE")
13738 999 errorsexits(
"SOLVER_MATRICES_DYNAMIC_ASSEMBLE",err,error)
13750 TYPE(solver_type),
POINTER :: SOLVER
13751 INTEGER(INTG),
INTENT(IN) :: SELECTION_TYPE
13752 INTEGER(INTG),
INTENT(OUT) :: ERR
13753 TYPE(varying_string),
INTENT(OUT) :: ERROR
13755 INTEGER(INTG) :: dependent_variable_type,interface_variable_type,equations_column_number,equations_matrix_idx, &
13756 & equations_matrix_number,interface_row_number,equations_row_number,equations_row_number2,equations_set_idx, &
13757 & interface_column_number,interface_condition_idx,interface_matrix_idx,LINEAR_VARIABLE_TYPE,rhs_boundary_condition, &
13758 & rhs_global_dof,equations_matrix_idx2,rhs_variable_dof,rhs_variable_type,variable_boundary_condition,solver_matrix_idx, &
13759 & solver_row_idx,solver_row_number,variable_dof,variable_global_dof,variable_idx,variable_type,&
13760 & dirichlet_idx,dirichlet_row,number_of_interface_matrices
13761 REAL(SP) :: SYSTEM_ELAPSED,SYSTEM_TIME1(1),SYSTEM_TIME2(1),USER_ELAPSED,USER_TIME1(1),USER_TIME2(1)
13762 REAL(DP) :: DEPENDENT_VALUE,LINEAR_VALUE,LINEAR_VALUE_SUM,MATRIX_VALUE,RESIDUAL_VALUE,RHS_VALUE,row_coupling_coefficient, &
13763 & SOURCE_VALUE,VALUE,RHS_INTEGRATED_VALUE
13764 REAL(DP),
POINTER :: RHS_PARAMETERS(:),CHECK_DATA(:),CHECK_DATA2(:),CHECK_DATA3(:),CHECK_DATA4(:)
13765 LOGICAL :: SUBTRACT_FIXED_BCS_FROM_RESIDUAL,HAS_INTEGRATED_VALUES
13766 TYPE(real_dp_ptr_type),
ALLOCATABLE :: DEPENDENT_PARAMETERS(:)
13767 TYPE(boundary_conditions_type),
POINTER :: BOUNDARY_CONDITIONS
13768 TYPE(boundary_conditions_variable_type),
POINTER :: DEPENDENT_BOUNDARY_CONDITIONS,RHS_BOUNDARY_CONDITIONS
13769 TYPE(distributed_matrix_type),
POINTER :: PREVIOUS_SOLVER_DISTRIBUTED_MATRIX,SOLVER_DISTRIBUTED_MATRIX
13770 TYPE(distributed_vector_type),
POINTER :: LAGRANGE_VECTOR,DEPENDENT_VECTOR,DISTRIBUTED_SOURCE_VECTOR,EQUATIONS_RHS_VECTOR, &
13771 & LINEAR_TEMP_VECTOR,INTERFACE_TEMP_VECTOR,RESIDUAL_VECTOR,SOLVER_RESIDUAL_VECTOR,SOLVER_RHS_VECTOR
13772 TYPE(domain_mapping_type),
POINTER :: RHS_DOMAIN_MAPPING,VARIABLE_DOMAIN_MAPPING
13773 TYPE(equations_jacobian_type),
POINTER :: JACOBIAN_MATRIX
13774 TYPE(equations_type),
POINTER :: EQUATIONS
13775 TYPE(equations_mapping_type),
POINTER :: EQUATIONS_MAPPING
13776 TYPE(equations_mapping_linear_type),
POINTER :: LINEAR_MAPPING
13777 TYPE(equations_mapping_nonlinear_type),
POINTER :: NONLINEAR_MAPPING
13778 TYPE(equations_mapping_rhs_type),
POINTER :: RHS_MAPPING
13779 TYPE(equations_mapping_source_type),
POINTER :: SOURCE_MAPPING
13780 TYPE(equations_matrices_type),
POINTER :: EQUATIONS_MATRICES
13781 TYPE(equations_matrices_linear_type),
POINTER :: LINEAR_MATRICES
13782 TYPE(equations_matrices_nonlinear_type),
POINTER :: NONLINEAR_MATRICES
13783 TYPE(equations_matrices_rhs_type),
POINTER :: RHS_VECTOR
13784 TYPE(equations_matrices_source_type),
POINTER :: SOURCE_VECTOR
13785 TYPE(equations_matrix_type),
POINTER :: EQUATIONS_MATRIX,LINEAR_MATRIX
13786 TYPE(equations_set_type),
POINTER :: EQUATIONS_SET
13787 TYPE(equations_to_solver_maps_type),
POINTER :: EQUATIONS_TO_SOLVER_MAP
13788 TYPE(field_type),
POINTER :: DEPENDENT_FIELD,LAGRANGE_FIELD
13789 TYPE(field_variable_type),
POINTER :: INTERFACE_VARIABLE,DEPENDENT_VARIABLE,LINEAR_VARIABLE,RHS_VARIABLE
13790 TYPE(interface_condition_type),
POINTER :: INTERFACE_CONDITION
13791 TYPE(interface_equations_type),
POINTER :: INTERFACE_EQUATIONS
13792 TYPE(interface_lagrange_type),
POINTER :: INTERFACE_LAGRANGE
13793 TYPE(interface_mapping_type),
POINTER :: INTERFACE_MAPPING
13794 TYPE(interface_mapping_rhs_type),
POINTER :: INTERFACE_RHS_MAPPING
13795 TYPE(interface_matrices_type),
POINTER :: INTERFACE_MATRICES
13796 TYPE(interface_matrix_type),
POINTER :: INTERFACE_MATRIX
13797 TYPE(interface_rhs_type),
POINTER :: INTERFACE_RHS_VECTOR
13798 TYPE(interface_to_solver_maps_type),
POINTER :: INTERFACE_TO_SOLVER_MAP
13799 TYPE(jacobian_to_solver_map_type),
POINTER :: JACOBIAN_TO_SOLVER_MAP
13800 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
13801 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
13802 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
13803 TYPE(solver_matrix_type),
POINTER :: SOLVER_MATRIX
13804 TYPE(varying_string) :: LOCAL_ERROR
13805 TYPE(boundary_conditions_sparsity_indices_type),
POINTER :: SPARSITY_INDICES
13807 enters(
"SOLVER_MATRICES_STATIC_ASSEMBLE",err,error,*999)
13809 IF(
ASSOCIATED(solver))
THEN 13810 solver_equations=>solver%SOLVER_EQUATIONS
13811 IF(
ASSOCIATED(solver_equations))
THEN 13812 solver_mapping=>solver_equations%SOLVER_MAPPING
13813 IF(
ASSOCIATED(solver_mapping))
THEN 13814 solver_matrices=>solver_equations%SOLVER_MATRICES
13815 IF(
ASSOCIATED(solver_matrices))
THEN 13817 NULLIFY(previous_solver_distributed_matrix)
13818 IF(selection_type==solver_matrices_all.OR. &
13819 & selection_type==solver_matrices_linear_only.OR. &
13820 & selection_type==solver_matrices_nonlinear_only.OR. &
13821 & selection_type==solver_matrices_jacobian_only)
THEN 13824 CALL cpu_timer(user_cpu,user_time1,err,error,*999)
13825 CALL cpu_timer(system_cpu,system_time1,err,error,*999)
13828 DO solver_matrix_idx=1,solver_mapping%NUMBER_OF_SOLVER_MATRICES
13829 solver_matrix=>solver_matrices%MATRICES(solver_matrix_idx)%PTR
13830 IF(
ASSOCIATED(solver_matrix))
THEN 13831 IF(solver_matrix%UPDATE_MATRIX)
THEN 13832 solver_distributed_matrix=>solver_matrix%MATRIX
13833 IF(
ASSOCIATED(solver_distributed_matrix))
THEN 13835 CALL distributed_matrix_all_values_set(solver_distributed_matrix,0.0_dp,err,error,*999)
13837 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
13839 DO equations_matrix_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
13840 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%NUMBER_OF_LINEAR_EQUATIONS_MATRICES
13841 equations_to_solver_map=>solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
13842 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%LINEAR_EQUATIONS_TO_SOLVER_MATRIX_MAPS( &
13843 & equations_matrix_idx)%PTR
13844 IF(
ASSOCIATED(equations_to_solver_map))
THEN 13845 equations_matrix=>equations_to_solver_map%EQUATIONS_MATRIX
13846 IF(
ASSOCIATED(equations_matrix))
THEN 13847 CALL solver_matrix_equations_matrix_add(solver_matrix,equations_set_idx,1.0_dp,equations_matrix, &
13850 CALL flagerror(
"The equations matrix is not associated.",err,error,*999)
13853 CALL flagerror(
"The equations matrix equations to solver map is not associated.",err,error,*999)
13856 IF(selection_type==solver_matrices_all.OR. &
13857 & selection_type==solver_matrices_nonlinear_only.OR. &
13858 & selection_type==solver_matrices_jacobian_only)
THEN 13860 DO equations_matrix_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
13861 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%NUMBER_OF_EQUATIONS_JACOBIANS
13862 jacobian_to_solver_map=>solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
13863 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%JACOBIAN_TO_SOLVER_MATRIX_MAPS( &
13864 & equations_matrix_idx)%PTR
13865 IF(
ASSOCIATED(jacobian_to_solver_map))
THEN 13866 jacobian_matrix=>jacobian_to_solver_map%JACOBIAN_MATRIX
13867 IF(
ASSOCIATED(jacobian_matrix))
THEN 13868 CALL solver_matrix_jacobian_matrix_add(solver_matrix,equations_set_idx,1.0_dp,jacobian_matrix, &
13871 CALL flagerror(
"Jacobian matrix is not associated.",err,error,*999)
13874 local_error=
"Jacobian to solver map is not associated for Jacobian number "// &
13875 & trim(numbertovstring(equations_matrix_idx,
"*",err,error))//
"." 13876 CALL flagerror(local_error,err,error,*999)
13882 DO interface_condition_idx=1,solver_mapping%NUMBER_OF_INTERFACE_CONDITIONS
13884 DO interface_matrix_idx=1,solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
13885 & interface_to_solver_matrix_maps_sm(solver_matrix_idx)%NUMBER_OF_INTERFACE_MATRICES
13886 interface_to_solver_map=>solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
13887 & interface_to_solver_matrix_maps_sm(solver_matrix_idx)%INTERFACE_EQUATIONS_TO_SOLVER_MATRIX_MAPS( &
13888 & interface_matrix_idx)%PTR
13889 IF(
ASSOCIATED(interface_to_solver_map))
THEN 13890 interface_matrix=>interface_to_solver_map%INTERFACE_MATRIX
13891 IF(
ASSOCIATED(interface_matrix))
THEN 13892 CALL solver_matrix_interface_matrix_add(solver_matrix,interface_condition_idx,(/1.0_dp,1.0_dp/), &
13893 & interface_matrix,err,error,*999)
13895 CALL flagerror(
"The interface matrix is not associated.",err,error,*999)
13898 CALL flagerror(
"The interface matrix interface to solver map is not associated.",err,error,*999)
13903 CALL distributed_matrix_update_start(solver_distributed_matrix,err,error,*999)
13904 IF(
ASSOCIATED(previous_solver_distributed_matrix))
THEN 13905 CALL distributed_matrix_update_finish(previous_solver_distributed_matrix,err,error,*999)
13907 previous_solver_distributed_matrix=>solver_distributed_matrix
13909 CALL flagerror(
"Solver matrix distributed matrix is not associated.",err,error,*999)
13913 CALL flagerror(
"Solver matrix is not associated.",err,error,*999)
13916 IF(
ASSOCIATED(previous_solver_distributed_matrix))
THEN 13917 CALL distributed_matrix_update_finish(previous_solver_distributed_matrix,err,error,*999)
13920 CALL cpu_timer(user_cpu,user_time2,err,error,*999)
13921 CALL cpu_timer(system_cpu,system_time2,err,error,*999)
13922 user_elapsed=user_time2(1)-user_time1(1)
13923 system_elapsed=system_time2(1)-system_time1(1)
13924 CALL write_string(general_output_type,
"",err,error,*999)
13925 CALL write_string_value(general_output_type,
"Total user time for solver matrices assembly = ",user_elapsed, &
13927 CALL write_string_value(general_output_type,
"Total System time for solver matrices assembly = ",system_elapsed, &
13932 NULLIFY(solver_residual_vector)
13933 IF(selection_type==solver_matrices_all.OR. &
13934 & selection_type==solver_matrices_nonlinear_only.OR. &
13935 & selection_type==solver_matrices_residual_only.OR. &
13936 & selection_type==solver_matrices_rhs_residual_only)
THEN 13942 CALL cpu_timer(user_cpu,user_time1,err,error,*999)
13943 CALL cpu_timer(system_cpu,system_time1,err,error,*999)
13945 IF(solver_matrices%UPDATE_RESIDUAL)
THEN 13946 solver_residual_vector=>solver_matrices%RESIDUAL
13947 IF(
ASSOCIATED(solver_residual_vector))
THEN 13949 CALL distributed_vector_all_values_set(solver_residual_vector,0.0_dp,err,error,*999)
13951 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
13952 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
13953 IF(
ASSOCIATED(equations_set))
THEN 13954 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
13955 IF(
ASSOCIATED(dependent_field))
THEN 13956 equations=>equations_set%EQUATIONS
13957 IF(
ASSOCIATED(equations))
THEN 13958 equations_matrices=>equations%EQUATIONS_MATRICES
13959 IF(
ASSOCIATED(equations_matrices))
THEN 13960 equations_mapping=>equations%EQUATIONS_MAPPING
13961 IF(
ASSOCIATED(equations_mapping))
THEN 13963 linear_mapping=>equations_mapping%LINEAR_MAPPING
13964 IF(
ASSOCIATED(linear_mapping))
THEN 13965 linear_matrices=>equations_matrices%LINEAR_MATRICES
13966 IF(
ASSOCIATED(linear_matrices))
THEN 13967 DO equations_matrix_idx=1,linear_matrices%NUMBER_OF_LINEAR_MATRICES
13968 linear_matrix=>linear_matrices%MATRICES(equations_matrix_idx)%PTR
13969 IF(
ASSOCIATED(linear_matrix))
THEN 13970 linear_variable_type=linear_mapping%EQUATIONS_MATRIX_TO_VAR_MAPS(equations_matrix_idx)% &
13972 linear_variable=>linear_mapping%EQUATIONS_MATRIX_TO_VAR_MAPS(equations_matrix_idx)% &
13974 IF(
ASSOCIATED(linear_variable))
THEN 13975 linear_temp_vector=>linear_matrix%TEMP_VECTOR
13977 CALL distributed_vector_all_values_set(linear_temp_vector,0.0_dp,err,error,*999)
13978 NULLIFY(dependent_vector)
13979 CALL field_parameter_set_vector_get(dependent_field,linear_variable_type, &
13980 & field_values_set_type,dependent_vector,err,error,*999)
13981 CALL distributed_matrix_by_vector_add(distributed_matrix_vector_no_ghosts_type,1.0_dp, &
13982 & linear_matrix%MATRIX,dependent_vector,linear_temp_vector,err,error,*999)
13984 CALL flagerror(
"Linear variable is not associated.",err,error,*999)
13987 local_error=
"Linear matrix is not associated for linear matrix number "// &
13988 & trim(numbertovstring(equations_matrix_idx,
"*",err,error))//
"." 13989 CALL flagerror(local_error,err,error,*999)
13993 CALL flagerror(
"Equations matrices linear matrices is not associated.",err,error,*999)
13997 nonlinear_mapping=>equations_mapping%NONLINEAR_MAPPING
13998 IF(
ASSOCIATED(nonlinear_mapping))
THEN 13999 nonlinear_matrices=>equations_matrices%NONLINEAR_MATRICES
14000 IF(
ASSOCIATED(nonlinear_matrices))
THEN 14001 residual_vector=>nonlinear_matrices%RESIDUAL
14003 DO equations_row_number=1,equations_mapping%TOTAL_NUMBER_OF_ROWS
14004 IF(solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
14005 & equations_row_to_solver_rows_maps(equations_row_number)% &
14006 & number_of_solver_rows>0)
THEN 14008 CALL distributed_vector_values_get(residual_vector,equations_row_number, &
14009 & residual_value,err,error,*999)
14011 IF(
ASSOCIATED(linear_mapping))
THEN 14012 linear_value_sum=0.0_dp
14013 DO equations_matrix_idx2=1,linear_matrices%NUMBER_OF_LINEAR_MATRICES
14014 linear_matrix=>linear_matrices%MATRICES(equations_matrix_idx2)%PTR
14015 linear_temp_vector=>linear_matrix%TEMP_VECTOR
14016 CALL distributed_vector_values_get(linear_temp_vector,equations_row_number, &
14017 & linear_value,err,error,*999)
14018 linear_value_sum=linear_value_sum+linear_value
14020 residual_value=residual_value+linear_value_sum
14023 DO solver_row_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
14024 & equations_row_to_solver_rows_maps(equations_row_number)%NUMBER_OF_SOLVER_ROWS
14025 solver_row_number=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
14026 & equations_row_to_solver_rows_maps(equations_row_number)%SOLVER_ROWS( &
14028 row_coupling_coefficient=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
14029 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS(equations_row_number)% &
14030 & coupling_coefficients(solver_row_idx)
14031 VALUE=residual_value*row_coupling_coefficient
14033 CALL distributed_vector_values_add(solver_residual_vector,solver_row_number,
VALUE, &
14039 CALL flagerror(
"Equations matrices nonlinear matrices is not associated.",err,error,*999)
14041 ELSE IF(
ASSOCIATED(linear_mapping))
THEN 14042 DO equations_row_number=1,equations_mapping%TOTAL_NUMBER_OF_ROWS
14043 IF(solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
14044 & equations_row_to_solver_rows_maps(equations_row_number)% &
14045 & number_of_solver_rows>0)
THEN 14046 linear_value_sum=0.0_dp
14047 DO equations_matrix_idx=1,linear_matrices%NUMBER_OF_LINEAR_MATRICES
14048 linear_matrix=>linear_matrices%MATRICES(equations_matrix_idx)%PTR
14049 linear_temp_vector=>linear_matrix%TEMP_VECTOR
14050 CALL distributed_vector_values_get(linear_temp_vector,equations_row_number, &
14051 & linear_value,err,error,*999)
14052 linear_value_sum=linear_value_sum+linear_value
14054 residual_value=linear_value_sum
14056 DO solver_row_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
14057 & equations_row_to_solver_rows_maps(equations_row_number)%NUMBER_OF_SOLVER_ROWS
14058 solver_row_number=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
14059 & equations_row_to_solver_rows_maps(equations_row_number)%SOLVER_ROWS( &
14061 row_coupling_coefficient=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
14062 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS(equations_row_number)% &
14063 & coupling_coefficients(solver_row_idx)
14064 VALUE=residual_value*row_coupling_coefficient
14066 CALL distributed_vector_values_add(solver_residual_vector,solver_row_number,
VALUE, &
14073 CALL flagerror(
"Equations equations mapping is not associated.",err,error,*999)
14076 CALL flagerror(
"Equations equations matrices is not associated.",err,error,*999)
14079 CALL flagerror(
"Equations set equations is not associated.",err,error,*999)
14082 CALL flagerror(
"Equations set dependent field is not associated.",err,error,*999)
14085 CALL flagerror(
"Equations set is not associated.",err,error,*999)
14089 DO interface_condition_idx=1,solver_mapping%NUMBER_OF_INTERFACE_CONDITIONS
14090 interface_condition=>solver_mapping%INTERFACE_CONDITIONS(interface_condition_idx)%PTR
14091 IF(
ASSOCIATED(interface_condition))
THEN 14092 lagrange_field=>interface_condition%LAGRANGE%LAGRANGE_FIELD
14093 IF(
ASSOCIATED(lagrange_field))
THEN 14094 interface_equations=>interface_condition%INTERFACE_EQUATIONS
14095 IF(
ASSOCIATED(interface_equations))
THEN 14096 interface_matrices=>interface_equations%INTERFACE_MATRICES
14097 IF(
ASSOCIATED(interface_matrices))
THEN 14098 interface_mapping=>interface_equations%INTERFACE_MAPPING
14099 IF(
ASSOCIATED(interface_mapping))
THEN 14100 SELECT CASE(interface_condition%METHOD)
14101 CASE(interface_condition_lagrange_multipliers_method)
14102 number_of_interface_matrices=interface_mapping%NUMBER_OF_INTERFACE_MATRICES
14103 CASE(interface_condition_penalty_method)
14104 number_of_interface_matrices=interface_mapping%NUMBER_OF_INTERFACE_MATRICES-1
14107 DO interface_matrix_idx=1,number_of_interface_matrices
14109 interface_matrix=>interface_matrices%MATRICES(interface_matrix_idx)%PTR
14110 IF(
ASSOCIATED(interface_matrix))
THEN 14111 interface_variable_type=interface_mapping%LAGRANGE_VARIABLE_TYPE
14112 interface_variable=>interface_mapping%LAGRANGE_VARIABLE
14113 IF(
ASSOCIATED(interface_variable))
THEN 14114 interface_temp_vector=>interface_matrix%TEMP_VECTOR
14116 CALL distributed_vector_all_values_set(interface_temp_vector,0.0_dp,err,error,*999)
14117 NULLIFY(lagrange_vector)
14118 CALL field_parameter_set_vector_get(lagrange_field,interface_variable_type, &
14119 & field_values_set_type,lagrange_vector,err,error,*999)
14120 CALL distributed_matrix_by_vector_add(distributed_matrix_vector_no_ghosts_type,1.0_dp, &
14121 & interface_matrix%MATRIX,lagrange_vector,interface_temp_vector,err,error,*999)
14123 DO interface_row_number=1,interface_matrix%NUMBER_OF_ROWS
14124 IF(solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
14125 & interface_to_solver_matrix_maps_im(interface_matrix_idx)% &
14126 & interface_row_to_solver_rows_map(interface_row_number)%NUMBER_OF_SOLVER_ROWS>0)
THEN 14129 solver_row_number=solver_mapping% &
14130 & interface_condition_to_solver_map(interface_condition_idx)% &
14131 & interface_to_solver_matrix_maps_im(interface_matrix_idx)% &
14132 & interface_row_to_solver_rows_map(interface_row_number)%SOLVER_ROW
14133 row_coupling_coefficient=solver_mapping% &
14134 & interface_condition_to_solver_map(interface_condition_idx)% &
14135 & interface_to_solver_matrix_maps_im(interface_matrix_idx)% &
14136 & interface_row_to_solver_rows_map(interface_row_number)%COUPLING_COEFFICIENT
14137 CALL distributed_vector_values_get(interface_temp_vector,interface_row_number, &
14138 & residual_value,err,error,*999)
14139 VALUE=residual_value*row_coupling_coefficient
14141 CALL distributed_vector_values_add(solver_residual_vector,solver_row_number,
VALUE, &
14146 CALL flagerror(
"Interface variable is not associated.",err,error,*999)
14149 dependent_variable_type=interface_mapping% &
14150 & interface_matrix_rows_to_var_maps(interface_matrix_idx)%VARIABLE_TYPE
14151 dependent_variable=>interface_mapping% &
14152 & interface_matrix_rows_to_var_maps(interface_matrix_idx)%VARIABLE
14153 IF(
ASSOCIATED(dependent_variable))
THEN 14154 interface_temp_vector=>interface_matrix%TEMP_TRANSPOSE_VECTOR
14156 CALL distributed_vector_all_values_set(interface_temp_vector,0.0_dp,err,error,*999)
14157 NULLIFY(dependent_vector)
14158 dependent_field=>dependent_variable%FIELD
14159 CALL field_parameter_set_vector_get(dependent_field,dependent_variable_type, &
14160 & field_values_set_type,dependent_vector,err,error,*999)
14161 CALL distributed_matrix_by_vector_add(distributed_matrix_vector_no_ghosts_type,1.0_dp, &
14162 & interface_matrix%MATRIX_TRANSPOSE,dependent_vector,interface_temp_vector,err,error,*999)
14165 DO interface_row_number=1,interface_matrices%NUMBER_OF_COLUMNS
14166 IF(solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
14167 & interface_column_to_solver_rows_maps(interface_row_number)%NUMBER_OF_SOLVER_ROWS>0)
THEN 14170 solver_row_number=solver_mapping% &
14171 & interface_condition_to_solver_map(interface_condition_idx)% &
14172 & interface_column_to_solver_rows_maps(interface_row_number)%SOLVER_ROW
14173 row_coupling_coefficient=solver_mapping% &
14174 & interface_condition_to_solver_map(interface_condition_idx)% &
14175 & interface_column_to_solver_rows_maps(interface_row_number)%COUPLING_COEFFICIENT
14176 CALL distributed_vector_values_get(interface_temp_vector,interface_row_number, &
14177 & residual_value,err,error,*999)
14178 VALUE=residual_value*row_coupling_coefficient
14180 CALL distributed_vector_values_add(solver_residual_vector,solver_row_number,
VALUE, &
14185 CALL flagerror(
"Dependent variable is not associated.",err,error,*999)
14188 local_error=
"Interface matrix is not associated for linear matrix number "// &
14189 & trim(numbertovstring(equations_matrix_idx,
"*",err,error))//
"." 14190 CALL flagerror(local_error,err,error,*999)
14193 SELECT CASE(interface_condition%METHOD)
14194 CASE(interface_condition_penalty_method)
14195 interface_matrix_idx=interface_mapping%NUMBER_OF_INTERFACE_MATRICES
14197 interface_matrix=>interface_matrices%MATRICES(interface_matrix_idx)%PTR
14198 IF(
ASSOCIATED(interface_matrix))
THEN 14199 interface_variable_type=interface_mapping%LAGRANGE_VARIABLE_TYPE
14200 interface_variable=>interface_mapping%LAGRANGE_VARIABLE
14201 IF(
ASSOCIATED(interface_variable))
THEN 14202 interface_temp_vector=>interface_matrix%TEMP_VECTOR
14204 CALL distributed_vector_all_values_set(interface_temp_vector,0.0_dp,err,error,*999)
14205 NULLIFY(lagrange_vector)
14206 CALL field_parameter_set_vector_get(lagrange_field,interface_variable_type, &
14207 & field_values_set_type,lagrange_vector,err,error,*999)
14208 CALL distributed_matrix_by_vector_add(distributed_matrix_vector_no_ghosts_type,1.0_dp, &
14209 & interface_matrix%MATRIX,lagrange_vector,interface_temp_vector,err,error,*999)
14211 DO interface_row_number=1,interface_matrix%NUMBER_OF_ROWS
14212 IF(solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
14213 & interface_to_solver_matrix_maps_im(interface_matrix_idx)% &
14214 & interface_row_to_solver_rows_map(interface_row_number)%NUMBER_OF_SOLVER_ROWS>0)
THEN 14217 solver_row_number=solver_mapping% &
14218 & interface_condition_to_solver_map(interface_condition_idx)% &
14219 & interface_to_solver_matrix_maps_im(interface_matrix_idx)% &
14220 & interface_row_to_solver_rows_map(interface_row_number)%SOLVER_ROW
14221 row_coupling_coefficient=solver_mapping% &
14222 & interface_condition_to_solver_map(interface_condition_idx)% &
14223 & interface_to_solver_matrix_maps_im(interface_matrix_idx)% &
14224 & interface_row_to_solver_rows_map(interface_row_number)%COUPLING_COEFFICIENT
14225 CALL distributed_vector_values_get(interface_temp_vector,interface_row_number, &
14226 & residual_value,err,error,*999)
14227 VALUE=residual_value*row_coupling_coefficient
14229 CALL distributed_vector_values_add(solver_residual_vector,solver_row_number,
VALUE, &
14234 CALL flagerror(
"Interface variable is not associated.",err,error,*999)
14237 local_error=
"Interface matrix is not associated for linear matrix number "// &
14238 & trim(numbertovstring(equations_matrix_idx,
"*",err,error))//
"." 14239 CALL flagerror(local_error,err,error,*999)
14243 CALL flagerror(
"Interface mapping is not associated.",err,error,*999)
14246 CALL flagerror(
"Interface matrices is not associated.",err,error,*999)
14249 CALL flagerror(
"Interface equations is not associated.",err,error,*999)
14252 CALL flagerror(
"Interface Lagrange field is not associated.",err,error,*999)
14255 CALL flagerror(
"Interface condition is not associated.",err,error,*999)
14259 CALL distributed_vector_update_start(solver_residual_vector,err,error,*999)
14261 CALL flagerror(
"The solver residual vector is not associated.",err,error,*999)
14264 IF(
ASSOCIATED(solver_residual_vector))
THEN 14265 CALL distributed_vector_update_finish(solver_residual_vector,err,error,*999)
14268 CALL cpu_timer(user_cpu,user_time2,err,error,*999)
14269 CALL cpu_timer(system_cpu,system_time2,err,error,*999)
14270 user_elapsed=user_time2(1)-user_time1(1)
14271 system_elapsed=system_time2(1)-system_time1(1)
14272 CALL write_string(general_output_type,
"",err,error,*999)
14273 CALL write_string_value(general_output_type,
"Total user time for solver residual assembly = ",user_elapsed, &
14275 CALL write_string_value(general_output_type,
"Total System time for solver residual assembly = ",system_elapsed, &
14279 NULLIFY(solver_rhs_vector)
14280 IF(selection_type==solver_matrices_all.OR. &
14281 & selection_type==solver_matrices_linear_only.OR. &
14282 & selection_type==solver_matrices_nonlinear_only.OR. &
14283 & selection_type==solver_matrices_rhs_only.OR. &
14284 & selection_type==solver_matrices_rhs_residual_only)
THEN 14287 CALL cpu_timer(user_cpu,user_time1,err,error,*999)
14288 CALL cpu_timer(system_cpu,system_time1,err,error,*999)
14290 IF(solver_matrices%UPDATE_RHS_VECTOR)
THEN 14291 solver_rhs_vector=>solver_matrices%RHS_VECTOR
14292 IF(
ASSOCIATED(solver_rhs_vector))
THEN 14294 CALL distributed_vector_all_values_set(solver_rhs_vector,0.0_dp,err,error,*999)
14295 NULLIFY(check_data)
14296 CALL distributed_vector_data_get(solver_rhs_vector,check_data,err,error,*999)
14297 subtract_fixed_bcs_from_residual=.false.
14298 IF(selection_type==solver_matrices_all.OR. &
14299 & selection_type==solver_matrices_nonlinear_only.OR. &
14300 & selection_type==solver_matrices_rhs_residual_only)
THEN 14301 IF(solver_matrices%UPDATE_RESIDUAL)
THEN 14302 IF(
ASSOCIATED(solver_residual_vector))
THEN 14303 subtract_fixed_bcs_from_residual=.true.
14305 CALL flagerror(
"The solver residual vector is not associated.",err,error,*999)
14310 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
14311 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
14312 IF(
ASSOCIATED(equations_set))
THEN 14313 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
14314 IF(
ASSOCIATED(dependent_field))
THEN 14315 equations=>equations_set%EQUATIONS
14316 IF(
ASSOCIATED(equations))
THEN 14317 equations_matrices=>equations%EQUATIONS_MATRICES
14318 IF(
ASSOCIATED(equations_matrices))
THEN 14319 equations_mapping=>equations%EQUATIONS_MAPPING
14320 IF(
ASSOCIATED(equations_mapping))
THEN 14321 source_mapping=>equations_mapping%SOURCE_MAPPING
14322 IF(
ASSOCIATED(source_mapping))
THEN 14323 source_vector=>equations_matrices%SOURCE_VECTOR
14324 IF(
ASSOCIATED(source_vector))
THEN 14325 distributed_source_vector=>source_vector%VECTOR
14327 CALL flagerror(
"Source vector vector is not associated.",err,error,*999)
14330 rhs_mapping=>equations_mapping%RHS_MAPPING
14331 IF(
ASSOCIATED(rhs_mapping))
THEN 14332 NULLIFY(rhs_parameters)
14333 rhs_variable_type=rhs_mapping%RHS_VARIABLE_TYPE
14334 CALL field_parameter_set_data_get(dependent_field,rhs_variable_type,field_values_set_type, &
14335 & rhs_parameters,err,error,*999)
14336 NULLIFY(check_data)
14337 CALL distributed_vector_data_get(solver_rhs_vector,check_data,err,error,*999)
14338 rhs_vector=>equations_matrices%RHS_VECTOR
14339 IF(
ASSOCIATED(rhs_vector))
THEN 14340 linear_mapping=>equations_mapping%LINEAR_MAPPING
14341 nonlinear_mapping=>equations_mapping%NONLINEAR_MAPPING
14342 IF(
ASSOCIATED(linear_mapping))
THEN 14343 linear_matrices=>equations_matrices%LINEAR_MATRICES
14344 IF(
ASSOCIATED(linear_matrices))
THEN 14345 ALLOCATE(dependent_parameters(linear_mapping%NUMBER_OF_LINEAR_MATRIX_VARIABLES),stat=err)
14346 IF(err/=0)
CALL flagerror(
"Could not allocate dependent_parameters.",err,error,*999)
14347 DO variable_idx=1,linear_mapping%NUMBER_OF_LINEAR_MATRIX_VARIABLES
14348 variable_type=linear_mapping%LINEAR_MATRIX_VARIABLE_TYPES(variable_idx)
14349 NULLIFY(dependent_parameters(variable_idx)%PTR)
14350 CALL field_parameter_set_data_get(dependent_field,variable_type,field_values_set_type, &
14351 & dependent_parameters(variable_idx)%PTR,err,error,*999)
14354 CALL flagerror(
"Equations matrices linear matrices is not associated.",err,error,*999)
14357 boundary_conditions=>solver_equations%BOUNDARY_CONDITIONS
14358 IF(
ASSOCIATED(boundary_conditions))
THEN 14360 rhs_variable=>rhs_mapping%RHS_VARIABLE
14361 rhs_variable_type=rhs_variable%VARIABLE_TYPE
14362 rhs_domain_mapping=>rhs_variable%DOMAIN_MAPPING
14364 CALL field_parameter_set_created(rhs_variable%FIELD,rhs_variable_type, &
14365 & field_integrated_neumann_set_type,has_integrated_values,err,error,*999)
14366 equations_rhs_vector=>rhs_vector%VECTOR
14367 CALL boundary_conditions_variable_get(boundary_conditions,rhs_variable, &
14368 & rhs_boundary_conditions,err,error,*999)
14369 IF(
ASSOCIATED(rhs_boundary_conditions))
THEN 14371 CALL boundaryconditions_neumannintegrate(rhs_boundary_conditions, &
14374 DO equations_row_number=1,equations_mapping%TOTAL_NUMBER_OF_ROWS
14376 IF(
ASSOCIATED(source_mapping))
THEN 14378 CALL distributed_vector_values_get(distributed_source_vector,equations_row_number, &
14379 & source_value,err,error,*999)
14381 DO solver_row_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
14382 & equations_row_to_solver_rows_maps(equations_row_number)%NUMBER_OF_SOLVER_ROWS
14384 solver_row_number=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
14385 & equations_row_to_solver_rows_maps(equations_row_number)%SOLVER_ROWS( &
14388 row_coupling_coefficient=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
14389 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS(equations_row_number)% &
14390 & coupling_coefficients(solver_row_idx)
14391 VALUE=1.0_dp*source_value*row_coupling_coefficient
14393 CALL distributed_vector_values_add(solver_rhs_vector,solver_row_number,
VALUE, &
14397 rhs_variable_dof=rhs_mapping%EQUATIONS_ROW_TO_RHS_DOF_MAP(equations_row_number)
14398 rhs_global_dof=rhs_domain_mapping%LOCAL_TO_GLOBAL_MAP(rhs_variable_dof)
14399 rhs_boundary_condition=rhs_boundary_conditions%DOF_TYPES(rhs_global_dof)
14401 SELECT CASE(rhs_boundary_condition)
14402 CASE(boundary_condition_dof_free)
14404 CALL distributed_vector_values_get(equations_rhs_vector,equations_row_number, &
14405 & rhs_value,err,error,*999)
14406 IF(has_integrated_values)
THEN 14408 CALL field_parameter_set_get_local_dof(rhs_variable%FIELD,rhs_variable_type, &
14409 & field_integrated_neumann_set_type,rhs_variable_dof,rhs_integrated_value, &
14411 rhs_value=rhs_value+rhs_integrated_value
14414 DO solver_row_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
14415 & equations_row_to_solver_rows_maps(equations_row_number)%NUMBER_OF_SOLVER_ROWS
14416 solver_row_number=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
14417 & equations_row_to_solver_rows_maps(equations_row_number)%SOLVER_ROWS( &
14419 row_coupling_coefficient=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
14420 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS(equations_row_number)% &
14421 & coupling_coefficients(solver_row_idx)
14422 VALUE=rhs_value*row_coupling_coefficient
14423 CALL distributed_vector_values_add(solver_rhs_vector,solver_row_number,
VALUE, &
14427 IF(
ASSOCIATED(linear_mapping).AND..NOT.
ASSOCIATED(nonlinear_mapping))
THEN 14429 DO variable_idx=1,linear_mapping%NUMBER_OF_LINEAR_MATRIX_VARIABLES
14430 variable_type=linear_mapping%LINEAR_MATRIX_VARIABLE_TYPES(variable_idx)
14431 dependent_variable=>linear_mapping%VAR_TO_EQUATIONS_MATRICES_MAPS( &
14432 & variable_type)%VARIABLE
14433 dependent_variable_type=dependent_variable%VARIABLE_TYPE
14434 variable_domain_mapping=>dependent_variable%DOMAIN_MAPPING
14435 CALL boundary_conditions_variable_get(boundary_conditions,dependent_variable, &
14436 & dependent_boundary_conditions,err,error,*999)
14437 variable_dof=linear_mapping%EQUATIONS_ROW_TO_VARIABLE_DOF_MAPS( &
14438 & equations_row_number,variable_idx)
14439 variable_global_dof=variable_domain_mapping%LOCAL_TO_GLOBAL_MAP(variable_dof)
14440 variable_boundary_condition=dependent_boundary_conditions%DOF_TYPES( &
14441 & variable_global_dof)
14442 IF(variable_boundary_condition==boundary_condition_dof_fixed)
THEN 14443 dependent_value=dependent_parameters(variable_idx)%PTR(variable_dof)
14444 IF(abs(dependent_value)>=zero_tolerance)
THEN 14445 DO equations_matrix_idx=1,linear_mapping%VAR_TO_EQUATIONS_MATRICES_MAPS( &
14446 & variable_type)%NUMBER_OF_EQUATIONS_MATRICES
14447 equations_matrix_number=linear_mapping%VAR_TO_EQUATIONS_MATRICES_MAPS( &
14448 & variable_type)%EQUATIONS_MATRIX_NUMBERS(equations_matrix_idx)
14449 equations_matrix=>linear_matrices%MATRICES(equations_matrix_number)%PTR
14450 equations_column_number=linear_mapping%VAR_TO_EQUATIONS_MATRICES_MAPS( &
14451 & variable_type)%DOF_TO_COLUMNS_MAPS(equations_matrix_idx)%COLUMN_DOF( &
14453 IF(
ASSOCIATED(dependent_boundary_conditions%DIRICHLET_BOUNDARY_CONDITIONS))
THEN 14454 IF(dependent_boundary_conditions%NUMBER_OF_DIRICHLET_CONDITIONS>0)
THEN 14455 DO dirichlet_idx=1,dependent_boundary_conditions% &
14456 & number_of_dirichlet_conditions
14457 IF(dependent_boundary_conditions%DIRICHLET_BOUNDARY_CONDITIONS% &
14458 & dirichlet_dof_indices(dirichlet_idx)==equations_column_number)
EXIT 14460 SELECT CASE(equations_matrix%STORAGE_TYPE)
14461 CASE(distributed_matrix_block_storage_type)
14462 DO dirichlet_row=1,equations_matrices%TOTAL_NUMBER_OF_ROWS
14463 CALL distributed_matrix_values_get(equations_matrix%MATRIX, &
14464 & dirichlet_row,equations_column_number,matrix_value,err,error,*999)
14465 IF(abs(matrix_value)>=zero_tolerance)
THEN 14466 DO solver_row_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
14467 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS( &
14468 & dirichlet_row)%NUMBER_OF_SOLVER_ROWS
14469 solver_row_number=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
14470 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS( &
14471 & dirichlet_row)%SOLVER_ROWS(solver_row_idx)
14472 row_coupling_coefficient=solver_mapping% &
14473 & equations_set_to_solver_map(equations_set_idx)% &
14474 & equations_row_to_solver_rows_maps(dirichlet_row)% &
14475 & coupling_coefficients(solver_row_idx)
14476 VALUE=-1.0_dp*matrix_value*dependent_value*row_coupling_coefficient
14477 CALL distributed_vector_values_add(solver_rhs_vector, &
14478 & solver_row_number,
VALUE,err,error,*999)
14479 IF(subtract_fixed_bcs_from_residual)
THEN 14480 CALL distributed_vector_values_add(solver_residual_vector, &
14481 & solver_row_number,
VALUE,err,error,*999)
14486 CASE(distributed_matrix_diagonal_storage_type)
14487 dirichlet_row=equations_column_number
14488 CALL distributed_matrix_values_get(equations_matrix%MATRIX, &
14489 & dirichlet_row,equations_column_number,matrix_value,err,error,*999)
14490 IF(abs(matrix_value)>=zero_tolerance)
THEN 14491 DO solver_row_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
14492 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS( &
14493 & dirichlet_row)%NUMBER_OF_SOLVER_ROWS
14494 solver_row_number=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
14495 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS( &
14496 & dirichlet_row)%SOLVER_ROWS(solver_row_idx)
14497 row_coupling_coefficient=solver_mapping% &
14498 & equations_set_to_solver_map(equations_set_idx)% &
14499 & equations_row_to_solver_rows_maps(dirichlet_row)% &
14500 & coupling_coefficients(solver_row_idx)
14501 VALUE=-1.0_dp*matrix_value*dependent_value*row_coupling_coefficient
14502 CALL distributed_vector_values_add(solver_rhs_vector, &
14503 & solver_row_number,
VALUE,err,error,*999)
14504 IF(subtract_fixed_bcs_from_residual)
THEN 14505 CALL distributed_vector_values_add(solver_residual_vector, &
14506 & solver_row_number,
VALUE,err,error,*999)
14510 CASE(distributed_matrix_column_major_storage_type)
14511 CALL flagerror(
"Not implemented.",err,error,*999)
14512 CASE(distributed_matrix_row_major_storage_type)
14513 CALL flagerror(
"Not implemented.",err,error,*999)
14514 CASE(distributed_matrix_compressed_row_storage_type)
14515 sparsity_indices=>dependent_boundary_conditions% &
14516 & dirichlet_boundary_conditions%LINEAR_SPARSITY_INDICES( &
14517 & equations_set_idx,equations_matrix_idx)%PTR
14518 IF(
ASSOCIATED(sparsity_indices))
THEN 14519 DO equations_row_number2=sparsity_indices%SPARSE_COLUMN_INDICES( &
14520 & dirichlet_idx),sparsity_indices%SPARSE_COLUMN_INDICES( &
14521 & dirichlet_idx+1)-1
14522 dirichlet_row=sparsity_indices%SPARSE_ROW_INDICES( &
14523 & equations_row_number2)
14524 CALL distributed_matrix_values_get(equations_matrix%MATRIX, &
14525 & dirichlet_row,equations_column_number,matrix_value,err,error,*999)
14526 IF(abs(matrix_value)>=zero_tolerance)
THEN 14527 DO solver_row_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
14528 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS( &
14529 & dirichlet_row)%NUMBER_OF_SOLVER_ROWS
14530 solver_row_number=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
14531 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS( &
14532 & dirichlet_row)%SOLVER_ROWS(solver_row_idx)
14533 row_coupling_coefficient=solver_mapping% &
14534 & equations_set_to_solver_map(equations_set_idx)% &
14535 & equations_row_to_solver_rows_maps(dirichlet_row)% &
14536 & coupling_coefficients(solver_row_idx)
14537 VALUE=-1.0_dp*matrix_value*dependent_value* &
14538 & row_coupling_coefficient
14539 CALL distributed_vector_values_add(solver_rhs_vector, &
14540 & solver_row_number,
VALUE,err,error,*999)
14541 IF(subtract_fixed_bcs_from_residual)
THEN 14542 CALL distributed_vector_values_add(solver_residual_vector, &
14543 & solver_row_number,
VALUE,err,error,*999)
14549 CALL flagerror(
"Sparsity indices are not associated.",err,error,*999)
14551 CASE(distributed_matrix_compressed_column_storage_type)
14552 CALL flagerror(
"Not implemented.",err,error,*999)
14553 CASE(distributed_matrix_row_column_storage_type)
14554 CALL flagerror(
"Not implemented.",err,error,*999)
14556 local_error=
"The storage type of "// &
14557 & trim(numbertovstring(equations_matrix%STORAGE_TYPE,
"*", &
14558 & err,error))//
" is invalid." 14559 CALL flagerror(local_error,err,error,*999)
14563 CALL flagerror(
"Dirichlet boundary conditions is not associated.",err, &
14571 CASE(boundary_condition_dof_fixed)
14572 rhs_value=rhs_parameters(rhs_variable_dof)
14574 IF(has_integrated_values)
THEN 14575 CALL field_parameter_set_get_local_dof(rhs_variable%FIELD,rhs_variable_type, &
14576 & field_integrated_neumann_set_type,rhs_variable_dof,rhs_integrated_value, &
14578 rhs_value=rhs_value+rhs_integrated_value
14580 IF(abs(rhs_value)>=zero_tolerance)
THEN 14582 DO solver_row_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
14583 & equations_row_to_solver_rows_maps(equations_row_number)%NUMBER_OF_SOLVER_ROWS
14584 solver_row_number=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
14585 & equations_row_to_solver_rows_maps(equations_row_number)%SOLVER_ROWS( &
14587 row_coupling_coefficient=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP( &
14588 & equations_set_idx)%EQUATIONS_ROW_TO_SOLVER_ROWS_MAPS(equations_row_number)% &
14589 & coupling_coefficients(solver_row_idx)
14592 VALUE=rhs_value*row_coupling_coefficient
14593 CALL distributed_vector_values_add(solver_rhs_vector,solver_row_number,
VALUE, &
14597 CASE(boundary_condition_dof_mixed)
14599 CALL flagerror(
"Not implemented.",err,error,*999)
14601 local_error=
"The RHS boundary condition of "// &
14602 & trim(numbertovstring(rhs_boundary_condition,
"*",err,error))// &
14603 &
" for RHS variable dof number "// &
14604 & trim(numbertovstring(rhs_variable_dof,
"*",err,error))//
" is invalid." 14605 CALL flagerror(local_error,err,error,*999)
14608 IF(
ASSOCIATED(solver_residual_vector))
THEN 14609 CALL distributed_vector_update_start(solver_residual_vector,err,error,*999)
14610 CALL distributed_vector_update_finish(solver_residual_vector,err,error,*999)
14612 NULLIFY(check_data2)
14613 CALL distributed_vector_data_get(equations_rhs_vector,check_data2,err,error,*999)
14614 NULLIFY(check_data3)
14615 CALL distributed_vector_data_get(solver_rhs_vector,check_data3,err,error,*999)
14616 NULLIFY(check_data4)
14617 CALL distributed_vector_data_get(solver_rhs_vector,check_data4,err,error,*999)
14619 CALL flagerror(
"RHS boundary conditions variable is not associated.",err,error,*999)
14622 CALL flagerror(
"Equations set boundary conditions is not associated.",err,error,*999)
14624 IF(
ASSOCIATED(linear_mapping))
THEN 14625 DO variable_idx=1,linear_mapping%NUMBER_OF_LINEAR_MATRIX_VARIABLES
14626 variable_type=linear_mapping%LINEAR_MATRIX_VARIABLE_TYPES(variable_idx)
14627 CALL field_parameter_set_data_restore(dependent_field,variable_type,field_values_set_type, &
14628 & dependent_parameters(variable_idx)%PTR,err,error,*999)
14630 IF(
ALLOCATED(dependent_parameters))
DEALLOCATE(dependent_parameters)
14633 CALL flagerror(
"Equations matrices RHS vector is not associated.",err,error,*999)
14635 CALL field_parameter_set_data_restore(dependent_field,rhs_variable_type,field_values_set_type, &
14636 & rhs_parameters,err,error,*999)
14638 CALL flagerror(
"Equations mapping RHS mapping is not associated.",err,error,*999)
14641 CALL flagerror(
"Equations equations mapping is not associated.",err,error,*999)
14644 CALL flagerror(
"Equations equations matrices is not associated.",err,error,*999)
14647 CALL flagerror(
"Equations set equations is not associated.",err,error,*999)
14650 CALL flagerror(
"Equations set is not associated.",err,error,*999)
14655 DO interface_condition_idx=1,solver_mapping%NUMBER_OF_INTERFACE_CONDITIONS
14656 interface_condition=>solver_mapping%INTERFACE_CONDITIONS(interface_condition_idx)%PTR
14657 IF(
ASSOCIATED(interface_condition))
THEN 14658 SELECT CASE(interface_condition%METHOD)
14659 CASE(interface_condition_lagrange_multipliers_method,interface_condition_penalty_method)
14660 interface_equations=>interface_condition%INTERFACE_EQUATIONS
14661 IF(
ASSOCIATED(interface_equations))
THEN 14662 interface_mapping=>interface_equations%INTERFACE_MAPPING
14663 IF(
ASSOCIATED(interface_mapping))
THEN 14664 interface_lagrange=>interface_condition%LAGRANGE
14665 IF(
ASSOCIATED(interface_lagrange))
THEN 14666 lagrange_field=>interface_lagrange%LAGRANGE_FIELD
14667 IF(
ASSOCIATED(lagrange_field))
THEN 14668 interface_rhs_mapping=>interface_mapping%RHS_MAPPING
14669 IF(
ASSOCIATED(interface_rhs_mapping))
THEN 14670 interface_matrices=>interface_equations%INTERFACE_MATRICES
14671 IF(
ASSOCIATED(interface_matrices))
THEN 14672 interface_rhs_vector=>interface_matrices%RHS_VECTOR
14673 IF(
ASSOCIATED(interface_rhs_vector))
THEN 14675 DO interface_column_number=1,interface_mapping%TOTAL_NUMBER_OF_COLUMNS
14676 CALL distributed_vector_values_get(interface_rhs_vector%RHS_VECTOR, &
14677 & interface_column_number,rhs_value,err,error,*999)
14679 DO solver_row_idx=1,solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP( &
14680 & interface_condition_idx)%INTERFACE_COLUMN_TO_SOLVER_ROWS_MAPS( &
14681 & interface_column_number)%NUMBER_OF_SOLVER_ROWS
14682 solver_row_number=solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP( &
14683 & interface_condition_idx)%INTERFACE_COLUMN_TO_SOLVER_ROWS_MAPS( &
14684 & interface_column_number)%SOLVER_ROW
14685 row_coupling_coefficient=solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP( &
14686 & interface_condition_idx)%INTERFACE_COLUMN_TO_SOLVER_ROWS_MAPS( &
14687 & interface_column_number)%COUPLING_COEFFICIENT
14688 VALUE=rhs_value*row_coupling_coefficient
14689 CALL distributed_vector_values_add(solver_rhs_vector,solver_row_number,
VALUE, &
14694 CALL flagerror(
"Interface matrices RHS vector is not associated.",err,error,*999)
14697 CALL flagerror(
"Interface equations interface matrices is not associated.",err,error,*999)
14700 CALL flagerror(
"Interface mapping RHS mapping is not associated.",err,error,*999)
14703 CALL flagerror(
"Interface Lagrange field is not associated.",err,error,*999)
14706 CALL flagerror(
"Interface Lagrange is not associated.",err,error,*999)
14709 CALL flagerror(
"Interface equations interface mapping is not associated.",err,error,*999)
14712 CALL flagerror(
"Interface condition equations is not associated.",err,error,*999)
14714 CASE(interface_condition_augmented_lagrange_method)
14715 CALL flagerror(
"Not implemented.",err,error,*999)
14716 CASE(interface_condition_point_to_point_method)
14717 CALL flagerror(
"Not implemented.",err,error,*999)
14719 local_error=
"The interface condition method of "// &
14720 & trim(numbertovstring(interface_condition%METHOD,
"*",err,error))// &
14722 CALL flagerror(local_error,err,error,*999)
14725 CALL flagerror(
"Interface condition is not associated.",err,error,*999)
14729 CALL distributed_vector_update_start(solver_rhs_vector,err,error,*999)
14730 NULLIFY(check_data)
14731 CALL distributed_vector_data_get(solver_rhs_vector,check_data,err,error,*999)
14733 CALL flagerror(
"The solver RHS vector is not associated.",err,error,*999)
14737 CALL cpu_timer(user_cpu,user_time2,err,error,*999)
14738 CALL cpu_timer(system_cpu,system_time2,err,error,*999)
14739 user_elapsed=user_time2(1)-user_time1(1)
14740 system_elapsed=system_time2(1)-system_time1(1)
14741 CALL write_string(general_output_type,
"",err,error,*999)
14742 CALL write_string_value(general_output_type,
"Total user time for solver RHS assembly = ",user_elapsed, &
14744 CALL write_string_value(general_output_type,
"Total System time for solver RHS assembly = ",system_elapsed, &
14748 IF(
ASSOCIATED(solver_rhs_vector))
THEN 14749 CALL distributed_vector_update_finish(solver_rhs_vector,err,error,*999)
14753 CALL solver_matrices_output(general_output_type,selection_type,solver_matrices,err,error,*999)
14756 CALL flagerror(
"Solver solver matrices is not associated.",err,error,*999)
14759 CALL flagerror(
"Solver matrices solution mapping is not associated.",err,error,*999)
14762 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
14765 CALL flagerror(
"Solver is not associated.",err,error,*999)
14768 exits(
"SOLVER_MATRICES_STATIC_ASSEMBLE")
14770 999
IF(
ALLOCATED(dependent_parameters))
DEALLOCATE(dependent_parameters)
14771 errorsexits(
"SOLVER_MATRICES_STATIC_ASSEMBLE",err,error)
14783 TYPE(solver_type),
POINTER :: SOLVER
14784 INTEGER(INTG),
INTENT(OUT) :: MATRICES_LIBRARY_TYPE
14785 INTEGER(INTG),
INTENT(OUT) :: ERR
14786 TYPE(varying_string),
INTENT(OUT) :: ERROR
14788 TYPE(eigenproblem_solver_type),
POINTER :: EIGENPROBLEM_SOLVER
14789 TYPE(linear_solver_type),
POINTER :: LINEAR_SOLVER
14790 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
14791 TYPE(optimiser_solver_type),
POINTER :: OPTIMISER_SOLVER
14792 TYPE(varying_string) :: LOCAL_ERROR
14794 enters(
"SOLVER_MATRICES_LIBRARY_TYPE_GET",err,error,*999)
14796 IF(
ASSOCIATED(solver))
THEN 14797 SELECT CASE(solver%SOLVE_TYPE)
14799 linear_solver=>solver%LINEAR_SOLVER
14800 IF(
ASSOCIATED(linear_solver))
THEN 14803 CALL flagerror(
"Solver linear solver is not associated.",err,error,*999)
14806 nonlinear_solver=>solver%NONLINEAR_SOLVER
14807 IF(
ASSOCIATED(nonlinear_solver))
THEN 14810 CALL flagerror(
"Solver nonlinear solver is not associated.",err,error,*999)
14813 CALL flagerror(
"Cannot get the solver matrices library for a dynamic solver.",err,error,*999)
14815 CALL flagerror(
"Cannot get the solver matrices library for an differential-algebraic equations solver.",err,error,*999)
14817 eigenproblem_solver=>solver%EIGENPROBLEM_SOLVER
14818 IF(
ASSOCIATED(eigenproblem_solver))
THEN 14821 CALL flagerror(
"Solver eigenproblem solver is not associated.",err,error,*999)
14824 optimiser_solver=>solver%OPTIMISER_SOLVER
14825 IF(
ASSOCIATED(optimiser_solver))
THEN 14828 CALL flagerror(
"Solver optimiser solver is not associated.",err,error,*999)
14831 CALL flagerror(
"Cannot get the solver matrices library for a CellML evaluator solver.",err,error,*999)
14833 local_error=
"The solver type of "//trim(numbertovstring(solver%SOLVE_TYPE,
"*",err,error))//
" is invalid." 14834 CALL flagerror(local_error,err,error,*999)
14837 CALL flagerror(
"Solver is not associated.",err,error,*999)
14840 exits(
"SOLVER_MATRICES_LIBRARY_TYPE_GET")
14842 999 errorsexits(
"SOLVER_MATRICES_LIBRARY_TYPE_GET",err,error)
14855 TYPE(solver_type),
POINTER :: SOLVER
14856 REAL(DP),
INTENT(IN) :: ABSOLUTE_TOLERANCE
14857 INTEGER(INTG),
INTENT(OUT) :: ERR
14858 TYPE(varying_string),
INTENT(OUT) :: ERROR
14860 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
14861 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
14862 TYPE(varying_string) :: LOCAL_ERROR
14864 enters(
"SOLVER_QUASI_NEWTON_ABSOLUTE_TOLERANCE_SET",err,error,*999)
14866 IF(
ASSOCIATED(solver))
THEN 14867 IF(solver%SOLVER_FINISHED)
THEN 14868 CALL flagerror(
"Solver has already been finished.",err,error,*999)
14871 nonlinear_solver=>solver%NONLINEAR_SOLVER
14872 IF(
ASSOCIATED(nonlinear_solver))
THEN 14874 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
14875 IF(
ASSOCIATED(quasi_newton_solver))
THEN 14876 IF(absolute_tolerance>zero_tolerance)
THEN 14877 quasi_newton_solver%ABSOLUTE_TOLERANCE=absolute_tolerance
14879 local_error=
"The specified absolute tolerance of "//trim(numbertovstring(absolute_tolerance,
"*",err,error))// &
14880 &
" is invalid. The absolute tolerance must be > 0." 14881 CALL flagerror(local_error,err,error,*999)
14884 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
14887 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
14890 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
14893 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
14897 CALL flagerror(
"Solver is not associated.",err,error,*999)
14900 exits(
"SOLVER_QUASI_NEWTON_ABSOLUTE_TOLERANCE_SET")
14902 999 errorsexits(
"SOLVER_QUASI_NEWTON_ABSOLUTE_TOLERANCE_SET",err,error)
14915 TYPE(solver_type),
POINTER :: solver
14916 LOGICAL,
INTENT(IN) :: linesearchMonitorOutputFlag
14917 INTEGER(INTG),
INTENT(OUT) :: err
14918 TYPE(varying_string),
INTENT(OUT) :: error
14920 TYPE(quasi_newton_linesearch_solver_type),
POINTER :: linesearchSolver
14921 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
14922 TYPE(nonlinear_solver_type),
POINTER :: nonlinearSolver
14924 enters(
"Solver_QuasiNewtonLineSearchMonitorOutputSet",err,error,*999)
14926 IF(
ASSOCIATED(solver))
THEN 14927 IF(solver%SOLVER_FINISHED)
THEN 14928 CALL flagerror(
"Solver has already been finished.",err,error,*999)
14931 nonlinearsolver=>solver%NONLINEAR_SOLVER
14932 IF(
ASSOCIATED(nonlinearsolver))
THEN 14934 quasi_newton_solver=>nonlinearsolver%QUASI_NEWTON_SOLVER
14935 IF(
ASSOCIATED(quasi_newton_solver))
THEN 14937 linesearchsolver=>quasi_newton_solver%LINESEARCH_SOLVER
14938 IF(
ASSOCIATED(linesearchsolver))
THEN 14939 linesearchsolver%linesearchMonitorOutput=linesearchmonitoroutputflag
14941 CALL flagerror(
"The Quasi-Newton linesearch solver is not associated.",err,error,*999)
14944 CALL flagerror(
"The Quasi-Newton solver is not a linesearch solver.",err,error,*999)
14947 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
14950 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
14953 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
14956 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
14960 CALL flagerror(
"Solver is not associated.",err,error,*999)
14963 exits(
"Solver_QuasiNewtonLineSearchMonitorOutputSet")
14965 999 errors(
"Solver_QuasiNewtonLineSearchMonitorOutputSet",err,error)
14966 exits(
"Solver_QuasiNewtonLineSearchMonitorOutputSet")
14979 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
14980 INTEGER(INTG),
INTENT(OUT) :: ERR
14981 TYPE(varying_string),
INTENT(OUT) :: ERROR
14983 TYPE(varying_string) :: LOCAL_ERROR
14985 enters(
"SOLVER_QUASI_NEWTON_CREATE_FINISH",err,error,*999)
14987 IF(
ASSOCIATED(quasi_newton_solver))
THEN 14988 SELECT CASE(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE)
14991 & linesearch_solver,err,error,*999)
14994 & trustregion_solver,err,error,*999)
14996 local_error=
"The Quasi-Newton solver type of "// &
14997 & trim(numbertovstring(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE,
"*",err,error))//
" is invalid." 14998 CALL flagerror(local_error,err,error,*999)
15001 CALL flagerror(
"Quasi-Newton solver is not associated.",err,error,*999)
15004 exits(
"SOLVER_QUASI_NEWTON_CREATE_FINISH")
15006 999 errorsexits(
"SOLVER_QUASI_NEWTON_CREATE_FINISH",err,error)
15019 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
15020 INTEGER(INTG),
INTENT(OUT) :: ERR
15021 TYPE(varying_string),
INTENT(OUT) :: ERROR
15024 enters(
"SOLVER_QUASI_NEWTON_FINALISE",err,error,*999)
15026 IF(
ASSOCIATED(quasi_newton_solver))
THEN 15029 CALL solver_finalise(quasi_newton_solver%LINEAR_SOLVER,err,error,*999)
15030 DEALLOCATE(quasi_newton_solver)
15033 exits(
"SOLVER_QUASI_NEWTON_FINALISE")
15035 999 errorsexits(
"SOLVER_QUASI_NEWTON_FINALISE",err,error)
15048 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
15049 INTEGER(INTG),
INTENT(OUT) :: ERR
15050 TYPE(varying_string),
INTENT(OUT) :: ERROR
15052 INTEGER(INTG) :: DUMMY_ERR
15053 TYPE(solver_type),
POINTER :: SOLVER
15054 TYPE(varying_string) :: DUMMY_ERROR
15056 enters(
"SOLVER_QUASI_NEWTON_INITIALISE",err,error,*998)
15058 IF(
ASSOCIATED(nonlinear_solver))
THEN 15059 IF(
ASSOCIATED(nonlinear_solver%QUASI_NEWTON_SOLVER))
THEN 15060 CALL flagerror(
"Quasi-Newton solver is already associated for this nonlinear solver.",err,error,*998)
15062 solver=>nonlinear_solver%SOLVER
15063 IF(
ASSOCIATED(solver))
THEN 15065 ALLOCATE(nonlinear_solver%QUASI_NEWTON_SOLVER,stat=err)
15066 IF(err/=0)
CALL flagerror(
"Could not allocate nonlinear solver Quasi-Newton solver.",err,error,*999)
15067 nonlinear_solver%QUASI_NEWTON_SOLVER%NONLINEAR_SOLVER=>nonlinear_solver
15069 nonlinear_solver%QUASI_NEWTON_SOLVER%TOTAL_NUMBER_OF_FUNCTION_EVALUATIONS=0
15070 nonlinear_solver%QUASI_NEWTON_SOLVER%TOTAL_NUMBER_OF_JACOBIAN_EVALUATIONS=0
15071 nonlinear_solver%QUASI_NEWTON_SOLVER%MAXIMUM_NUMBER_OF_ITERATIONS=50
15072 nonlinear_solver%QUASI_NEWTON_SOLVER%MAXIMUM_NUMBER_OF_FUNCTION_EVALUATIONS=1000
15075 nonlinear_solver%QUASI_NEWTON_SOLVER%ABSOLUTE_TOLERANCE=1.0e-10_dp
15076 nonlinear_solver%QUASI_NEWTON_SOLVER%RELATIVE_TOLERANCE=1.0e-05_dp
15077 nonlinear_solver%QUASI_NEWTON_SOLVER%SOLUTION_TOLERANCE=1.0e-05_dp
15078 NULLIFY(nonlinear_solver%QUASI_NEWTON_SOLVER%LINESEARCH_SOLVER)
15079 NULLIFY(nonlinear_solver%QUASI_NEWTON_SOLVER%TRUSTREGION_SOLVER)
15080 NULLIFY(nonlinear_solver%QUASI_NEWTON_SOLVER%CELLML_EVALUATOR_SOLVER)
15081 NULLIFY(nonlinear_solver%QUASI_NEWTON_SOLVER%convergenceTest)
15082 ALLOCATE(nonlinear_solver%QUASI_NEWTON_SOLVER%convergenceTest,stat=err)
15083 IF(err/=0)
CALL flagerror(
"Could not allocate convergence test object.",err,error,*999)
15084 nonlinear_solver%QUASI_NEWTON_SOLVER%convergenceTest%energyFirstIter = 0.0_dp
15085 nonlinear_solver%QUASI_NEWTON_SOLVER%convergenceTest%normalisedEnergy = 0.0_dp
15092 nonlinear_solver%QUASI_NEWTON_SOLVER%RESTART=10
15095 ALLOCATE(nonlinear_solver%QUASI_NEWTON_SOLVER%LINEAR_SOLVER,stat=err)
15096 IF(err/=0)
CALL flagerror(
"Could not allocate Quasi-Newton solver linear solver.",err,error,*999)
15097 NULLIFY(nonlinear_solver%QUASI_NEWTON_SOLVER%LINEAR_SOLVER%SOLVERS)
15102 CALL flagerror(
"Nonlinear solver solver is not associated.",err,error,*998)
15106 CALL flagerror(
"Nonlinear solver is not associated.",err,error,*998)
15109 exits(
"SOLVER_QUASI_NEWTON_INITIALISE")
15112 998 errorsexits(
"SOLVER_QUASI_NEWTON_INITIALISE",err,error)
15125 TYPE(solver_type),
POINTER :: SOLVER
15126 INTEGER(INTG),
INTENT(IN) :: JACOBIAN_CALCULATION_TYPE
15127 INTEGER(INTG),
INTENT(OUT) :: ERR
15128 TYPE(varying_string),
INTENT(OUT) :: ERROR
15130 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
15131 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
15132 TYPE(varying_string) :: LOCAL_ERROR
15134 enters(
"Solver_QuasiNewtonJacobianCalculationTypeSet",err,error,*999)
15136 IF(
ASSOCIATED(solver))
THEN 15137 IF(solver%SOLVER_FINISHED)
THEN 15138 CALL flagerror(
"Solver has already been finished",err,error,*999)
15141 nonlinear_solver=>solver%NONLINEAR_SOLVER
15142 IF(
ASSOCIATED(nonlinear_solver))
THEN 15144 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
15145 IF(
ASSOCIATED(quasi_newton_solver))
THEN 15146 IF(jacobian_calculation_type/=quasi_newton_solver%JACOBIAN_CALCULATION_TYPE)
THEN 15147 SELECT CASE(jacobian_calculation_type)
15155 local_error=
"The Jacobian calculation type of "// &
15156 & trim(numbertovstring(jacobian_calculation_type,
"*",err,error))//
" is invalid." 15157 CALL flagerror(local_error,err,error,*999)
15161 CALL flagerror(
"The nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
15164 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
15167 CALL flagerror(
"The Solver nonlinear solver is not associated",err,error,*999)
15170 CALL flagerror(
"The solver is not a nonlinear solver",err,error,*999)
15174 CALL flagerror(
"Solver is not associated",err,error,*999)
15177 exits(
"Solver_QuasiNewtonJacobianCalculationTypeSet")
15179 999 errors(
"Solver_QuasiNewtonJacobianCalculationTypeSet",err,error)
15180 exits(
"Solver_QuasiNewtonJacobianCalculationTypeSet")
15193 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
15194 INTEGER(INTG),
INTENT(OUT) :: SOLVER_LIBRARY_TYPE
15195 INTEGER(INTG),
INTENT(OUT) :: ERR
15196 TYPE(varying_string),
INTENT(OUT) :: ERROR
15198 TYPE(quasi_newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
15199 TYPE(quasi_newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
15200 TYPE(varying_string) :: LOCAL_ERROR
15202 enters(
"SOLVER_QUASI_NEWTON_LIBRARY_TYPE_GET",err,error,*999)
15204 IF(
ASSOCIATED(quasi_newton_solver))
THEN 15205 SELECT CASE(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE)
15207 linesearch_solver=>quasi_newton_solver%LINESEARCH_SOLVER
15208 IF(
ASSOCIATED(linesearch_solver))
THEN 15209 solver_library_type=linesearch_solver%SOLVER_LIBRARY
15211 CALL flagerror(
"Quasi-Newton line search solver is not associated.",err,error,*999)
15214 trustregion_solver=>quasi_newton_solver%TRUSTREGION_SOLVER
15215 IF(
ASSOCIATED(trustregion_solver))
THEN 15216 solver_library_type=trustregion_solver%SOLVER_LIBRARY
15218 CALL flagerror(
"Quasi-Newton trust region solver is not associated.",err,error,*999)
15221 local_error=
"The Quasi-Newton solver type of "// &
15222 & trim(numbertovstring(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE,
"*",err,error))//
" is invalid." 15223 CALL flagerror(local_error,err,error,*999)
15226 CALL flagerror(
"Quasi-Newton solver is not associated.",err,error,*999)
15229 exits(
"SOLVER_QUASI_NEWTON_LIBRARY_TYPE_GET")
15231 999 errorsexits(
"SOLVER_QUASI_NEWTON_LIBRARY_TYPE_GET",err,error)
15244 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
15245 INTEGER(INTG),
INTENT(IN) :: SOLVER_LIBRARY_TYPE
15246 INTEGER(INTG),
INTENT(OUT) :: ERR
15247 TYPE(varying_string),
INTENT(OUT) :: ERROR
15249 TYPE(quasi_newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
15250 TYPE(quasi_newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
15251 TYPE(varying_string) :: LOCAL_ERROR
15253 enters(
"SOLVER_QUASI_NEWTON_LIBRARY_TYPE_SET",err,error,*999)
15255 IF(
ASSOCIATED(quasi_newton_solver))
THEN 15256 SELECT CASE(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE)
15258 linesearch_solver=>quasi_newton_solver%LINESEARCH_SOLVER
15259 IF(
ASSOCIATED(linesearch_solver))
THEN 15260 SELECT CASE(solver_library_type)
15262 CALL flagerror(
"Not implemented.",err,error,*999)
15265 linesearch_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
15267 local_error=
"The solver library type of "//trim(numbertovstring(solver_library_type,
"*",err,error))// &
15268 &
" is invalid for a Quasi-Newton linesearch solver." 15269 CALL flagerror(local_error,err,error,*999)
15272 CALL flagerror(
"Quasi-Newton line search solver is not associated.",err,error,*999)
15275 trustregion_solver=>quasi_newton_solver%TRUSTREGION_SOLVER
15276 IF(
ASSOCIATED(trustregion_solver))
THEN 15277 SELECT CASE(solver_library_type)
15279 CALL flagerror(
"Not implemented.",err,error,*999)
15282 trustregion_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
15284 local_error=
"The solver library type of "//trim(numbertovstring(solver_library_type,
"*",err,error))// &
15285 &
" is invalid for a Quasi-Newton trustregion solver." 15286 CALL flagerror(local_error,err,error,*999)
15289 CALL flagerror(
"Quasi-Newton trust region solver is not associated.",err,error,*999)
15292 local_error=
"The Quasi-Newton solver type of "// &
15293 & trim(numbertovstring(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE,
"*",err,error))//
" is invalid." 15294 CALL flagerror(local_error,err,error,*999)
15297 CALL flagerror(
"Quasi-Newton solver is not associated.",err,error,*999)
15300 exits(
"SOLVER_QUASI_NEWTON_LIBRARY_TYPE_SET")
15302 999 errorsexits(
"SOLVER_QUASI_NEWTON_LIBRARY_TYPE_SET",err,error)
15315 TYPE(solver_type),
POINTER :: SOLVER
15316 TYPE(solver_type),
POINTER :: LINEAR_SOLVER
15317 INTEGER(INTG),
INTENT(OUT) :: ERR
15318 TYPE(varying_string),
INTENT(OUT) :: ERROR
15320 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
15321 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
15323 enters(
"SOLVER_QUASI_NEWTON_LINEAR_SOLVER_GET",err,error,*999)
15325 IF(
ASSOCIATED(solver))
THEN 15326 IF(
ASSOCIATED(linear_solver))
THEN 15327 CALL flagerror(
"Linear solver is already associated.",err,error,*999)
15329 NULLIFY(linear_solver)
15331 nonlinear_solver=>solver%NONLINEAR_SOLVER
15332 IF(
ASSOCIATED(nonlinear_solver))
THEN 15334 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
15335 IF(
ASSOCIATED(quasi_newton_solver))
THEN 15336 linear_solver=>quasi_newton_solver%LINEAR_SOLVER
15337 IF(.NOT.
ASSOCIATED(linear_solver)) &
15338 &
CALL flagerror(
"Quasi-Newton solver linear solver is not associated.",err,error,*999)
15340 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
15343 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
15346 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
15349 CALL flagerror(
"The specified solver is not a dynamic solver.",err,error,*999)
15353 CALL flagerror(
"Solver is not associated.",err,error,*999)
15356 exits(
"SOLVER_QUASI_NEWTON_LINEAR_SOLVER_GET")
15358 999 errorsexits(
"SOLVER_QUASI_NEWTON_LINEAR_SOLVER_GET",err,error)
15371 TYPE(solver_type),
POINTER :: SOLVER
15372 TYPE(solver_type),
POINTER :: CELLML_SOLVER
15373 INTEGER(INTG),
INTENT(OUT) :: ERR
15374 TYPE(varying_string),
INTENT(OUT) :: ERROR
15376 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
15377 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
15379 enters(
"SOLVER_QUASI_NEWTON_CELLML_SOLVER_GET",err,error,*999)
15381 IF(
ASSOCIATED(solver))
THEN 15382 IF(
ASSOCIATED(cellml_solver))
THEN 15383 CALL flagerror(
"Linear solver is already associated.",err,error,*999)
15385 NULLIFY(cellml_solver)
15387 nonlinear_solver=>solver%NONLINEAR_SOLVER
15388 IF(
ASSOCIATED(nonlinear_solver))
THEN 15390 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
15391 IF(
ASSOCIATED(quasi_newton_solver))
THEN 15392 cellml_solver=>quasi_newton_solver%CELLML_EVALUATOR_SOLVER
15393 IF(.NOT.
ASSOCIATED(cellml_solver)) &
15394 &
CALL flagerror(
"Quasi-Newton solver CellML solver is not associated.",err,error,*999)
15396 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
15399 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
15402 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
15405 nonlinear_solver=>solver%DYNAMIC_SOLVER%NONLINEAR_SOLVER%NONLINEAR_SOLVER
15406 IF(
ASSOCIATED(nonlinear_solver))
THEN 15408 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
15409 IF(
ASSOCIATED(quasi_newton_solver))
THEN 15410 cellml_solver=>quasi_newton_solver%CELLML_EVALUATOR_SOLVER
15411 IF(.NOT.
ASSOCIATED(cellml_solver)) &
15412 &
CALL flagerror(
"Quasi-Newton solver CellML solver is not associated.",err,error,*999)
15414 CALL flagerror(
"Dynamic nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
15417 CALL flagerror(
"The Dynamic nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
15420 CALL flagerror(
"The solver dynamic nonlinear solver is not associated.",err,error,*999)
15423 CALL flagerror(
"The specified solver is not a nonlinear or dynamic nonlinear solver.",err,error,*999)
15427 CALL flagerror(
"Solver is not associated.",err,error,*999)
15430 exits(
"SOLVER_QUASI_NEWTON_CELLML_SOLVER_GET")
15432 999 errorsexits(
"SOLVER_QUASI_NEWTON_CELLML_SOLVER_GET",err,error)
15445 TYPE(solver_type),
POINTER :: solver
15446 INTEGER(INTG),
INTENT(IN) :: convergenceTestType
15447 INTEGER(INTG),
INTENT(OUT) :: err
15448 TYPE(varying_string),
INTENT(OUT) :: error
15450 TYPE(quasi_newton_solver_type),
POINTER :: quasiNewtonSolver
15451 TYPE(nonlinear_solver_type),
POINTER :: nonlinearSolver
15452 TYPE(varying_string) :: localError
15454 enters(
"Solver_QuasiNewtonConvergenceTestTypeSet",err,error,*999)
15456 IF(
ASSOCIATED(solver))
THEN 15457 IF(solver%SOLVER_FINISHED)
THEN 15458 CALL flagerror(
"Solver has already been finished.",err,error,*999)
15461 nonlinearsolver=>solver%NONLINEAR_SOLVER
15462 IF(
ASSOCIATED(nonlinearsolver))
THEN 15464 quasinewtonsolver=>nonlinearsolver%QUASI_NEWTON_SOLVER
15465 IF(
ASSOCIATED(quasinewtonsolver))
THEN 15466 SELECT CASE(convergencetesttype)
15474 localerror=
"The specified convergence test type of "//trim(numbertovstring(convergencetesttype, &
15475 &
"*",err,error))//
" is invalid." 15476 CALL flagerror(localerror,err,error,*999)
15479 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
15482 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
15485 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
15488 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
15492 CALL flagerror(
"Solver is not associated.",err,error,*999)
15495 exits(
"Solver_QuasiNewtonConvergenceTestTypeSet")
15497 999 errorsexits(
"Solver_QuasiNewtonConvergenceTestTypeSet",err,error)
15510 TYPE(quasi_newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
15511 INTEGER(INTG),
INTENT(OUT) :: ERR
15512 TYPE(varying_string),
INTENT(OUT) :: ERROR
15514 EXTERNAL :: problem_solverjacobianevaluatepetsc
15515 EXTERNAL :: problem_solverjacobianfdcalculatepetsc
15516 EXTERNAL :: problem_solverresidualevaluatepetsc
15517 EXTERNAL :: problem_solverconvergencetestpetsc
15518 EXTERNAL :: problem_solvernonlinearmonitorpetsc
15519 INTEGER(INTG) :: equations_matrix_idx,equations_set_idx,interface_condition_idx,interface_matrix_idx
15520 TYPE(distributed_matrix_type),
POINTER :: JACOBIAN_MATRIX
15521 TYPE(distributed_vector_type),
POINTER :: RESIDUAL_VECTOR
15522 TYPE(equations_type),
POINTER :: EQUATIONS
15523 TYPE(equations_mapping_type),
POINTER :: EQUATIONS_MAPPING
15524 TYPE(equations_mapping_linear_type),
POINTER :: LINEAR_MAPPING
15525 TYPE(equations_matrices_type),
POINTER :: EQUATIONS_MATRICES
15526 TYPE(equations_matrices_linear_type),
POINTER :: LINEAR_MATRICES
15527 TYPE(equations_matrix_type),
POINTER :: EQUATIONS_MATRIX
15528 TYPE(equations_set_type),
POINTER :: EQUATIONS_SET
15529 TYPE(field_type),
POINTER :: DEPENDENT_FIELD,LAGRANGE_FIELD
15530 TYPE(field_variable_type),
POINTER :: LINEAR_VARIABLE,INTERFACE_VARIABLE,LAGRANGE_VARIABLE
15531 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
15532 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
15533 TYPE(solver_type),
POINTER :: LINEAR_SOLVER,SOLVER
15534 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
15535 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
15536 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
15537 TYPE(solver_matrix_type),
POINTER :: SOLVER_JACOBIAN
15538 TYPE(interface_condition_type),
POINTER :: INTERFACE_CONDITION
15539 TYPE(interface_equations_type),
POINTER :: INTERFACE_EQUATIONS
15540 TYPE(interface_mapping_type),
POINTER :: INTERFACE_MAPPING
15541 TYPE(interface_matrices_type),
POINTER :: INTERFACE_MATRICES
15542 TYPE(interface_matrix_type),
POINTER :: INTERFACE_MATRIX
15544 TYPE(varying_string) :: LOCAL_ERROR
15546 enters(
"Solver_QuasiNewtonLinesearchCreateFinish",err,error,*999)
15548 IF(
ASSOCIATED(linesearch_solver))
THEN 15549 quasi_newton_solver=>linesearch_solver%QUASI_NEWTON_SOLVER
15550 IF(
ASSOCIATED(quasi_newton_solver))
THEN 15551 nonlinear_solver=>quasi_newton_solver%NONLINEAR_SOLVER
15552 IF(
ASSOCIATED(nonlinear_solver))
THEN 15553 solver=>nonlinear_solver%SOLVER
15554 IF(
ASSOCIATED(solver))
THEN 15555 solver_equations=>solver%SOLVER_EQUATIONS
15556 IF(
ASSOCIATED(solver_equations))
THEN 15557 SELECT CASE(linesearch_solver%SOLVER_LIBRARY)
15559 CALL flagerror(
"Not implemented.",err,error,*999)
15561 solver_mapping=>solver_equations%SOLVER_MAPPING
15562 IF(
ASSOCIATED(solver_mapping))
THEN 15564 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
15565 equations=>solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)%EQUATIONS
15566 IF(
ASSOCIATED(equations))
THEN 15567 equations_set=>equations%EQUATIONS_SET
15568 IF(
ASSOCIATED(equations_set))
THEN 15569 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
15570 IF(
ASSOCIATED(dependent_field))
THEN 15571 equations_mapping=>equations%EQUATIONS_MAPPING
15572 IF(
ASSOCIATED(equations_mapping))
THEN 15573 linear_mapping=>equations_mapping%LINEAR_MAPPING
15574 IF(
ASSOCIATED(linear_mapping))
THEN 15576 equations_matrices=>equations%EQUATIONS_MATRICES
15577 IF(
ASSOCIATED(equations_matrices))
THEN 15578 linear_matrices=>equations_matrices%LINEAR_MATRICES
15579 IF(
ASSOCIATED(linear_matrices))
THEN 15580 DO equations_matrix_idx=1,linear_matrices%NUMBER_OF_LINEAR_MATRICES
15581 equations_matrix=>linear_matrices%MATRICES(equations_matrix_idx)%PTR
15582 IF(
ASSOCIATED(equations_matrix))
THEN 15583 IF(.NOT.
ASSOCIATED(equations_matrix%TEMP_VECTOR))
THEN 15584 linear_variable=>linear_mapping%EQUATIONS_MATRIX_TO_VAR_MAPS(equations_matrix_idx)%VARIABLE
15585 IF(
ASSOCIATED(linear_variable))
THEN 15586 CALL distributed_vector_create_start(linear_variable%DOMAIN_MAPPING, &
15587 & equations_matrix%TEMP_VECTOR,err,error,*999)
15588 CALL distributed_vector_data_type_set(equations_matrix%TEMP_VECTOR, &
15589 & distributed_matrix_vector_dp_type,err,error,*999)
15590 CALL distributed_vector_create_finish(equations_matrix%TEMP_VECTOR,err,error,*999)
15592 CALL flagerror(
"Linear mapping linear variable is not associated.",err,error,*999)
15596 CALL flagerror(
"Equations matrix is not associated.",err,error,*999)
15600 CALL flagerror(
"Equations matrices linear matrices is not associated.",err,error,*999)
15603 CALL flagerror(
"Equations equations matrices is not associated.",err,error,*999)
15607 CALL flagerror(
"Equations equations mapping is not associated.",err,error,*999)
15610 local_error=
"Equations set dependent field is not associated for equations set index "// &
15611 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 15612 CALL flagerror(local_error,err,error,*999)
15615 local_error=
"Equations equations set is not associated for equations set index "// &
15616 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 15617 CALL flagerror(local_error,err,error,*999)
15620 local_error=
"Equations is not associated for equations set index "// &
15621 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 15622 CALL flagerror(local_error,err,error,*999)
15626 DO interface_condition_idx=1,solver_mapping%NUMBER_OF_INTERFACE_CONDITIONS
15627 interface_condition=>solver_mapping%INTERFACE_CONDITIONS(interface_condition_idx)%PTR
15628 IF(
ASSOCIATED(interface_condition))
THEN 15629 lagrange_field=>interface_condition%LAGRANGE%LAGRANGE_FIELD
15630 IF(
ASSOCIATED(lagrange_field))
THEN 15631 interface_equations=>interface_condition%INTERFACE_EQUATIONS
15632 IF(
ASSOCIATED(interface_equations))
THEN 15633 interface_matrices=>interface_equations%INTERFACE_MATRICES
15634 IF(
ASSOCIATED(interface_matrices))
THEN 15635 interface_mapping=>interface_equations%INTERFACE_MAPPING
15636 IF(
ASSOCIATED(interface_mapping))
THEN 15637 lagrange_variable=>interface_mapping%LAGRANGE_VARIABLE
15638 IF(
ASSOCIATED(lagrange_variable))
THEN 15640 DO interface_matrix_idx=1,interface_mapping%NUMBER_OF_INTERFACE_MATRICES
15641 interface_matrix=>interface_matrices%MATRICES(interface_matrix_idx)%PTR
15642 IF(
ASSOCIATED(interface_matrix))
THEN 15643 IF(.NOT.
ASSOCIATED(interface_matrix%TEMP_VECTOR))
THEN 15644 interface_variable=>interface_mapping% &
15645 & interface_matrix_rows_to_var_maps(interface_matrix_idx)%VARIABLE
15646 IF(
ASSOCIATED(interface_variable))
THEN 15648 CALL distributed_vector_create_start(interface_variable%DOMAIN_MAPPING, &
15649 & interface_matrix%TEMP_VECTOR,err,error,*999)
15650 CALL distributed_vector_data_type_set(interface_matrix%TEMP_VECTOR, &
15651 & distributed_matrix_vector_dp_type,err,error,*999)
15652 CALL distributed_vector_create_finish(interface_matrix%TEMP_VECTOR,err,error,*999)
15654 CALL distributed_vector_create_start(lagrange_variable%DOMAIN_MAPPING, &
15655 & interface_matrix%TEMP_TRANSPOSE_VECTOR,err,error,*999)
15656 CALL distributed_vector_data_type_set(interface_matrix%TEMP_TRANSPOSE_VECTOR, &
15657 & distributed_matrix_vector_dp_type,err,error,*999)
15658 CALL distributed_vector_create_finish(interface_matrix%TEMP_TRANSPOSE_VECTOR, &
15661 CALL flagerror(
"Interface mapping variable is not associated.",err,error,*999)
15665 CALL flagerror(
"Interface matrix is not associated.",err,error,*999)
15669 CALL flagerror(
"Interface matrix is not associated.",err,error,*999)
15672 CALL flagerror(
"interface condition mapping is not associated.",err,error,*999)
15675 CALL flagerror(
"Interface matrices is not associated.",err,error,*999)
15678 local_error=
"Interface eqauations is not associated for interface condition index "// &
15679 & trim(numbertovstring(interface_condition_idx,
"*",err,error))//
"." 15680 CALL flagerror(local_error,err,error,*999)
15683 local_error=
"Interface condition Lagrange field is not associated for interface condition "// &
15684 & trim(numbertovstring(interface_condition_idx,
"*",err,error))//
"." 15685 CALL flagerror(local_error,err,error,*999)
15688 local_error=
"Interface condition is not associated for interface condition index "// &
15689 & trim(numbertovstring(interface_condition_idx,
"*",err,error))//
"." 15690 CALL flagerror(local_error,err,error,*999)
15694 CALL petsc_snescreate(computational_environment%MPI_COMM,linesearch_solver%snes,err,error,*999)
15696 CALL petsc_snessettype(linesearch_solver%snes,petsc_snesqn,err,error,*999)
15699 SELECT CASE(quasi_newton_solver%QUASI_NEWTON_TYPE)
15701 CALL petsc_snesqnsettype(linesearch_solver%snes,petsc_snes_qn_lbfgs,err,error,*999)
15703 CALL petsc_snesqnsettype(linesearch_solver%snes,petsc_snes_qn_broyden,err,error,*999)
15705 CALL petsc_snesqnsettype(linesearch_solver%snes,petsc_snes_qn_badbroyden,err,error,*999)
15707 local_error=
"The specified nonlinear Quasi-Newton type of "// &
15708 & trim(numbertovstring(quasi_newton_solver%QUASI_NEWTON_TYPE,
"*",err,error))//
" is invalid." 15709 CALL flagerror(local_error,err,error,*999)
15712 SELECT CASE(quasi_newton_solver%RESTART_TYPE)
15714 CALL petsc_snesqnsetrestarttype(linesearch_solver%snes,petsc_snes_qn_restart_none,err,error,*999)
15716 CALL petsc_snesqnsetrestarttype(linesearch_solver%snes,petsc_snes_qn_restart_powell,err,error,*999)
15718 CALL petsc_snesqnsetrestarttype(linesearch_solver%snes,petsc_snes_qn_restart_periodic,err,error,*999)
15720 local_error=
"The specified nonlinear Quasi-Newton restart type of "// &
15721 & trim(numbertovstring(quasi_newton_solver%RESTART_TYPE,
"*",err,error))//
" is invalid." 15722 CALL flagerror(local_error,err,error,*999)
15725 SELECT CASE(quasi_newton_solver%SCALE_TYPE)
15727 CALL petsc_snesqnsetscaletype(linesearch_solver%snes,petsc_snes_qn_scale_none,err,error,*999)
15729 CALL petsc_snesqnsetscaletype(linesearch_solver%snes,petsc_snes_qn_scale_shanno,err,error,*999)
15731 CALL petsc_snesqnsetscaletype(linesearch_solver%snes,petsc_snes_qn_scale_linesearch,err,error,*999)
15733 CALL petsc_snesqnsetscaletype(linesearch_solver%snes,petsc_snes_qn_scale_jacobian,err,error,*999)
15735 local_error=
"The specified nonlinear Quasi-Newton scale type of "// &
15736 & trim(numbertovstring(quasi_newton_solver%SCALE_TYPE,
"*",err,error))//
" is invalid." 15737 CALL flagerror(local_error,err,error,*999)
15743 linear_solver=>quasi_newton_solver%LINEAR_SOLVER
15744 IF(
ASSOCIATED(linear_solver))
THEN 15745 NULLIFY(solver_matrices)
15746 CALL solver_matrices_create_start(solver_equations,solver_matrices,err,error,*999)
15748 SELECT CASE(solver_equations%SPARSITY_TYPE)
15750 CALL solver_matrices_storage_type_set(solver_matrices,[distributed_matrix_compressed_row_storage_type], &
15753 CALL solver_matrices_storage_type_set(solver_matrices,[distributed_matrix_block_storage_type], &
15756 local_error=
"The specified solver equations sparsity type of "// &
15757 & trim(numbertovstring(solver_equations%SPARSITY_TYPE,
"*",err,error))//
" is invalid." 15758 CALL flagerror(local_error,err,error,*999)
15760 CALL solver_matrices_create_finish(solver_matrices,err,error,*999)
15762 linear_solver%SOLVER_EQUATIONS=>solver%SOLVER_EQUATIONS
15766 SELECT CASE(linear_solver%LINEAR_SOLVER%LINEAR_SOLVE_TYPE)
15768 CALL petsc_snessetksp(linesearch_solver%snes,linear_solver%linear_solver%direct_solver%ksp,err,error,*999)
15770 CALL petsc_snessetksp(linesearch_solver%snes,linear_solver%linear_solver%iterative_solver%ksp,err,error,*999)
15774 residual_vector=>solver_matrices%RESIDUAL
15775 IF(
ASSOCIATED(residual_vector))
THEN 15776 IF(
ASSOCIATED(residual_vector%PETSC))
THEN 15778 CALL petsc_snessetfunction(linesearch_solver%snes,residual_vector%PETSC%VECTOR, &
15779 & problem_solverresidualevaluatepetsc,linesearch_solver%QUASI_NEWTON_SOLVER%NONLINEAR_SOLVER%SOLVER, &
15781 SELECT CASE(linesearch_solver%QUASI_NEWTON_SOLVER%convergenceTestType)
15785 CALL petsc_snessetconvergencetest(linesearch_solver%snes,problem_solverconvergencetestpetsc, &
15786 & linesearch_solver%QUASI_NEWTON_SOLVER%NONLINEAR_SOLVER%SOLVER,err,error,*999)
15788 local_error=
"The specified convergence test type of "//trim(numbertovstring(linesearch_solver% &
15789 & quasi_newton_solver%convergenceTestType,
"*",err,error))//
" is invalid." 15790 CALL flagerror(local_error,err,error,*999)
15793 CALL flagerror(
"The residual vector PETSc is not associated.",err,error,*999)
15796 CALL flagerror(
"Solver matrices residual vector is not associated.",err,error,*999)
15800 IF(solver_matrices%NUMBER_OF_MATRICES==1)
THEN 15801 solver_jacobian=>solver_matrices%MATRICES(1)%PTR
15802 IF(
ASSOCIATED(solver_jacobian))
THEN 15803 jacobian_matrix=>solver_jacobian%MATRIX
15804 IF(
ASSOCIATED(jacobian_matrix))
THEN 15805 IF(
ASSOCIATED(jacobian_matrix%PETSC))
THEN 15806 SELECT CASE(quasi_newton_solver%JACOBIAN_CALCULATION_TYPE)
15808 CALL flagerror(
"Cannot have no Jacobian calculation for a PETSc nonlinear linesearch solver.", &
15811 solver_jacobian%UPDATE_MATRIX=.true.
15813 CALL petsc_snessetjacobian(linesearch_solver%snes,jacobian_matrix%PETSC%MATRIX, &
15814 & jacobian_matrix%PETSC%MATRIX,problem_solverjacobianevaluatepetsc, &
15815 & linesearch_solver%QUASI_NEWTON_SOLVER%NONLINEAR_SOLVER%SOLVER,err,error,*999)
15817 solver_jacobian%UPDATE_MATRIX=.false.
15818 CALL distributed_matrix_form(jacobian_matrix,err,error,*999)
15819 SELECT CASE(solver_equations%SPARSITY_TYPE)
15821 CALL petsc_matcoloringcreate(jacobian_matrix%PETSC%MATRIX,linesearch_solver%jacobianMatColoring, &
15823 CALL petsc_matcoloringsettype(linesearch_solver%jacobianMatColoring,petsc_matcoloring_sl, &
15825 CALL petsc_matcoloringsetfromoptions(linesearch_solver%jacobianMatColoring,err,error,*999)
15826 CALL petsc_matcoloringapply(linesearch_solver%jacobianMatColoring,linesearch_solver% &
15827 & jacobianiscoloring,err,error,*999)
15828 CALL petsc_matcoloringdestroy(linesearch_solver%jacobianMatColoring,err,error,*999)
15829 CALL petsc_matfdcoloringcreate(jacobian_matrix%PETSC%MATRIX,linesearch_solver% &
15830 & jacobianiscoloring,linesearch_solver%jacobianMatFDColoring,err,error,*999)
15831 CALL petsc_matfdcoloringsetfunction(linesearch_solver%jacobianMatFDColoring, &
15832 & problem_solverresidualevaluatepetsc,linesearch_solver%QUASI_NEWTON_SOLVER%NONLINEAR_SOLVER% &
15833 & solver,err,error,*999)
15834 CALL petsc_matfdcoloringsetfromoptions(linesearch_solver%jacobianMatFDColoring,err,error,*999)
15835 CALL petsc_matfdcoloringsetup(jacobian_matrix%PETSC%MATRIX,linesearch_solver% &
15836 & jacobianiscoloring,linesearch_solver%jacobianMatFDColoring,err,error,*999)
15837 CALL petsc_iscoloringdestroy(linesearch_solver%jacobianISColoring,err,error,*999)
15841 local_error=
"The specified solver equations sparsity type of "// &
15842 & trim(numbertovstring(solver_equations%SPARSITY_TYPE,
"*",err,error))//
" is invalid." 15843 CALL flagerror(local_error,err,error,*999)
15845 CALL petsc_snessetjacobian(linesearch_solver%snes,jacobian_matrix%PETSC%MATRIX, &
15846 & jacobian_matrix%PETSC%MATRIX,problem_solverjacobianfdcalculatepetsc,linesearch_solver% &
15847 & quasi_newton_solver%NONLINEAR_SOLVER%SOLVER,err,error,*999)
15849 local_error=
"The Jacobian calculation type of "// &
15850 & trim(numbertovstring(quasi_newton_solver%JACOBIAN_CALCULATION_TYPE,
"*",err,error))// &
15852 CALL flagerror(local_error,err,error,*999)
15855 CALL flagerror(
"Jacobian matrix PETSc is not associated.",err,error,*999)
15858 CALL flagerror(
"Solver Jacobian matrix is not associated.",err,error,*999)
15861 CALL flagerror(
"The solver Jacobian is not associated.",err,error,*999)
15864 local_error=
"Invalid number of solver matrices. The number of solver matrices is "// &
15865 & trim(numbertovstring(solver_matrices%NUMBER_OF_MATRICES,
"*",err,error))//
" and it should be 1." 15866 CALL flagerror(local_error,err,error,*999)
15871 CALL petsc_snesmonitorset(linesearch_solver%snes,problem_solvernonlinearmonitorpetsc, &
15872 & linesearch_solver%QUASI_NEWTON_SOLVER%NONLINEAR_SOLVER%SOLVER,err,error,*999)
15874 CALL petsc_snesgetlinesearch(linesearch_solver%snes,linesearch_solver%snesLineSearch,err,error,*999)
15876 SELECT CASE(linesearch_solver%linesearch_type)
15878 CALL petsc_sneslinesearchsettype(linesearch_solver%snesLineSearch,petsc_snes_linesearch_basic,err,error,*999)
15880 CALL petsc_sneslinesearchsettype(linesearch_solver%snesLineSearch,petsc_snes_linesearch_l2,err,error,*999)
15882 CALL petsc_sneslinesearchsettype(linesearch_solver%snesLineSearch,petsc_snes_linesearch_cp,err,error,*999)
15884 local_error=
"The nonlinear Quasi-Newton line search type of "// &
15885 & trim(numbertovstring(linesearch_solver%linesearch_type,
"*",err,error))//
" is invalid." 15886 CALL flagerror(local_error,err,error,*999)
15889 CALL petsc_sneslinesearchsettolerances(linesearch_solver%snesLineSearch, &
15890 & linesearch_solver%LINESEARCH_STEPTOLERANCE,linesearch_solver%LINESEARCH_MAXSTEP, &
15891 & petsc_default_real,petsc_default_real,petsc_default_real, &
15892 & petsc_default_integer,err,error,*999)
15893 IF(linesearch_solver%linesearchMonitorOutput)
THEN 15894 CALL petsc_sneslinesearchsetmonitor(linesearch_solver%snesLineSearch,petsc_true,err,error,*999)
15896 CALL petsc_sneslinesearchsetmonitor(linesearch_solver%snesLineSearch,petsc_false,err,error,*999)
15899 CALL petsc_snessettolerances(linesearch_solver%snes,quasi_newton_solver%ABSOLUTE_TOLERANCE, &
15900 & quasi_newton_solver%RELATIVE_TOLERANCE,quasi_newton_solver%SOLUTION_TOLERANCE, &
15901 & quasi_newton_solver%MAXIMUM_NUMBER_OF_ITERATIONS, &
15902 & quasi_newton_solver%MAXIMUM_NUMBER_OF_FUNCTION_EVALUATIONS,err,error,*999)
15904 CALL petsc_snessetfromoptions(linesearch_solver%snes,err,error,*999)
15906 CALL flagerror(
"Quasi-Newton linesearch solver linear solver is not associated.",err,error,*999)
15909 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
15912 local_error=
"The solver library type of "// &
15913 & trim(numbertovstring(linesearch_solver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid." 15914 CALL flagerror(local_error,err,error,*999)
15917 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
15920 CALL flagerror(
"Nonlinear solver solver is not associated.",err,error,*999)
15923 CALL flagerror(
"Quasi-Newton solver nonlinear solver is not associated.",err,error,*999)
15926 CALL flagerror(
"Linesearch solver Quasi-Newton solver is not associated.",err,error,*999)
15929 CALL flagerror(
"Line search solver is not associated.",err,error,*999)
15932 exits(
"Solver_QuasiNewtonLinesearchCreateFinish")
15934 999 errorsexits(
"Solver_QuasiNewtonLinesearchCreateFinish",err,error)
15947 TYPE(quasi_newton_linesearch_solver_type),
POINTER :: linesearchSolver
15948 INTEGER(INTG),
INTENT(OUT) :: err
15949 TYPE(varying_string),
INTENT(OUT) :: error
15952 enters(
"Solver_QuasiNewtonLinesearchFinalise",err,error,*999)
15954 IF(
ASSOCIATED(linesearchsolver))
THEN 15955 CALL petsc_iscoloringfinalise(linesearchsolver%jacobianISColoring,err,error,*999)
15956 CALL petsc_matcoloringfinalise(linesearchsolver%jacobianMatColoring,err,error,*999)
15957 CALL petsc_matfdcoloringfinalise(linesearchsolver%jacobianMatFDColoring,err,error,*999)
15958 CALL petsc_sneslinesearchfinalise(linesearchsolver%snesLineSearch,err,error,*999)
15959 CALL petsc_snesfinalise(linesearchsolver%snes,err,error,*999)
15960 DEALLOCATE(linesearchsolver)
15963 exits(
"Solver_QuasiNewtonLinesearchFinalise")
15965 999 errorsexits(
"Solver_QuasiNewtonLinesearchFinalise",err,error)
15978 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
15979 INTEGER(INTG),
INTENT(OUT) :: ERR
15980 TYPE(varying_string),
INTENT(OUT) :: ERROR
15982 INTEGER(INTG) :: DUMMY_ERR
15983 TYPE(varying_string) :: DUMMY_ERROR
15985 enters(
"SOLVER_QUASI_NEWTON_LINESEARCH_INITIALISE",err,error,*998)
15987 IF(
ASSOCIATED(quasi_newton_solver))
THEN 15988 IF(
ASSOCIATED(quasi_newton_solver%LINESEARCH_SOLVER))
THEN 15989 CALL flagerror(
"Quasi-Newton line search solver is already associated for this Quasi-Newton solver.",err,error,*998)
15992 ALLOCATE(quasi_newton_solver%LINESEARCH_SOLVER,stat=err)
15993 IF(err/=0)
CALL flagerror(
"Could not allocate nonlinear solver Quasi-Newton line search solver.",err,error,*999)
15994 quasi_newton_solver%LINESEARCH_SOLVER%QUASI_NEWTON_SOLVER=>quasi_newton_solver
15996 quasi_newton_solver%LINESEARCH_SOLVER%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
15998 quasi_newton_solver%LINESEARCH_SOLVER%LINESEARCH_MAXSTEP=1.0e8_dp
15999 quasi_newton_solver%LINESEARCH_SOLVER%LINESEARCH_STEPTOLERANCE=convergence_tolerance
16000 CALL petsc_matcoloringinitialise(quasi_newton_solver%LINESEARCH_SOLVER%jacobianMatColoring,err,error,*999)
16001 CALL petsc_iscoloringinitialise(quasi_newton_solver%LINESEARCH_SOLVER%jacobianISColoring,err,error,*999)
16002 CALL petsc_matfdcoloringinitialise(quasi_newton_solver%LINESEARCH_SOLVER%jacobianMatFDColoring,err,error,*999)
16003 CALL petsc_snesinitialise(quasi_newton_solver%LINESEARCH_SOLVER%snes,err,error,*999)
16004 CALL petsc_sneslinesearchinitialise(quasi_newton_solver%LINESEARCH_SOLVER%snesLineSearch,err,error,*999)
16005 quasi_newton_solver%LINESEARCH_SOLVER%linesearchMonitorOutput=.false.
16008 CALL flagerror(
"Quasi-Newton solver is not associated.",err,error,*998)
16011 exits(
"SOLVER_QUASI_NEWTON_LINESEARCH_INITIALISE")
16014 998 errorsexits(
"SOLVER_QUASI_NEWTON_LINESEARCH_INITIALISE",err,error)
16027 TYPE(solver_type),
POINTER :: SOLVER
16028 REAL(DP),
INTENT(IN) :: LINESEARCH_MAXSTEP
16029 INTEGER(INTG),
INTENT(OUT) :: ERR
16030 TYPE(varying_string),
INTENT(OUT) :: ERROR
16032 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
16033 TYPE(quasi_newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
16034 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
16035 TYPE(varying_string) :: LOCAL_ERROR
16037 enters(
"SOLVER_QUASI_NEWTON_LINESEARCH_MAXSTEP_SET",err,error,*999)
16039 IF(
ASSOCIATED(solver))
THEN 16040 IF(solver%SOLVER_FINISHED)
THEN 16041 CALL flagerror(
"Solver has already been finished.",err,error,*999)
16044 nonlinear_solver=>solver%NONLINEAR_SOLVER
16045 IF(
ASSOCIATED(nonlinear_solver))
THEN 16047 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
16048 IF(
ASSOCIATED(quasi_newton_solver))
THEN 16050 linesearch_solver=>quasi_newton_solver%LINESEARCH_SOLVER
16051 IF(
ASSOCIATED(linesearch_solver))
THEN 16052 IF(linesearch_maxstep>zero_tolerance)
THEN 16053 linesearch_solver%LINESEARCH_MAXSTEP=linesearch_maxstep
16055 local_error=
"The specified line search maximum step of "// &
16056 & trim(numbertovstring(linesearch_maxstep,
"*",err,error))// &
16057 &
" is invalid. The line search maximum step must be > 0." 16058 CALL flagerror(local_error,err,error,*999)
16061 CALL flagerror(
"The Quasi-Newton solver line search solver is not associated.",err,error,*999)
16064 CALL flagerror(
"The Quasi-Newton solver is not a line search solver.",err,error,*999)
16067 CALL flagerror(
"The nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
16070 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
16073 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
16076 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
16080 CALL flagerror(
"Solver is not associated.",err,error,*999)
16083 exits(
"SOLVER_QUASI_NEWTON_LINESEARCH_MAXSTEP_SET")
16085 999 errorsexits(
"SOLVER_QUASI_NEWTON_LINESEARCH_MAXSTEP_SET",err,error)
16098 TYPE(quasi_newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
16099 INTEGER(INTG),
INTENT(OUT) :: ERR
16100 TYPE(varying_string),
INTENT(OUT) :: ERROR
16103 INTEGER(INTG) :: CONVERGED_REASON,NUMBER_ITERATIONS
16104 REAL(DP) :: FUNCTION_NORM
16105 TYPE(distributed_vector_type),
POINTER :: RHS_VECTOR,SOLVER_VECTOR
16106 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
16107 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
16108 TYPE(petscvectype) :: FUNCTION_VECTOR
16109 TYPE(solver_type),
POINTER :: SOLVER
16110 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
16111 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
16112 TYPE(varying_string) :: LOCAL_ERROR
16114 enters(
"SOLVER_QUASI_NEWTON_LINESEARCH_SOLVE",err,error,*999)
16116 IF(
ASSOCIATED(linesearch_solver))
THEN 16117 quasi_newton_solver=>linesearch_solver%QUASI_NEWTON_SOLVER
16118 IF(
ASSOCIATED(quasi_newton_solver))
THEN 16119 nonlinear_solver=>quasi_newton_solver%NONLINEAR_SOLVER
16120 IF(
ASSOCIATED(nonlinear_solver))
THEN 16121 solver=>nonlinear_solver%SOLVER
16122 IF(
ASSOCIATED(solver))
THEN 16123 solver_equations=>solver%SOLVER_EQUATIONS
16124 IF(
ASSOCIATED(solver_equations))
THEN 16125 solver_matrices=>solver_equations%SOLVER_MATRICES
16126 IF(
ASSOCIATED(solver_matrices))
THEN 16127 IF(solver_matrices%NUMBER_OF_MATRICES==1)
THEN 16128 rhs_vector=>solver_matrices%RHS_VECTOR
16129 IF(
ASSOCIATED(rhs_vector))
THEN 16130 solver_vector=>solver_matrices%MATRICES(1)%PTR%SOLVER_VECTOR
16131 IF(
ASSOCIATED(solver_vector))
THEN 16132 SELECT CASE(linesearch_solver%SOLVER_LIBRARY)
16134 CALL flagerror(
"Not implemented.",err,error,*999)
16136 SELECT CASE(quasi_newton_solver%SOLUTION_INITIALISE_TYPE)
16139 CALL distributed_vector_all_values_set(solver_vector,0.0_dp,err,error,*999)
16146 local_error=
"The Quasi-Newton solver solution initialise type of "// &
16147 & trim(numbertovstring(quasi_newton_solver%SOLUTION_INITIALISE_TYPE,
"*",err,error))// &
16149 CALL flagerror(local_error,err,error,*999)
16152 CALL petsc_snessolve(linesearch_solver%snes,rhs_vector%PETSC%VECTOR,solver_vector%PETSC%VECTOR, &
16155 CALL petsc_snesgetconvergedreason(linesearch_solver%snes,converged_reason,err,error,*999)
16156 SELECT CASE(converged_reason)
16157 CASE(petsc_snes_diverged_function_count)
16158 CALL flag_warning(
"Nonlinear line search solver did not converge. PETSc diverged function count.", &
16160 CASE(petsc_snes_diverged_linear_solve)
16161 CALL flag_warning(
"Nonlinear line search solver did not converge. PETSc diverged linear solve.", &
16163 CASE(petsc_snes_diverged_fnorm_nan)
16164 CALL flag_warning(
"Nonlinear line search solver did not converge. PETSc diverged F Norm NaN.", &
16166 CASE(petsc_snes_diverged_max_it)
16167 CALL flag_warning(
"Nonlinear line search solver did not converge. PETSc diverged maximum iterations.", &
16169 CASE(petsc_snes_diverged_line_search)
16170 CALL flag_warning(
"Nonlinear line search solver did not converge. PETSc diverged line search.", &
16172 CASE(petsc_snes_diverged_local_min)
16173 CALL flag_warning(
"Nonlinear line search solver did not converge. PETSc diverged local minimum.", &
16178 CALL write_string(general_output_type,
"",err,error,*999)
16179 CALL write_string(general_output_type,
"Quasi-Newton linesearch solver parameters:",err,error,*999)
16180 CALL petsc_snesgetiterationnumber(linesearch_solver%snes,number_iterations,err,error,*999)
16181 CALL write_string_value(general_output_type,
"Final number of iterations = ",number_iterations, &
16183 CALL petsc_snesgetfunction(linesearch_solver%snes,function_vector,err,error,*999)
16184 CALL petsc_vecnorm(function_vector,petsc_norm_2,function_norm,err,error,*999)
16185 CALL write_string_value(general_output_type,
"Final function norm = ",function_norm, &
16187 SELECT CASE(converged_reason)
16188 CASE(petsc_snes_converged_fnorm_abs)
16189 CALL write_string(general_output_type,
"Converged Reason = PETSc converged F Norm absolute.", &
16191 CASE(petsc_snes_converged_fnorm_relative)
16192 CALL write_string(general_output_type,
"Converged Reason = PETSc converged F Norm relative.", &
16194 CASE(petsc_snes_converged_its)
16195 CALL write_string(general_output_type,
"Converged Reason = PETSc converged its.",err,error,*999)
16196 CASE(petsc_snes_converged_iterating)
16197 CALL write_string(general_output_type,
"Converged Reason = PETSc converged iterating.",err,error,*999)
16201 local_error=
"The Quasi-Newton line search solver library type of "// &
16202 & trim(numbertovstring(linesearch_solver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid." 16203 CALL flagerror(local_error,err,error,*999)
16206 CALL flagerror(
"Solver vector is not associated.",err,error,*999)
16209 CALL flagerror(
"Solver RHS vector is not associated.",err,error,*999)
16212 local_error=
"The number of solver matrices of "// &
16213 & trim(numbertovstring(solver_matrices%NUMBER_OF_MATRICES,
"*",err,error))// &
16214 &
" is invalid. There should only be one solver matrix for a Quasi-Newton linesearch solver." 16215 CALL flagerror(local_error,err,error,*999)
16218 CALL flagerror(
"Solver matrices is not associated.",err,error,*999)
16221 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
16224 CALL flagerror(
"Nonlinear solver solver is not associated.",err,error,*999)
16227 CALL flagerror(
"Quasi-Newton solver nonlinear solver is not associated.",err,error,*999)
16230 CALL flagerror(
"Linesearch solver Quasi-Newton solver is not associated.",err,error,*999)
16233 CALL flagerror(
"Linesearch solver is not associated.",err,error,*999)
16236 exits(
"SOLVER_QUASI_NEWTON_LINESEARCH_SOLVE")
16238 999 errorsexits(
"SOLVER_QUASI_NEWTON_LINESEARCH_SOLVE",err,error)
16251 TYPE(solver_type),
POINTER :: SOLVER
16252 REAL(DP),
INTENT(IN) :: LINESEARCH_STEPTOL
16253 INTEGER(INTG),
INTENT(OUT) :: ERR
16254 TYPE(varying_string),
INTENT(OUT) :: ERROR
16256 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
16257 TYPE(quasi_newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
16258 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
16259 TYPE(varying_string) :: LOCAL_ERROR
16261 enters(
"SOLVER_QUASI_NEWTON_LINESEARCH_STEPTOL_SET",err,error,*999)
16263 IF(
ASSOCIATED(solver))
THEN 16264 IF(solver%SOLVER_FINISHED)
THEN 16265 CALL flagerror(
"Solver has already been finished.",err,error,*999)
16268 nonlinear_solver=>solver%NONLINEAR_SOLVER
16269 IF(
ASSOCIATED(nonlinear_solver))
THEN 16271 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
16272 IF(
ASSOCIATED(quasi_newton_solver))
THEN 16274 linesearch_solver=>quasi_newton_solver%LINESEARCH_SOLVER
16275 IF(
ASSOCIATED(linesearch_solver))
THEN 16276 IF(linesearch_steptol>zero_tolerance)
THEN 16277 linesearch_solver%LINESEARCH_STEPTOLERANCE=linesearch_steptol
16279 local_error=
"The specified line search step tolerance of "// &
16280 & trim(numbertovstring(linesearch_steptol,
"*",err,error))// &
16281 &
" is invalid. The line search step tolerance must be > 0." 16282 CALL flagerror(local_error,err,error,*999)
16285 CALL flagerror(
"The Quasi-Newton solver line search solver is not associated.",err,error,*999)
16288 CALL flagerror(
"The Quasi-Newton solver is not a line search solver.",err,error,*999)
16291 CALL flagerror(
"The nonlinear Quasi-Newton solver is not associated.",err,error,*999)
16294 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
16297 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
16300 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
16304 CALL flagerror(
"Solver is not associated.",err,error,*999)
16307 exits(
"SOLVER_QUASI_NEWTON_LINESEARCH_STEPTOL_SET")
16309 999 errorsexits(
"SOLVER_QUASI_NEWTON_LINESEARCH_STEPTOL_SET",err,error)
16322 TYPE(solver_type),
POINTER :: SOLVER
16323 INTEGER(INTG),
INTENT(IN) :: LINESEARCH_TYPE
16324 INTEGER(INTG),
INTENT(OUT) :: ERR
16325 TYPE(varying_string),
INTENT(OUT) :: ERROR
16327 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
16328 TYPE(quasi_newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
16329 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
16330 TYPE(varying_string) :: LOCAL_ERROR
16332 enters(
"SOLVER_QUASI_NEWTON_LINESEARCH_TYPE_SET",err,error,*999)
16334 IF(
ASSOCIATED(solver))
THEN 16335 IF(solver%SOLVER_FINISHED)
THEN 16336 CALL flagerror(
"Solver has already been finished.",err,error,*999)
16339 nonlinear_solver=>solver%NONLINEAR_SOLVER
16340 IF(
ASSOCIATED(nonlinear_solver))
THEN 16342 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
16343 IF(
ASSOCIATED(quasi_newton_solver))
THEN 16345 linesearch_solver=>quasi_newton_solver%LINESEARCH_SOLVER
16346 IF(
ASSOCIATED(linesearch_solver))
THEN 16347 SELECT CASE(linesearch_type)
16355 local_error=
"The specified line search type of "//trim(numbertovstring(linesearch_type,
"*",err,error))// &
16357 CALL flagerror(local_error,err,error,*999)
16360 CALL flagerror(
"The Quasi-Newton solver line search solver is not associated.",err,error,*999)
16363 CALL flagerror(
"The Quasi-Newton solver is not a line search solver.",err,error,*999)
16366 CALL flagerror(
"The nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
16369 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
16372 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
16375 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
16379 CALL flagerror(
"Solver is not associated.",err,error,*999)
16382 exits(
"SOLVER_QUASI_NEWTON_LINESEARCH_TYPE_SET")
16384 999 errorsexits(
"SOLVER_QUASI_NEWTON_LINESEARCH_TYPE_SET",err,error)
16397 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
16398 INTEGER(INTG),
INTENT(OUT) :: MATRICES_LIBRARY_TYPE
16399 INTEGER(INTG),
INTENT(OUT) :: ERR
16400 TYPE(varying_string),
INTENT(OUT) :: ERROR
16402 TYPE(quasi_newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
16403 TYPE(quasi_newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
16404 TYPE(varying_string) :: LOCAL_ERROR
16406 enters(
"SOLVER_QUASI_NEWTON_LIBRARY_TYPE_GET",err,error,*999)
16408 IF(
ASSOCIATED(quasi_newton_solver))
THEN 16409 SELECT CASE(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE)
16411 linesearch_solver=>quasi_newton_solver%LINESEARCH_SOLVER
16412 IF(
ASSOCIATED(linesearch_solver))
THEN 16413 matrices_library_type=linesearch_solver%SOLVER_MATRICES_LIBRARY
16415 CALL flagerror(
"Quasi-Newton line search solver is not associated.",err,error,*999)
16418 trustregion_solver=>quasi_newton_solver%TRUSTREGION_SOLVER
16419 IF(
ASSOCIATED(trustregion_solver))
THEN 16420 matrices_library_type=trustregion_solver%SOLVER_MATRICES_LIBRARY
16422 CALL flagerror(
"Quasi-Newton trust region solver is not associated.",err,error,*999)
16425 local_error=
"The Quasi-Newton solver type of "// &
16426 & trim(numbertovstring(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE,
"*",err,error))//
" is invalid." 16427 CALL flagerror(local_error,err,error,*999)
16430 CALL flagerror(
"Quasi-Newton solver is not associated.",err,error,*999)
16433 exits(
"Solver_QuasiNewtonMatricesLibraryTypeGet")
16435 999 errorsexits(
"Solver_QuasiNewtonMatricesLibraryTypeGet",err,error)
16448 TYPE(solver_type),
POINTER :: SOLVER
16449 INTEGER(INTG),
INTENT(IN) :: MAXIMUM_FUNCTION_EVALUATIONS
16450 INTEGER(INTG),
INTENT(OUT) :: ERR
16451 TYPE(varying_string),
INTENT(OUT) :: ERROR
16453 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
16454 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
16455 TYPE(varying_string) :: LOCAL_ERROR
16457 enters(
"Solver_QuasiNewtonMaximumFunctionEvaluationsSet",err,error,*999)
16459 IF(
ASSOCIATED(solver))
THEN 16460 IF(solver%SOLVER_FINISHED)
THEN 16461 CALL flagerror(
"Solver has already been finished.",err,error,*999)
16464 nonlinear_solver=>solver%NONLINEAR_SOLVER
16465 IF(
ASSOCIATED(nonlinear_solver))
THEN 16467 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
16468 IF(
ASSOCIATED(quasi_newton_solver))
THEN 16469 IF(maximum_function_evaluations>0)
THEN 16470 quasi_newton_solver%MAXIMUM_NUMBER_OF_FUNCTION_EVALUATIONS=maximum_function_evaluations
16472 local_error=
"The specified maximum number of function evaluations of "// &
16473 & trim(numbertovstring(maximum_function_evaluations,
"*",err,error))// &
16474 &
" is invalid. The maximum number of function evaluations must be > 0." 16475 CALL flagerror(local_error,err,error,*999)
16478 CALL flagerror(
"The nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
16481 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
16484 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
16487 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
16491 CALL flagerror(
"Solver is not associated.",err,error,*999)
16494 exits(
"Solver_QuasiNewtonMaximumFunctionEvaluationsSet")
16496 999 errors(
"Solver_QuasiNewtonMaximumFunctionEvaluationsSet",err,error)
16497 exits(
"Solver_QuasiNewtonMaximumFunctionEvaluationsSet")
16510 TYPE(solver_type),
POINTER :: SOLVER
16511 INTEGER(INTG),
INTENT(IN) :: MAXIMUM_ITERATIONS
16512 INTEGER(INTG),
INTENT(OUT) :: ERR
16513 TYPE(varying_string),
INTENT(OUT) :: ERROR
16515 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
16516 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
16517 TYPE(varying_string) :: LOCAL_ERROR
16519 enters(
"SOLVER_QUASI_NEWTON_MAXIMUM_ITERATIONS_SET",err,error,*999)
16521 IF(
ASSOCIATED(solver))
THEN 16522 IF(solver%SOLVER_FINISHED)
THEN 16523 CALL flagerror(
"Solver has already been finished.",err,error,*999)
16526 nonlinear_solver=>solver%NONLINEAR_SOLVER
16527 IF(
ASSOCIATED(nonlinear_solver))
THEN 16529 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
16530 IF(
ASSOCIATED(quasi_newton_solver))
THEN 16531 IF(maximum_iterations>0)
THEN 16532 quasi_newton_solver%MAXIMUM_NUMBER_OF_ITERATIONS=maximum_iterations
16534 local_error=
"The specified maximum iterations of "//trim(numbertovstring(maximum_iterations,
"*",err,error))// &
16535 &
" is invalid. The maximum number of iterations must be > 0." 16536 CALL flagerror(local_error,err,error,*999)
16539 CALL flagerror(
"Nonlinear sovler Quasi-Newton solver is not associated.",err,error,*999)
16542 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
16545 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
16548 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
16552 CALL flagerror(
"Solver is not associated.",err,error,*999)
16555 exits(
"SOLVER_QUASI_NEWTON_MAXIMUM_ITERATIONS_SET")
16557 999 errorsexits(
"SOLVER_QUASI_NEWTON_MAXIMUM_ITERATIONS_SET",err,error)
16570 TYPE(solver_type),
POINTER :: SOLVER
16571 REAL(DP),
INTENT(IN) :: RELATIVE_TOLERANCE
16572 INTEGER(INTG),
INTENT(OUT) :: ERR
16573 TYPE(varying_string),
INTENT(OUT) :: ERROR
16575 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
16576 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
16577 TYPE(varying_string) :: LOCAL_ERROR
16579 enters(
"SOLVER_QUASI_NEWTON_RELATIVE_TOLERANCE_SET",err,error,*999)
16581 IF(
ASSOCIATED(solver))
THEN 16582 IF(solver%SOLVER_FINISHED)
THEN 16583 CALL flagerror(
"Solver has already been finished.",err,error,*999)
16586 nonlinear_solver=>solver%NONLINEAR_SOLVER
16587 IF(
ASSOCIATED(nonlinear_solver))
THEN 16589 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
16590 IF(
ASSOCIATED(quasi_newton_solver))
THEN 16591 IF(relative_tolerance>zero_tolerance)
THEN 16592 quasi_newton_solver%RELATIVE_TOLERANCE=relative_tolerance
16594 local_error=
"The specified relative tolerance of "//trim(numbertovstring(relative_tolerance,
"*",err,error))// &
16595 &
" is invalid. The relative tolerance must be > 0." 16596 CALL flagerror(local_error,err,error,*999)
16599 CALL flagerror(
"The nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
16602 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
16605 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
16608 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
16612 CALL flagerror(
"Solver is not associated.",err,error,*999)
16615 exits(
"SOLVER_QUASI_NEWTON_RELATIVE_TOLERANCE_SET")
16617 999 errorsexits(
"SOLVER_QUASI_NEWTON_RELATIVE_TOLERANCE_SET",err,error)
16630 TYPE(solver_type),
POINTER :: SOLVER
16631 INTEGER(INTG),
INTENT(IN) :: SOLUTION_INITIALISE_TYPE
16632 INTEGER(INTG),
INTENT(OUT) :: ERR
16633 TYPE(varying_string),
INTENT(OUT) :: ERROR
16635 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
16636 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
16637 TYPE(varying_string) :: LOCAL_ERROR
16639 enters(
"SOLVER_NONLINAR_QUASI_NEWTON_SOLUTION_INIT_TYPE_SET",err,error,*999)
16641 IF(
ASSOCIATED(solver))
THEN 16642 IF(solver%SOLVER_FINISHED)
THEN 16643 CALL flagerror(
"Solver has already been finished.",err,error,*999)
16646 nonlinear_solver=>solver%NONLINEAR_SOLVER
16647 IF(
ASSOCIATED(nonlinear_solver))
THEN 16649 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
16650 IF(
ASSOCIATED(quasi_newton_solver))
THEN 16651 SELECT CASE(solution_initialise_type)
16659 local_error=
"The specified solution initialise type of "// &
16660 & trim(numbertovstring(solution_initialise_type,
"*",err,error))//
" is invalid." 16661 CALL flagerror(local_error,err,error,*999)
16664 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
16667 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
16670 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
16673 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
16677 CALL flagerror(
"Solver is not associated.",err,error,*999)
16680 exits(
"SOLVER_QUASI_NEWTON_SOLUTION_INIT_TYPE_SET")
16682 999 errorsexits(
"SOLVER_QUASI_NEWTON_SOLUTION_INIT_TYPE_SET",err,error)
16695 TYPE(solver_type),
POINTER :: SOLVER
16696 REAL(DP),
INTENT(IN) :: SOLUTION_TOLERANCE
16697 INTEGER(INTG),
INTENT(OUT) :: ERR
16698 TYPE(varying_string),
INTENT(OUT) :: ERROR
16700 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
16701 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
16702 TYPE(varying_string) :: LOCAL_ERROR
16704 enters(
"SOLVER_QUASI_NEWTON_SOLUTION_TOLERANCE_SET",err,error,*999)
16706 IF(
ASSOCIATED(solver))
THEN 16707 IF(solver%SOLVER_FINISHED)
THEN 16708 CALL flagerror(
"Solver has already been finished.",err,error,*999)
16711 nonlinear_solver=>solver%NONLINEAR_SOLVER
16712 IF(
ASSOCIATED(nonlinear_solver))
THEN 16714 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
16715 IF(
ASSOCIATED(quasi_newton_solver))
THEN 16716 IF(solution_tolerance>zero_tolerance)
THEN 16717 quasi_newton_solver%SOLUTION_TOLERANCE=solution_tolerance
16719 local_error=
"The specified solution tolerance of "//trim(numbertovstring(solution_tolerance,
"*",err,error))// &
16720 &
" is invalid. The relative tolerance must be > 0." 16721 CALL flagerror(local_error,err,error,*999)
16724 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
16727 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
16730 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
16733 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
16737 CALL flagerror(
"Solver is not associated.",err,error,*999)
16740 exits(
"SOLVER_QUASI_NEWTON_SOLUTION_TOLERANCE_SET")
16742 999 errorsexits(
"SOLVER_QUASI_NEWTON_SOLUTION_TOLERANCE_SET",err,error)
16755 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
16756 INTEGER(INTG),
INTENT(OUT) :: ERR
16757 TYPE(varying_string),
INTENT(OUT) :: ERROR
16759 TYPE(varying_string) :: LOCAL_ERROR
16761 enters(
"SOLVER_QUASI_NEWTON_SOLVE",err,error,*999)
16763 IF(
ASSOCIATED(quasi_newton_solver))
THEN 16764 SELECT CASE(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE)
16770 local_error=
"The nonlinear solver type of "// &
16771 & trim(numbertovstring(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE,
"*",err,error))//
" is invalid." 16772 CALL flagerror(local_error,err,error,*999)
16775 CALL flagerror(
"Quasi-Newton solver is not associated.",err,error,*999)
16778 exits(
"SOLVER_QUASI_NEWTON_SOLVE")
16780 999 errorsexits(
"SOLVER_QUASI_NEWTON_SOLVE",err,error)
16793 TYPE(quasi_newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
16794 INTEGER(INTG),
INTENT(OUT) :: ERR
16795 TYPE(varying_string),
INTENT(OUT) :: ERROR
16797 EXTERNAL :: problem_solverresidualevaluatepetsc
16798 INTEGER(INTG) :: equations_matrix_idx,equations_set_idx
16799 TYPE(distributed_vector_type),
POINTER :: RESIDUAL_VECTOR
16800 TYPE(equations_type),
POINTER :: EQUATIONS
16801 TYPE(equations_mapping_type),
POINTER :: EQUATIONS_MAPPING
16802 TYPE(equations_mapping_linear_type),
POINTER :: LINEAR_MAPPING
16803 TYPE(equations_matrices_type),
POINTER :: EQUATIONS_MATRICES
16804 TYPE(equations_matrices_linear_type),
POINTER :: LINEAR_MATRICES
16805 TYPE(equations_matrix_type),
POINTER :: EQUATIONS_MATRIX
16806 TYPE(equations_set_type),
POINTER :: EQUATIONS_SET
16807 TYPE(field_type),
POINTER :: DEPENDENT_FIELD
16808 TYPE(field_variable_type),
POINTER :: LINEAR_VARIABLE
16809 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
16810 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
16811 TYPE(solver_type),
POINTER :: SOLVER
16812 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
16813 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
16814 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
16815 TYPE(varying_string) :: LOCAL_ERROR
16817 enters(
"Solver_QuasiNewtonTrustRegionCreateFinish",err,error,*999)
16819 IF(
ASSOCIATED(trustregion_solver))
THEN 16820 quasi_newton_solver=>trustregion_solver%QUASI_NEWTON_SOLVER
16821 IF(
ASSOCIATED(quasi_newton_solver))
THEN 16822 nonlinear_solver=>quasi_newton_solver%NONLINEAR_SOLVER
16823 IF(
ASSOCIATED(nonlinear_solver))
THEN 16824 solver=>nonlinear_solver%SOLVER
16825 IF(
ASSOCIATED(solver))
THEN 16826 solver_equations=>solver%SOLVER_EQUATIONS
16827 IF(
ASSOCIATED(solver_equations))
THEN 16828 SELECT CASE(trustregion_solver%SOLVER_LIBRARY)
16830 CALL flagerror(
"Not implemented.",err,error,*999)
16832 solver_mapping=>solver_equations%SOLVER_MAPPING
16833 IF(
ASSOCIATED(solver_mapping))
THEN 16835 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
16836 equations=>solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)%EQUATIONS
16837 IF(
ASSOCIATED(equations))
THEN 16838 equations_set=>equations%EQUATIONS_SET
16839 IF(
ASSOCIATED(equations_set))
THEN 16840 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
16841 IF(
ASSOCIATED(dependent_field))
THEN 16842 equations_mapping=>equations%EQUATIONS_MAPPING
16843 IF(
ASSOCIATED(equations_mapping))
THEN 16844 linear_mapping=>equations_mapping%LINEAR_MAPPING
16845 IF(
ASSOCIATED(linear_mapping))
THEN 16847 equations_matrices=>equations%EQUATIONS_MATRICES
16848 IF(
ASSOCIATED(equations_matrices))
THEN 16849 linear_matrices=>equations_matrices%LINEAR_MATRICES
16850 IF(
ASSOCIATED(linear_matrices))
THEN 16851 DO equations_matrix_idx=1,linear_matrices%NUMBER_OF_LINEAR_MATRICES
16852 equations_matrix=>linear_matrices%MATRICES(equations_matrix_idx)%PTR
16853 IF(
ASSOCIATED(equations_matrix))
THEN 16854 IF(.NOT.
ASSOCIATED(equations_matrix%TEMP_VECTOR))
THEN 16855 linear_variable=>linear_mapping%EQUATIONS_MATRIX_TO_VAR_MAPS(equations_matrix_idx)%VARIABLE
16856 IF(
ASSOCIATED(linear_variable))
THEN 16857 CALL distributed_vector_create_start(linear_variable%DOMAIN_MAPPING, &
16858 & equations_matrix%TEMP_VECTOR,err,error,*999)
16859 CALL distributed_vector_data_type_set(equations_matrix%TEMP_VECTOR, &
16860 & distributed_matrix_vector_dp_type,err,error,*999)
16861 CALL distributed_vector_create_finish(equations_matrix%TEMP_VECTOR,err,error,*999)
16863 CALL flagerror(
"Linear mapping linear variable is not associated.",err,error,*999)
16867 CALL flagerror(
"Equations matrix is not associated.",err,error,*999)
16871 CALL flagerror(
"Equations matrices linear matrices is not associated.",err,error,*999)
16874 CALL flagerror(
"Equations equations matrices is not associated.",err,error,*999)
16878 CALL flagerror(
"Equations equations mapping is not associated.",err,error,*999)
16881 local_error=
"Equations set dependent field is not associated for equations set index "// &
16882 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 16883 CALL flagerror(local_error,err,error,*999)
16886 local_error=
"Equations equations set is not associated for equations set index "// &
16887 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 16888 CALL flagerror(local_error,err,error,*999)
16891 local_error=
"Equations is not associated for equations set index "// &
16892 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 16893 CALL flagerror(local_error,err,error,*999)
16898 CALL solver_matrices_create_start(solver_equations,solver_matrices,err,error,*999)
16901 CALL solver_matrices_create_finish(solver_matrices,err,error,*999)
16903 CALL petsc_snescreate(computational_environment%MPI_COMM,trustregion_solver%snes,err,error,*999)
16905 CALL petsc_snessettype(trustregion_solver%snes,petsc_snesnewtontr,err,error,*999)
16907 residual_vector=>solver_matrices%RESIDUAL
16908 IF(
ASSOCIATED(residual_vector))
THEN 16909 IF(
ASSOCIATED(residual_vector%PETSC))
THEN 16910 CALL petsc_snessetfunction(trustregion_solver%snes,residual_vector%PETSC%VECTOR, &
16911 & problem_solverresidualevaluatepetsc,solver,err,error,*999)
16912 CALL flagerror(
"The residual vector PETSc is not associated.",err,error,*999)
16915 CALL flagerror(
"Solver matrices residual vector is not associated.",err,error,*999)
16921 CALL petsc_snessettrustregiontolerance(trustregion_solver%snes,trustregion_solver%TRUSTREGION_TOLERANCE, &
16924 CALL petsc_snessettolerances(trustregion_solver%snes,quasi_newton_solver%ABSOLUTE_TOLERANCE, &
16925 & quasi_newton_solver%RELATIVE_TOLERANCE,quasi_newton_solver%SOLUTION_TOLERANCE, &
16926 & quasi_newton_solver%MAXIMUM_NUMBER_OF_ITERATIONS,quasi_newton_solver%MAXIMUM_NUMBER_OF_FUNCTION_EVALUATIONS, &
16929 CALL petsc_snessetfromoptions(trustregion_solver%snes,err,error,*999)
16931 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
16934 local_error=
"The solver library type of "// &
16935 & trim(numbertovstring(trustregion_solver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid." 16936 CALL flagerror(local_error,err,error,*999)
16939 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
16942 CALL flagerror(
"Nonlinear solver solver is not associated.",err,error,*999)
16945 CALL flagerror(
"Quasi-Newton solver nonlinear solver is not associated.",err,error,*999)
16948 CALL flagerror(
"Trust region Quasi-Newton solver is not associated.",err,error,*999)
16951 CALL flagerror(
"Trust region solver is not associated.",err,error,*999)
16954 exits(
"Solver_QuasiNewtonTrustRegionCreateFinish")
16956 999 errorsexits(
"Solver_QuasiNewtonTrustRegionCreateFinish",err,error)
16969 TYPE(solver_type),
POINTER :: SOLVER
16970 REAL(DP),
INTENT(IN) :: TRUSTREGION_DELTA0
16971 INTEGER(INTG),
INTENT(OUT) :: ERR
16972 TYPE(varying_string),
INTENT(OUT) :: ERROR
16974 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
16975 TYPE(quasi_newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
16976 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
16977 TYPE(varying_string) :: LOCAL_ERROR
16979 enters(
"SOLVER_QUASI_NEWTON_TRUSTREGION_DELTA0_SET",err,error,*999)
16981 IF(
ASSOCIATED(solver))
THEN 16982 IF(solver%SOLVER_FINISHED)
THEN 16983 CALL flagerror(
"Solver has already been finished.",err,error,*999)
16986 nonlinear_solver=>solver%NONLINEAR_SOLVER
16987 IF(
ASSOCIATED(nonlinear_solver))
THEN 16989 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
16990 IF(
ASSOCIATED(quasi_newton_solver))
THEN 16992 trustregion_solver=>quasi_newton_solver%TRUSTREGION_SOLVER
16993 IF(
ASSOCIATED(trustregion_solver))
THEN 16994 IF(trustregion_delta0>zero_tolerance)
THEN 16995 trustregion_solver%TRUSTREGION_DELTA0=trustregion_delta0
16997 local_error=
"The specified trust region delta0 of "// &
16998 & trim(numbertovstring(trustregion_delta0,
"*",err,error))// &
16999 &
" is invalid. The trust region delta0 must be > 0." 17000 CALL flagerror(local_error,err,error,*999)
17003 CALL flagerror(
"The Quasi-Newton solver trust region solver is not associated.",err,error,*999)
17006 CALL flagerror(
"The Quasi-Newton solver is not a trust region solver.",err,error,*999)
17009 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
17012 CALL flagerror(
"Nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
17015 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
17018 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
17022 CALL flagerror(
"Solver is not associated.",err,error,*999)
17025 exits(
"SOLVER_QUASI_NEWTON_TRUSTREGION_DELTA0_SET")
17027 999 errorsexits(
"SOLVER_QUASI_NEWTON_TRUSTREGION_DELTA0_SET",err,error)
17040 TYPE(quasi_newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
17041 INTEGER(INTG),
INTENT(OUT) :: ERR
17042 TYPE(varying_string),
INTENT(OUT) :: ERROR
17045 enters(
"SOLVER_QUASI_NEWTON_TRUSTREGION_FINALISE",err,error,*999)
17047 IF(
ASSOCIATED(trustregion_solver))
THEN 17048 CALL petsc_snesfinalise(trustregion_solver%snes,err,error,*999)
17049 DEALLOCATE(trustregion_solver)
17052 exits(
"SOLVER_QUASI_NEWTON_TRUSTREGION_FINALISE")
17054 999 errorsexits(
"SOLVER_QUASI_NEWTON_TRUSTREGION_FINALISE",err,error)
17067 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
17068 INTEGER(INTG),
INTENT(OUT) :: ERR
17069 TYPE(varying_string),
INTENT(OUT) :: ERROR
17071 INTEGER(INTG) :: DUMMY_ERR
17072 TYPE(varying_string) :: DUMMY_ERROR
17074 enters(
"SOLVER_QUASI_NEWTON_TRUSTREGION_INITIALISE",err,error,*998)
17076 IF(
ASSOCIATED(quasi_newton_solver))
THEN 17077 IF(
ASSOCIATED(quasi_newton_solver%TRUSTREGION_SOLVER))
THEN 17078 CALL flagerror(
"Trust region solver is already associated for this nonlinear solver.",err,error,*998)
17080 ALLOCATE(quasi_newton_solver%TRUSTREGION_SOLVER,stat=err)
17081 IF(err/=0)
CALL flagerror(
"Could not allocate Quasi-Newton solver trust region solver.",err,error,*999)
17082 quasi_newton_solver%TRUSTREGION_SOLVER%QUASI_NEWTON_SOLVER=>quasi_newton_solver
17084 quasi_newton_solver%TRUSTREGION_SOLVER%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
17086 quasi_newton_solver%TRUSTREGION_SOLVER%TRUSTREGION_DELTA0=0.01_dp
17087 CALL petsc_snesinitialise(quasi_newton_solver%TRUSTREGION_SOLVER%snes,err,error,*999)
17090 CALL flagerror(
"Quasi-Newton solver is not associated.",err,error,*998)
17093 exits(
"SOLVER_QUASI_NEWTON_TRUSTREGION_INITIALISE")
17096 998 errorsexits(
"SOLVER_QUASI_NEWTON_TRUSTREGION_INITIALISE",err,error)
17109 TYPE(quasi_newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
17110 INTEGER(INTG),
INTENT(OUT) :: ERR
17111 TYPE(varying_string),
INTENT(OUT) :: ERROR
17113 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
17114 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
17115 TYPE(solver_type),
POINTER :: SOLVER
17116 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
17117 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
17118 TYPE(varying_string) :: LOCAL_ERROR
17120 enters(
"SOLVER_QUASI_NEWTON_TRUSTREGION_SOLVE",err,error,*999)
17122 IF(
ASSOCIATED(trustregion_solver))
THEN 17123 quasi_newton_solver=>trustregion_solver%QUASI_NEWTON_SOLVER
17124 IF(
ASSOCIATED(quasi_newton_solver))
THEN 17125 nonlinear_solver=>quasi_newton_solver%NONLINEAR_SOLVER
17126 IF(
ASSOCIATED(nonlinear_solver))
THEN 17127 solver=>nonlinear_solver%SOLVER
17128 IF(
ASSOCIATED(solver))
THEN 17129 solver_equations=>solver%SOLVER_EQUATIONS
17130 IF(
ASSOCIATED(solver_equations))
THEN 17131 solver_matrices=>solver_equations%SOLVER_MATRICES
17132 IF(
ASSOCIATED(solver_matrices))
THEN 17133 SELECT CASE(trustregion_solver%SOLVER_LIBRARY)
17135 CALL flagerror(
"Not implemented.",err,error,*999)
17137 CALL flagerror(
"Not implemented.",err,error,*999)
17139 local_error=
"The nonlinear Quasi-Newton trust region solver library type of "// &
17140 & trim(numbertovstring(trustregion_solver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid." 17141 CALL flagerror(local_error,err,error,*999)
17144 CALL flagerror(
"Solver matrices is not associated.",err,error,*999)
17147 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
17150 CALL flagerror(
"Nonlinear solver solver is not associated.",err,error,*999)
17153 CALL flagerror(
"Quasi-Newton solver nonlinear solver is not associated.",err,error,*999)
17156 CALL flagerror(
"Trust region solver Quasi-Newton solver is not associated.",err,error,*999)
17159 CALL flagerror(
"Trust region solver is not associated.",err,error,*999)
17162 exits(
"SOLVER_QUASI_NEWTON_TRUSTREGION_SOLVE")
17164 999 errorsexits(
"SOLVER_QUASI_NEWTON_TRUSTREGION_SOLVE",err,error)
17177 TYPE(solver_type),
POINTER :: SOLVER
17178 REAL(DP),
INTENT(IN) :: TRUSTREGION_TOLERANCE
17179 INTEGER(INTG),
INTENT(OUT) :: ERR
17180 TYPE(varying_string),
INTENT(OUT) :: ERROR
17182 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
17183 TYPE(quasi_newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
17184 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
17185 TYPE(varying_string) :: LOCAL_ERROR
17187 enters(
"Solver_QuasiNewtonTrustRegionToleranceSet",err,error,*999)
17189 IF(
ASSOCIATED(solver))
THEN 17190 IF(solver%SOLVER_FINISHED)
THEN 17191 CALL flagerror(
"Solver has already been finished.",err,error,*999)
17194 nonlinear_solver=>solver%NONLINEAR_SOLVER
17195 IF(
ASSOCIATED(nonlinear_solver))
THEN 17197 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
17198 IF(
ASSOCIATED(quasi_newton_solver))
THEN 17200 trustregion_solver=>quasi_newton_solver%TRUSTREGION_SOLVER
17201 IF(
ASSOCIATED(trustregion_solver))
THEN 17202 IF(trustregion_tolerance>zero_tolerance)
THEN 17203 trustregion_solver%TRUSTREGION_TOLERANCE=trustregion_tolerance
17205 local_error=
"The specified trust region tolerance of "// &
17206 & trim(numbertovstring(trustregion_tolerance,
"*",err,error))// &
17207 &
" is invalid. The trust region tolerance must be > 0." 17208 CALL flagerror(local_error,err,error,*999)
17211 CALL flagerror(
"The Quasi-Newton solver trust region solver is not associated.",err,error,*999)
17214 CALL flagerror(
"The Quasi-Newton solver is not a trust region solver.",err,error,*999)
17217 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
17220 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
17223 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
17226 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
17230 CALL flagerror(
"Solver is not associated.",err,error,*999)
17233 exits(
"Solver_QuasiNewtonTrustRegionToleranceSet")
17235 999 errorsexits(
"Solver_QuasiNewtonTrustRegionToleranceSet",err,error)
17248 TYPE(solver_type),
POINTER :: SOLVER
17249 INTEGER(INTG),
INTENT(IN) :: RESTART
17250 INTEGER(INTG),
INTENT(OUT) :: ERR
17251 TYPE(varying_string),
INTENT(OUT) :: ERROR
17253 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
17254 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
17256 enters(
"SOLVER_QUASI_NEWTON_RESTART_TYPE_SET",err,error,*999)
17258 IF(
ASSOCIATED(solver))
THEN 17259 IF(solver%SOLVER_FINISHED)
THEN 17260 CALL flagerror(
"Solver has already been finished.",err,error,*999)
17263 nonlinear_solver=>solver%NONLINEAR_SOLVER
17264 IF(
ASSOCIATED(nonlinear_solver))
THEN 17266 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
17267 IF(
ASSOCIATED(quasi_newton_solver))
THEN 17268 quasi_newton_solver%RESTART=restart
17270 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
17273 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
17276 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
17279 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
17283 CALL flagerror(
"Solver is not associated.",err,error,*999)
17286 exits(
"SOLVER_QUASI_NEWTON_RESTART_SET")
17288 999 errorsexits(
"SOLVER_QUASI_NEWTON_RESTART_SET",err,error)
17301 TYPE(solver_type),
POINTER :: SOLVER
17302 INTEGER(INTG),
INTENT(IN) :: QUASI_NEWTON_RESTART_TYPE
17303 INTEGER(INTG),
INTENT(OUT) :: ERR
17304 TYPE(varying_string),
INTENT(OUT) :: ERROR
17306 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
17307 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
17308 TYPE(varying_string) :: LOCAL_ERROR
17310 enters(
"SOLVER_QUASI_NEWTON_RESTART_TYPE_SET",err,error,*999)
17312 IF(
ASSOCIATED(solver))
THEN 17313 IF(solver%SOLVER_FINISHED)
THEN 17314 CALL flagerror(
"Solver has already been finished.",err,error,*999)
17317 nonlinear_solver=>solver%NONLINEAR_SOLVER
17318 IF(
ASSOCIATED(nonlinear_solver))
THEN 17320 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
17321 IF(
ASSOCIATED(quasi_newton_solver))
THEN 17322 IF(quasi_newton_restart_type/=quasi_newton_solver%RESTART_TYPE)
THEN 17324 SELECT CASE(quasi_newton_restart_type)
17332 local_error=
"The Quasi-Newton restart type of "//trim(numbertovstring( &
17333 & quasi_newton_restart_type,
"*",err,error))// &
17335 CALL flagerror(local_error,err,error,*999)
17339 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
17342 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
17345 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
17348 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
17352 CALL flagerror(
"Solver is not associated.",err,error,*999)
17355 exits(
"SOLVER_QUASI_NEWTON_RESTART_TYPE_SET")
17357 999 errorsexits(
"SOLVER_QUASI_NEWTON_RESTART_TYPE_SET",err,error)
17370 TYPE(solver_type),
POINTER :: SOLVER
17371 INTEGER(INTG),
INTENT(IN) :: QUASI_NEWTON_SCALE_TYPE
17372 INTEGER(INTG),
INTENT(OUT) :: ERR
17373 TYPE(varying_string),
INTENT(OUT) :: ERROR
17375 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
17376 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
17377 TYPE(varying_string) :: LOCAL_ERROR
17379 enters(
"SOLVER_QUASI_NEWTON_SCALE_TYPE_SET",err,error,*999)
17381 IF(
ASSOCIATED(solver))
THEN 17382 IF(solver%SOLVER_FINISHED)
THEN 17383 CALL flagerror(
"Solver has already been finished.",err,error,*999)
17386 nonlinear_solver=>solver%NONLINEAR_SOLVER
17387 IF(
ASSOCIATED(nonlinear_solver))
THEN 17389 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
17390 IF(
ASSOCIATED(quasi_newton_solver))
THEN 17391 IF(quasi_newton_scale_type/=quasi_newton_solver%SCALE_TYPE)
THEN 17393 SELECT CASE(quasi_newton_scale_type)
17403 local_error=
"The Quasi-Newton scale type of "//trim(numbertovstring( &
17404 & quasi_newton_scale_type,
"*",err,error))// &
17406 CALL flagerror(local_error,err,error,*999)
17410 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
17413 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
17416 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
17419 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
17423 CALL flagerror(
"Solver is not associated.",err,error,*999)
17426 exits(
"SOLVER_QUASI_NEWTON_SCALE_TYPE_SET")
17428 999 errorsexits(
"SOLVER_QUASI_NEWTON_SCALE_TYPE_SET",err,error)
17441 TYPE(solver_type),
POINTER :: SOLVER
17442 INTEGER(INTG),
INTENT(IN) :: QUASI_NEWTON_TYPE
17443 INTEGER(INTG),
INTENT(OUT) :: ERR
17444 TYPE(varying_string),
INTENT(OUT) :: ERROR
17446 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
17447 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
17448 TYPE(varying_string) :: LOCAL_ERROR
17450 enters(
"SOLVER_QUASI_NEWTON_TYPE_SET",err,error,*999)
17452 IF(
ASSOCIATED(solver))
THEN 17453 IF(solver%SOLVER_FINISHED)
THEN 17454 CALL flagerror(
"Solver has already been finished.",err,error,*999)
17457 nonlinear_solver=>solver%NONLINEAR_SOLVER
17458 IF(
ASSOCIATED(nonlinear_solver))
THEN 17460 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
17461 IF(
ASSOCIATED(quasi_newton_solver))
THEN 17462 IF(quasi_newton_type/=quasi_newton_solver%QUASI_NEWTON_TYPE)
THEN 17464 SELECT CASE(quasi_newton_type)
17472 local_error=
"The Quasi-Newton type of "//trim(numbertovstring(quasi_newton_type,
"*",err,error))// &
17474 CALL flagerror(local_error,err,error,*999)
17478 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
17481 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*999)
17484 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
17487 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
17491 CALL flagerror(
"Solver is not associated.",err,error,*999)
17494 exits(
"SOLVER_QUASI_NEWTON_TYPE_SET")
17496 999 errorsexits(
"SOLVER_QUASI_NEWTON_TYPE_SET",err,error)
17509 TYPE(solver_type),
POINTER :: SOLVER
17510 INTEGER(INTG),
INTENT(IN) :: QUASI_NEWTON_SOLVE_TYPE
17511 INTEGER(INTG),
INTENT(OUT) :: ERR
17512 TYPE(varying_string),
INTENT(OUT) :: ERROR
17514 INTEGER(INTG) :: DUMMY_ERR
17515 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
17516 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
17517 TYPE(varying_string) :: DUMMY_ERROR,LOCAL_ERROR
17519 enters(
"SOLVER_QUASI_NEWTON_SOLVE_TYPE_SET",err,error,*998)
17521 IF(
ASSOCIATED(solver))
THEN 17522 IF(solver%SOLVER_FINISHED)
THEN 17523 CALL flagerror(
"Solver has already been finished.",err,error,*998)
17526 nonlinear_solver=>solver%NONLINEAR_SOLVER
17527 IF(
ASSOCIATED(nonlinear_solver))
THEN 17529 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
17530 IF(
ASSOCIATED(quasi_newton_solver))
THEN 17531 IF(quasi_newton_solve_type/=quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE)
THEN 17533 SELECT CASE(quasi_newton_solve_type)
17539 local_error=
"The Quasi-Newton solver type of " &
17540 & //trim(numbertovstring(quasi_newton_solve_type,
"*",err,error))// &
17542 CALL flagerror(local_error,err,error,*999)
17545 SELECT CASE(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE)
17551 local_error=
"The Quasi-Newton solver type of "// &
17552 & trim(numbertovstring(quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE,
"*",err,error))//
" is invalid." 17553 CALL flagerror(local_error,err,error,*999)
17555 quasi_newton_solver%QUASI_NEWTON_SOLVE_TYPE=quasi_newton_solve_type
17558 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*998)
17561 CALL flagerror(
"The nonlinear solver is not a Quasi-Newton solver.",err,error,*998)
17564 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*998)
17567 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*998)
17571 CALL flagerror(
"Solver is not associated.",err,error,*998)
17574 exits(
"SOLVER_QUASI_NEWTON_SOLVE_TYPE_SET")
17576 999
SELECT CASE(quasi_newton_solve_type)
17582 998 errorsexits(
"SOLVER_QUASI_NEWTON_SOLVE_TYPE_SET",err,error)
17595 TYPE(solver_type),
POINTER :: SOLVER
17596 REAL(DP),
INTENT(IN) :: ABSOLUTE_TOLERANCE
17597 INTEGER(INTG),
INTENT(OUT) :: ERR
17598 TYPE(varying_string),
INTENT(OUT) :: ERROR
17600 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
17601 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
17602 TYPE(varying_string) :: LOCAL_ERROR
17604 enters(
"SOLVER_NEWTON_ABSOLUTE_TOLERANCE_SET",err,error,*999)
17606 IF(
ASSOCIATED(solver))
THEN 17607 IF(solver%SOLVER_FINISHED)
THEN 17608 CALL flagerror(
"Solver has already been finished.",err,error,*999)
17611 nonlinear_solver=>solver%NONLINEAR_SOLVER
17612 IF(
ASSOCIATED(nonlinear_solver))
THEN 17614 newton_solver=>nonlinear_solver%NEWTON_SOLVER
17615 IF(
ASSOCIATED(newton_solver))
THEN 17616 IF(absolute_tolerance>zero_tolerance)
THEN 17617 newton_solver%ABSOLUTE_TOLERANCE=absolute_tolerance
17619 local_error=
"The specified absolute tolerance of "//trim(numbertovstring(absolute_tolerance,
"*",err,error))// &
17620 &
" is invalid. The absolute tolerance must be > 0." 17621 CALL flagerror(local_error,err,error,*999)
17624 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
17627 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
17630 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
17633 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
17637 CALL flagerror(
"Solver is not associated.",err,error,*999)
17640 exits(
"SOLVER_NEWTON_ABSOLUTE_TOLERANCE_SET")
17642 999 errorsexits(
"SOLVER_NEWTON_ABSOLUTE_TOLERANCE_SET",err,error)
17655 TYPE(solver_type),
POINTER :: solver
17656 LOGICAL,
INTENT(IN) :: linesearchMonitorOutputFlag
17657 INTEGER(INTG),
INTENT(OUT) :: err
17658 TYPE(varying_string),
INTENT(OUT) :: error
17660 TYPE(newton_linesearch_solver_type),
POINTER :: linesearchSolver
17661 TYPE(newton_solver_type),
POINTER :: newtonSolver
17662 TYPE(nonlinear_solver_type),
POINTER :: nonlinearSolver
17664 enters(
"Solver_NewtonLineSearchMonitorOutputSet",err,error,*999)
17666 IF(
ASSOCIATED(solver))
THEN 17667 IF(solver%SOLVER_FINISHED)
THEN 17668 CALL flagerror(
"Solver has already been finished.",err,error,*999)
17671 nonlinearsolver=>solver%NONLINEAR_SOLVER
17672 IF(
ASSOCIATED(nonlinearsolver))
THEN 17674 newtonsolver=>nonlinearsolver%NEWTON_SOLVER
17675 IF(
ASSOCIATED(newtonsolver))
THEN 17677 linesearchsolver=>newtonsolver%LINESEARCH_SOLVER
17678 IF(
ASSOCIATED(linesearchsolver))
THEN 17679 linesearchsolver%linesearchMonitorOutput=linesearchmonitoroutputflag
17681 CALL flagerror(
"The Newton linesearch solver is not associated.",err,error,*999)
17684 CALL flagerror(
"The Newton solver is not a linesearch solver.",err,error,*999)
17687 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
17690 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
17693 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
17696 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
17700 CALL flagerror(
"Solver is not associated.",err,error,*999)
17703 exits(
"Solver_NewtonLineSearchMonitorOutputSet")
17705 999 errorsexits(
"Solver_NewtonLineSearchMonitorOutputSet",err,error)
17718 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
17719 INTEGER(INTG),
INTENT(OUT) :: ERR
17720 TYPE(varying_string),
INTENT(OUT) :: ERROR
17722 TYPE(varying_string) :: LOCAL_ERROR
17724 enters(
"SOLVER_NEWTON_CREATE_FINISH",err,error,*999)
17726 IF(
ASSOCIATED(newton_solver))
THEN 17727 SELECT CASE(newton_solver%NEWTON_SOLVE_TYPE)
17733 local_error=
"The Newton solver type of "// &
17734 & trim(numbertovstring(newton_solver%NEWTON_SOLVE_TYPE,
"*",err,error))//
" is invalid." 17735 CALL flagerror(local_error,err,error,*999)
17738 CALL flagerror(
"Newton solver is not associated.",err,error,*999)
17741 exits(
"SOLVER_NEWTON_CREATE_FINISH")
17743 999 errorsexits(
"SOLVER_NEWTON_CREATE_FINISH",err,error)
17756 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
17757 INTEGER(INTG),
INTENT(OUT) :: ERR
17758 TYPE(varying_string),
INTENT(OUT) :: ERROR
17761 enters(
"SOLVER_NEWTON_FINALISE",err,error,*999)
17763 IF(
ASSOCIATED(newton_solver))
THEN 17767 DEALLOCATE(newton_solver)
17770 exits(
"SOLVER_NEWTON_FINALISE")
17772 999 errorsexits(
"SOLVER_NEWTON_FINALISE",err,error)
17785 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
17786 INTEGER(INTG),
INTENT(OUT) :: ERR
17787 TYPE(varying_string),
INTENT(OUT) :: ERROR
17789 INTEGER(INTG) :: DUMMY_ERR
17790 TYPE(solver_type),
POINTER :: SOLVER
17791 TYPE(varying_string) :: DUMMY_ERROR
17793 enters(
"SOLVER_NEWTON_INITIALISE",err,error,*998)
17795 IF(
ASSOCIATED(nonlinear_solver))
THEN 17796 IF(
ASSOCIATED(nonlinear_solver%NEWTON_SOLVER))
THEN 17797 CALL flagerror(
"Newton solver is already associated for this nonlinear solver.",err,error,*998)
17799 solver=>nonlinear_solver%SOLVER
17800 IF(
ASSOCIATED(solver))
THEN 17802 ALLOCATE(nonlinear_solver%NEWTON_SOLVER,stat=err)
17803 IF(err/=0)
CALL flagerror(
"Could not allocate nonlinear solver Newton solver.",err,error,*999)
17804 nonlinear_solver%NEWTON_SOLVER%NONLINEAR_SOLVER=>nonlinear_solver
17806 nonlinear_solver%NEWTON_SOLVER%TOTAL_NUMBER_OF_FUNCTION_EVALUATIONS=0
17807 nonlinear_solver%NEWTON_SOLVER%TOTAL_NUMBER_OF_JACOBIAN_EVALUATIONS=0
17808 nonlinear_solver%NEWTON_SOLVER%MAXIMUM_NUMBER_OF_ITERATIONS=50
17809 nonlinear_solver%NEWTON_SOLVER%MAXIMUM_NUMBER_OF_FUNCTION_EVALUATIONS=1000
17812 nonlinear_solver%NEWTON_SOLVER%ABSOLUTE_TOLERANCE=1.0e-10_dp
17813 nonlinear_solver%NEWTON_SOLVER%RELATIVE_TOLERANCE=1.0e-05_dp
17814 nonlinear_solver%NEWTON_SOLVER%SOLUTION_TOLERANCE=1.0e-05_dp
17815 NULLIFY(nonlinear_solver%NEWTON_SOLVER%LINESEARCH_SOLVER)
17816 NULLIFY(nonlinear_solver%NEWTON_SOLVER%TRUSTREGION_SOLVER)
17817 NULLIFY(nonlinear_solver%NEWTON_SOLVER%CELLML_EVALUATOR_SOLVER)
17818 NULLIFY(nonlinear_solver%NEWTON_SOLVER%convergenceTest)
17819 ALLOCATE(nonlinear_solver%NEWTON_SOLVER%convergenceTest,stat=err)
17820 IF(err/=0)
CALL flagerror(
"Could not allocate convergence test object.",err,error,*999)
17821 nonlinear_solver%NEWTON_SOLVER%convergenceTest%energyFirstIter = 0.0_dp
17822 nonlinear_solver%NEWTON_SOLVER%convergenceTest%normalisedEnergy = 0.0_dp
17827 ALLOCATE(nonlinear_solver%NEWTON_SOLVER%LINEAR_SOLVER,stat=err)
17828 IF(err/=0)
CALL flagerror(
"Could not allocate Newton solver linear solver.",err,error,*999)
17829 NULLIFY(nonlinear_solver%NEWTON_SOLVER%LINEAR_SOLVER%SOLVERS)
17834 CALL flagerror(
"Nonlinear solver solver is not associated.",err,error,*998)
17838 CALL flagerror(
"Nonlinear solver is not associated.",err,error,*998)
17841 exits(
"SOLVER_NEWTON_INITIALISE")
17844 998 errorsexits(
"SOLVER_NEWTON_INITIALISE",err,error)
17857 TYPE(solver_type),
POINTER :: SOLVER
17858 INTEGER(INTG),
INTENT(IN) :: JACOBIAN_CALCULATION_TYPE
17859 INTEGER(INTG),
INTENT(OUT) :: ERR
17860 TYPE(varying_string),
INTENT(OUT) :: ERROR
17862 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
17863 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
17864 TYPE(varying_string) :: LOCAL_ERROR
17866 enters(
"SOLVER_NEWTON_JACOBIAN_CALCULATION_TYPE_SET",err,error,*999)
17868 IF(
ASSOCIATED(solver))
THEN 17869 IF(solver%SOLVER_FINISHED)
THEN 17870 CALL flagerror(
"Solver has already been finished",err,error,*999)
17873 nonlinear_solver=>solver%NONLINEAR_SOLVER
17874 IF(
ASSOCIATED(nonlinear_solver))
THEN 17876 newton_solver=>nonlinear_solver%NEWTON_SOLVER
17877 IF(
ASSOCIATED(newton_solver))
THEN 17878 IF(jacobian_calculation_type/=newton_solver%JACOBIAN_CALCULATION_TYPE)
THEN 17879 SELECT CASE(jacobian_calculation_type)
17887 local_error=
"The Jacobian calculation type of "// &
17888 & trim(numbertovstring(jacobian_calculation_type,
"*",err,error))//
" is invalid." 17889 CALL flagerror(local_error,err,error,*999)
17893 CALL flagerror(
"The nonlinear solver Newton solver is not associated.",err,error,*999)
17896 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
17899 CALL flagerror(
"The Solver nonlinear solver is not associated",err,error,*999)
17902 CALL flagerror(
"The solver is not a nonlinear solver",err,error,*999)
17906 CALL flagerror(
"Solver is not associated",err,error,*999)
17909 exits(
"SOLVER_NEWTON_JACOBIAN_CALCULATION_TYPE_SET")
17911 999 errorsexits(
"SOLVER_NEWTON_JACOBIAN_CALCULATION_TYPE_SET",err,error)
17924 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
17925 INTEGER(INTG),
INTENT(OUT) :: SOLVER_LIBRARY_TYPE
17926 INTEGER(INTG),
INTENT(OUT) :: ERR
17927 TYPE(varying_string),
INTENT(OUT) :: ERROR
17929 TYPE(newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
17930 TYPE(newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
17931 TYPE(varying_string) :: LOCAL_ERROR
17933 enters(
"SOLVER_NEWTON_LIBRARY_TYPE_GET",err,error,*999)
17935 IF(
ASSOCIATED(newton_solver))
THEN 17936 SELECT CASE(newton_solver%NEWTON_SOLVE_TYPE)
17938 linesearch_solver=>newton_solver%LINESEARCH_SOLVER
17939 IF(
ASSOCIATED(linesearch_solver))
THEN 17940 solver_library_type=linesearch_solver%SOLVER_LIBRARY
17942 CALL flagerror(
"Newton line search solver is not associated.",err,error,*999)
17945 trustregion_solver=>newton_solver%TRUSTREGION_SOLVER
17946 IF(
ASSOCIATED(trustregion_solver))
THEN 17947 solver_library_type=trustregion_solver%SOLVER_LIBRARY
17949 CALL flagerror(
"Newton trust region solver is not associated.",err,error,*999)
17952 local_error=
"The Newton solver type of "// &
17953 & trim(numbertovstring(newton_solver%NEWTON_SOLVE_TYPE,
"*",err,error))//
" is invalid." 17954 CALL flagerror(local_error,err,error,*999)
17957 CALL flagerror(
"Newton solver is not associated.",err,error,*999)
17960 exits(
"SOLVER_NEWTON_LIBRARY_TYPE_GET")
17962 999 errorsexits(
"SOLVER_NEWTON_LIBRARY_TYPE_GET",err,error)
17975 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
17976 INTEGER(INTG),
INTENT(IN) :: SOLVER_LIBRARY_TYPE
17977 INTEGER(INTG),
INTENT(OUT) :: ERR
17978 TYPE(varying_string),
INTENT(OUT) :: ERROR
17980 TYPE(newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
17981 TYPE(newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
17982 TYPE(varying_string) :: LOCAL_ERROR
17984 enters(
"SOLVER_NEWTON_LIBRARY_TYPE_SET",err,error,*999)
17986 IF(
ASSOCIATED(newton_solver))
THEN 17987 SELECT CASE(newton_solver%NEWTON_SOLVE_TYPE)
17989 linesearch_solver=>newton_solver%LINESEARCH_SOLVER
17990 IF(
ASSOCIATED(linesearch_solver))
THEN 17991 SELECT CASE(solver_library_type)
17993 CALL flagerror(
"Not implemented.",err,error,*999)
17996 linesearch_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
17998 local_error=
"The solver library type of "//trim(numbertovstring(solver_library_type,
"*",err,error))// &
17999 &
" is invalid for a Newton linesearch solver." 18000 CALL flagerror(local_error,err,error,*999)
18003 CALL flagerror(
"Newton line search solver is not associated.",err,error,*999)
18006 trustregion_solver=>newton_solver%TRUSTREGION_SOLVER
18007 IF(
ASSOCIATED(trustregion_solver))
THEN 18008 SELECT CASE(solver_library_type)
18010 CALL flagerror(
"Not implemented.",err,error,*999)
18013 trustregion_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
18015 local_error=
"The solver library type of "//trim(numbertovstring(solver_library_type,
"*",err,error))// &
18016 &
" is invalid for a Newton trustregion solver." 18017 CALL flagerror(local_error,err,error,*999)
18020 CALL flagerror(
"Newton trust region solver is not associated.",err,error,*999)
18023 local_error=
"The Newton solver type of "// &
18024 & trim(numbertovstring(newton_solver%NEWTON_SOLVE_TYPE,
"*",err,error))//
" is invalid." 18025 CALL flagerror(local_error,err,error,*999)
18028 CALL flagerror(
"Newton solver is not associated.",err,error,*999)
18031 exits(
"SOLVER_NEWTON_LIBRARY_TYPE_SET")
18033 999 errorsexits(
"SOLVER_NEWTON_LIBRARY_TYPE_SET",err,error)
18046 TYPE(solver_type),
POINTER :: SOLVER
18047 TYPE(solver_type),
POINTER :: LINEAR_SOLVER
18048 INTEGER(INTG),
INTENT(OUT) :: ERR
18049 TYPE(varying_string),
INTENT(OUT) :: ERROR
18051 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
18052 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
18054 enters(
"SOLVER_NEWTON_LINEAR_SOLVER_GET",err,error,*999)
18056 IF(
ASSOCIATED(solver))
THEN 18057 IF(
ASSOCIATED(linear_solver))
THEN 18058 CALL flagerror(
"Linear solver is already associated.",err,error,*999)
18060 NULLIFY(linear_solver)
18062 nonlinear_solver=>solver%NONLINEAR_SOLVER
18063 IF(
ASSOCIATED(nonlinear_solver))
THEN 18065 newton_solver=>nonlinear_solver%NEWTON_SOLVER
18066 IF(
ASSOCIATED(newton_solver))
THEN 18067 linear_solver=>newton_solver%LINEAR_SOLVER
18068 IF(.NOT.
ASSOCIATED(linear_solver)) &
18069 &
CALL flagerror(
"Newton solver linear solver is not associated.",err,error,*999)
18071 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
18074 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
18077 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
18080 CALL flagerror(
"The specified solver is not a dynamic solver.",err,error,*999)
18084 CALL flagerror(
"Solver is not associated.",err,error,*999)
18087 exits(
"SOLVER_NEWTON_LINEAR_SOLVER_GET")
18089 999 errorsexits(
"SOLVER_NEWTON_LINEAR_SOLVER_GET",err,error)
18102 TYPE(solver_type),
POINTER :: SOLVER
18103 TYPE(solver_type),
POINTER :: CELLML_SOLVER
18104 INTEGER(INTG),
INTENT(OUT) :: ERR
18105 TYPE(varying_string),
INTENT(OUT) :: ERROR
18107 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
18108 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
18110 enters(
"SOLVER_NEWTON_CELLML_SOLVER_GET",err,error,*999)
18112 IF(
ASSOCIATED(solver))
THEN 18113 IF(
ASSOCIATED(cellml_solver))
THEN 18114 CALL flagerror(
"Linear solver is already associated.",err,error,*999)
18116 NULLIFY(cellml_solver)
18118 nonlinear_solver=>solver%NONLINEAR_SOLVER
18119 IF(
ASSOCIATED(nonlinear_solver))
THEN 18121 newton_solver=>nonlinear_solver%NEWTON_SOLVER
18122 IF(
ASSOCIATED(newton_solver))
THEN 18123 cellml_solver=>newton_solver%CELLML_EVALUATOR_SOLVER
18124 IF(.NOT.
ASSOCIATED(cellml_solver)) &
18125 &
CALL flagerror(
"Newton solver CellML solver is not associated.",err,error,*999)
18127 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
18130 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
18133 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
18136 nonlinear_solver=>solver%DYNAMIC_SOLVER%NONLINEAR_SOLVER%NONLINEAR_SOLVER
18137 IF(
ASSOCIATED(nonlinear_solver))
THEN 18139 newton_solver=>nonlinear_solver%NEWTON_SOLVER
18140 IF(
ASSOCIATED(newton_solver))
THEN 18141 cellml_solver=>newton_solver%CELLML_EVALUATOR_SOLVER
18142 IF(.NOT.
ASSOCIATED(cellml_solver)) &
18143 &
CALL flagerror(
"Newton solver CellML solver is not associated.",err,error,*999)
18145 CALL flagerror(
"Dynamic nonlinear solver Newton solver is not associated.",err,error,*999)
18148 CALL flagerror(
"The Dynamic nonlinear solver is not a Newton solver.",err,error,*999)
18151 CALL flagerror(
"The solver dynamic nonlinear solver is not associated.",err,error,*999)
18154 CALL flagerror(
"The specified solver is not a nonlinear or dynamic nonlinear solver.",err,error,*999)
18158 CALL flagerror(
"Solver is not associated.",err,error,*999)
18161 exits(
"SOLVER_NEWTON_CELLML_SOLVER_GET")
18163 999 errorsexits(
"SOLVER_NEWTON_CELLML_SOLVER_GET",err,error)
18176 TYPE(solver_type),
POINTER :: solver
18177 INTEGER(INTG),
INTENT(IN) :: convergenceTestType
18178 INTEGER(INTG),
INTENT(OUT) :: err
18179 TYPE(varying_string),
INTENT(OUT) :: error
18181 TYPE(newton_solver_type),
POINTER :: newtonSolver
18182 TYPE(nonlinear_solver_type),
POINTER :: nonlinearSolver
18183 TYPE(varying_string) :: localError
18185 enters(
"Solver_NewtonConvergenceTestTypeSet",err,error,*999)
18187 IF(
ASSOCIATED(solver))
THEN 18188 IF(solver%SOLVER_FINISHED)
THEN 18189 CALL flagerror(
"Solver has already been finished.",err,error,*999)
18192 nonlinearsolver=>solver%NONLINEAR_SOLVER
18193 IF(
ASSOCIATED(nonlinearsolver))
THEN 18195 newtonsolver=>nonlinearsolver%NEWTON_SOLVER
18196 IF(
ASSOCIATED(newtonsolver))
THEN 18197 SELECT CASE(convergencetesttype)
18205 localerror=
"The specified convergence test type of "//trim(numbertovstring(convergencetesttype, &
18206 &
"*",err,error))//
" is invalid." 18207 CALL flagerror(localerror,err,error,*999)
18210 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
18213 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
18216 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
18219 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
18223 CALL flagerror(
"Solver is not associated.",err,error,*999)
18226 exits(
"Solver_NewtonConvergenceTestTypeSet")
18228 999 errorsexits(
"Solver_NewtonConvergenceTestTypeSet",err,error)
18241 TYPE(solver_type),
POINTER :: SOLVER
18242 REAL(DP),
INTENT(IN) :: LINESEARCH_ALPHA
18243 INTEGER(INTG),
INTENT(OUT) :: ERR
18244 TYPE(varying_string),
INTENT(OUT) :: ERROR
18246 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
18247 TYPE(newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
18248 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
18249 TYPE(varying_string) :: LOCAL_ERROR
18251 enters(
"SOLVER_NEWTON_LINESEARCH_ALPHA_SET",err,error,*999)
18253 IF(
ASSOCIATED(solver))
THEN 18254 IF(solver%SOLVER_FINISHED)
THEN 18255 CALL flagerror(
"Solver has already been finished.",err,error,*999)
18258 nonlinear_solver=>solver%NONLINEAR_SOLVER
18259 IF(
ASSOCIATED(nonlinear_solver))
THEN 18261 newton_solver=>nonlinear_solver%NEWTON_SOLVER
18262 IF(
ASSOCIATED(newton_solver))
THEN 18264 linesearch_solver=>newton_solver%LINESEARCH_SOLVER
18265 IF(
ASSOCIATED(linesearch_solver))
THEN 18266 IF(linesearch_alpha>zero_tolerance)
THEN 18267 linesearch_solver%LINESEARCH_ALPHA=linesearch_alpha
18269 local_error=
"The specified line search alpha of "//trim(numbertovstring(linesearch_alpha,
"*",err,error))// &
18270 &
" is invalid. The line search alpha must be > 0." 18271 CALL flagerror(local_error,err,error,*999)
18274 CALL flagerror(
"The Newton solver line search solver is not associated.",err,error,*999)
18277 CALL flagerror(
"The Newton solver is not a line search solver.",err,error,*999)
18280 CALL flagerror(
"The nonlinear solver Newton solver is not associated.",err,error,*999)
18283 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
18286 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
18289 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
18293 CALL flagerror(
"Solver is not associated.",err,error,*999)
18296 exits(
"SOLVER_NEWTON_LINESEARCH_ALPHA_SET")
18298 999 errorsexits(
"SOLVER_NEWTON_LINESEARCH_ALPHA_SET",err,error)
18311 TYPE(newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
18312 INTEGER(INTG),
INTENT(OUT) :: ERR
18313 TYPE(varying_string),
INTENT(OUT) :: ERROR
18315 EXTERNAL :: problem_solverjacobianevaluatepetsc
18316 EXTERNAL :: problem_solverjacobianfdcalculatepetsc
18317 EXTERNAL :: problem_solverresidualevaluatepetsc
18318 EXTERNAL :: problem_solverconvergencetestpetsc
18319 EXTERNAL :: problem_solvernonlinearmonitorpetsc
18320 INTEGER(INTG) :: equations_matrix_idx,equations_set_idx,interface_condition_idx,interface_matrix_idx
18321 TYPE(distributed_matrix_type),
POINTER :: JACOBIAN_MATRIX
18322 TYPE(distributed_vector_type),
POINTER :: RESIDUAL_VECTOR
18323 TYPE(equations_type),
POINTER :: EQUATIONS
18324 TYPE(equations_mapping_type),
POINTER :: EQUATIONS_MAPPING
18325 TYPE(equations_mapping_linear_type),
POINTER :: LINEAR_MAPPING
18326 TYPE(equations_matrices_type),
POINTER :: EQUATIONS_MATRICES
18327 TYPE(equations_matrices_linear_type),
POINTER :: LINEAR_MATRICES
18328 TYPE(equations_matrix_type),
POINTER :: EQUATIONS_MATRIX
18329 TYPE(equations_set_type),
POINTER :: EQUATIONS_SET
18330 TYPE(field_type),
POINTER :: DEPENDENT_FIELD,LAGRANGE_FIELD
18331 TYPE(field_variable_type),
POINTER :: LINEAR_VARIABLE,INTERFACE_VARIABLE,LAGRANGE_VARIABLE
18332 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
18333 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
18334 TYPE(solver_type),
POINTER :: LINEAR_SOLVER,SOLVER
18335 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
18336 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
18337 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
18338 TYPE(solver_matrix_type),
POINTER :: SOLVER_JACOBIAN
18339 TYPE(interface_condition_type),
POINTER :: INTERFACE_CONDITION
18340 TYPE(interface_equations_type),
POINTER :: INTERFACE_EQUATIONS
18341 TYPE(interface_mapping_type),
POINTER :: INTERFACE_MAPPING
18342 TYPE(interface_matrices_type),
POINTER :: INTERFACE_MATRICES
18343 TYPE(interface_matrix_type),
POINTER :: INTERFACE_MATRIX
18345 TYPE(varying_string) :: LOCAL_ERROR
18347 enters(
"SOLVER_NEWTON_LINESEARCH_CREATE_FINISH",err,error,*999)
18349 IF(
ASSOCIATED(linesearch_solver))
THEN 18350 newton_solver=>linesearch_solver%NEWTON_SOLVER
18351 IF(
ASSOCIATED(newton_solver))
THEN 18352 nonlinear_solver=>newton_solver%NONLINEAR_SOLVER
18353 IF(
ASSOCIATED(nonlinear_solver))
THEN 18354 solver=>nonlinear_solver%SOLVER
18355 IF(
ASSOCIATED(solver))
THEN 18356 solver_equations=>solver%SOLVER_EQUATIONS
18357 IF(
ASSOCIATED(solver_equations))
THEN 18358 SELECT CASE(linesearch_solver%SOLVER_LIBRARY)
18360 CALL flagerror(
"Not implemented.",err,error,*999)
18362 solver_mapping=>solver_equations%SOLVER_MAPPING
18363 IF(
ASSOCIATED(solver_mapping))
THEN 18365 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
18366 equations=>solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)%EQUATIONS
18367 IF(
ASSOCIATED(equations))
THEN 18368 equations_set=>equations%EQUATIONS_SET
18369 IF(
ASSOCIATED(equations_set))
THEN 18370 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
18371 IF(
ASSOCIATED(dependent_field))
THEN 18372 equations_mapping=>equations%EQUATIONS_MAPPING
18373 IF(
ASSOCIATED(equations_mapping))
THEN 18374 linear_mapping=>equations_mapping%LINEAR_MAPPING
18375 IF(
ASSOCIATED(linear_mapping))
THEN 18377 equations_matrices=>equations%EQUATIONS_MATRICES
18378 IF(
ASSOCIATED(equations_matrices))
THEN 18379 linear_matrices=>equations_matrices%LINEAR_MATRICES
18380 IF(
ASSOCIATED(linear_matrices))
THEN 18381 DO equations_matrix_idx=1,linear_matrices%NUMBER_OF_LINEAR_MATRICES
18382 equations_matrix=>linear_matrices%MATRICES(equations_matrix_idx)%PTR
18383 IF(
ASSOCIATED(equations_matrix))
THEN 18384 IF(.NOT.
ASSOCIATED(equations_matrix%TEMP_VECTOR))
THEN 18385 linear_variable=>linear_mapping%EQUATIONS_MATRIX_TO_VAR_MAPS(equations_matrix_idx)%VARIABLE
18386 IF(
ASSOCIATED(linear_variable))
THEN 18387 CALL distributed_vector_create_start(linear_variable%DOMAIN_MAPPING, &
18388 & equations_matrix%TEMP_VECTOR,err,error,*999)
18389 CALL distributed_vector_data_type_set(equations_matrix%TEMP_VECTOR, &
18390 & distributed_matrix_vector_dp_type,err,error,*999)
18391 CALL distributed_vector_create_finish(equations_matrix%TEMP_VECTOR,err,error,*999)
18393 CALL flagerror(
"Linear mapping linear variable is not associated.",err,error,*999)
18397 CALL flagerror(
"Equations matrix is not associated.",err,error,*999)
18401 CALL flagerror(
"Equations matrices linear matrices is not associated.",err,error,*999)
18404 CALL flagerror(
"Equations equations matrices is not associated.",err,error,*999)
18408 CALL flagerror(
"Equations equations mapping is not associated.",err,error,*999)
18411 local_error=
"Equations set dependent field is not associated for equations set index "// &
18412 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 18413 CALL flagerror(local_error,err,error,*999)
18416 local_error=
"Equations equations set is not associated for equations set index "// &
18417 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 18418 CALL flagerror(local_error,err,error,*999)
18421 local_error=
"Equations is not associated for equations set index "// &
18422 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 18423 CALL flagerror(local_error,err,error,*999)
18427 DO interface_condition_idx=1,solver_mapping%NUMBER_OF_INTERFACE_CONDITIONS
18428 interface_condition=>solver_mapping%INTERFACE_CONDITIONS(interface_condition_idx)%PTR
18429 IF(
ASSOCIATED(interface_condition))
THEN 18430 lagrange_field=>interface_condition%LAGRANGE%LAGRANGE_FIELD
18431 IF(
ASSOCIATED(lagrange_field))
THEN 18432 interface_equations=>interface_condition%INTERFACE_EQUATIONS
18433 IF(
ASSOCIATED(interface_equations))
THEN 18434 interface_matrices=>interface_equations%INTERFACE_MATRICES
18435 IF(
ASSOCIATED(interface_matrices))
THEN 18436 interface_mapping=>interface_equations%INTERFACE_MAPPING
18437 IF(
ASSOCIATED(interface_mapping))
THEN 18438 lagrange_variable=>interface_mapping%LAGRANGE_VARIABLE
18439 IF(
ASSOCIATED(lagrange_variable))
THEN 18441 DO interface_matrix_idx=1,interface_mapping%NUMBER_OF_INTERFACE_MATRICES
18442 interface_matrix=>interface_matrices%MATRICES(interface_matrix_idx)%PTR
18443 IF(
ASSOCIATED(interface_matrix))
THEN 18444 IF(.NOT.
ASSOCIATED(interface_matrix%TEMP_VECTOR))
THEN 18445 interface_variable=>interface_mapping% &
18446 & interface_matrix_rows_to_var_maps(interface_matrix_idx)%VARIABLE
18447 IF(
ASSOCIATED(interface_variable))
THEN 18449 CALL distributed_vector_create_start(interface_variable%DOMAIN_MAPPING, &
18450 & interface_matrix%TEMP_VECTOR,err,error,*999)
18451 CALL distributed_vector_data_type_set(interface_matrix%TEMP_VECTOR, &
18452 & distributed_matrix_vector_dp_type,err,error,*999)
18453 CALL distributed_vector_create_finish(interface_matrix%TEMP_VECTOR,err,error,*999)
18455 CALL distributed_vector_create_start(lagrange_variable%DOMAIN_MAPPING, &
18456 & interface_matrix%TEMP_TRANSPOSE_VECTOR,err,error,*999)
18457 CALL distributed_vector_data_type_set(interface_matrix%TEMP_TRANSPOSE_VECTOR, &
18458 & distributed_matrix_vector_dp_type,err,error,*999)
18459 CALL distributed_vector_create_finish(interface_matrix%TEMP_TRANSPOSE_VECTOR, &
18462 CALL flagerror(
"Interface mapping variable is not associated.",err,error,*999)
18466 CALL flagerror(
"Interface matrix is not associated.",err,error,*999)
18470 CALL flagerror(
"Interface matrix is not associated.",err,error,*999)
18473 CALL flagerror(
"interface condition mapping is not associated.",err,error,*999)
18476 CALL flagerror(
"Interface matrices is not associated.",err,error,*999)
18479 local_error=
"Interface eqauations is not associated for interface condition index "// &
18480 & trim(numbertovstring(interface_condition_idx,
"*",err,error))//
"." 18481 CALL flagerror(local_error,err,error,*999)
18484 local_error=
"Interface condition Lagrange field is not associated for interface condition "// &
18485 & trim(numbertovstring(interface_condition_idx,
"*",err,error))//
"." 18486 CALL flagerror(local_error,err,error,*999)
18489 local_error=
"Interface condition is not associated for interface condition index "// &
18490 & trim(numbertovstring(interface_condition_idx,
"*",err,error))//
"." 18491 CALL flagerror(local_error,err,error,*999)
18495 CALL petsc_snescreate(computational_environment%MPI_COMM,linesearch_solver%snes,err,error,*999)
18497 CALL petsc_snessettype(linesearch_solver%snes,petsc_snesnewtonls,err,error,*999)
18500 linear_solver=>newton_solver%LINEAR_SOLVER
18501 IF(
ASSOCIATED(linear_solver))
THEN 18502 NULLIFY(solver_matrices)
18503 CALL solver_matrices_create_start(solver_equations,solver_matrices,err,error,*999)
18505 SELECT CASE(solver_equations%SPARSITY_TYPE)
18507 CALL solver_matrices_storage_type_set(solver_matrices,[distributed_matrix_compressed_row_storage_type], &
18510 CALL solver_matrices_storage_type_set(solver_matrices,[distributed_matrix_block_storage_type], &
18513 local_error=
"The specified solver equations sparsity type of "// &
18514 & trim(numbertovstring(solver_equations%SPARSITY_TYPE,
"*",err,error))//
" is invalid." 18515 CALL flagerror(local_error,err,error,*999)
18517 CALL solver_matrices_create_finish(solver_matrices,err,error,*999)
18519 linear_solver%SOLVER_EQUATIONS=>solver%SOLVER_EQUATIONS
18523 SELECT CASE(linear_solver%LINEAR_SOLVER%LINEAR_SOLVE_TYPE)
18525 CALL petsc_snessetksp(linesearch_solver%snes,linear_solver%linear_solver%direct_solver%ksp,err,error,*999)
18527 CALL petsc_snessetksp(linesearch_solver%snes,linear_solver%linear_solver%iterative_solver%ksp,err,error,*999)
18531 residual_vector=>solver_matrices%RESIDUAL
18532 IF(
ASSOCIATED(residual_vector))
THEN 18533 IF(
ASSOCIATED(residual_vector%PETSC))
THEN 18535 CALL petsc_snessetapplicationcontext(linesearch_solver%snes,linesearch_solver%NEWTON_SOLVER% &
18536 & nonlinear_solver%SOLVER,err,error,*999)
18538 CALL petsc_snessetfunction(linesearch_solver%snes,residual_vector%PETSC%VECTOR, &
18539 & problem_solverresidualevaluatepetsc,linesearch_solver%NEWTON_SOLVER%NONLINEAR_SOLVER%SOLVER, &
18541 SELECT CASE(linesearch_solver%NEWTON_SOLVER%convergenceTestType)
18545 CALL petsc_snessetconvergencetest(linesearch_solver%snes,problem_solverconvergencetestpetsc, &
18546 & linesearch_solver%NEWTON_SOLVER%NONLINEAR_SOLVER%SOLVER,err,error,*999)
18548 local_error=
"The specified convergence test type of "//trim(numbertovstring(linesearch_solver% &
18549 & newton_solver%convergenceTestType,
"*",err,error))//
" is invalid." 18550 CALL flagerror(local_error,err,error,*999)
18553 CALL flagerror(
"The residual vector PETSc is not associated.",err,error,*999)
18556 CALL flagerror(
"Solver matrices residual vector is not associated.",err,error,*999)
18560 IF(solver_matrices%NUMBER_OF_MATRICES==1)
THEN 18561 solver_jacobian=>solver_matrices%MATRICES(1)%PTR
18562 IF(
ASSOCIATED(solver_jacobian))
THEN 18563 jacobian_matrix=>solver_jacobian%MATRIX
18564 IF(
ASSOCIATED(jacobian_matrix))
THEN 18565 IF(
ASSOCIATED(jacobian_matrix%PETSC))
THEN 18566 SELECT CASE(newton_solver%JACOBIAN_CALCULATION_TYPE)
18568 CALL flagerror(
"Cannot have no Jacobian calculation for a PETSc nonlinear linesearch solver.", &
18571 solver_jacobian%UPDATE_MATRIX=.true.
18573 CALL petsc_snessetjacobian(linesearch_solver%snes,jacobian_matrix%PETSC%MATRIX, &
18574 & jacobian_matrix%PETSC%MATRIX,problem_solverjacobianevaluatepetsc, &
18575 & linesearch_solver%NEWTON_SOLVER%NONLINEAR_SOLVER%SOLVER,err,error,*999)
18577 solver_jacobian%UPDATE_MATRIX=.false.
18578 CALL distributed_matrix_form(jacobian_matrix,err,error,*999)
18579 SELECT CASE(solver_equations%SPARSITY_TYPE)
18581 CALL petsc_matcoloringcreate(jacobian_matrix%petsc%matrix,linesearch_solver%jacobianMatColoring, &
18583 CALL petsc_matcoloringsettype(linesearch_solver%jacobianMatColoring,petsc_matcoloring_sl, &
18585 CALL petsc_matcoloringsetfromoptions(linesearch_solver%jacobianMatColoring,err,error,*999)
18586 CALL petsc_matcoloringapply(linesearch_solver%jacobianMatColoring,linesearch_solver% &
18587 & jacobianiscoloring,err,error,*999)
18588 CALL petsc_matcoloringdestroy(linesearch_solver%jacobianMatColoring,err,error,*999)
18590 CALL petsc_matfdcoloringcreate(jacobian_matrix%petsc%matrix,linesearch_solver%jacobianISColoring, &
18591 & linesearch_solver%jacobianMatFDColoring,err,error,*999)
18593 CALL petsc_matfdcoloringsetfunction(linesearch_solver%jacobianMatFDColoring, &
18594 & problem_solverresidualevaluatepetsc,linesearch_solver%NEWTON_SOLVER%NONLINEAR_SOLVER% &
18595 & solver,err,error,*999)
18596 CALL petsc_matfdcoloringsetfromoptions(linesearch_solver%jacobianMatFDColoring,err,error,*999)
18597 CALL petsc_matfdcoloringsetup(jacobian_matrix%petsc%matrix,linesearch_solver%jacobianISColoring, &
18598 & linesearch_solver%jacobianMatFDColoring,err,error,*999)
18599 CALL petsc_iscoloringdestroy(linesearch_solver%jacobianISColoring,err,error,*999)
18603 local_error=
"The specified solver equations sparsity type of "// &
18604 & trim(numbertovstring(solver_equations%SPARSITY_TYPE,
"*",err,error))//
" is invalid." 18605 CALL flagerror(local_error,err,error,*999)
18607 CALL petsc_snessetjacobian(linesearch_solver%snes,jacobian_matrix%petsc%matrix, &
18608 & jacobian_matrix%petsc%matrix,problem_solverjacobianfdcalculatepetsc,linesearch_solver% &
18609 & newton_solver%NONLINEAR_SOLVER%SOLVER,err,error,*999)
18611 local_error=
"The Jacobian calculation type of "// &
18612 & trim(numbertovstring(newton_solver%JACOBIAN_CALCULATION_TYPE,
"*",err,error))// &
18614 CALL flagerror(local_error,err,error,*999)
18617 CALL flagerror(
"Jacobian matrix PETSc is not associated.",err,error,*999)
18620 CALL flagerror(
"Solver Jacobian matrix is not associated.",err,error,*999)
18623 CALL flagerror(
"The solver Jacobian is not associated.",err,error,*999)
18626 local_error=
"Invalid number of solver matrices. The number of solver matrices is "// &
18627 & trim(numbertovstring(solver_matrices%NUMBER_OF_MATRICES,
"*",err,error))//
" and it should be 1." 18628 CALL flagerror(local_error,err,error,*999)
18633 CALL petsc_snesmonitorset(linesearch_solver%snes,problem_solvernonlinearmonitorpetsc, &
18634 & linesearch_solver%NEWTON_SOLVER%NONLINEAR_SOLVER%SOLVER,err,error,*999)
18636 CALL petsc_snesgetlinesearch(linesearch_solver%snes,linesearch_solver%snesLineSearch,err,error,*999)
18638 SELECT CASE(linesearch_solver%linesearch_type)
18640 CALL petsc_sneslinesearchsettype(linesearch_solver%snesLineSearch,petsc_snes_linesearch_basic,err,error,*999)
18641 CALL petsc_sneslinesearchsetcomputenorms(linesearch_solver%snesLineSearch,.false.,err,error,*999)
18643 CALL petsc_sneslinesearchsettype(linesearch_solver%snesLineSearch,petsc_snes_linesearch_cp,err,error,*999)
18644 CALL petsc_sneslinesearchsetorder(linesearch_solver%snesLineSearch,petsc_snes_linesearch_order_linear, &
18647 CALL petsc_sneslinesearchsettype(linesearch_solver%snesLineSearch,petsc_snes_linesearch_bt,err,error,*999)
18648 CALL petsc_sneslinesearchsetorder(linesearch_solver%snesLineSearch,petsc_snes_linesearch_order_quadratic, &
18651 CALL petsc_sneslinesearchsettype(linesearch_solver%snesLineSearch,petsc_snes_linesearch_bt,err,error,*999)
18652 CALL petsc_sneslinesearchsetorder(linesearch_solver%snesLineSearch,petsc_snes_linesearch_order_cubic, &
18655 local_error=
"The nonlinear Newton line search type of "// &
18656 & trim(numbertovstring(linesearch_solver%linesearch_type,
"*",err,error))//
" is invalid." 18657 CALL flagerror(local_error,err,error,*999)
18659 SELECT CASE(linesearch_solver%linesearch_type)
18662 CALL petsc_sneslinesearchbtsetalpha(linesearch_solver%snesLineSearch,linesearch_solver%LINESEARCH_ALPHA, &
18667 CALL petsc_sneslinesearchsettolerances(linesearch_solver%snesLineSearch, &
18668 & linesearch_solver%LINESEARCH_STEPTOLERANCE,linesearch_solver%LINESEARCH_MAXSTEP, &
18669 & petsc_default_real,petsc_default_real,petsc_default_real,petsc_default_integer,err,error,*999)
18670 IF(linesearch_solver%linesearchMonitorOutput)
THEN 18671 CALL petsc_sneslinesearchsetmonitor(linesearch_solver%snesLineSearch,petsc_true,err,error,*999)
18673 CALL petsc_sneslinesearchsetmonitor(linesearch_solver%snesLineSearch,petsc_false,err,error,*999)
18676 CALL petsc_snessettolerances(linesearch_solver%snes,newton_solver%ABSOLUTE_TOLERANCE, &
18677 & newton_solver%RELATIVE_TOLERANCE,newton_solver%SOLUTION_TOLERANCE, &
18678 & newton_solver%MAXIMUM_NUMBER_OF_ITERATIONS, &
18679 & newton_solver%MAXIMUM_NUMBER_OF_FUNCTION_EVALUATIONS,err,error,*999)
18681 CALL petsc_snessetfromoptions(linesearch_solver%snes,err,error,*999)
18683 CALL flagerror(
"Newton linesearch solver linear solver is not associated.",err,error,*999)
18686 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
18689 local_error=
"The solver library type of "// &
18690 & trim(numbertovstring(linesearch_solver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid." 18691 CALL flagerror(local_error,err,error,*999)
18694 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
18697 CALL flagerror(
"Nonlinear solver solver is not associated.",err,error,*999)
18700 CALL flagerror(
"Newton solver nonlinear solver is not associated.",err,error,*999)
18703 CALL flagerror(
"Linesearch solver Newton solver is not associated.",err,error,*999)
18706 CALL flagerror(
"Line search solver is not associated.",err,error,*999)
18709 exits(
"SOLVER_NEWTON_LINESEARCH_CREATE_FINISH")
18711 999 errorsexits(
"SOLVER_NEWTON_LINESEARCH_CREATE_FINISH",err,error)
18724 TYPE(newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
18725 INTEGER(INTG),
INTENT(OUT) :: ERR
18726 TYPE(varying_string),
INTENT(OUT) :: ERROR
18729 enters(
"SOLVER_NEWTON_LINESEARCH_FINALISE",err,error,*999)
18731 IF(
ASSOCIATED(linesearch_solver))
THEN 18732 CALL petsc_matcoloringfinalise(linesearch_solver%jacobianMatColoring,err,error,*999)
18733 CALL petsc_iscoloringfinalise(linesearch_solver%jacobianISColoring,err,error,*999)
18734 CALL petsc_matfdcoloringfinalise(linesearch_solver%jacobianMatFDColoring,err,error,*999)
18735 CALL petsc_sneslinesearchfinalise(linesearch_solver%snesLineSearch,err,error,*999)
18736 CALL petsc_snesfinalise(linesearch_solver%snes,err,error,*999)
18737 DEALLOCATE(linesearch_solver)
18740 exits(
"SOLVER_NEWTON_LINESEARCH_FINALISE")
18742 999 errorsexits(
"SOLVER_NEWTON_LINESEARCH_FINALISE",err,error)
18755 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
18756 INTEGER(INTG),
INTENT(OUT) :: ERR
18757 TYPE(varying_string),
INTENT(OUT) :: ERROR
18759 INTEGER(INTG) :: DUMMY_ERR
18760 TYPE(varying_string) :: DUMMY_ERROR
18762 enters(
"SOLVER_NEWTON_LINESEARCH_INITIALISE",err,error,*998)
18764 IF(
ASSOCIATED(newton_solver))
THEN 18765 IF(
ASSOCIATED(newton_solver%LINESEARCH_SOLVER))
THEN 18766 CALL flagerror(
"Netwon line search solver is already associated for this Newton solver.",err,error,*998)
18769 ALLOCATE(newton_solver%LINESEARCH_SOLVER,stat=err)
18770 IF(err/=0)
CALL flagerror(
"Could not allocate nonlinear solver Newton line search solver.",err,error,*999)
18771 newton_solver%LINESEARCH_SOLVER%NEWTON_SOLVER=>newton_solver
18773 newton_solver%LINESEARCH_SOLVER%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
18775 newton_solver%LINESEARCH_SOLVER%LINESEARCH_ALPHA=0.0001_dp
18776 newton_solver%LINESEARCH_SOLVER%LINESEARCH_MAXSTEP=1.0e8_dp
18777 newton_solver%LINESEARCH_SOLVER%LINESEARCH_STEPTOLERANCE=convergence_tolerance
18778 CALL petsc_matcoloringinitialise(newton_solver%LINESEARCH_SOLVER%jacobianMatColoring,err,error,*999)
18779 CALL petsc_iscoloringinitialise(newton_solver%LINESEARCH_SOLVER%jacobianISColoring,err,error,*999)
18780 CALL petsc_matfdcoloringinitialise(newton_solver%LINESEARCH_SOLVER%jacobianMatFDColoring,err,error,*999)
18781 CALL petsc_snesinitialise(newton_solver%LINESEARCH_SOLVER%snes,err,error,*999)
18782 CALL petsc_sneslinesearchinitialise(newton_solver%LINESEARCH_SOLVER%snesLineSearch,err,error,*999)
18783 newton_solver%LINESEARCH_SOLVER%linesearchMonitorOutput=.false.
18786 CALL flagerror(
"Newton solver is not associated.",err,error,*998)
18789 exits(
"SOLVER_NEWTON_LINESEARCH_INITIALISE")
18792 998 errorsexits(
"SOLVER_NEWTON_LINESEARCH_INITIALISE",err,error)
18805 TYPE(solver_type),
POINTER :: SOLVER
18806 REAL(DP),
INTENT(IN) :: LINESEARCH_MAXSTEP
18807 INTEGER(INTG),
INTENT(OUT) :: ERR
18808 TYPE(varying_string),
INTENT(OUT) :: ERROR
18810 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
18811 TYPE(newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
18812 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
18813 TYPE(varying_string) :: LOCAL_ERROR
18815 enters(
"SOLVER_NEWTON_LINESEARCH_MAXSTEP_SET",err,error,*999)
18817 IF(
ASSOCIATED(solver))
THEN 18818 IF(solver%SOLVER_FINISHED)
THEN 18819 CALL flagerror(
"Solver has already been finished.",err,error,*999)
18822 nonlinear_solver=>solver%NONLINEAR_SOLVER
18823 IF(
ASSOCIATED(nonlinear_solver))
THEN 18825 newton_solver=>nonlinear_solver%NEWTON_SOLVER
18826 IF(
ASSOCIATED(newton_solver))
THEN 18828 linesearch_solver=>newton_solver%LINESEARCH_SOLVER
18829 IF(
ASSOCIATED(linesearch_solver))
THEN 18830 IF(linesearch_maxstep>zero_tolerance)
THEN 18831 linesearch_solver%LINESEARCH_MAXSTEP=linesearch_maxstep
18833 local_error=
"The specified line search maximum step of "// &
18834 & trim(numbertovstring(linesearch_maxstep,
"*",err,error))// &
18835 &
" is invalid. The line search maximum step must be > 0." 18836 CALL flagerror(local_error,err,error,*999)
18839 CALL flagerror(
"The Newton solver line search solver is not associated.",err,error,*999)
18842 CALL flagerror(
"The Newton solver is not a line search solver.",err,error,*999)
18845 CALL flagerror(
"The nonlinear solver Newton solver is not associated.",err,error,*999)
18848 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
18851 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
18854 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
18858 CALL flagerror(
"Solver is not associated.",err,error,*999)
18861 exits(
"SOLVER_NEWTON_LINESEARCH_MAXSTEP_SET")
18863 999 errorsexits(
"SOLVER_NEWTON_LINESEARCH_MAXSTEP_SET",err,error)
18876 TYPE(newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
18877 INTEGER(INTG),
INTENT(OUT) :: ERR
18878 TYPE(varying_string),
INTENT(OUT) :: ERROR
18880 INTEGER(INTG) :: CONVERGED_REASON,NUMBER_ITERATIONS
18881 REAL(DP) :: FUNCTION_NORM
18882 TYPE(distributed_vector_type),
POINTER :: RHS_VECTOR,SOLVER_VECTOR
18883 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
18884 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
18885 TYPE(petscvectype) :: FUNCTION_VECTOR
18886 TYPE(solver_type),
POINTER :: SOLVER
18887 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
18888 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
18889 TYPE(varying_string) :: LOCAL_ERROR
18891 enters(
"SOLVER_NEWTON_LINESEARCH_SOLVE",err,error,*999)
18893 IF(
ASSOCIATED(linesearch_solver))
THEN 18894 newton_solver=>linesearch_solver%NEWTON_SOLVER
18895 IF(
ASSOCIATED(newton_solver))
THEN 18896 nonlinear_solver=>newton_solver%NONLINEAR_SOLVER
18897 IF(
ASSOCIATED(nonlinear_solver))
THEN 18898 solver=>nonlinear_solver%SOLVER
18899 IF(
ASSOCIATED(solver))
THEN 18900 solver_equations=>solver%SOLVER_EQUATIONS
18901 IF(
ASSOCIATED(solver_equations))
THEN 18902 solver_matrices=>solver_equations%SOLVER_MATRICES
18903 IF(
ASSOCIATED(solver_matrices))
THEN 18904 IF(solver_matrices%NUMBER_OF_MATRICES==1)
THEN 18905 rhs_vector=>solver_matrices%RHS_VECTOR
18906 IF(
ASSOCIATED(rhs_vector))
THEN 18907 solver_vector=>solver_matrices%MATRICES(1)%PTR%SOLVER_VECTOR
18908 IF(
ASSOCIATED(solver_vector))
THEN 18909 SELECT CASE(linesearch_solver%SOLVER_LIBRARY)
18911 CALL flagerror(
"Not implemented.",err,error,*999)
18913 SELECT CASE(newton_solver%SOLUTION_INITIALISE_TYPE)
18916 CALL distributed_vector_all_values_set(solver_vector,0.0_dp,err,error,*999)
18923 local_error=
"The Newton solver solution initialise type of "// &
18924 & trim(numbertovstring(newton_solver%SOLUTION_INITIALISE_TYPE,
"*",err,error))// &
18926 CALL flagerror(local_error,err,error,*999)
18929 CALL petsc_snessolve(linesearch_solver%snes,rhs_vector%PETSC%VECTOR,solver_vector%PETSC%VECTOR, &
18932 CALL petsc_snesgetconvergedreason(linesearch_solver%snes,converged_reason,err,error,*999)
18933 SELECT CASE(converged_reason)
18934 CASE(petsc_snes_diverged_function_domain)
18935 CALL flagerror(
"Nonlinear line search solver did not converge. PETSc diverged function domain.", &
18937 CASE(petsc_snes_diverged_function_count)
18938 CALL flagerror(
"Nonlinear line search solver did not converge. PETSc diverged function count.", &
18940 CASE(petsc_snes_diverged_linear_solve)
18941 CALL flagerror(
"Nonlinear line search solver did not converge. PETSc diverged linear solve.", &
18943 CASE(petsc_snes_diverged_fnorm_nan)
18944 CALL flagerror(
"Nonlinear line search solver did not converge. PETSc diverged F Norm NaN.", &
18946 CASE(petsc_snes_diverged_max_it)
18947 CALL flagerror(
"Nonlinear line search solver did not converge. PETSc diverged maximum iterations.", &
18949 CASE(petsc_snes_diverged_line_search)
18950 CALL flagerror(
"Nonlinear line search solver did not converge. PETSc diverged line search.", &
18952 CASE(petsc_snes_diverged_local_min)
18953 CALL flagerror(
"Nonlinear line search solver did not converge. PETSc diverged local minimum.", &
18958 CALL write_string(general_output_type,
"",err,error,*999)
18959 CALL write_string(general_output_type,
"Newton linesearch solver parameters:",err,error,*999)
18960 CALL petsc_snesgetiterationnumber(linesearch_solver%snes,number_iterations,err,error,*999)
18961 CALL write_string_value(general_output_type,
"Final number of iterations = ",number_iterations, &
18963 CALL petsc_snesgetfunction(linesearch_solver%snes,function_vector,err,error,*999)
18964 CALL petsc_vecnorm(function_vector,petsc_norm_2,function_norm,err,error,*999)
18965 CALL write_string_value(general_output_type,
"Final function norm = ",function_norm, &
18967 SELECT CASE(converged_reason)
18968 CASE(petsc_snes_converged_fnorm_abs)
18969 CALL write_string(general_output_type,
"Converged Reason = PETSc converged F Norm absolute.", &
18971 CASE(petsc_snes_converged_fnorm_relative)
18972 CALL write_string(general_output_type,
"Converged Reason = PETSc converged F Norm relative.", &
18974 CASE(petsc_snes_converged_snorm_relative)
18975 CALL write_string(general_output_type,
"Converged Reason = PETSc converged S Norm relative.", &
18977 CASE(petsc_snes_converged_its)
18978 CALL write_string(general_output_type,
"Converged Reason = PETSc converged its.",err,error,*999)
18979 CASE(petsc_snes_converged_iterating)
18980 CALL write_string(general_output_type,
"Converged Reason = PETSc converged iterating.",err,error,*999)
18984 local_error=
"The Newton line search solver library type of "// &
18985 & trim(numbertovstring(linesearch_solver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid." 18986 CALL flagerror(local_error,err,error,*999)
18989 CALL flagerror(
"Solver vector is not associated.",err,error,*999)
18992 CALL flagerror(
"Solver RHS vector is not associated.",err,error,*999)
18995 local_error=
"The number of solver matrices of "// &
18996 & trim(numbertovstring(solver_matrices%NUMBER_OF_MATRICES,
"*",err,error))// &
18997 &
" is invalid. There should only be one solver matrix for a Newton linesearch solver." 18998 CALL flagerror(local_error,err,error,*999)
19001 CALL flagerror(
"Solver matrices is not associated.",err,error,*999)
19004 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
19007 CALL flagerror(
"Nonlinear solver solver is not associated.",err,error,*999)
19010 CALL flagerror(
"Newton solver nonlinear solver is not associated.",err,error,*999)
19013 CALL flagerror(
"Linesearch solver Newton solver is not associated.",err,error,*999)
19016 CALL flagerror(
"Linesearch solver is not associated.",err,error,*999)
19019 exits(
"SOLVER_NEWTON_LINESEARCH_SOLVE")
19021 999 errorsexits(
"SOLVER_NEWTON_LINESEARCH_SOLVE",err,error)
19034 TYPE(solver_type),
POINTER :: SOLVER
19035 REAL(DP),
INTENT(IN) :: LINESEARCH_STEPTOL
19036 INTEGER(INTG),
INTENT(OUT) :: ERR
19037 TYPE(varying_string),
INTENT(OUT) :: ERROR
19039 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
19040 TYPE(newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
19041 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
19042 TYPE(varying_string) :: LOCAL_ERROR
19044 enters(
"SOLVER_NEWTON_LINESEARCH_STEPTOL_SET",err,error,*999)
19046 IF(
ASSOCIATED(solver))
THEN 19047 IF(solver%SOLVER_FINISHED)
THEN 19048 CALL flagerror(
"Solver has already been finished.",err,error,*999)
19051 nonlinear_solver=>solver%NONLINEAR_SOLVER
19052 IF(
ASSOCIATED(nonlinear_solver))
THEN 19054 newton_solver=>nonlinear_solver%NEWTON_SOLVER
19055 IF(
ASSOCIATED(newton_solver))
THEN 19057 linesearch_solver=>newton_solver%LINESEARCH_SOLVER
19058 IF(
ASSOCIATED(linesearch_solver))
THEN 19059 IF(linesearch_steptol>zero_tolerance)
THEN 19060 linesearch_solver%LINESEARCH_STEPTOLERANCE=linesearch_steptol
19062 local_error=
"The specified line search step tolerance of "// &
19063 & trim(numbertovstring(linesearch_steptol,
"*",err,error))// &
19064 &
" is invalid. The line search step tolerance must be > 0." 19065 CALL flagerror(local_error,err,error,*999)
19068 CALL flagerror(
"The Newton solver line search solver is not associated.",err,error,*999)
19071 CALL flagerror(
"The Newton solver is not a line search solver.",err,error,*999)
19074 CALL flagerror(
"The nonlinear Newton solver is not associated.",err,error,*999)
19077 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
19080 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
19083 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
19087 CALL flagerror(
"Solver is not associated.",err,error,*999)
19090 exits(
"SOLVER_NEWTON_LINESEARCH_STEPTOL_SET")
19092 999 errorsexits(
"SOLVER_NEWTON_LINESEARCH_STEPTOL_SET",err,error)
19105 TYPE(solver_type),
POINTER :: SOLVER
19106 INTEGER(INTG),
INTENT(IN) :: LINESEARCH_TYPE
19107 INTEGER(INTG),
INTENT(OUT) :: ERR
19108 TYPE(varying_string),
INTENT(OUT) :: ERROR
19110 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
19111 TYPE(newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
19112 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
19113 TYPE(varying_string) :: LOCAL_ERROR
19115 enters(
"SOLVER_NEWTON_LINESEARCH_TYPE_SET",err,error,*999)
19117 IF(
ASSOCIATED(solver))
THEN 19118 IF(solver%SOLVER_FINISHED)
THEN 19119 CALL flagerror(
"Solver has already been finished.",err,error,*999)
19122 nonlinear_solver=>solver%NONLINEAR_SOLVER
19123 IF(
ASSOCIATED(nonlinear_solver))
THEN 19125 newton_solver=>nonlinear_solver%NEWTON_SOLVER
19126 IF(
ASSOCIATED(newton_solver))
THEN 19128 linesearch_solver=>newton_solver%LINESEARCH_SOLVER
19129 IF(
ASSOCIATED(linesearch_solver))
THEN 19130 SELECT CASE(linesearch_type)
19140 local_error=
"The specified line search type of "//trim(numbertovstring(linesearch_type,
"*",err,error))// &
19142 CALL flagerror(local_error,err,error,*999)
19145 CALL flagerror(
"The Newton solver line search solver is not associated.",err,error,*999)
19148 CALL flagerror(
"The Newton solver is not a line search solver.",err,error,*999)
19151 CALL flagerror(
"The nonlinear solver Newton solver is not associated.",err,error,*999)
19154 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
19157 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
19160 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
19164 CALL flagerror(
"Solver is not associated.",err,error,*999)
19167 exits(
"SOLVER_NEWTON_LINESEARCH_TYPE_SET")
19169 999 errorsexits(
"SOLVER_NEWTON_LINESEARCH_TYPE_SET",err,error)
19182 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
19183 INTEGER(INTG),
INTENT(OUT) :: MATRICES_LIBRARY_TYPE
19184 INTEGER(INTG),
INTENT(OUT) :: ERR
19185 TYPE(varying_string),
INTENT(OUT) :: ERROR
19187 TYPE(newton_linesearch_solver_type),
POINTER :: LINESEARCH_SOLVER
19188 TYPE(newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
19189 TYPE(varying_string) :: LOCAL_ERROR
19191 enters(
"SOLVER_NEWTON_LIBRARY_TYPE_GET",err,error,*999)
19193 IF(
ASSOCIATED(newton_solver))
THEN 19194 SELECT CASE(newton_solver%NEWTON_SOLVE_TYPE)
19196 linesearch_solver=>newton_solver%LINESEARCH_SOLVER
19197 IF(
ASSOCIATED(linesearch_solver))
THEN 19198 matrices_library_type=linesearch_solver%SOLVER_MATRICES_LIBRARY
19200 CALL flagerror(
"Newton line search solver is not associated.",err,error,*999)
19203 trustregion_solver=>newton_solver%TRUSTREGION_SOLVER
19204 IF(
ASSOCIATED(trustregion_solver))
THEN 19205 matrices_library_type=trustregion_solver%SOLVER_MATRICES_LIBRARY
19207 CALL flagerror(
"Newton trust region solver is not associated.",err,error,*999)
19210 local_error=
"The Newton solver type of "// &
19211 & trim(numbertovstring(newton_solver%NEWTON_SOLVE_TYPE,
"*",err,error))//
" is invalid." 19212 CALL flagerror(local_error,err,error,*999)
19215 CALL flagerror(
"Newton solver is not associated.",err,error,*999)
19218 exits(
"SOLVER_NEWTON_MATRICES_LIBRARY_TYPE_GET")
19220 999 errorsexits(
"SOLVER_NEWTON_MATRICES_LIBRARY_TYPE_GET",err,error)
19233 TYPE(solver_type),
POINTER :: SOLVER
19234 INTEGER(INTG),
INTENT(IN) :: MAXIMUM_FUNCTION_EVALUATIONS
19235 INTEGER(INTG),
INTENT(OUT) :: ERR
19236 TYPE(varying_string),
INTENT(OUT) :: ERROR
19238 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
19239 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
19240 TYPE(varying_string) :: LOCAL_ERROR
19242 enters(
"Solver_NewtonMaximumFunctionEvaluationsSet",err,error,*999)
19244 IF(
ASSOCIATED(solver))
THEN 19245 IF(solver%SOLVER_FINISHED)
THEN 19246 CALL flagerror(
"Solver has already been finished.",err,error,*999)
19249 nonlinear_solver=>solver%NONLINEAR_SOLVER
19250 IF(
ASSOCIATED(nonlinear_solver))
THEN 19252 newton_solver=>nonlinear_solver%NEWTON_SOLVER
19253 IF(
ASSOCIATED(newton_solver))
THEN 19254 IF(maximum_function_evaluations>0)
THEN 19255 newton_solver%MAXIMUM_NUMBER_OF_FUNCTION_EVALUATIONS=maximum_function_evaluations
19257 local_error=
"The specified maximum number of function evaluations of "// &
19258 & trim(numbertovstring(maximum_function_evaluations,
"*",err,error))// &
19259 &
" is invalid. The maximum number of function evaluations must be > 0." 19260 CALL flagerror(local_error,err,error,*999)
19263 CALL flagerror(
"The nonlinear solver Newton solver is not associated.",err,error,*999)
19266 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
19269 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
19272 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
19276 CALL flagerror(
"Solver is not associated.",err,error,*999)
19279 exits(
"Solver_NewtonMaximumFunctionEvaluationsSet")
19281 999 errorsexits(
"Solver_NewtonMaximumFunctionEvaluationsSet",err,error)
19294 TYPE(solver_type),
POINTER :: SOLVER
19295 INTEGER(INTG),
INTENT(IN) :: MAXIMUM_ITERATIONS
19296 INTEGER(INTG),
INTENT(OUT) :: ERR
19297 TYPE(varying_string),
INTENT(OUT) :: ERROR
19299 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
19300 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
19301 TYPE(varying_string) :: LOCAL_ERROR
19303 enters(
"SOLVER_NEWTON_MAXIMUM_ITERATIONS_SET",err,error,*999)
19305 IF(
ASSOCIATED(solver))
THEN 19306 IF(solver%SOLVER_FINISHED)
THEN 19307 CALL flagerror(
"Solver has already been finished.",err,error,*999)
19310 nonlinear_solver=>solver%NONLINEAR_SOLVER
19311 IF(
ASSOCIATED(nonlinear_solver))
THEN 19313 newton_solver=>nonlinear_solver%NEWTON_SOLVER
19314 IF(
ASSOCIATED(newton_solver))
THEN 19315 IF(maximum_iterations>0)
THEN 19316 newton_solver%MAXIMUM_NUMBER_OF_ITERATIONS=maximum_iterations
19318 local_error=
"The specified maximum iterations of "//trim(numbertovstring(maximum_iterations,
"*",err,error))// &
19319 &
" is invalid. The maximum number of iterations must be > 0." 19320 CALL flagerror(local_error,err,error,*999)
19323 CALL flagerror(
"Nonlinear sovler Newton solver is not associated.",err,error,*999)
19326 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
19329 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
19332 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
19336 CALL flagerror(
"Solver is not associated.",err,error,*999)
19339 exits(
"SOLVER_NEWTON_MAXIMUM_ITERATIONS_SET")
19341 999 errorsexits(
"SOLVER_NEWTON_MAXIMUM_ITERATIONS_SET",err,error)
19354 TYPE(solver_type),
POINTER :: SOLVER
19355 REAL(DP),
INTENT(IN) :: RELATIVE_TOLERANCE
19356 INTEGER(INTG),
INTENT(OUT) :: ERR
19357 TYPE(varying_string),
INTENT(OUT) :: ERROR
19359 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
19360 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
19361 TYPE(varying_string) :: LOCAL_ERROR
19363 enters(
"SOLVER_NEWTON_RELATIVE_TOLERANCE_SET",err,error,*999)
19365 IF(
ASSOCIATED(solver))
THEN 19366 IF(solver%SOLVER_FINISHED)
THEN 19367 CALL flagerror(
"Solver has already been finished.",err,error,*999)
19370 nonlinear_solver=>solver%NONLINEAR_SOLVER
19371 IF(
ASSOCIATED(nonlinear_solver))
THEN 19373 newton_solver=>nonlinear_solver%NEWTON_SOLVER
19374 IF(
ASSOCIATED(newton_solver))
THEN 19375 IF(relative_tolerance>zero_tolerance)
THEN 19376 newton_solver%RELATIVE_TOLERANCE=relative_tolerance
19378 local_error=
"The specified relative tolerance of "//trim(numbertovstring(relative_tolerance,
"*",err,error))// &
19379 &
" is invalid. The relative tolerance must be > 0." 19380 CALL flagerror(local_error,err,error,*999)
19383 CALL flagerror(
"The nonlinear solver Newton solver is not associated.",err,error,*999)
19386 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
19389 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
19392 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
19396 CALL flagerror(
"Solver is not associated.",err,error,*999)
19399 exits(
"SOLVER_NEWTON_RELATIVE_TOLERANCE_SET")
19401 999 errorsexits(
"SOLVER_NEWTON_RELATIVE_TOLERANCE_SET",err,error)
19414 TYPE(solver_type),
POINTER :: SOLVER
19415 INTEGER(INTG),
INTENT(IN) :: SOLUTION_INITIALISE_TYPE
19416 INTEGER(INTG),
INTENT(OUT) :: ERR
19417 TYPE(varying_string),
INTENT(OUT) :: ERROR
19419 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
19420 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
19421 TYPE(varying_string) :: LOCAL_ERROR
19423 enters(
"SOLVER_NEWTON_SOLUTION_INIT_TYPE_SET",err,error,*999)
19425 IF(
ASSOCIATED(solver))
THEN 19426 IF(solver%SOLVER_FINISHED)
THEN 19427 CALL flagerror(
"Solver has already been finished.",err,error,*999)
19430 nonlinear_solver=>solver%NONLINEAR_SOLVER
19431 IF(
ASSOCIATED(nonlinear_solver))
THEN 19433 newton_solver=>nonlinear_solver%NEWTON_SOLVER
19434 IF(
ASSOCIATED(newton_solver))
THEN 19435 SELECT CASE(solution_initialise_type)
19443 local_error=
"The specified solution initialise type of "// &
19444 & trim(numbertovstring(solution_initialise_type,
"*",err,error))//
" is invalid." 19445 CALL flagerror(local_error,err,error,*999)
19448 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
19451 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
19454 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
19457 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
19461 CALL flagerror(
"Solver is not associated.",err,error,*999)
19464 exits(
"SOLVER_NEWTON_SOLUTION_INIT_TYPE_SET")
19466 999 errorsexits(
"SOLVER_NEWTON_SOLUTION_INIT_TYPE_SET",err,error)
19479 TYPE(solver_type),
POINTER :: SOLVER
19480 REAL(DP),
INTENT(IN) :: SOLUTION_TOLERANCE
19481 INTEGER(INTG),
INTENT(OUT) :: ERR
19482 TYPE(varying_string),
INTENT(OUT) :: ERROR
19484 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
19485 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
19486 TYPE(varying_string) :: LOCAL_ERROR
19488 enters(
"SOLVER_NEWTON_SOLUTION_TOLERANCE_SET",err,error,*999)
19490 IF(
ASSOCIATED(solver))
THEN 19491 IF(solver%SOLVER_FINISHED)
THEN 19492 CALL flagerror(
"Solver has already been finished.",err,error,*999)
19495 nonlinear_solver=>solver%NONLINEAR_SOLVER
19496 IF(
ASSOCIATED(nonlinear_solver))
THEN 19498 newton_solver=>nonlinear_solver%NEWTON_SOLVER
19499 IF(
ASSOCIATED(newton_solver))
THEN 19500 IF(solution_tolerance>zero_tolerance)
THEN 19501 newton_solver%SOLUTION_TOLERANCE=solution_tolerance
19503 local_error=
"The specified solution tolerance of "//trim(numbertovstring(solution_tolerance,
"*",err,error))// &
19504 &
" is invalid. The relative tolerance must be > 0." 19505 CALL flagerror(local_error,err,error,*999)
19508 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
19511 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
19514 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
19517 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
19521 CALL flagerror(
"Solver is not associated.",err,error,*999)
19524 exits(
"SOLVER_NEWTON_SOLUTION_TOLERANCE_SET")
19526 999 errorsexits(
"SOLVER_NEWTON_SOLUTION_TOLERANCE_SET",err,error)
19539 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
19540 INTEGER(INTG),
INTENT(OUT) :: ERR
19541 TYPE(varying_string),
INTENT(OUT) :: ERROR
19543 TYPE(varying_string) :: LOCAL_ERROR
19545 enters(
"SOLVER_NEWTON_SOLVE",err,error,*999)
19547 IF(
ASSOCIATED(newton_solver))
THEN 19548 SELECT CASE(newton_solver%NEWTON_SOLVE_TYPE)
19554 local_error=
"The nonlinear solver type of "// &
19555 & trim(numbertovstring(newton_solver%NEWTON_SOLVE_TYPE,
"*",err,error))//
" is invalid." 19556 CALL flagerror(local_error,err,error,*999)
19559 CALL flagerror(
"Newton solver is not associated.",err,error,*999)
19562 exits(
"SOLVER_NEWTON_SOLVE")
19564 999 errorsexits(
"SOLVER_NEWTON_SOLVE",err,error)
19577 TYPE(newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
19578 INTEGER(INTG),
INTENT(OUT) :: ERR
19579 TYPE(varying_string),
INTENT(OUT) :: ERROR
19581 EXTERNAL :: problem_solverresidualevaluatepetsc
19582 INTEGER(INTG) :: equations_matrix_idx,equations_set_idx
19583 TYPE(distributed_vector_type),
POINTER :: RESIDUAL_VECTOR
19584 TYPE(equations_type),
POINTER :: EQUATIONS
19585 TYPE(equations_mapping_type),
POINTER :: EQUATIONS_MAPPING
19586 TYPE(equations_mapping_linear_type),
POINTER :: LINEAR_MAPPING
19587 TYPE(equations_matrices_type),
POINTER :: EQUATIONS_MATRICES
19588 TYPE(equations_matrices_linear_type),
POINTER :: LINEAR_MATRICES
19589 TYPE(equations_matrix_type),
POINTER :: EQUATIONS_MATRIX
19590 TYPE(equations_set_type),
POINTER :: EQUATIONS_SET
19591 TYPE(field_type),
POINTER :: DEPENDENT_FIELD
19592 TYPE(field_variable_type),
POINTER :: LINEAR_VARIABLE
19593 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
19594 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
19595 TYPE(solver_type),
POINTER :: SOLVER
19596 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
19597 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
19598 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
19599 TYPE(varying_string) :: LOCAL_ERROR
19601 enters(
"SOLVER_NEWTON_TRUSTREGION_CREATE_FINISH",err,error,*999)
19603 IF(
ASSOCIATED(trustregion_solver))
THEN 19604 newton_solver=>trustregion_solver%NEWTON_SOLVER
19605 IF(
ASSOCIATED(newton_solver))
THEN 19606 nonlinear_solver=>newton_solver%NONLINEAR_SOLVER
19607 IF(
ASSOCIATED(nonlinear_solver))
THEN 19608 solver=>nonlinear_solver%SOLVER
19609 IF(
ASSOCIATED(solver))
THEN 19610 solver_equations=>solver%SOLVER_EQUATIONS
19611 IF(
ASSOCIATED(solver_equations))
THEN 19612 SELECT CASE(trustregion_solver%SOLVER_LIBRARY)
19614 CALL flagerror(
"Not implemented.",err,error,*999)
19616 solver_mapping=>solver_equations%SOLVER_MAPPING
19617 IF(
ASSOCIATED(solver_mapping))
THEN 19619 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
19620 equations=>solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)%EQUATIONS
19621 IF(
ASSOCIATED(equations))
THEN 19622 equations_set=>equations%EQUATIONS_SET
19623 IF(
ASSOCIATED(equations_set))
THEN 19624 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
19625 IF(
ASSOCIATED(dependent_field))
THEN 19626 equations_mapping=>equations%EQUATIONS_MAPPING
19627 IF(
ASSOCIATED(equations_mapping))
THEN 19628 linear_mapping=>equations_mapping%LINEAR_MAPPING
19629 IF(
ASSOCIATED(linear_mapping))
THEN 19631 equations_matrices=>equations%EQUATIONS_MATRICES
19632 IF(
ASSOCIATED(equations_matrices))
THEN 19633 linear_matrices=>equations_matrices%LINEAR_MATRICES
19634 IF(
ASSOCIATED(linear_matrices))
THEN 19635 DO equations_matrix_idx=1,linear_matrices%NUMBER_OF_LINEAR_MATRICES
19636 equations_matrix=>linear_matrices%MATRICES(equations_matrix_idx)%PTR
19637 IF(
ASSOCIATED(equations_matrix))
THEN 19638 IF(.NOT.
ASSOCIATED(equations_matrix%TEMP_VECTOR))
THEN 19639 linear_variable=>linear_mapping%EQUATIONS_MATRIX_TO_VAR_MAPS(equations_matrix_idx)%VARIABLE
19640 IF(
ASSOCIATED(linear_variable))
THEN 19641 CALL distributed_vector_create_start(linear_variable%DOMAIN_MAPPING, &
19642 & equations_matrix%TEMP_VECTOR,err,error,*999)
19643 CALL distributed_vector_data_type_set(equations_matrix%TEMP_VECTOR, &
19644 & distributed_matrix_vector_dp_type,err,error,*999)
19645 CALL distributed_vector_create_finish(equations_matrix%TEMP_VECTOR,err,error,*999)
19647 CALL flagerror(
"Linear mapping linear variable is not associated.",err,error,*999)
19651 CALL flagerror(
"Equations matrix is not associated.",err,error,*999)
19655 CALL flagerror(
"Equations matrices linear matrices is not associated.",err,error,*999)
19658 CALL flagerror(
"Equations equations matrices is not associated.",err,error,*999)
19662 CALL flagerror(
"Equations equations mapping is not associated.",err,error,*999)
19665 local_error=
"Equations set dependent field is not associated for equations set index "// &
19666 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 19667 CALL flagerror(local_error,err,error,*999)
19670 local_error=
"Equations equations set is not associated for equations set index "// &
19671 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 19672 CALL flagerror(local_error,err,error,*999)
19675 local_error=
"Equations is not associated for equations set index "// &
19676 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 19677 CALL flagerror(local_error,err,error,*999)
19682 CALL solver_matrices_create_start(solver_equations,solver_matrices,err,error,*999)
19685 CALL solver_matrices_create_finish(solver_matrices,err,error,*999)
19687 CALL petsc_snescreate(computational_environment%MPI_COMM,trustregion_solver%snes,err,error,*999)
19689 CALL petsc_snessettype(trustregion_solver%snes,petsc_snesnewtontr,err,error,*999)
19691 CALL petsc_snessetapplicationcontext(trustregion_solver%snes,solver,err,error,*999)
19693 residual_vector=>solver_matrices%RESIDUAL
19694 IF(
ASSOCIATED(residual_vector))
THEN 19695 IF(
ASSOCIATED(residual_vector%PETSC))
THEN 19696 CALL petsc_snessetfunction(trustregion_solver%snes,residual_vector%PETSC%VECTOR, &
19697 & problem_solverresidualevaluatepetsc,solver,err,error,*999)
19698 CALL flagerror(
"The residual vector PETSc is not associated.",err,error,*999)
19701 CALL flagerror(
"Solver matrices residual vector is not associated.",err,error,*999)
19707 CALL petsc_snessettrustregiontolerance(trustregion_solver%snes,trustregion_solver%TRUSTREGION_TOLERANCE, &
19710 CALL petsc_snessettolerances(trustregion_solver%snes,newton_solver%ABSOLUTE_TOLERANCE, &
19711 & newton_solver%RELATIVE_TOLERANCE,newton_solver%SOLUTION_TOLERANCE, &
19712 & newton_solver%MAXIMUM_NUMBER_OF_ITERATIONS,newton_solver%MAXIMUM_NUMBER_OF_FUNCTION_EVALUATIONS, &
19715 CALL petsc_snessetfromoptions(trustregion_solver%snes,err,error,*999)
19717 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
19720 local_error=
"The solver library type of "// &
19721 & trim(numbertovstring(trustregion_solver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid." 19722 CALL flagerror(local_error,err,error,*999)
19725 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
19728 CALL flagerror(
"Nonlinear solver solver is not associated.",err,error,*999)
19731 CALL flagerror(
"Newton solver nonlinear solver is not associated.",err,error,*999)
19734 CALL flagerror(
"Trust region Newton solver is not associated.",err,error,*999)
19737 CALL flagerror(
"Trust region solver is not associated.",err,error,*999)
19740 exits(
"SOLVER_NEWTON_TRUSTREGION_CREATE_FINISH")
19742 999 errorsexits(
"SOLVER_NEWTON_TRUSTREGION_CREATE_FINISH",err,error)
19755 TYPE(solver_type),
POINTER :: SOLVER
19756 REAL(DP),
INTENT(IN) :: TRUSTREGION_DELTA0
19757 INTEGER(INTG),
INTENT(OUT) :: ERR
19758 TYPE(varying_string),
INTENT(OUT) :: ERROR
19760 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
19761 TYPE(newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
19762 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
19763 TYPE(varying_string) :: LOCAL_ERROR
19765 enters(
"SOLVER_NEWTON_TRUSTREGION_DELTA0_SET",err,error,*999)
19767 IF(
ASSOCIATED(solver))
THEN 19768 IF(solver%SOLVER_FINISHED)
THEN 19769 CALL flagerror(
"Solver has already been finished.",err,error,*999)
19772 nonlinear_solver=>solver%NONLINEAR_SOLVER
19773 IF(
ASSOCIATED(nonlinear_solver))
THEN 19775 newton_solver=>nonlinear_solver%NEWTON_SOLVER
19776 IF(
ASSOCIATED(newton_solver))
THEN 19778 trustregion_solver=>newton_solver%TRUSTREGION_SOLVER
19779 IF(
ASSOCIATED(trustregion_solver))
THEN 19780 IF(trustregion_delta0>zero_tolerance)
THEN 19781 trustregion_solver%TRUSTREGION_DELTA0=trustregion_delta0
19783 local_error=
"The specified trust region delta0 of "// &
19784 & trim(numbertovstring(trustregion_delta0,
"*",err,error))// &
19785 &
" is invalid. The trust region delta0 must be > 0." 19786 CALL flagerror(local_error,err,error,*999)
19789 CALL flagerror(
"The Newton solver trust region solver is not associated.",err,error,*999)
19792 CALL flagerror(
"The Newton solver is not a trust region solver.",err,error,*999)
19795 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
19798 CALL flagerror(
"Nonlinear solver is not a Newton solver.",err,error,*999)
19801 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
19804 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
19808 CALL flagerror(
"Solver is not associated.",err,error,*999)
19811 exits(
"SOLVER_NEWTON_TRUSTREGION_DELTA0_SET")
19813 999 errorsexits(
"SOLVER_NEWTON_TRUSTREGION_DELTA0_SET",err,error)
19826 TYPE(newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
19827 INTEGER(INTG),
INTENT(OUT) :: ERR
19828 TYPE(varying_string),
INTENT(OUT) :: ERROR
19831 enters(
"SOLVER_NEWTON_TRUSTREGION_FINALISE",err,error,*999)
19833 IF(
ASSOCIATED(trustregion_solver))
THEN 19834 CALL petsc_snesfinalise(trustregion_solver%snes,err,error,*999)
19835 DEALLOCATE(trustregion_solver)
19838 exits(
"SOLVER_NEWTON_TRUSTREGION_FINALISE")
19840 999 errorsexits(
"SOLVER_NEWTON_TRUSTREGION_FINALISE",err,error)
19853 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
19854 INTEGER(INTG),
INTENT(OUT) :: ERR
19855 TYPE(varying_string),
INTENT(OUT) :: ERROR
19857 INTEGER(INTG) :: DUMMY_ERR
19858 TYPE(varying_string) :: DUMMY_ERROR
19860 enters(
"SOLVER_NEWTON_TRUSTREGION_INITIALISE",err,error,*998)
19862 IF(
ASSOCIATED(newton_solver))
THEN 19863 IF(
ASSOCIATED(newton_solver%TRUSTREGION_SOLVER))
THEN 19864 CALL flagerror(
"Trust region solver is already associated for this nonlinear solver.",err,error,*998)
19866 ALLOCATE(newton_solver%TRUSTREGION_SOLVER,stat=err)
19867 IF(err/=0)
CALL flagerror(
"Could not allocate Newton solver trust region solver.",err,error,*999)
19868 newton_solver%TRUSTREGION_SOLVER%NEWTON_SOLVER=>newton_solver
19870 newton_solver%TRUSTREGION_SOLVER%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
19872 newton_solver%TRUSTREGION_SOLVER%TRUSTREGION_DELTA0=0.01_dp
19873 CALL petsc_snesinitialise(newton_solver%TRUSTREGION_SOLVER%snes,err,error,*999)
19876 CALL flagerror(
"Newton solver is not associated.",err,error,*998)
19879 exits(
"SOLVER_NEWTON_TRUSTREGION_INITIALISE")
19882 998 errorsexits(
"SOLVER_NEWTON_TRUSTREGION_INITIALISE",err,error)
19895 TYPE(newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
19896 INTEGER(INTG),
INTENT(OUT) :: ERR
19897 TYPE(varying_string),
INTENT(OUT) :: ERROR
19899 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
19900 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
19901 TYPE(solver_type),
POINTER :: SOLVER
19902 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
19903 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
19904 TYPE(varying_string) :: LOCAL_ERROR
19906 enters(
"SOLVER_NEWTON_TRUSTREGION_SOLVE",err,error,*999)
19908 IF(
ASSOCIATED(trustregion_solver))
THEN 19909 newton_solver=>trustregion_solver%NEWTON_SOLVER
19910 IF(
ASSOCIATED(newton_solver))
THEN 19911 nonlinear_solver=>newton_solver%NONLINEAR_SOLVER
19912 IF(
ASSOCIATED(nonlinear_solver))
THEN 19913 solver=>nonlinear_solver%SOLVER
19914 IF(
ASSOCIATED(solver))
THEN 19915 solver_equations=>solver%SOLVER_EQUATIONS
19916 IF(
ASSOCIATED(solver_equations))
THEN 19917 solver_matrices=>solver_equations%SOLVER_MATRICES
19918 IF(
ASSOCIATED(solver_matrices))
THEN 19919 SELECT CASE(trustregion_solver%SOLVER_LIBRARY)
19921 CALL flagerror(
"Not implemented.",err,error,*999)
19923 CALL flagerror(
"Not implemented.",err,error,*999)
19925 local_error=
"The nonlinear Newton trust region solver library type of "// &
19926 & trim(numbertovstring(trustregion_solver%SOLVER_LIBRARY,
"*",err,error))//
" is invalid." 19927 CALL flagerror(local_error,err,error,*999)
19930 CALL flagerror(
"Solver matrices is not associated.",err,error,*999)
19933 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
19936 CALL flagerror(
"Nonlinear solver solver is not associated.",err,error,*999)
19939 CALL flagerror(
"Newton solver nonlinear solver is not associated.",err,error,*999)
19942 CALL flagerror(
"Trust region solver Newton solver is not associated.",err,error,*999)
19945 CALL flagerror(
"Trust region solver is not associated.",err,error,*999)
19948 exits(
"SOLVER_NEWTON_TRUSTREGION_SOLVE")
19950 999 errorsexits(
"SOLVER_NEWTON_TRUSTREGION_SOLVE",err,error)
19963 TYPE(solver_type),
POINTER :: SOLVER
19964 REAL(DP),
INTENT(IN) :: TRUSTREGION_TOLERANCE
19965 INTEGER(INTG),
INTENT(OUT) :: ERR
19966 TYPE(varying_string),
INTENT(OUT) :: ERROR
19968 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
19969 TYPE(newton_trustregion_solver_type),
POINTER :: TRUSTREGION_SOLVER
19970 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
19971 TYPE(varying_string) :: LOCAL_ERROR
19973 enters(
"SOLVER_NEWTON_TRUSTREGION_TOLERANCE_SET",err,error,*999)
19975 IF(
ASSOCIATED(solver))
THEN 19976 IF(solver%SOLVER_FINISHED)
THEN 19977 CALL flagerror(
"Solver has already been finished.",err,error,*999)
19980 nonlinear_solver=>solver%NONLINEAR_SOLVER
19981 IF(
ASSOCIATED(nonlinear_solver))
THEN 19983 newton_solver=>nonlinear_solver%NEWTON_SOLVER
19984 IF(
ASSOCIATED(newton_solver))
THEN 19986 trustregion_solver=>newton_solver%TRUSTREGION_SOLVER
19987 IF(
ASSOCIATED(trustregion_solver))
THEN 19988 IF(trustregion_tolerance>zero_tolerance)
THEN 19989 trustregion_solver%TRUSTREGION_TOLERANCE=trustregion_tolerance
19991 local_error=
"The specified trust region tolerance of "// &
19992 & trim(numbertovstring(trustregion_tolerance,
"*",err,error))// &
19993 &
" is invalid. The trust region tolerance must be > 0." 19994 CALL flagerror(local_error,err,error,*999)
19997 CALL flagerror(
"The Newton solver trust region solver is not associated.",err,error,*999)
20000 CALL flagerror(
"The Newton solver is not a trust region solver.",err,error,*999)
20003 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
20006 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*999)
20009 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*999)
20012 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*999)
20016 CALL flagerror(
"Solver is not associated.",err,error,*999)
20019 exits(
"SOLVER_NEWTON_TRUSTREGION_TOLERANCE_SET")
20021 999 errorsexits(
"SOLVER_NEWTON_TRUSTREGION_TOLERANCE_SET",err,error)
20034 TYPE(solver_type),
POINTER :: SOLVER
20035 INTEGER(INTG),
INTENT(IN) :: NEWTON_SOLVE_TYPE
20036 INTEGER(INTG),
INTENT(OUT) :: ERR
20037 TYPE(varying_string),
INTENT(OUT) :: ERROR
20039 INTEGER(INTG) :: DUMMY_ERR
20040 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
20041 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
20042 TYPE(varying_string) :: DUMMY_ERROR,LOCAL_ERROR
20044 enters(
"SOLVER_NEWTON_TYPE_SET",err,error,*998)
20046 IF(
ASSOCIATED(solver))
THEN 20047 IF(solver%SOLVER_FINISHED)
THEN 20048 CALL flagerror(
"Solver has already been finished.",err,error,*998)
20051 nonlinear_solver=>solver%NONLINEAR_SOLVER
20052 IF(
ASSOCIATED(nonlinear_solver))
THEN 20054 newton_solver=>nonlinear_solver%NEWTON_SOLVER
20055 IF(
ASSOCIATED(newton_solver))
THEN 20056 IF(newton_solve_type/=newton_solver%NEWTON_SOLVE_TYPE)
THEN 20058 SELECT CASE(newton_solve_type)
20064 local_error=
"The Newton solver type of "//trim(numbertovstring(newton_solve_type,
"*",err,error))// &
20066 CALL flagerror(local_error,err,error,*999)
20069 SELECT CASE(newton_solver%NEWTON_SOLVE_TYPE)
20075 local_error=
"The Newton solver type of "// &
20076 & trim(numbertovstring(newton_solver%NEWTON_SOLVE_TYPE,
"*",err,error))//
" is invalid." 20077 CALL flagerror(local_error,err,error,*999)
20079 newton_solver%NEWTON_SOLVE_TYPE=newton_solve_type
20082 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*998)
20085 CALL flagerror(
"The nonlinear solver is not a Newton solver.",err,error,*998)
20088 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*998)
20091 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*998)
20095 CALL flagerror(
"Solver is not associated.",err,error,*998)
20098 exits(
"SOLVER_NEWTON_TYPE_SET")
20100 999
SELECT CASE(newton_solve_type)
20106 998 errorsexits(
"SOLVER_NEWTON_TYPE_SET",err,error)
20124 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
20125 INTEGER(INTG),
INTENT(OUT) :: ERR
20126 TYPE(varying_string),
INTENT(OUT) :: ERROR
20128 TYPE(varying_string) :: LOCAL_ERROR
20130 enters(
"SOLVER_NONLINEAR_CREATE_FINISH",err,error,*999)
20132 IF(
ASSOCIATED(nonlinear_solver))
THEN 20133 SELECT CASE(nonlinear_solver%NONLINEAR_SOLVE_TYPE)
20137 CALL flagerror(
"Not implemented.",err,error,*999)
20139 CALL flagerror(
"Not implemented.",err,error,*999)
20143 local_error=
"The nonlinear solver type of "// &
20144 & trim(numbertovstring(nonlinear_solver%NONLINEAR_SOLVE_TYPE,
"*",err,error))//
" is invalid." 20145 CALL flagerror(local_error,err,error,*999)
20148 CALL flagerror(
"Nonlinear solver is not associated.",err,error,*999)
20151 exits(
"SOLVER_NONLINEAR_CREATE_FINISH")
20153 999 errorsexits(
"SOLVER_NONLINEAR_CREATE_FINISH",err,error)
20164 TYPE(solver_type),
INTENT(IN) :: SOLVER
20165 INTEGER(INTG),
INTENT(OUT) :: ERR
20166 TYPE(varying_string),
INTENT(OUT) :: ERROR
20168 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
20169 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
20170 TYPE(newton_linesearch_solver_type),
POINTER :: NEWTON_LINESEARCH_SOLVER
20171 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
20172 TYPE(quasi_newton_linesearch_solver_type),
POINTER :: QUASI_NEWTON_LINESEARCH_SOLVER
20173 INTEGER(INTG) :: CONVERGED_REASON
20175 enters(
"SOLVER_NONLINEAR_DIVERGENCE_EXIT",err,error,*999)
20177 NULLIFY(nonlinear_solver,newton_solver,newton_linesearch_solver,quasi_newton_solver,quasi_newton_linesearch_solver)
20179 nonlinear_solver=>solver%NONLINEAR_SOLVER
20180 IF(
ASSOCIATED(nonlinear_solver))
THEN 20181 SELECT CASE(nonlinear_solver%NONLINEAR_SOLVE_TYPE)
20183 newton_solver=>nonlinear_solver%NEWTON_SOLVER
20184 IF(
ASSOCIATED(newton_solver))
THEN 20185 SELECT CASE (newton_solver%NEWTON_SOLVE_TYPE)
20187 newton_linesearch_solver=>newton_solver%LINESEARCH_SOLVER
20188 IF(
ASSOCIATED(newton_linesearch_solver))
THEN 20189 CALL petsc_snesgetconvergedreason(newton_linesearch_solver%snes,converged_reason,err,error,*999)
20190 SELECT CASE(converged_reason)
20191 CASE(petsc_snes_diverged_function_count)
20192 CALL flagerror(
"Nonlinear line search solver did not converge. Exit due to PETSc diverged function count.", &
20194 CASE(petsc_snes_diverged_linear_solve)
20195 CALL flagerror(
"Nonlinear line search solver did not converge. Exit due to PETSc diverged linear solve.", &
20197 CASE(petsc_snes_diverged_fnorm_nan)
20198 CALL flagerror(
"Nonlinear line search solver did not converge. Exit due to PETSc diverged F Norm NaN.", &
20200 CASE(petsc_snes_diverged_max_it)
20201 CALL flagerror(
"Nonlinear line search solver did not converge. Exit due to PETSc diverged maximum iterations.", &
20203 CASE(petsc_snes_diverged_line_search)
20204 CALL flagerror(
"Nonlinear line search solver did not converge. Exit due to PETSc diverged line search.", &
20206 CASE(petsc_snes_diverged_local_min)
20207 CALL flagerror(
"Nonlinear line search solver did not converge. Exit due to PETSc diverged local minimum.", &
20211 CALL flagerror(
"Linesearch solver is not associated.",err,error,*999)
20217 CALL flagerror(
"Newton solver is not associated.",err,error,*999)
20224 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
20225 IF(
ASSOCIATED(quasi_newton_solver))
THEN 20226 quasi_newton_linesearch_solver=>quasi_newton_solver%LINESEARCH_SOLVER
20227 IF(
ASSOCIATED(quasi_newton_linesearch_solver))
THEN 20228 CALL petsc_snesgetconvergedreason(quasi_newton_linesearch_solver%snes,converged_reason,err,error,*999)
20229 SELECT CASE(converged_reason)
20230 CASE(petsc_snes_diverged_function_count)
20231 CALL flagerror(
"Nonlinear line search solver did not converge. Exit due to PETSc diverged function count.", &
20233 CASE(petsc_snes_diverged_linear_solve)
20234 CALL flagerror(
"Nonlinear line search solver did not converge. Exit due to PETSc diverged linear solve.", &
20236 CASE(petsc_snes_diverged_fnorm_nan)
20237 CALL flagerror(
"Nonlinear line search solver did not converge. Exit due to PETSc diverged F Norm NaN.", &
20239 CASE(petsc_snes_diverged_max_it)
20240 CALL flagerror(
"Nonlinear line search solver did not converge. Exit due to PETSc diverged maximum iterations.", &
20242 CASE(petsc_snes_diverged_line_search)
20243 CALL flagerror(
"Nonlinear line search solver did not converge. Exit due to PETSc diverged line search.", &
20245 CASE(petsc_snes_diverged_local_min)
20246 CALL flagerror(
"Nonlinear line search solver did not converge. Exit due to PETSc diverged local minimum.", &
20250 CALL flagerror(
"Linesearch solver is not associated.",err,error,*999)
20253 CALL flagerror(
"Newton solver is not associated.",err,error,*999)
20257 CALL flagerror(
"Nonlinear solver is not associated.",err,error,*999)
20260 exits(
"SOLVER_NONLINEAR_DIVERGENCE_EXIT")
20262 999 errorsexits(
"SOLVER_NONLINEAR_DIVERGENCE_EXIT",err,error)
20274 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
20275 INTEGER(INTG),
INTENT(OUT) :: ERR
20276 TYPE(varying_string),
INTENT(OUT) :: ERROR
20278 TYPE(varying_string) :: LOCAL_ERROR
20280 enters(
"SOLVER_NONLINEAR_FINALISE",err,error,*999)
20282 IF(
ASSOCIATED(nonlinear_solver))
THEN 20283 SELECT CASE(nonlinear_solver%NONLINEAR_SOLVE_TYPE)
20287 CALL flagerror(
"Not implemented.",err,error,*999)
20289 CALL flagerror(
"Not implemented.",err,error,*999)
20293 local_error=
"The nonlinear solver type of "// &
20294 & trim(numbertovstring(nonlinear_solver%NONLINEAR_SOLVE_TYPE,
"*",err,error))//
" is invalid." 20295 CALL flagerror(local_error,err,error,*999)
20297 DEALLOCATE(nonlinear_solver)
20300 exits(
"SOLVER_NONLINEAR_FINALISE")
20302 999 errorsexits(
"SOLVER_NONLINEAR_FINALISE",err,error)
20315 TYPE(solver_type),
POINTER :: SOLVER
20316 INTEGER(INTG),
INTENT(OUT) :: ERR
20317 TYPE(varying_string),
INTENT(OUT) :: ERROR
20319 INTEGER(INTG) :: DUMMY_ERR
20320 TYPE(varying_string) :: DUMMY_ERROR
20322 enters(
"SOLVER_NONLINEAR_INITIALISE",err,error,*998)
20324 IF(
ASSOCIATED(solver))
THEN 20325 IF(
ASSOCIATED(solver%NONLINEAR_SOLVER))
THEN 20326 CALL flagerror(
"Nonlinear solver is already associated for this solver.",err,error,*998)
20329 ALLOCATE(solver%NONLINEAR_SOLVER,stat=err)
20330 IF(err/=0)
CALL flagerror(
"Could not allocate solver nonlinear solver.",err,error,*999)
20331 solver%NONLINEAR_SOLVER%SOLVER=>solver
20332 NULLIFY(solver%NONLINEAR_SOLVER%NEWTON_SOLVER)
20338 CALL flagerror(
"Solver is not associated.",err,error,*998)
20341 exits(
"SOLVER_NONLINEAR_INITIALISE")
20344 998 errorsexits(
"SOLVER_NONLINEAR_INITIALISE",err,error)
20357 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
20358 INTEGER(INTG),
INTENT(OUT) :: SOLVER_LIBRARY_TYPE
20359 INTEGER(INTG),
INTENT(OUT) :: ERR
20360 TYPE(varying_string),
INTENT(OUT) :: ERROR
20362 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
20363 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
20364 TYPE(varying_string) :: LOCAL_ERROR
20366 enters(
"SOLVER_NONLINEAR_LIBRARY_TYPE_GET",err,error,*999)
20368 IF(
ASSOCIATED(nonlinear_solver))
THEN 20369 SELECT CASE(nonlinear_solver%NONLINEAR_SOLVE_TYPE)
20371 newton_solver=>nonlinear_solver%NEWTON_SOLVER
20372 IF(
ASSOCIATED(newton_solver))
THEN 20375 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
20378 CALL flagerror(
"Not implemented.",err,error,*999)
20380 CALL flagerror(
"Not implemented.",err,error,*999)
20382 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
20383 IF(
ASSOCIATED(quasi_newton_solver))
THEN 20385 & solver_library_type,err,error,*999)
20387 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
20390 local_error=
"The nonlinear solver type of "// &
20391 & trim(numbertovstring(nonlinear_solver%NONLINEAR_SOLVE_TYPE,
"*",err,error))//
" is invalid." 20392 CALL flagerror(local_error,err,error,*999)
20395 CALL flagerror(
"Nonlinear solver is not associated.",err,error,*999)
20398 exits(
"SOLVER_NONLINEAR_LIBRARY_TYPE_GET")
20400 999 errorsexits(
"SOLVER_NONLINEAR_LIBRARY_TYPE_GET",err,error)
20413 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
20414 INTEGER(INTG),
INTENT(IN) :: SOLVER_LIBRARY_TYPE
20415 INTEGER(INTG),
INTENT(OUT) :: ERR
20416 TYPE(varying_string),
INTENT(OUT) :: ERROR
20418 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
20419 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
20420 TYPE(varying_string) :: LOCAL_ERROR
20422 enters(
"SOLVER_NONLINEAR_LIBRARY_TYPE_SET",err,error,*999)
20424 IF(
ASSOCIATED(nonlinear_solver))
THEN 20425 SELECT CASE(nonlinear_solver%NONLINEAR_SOLVE_TYPE)
20427 newton_solver=>nonlinear_solver%NEWTON_SOLVER
20428 IF(
ASSOCIATED(newton_solver))
THEN 20431 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
20434 CALL flagerror(
"Not implemented.",err,error,*999)
20436 CALL flagerror(
"Not implemented.",err,error,*999)
20438 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
20439 IF(
ASSOCIATED(quasi_newton_solver))
THEN 20441 & solver_library_type,err,error,*999)
20443 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
20446 local_error=
"The nonlinear solver type of "// &
20447 & trim(numbertovstring(nonlinear_solver%NONLINEAR_SOLVE_TYPE,
"*",err,error))//
" is invalid." 20448 CALL flagerror(local_error,err,error,*999)
20451 CALL flagerror(
"Nonlinear solver is not associated.",err,error,*999)
20454 exits(
"SOLVER_NONLINEAR_LIBRARY_TYPE_SET")
20456 999 errorsexits(
"SOLVER_NONLINEAR_LIBRARY_TYPE_SET",err,error)
20469 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
20470 INTEGER(INTG),
INTENT(OUT) :: MATRICES_LIBRARY_TYPE
20471 INTEGER(INTG),
INTENT(OUT) :: ERR
20472 TYPE(varying_string),
INTENT(OUT) :: ERROR
20474 TYPE(newton_solver_type),
POINTER :: NEWTON_SOLVER
20475 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
20476 TYPE(varying_string) :: LOCAL_ERROR
20478 enters(
"SOLVER_NONLINEAR_MATRICES_LIBRARY_TYPE_GET",err,error,*999)
20480 IF(
ASSOCIATED(nonlinear_solver))
THEN 20481 SELECT CASE(nonlinear_solver%NONLINEAR_SOLVE_TYPE)
20483 newton_solver=>nonlinear_solver%NEWTON_SOLVER
20484 IF(
ASSOCIATED(newton_solver))
THEN 20487 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
20490 CALL flagerror(
"Not implemented.",err,error,*999)
20492 CALL flagerror(
"Not implemented.",err,error,*999)
20494 quasi_newton_solver=>nonlinear_solver%QUASI_NEWTON_SOLVER
20495 IF(
ASSOCIATED(quasi_newton_solver))
THEN 20497 & matrices_library_type,err,error,*999)
20499 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
20502 local_error=
"The nonlinear solver type of "// &
20503 & trim(numbertovstring(nonlinear_solver%NONLINEAR_SOLVE_TYPE,
"*",err,error))//
" is invalid." 20504 CALL flagerror(local_error,err,error,*999)
20507 CALL flagerror(
"Nonlinear solver is not associated.",err,error,*999)
20510 exits(
"SOLVER_NONLINEAR_MATRICES_LIBRARY_TYPE_GET")
20512 999 errorsexits(
"SOLVER_NONLINEAR_MATRICES_LIBRARY_TYPE_GET",err,error)
20525 TYPE(nonlinear_solver_type),
POINTER :: nonlinearSolver
20526 INTEGER(INTG),
INTENT(IN) :: its
20527 REAL(DP),
INTENT(IN) :: norm
20528 INTEGER(INTG),
INTENT(OUT) :: err
20529 TYPE(varying_string),
INTENT(OUT) :: error
20534 TYPE(newton_linesearch_solver_type),
POINTER :: newtonLinesearchSolver
20535 TYPE(newton_solver_type),
POINTER :: newtonSolver
20536 TYPE(quasi_newton_linesearch_solver_type),
POINTER :: quasiNewtonlinesearchSolver
20537 TYPE(quasi_newton_solver_type),
POINTER :: QUASI_NEWTON_SOLVER
20538 TYPE(varying_string) :: localError
20540 enters(
"SOLVER_NONLINEAR_MONITOR",err,error,*999)
20542 IF(
ASSOCIATED(nonlinearsolver))
THEN 20544 CALL write_string(general_output_type,
"",err,error,*999)
20545 CALL write_string(general_output_type,
"Nonlinear solve monitor: ",err,error,*999)
20546 CALL write_string(general_output_type,
"",err,error,*999)
20547 CALL write_string_value(general_output_type,
" Iteration number = ",its,err,error,*999)
20548 SELECT CASE(nonlinearsolver%NONLINEAR_SOLVE_TYPE)
20550 newtonsolver=>nonlinearsolver%NEWTON_SOLVER
20551 IF(
ASSOCIATED(newtonsolver))
THEN 20552 SELECT CASE(newtonsolver%convergenceTestType)
20554 CALL write_string_value(general_output_type,
" Function Norm = ",norm,err,error,*999)
20556 SELECT CASE(newtonsolver%NEWTON_SOLVE_TYPE)
20558 newtonlinesearchsolver=>newtonsolver%LINESEARCH_SOLVER
20559 IF(
ASSOCIATED(newtonlinesearchsolver))
THEN 20560 CALL petsc_sneslinesearchgetnorms(newtonlinesearchsolver%sneslinesearch,xnorm,fnorm,ynorm,err,error,*999)
20561 CALL write_string_value(general_output_type,
" Solution Norm = ",xnorm,err,error,*999)
20562 CALL write_string_value(general_output_type,
" Solution Update Norm = ",ynorm,err,error,*999)
20563 CALL write_string_value(general_output_type,
" Function Norm = ",fnorm,err,error,*999)
20564 CALL write_string_value(general_output_type,
" Normalised Energy Norm = ", &
20565 & newtonsolver%convergenceTest%normalisedEnergy,err,error,*999)
20567 CALL flagerror(
"Newton solver linesearch solver is not associated.",err,error,*999)
20570 CALL flagerror(
"The Newton Trust region solver is not implemented.",err,error,*999)
20572 localerror=
"The Newton solve type of "// &
20573 & trim(numbertovstring(newtonsolver%NEWTON_SOLVE_TYPE,
"*",err,error))//
"is invalid." 20574 CALL flagerror(localerror,err,error,*999)
20577 CALL flagerror(
"The Sum of differentiated ratios of unconstrained to constrained residuals"// &
20578 &
"convergence test type is not implemented.",err,error,*999)
20580 CALL write_string(general_output_type,
" Newton solver information: ",err,error,*999)
20581 CALL write_string_value(general_output_type,
" Number of function evaluations = ",newtonsolver% &
20582 & total_number_of_function_evaluations,err,error,*999)
20583 CALL write_string_value(general_output_type,
" Number of Jacobian evaluations = ",newtonsolver% &
20584 & total_number_of_jacobian_evaluations,err,error,*999)
20586 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
20593 quasi_newton_solver=>nonlinearsolver%QUASI_NEWTON_SOLVER
20594 IF(
ASSOCIATED(quasi_newton_solver))
THEN 20595 SELECT CASE(quasi_newton_solver%convergenceTestType)
20597 CALL write_string_value(general_output_type,
" Function Norm = ",norm,err,error,*999)
20599 quasinewtonlinesearchsolver=>quasi_newton_solver%LINESEARCH_SOLVER
20600 IF(
ASSOCIATED(quasinewtonlinesearchsolver))
THEN 20601 CALL petsc_sneslinesearchgetnorms(quasinewtonlinesearchsolver%sneslinesearch, &
20602 & xnorm,fnorm,ynorm,err,error,*999)
20603 CALL write_string_value(general_output_type,
" Solution Norm = ",xnorm,err,error,*999)
20604 CALL write_string_value(general_output_type,
" Solution Update Norm = ",ynorm,err,error,*999)
20605 CALL write_string_value(general_output_type,
" Function Norm = ",fnorm,err,error,*999)
20606 CALL write_string_value(general_output_type,
" Normalised Energy Norm = ", &
20607 & quasi_newton_solver%convergenceTest%normalisedEnergy,err,error,*999)
20609 CALL flagerror(
"Quasi-Newton solver linesearch solver is not associated.",err,error,*999)
20612 CALL flagerror(
"The Sum of differentiated ratios of unconstrained to constrained residuals"// &
20613 &
"convergence test type is not implemented.",err,error,*999)
20615 CALL write_string(general_output_type,
" Quasi-Newton solver information: ",err,error,*999)
20616 CALL write_string_value(general_output_type,
" Number of function evaluations = ",quasi_newton_solver% &
20617 & total_number_of_function_evaluations,err,error,*999)
20618 CALL write_string_value(general_output_type,
" Number of Jacobian evaluations = ",quasi_newton_solver% &
20619 & total_number_of_jacobian_evaluations,err,error,*999)
20621 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*999)
20624 localerror=
"The nonlinear solver type of "// &
20625 & trim(numbertovstring(nonlinearsolver%NONLINEAR_SOLVE_TYPE,
"*",err,error))// &
20627 CALL flagerror(localerror,err,error,*999)
20630 CALL flagerror(
"Nonlinear solver is not associated.",err,error,*999)
20633 exits(
"SOLVER_NONLINEAR_MONITOR")
20635 999 errorsexits(
"SOLVER_NONLINEAR_MONITOR",err,error)
20647 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
20648 INTEGER(INTG),
INTENT(OUT) :: ERR
20649 TYPE(varying_string),
INTENT(OUT) :: ERROR
20651 INTEGER(INTG) :: solver_matrix_idx
20652 TYPE(solver_type),
POINTER :: SOLVER
20653 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
20654 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
20655 TYPE(varying_string) :: LOCAL_ERROR
20657 enters(
"SOLVER_NONLINEAR_SOLVE",err,error,*999)
20659 IF(
ASSOCIATED(nonlinear_solver))
THEN 20660 solver=>nonlinear_solver%SOLVER
20661 IF(
ASSOCIATED(solver))
THEN 20662 SELECT CASE(nonlinear_solver%NONLINEAR_SOLVE_TYPE)
20666 CALL flagerror(
"Not implemented.",err,error,*999)
20668 CALL flagerror(
"Not implemented.",err,error,*999)
20672 local_error=
"The nonlinear solver type of "// &
20673 & trim(numbertovstring(nonlinear_solver%NONLINEAR_SOLVE_TYPE,
"*",err,error))//
" is invalid." 20674 CALL flagerror(local_error,err,error,*999)
20680 CALL tau_static_phase_start(
"Solution Output Phase")
20683 solver_equations=>solver%SOLVER_EQUATIONS
20684 IF(
ASSOCIATED(solver_equations))
THEN 20685 solver_matrices=>solver_equations%SOLVER_MATRICES
20686 IF(
ASSOCIATED(solver_matrices))
THEN 20687 CALL write_string(general_output_type,
"",err,error,*999)
20688 CALL write_string(general_output_type,
"Solver solution vectors:",err,error,*999)
20689 CALL write_string_value(general_output_type,
"Number of solution vectors = ",solver_matrices%NUMBER_OF_MATRICES, &
20691 DO solver_matrix_idx=1,solver_matrices%NUMBER_OF_MATRICES
20692 CALL write_string_value(general_output_type,
"Solution vector for solver matrix : ",solver_matrix_idx, &
20694 CALL distributed_vector_output(general_output_type,solver_matrices%MATRICES(solver_matrix_idx)%PTR% &
20695 & solver_vector,err,error,*999)
20698 CALL flagerror(
"Solver equations solver matrices is not associated.",err,error,*999)
20701 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
20705 CALL tau_static_phase_stop(
"Solution Output Phase")
20709 CALL flagerror(
"Nonlinear solver solver is not associated.",err,error,*999)
20712 CALL flagerror(
"Nonlinear solver is not associated.",err,error,*999)
20715 exits(
"SOLVER_NONLINEAR_SOLVE")
20717 999 errorsexits(
"SOLVER_NONLINEAR_SOLVE",err,error)
20730 TYPE(solver_type),
POINTER :: SOLVER
20731 INTEGER(INTG),
INTENT(IN) :: NONLINEAR_SOLVE_TYPE
20732 INTEGER(INTG),
INTENT(OUT) :: ERR
20733 TYPE(varying_string),
INTENT(OUT) :: ERROR
20735 INTEGER(INTG) :: DUMMY_ERR
20736 TYPE(nonlinear_solver_type),
POINTER :: NONLINEAR_SOLVER
20737 TYPE(varying_string) :: DUMMY_ERROR,LOCAL_ERROR
20739 enters(
"SOLVER_NONLINEAR_TYPE_SET",err,error,*998)
20741 IF(
ASSOCIATED(solver))
THEN 20742 IF(solver%SOLVER_FINISHED)
THEN 20743 CALL flagerror(
"Solver has already been finished.",err,error,*998)
20747 nonlinear_solver=>solver%NONLINEAR_SOLVER
20748 IF(
ASSOCIATED(nonlinear_solver))
THEN 20749 IF(nonlinear_solve_type/=nonlinear_solver%NONLINEAR_SOLVE_TYPE)
THEN 20751 SELECT CASE(nonlinear_solver%NONLINEAR_SOLVE_TYPE)
20755 CALL flagerror(
"Not implemented.",err,error,*999)
20757 CALL flagerror(
"Not implemented.",err,error,*999)
20761 local_error=
"The nonlinear solver type of "// &
20762 & trim(numbertovstring(nonlinear_solver%NONLINEAR_SOLVE_TYPE,
"*",err,error))//
" is invalid." 20763 CALL flagerror(local_error,err,error,*999)
20765 nonlinear_solver%NONLINEAR_SOLVE_TYPE=nonlinear_solve_type
20767 SELECT CASE(nonlinear_solve_type)
20769 NULLIFY(nonlinear_solver%NEWTON_SOLVER)
20772 CALL flagerror(
"Not implemented.",err,error,*999)
20774 CALL flagerror(
"Not implemented.",err,error,*999)
20776 NULLIFY(nonlinear_solver%QUASI_NEWTON_SOLVER)
20779 local_error=
"The specified nonlinear solver type of "// &
20780 & trim(numbertovstring(nonlinear_solve_type,
"*",err,error))//
" is invalid." 20781 CALL flagerror(local_error,err,error,*999)
20785 CALL flagerror(
"The solver nonlinear solver is not associated.",err,error,*998)
20788 CALL flagerror(
"The solver is not a nonlinear solver.",err,error,*998)
20792 CALL flagerror(
"Solver is not associated.",err,error,*998)
20795 exits(
"SOLVER_NONLINEAR_TYPE_SET")
20797 999
SELECT CASE(nonlinear_solve_type)
20801 CALL flagerror(
"Not implemented.",err,error,*998)
20803 CALL flagerror(
"Not implemented.",err,error,*998)
20807 998 errorsexits(
"SOLVER_NONLINEAR_TYPE_SET",err,error)
20820 TYPE(optimiser_solver_type),
POINTER :: OPTIMISER_SOLVER
20821 INTEGER(INTG),
INTENT(OUT) :: ERR
20822 TYPE(varying_string),
INTENT(OUT) :: ERROR
20825 enters(
"SOLVER_OPTIMISER_CREATE_FINISH",err,error,*999)
20827 IF(
ASSOCIATED(optimiser_solver))
THEN 20828 CALL flagerror(
"Not implemented.",err,error,*999)
20830 CALL flagerror(
"Optimiser solver is not associated.",err,error,*999)
20833 exits(
"SOLVER_OPTIMISER_CREATE_FINISH")
20835 999 errorsexits(
"SOLVER_OPTIMISER_CREATE_FINISH",err,error)
20848 TYPE(optimiser_solver_type),
POINTER :: OPTIMISER_SOLVER
20849 INTEGER(INTG),
INTENT(OUT) :: ERR
20850 TYPE(varying_string),
INTENT(OUT) :: ERROR
20853 enters(
"SOLVER_OPTIMISER_FINALISE",err,error,*999)
20855 IF(
ASSOCIATED(optimiser_solver))
THEN 20856 DEALLOCATE(optimiser_solver)
20859 exits(
"SOLVER_OPTIMISER_FINALISE")
20861 999 errorsexits(
"SOLVER_OPTIMISER_FINALISE",err,error)
20874 TYPE(solver_type),
POINTER :: SOLVER
20875 INTEGER(INTG),
INTENT(OUT) :: ERR
20876 TYPE(varying_string),
INTENT(OUT) :: ERROR
20878 INTEGER(INTG) :: DUMMY_ERR
20879 TYPE(varying_string) :: DUMMY_ERROR
20881 enters(
"SOLVER_OPTIMISER_INITIALISE",err,error,*998)
20883 IF(
ASSOCIATED(solver))
THEN 20884 IF(
ASSOCIATED(solver%OPTIMISER_SOLVER))
THEN 20885 CALL flagerror(
"Optimiser solver is already associated for this solver.",err,error,*998)
20887 ALLOCATE(solver%OPTIMISER_SOLVER,stat=err)
20888 IF(err/=0)
CALL flagerror(
"Could not allocate solver optimiser solver.",err,error,*999)
20889 solver%OPTIMISER_SOLVER%SOLVER=>solver
20891 solver%OPTIMISER_SOLVER%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
20894 CALL flagerror(
"Solver is not associated.",err,error,*998)
20897 exits(
"SOLVER_OPTIMISER_INITIALISE")
20900 998 errorsexits(
"SOLVER_OPTIMISER_INITIALISE",err,error)
20913 TYPE(optimiser_solver_type),
POINTER :: OPTIMISER_SOLVER
20914 INTEGER(INTG),
INTENT(OUT) :: SOLVER_LIBRARY_TYPE
20915 INTEGER(INTG),
INTENT(OUT) :: ERR
20916 TYPE(varying_string),
INTENT(OUT) :: ERROR
20919 enters(
"SOLVER_OPTIMISER_LIBRARY_TYPE_GET",err,error,*999)
20921 IF(
ASSOCIATED(optimiser_solver))
THEN 20922 solver_library_type=optimiser_solver%SOLVER_LIBRARY
20924 CALL flagerror(
"Optimiser solver is not associated.",err,error,*999)
20927 exits(
"SOLVER_OPTIMISER_LIBRARY_TYPE_GET")
20929 999 errorsexits(
"SOLVER_OPTIMISER_LIBRARY_TYPE_GET",err,error)
20942 TYPE(optimiser_solver_type),
POINTER :: OPTIMISER_SOLVER
20943 INTEGER(INTG),
INTENT(IN) :: SOLVER_LIBRARY_TYPE
20944 INTEGER(INTG),
INTENT(OUT) :: ERR
20945 TYPE(varying_string),
INTENT(OUT) :: ERROR
20947 TYPE(varying_string) :: LOCAL_ERROR
20949 enters(
"SOLVER_OPTIMISER_LIBRARY_TYPE_SET",err,error,*999)
20951 IF(
ASSOCIATED(optimiser_solver))
THEN 20952 SELECT CASE(solver_library_type)
20954 CALL flagerror(
"Not implemented.",err,error,*999)
20957 optimiser_solver%SOLVER_MATRICES_LIBRARY=distributed_matrix_vector_petsc_type
20959 local_error=
"The specified solver library type of "//trim(numbertovstring(solver_library_type,
"*",err,error))// &
20960 &
" is invalid for an optimiser solver." 20961 CALL flagerror(local_error,err,error,*999)
20964 CALL flagerror(
"Optimiser solver is not associated.",err,error,*999)
20967 exits(
"SOLVER_OPTIMISER_LIBRARY_TYPE_SET")
20969 999 errorsexits(
"SOLVER_OPTIMISER_LIBRARY_TYPE_SET",err,error)
20982 TYPE(optimiser_solver_type),
POINTER :: OPTIMISER_SOLVER
20983 INTEGER(INTG),
INTENT(OUT) :: MATRICES_LIBRARY_TYPE
20984 INTEGER(INTG),
INTENT(OUT) :: ERR
20985 TYPE(varying_string),
INTENT(OUT) :: ERROR
20988 enters(
"SOLVER_OPTIMISER_MATRICES_LIBRARY_TYPE_GET",err,error,*999)
20990 IF(
ASSOCIATED(optimiser_solver))
THEN 20991 matrices_library_type=optimiser_solver%SOLVER_MATRICES_LIBRARY
20993 CALL flagerror(
"Optimiser solver is not associated.",err,error,*999)
20996 exits(
"SOLVER_OPTIMISER_MATRICES_LIBRARY_TYPE_GET")
20998 999 errorsexits(
"SOLVER_OPTIMISER_MATRICES_LIBRARY_TYPE_GET",err,error)
21011 TYPE(optimiser_solver_type),
POINTER :: OPTIMISER_SOLVER
21012 INTEGER(INTG),
INTENT(OUT) :: ERR
21013 TYPE(varying_string),
INTENT(OUT) :: ERROR
21016 enters(
"SOLVER_OPTIMISER_SOLVE",err,error,*999)
21018 IF(
ASSOCIATED(optimiser_solver))
THEN 21019 CALL flagerror(
"Not implemented.",err,error,*999)
21021 CALL flagerror(
"Optimiser solver is not associated.",err,error,*999)
21024 exits(
"SOLVER_OPTIMISER_SOLVE")
21026 999 errorsexits(
"SOLVER_OPTIMISER_SOLVE",err,error)
21039 TYPE(solver_type),
POINTER :: SOLVER
21040 INTEGER(INTG),
INTENT(IN) :: OUTPUT_TYPE
21041 INTEGER(INTG),
INTENT(OUT) :: ERR
21042 TYPE(varying_string),
INTENT(OUT) :: ERROR
21044 TYPE(varying_string) :: LOCAL_ERROR
21046 enters(
"SOLVER_OUTPUT_TYPE_SET",err,error,*999)
21048 IF(
ASSOCIATED(solver))
THEN 21049 IF(solver%SOLVER_FINISHED)
THEN 21050 CALL flagerror(
"Solver has already been finished.",err,error,*999)
21052 SELECT CASE(output_type)
21064 local_error=
"The specified solver output type of "// &
21065 & trim(numbertovstring(output_type,
"*",err,error))//
" is invalid." 21066 CALL flagerror(local_error,err,error,*999)
21070 CALL flagerror(
"Solver is not associated.",err,error,*999)
21073 exits(
"SOLVER_OUTPUT_TYPE_SET")
21075 999 errorsexits(
"SOLVER_OUTPUT_TYPE_SET",err,error)
21088 TYPE(solver_type),
POINTER :: SOLVER
21089 INTEGER(INTG),
INTENT(OUT) :: ERR
21090 TYPE(varying_string),
INTENT(OUT) :: ERROR
21092 INTEGER(INTG) :: column_number,equations_set_idx,local_number,solver_matrix_idx,variable_dof_idx,variable_idx,variable_type, &
21093 & interface_condition_idx
21094 REAL(DP) :: additive_constant,
VALUE,coupling_coefficient
21095 REAL(DP),
POINTER :: VARIABLE_DATA(:)
21096 TYPE(distributed_vector_type),
POINTER :: SOLVER_VECTOR
21097 TYPE(domain_mapping_type),
POINTER :: DOMAIN_MAPPING
21098 TYPE(field_type),
POINTER :: DEPENDENT_FIELD,LAGRANGE_FIELD
21099 TYPE(field_variable_type),
POINTER :: DEPENDENT_VARIABLE,LAGRANGE_VARIABLE
21100 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
21101 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
21102 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
21103 TYPE(solver_matrix_type),
POINTER :: SOLVER_MATRIX
21105 NULLIFY(variable_data)
21107 enters(
"SOLVER_SOLUTION_UPDATE",err,error,*999)
21109 IF(
ASSOCIATED(solver))
THEN 21110 IF(solver%SOLVER_FINISHED)
THEN 21111 solver_equations=>solver%SOLVER_EQUATIONS
21112 IF(
ASSOCIATED(solver_equations))
THEN 21113 solver_matrices=>solver_equations%SOLVER_MATRICES
21114 IF(
ASSOCIATED(solver_matrices))
THEN 21115 solver_mapping=>solver_matrices%SOLVER_MAPPING
21116 IF(
ASSOCIATED(solver_mapping))
THEN 21117 DO solver_matrix_idx=1,solver_matrices%NUMBER_OF_MATRICES
21118 solver_matrix=>solver_matrices%MATRICES(solver_matrix_idx)%PTR
21119 IF(
ASSOCIATED(solver_matrix))
THEN 21120 solver_vector=>solver_matrix%SOLVER_VECTOR
21121 IF(
ASSOCIATED(solver_vector))
THEN 21122 domain_mapping=>solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)%COLUMN_DOFS_MAPPING
21123 IF(
ASSOCIATED(domain_mapping))
THEN 21124 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
21125 DO variable_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
21126 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%NUMBER_OF_VARIABLES
21127 dependent_variable=>solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
21128 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%VARIABLES(variable_idx)%PTR
21129 IF(
ASSOCIATED(dependent_variable))
THEN 21130 variable_type=dependent_variable%VARIABLE_TYPE
21131 dependent_field=>dependent_variable%FIELD
21132 NULLIFY(variable_data)
21133 CALL field_parameter_set_data_get(dependent_field,variable_type,field_values_set_type,variable_data, &
21135 DO variable_dof_idx=1,dependent_variable%NUMBER_OF_DOFS
21136 column_number=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
21137 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%VARIABLE_TO_SOLVER_COL_MAPS(variable_idx)% &
21138 & column_numbers(variable_dof_idx)
21139 IF(column_number/=0)
THEN 21140 coupling_coefficient=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
21141 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%VARIABLE_TO_SOLVER_COL_MAPS( &
21142 & variable_idx)%COUPLING_COEFFICIENTS(variable_dof_idx)
21143 additive_constant=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
21144 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%VARIABLE_TO_SOLVER_COL_MAPS( &
21145 & variable_idx)%ADDITIVE_CONSTANTS(variable_dof_idx)
21146 VALUE=variable_data(variable_dof_idx)*coupling_coefficient+additive_constant
21147 local_number=domain_mapping%GLOBAL_TO_LOCAL_MAP(column_number)%LOCAL_NUMBER(1)
21148 CALL distributed_vector_values_set(solver_vector,local_number,
VALUE,err,error,*999)
21151 CALL field_parameter_set_data_restore(dependent_field,variable_type,field_values_set_type, &
21152 & variable_data,err,error,*999)
21154 CALL flagerror(
"Variable is not associated.",err,error,*999)
21158 DO interface_condition_idx=1,solver_mapping%NUMBER_OF_INTERFACE_CONDITIONS
21159 lagrange_variable=>solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
21160 & interface_to_solver_matrix_maps_sm(solver_matrix_idx)%LAGRANGE_VARIABLE
21161 IF(
ASSOCIATED(dependent_variable))
THEN 21162 variable_type=lagrange_variable%VARIABLE_TYPE
21163 lagrange_field=>lagrange_variable%FIELD
21164 NULLIFY(variable_data)
21165 CALL field_parameter_set_data_get(lagrange_field,variable_type,field_values_set_type,variable_data, &
21167 DO variable_dof_idx=1,lagrange_variable%NUMBER_OF_DOFS
21168 column_number=solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
21169 & interface_to_solver_matrix_maps_sm(solver_matrix_idx)%LAGRANGE_VARIABLE_TO_SOLVER_COL_MAP% &
21170 & column_numbers(variable_dof_idx)
21171 IF(column_number/=0)
THEN 21172 coupling_coefficient=solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
21173 & interface_to_solver_matrix_maps_sm(solver_matrix_idx)%LAGRANGE_VARIABLE_TO_SOLVER_COL_MAP% &
21174 & coupling_coefficients(variable_dof_idx)
21175 additive_constant=solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
21176 & interface_to_solver_matrix_maps_sm(solver_matrix_idx)%LAGRANGE_VARIABLE_TO_SOLVER_COL_MAP% &
21177 & additive_constants(variable_dof_idx)
21178 VALUE=variable_data(variable_dof_idx)*coupling_coefficient+additive_constant
21179 local_number=domain_mapping%GLOBAL_TO_LOCAL_MAP(column_number)%LOCAL_NUMBER(1)
21180 CALL distributed_vector_values_set(solver_vector,local_number,
VALUE,err,error,*999)
21183 CALL field_parameter_set_data_restore(dependent_field,variable_type,field_values_set_type, &
21184 & variable_data,err,error,*999)
21186 CALL flagerror(
"Variable is not associated.",err,error,*999)
21190 CALL flagerror(
"Domain mapping is not associated.",err,error,*999)
21192 CALL distributed_vector_update_start(solver_vector,err,error,*999)
21193 CALL distributed_vector_update_finish(solver_vector,err,error,*999)
21195 CALL flagerror(
"Solver vector is not associated.",err,error,*999)
21198 CALL flagerror(
"Solver matrix is not associated.",err,error,*999)
21202 CALL flagerror(
"Solver matrices solution mapping is not associated.",err,error,*999)
21205 CALL flagerror(
"Solver equations solver matrices are not associated.",err,error,*999)
21208 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
21211 CALL flagerror(
"Solver has not been finished.",err,error,*999)
21214 CALL flagerror(
"Solver is not associated.",err,error,*999)
21217 exits(
"SOLVER_SOLUTION_UPDATE")
21219 999 errorsexits(
"SOLVER_SOLUTION_UPDATE",err,error)
21232 TYPE(solver_type),
POINTER :: SOLVER
21233 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
21234 INTEGER(INTG),
INTENT(OUT) :: ERR
21235 TYPE(varying_string),
INTENT(OUT) :: ERROR
21238 enters(
"SOLVER_SOLVER_EQUATIONS_GET",err,error,*998)
21240 IF(
ASSOCIATED(solver))
THEN 21241 IF(solver%SOLVER_FINISHED)
THEN 21242 IF(
ASSOCIATED(solver_equations))
THEN 21243 CALL flagerror(
"Solver equations is already associated.",err,error,*998)
21245 solver_equations=>solver%SOLVER_EQUATIONS
21246 IF(.NOT.
ASSOCIATED(solver_equations))
CALL flagerror(
"Solver equations is not associated.",err,error,*999)
21249 CALL flagerror(
"Solver has not been finished.",err,error,*998)
21252 CALL flagerror(
"Solver is not associated.",err,error,*998)
21255 exits(
"SOLVER_SOLVER_EQUATIONS_GET")
21257 999
NULLIFY(solver_equations)
21258 998 errorsexits(
"SOLVER_SOLVER_EQUATIONS_GET",err,error)
21271 TYPE(solver_type),
POINTER :: SOLVER
21272 INTEGER(INTG),
INTENT(OUT) :: ERR
21273 TYPE(varying_string),
INTENT(OUT) :: ERROR
21275 REAL(SP) :: SYSTEM_ELAPSED,SYSTEM_TIME1(1),SYSTEM_TIME2(1),USER_ELAPSED,USER_TIME1(1),USER_TIME2(1)
21276 TYPE(varying_string) :: LOCAL_ERROR
21278 enters(
"SOLVER_SOLVE",err,error,*999)
21280 IF(
ASSOCIATED(solver))
THEN 21281 IF(solver%SOLVER_FINISHED)
THEN 21283 CALL cpu_timer(user_cpu,user_time1,err,error,*999)
21284 CALL cpu_timer(system_cpu,system_time1,err,error,*999)
21287 SELECT CASE(solver%SOLVE_TYPE)
21310 local_error=
"The solver type of "//trim(numbertovstring(solver%SOLVE_TYPE,
"*",err,error))//
" is invalid." 21311 CALL flagerror(local_error,err,error,*999)
21315 CALL cpu_timer(user_cpu,user_time2,err,error,*999)
21316 CALL cpu_timer(system_cpu,system_time2,err,error,*999)
21317 user_elapsed=user_time2(1)-user_time1(1)
21318 system_elapsed=system_time2(1)-system_time1(1)
21319 CALL write_string(general_output_type,
"",err,error,*999)
21320 CALL write_string_value(general_output_type,
"Total user time for solve = ",user_elapsed, &
21322 CALL write_string_value(general_output_type,
"Total System time for solve = ",system_elapsed, &
21326 CALL flagerror(
"Solver has not been finished.",err,error,*999)
21329 CALL flagerror(
"Solver is not associated.",err,error,*999)
21332 exits(
"SOLVER_SOLVE")
21334 999 errorsexits(
"SOLVER_SOLVE",err,error)
21347 TYPE(solver_type),
POINTER :: SOLVER
21348 INTEGER(INTG),
INTENT(IN) :: SOLVE_TYPE
21349 INTEGER(INTG),
INTENT(OUT) :: ERR
21350 TYPE(varying_string),
INTENT(OUT) :: ERROR
21352 INTEGER(INTG) :: DUMMY_ERR
21353 TYPE(varying_string) :: DUMMY_ERROR,LOCAL_ERROR
21355 enters(
"SOLVER_TYPE_SET",err,error,*998)
21357 IF(
ASSOCIATED(solver))
THEN 21358 IF(solver%SOLVER_FINISHED)
THEN 21359 CALL flagerror(
"Solver has already been finished.",err,error,*998)
21361 IF(
ASSOCIATED(solver%LINKING_SOLVER))
THEN 21362 CALL flagerror(
"Can not changed the solver type for a solve that has been linked.",err,error,*998)
21364 IF(solve_type/=solver%SOLVE_TYPE)
THEN 21366 SELECT CASE(solve_type)
21384 local_error=
"The specified solve type of "//trim(numbertovstring(solve_type,
"*",err,error))//
" is invalid." 21385 CALL flagerror(local_error,err,error,*999)
21388 SELECT CASE(solver%SOLVE_TYPE)
21406 local_error=
"The solver solve type of "//trim(numbertovstring(solver%SOLVE_TYPE,
"*",err,error))//
" is invalid." 21407 CALL flagerror(local_error,err,error,*999)
21410 solver%SOLVE_TYPE=solve_type
21415 CALL flagerror(
"Solver is not associated.",err,error,*998)
21418 exits(
"SOLVER_TYPE_SET")
21420 999
SELECT CASE(solve_type)
21436 998 errorsexits(
"SOLVER_TYPE_SET",err,error)
21449 TYPE(solver_type),
POINTER :: SOLVER
21450 INTEGER(INTG),
INTENT(OUT) :: ERR
21451 TYPE(varying_string),
INTENT(OUT) :: ERROR
21453 INTEGER(INTG) :: DUMMY_ERR,DYNAMIC_VARIABLE_TYPE,equations_idx,equations_set_idx,solver_dof_idx,solver_matrix_idx,variable_dof
21454 REAL(DP) :: ACCELERATION_VALUE,additive_constant,DELTA_T,DISPLACEMENT_VALUE,PREDICTED_DISPLACEMENT,PREVIOUS_ACCELERATION, &
21455 & PREVIOUS_DISPLACEMENT,PREVIOUS_VELOCITY,SOLVER_VALUE,variable_coefficient,VELOCITY_VALUE
21456 REAL(DP),
POINTER :: SOLVER_DATA(:)
21457 TYPE(distributed_vector_type),
POINTER :: SOLVER_VECTOR
21458 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
21459 TYPE(equations_type),
POINTER :: EQUATIONS
21460 TYPE(equations_mapping_type),
POINTER :: EQUATIONS_MAPPING
21461 TYPE(equations_mapping_dynamic_type),
POINTER :: DYNAMIC_MAPPING
21462 TYPE(equations_mapping_nonlinear_type),
POINTER :: NONLINEAR_MAPPING
21463 TYPE(equations_set_type),
POINTER :: EQUATIONS_SET
21464 TYPE(field_type),
POINTER :: DEPENDENT_FIELD
21465 TYPE(field_variable_type),
POINTER :: DEPENDENT_VARIABLE
21466 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
21467 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
21468 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
21469 TYPE(solver_matrix_type),
POINTER :: SOLVER_MATRIX
21470 TYPE(varying_string) :: DUMMY_ERROR,LOCAL_ERROR
21472 NULLIFY(solver_data)
21474 enters(
"SOLVER_VARIABLES_DYNAMIC_FIELD_UPDATE",err,error,*998)
21476 IF(
ASSOCIATED(solver))
THEN 21477 IF(solver%SOLVER_FINISHED)
THEN 21478 dynamic_solver=>solver%DYNAMIC_SOLVER
21479 IF(
ASSOCIATED(dynamic_solver))
THEN 21480 delta_t=dynamic_solver%TIME_INCREMENT
21481 solver_equations=>solver%SOLVER_EQUATIONS
21482 IF(
ASSOCIATED(solver_equations))
THEN 21483 solver_matrices=>solver_equations%SOLVER_MATRICES
21484 IF(
ASSOCIATED(solver_matrices))
THEN 21485 solver_mapping=>solver_matrices%SOLVER_MAPPING
21486 IF(
ASSOCIATED(solver_mapping))
THEN 21487 DO solver_matrix_idx=1,solver_matrices%NUMBER_OF_MATRICES
21488 solver_matrix=>solver_matrices%MATRICES(solver_matrix_idx)%PTR
21489 IF(
ASSOCIATED(solver_matrix))
THEN 21490 solver_vector=>solver_matrix%SOLVER_VECTOR
21491 IF(
ASSOCIATED(solver_vector))
THEN 21493 CALL distributed_vector_data_get(solver_vector,solver_data,err,error,*999)
21495 DO solver_dof_idx=1,solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)%NUMBER_OF_DOFS
21497 DO equations_idx=1,solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
21498 & solver_dof_to_variable_maps(solver_dof_idx)%NUMBER_OF_EQUATION_DOFS
21499 SELECT CASE(solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
21500 & solver_dof_to_variable_maps(solver_dof_idx)%EQUATIONS_TYPES(equations_idx))
21501 CASE(solver_mapping_equations_equations_set)
21502 dependent_variable=>solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
21503 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE(equations_idx)%PTR
21504 IF(
ASSOCIATED(dependent_variable))
THEN 21505 dynamic_variable_type=dependent_variable%VARIABLE_TYPE
21506 NULLIFY(dependent_field)
21507 dependent_field=>dependent_variable%FIELD
21508 IF(
ASSOCIATED(dependent_field))
THEN 21510 variable_dof=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
21511 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE_DOF(equations_idx)
21512 variable_coefficient=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
21513 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE_COEFFICIENT(equations_idx)
21514 additive_constant=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
21515 & solver_dof_to_variable_maps(solver_dof_idx)%ADDITIVE_CONSTANT(equations_idx)
21516 solver_value=solver_data(solver_dof_idx)*variable_coefficient+additive_constant
21518 IF(dynamic_solver%SOLVER_INITIALISED)
THEN 21519 SELECT CASE(dynamic_solver%DEGREE)
21523 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21524 & field_predicted_displacement_set_type,variable_dof,predicted_displacement, &
21526 displacement_value=predicted_displacement+delta_t*solver_value
21528 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21529 & field_values_set_type,variable_dof,previous_displacement, &
21531 displacement_value=previous_displacement+delta_t*solver_value
21533 CALL field_parameter_set_update_local_dof(dependent_field,dynamic_variable_type, &
21534 & field_values_set_type,variable_dof,displacement_value,err,error,*999)
21538 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21539 & field_predicted_displacement_set_type,variable_dof,predicted_displacement, &
21541 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21542 & field_previous_velocity_set_type,variable_dof,previous_velocity, &
21544 displacement_value=predicted_displacement+delta_t*previous_velocity+ &
21545 & (delta_t*delta_t/2.0_dp)*solver_value
21547 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21548 & field_values_set_type,variable_dof,previous_displacement, &
21550 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21551 & field_previous_velocity_set_type,variable_dof,previous_velocity, &
21553 displacement_value=previous_displacement+delta_t*previous_velocity+ &
21554 & (delta_t*delta_t/2.0_dp)*solver_value
21556 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21557 & field_previous_velocity_set_type,variable_dof,previous_velocity, &
21559 velocity_value=previous_velocity+delta_t*solver_value
21560 CALL field_parameter_set_update_local_dof(dependent_field,dynamic_variable_type, &
21561 & field_values_set_type,variable_dof,displacement_value,err,error,*999)
21562 CALL field_parameter_set_update_local_dof(dependent_field,dynamic_variable_type, &
21563 & field_velocity_values_set_type,variable_dof,velocity_value,err,error,*999)
21567 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21568 & field_predicted_displacement_set_type,variable_dof,predicted_displacement, &
21570 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21571 & field_previous_velocity_set_type,variable_dof,previous_velocity, &
21573 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21574 & field_previous_acceleration_set_type,variable_dof,previous_acceleration, &
21576 displacement_value=predicted_displacement+delta_t*previous_velocity+ &
21577 & (delta_t*delta_t/2.0_dp)*previous_acceleration+ &
21578 & (delta_t*delta_t*delta_t/6.0_dp)*solver_value
21580 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21581 & field_values_set_type,variable_dof,previous_displacement, &
21583 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21584 & field_previous_velocity_set_type,variable_dof,previous_velocity, &
21586 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21587 & field_previous_acceleration_set_type,variable_dof,previous_acceleration, &
21589 displacement_value=previous_displacement+delta_t*previous_velocity+ &
21590 & (delta_t*delta_t/2.0_dp)*previous_acceleration+ &
21591 & (delta_t*delta_t*delta_t/6.0_dp)*solver_value
21593 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21594 & field_previous_velocity_set_type,variable_dof,previous_velocity, &
21596 velocity_value=previous_velocity+delta_t*previous_acceleration+ &
21597 & (delta_t*delta_t/2.0_dp)*solver_value
21598 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
21599 & field_previous_acceleration_set_type,variable_dof,previous_acceleration, &
21601 acceleration_value=previous_acceleration+delta_t*solver_value
21602 CALL field_parameter_set_update_local_dof(dependent_field,dynamic_variable_type, &
21603 & field_values_set_type,variable_dof,displacement_value,err,error,*999)
21604 CALL field_parameter_set_update_local_dof(dependent_field,dynamic_variable_type, &
21605 & field_velocity_values_set_type,variable_dof,velocity_value,err,error,*999)
21606 CALL field_parameter_set_update_local_dof(dependent_field,dynamic_variable_type, &
21607 & field_acceleration_values_set_type,variable_dof,acceleration_value,err,error,*999)
21609 local_error=
"The dynamic solver degree of "// &
21610 & trim(numbertovstring(dynamic_solver%DEGREE,
"*",err,error))// &
21612 CALL flagerror(local_error,err,error,*999)
21615 SELECT CASE(dynamic_solver%ORDER)
21617 SELECT CASE(dynamic_solver%DEGREE)
21621 CALL field_parameter_set_update_local_dof(dependent_field,dynamic_variable_type, &
21622 & field_initial_velocity_set_type,variable_dof,solver_value,err,error,*999)
21624 CALL field_parameter_set_update_local_dof(dependent_field,dynamic_variable_type, &
21625 & field_initial_velocity_set_type,variable_dof,solver_value,err,error,*999)
21626 CALL field_parameter_set_update_local_dof(dependent_field,dynamic_variable_type, &
21627 & field_initial_acceleration_set_type,variable_dof,0.0_dp,err,error,*999)
21629 local_error=
"The dynamic solver degree of "// &
21630 & trim(numbertovstring(dynamic_solver%DEGREE,
"*",err,error))//
" is invalid." 21631 CALL flagerror(local_error,err,error,*999)
21635 CALL field_parameter_set_update_local_dof(dependent_field,dynamic_variable_type, &
21636 & field_initial_acceleration_set_type,variable_dof,solver_value,err,error,*999)
21639 local_error=
"The dynamic solver order of "// &
21640 & trim(numbertovstring(dynamic_solver%ORDER,
"*",err,error))//
" is invalid." 21641 CALL flagerror(local_error,err,error,*999)
21645 CALL flagerror(
"Dependent field is not associated.",err,error,*999)
21648 CALL flagerror(
"Dependent variable is not associated.",err,error,*999)
21650 CASE(solver_mapping_equations_interface_condition)
21653 local_error=
"The equations type of "//trim(numbertovstring(solver_mapping% &
21654 & solver_col_to_equations_cols_map(solver_matrix_idx)%SOLVER_DOF_TO_VARIABLE_MAPS(solver_dof_idx)% &
21655 & equations_types(equations_idx),
"*",err,error))//
" of equations index "// &
21656 & trim(numbertovstring(equations_idx,
"*",err,error))//
" for solver degree-of-freedom "// &
21657 & trim(numbertovstring(solver_dof_idx,
"*",err,error))//
" is invalid." 21658 CALL flagerror(local_error,err,error,*999)
21663 CALL distributed_vector_data_restore(solver_vector,solver_data,err,error,*999)
21665 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
21666 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
21667 IF(
ASSOCIATED(equations_set))
THEN 21668 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
21669 IF(
ASSOCIATED(dependent_field))
THEN 21670 equations=>equations_set%EQUATIONS
21671 IF(
ASSOCIATED(equations))
THEN 21672 equations_mapping=>equations%EQUATIONS_MAPPING
21673 IF(
ASSOCIATED(equations_mapping))
THEN 21674 dynamic_mapping=>equations_mapping%DYNAMIC_MAPPING
21675 IF(
ASSOCIATED(dynamic_mapping))
THEN 21676 dynamic_variable_type=dynamic_mapping%DYNAMIC_VARIABLE_TYPE
21677 IF(dynamic_solver%SOLVER_INITIALISED)
THEN 21678 CALL field_parameter_set_update_start(dependent_field,dynamic_variable_type, &
21679 & field_values_set_type,err,error,*999)
21681 CALL field_parameter_set_update_start(dependent_field,dynamic_variable_type, &
21682 & field_velocity_values_set_type,err,error,*999)
21684 CALL field_parameter_set_update_start(dependent_field,dynamic_variable_type, &
21685 & field_acceleration_values_set_type,err,error,*999)
21689 SELECT CASE(dynamic_solver%ORDER)
21691 SELECT CASE(dynamic_solver%DEGREE)
21695 CALL field_parameter_set_update_start(dependent_field,dynamic_variable_type, &
21696 & field_initial_velocity_set_type,err,error,*999)
21698 CALL field_parameter_set_update_start(dependent_field,dynamic_variable_type, &
21699 & field_initial_velocity_set_type,err,error,*999)
21700 CALL field_parameter_set_update_start(dependent_field,dynamic_variable_type, &
21701 & field_initial_acceleration_set_type,err,error,*999)
21703 local_error=
"The dynamic solver degree of "// &
21704 & trim(numbertovstring(dynamic_solver%DEGREE,
"*",err,error))//
" is invalid." 21705 CALL flagerror(local_error,err,error,*999)
21709 CALL field_parameter_set_update_start(dependent_field,dynamic_variable_type, &
21710 & field_initial_acceleration_set_type,err,error,*999)
21713 local_error=
"The dynamic solver order of "// &
21714 & trim(numbertovstring(dynamic_solver%ORDER,
"*",err,error))//
" is invalid." 21715 CALL flagerror(local_error,err,error,*999)
21720 nonlinear_mapping=>equations_mapping%NONLINEAR_MAPPING
21721 IF(
ASSOCIATED(nonlinear_mapping))
THEN 21722 dynamic_variable_type=field_u_variable_type
21723 IF(dynamic_solver%SOLVER_INITIALISED)
THEN 21724 CALL field_parameter_set_update_start(dependent_field,dynamic_variable_type, &
21725 & field_values_set_type,err,error,*999)
21727 CALL field_parameter_set_update_start(dependent_field,dynamic_variable_type, &
21728 & field_velocity_values_set_type,err,error,*999)
21730 CALL field_parameter_set_update_start(dependent_field,dynamic_variable_type, &
21731 & field_acceleration_values_set_type,err,error,*999)
21735 SELECT CASE(dynamic_solver%ORDER)
21737 SELECT CASE(dynamic_solver%DEGREE)
21741 CALL field_parameter_set_update_start(dependent_field,dynamic_variable_type, &
21742 & field_initial_velocity_set_type,err,error,*999)
21744 CALL field_parameter_set_update_start(dependent_field,dynamic_variable_type, &
21745 & field_initial_velocity_set_type,err,error,*999)
21746 CALL field_parameter_set_update_start(dependent_field,dynamic_variable_type, &
21747 & field_initial_acceleration_set_type,err,error,*999)
21749 local_error=
"The dynamic solver degree of "// &
21750 & trim(numbertovstring(dynamic_solver%DEGREE,
"*",err,error))//
" is invalid." 21751 CALL flagerror(local_error,err,error,*999)
21755 CALL field_parameter_set_update_start(dependent_field,dynamic_variable_type, &
21756 & field_initial_acceleration_set_type,err,error,*999)
21759 local_error=
"The dynamic solver order of "// &
21760 & trim(numbertovstring(dynamic_solver%ORDER,
"*",err,error))//
" is invalid." 21761 CALL flagerror(local_error,err,error,*999)
21765 local_error=
"Neither equations mapping dynamic mapping nor equations mapping nonlinear "// &
21766 &
"mapping is associated for equations set index number "// &
21767 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 21768 CALL flagerror(local_error,err,error,*999)
21772 local_error=
"Equations equations mapping is not associated for equations set index number "// &
21773 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 21774 CALL flagerror(local_error,err,error,*999)
21777 local_error=
"Equations set equations is not associated for equations set index number "// &
21778 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 21779 CALL flagerror(local_error,err,error,*999)
21782 local_error=
"Equations set dependent field is not associated for equations set index number "// &
21783 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 21784 CALL flagerror(local_error,err,error,*999)
21787 local_error=
"Equations set is not associated for equations set index number "// &
21788 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 21789 CALL flagerror(local_error,err,error,*999)
21793 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
21794 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
21795 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
21796 equations=>equations_set%EQUATIONS
21797 equations_mapping=>equations%EQUATIONS_MAPPING
21798 dynamic_mapping=>equations_mapping%DYNAMIC_MAPPING
21800 IF(
ASSOCIATED(dynamic_mapping))
THEN 21802 dynamic_variable_type=dynamic_mapping%DYNAMIC_VARIABLE_TYPE
21803 IF(dynamic_solver%SOLVER_INITIALISED)
THEN 21804 CALL field_parameter_set_update_finish(dependent_field,dynamic_variable_type,field_values_set_type, &
21807 CALL field_parameter_set_update_finish(dependent_field,dynamic_variable_type, &
21808 & field_velocity_values_set_type,err,error,*999)
21810 CALL field_parameter_set_update_finish(dependent_field,dynamic_variable_type, &
21811 & field_acceleration_values_set_type,err,error,*999)
21815 SELECT CASE(dynamic_solver%ORDER)
21817 SELECT CASE(dynamic_solver%DEGREE)
21821 CALL field_parameter_set_update_finish(dependent_field,dynamic_variable_type, &
21822 & field_initial_velocity_set_type,err,error,*999)
21824 CALL field_parameter_set_update_finish(dependent_field,dynamic_variable_type, &
21825 & field_initial_velocity_set_type,err,error,*999)
21826 CALL field_parameter_set_update_finish(dependent_field,dynamic_variable_type, &
21827 & field_initial_acceleration_set_type,err,error,*999)
21829 local_error=
"The dynamic solver degree of "// &
21830 & trim(numbertovstring(dynamic_solver%DEGREE,
"*",err,error))//
" is invalid." 21831 CALL flagerror(local_error,err,error,*999)
21835 CALL field_parameter_set_update_finish(dependent_field,dynamic_variable_type, &
21836 & field_initial_acceleration_set_type,err,error,*999)
21839 local_error=
"The dynamic solver order of "// &
21840 & trim(numbertovstring(dynamic_solver%ORDER,
"*",err,error))//
" is invalid." 21841 CALL flagerror(local_error,err,error,*999)
21846 nonlinear_mapping=>equations_mapping%NONLINEAR_MAPPING
21847 IF(
ASSOCIATED(nonlinear_mapping))
THEN 21848 dynamic_variable_type=field_u_variable_type
21849 IF(dynamic_solver%SOLVER_INITIALISED)
THEN 21850 CALL field_parameter_set_update_finish(dependent_field,dynamic_variable_type,field_values_set_type, &
21853 CALL field_parameter_set_update_finish(dependent_field,dynamic_variable_type, &
21854 & field_velocity_values_set_type,err,error,*999)
21856 CALL field_parameter_set_update_finish(dependent_field,dynamic_variable_type, &
21857 & field_acceleration_values_set_type,err,error,*999)
21861 SELECT CASE(dynamic_solver%ORDER)
21863 SELECT CASE(dynamic_solver%DEGREE)
21867 CALL field_parameter_set_update_finish(dependent_field,dynamic_variable_type, &
21868 & field_initial_velocity_set_type,err,error,*999)
21870 CALL field_parameter_set_update_finish(dependent_field,dynamic_variable_type, &
21871 & field_initial_velocity_set_type,err,error,*999)
21872 CALL field_parameter_set_update_finish(dependent_field,dynamic_variable_type, &
21873 & field_initial_acceleration_set_type,err,error,*999)
21875 local_error=
"The dynamic solver degree of "// &
21876 & trim(numbertovstring(dynamic_solver%DEGREE,
"*",err,error))//
" is invalid." 21877 CALL flagerror(local_error,err,error,*999)
21881 CALL field_parameter_set_update_finish(dependent_field,dynamic_variable_type, &
21882 & field_initial_acceleration_set_type,err,error,*999)
21885 local_error=
"The dynamic solver order of "// &
21886 & trim(numbertovstring(dynamic_solver%ORDER,
"*",err,error))//
" is invalid." 21887 CALL flagerror(local_error,err,error,*999)
21891 CALL flagerror(
"Neither dynamic nor nonlinear mapping is associated",err,error,*999)
21897 CALL flagerror(
"Solver vector is not associated.",err,error,*998)
21900 CALL flagerror(
"Solver matrix is not associated.",err,error,*998)
21904 CALL flagerror(
"Solver matrices solution mapping is not associated.",err,error,*998)
21907 CALL flagerror(
"Solver equations solver matrices are not associated.",err,error,*998)
21910 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
21913 CALL flagerror(
"Solver dynamic solver is not associated.",err,error,*999)
21916 CALL flagerror(
"Solver has not been finished.",err,error,*998)
21919 CALL flagerror(
"Solver is not associated.",err,error,*998)
21922 exits(
"SOLVER_VARIABLES_DYNAMIC_FIELD_UPDATE")
21924 999
IF(
ASSOCIATED(solver_data))
CALL distributed_vector_data_restore(solver_vector,solver_data,dummy_err,dummy_error,*998)
21925 998 errorsexits(
"SOLVER_VARIABLES_DYNAMIC_FIELD_UPDATE",err,error)
21938 TYPE(solver_type),
POINTER :: SOLVER
21939 INTEGER(INTG),
INTENT(OUT) :: ERR
21940 TYPE(varying_string),
INTENT(OUT) :: ERROR
21942 INTEGER(INTG) :: VARIABLE_TYPE,equations_set_idx,solver_matrix_idx, &
21943 & residual_variable_idx,variable_idx
21944 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
21945 TYPE(equations_type),
POINTER :: EQUATIONS
21946 TYPE(equations_mapping_type),
POINTER :: EQUATIONS_MAPPING
21947 TYPE(equations_mapping_nonlinear_type),
POINTER :: NONLINEAR_MAPPING
21948 TYPE(equations_set_type),
POINTER :: EQUATIONS_SET
21949 TYPE(field_type),
POINTER :: FIELD
21950 TYPE(field_variable_type),
POINTER :: FIELD_VARIABLE,RESIDUAL_VARIABLE
21951 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
21952 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
21953 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
21954 TYPE(varying_string) :: LOCAL_ERROR
21956 enters(
"Solver_VariablesDynamicFieldPreviousValuesUpdate",err,error,*999)
21958 IF(
ASSOCIATED(solver))
THEN 21959 IF(solver%SOLVER_FINISHED)
THEN 21960 dynamic_solver=>solver%DYNAMIC_SOLVER
21961 IF(
ASSOCIATED(dynamic_solver))
THEN 21962 solver_equations=>solver%SOLVER_EQUATIONS
21963 IF(
ASSOCIATED(solver_equations))
THEN 21964 solver_matrices=>solver_equations%SOLVER_MATRICES
21965 IF(
ASSOCIATED(solver_matrices))
THEN 21966 solver_mapping=>solver_matrices%SOLVER_MAPPING
21967 IF(
ASSOCIATED(solver_mapping))
THEN 21968 DO solver_matrix_idx=1,solver_matrices%NUMBER_OF_MATRICES
21970 DO variable_idx=1,solver_mapping%VARIABLES_LIST(solver_matrix_idx)%NUMBER_OF_VARIABLES
21971 field_variable=>solver_mapping%VARIABLES_LIST(solver_matrix_idx)%VARIABLES(variable_idx)%VARIABLE
21972 IF(
ASSOCIATED(field_variable))
THEN 21973 variable_type=field_variable%VARIABLE_TYPE
21974 field=>field_variable%FIELD
21976 CALL field_parameter_sets_copy(field,variable_type,field_values_set_type, &
21977 & field_previous_values_set_type,1.0_dp,err,error,*999)
21980 CALL field_parameter_sets_copy(field,variable_type,field_velocity_values_set_type, &
21981 & field_previous_velocity_set_type,1.0_dp,err,error,*999)
21984 CALL field_parameter_sets_copy(field,variable_type,field_acceleration_values_set_type, &
21985 & field_previous_acceleration_set_type,1.0_dp,err,error,*999)
21989 local_error=
"The solver mapping variables list variable is not associated for variable index "// &
21990 & trim(numbertovstring(variable_idx,
"*",err,error))//
"." 21991 CALL flagerror(local_error,err,error,*999)
21996 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
21997 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
21998 IF(
ASSOCIATED(equations_set))
THEN 21999 equations=>equations_set%EQUATIONS
22000 IF(
ASSOCIATED(equations))
THEN 22001 IF(equations%LINEARITY==equations_nonlinear)
THEN 22002 equations_mapping=>equations%EQUATIONS_MAPPING
22003 IF(
ASSOCIATED(equations_mapping))
THEN 22004 nonlinear_mapping=>equations_mapping%NONLINEAR_MAPPING
22005 IF(
ASSOCIATED(nonlinear_mapping))
THEN 22006 DO residual_variable_idx=1,nonlinear_mapping%NUMBER_OF_RESIDUAL_VARIABLES
22007 residual_variable=>nonlinear_mapping%RESIDUAL_VARIABLES(residual_variable_idx)%PTR
22008 IF(
ASSOCIATED(residual_variable))
THEN 22009 CALL field_parameter_sets_copy(residual_variable%FIELD,residual_variable%VARIABLE_TYPE, &
22010 & field_residual_set_type,field_previous_residual_set_type,1.0_dp,err,error,*999)
22012 local_error=
"Nonlinear mapping residual variable is not associated for "// &
22013 "residual variable index "//trim(numbertovstring(residual_variable_idx,
"*",err,error))// &
22015 CALL flagerror(local_error,err,error,*999)
22019 CALL flagerror(
"Equations mapping nonlinear mapping is not associated.",err,error,*999)
22022 CALL flagerror(
"Equations equations mapping is not associated.",err,error,*999)
22026 CALL flagerror(
"Equations set equations is not associated.",err,error,*999)
22029 local_error=
"The solver mapping equations set is not associated for equations set index "// &
22030 & trim(numbertovstring(equations_set_idx,
"*",err,error))//
"." 22031 CALL flagerror(local_error,err,error,*999)
22037 CALL flagerror(
"Solver matrices solution mapping is not associated.",err,error,*999)
22040 CALL flagerror(
"Solver equations solver matrices are not associated.",err,error,*999)
22043 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
22046 CALL flagerror(
"Solver dynamic solver is not associated.",err,error,*999)
22049 CALL flagerror(
"Solver has not been finished.",err,error,*999)
22052 CALL flagerror(
"Solver is not associated.",err,error,*999)
22055 exits(
"Solver_VariablesDynamicFieldPreviousValuesUpdate")
22057 999 errors(
"Solver_VariablesDynamicFieldPreviousValuesUpdate",err,error)
22058 exits(
"Solver_VariablesDynamicFieldPreviousValuesUpdate")
22071 TYPE(solver_type),
POINTER :: SOLVER
22072 INTEGER(INTG),
INTENT(OUT) :: ERR
22073 TYPE(varying_string),
INTENT(OUT) :: ERROR
22076 INTEGER(INTG) :: DUMMY_ERR,DYNAMIC_VARIABLE_TYPE,equations_idx,equations_set_idx,solver_dof_idx,solver_matrix_idx,variable_dof
22077 REAL(DP) :: additive_constant,DELTA_T,
VALUE,variable_coefficient
22078 REAL(DP) :: ALPHA_VALUE,DYNAMIC_ALPHA_FACTOR, DYNAMIC_U_FACTOR,PREDICTED_DISPLACEMENT
22079 INTEGER(INTG) :: variable_idx,VARIABLE_TYPE,interface_condition_idx
22080 REAL(DP),
POINTER :: SOLVER_DATA(:)
22081 TYPE(distributed_vector_type),
POINTER :: SOLVER_VECTOR
22082 TYPE(equations_set_type),
POINTER :: EQUATIONS_SET
22083 TYPE(interface_equations_type),
POINTER :: INTERFACE_EQUATIONS
22084 TYPE(interface_condition_type),
POINTER :: INTERFACE_CONDITION
22085 TYPE(field_type),
POINTER :: DEPENDENT_FIELD
22086 TYPE(field_variable_type),
POINTER :: DEPENDENT_VARIABLE
22087 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
22088 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
22089 TYPE(equations_mapping_dynamic_type),
POINTER :: DYNAMIC_MAPPING
22090 TYPE(equations_mapping_nonlinear_type),
POINTER :: NONLINEAR_MAPPING
22091 TYPE(equations_mapping_type),
POINTER :: EQUATIONS_MAPPING
22092 TYPE(interface_mapping_type),
POINTER :: INTERFACE_MAPPING
22093 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
22094 TYPE(solver_matrix_type),
POINTER :: SOLVER_MATRIX
22095 TYPE(varying_string) :: DUMMY_ERROR,LOCAL_ERROR
22098 TYPE(dynamic_solver_type),
POINTER :: DYNAMIC_SOLVER
22099 TYPE(equations_type),
POINTER :: EQUATIONS
22102 LOGICAL :: STABILITY_TEST
22106 stability_test=.false.
22108 NULLIFY(solver_data)
22110 enters(
"SOLVER_VARIABLES_DYNAMIC_NONLINEAR_UPDATE",err,error,*998)
22112 IF(
ASSOCIATED(solver))
THEN 22113 IF(solver%SOLVER_FINISHED)
THEN 22114 solver_equations=>solver%SOLVER_EQUATIONS
22115 IF(
ASSOCIATED(solver%LINKING_SOLVER))
THEN 22116 dynamic_solver=>solver%LINKING_SOLVER%DYNAMIC_SOLVER
22118 IF(
ASSOCIATED(dynamic_solver))
THEN 22119 IF(dynamic_solver%SOLVER_INITIALISED)
THEN 22120 delta_t=dynamic_solver%TIME_INCREMENT
22121 SELECT CASE(dynamic_solver%DEGREE)
22123 dynamic_alpha_factor=delta_t
22124 dynamic_u_factor=1.0_dp
22126 dynamic_alpha_factor=delta_t*delta_t/2.0_dp
22127 dynamic_u_factor=1.0_dp
22129 dynamic_alpha_factor=delta_t*delta_t*delta_t/6.0_dp
22130 dynamic_u_factor=1.0_dp
22132 local_error=
"The dynamic solver degree of "//trim(numbertovstring(dynamic_solver%DEGREE,
"*",err,error))// &
22134 CALL flagerror(local_error,err,error,*999)
22139 CALL flagerror(
"Dynamic solver linking solver is not associated.",err,error,*999)
22142 IF(
ASSOCIATED(solver_equations))
THEN 22143 solver_matrices=>solver_equations%SOLVER_MATRICES
22144 IF(
ASSOCIATED(solver_matrices))
THEN 22145 solver_mapping=>solver_matrices%SOLVER_MAPPING
22146 IF(
ASSOCIATED(solver_mapping))
THEN 22147 DO solver_matrix_idx=1,solver_matrices%NUMBER_OF_MATRICES
22148 solver_matrix=>solver_matrices%MATRICES(solver_matrix_idx)%PTR
22149 IF(
ASSOCIATED(solver_matrix))
THEN 22150 solver_vector=>solver_matrix%SOLVER_VECTOR
22151 IF(
ASSOCIATED(solver_vector))
THEN 22153 CALL distributed_vector_data_get(solver_vector,solver_data,err,error,*999)
22155 DO solver_dof_idx=1,solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)%NUMBER_OF_DOFS
22157 DO equations_idx=1,solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22158 & solver_dof_to_variable_maps(solver_dof_idx)%NUMBER_OF_EQUATION_DOFS
22159 SELECT CASE(solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22160 & solver_dof_to_variable_maps(solver_dof_idx)%EQUATIONS_TYPES(equations_idx))
22161 CASE(solver_mapping_equations_equations_set)
22163 dependent_variable=>solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22164 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE(equations_idx)%PTR
22168 equations_set=>solver_mapping%EQUATIONS_SETS(solver_mapping% &
22169 & solver_col_to_equations_cols_map(solver_matrix_idx)% &
22170 & solver_dof_to_variable_maps(solver_dof_idx)%EQUATIONS_INDICES(equations_idx))%PTR
22173 IF(
ASSOCIATED(equations_set))
THEN 22174 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
22175 equations=>equations_set%EQUATIONS
22176 IF(
ASSOCIATED(dependent_variable))
THEN 22177 variable_type=dependent_variable%VARIABLE_TYPE
22178 IF(
ASSOCIATED(dependent_field))
THEN 22179 IF(
ASSOCIATED(equations))
THEN 22180 equations_mapping=>equations%EQUATIONS_MAPPING
22181 IF(
ASSOCIATED(equations_mapping))
THEN 22182 dynamic_mapping=>equations_mapping%DYNAMIC_MAPPING
22183 IF(
ASSOCIATED(dynamic_mapping))
THEN 22184 dynamic_variable_type=dynamic_mapping%DYNAMIC_VARIABLE_TYPE
22186 variable_dof=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22187 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE_DOF(equations_idx)
22188 variable_coefficient=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22189 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE_COEFFICIENT(equations_idx)
22190 additive_constant=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22191 & solver_dof_to_variable_maps(solver_dof_idx)%ADDITIVE_CONSTANT(equations_idx)
22193 alpha_value=solver_data(solver_dof_idx)
22194 CALL field_parameter_set_update_local_dof(dependent_field,variable_type, &
22195 & field_incremental_values_set_type,variable_dof,alpha_value,err,error,*999)
22197 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
22198 & field_predicted_displacement_set_type,variable_dof,predicted_displacement, &
22201 VALUE=alpha_value*variable_coefficient+additive_constant
22203 IF(stability_test)
THEN 22204 VALUE=
VALUE*dynamic_solver%THETA(1)
22206 VALUE=
VALUE*dynamic_alpha_factor+predicted_displacement
22207 CALL field_parameter_set_update_local_dof(dependent_field,variable_type, &
22208 & field_values_set_type,variable_dof,
VALUE,err,error,*999)
22211 nonlinear_mapping=>equations_mapping%NONLINEAR_MAPPING
22212 IF(
ASSOCIATED(nonlinear_mapping))
THEN 22214 dynamic_variable_type=field_u_variable_type
22216 variable_dof=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22217 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE_DOF(equations_idx)
22218 variable_coefficient=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22219 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE_COEFFICIENT(equations_idx)
22220 additive_constant=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22221 & solver_dof_to_variable_maps(solver_dof_idx)%ADDITIVE_CONSTANT(equations_idx)
22223 alpha_value=solver_data(solver_dof_idx)
22224 CALL field_parameter_set_update_local_dof(dependent_field,variable_type, &
22225 & field_incremental_values_set_type,variable_dof,alpha_value,err,error,*999)
22227 CALL field_parameter_set_get_local_dof(dependent_field,dynamic_variable_type, &
22228 & field_predicted_displacement_set_type,variable_dof,predicted_displacement, &
22231 VALUE=alpha_value*variable_coefficient+additive_constant
22233 IF(stability_test)
THEN 22234 VALUE=
VALUE*dynamic_solver%THETA(1)
22236 VALUE=
VALUE*dynamic_alpha_factor+predicted_displacement
22237 CALL field_parameter_set_update_local_dof(dependent_field,variable_type, &
22238 & field_values_set_type,variable_dof,
VALUE,err,error,*999)
22240 CALL flagerror(
"Neither dynamic nor nonlinear mapping is associated",err,error,*999)
22246 CALL flagerror(
"Equations mapping is not associated.",err,error,*999)
22249 CALL flagerror(
"Equations are not associated.",err,error,*999)
22252 CALL flagerror(
"Dependent field is not associated.",err,error,*999)
22255 CALL flagerror(
"Dependent variable is not associated.",err,error,*999)
22258 CALL flagerror(
"Equations set is not associated.",err,error,*999)
22260 CASE(solver_mapping_equations_interface_condition)
22263 dependent_variable=>solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22264 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE(equations_idx)%PTR
22266 interface_condition=>solver_mapping%INTERFACE_CONDITIONS(solver_mapping% &
22267 & solver_col_to_equations_cols_map(solver_matrix_idx)% &
22268 & solver_dof_to_variable_maps(solver_dof_idx)%EQUATIONS_INDICES(equations_idx))%PTR
22269 IF(
ASSOCIATED(interface_condition))
THEN 22271 dependent_field=>interface_condition%LAGRANGE%LAGRANGE_FIELD
22272 interface_equations=>interface_condition%INTERFACE_EQUATIONS
22273 IF(
ASSOCIATED(dependent_variable))
THEN 22274 variable_type=dependent_variable%VARIABLE_TYPE
22275 IF(
ASSOCIATED(dependent_field))
THEN 22276 IF(
ASSOCIATED(interface_equations))
THEN 22277 interface_mapping=>interface_equations%INTERFACE_MAPPING
22278 IF(
ASSOCIATED(interface_mapping))
THEN 22279 dynamic_variable_type=interface_mapping%LAGRANGE_VARIABLE_TYPE
22281 variable_dof=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22282 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE_DOF(equations_idx)
22283 variable_coefficient=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22284 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE_COEFFICIENT(equations_idx)
22285 additive_constant=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22286 & solver_dof_to_variable_maps(solver_dof_idx)%ADDITIVE_CONSTANT(equations_idx)
22287 predicted_displacement=0.0_dp
22289 alpha_value=solver_data(solver_dof_idx)
22291 VALUE=alpha_value*variable_coefficient+additive_constant
22293 IF(stability_test)
THEN 22294 VALUE=
VALUE*dynamic_solver%THETA(1)
22296 VALUE=
VALUE*dynamic_alpha_factor+predicted_displacement
22297 CALL field_parameter_set_update_local_dof(dependent_field,variable_type, &
22298 & field_values_set_type,variable_dof,
VALUE,err,error,*999)
22300 CALL flagerror(
"Interface mapping is not associated.",err,error,*999)
22303 CALL flagerror(
"Interface equations are not associated.",err,error,*999)
22306 CALL flagerror(
"Dependent field is not associated.",err,error,*999)
22309 CALL flagerror(
"Dependent variable is not associated.",err,error,*999)
22312 CALL flagerror(
"Interface condition is not associated.",err,error,*999)
22315 local_error=
"The equations type of "//trim(numbertovstring(solver_mapping% &
22316 & solver_col_to_equations_cols_map(solver_matrix_idx)%SOLVER_DOF_TO_VARIABLE_MAPS(solver_dof_idx)% &
22317 & equations_types(equations_idx),
"*",err,error))//
" of equations index "// &
22318 & trim(numbertovstring(equations_idx,
"*",err,error))//
" for solver degree-of-freedom "// &
22319 & trim(numbertovstring(solver_dof_idx,
"*",err,error))//
" is invalid." 22320 CALL flagerror(local_error,err,error,*999)
22325 CALL distributed_vector_data_restore(solver_vector,solver_data,err,error,*999)
22327 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
22328 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
22329 IF(
ASSOCIATED(equations_set))
THEN 22330 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
22331 DO variable_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
22332 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%NUMBER_OF_VARIABLES
22333 variable_type=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
22334 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%VARIABLE_TYPES(variable_idx)
22335 CALL field_parameter_set_update_start(dependent_field,variable_type,field_values_set_type,err,error,*999)
22336 CALL field_parameter_set_update_start(dependent_field,variable_type,field_incremental_values_set_type, &
22340 CALL flagerror(
"Equations set is not associated.",err,error,*999)
22344 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
22345 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
22346 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
22347 DO variable_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
22348 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%NUMBER_OF_VARIABLES
22349 variable_type=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
22350 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%VARIABLE_TYPES(variable_idx)
22351 CALL field_parameter_set_update_finish(dependent_field,variable_type,field_values_set_type,err,error,*999)
22352 CALL field_parameter_set_update_finish(dependent_field,variable_type,field_incremental_values_set_type, &
22359 DO interface_condition_idx=1,solver_mapping%NUMBER_OF_INTERFACE_CONDITIONS
22360 interface_condition=>solver_mapping%INTERFACE_CONDITIONS(interface_condition_idx)%PTR
22361 dependent_field=>interface_condition%LAGRANGE%LAGRANGE_FIELD
22362 variable_type=solver_mapping%INTERFACE_CONDITION_TO_SOLVER_MAP(interface_condition_idx)% &
22363 & interface_to_solver_matrix_maps_sm(solver_matrix_idx)%LAGRANGE_VARIABLE_TYPE
22364 CALL field_parameter_set_update_start(dependent_field,variable_type,field_values_set_type,err,error,*999)
22365 CALL field_parameter_set_update_finish(dependent_field,variable_type,field_values_set_type,err,error,*999)
22368 CALL flagerror(
"Solver vector is not associated.",err,error,*998)
22371 CALL flagerror(
"Solver matrix is not associated.",err,error,*998)
22375 CALL flagerror(
"Solver matrices solution mapping is not associated.",err,error,*998)
22378 CALL flagerror(
"Solver equations solver matrices are not associated.",err,error,*998)
22381 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
22384 CALL flagerror(
"Solver has not been finished.",err,error,*998)
22387 CALL flagerror(
"Solver is not associated.",err,error,*998)
22390 exits(
"SOLVER_VARIABLES_DYNAMIC_NONLINEAR_UPDATE")
22392 999
IF(
ASSOCIATED(solver_data))
CALL distributed_vector_data_restore(solver_vector,solver_data,dummy_err,dummy_error,*998)
22393 998 errorsexits(
"SOLVER_VARIABLES_DYNAMIC_NONLINEAR_UPDATE",err,error)
22406 TYPE(solver_type),
POINTER :: SOLVER
22407 INTEGER(INTG),
INTENT(OUT) :: ERR
22408 TYPE(varying_string),
INTENT(OUT) :: ERROR
22410 INTEGER(INTG) :: DUMMY_ERR,equations_idx,equations_set_idx,solver_dof_idx,solver_matrix_idx,variable_dof,variable_idx, &
22412 REAL(DP) :: additive_constant,
VALUE,variable_coefficient
22413 REAL(DP),
POINTER :: SOLVER_DATA(:)
22414 TYPE(distributed_vector_type),
POINTER :: SOLVER_VECTOR
22415 TYPE(equations_set_type),
POINTER :: EQUATIONS_SET
22416 TYPE(field_type),
POINTER :: DEPENDENT_FIELD,LAGRANGE_FIELD
22417 TYPE(field_variable_type),
POINTER :: DEPENDENT_VARIABLE,LAGRANGE_VARIABLE
22418 TYPE(solver_equations_type),
POINTER :: SOLVER_EQUATIONS
22419 TYPE(solver_mapping_type),
POINTER :: SOLVER_MAPPING
22420 TYPE(solver_matrices_type),
POINTER :: SOLVER_MATRICES
22421 TYPE(solver_matrix_type),
POINTER :: SOLVER_MATRIX
22422 TYPE(varying_string) :: DUMMY_ERROR,LOCAL_ERROR
22424 NULLIFY(solver_data)
22426 enters(
"SOLVER_VARIABLES_FIELD_UPDATE",err,error,*998)
22428 IF(
ASSOCIATED(solver))
THEN 22429 IF(solver%SOLVER_FINISHED)
THEN 22430 solver_equations=>solver%SOLVER_EQUATIONS
22431 IF(
ASSOCIATED(solver_equations))
THEN 22432 solver_matrices=>solver_equations%SOLVER_MATRICES
22433 IF(
ASSOCIATED(solver_matrices))
THEN 22434 solver_mapping=>solver_matrices%SOLVER_MAPPING
22435 IF(
ASSOCIATED(solver_mapping))
THEN 22436 DO solver_matrix_idx=1,solver_matrices%NUMBER_OF_MATRICES
22437 solver_matrix=>solver_matrices%MATRICES(solver_matrix_idx)%PTR
22438 IF(
ASSOCIATED(solver_matrix))
THEN 22439 solver_vector=>solver_matrix%SOLVER_VECTOR
22440 IF(
ASSOCIATED(solver_vector))
THEN 22442 CALL distributed_vector_data_get(solver_vector,solver_data,err,error,*999)
22444 DO solver_dof_idx=1,solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)%NUMBER_OF_DOFS
22446 DO equations_idx=1,solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22447 & solver_dof_to_variable_maps(solver_dof_idx)%NUMBER_OF_EQUATION_DOFS
22448 SELECT CASE(solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22449 & solver_dof_to_variable_maps(solver_dof_idx)%EQUATIONS_TYPES(equations_idx))
22450 CASE(solver_mapping_equations_equations_set)
22452 dependent_variable=>solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22453 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE(equations_idx)%PTR
22454 IF(
ASSOCIATED(dependent_variable))
THEN 22455 variable_type=dependent_variable%VARIABLE_TYPE
22456 dependent_field=>dependent_variable%FIELD
22457 IF(
ASSOCIATED(dependent_field))
THEN 22459 variable_dof=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22460 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE_DOF(equations_idx)
22461 variable_coefficient=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22462 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE_COEFFICIENT(equations_idx)
22463 additive_constant=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22464 & solver_dof_to_variable_maps(solver_dof_idx)%ADDITIVE_CONSTANT(equations_idx)
22466 VALUE=solver_data(solver_dof_idx)*variable_coefficient+additive_constant
22467 CALL field_parameter_set_update_local_dof(dependent_field,variable_type,field_values_set_type, &
22468 & variable_dof,
VALUE,err,error,*999)
22470 CALL flagerror(
"Dependent field is not associated.",err,error,*999)
22473 CALL flagerror(
"Dependent variable is not associated.",err,error,*999)
22475 CASE(solver_mapping_equations_interface_condition)
22477 lagrange_variable=>solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22478 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE(equations_idx)%PTR
22479 IF(
ASSOCIATED(lagrange_variable))
THEN 22480 variable_type=lagrange_variable%VARIABLE_TYPE
22481 lagrange_field=>lagrange_variable%FIELD
22482 IF(
ASSOCIATED(lagrange_field))
THEN 22484 variable_dof=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22485 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE_DOF(equations_idx)
22486 variable_coefficient=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22487 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE_COEFFICIENT(equations_idx)
22488 additive_constant=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22489 & solver_dof_to_variable_maps(solver_dof_idx)%ADDITIVE_CONSTANT(equations_idx)
22491 VALUE=solver_data(solver_dof_idx)*variable_coefficient+additive_constant
22492 CALL field_parameter_set_update_local_dof(lagrange_field,variable_type,field_values_set_type, &
22493 & variable_dof,
VALUE,err,error,*999)
22495 CALL flagerror(
"Lagrange field is not associated.",err,error,*999)
22498 CALL flagerror(
"Lagrange variable is not associated.",err,error,*999)
22501 local_error=
"The equations type of "//trim(numbertovstring(solver_mapping% &
22502 & solver_col_to_equations_cols_map(solver_matrix_idx)%SOLVER_DOF_TO_VARIABLE_MAPS(solver_dof_idx)% &
22503 & equations_types(equations_idx),
"*",err,error))//
" of equations index "// &
22504 & trim(numbertovstring(equations_idx,
"*",err,error))//
" for solver degree-of-freedom "// &
22505 & trim(numbertovstring(solver_dof_idx,
"*",err,error))//
" is invalid." 22506 CALL flagerror(local_error,err,error,*999)
22510 IF(diagnostics2)
THEN 22511 CALL write_string_value(diagnostic_output_type,
" Solver matrix index = ",solver_matrix_idx,err,error,*999)
22512 DO solver_dof_idx=1,solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)%NUMBER_OF_DOFS
22513 CALL write_string_value(diagnostic_output_type,
" Solver dof index = ",solver_dof_idx,err,error,*999)
22514 DO equations_idx=1,solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22515 & solver_dof_to_variable_maps(solver_dof_idx)%NUMBER_OF_EQUATION_DOFS
22516 CALL write_string_value(diagnostic_output_type,
" Equations index = ",equations_idx,err,error,*999)
22517 variable_dof=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22518 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE_DOF(equations_idx)
22519 variable_coefficient=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22520 & solver_dof_to_variable_maps(solver_dof_idx)%VARIABLE_COEFFICIENT(equations_idx)
22521 additive_constant=solver_mapping%SOLVER_COL_TO_EQUATIONS_COLS_MAP(solver_matrix_idx)% &
22522 & solver_dof_to_variable_maps(solver_dof_idx)%ADDITIVE_CONSTANT(equations_idx)
22523 VALUE=solver_data(solver_dof_idx)*variable_coefficient+additive_constant
22524 CALL write_string_value(diagnostic_output_type,
" Variable dof = ",variable_dof,err,error,*999)
22525 CALL write_string_value(diagnostic_output_type,
" Variable coefficient = ",variable_coefficient, &
22527 CALL write_string_value(diagnostic_output_type,
" Additive constant = ",additive_constant, &
22529 CALL write_string_value(diagnostic_output_type,
" Value = ",
VALUE,err,error,*999)
22534 CALL distributed_vector_data_restore(solver_vector,solver_data,err,error,*999)
22536 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
22537 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
22538 IF(
ASSOCIATED(equations_set))
THEN 22539 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
22540 DO variable_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
22541 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%NUMBER_OF_VARIABLES
22542 variable_type=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
22543 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%VARIABLE_TYPES(variable_idx)
22544 CALL field_parameter_set_update_start(dependent_field,variable_type,field_values_set_type,err,error,*999)
22547 CALL flagerror(
"Equations set is not associated.",err,error,*999)
22551 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
22552 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
22553 dependent_field=>equations_set%DEPENDENT%DEPENDENT_FIELD
22554 DO variable_idx=1,solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
22555 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%NUMBER_OF_VARIABLES
22556 variable_type=solver_mapping%EQUATIONS_SET_TO_SOLVER_MAP(equations_set_idx)% &
22557 & equations_to_solver_matrix_maps_sm(solver_matrix_idx)%VARIABLE_TYPES(variable_idx)
22558 CALL field_parameter_set_update_finish(dependent_field,variable_type,field_values_set_type,err,error,*999)
22562 CALL flagerror(
"Solver vector is not associated.",err,error,*998)
22565 CALL flagerror(
"Solver matrix is not associated.",err,error,*998)
22569 CALL flagerror(
"Solver matrices solution mapping is not associated.",err,error,*998)
22572 CALL flagerror(
"Solver equations solver matrices are not associated.",err,error,*998)
22575 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
22578 CALL flagerror(
"Solver has not been finished.",err,error,*998)
22581 CALL flagerror(
"Solver is not associated.",err,error,*998)
22584 exits(
"SOLVER_VARIABLES_FIELD_UPDATE")
22586 999
IF(
ASSOCIATED(solver_data))
CALL distributed_vector_data_restore(solver_vector,solver_data,dummy_err,dummy_error,*998)
22587 998 errorsexits(
"SOLVER_VARIABLES_FIELD_UPDATE",err,error)
22600 TYPE(solvers_type),
POINTER :: SOLVERS
22601 INTEGER(INTG),
INTENT(OUT) :: ERR
22602 TYPE(varying_string),
INTENT(OUT) :: ERROR
22604 INTEGER(INTG) :: solver_idx
22605 TYPE(control_loop_type),
POINTER :: CONTROL_LOOP
22606 TYPE(solver_type),
POINTER :: SOLVER
22608 enters(
"SOLVERS_CREATE_FINISH",err,error,*999)
22610 IF(
ASSOCIATED(solvers))
THEN 22611 IF(solvers%SOLVERS_FINISHED)
THEN 22612 CALL flagerror(
"Solvers has already been finished.",err,error,*999)
22614 control_loop=>solvers%CONTROL_LOOP
22615 IF(
ASSOCIATED(control_loop))
THEN 22617 IF(
ALLOCATED(solvers%SOLVERS))
THEN 22618 DO solver_idx=1,solvers%NUMBER_OF_SOLVERS
22619 solver=>solvers%SOLVERS(solver_idx)%PTR
22620 IF(
ASSOCIATED(solver))
THEN 22623 CALL flagerror(
"Solver is not associated.",err,error,*999)
22626 solvers%SOLVERS_FINISHED=.true.
22628 CALL flagerror(
"Solvers solvers is not allocated.",err,error,*999)
22631 CALL flagerror(
"Solvers control loop is not associated.",err,error,*999)
22635 CALL flagerror(
"Solvers is not associated.",err,error,*999)
22638 exits(
"SOLVERS_CREATE_FINISH")
22640 999 errorsexits(
"SOLVERS_CREATE_FINISH",err,error)
22653 TYPE(control_loop_type),
POINTER :: CONTROL_LOOP
22654 TYPE(solvers_type),
POINTER :: SOLVERS
22655 INTEGER(INTG),
INTENT(OUT) :: ERR
22656 TYPE(varying_string),
INTENT(OUT) :: ERROR
22658 TYPE(varying_string) :: LOCAL_ERROR
22660 enters(
"SOLVERS_CREATE_START",err,error,*999)
22662 IF(
ASSOCIATED(control_loop))
THEN 22663 IF(control_loop%CONTROL_LOOP_FINISHED)
THEN 22664 IF(control_loop%NUMBER_OF_SUB_LOOPS==0)
THEN 22665 IF(
ASSOCIATED(solvers))
THEN 22666 CALL flagerror(
"Solvers is already associated.",err,error,*999)
22672 solvers=>control_loop%SOLVERS
22675 local_error=
"Invalid control loop setup. The specified control loop has "// &
22676 & trim(numbertovstring(control_loop%NUMBER_OF_SUB_LOOPS,
"*",err,error))// &
22677 &
" sub loops. To create solvers the control loop must have 0 sub loops." 22678 CALL flagerror(local_error,err,error,*999)
22681 CALL flagerror(
"Control loop has not been finished.",err,error,*999)
22684 CALL flagerror(
"Control loop is not associated.",err,error,*999)
22687 exits(
"SOLVERS_CREATE_START")
22689 999 errorsexits(
"SOLVERS_CREATE_START",err,error)
22701 TYPE(solvers_type),
POINTER :: SOLVERS
22702 INTEGER(INTG),
INTENT(OUT) :: ERR
22703 TYPE(varying_string),
INTENT(OUT) :: ERROR
22706 enters(
"SOLVERS_DESTROY",err,error,*999)
22708 IF(
ASSOCIATED(solvers))
THEN 22711 CALL flagerror(
"Solvers is not associated.",err,error,*999)
22714 exits(
"SOLVERS_DESTROY")
22716 999 errorsexits(
"SOLVERS_DESTROY",err,error)
22729 TYPE(solvers_type),
POINTER :: SOLVERS
22730 INTEGER(INTG),
INTENT(OUT) :: ERR
22731 TYPE(varying_string),
INTENT(OUT) :: ERROR
22733 INTEGER(INTG) :: solver_idx
22735 enters(
"SOLVERS_FINALISE",err,error,*999)
22737 IF(
ASSOCIATED(solvers))
THEN 22738 IF(
ALLOCATED(solvers%SOLVERS))
THEN 22739 DO solver_idx=1,
SIZE(solvers%SOLVERS,1)
22742 DEALLOCATE(solvers%SOLVERS)
22744 DEALLOCATE(solvers)
22747 exits(
"SOLVERS_FINALISE")
22749 999 errorsexits(
"SOLVERS_FINALISE",err,error)
22761 TYPE(control_loop_type),
POINTER :: CONTROL_LOOP
22762 INTEGER(INTG),
INTENT(OUT) :: ERR
22763 TYPE(varying_string),
INTENT(OUT) :: ERROR
22765 INTEGER(INTG) :: DUMMY_ERR,solver_idx
22766 TYPE(varying_string) :: DUMMY_ERROR
22768 enters(
"SOLVERS_INITIALISE",err,error,*998)
22770 IF(
ASSOCIATED(control_loop))
THEN 22771 IF(
ASSOCIATED(control_loop%SOLVERS))
THEN 22772 CALL flagerror(
"Solvers is already allocated for this control loop.",err,error,*998)
22774 ALLOCATE(control_loop%SOLVERS,stat=err)
22775 IF(err/=0)
CALL flagerror(
"Could not allocate control loop solvers.",err,error,*999)
22776 control_loop%SOLVERS%CONTROL_LOOP=>control_loop
22777 control_loop%SOLVERS%SOLVERS_FINISHED=.false.
22778 control_loop%SOLVERS%NUMBER_OF_SOLVERS=1
22779 ALLOCATE(control_loop%SOLVERS%SOLVERS(control_loop%SOLVERS%NUMBER_OF_SOLVERS),stat=err)
22780 IF(err/=0)
CALL flagerror(
"Could not allocate solvers solvers.",err,error,*999)
22781 DO solver_idx=1,control_loop%SOLVERS%NUMBER_OF_SOLVERS
22782 NULLIFY(control_loop%SOLVERS%SOLVERS(solver_idx)%PTR)
22787 CALL flagerror(
"Control loop is not associated.",err,error,*998)
22790 exits(
"SOLVERS_INITIALISE")
22792 999
CALL solvers_finalise(control_loop%SOLVERS,dummy_err,dummy_error,*998)
22793 998 errorsexits(
"SOLVERS_INITIALISE",err,error)
22807 TYPE(solvers_type),
POINTER :: SOLVERS
22808 INTEGER(INTG),
INTENT(IN) :: NUMBER_OF_SOLVERS
22809 INTEGER(INTG),
INTENT(OUT) :: ERR
22810 TYPE(varying_string),
INTENT(OUT) :: ERROR
22812 INTEGER(INTG) :: solver_idx, OLD_NUMBER_OF_SOLVERS
22813 TYPE(solver_ptr_type),
ALLOCATABLE :: OLD_SOLVERS(:)
22814 TYPE(varying_string) :: LOCAL_ERROR
22816 enters(
"SOLVERS_NUMBER_SET",err,error,*998)
22818 IF(
ASSOCIATED(solvers))
THEN 22819 IF(solvers%SOLVERS_FINISHED)
THEN 22820 CALL flagerror(
"Solvers have already been finished.",err,error,*998)
22822 IF(number_of_solvers>0)
THEN 22823 old_number_of_solvers=solvers%NUMBER_OF_SOLVERS
22824 IF(number_of_solvers/=old_number_of_solvers)
THEN 22825 ALLOCATE(old_solvers(old_number_of_solvers),stat=err)
22826 IF(err/=0)
CALL flagerror(
"Could not allocate old solvers.",err,error,*999)
22827 DO solver_idx=1,old_number_of_solvers
22828 old_solvers(solver_idx)%PTR=>solvers%SOLVERS(solver_idx)%PTR
22830 IF(
ALLOCATED(solvers%SOLVERS))
DEALLOCATE(solvers%SOLVERS)
22831 ALLOCATE(solvers%SOLVERS(number_of_solvers),stat=err)
22832 IF(err/=0)
CALL flagerror(
"Could not allocate solvers.",err,error,*999)
22833 IF(number_of_solvers>old_number_of_solvers)
THEN 22834 DO solver_idx=1,old_number_of_solvers
22835 solvers%SOLVERS(solver_idx)%PTR=>old_solvers(solver_idx)%PTR
22837 solvers%NUMBER_OF_SOLVERS=number_of_solvers
22838 DO solver_idx=old_number_of_solvers+1,number_of_solvers
22839 NULLIFY(solvers%SOLVERS(solver_idx)%PTR)
22843 DO solver_idx=1,number_of_solvers
22844 solvers%SOLVERS(solver_idx)%PTR=>old_solvers(solver_idx)%PTR
22846 DO solver_idx=number_of_solvers+1,old_number_of_solvers
22849 solvers%NUMBER_OF_SOLVERS=number_of_solvers
22853 local_error=
"The specified number of solvers of "//trim(numbertovstring(number_of_solvers,
"*",err,error))// &
22854 &
" is invalid. The number of solvers must be > 0." 22855 CALL flagerror(local_error,err,error,*998)
22859 CALL flagerror(
"Solvers is not associated.",err,error,*998)
22862 exits(
"SOLVERS_NUMBER_SET")
22864 999
IF(
ALLOCATED(old_solvers))
DEALLOCATE(old_solvers)
22865 998 errorsexits(
"SOLVERS_NUMBER_SET",err,error)
22878 TYPE(solvers_type),
POINTER :: SOLVERS
22879 INTEGER(INTG),
INTENT(IN) :: SOLVER_INDEX
22880 TYPE(solver_type),
POINTER :: SOLVER
22881 INTEGER(INTG),
INTENT(OUT) :: ERR
22882 TYPE(varying_string),
INTENT(OUT) :: ERROR
22884 TYPE(varying_string) :: LOCAL_ERROR
22886 enters(
"SOLVERS_SOLVER_GET",err,error,*998)
22888 IF(
ASSOCIATED(solvers))
THEN 22889 IF(
ASSOCIATED(solver))
THEN 22890 CALL flagerror(
"Solver is already associated.",err,error,*998)
22893 IF(solver_index>0.AND.solver_index<=solvers%NUMBER_OF_SOLVERS)
THEN 22894 IF(
ALLOCATED(solvers%SOLVERS))
THEN 22895 solver=>solvers%SOLVERS(solver_index)%PTR
22896 IF(.NOT.
ASSOCIATED(solver))
CALL flagerror(
"Solver is not associated.",err,error,*999)
22898 CALL flagerror(
"Solvers solvers is not associated.",err,error,*999)
22901 local_error=
"The specified solver index of "//trim(numbertovstring(solver_index,
"*",err,error))// &
22902 &
" is invalid. The solver index must be >= 1 and <= "// &
22903 & trim(numbertovstring(solvers%NUMBER_OF_SOLVERS,
"*",err,error))//
"." 22904 CALL flagerror(local_error,err,error,*999)
22908 CALL flagerror(
"Solvers is not associated.",err,error,*998)
22911 exits(
"SOLVERS_SOLVER_GET")
22913 999
NULLIFY(solver)
22914 998 errorsexits(
"SOLVERS_SOLVER_GET",err,error)
22927 TYPE(solver_type),
POINTER :: SOLVER
22928 TYPE(solver_type),
POINTER :: SOLVER_TO_LINK
22929 INTEGER(INTG),
INTENT(IN) :: SOLV_TYPE
22930 INTEGER(INTG),
INTENT(OUT) :: ERR
22931 TYPE(varying_string),
INTENT(OUT) :: ERROR
22933 TYPE(varying_string) :: LOCAL_ERROR
22934 TYPE(solver_ptr_type),
ALLOCATABLE,
TARGET :: OLD_LINKED_SOLVERS(:)
22935 INTEGER(INTG) :: solver_idx
22937 enters(
"SOLVER_LINKED_SOLVER_ADD",err,error,*999)
22939 IF(
ASSOCIATED(solver))
THEN 22940 IF(
ASSOCIATED(solver_to_link))
THEN 22943 IF(solver%NUMBER_OF_LINKED_SOLVERS==0)
THEN 22945 ALLOCATE(solver%LINKED_SOLVERS(1),stat=err)
22946 IF(err/=0)
CALL flagerror(
"Could not allocate linked solvers.",err,error,*999)
22948 NULLIFY(solver%LINKED_SOLVER_TYPE_MAP(solver_idx)%PTR)
22950 solver%LINKED_SOLVER_TYPE_MAP(solv_type)%PTR=>solver_to_link
22951 solver%LINKED_SOLVERS(1)%PTR=>solver_to_link
22952 solver%NUMBER_OF_LINKED_SOLVERS=solver%NUMBER_OF_LINKED_SOLVERS+1
22956 DO solver_idx=1,solver%NUMBER_OF_LINKED_SOLVERS
22957 IF(solver%LINKED_SOLVERS(solver_idx)%PTR%SOLVE_TYPE==solv_type)
THEN 22958 local_error=
"The solver has already a linked solver of type "//trim(numbertovstring(solv_type, &
22959 &
"*",err,error))//
" attached to it." 22960 CALL flagerror(local_error,err,error,*999)
22963 ALLOCATE(old_linked_solvers(solver%NUMBER_OF_LINKED_SOLVERS),stat=err)
22964 IF(err/=0)
CALL flagerror(
"Could not old linked solvers.",err,error,*999)
22965 DO solver_idx=1,solver%NUMBER_OF_LINKED_SOLVERS
22966 old_linked_solvers(solver_idx)%PTR=>solver%LINKED_SOLVERS(solver_idx)%PTR
22968 DEALLOCATE(solver%LINKED_SOLVERS)
22969 ALLOCATE(solver%LINKED_SOLVERS(solver%NUMBER_OF_LINKED_SOLVERS+1),stat=err)
22970 IF(err/=0)
CALL flagerror(
"Could not new linked solvers.",err,error,*999)
22971 DO solver_idx=1,solver%NUMBER_OF_LINKED_SOLVERS
22972 solver%LINKED_SOLVERS(solver_idx)%PTR=>old_linked_solvers(solver_idx)%PTR
22974 solver%LINKED_SOLVERS(solver%NUMBER_OF_LINKED_SOLVERS+1)%PTR=>solver_to_link
22975 solver%LINKED_SOLVER_TYPE_MAP(solv_type)%PTR=>solver_to_link
22976 solver%NUMBER_OF_LINKED_SOLVERS=solver%NUMBER_OF_LINKED_SOLVERS+1
22977 DEALLOCATE(old_linked_solvers)
22979 local_error=
"The number of linked solvers is "//trim(numbertovstring(solver%NUMBER_OF_LINKED_SOLVERS,
"*",err, &
22981 CALL flagerror(local_error,err,error,*999)
22984 solver%LINKED_SOLVER_TYPE_MAP(solv_type)%PTR%SOLVE_TYPE=solv_type
22986 solver%LINKED_SOLVER_TYPE_MAP(solv_type)%PTR%LINKING_SOLVER=>solver
22988 local_error=
"The specified solver type is "//trim(numbertovstring(solv_type,
"*",err,error))//&
22990 CALL flagerror(local_error,err,error,*999)
22993 CALL flagerror(
"The solver to link is not associated.",err,error,*999)
22996 CALL flagerror(
"Solver is not associated.",err,error,*999)
22999 exits(
"SOLVER_LINKED_SOLVER_ADD")
23001 999 errorsexits(
"SOLVER_LINKED_SOLVER_ADD",err,error)
23013 TYPE(solver_type),
POINTER :: SOLVER
23014 INTEGER(INTG),
INTENT(IN) :: SOLV_TYPE
23015 INTEGER(INTG),
INTENT(OUT) :: ERR
23016 TYPE(varying_string),
INTENT(OUT) :: ERROR
23018 TYPE(varying_string) :: LOCAL_ERROR
23019 INTEGER(INTG) :: solver_idx
23021 enters(
"SOLVER_LINKED_SOLVER_REMOVE",err,error,*999)
23023 IF(
ASSOCIATED(solver))
THEN 23028 DO solver_idx=1,solver%NUMBER_OF_LINKED_SOLVERS
23029 IF(solver%LINKED_SOLVERS(solver_idx)%PTR%SOLVE_TYPE==solv_type)
THEN 23030 DEALLOCATE(solver%LINKED_SOLVERS)
23031 solver%NUMBER_OF_LINKED_SOLVERS=solver%NUMBER_OF_LINKED_SOLVERS-1
23036 local_error=
"The specified solver type is "//trim(numbertovstring(solv_type,
"*",err,error))//&
23038 CALL flagerror(local_error,err,error,*999)
23041 CALL flagerror(
"Solver is not associated.",err,error,*999)
23044 exits(
"SOLVER_LINKED_SOLVER_REMOVE")
23046 999 errorsexits(
"SOLVER_LINKED_SOLVER_REMOVE",err,error)
23078 INTEGER(INTG),
INTENT(INOUT) :: STEPS
23079 REAL(DP),
INTENT(INOUT) :: TIME
23082 INTEGER(INTG),
INTENT(INOUT) :: ERR
23087 IF(
ASSOCIATED(ctx))
THEN 23089 dae_solver=>ctx%DAE_SOLVER
23094 local_error=
"Invalid solve type. The solve type of "//
trim(
numbertovstring(ctx%SOLVE_TYPE,
"*",err,error))// &
23095 &
" does not correspond to a differntial-algebraic equations solver." 23096 CALL flagerror(local_error,err,error,*999)
23099 CALL flagerror(
"Solver context is not associated.",err,error,*999)
23104 998
CALL flag_warning(
"Error monitoring differential-algebraic equations solve.",err,error,*997)
23127 INTEGER(INTG),
INTENT(INOUT) :: ITS
23128 REAL(DP),
INTENT(INOUT) :: NORM
23130 INTEGER(INTG),
INTENT(INOUT) :: ERR
23135 IF(
ASSOCIATED(ctx))
THEN 23137 nonlinear_solver=>ctx%NONLINEAR_SOLVER
23142 local_error=
"Invalid solve type. The solve type of "//
trim(
numbertovstring(ctx%SOLVE_TYPE,
"*",err,error))// &
23143 &
" does not correspond to a nonlinear solver." 23144 CALL flagerror(local_error,err,error,*999)
23147 CALL flagerror(
"Solver context is not associated.",err,error,*999)
23152 998
CALL flag_warning(
"Error monitoring nonlinear solve.",err,error,*997)
subroutine solver_dae_rush_larson_initialise(DAE_SOLVER, ERR, ERROR,)
Initialise an Rush-Larson solver for a differential-algebraic equation solver.
integer(intg), parameter solver_equations_second_order_dynamic
Solver equations are second order dynamic.
subroutine, public enters(NAME, ERR, ERROR,)
Records the entry into the named procedure and initialises the error code.
integer(intg), parameter, public solver_quasi_newton_scale_shanno
Use Shanno scaling.
Contains information for an forward Euler differential-algebraic equation solver. ...
subroutine, public solvers_create_finish(SOLVERS, ERR, ERROR,)
Finish the creation of solvers.
subroutine solver_newton_trustregion_solve(TRUSTREGION_SOLVER, ERR, ERROR,)
subroutine, public petsc_tsfinalise(ts, err, error,)
integer(intg), parameter, public solver_dynamic_newmark3_scheme
3rd Newmark dynamic solver
subroutine, public solver_newton_linesearch_steptol_set(SOLVER, LINESEARCH_STEPTOL, ERR, ERROR,)
Sets/changes the line search step tolerance for a nonlinear Newton line search solver.
subroutine, public cellml_field_to_cellml_update(CELLML, ERR, ERROR,)
Updates any cellml fields from the mapped fields.
subroutine, public solver_matrices_dynamic_assemble(SOLVER, SELECTION_TYPE, ERR, ERROR,)
Assembles the solver matrices and rhs from the dynamic equations.
integer(intg), parameter, public solver_dynamic_third_degree
Dynamic solver uses a third degree polynomial for time interpolation.
subroutine, public solver_variables_field_update(SOLVER, ERR, ERROR,)
Updates the dependent variables from the solver solution for static solvers.
integer(intg), parameter, public solver_dae_bdf
General BDF differential-algebraic equation solver.
Contains information on the equations mapping i.e., how field variable DOFS are mapped to the rows an...
Contains information about the CellML equations for a solver.
Contains information about the equations in an equations set.
subroutine, public solver_lineariterativerelativetoleranceset(SOLVER, RELATIVE_TOLERANCE, ERR, ERROR,)
Sets/changes the relative tolerance for an iterative linear solver.
integer(intg), parameter, public solver_timing_output
Timing output from the solver routines plus below.
subroutine, public solver_newton_relative_tolerance_set(SOLVER, RELATIVE_TOLERANCE, ERR, ERROR,)
Sets/changes the relative tolerance for a nonlinear Newton solver.
subroutine, public solver_nonlinear_divergence_exit(SOLVER, ERR, ERROR,)
Instead of warning on nonlinear divergence, exit with error.
This module handles all solver matrix and rhs routines.
integer(intg), parameter, public solver_iterative_sor_preconditioner
Successive over relaxation preconditioner type.
recursive subroutine solver_newton_finalise(NEWTON_SOLVER, ERR, ERROR,)
Finalise a Newton solver and deallocate all memory.
subroutine solver_dae_bdf_finalise(BDF_SOLVER, ERR, ERROR,)
Finalise a BDF differential-algebraic equation solver and deallocate all memory.
integer(intg), parameter, public solver_dynamic_backward_euler_scheme
Backward Euler (implicit) dynamic solver.
integer(intg), parameter, public solver_dae_euler_forward
Forward Euler differential equation solver.
subroutine solver_optimiser_library_type_get(OPTIMISER_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for an optimiser solver.
integer(intg), parameter, public solver_quasi_newton_lbfgs
LBFGS Quasi-Newton type.
This module handles all problem wide constants.
integer(intg), parameter solver_equations_first_order_dynamic
Solver equations are first order dynamic.
integer(intg), parameter, public solver_iterative_additive_schwarz_preconditioner
Additive Schwrz preconditioner type.
subroutine, public solver_dynamic_order_set(SOLVER, ORDER, ERR, ERROR,)
Sets/changes the order for a dynamic solver.
subroutine solver_newton_linesearch_create_finish(LINESEARCH_SOLVER, ERR, ERROR,)
Finishes the process of creating nonlinear Newton line search solver.
integer(intg), parameter, public solver_dae_euler_improved
Improved Euler differential equation solver.
subroutine, public distributed_vector_create_start(DOMAIN_MAPPING, DISTRIBUTED_VECTOR, ERR, ERROR,)
Starts the creation a distributed vector.
subroutine, public solver_dae_euler_solver_type_set(SOLVER, DAE_EULER_TYPE, ERR, ERROR,)
Sets/changes the solve type for an Euler differential-algebraic equation solver.
subroutine solver_lineariterativematriceslibrarytypeget(ITERATIVE_SOLVER, MATRICES_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for an iterative linear solver matrices.
subroutine solver_dae_external_finalise(EXTERNAL_SOLVER, ERR, ERROR,)
Finalise an external differential-algebraic equation solver and deallocate all memory.
Contains information for a Runge-Kutta differential-algebraic equation solver.
Contains information for a Crank-Nicholson differential-algebraic equation solver.
This module is a CMISS buffer module to the PETSc library.
subroutine, public solver_newton_trustregion_delta0_set(SOLVER, TRUSTREGION_DELTA0, ERR, ERROR,)
Sets/changes the trust region delta0 for a nonlinear Newton trust region solver solver.
subroutine, public petsc_vecsetvalues(x, n, indices, values, insertMode, err, error,)
Buffer routine to the PETSc VecSetValues routine.
subroutine, public distributed_vector_create_finish(DISTRIBUTED_VECTOR, ERR, ERROR,)
Finishes the creation a distributed vector.
subroutine, public petsc_tssetduration(ts, maxSteps, maxTime, err, error,)
Buffer routine to the PETSc TSSetDuration routine.
integer(intg), parameter, public solver_dae_index_1
Index 1 differential-algebraic equation.
integer(intg), parameter, public solver_linear_iterative_solve_type
Iterative linear solver type.
subroutine solver_dynamic_library_type_get(DYNAMIC_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for a dynamic solver.
subroutine solver_dae_library_type_get(DAE_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for a differential-algebraic equation solver.
subroutine, public solver_geometrictransformationtranslationset(solver, translation, incrementIdx, err, error,)
Set the translation for a geometric transformation.
This module contains types related to the PETSc library.
subroutine, public solver_geometrictransformationmatrixset(solver, matrix, incrementIdx, err, error,)
Set the full transformation matrix for a geometric transformation at a load increment.
Contains information for an Euler differential-algebraic equation solver.
subroutine solver_dynamic_initialise(SOLVER, ERR, ERROR,)
Initialise a dynamic solver for a solver.
subroutine, public petsc_tssetrhsfunction(ts, rates, rhsFunction, ctx, err, error,)
Buffer routine to the PETSc TSSetRHSFunction routine.
subroutine solver_initialise_ptr(SOLVER, ERR, ERROR,)
Initialise a solver.
integer(intg), parameter, public solver_linear_direct_solve_type
Direct linear solver type.
integer(intg), parameter library_cmiss_type
CMISS (internal) library type.
Contains information on the type of solver to be used.
integer(intg), parameter, public solver_iterative_bicgstab
Stabalised bi-conjugate gradient iterative solver type.
integer(intg), parameter, public solver_dynamic_bossak_newmark2_scheme
2nd Bossak-Newmark dynamic solver
integer(intg), parameter, public solver_solution_initialise_current_field
Initialise the solution by copying in the current dependent field values.
integer(intg), parameter, public solver_newton_jacobian_equations_calculated
The Jacobian values will be calculated analytically for the nonlinear equations set.
integer(intg), parameter, public solver_petsc_library
PETSc solver library.
subroutine solver_linear_direct_library_type_set(DIRECT_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Sets/changes the type of library to use for a direct linear solver.
subroutine, public solvers_number_set(SOLVERS, NUMBER_OF_SOLVERS, ERR, ERROR,)
Sets/changes the number of solvers.
subroutine solver_dynamic_theta_set_dp1(SOLVER, THETA, ERR, ERROR,)
Sets/changes a single theta value for a dynamic solver.
integer(intg), parameter, public solver_direct_lu
LU direct linear solver.
subroutine solver_optimiser_solve(OPTIMISER_SOLVER, ERR, ERROR,)
Solve an optimiser solver.
subroutine, public solver_geometrictransformationscalingsset(solver, scalings, err, error,)
Set the scalings for geometric transformation solver.
subroutine solver_newton_solve(NEWTON_SOLVER, ERR, ERROR,)
subroutine, public solver_matrices_create_finish(SOLVER_MATRICES, ERR, ERROR,)
Finishes the process of creating the solver matrices.
subroutine, public solver_dae_time_step_set(SOLVER, TIME_STEP, ERR, ERROR,)
Set/change the (initial) time step size for a differential-algebraic equation solver.
integer(intg), parameter, public solver_dynamic_crank_nicolson_scheme
Crank-Nicolson dynamic solver.
integer(intg), parameter, public solver_iterative_conjgrad_squared
Conjugate gradient squared iterative solver type.
subroutine, public solver_dynamic_degree_set(SOLVER, DEGREE, ERR, ERROR,)
Sets/changes the degree of the polynomial used to interpolate time for a dynamic solver.
subroutine, public solver_quasinewtonjacobiancalculationtypeset(SOLVER, JACOBIAN_CALCULATION_TYPE, ERR, ERROR,)
Sets/changes the type of Jacobian calculation type for a Quasi-Newton solver.
integer(intg), parameter, public solver_dae_rush_larson
Rush-Larson differential-algebraic equation solver.
subroutine solver_newton_linesearch_finalise(LINESEARCH_SOLVER, ERR, ERROR,)
Finalise a nonlinear Newton line search solver and deallocate all memory.
integer(intg), parameter, public solver_dynamic_first_order
Dynamic solver has first order terms.
subroutine, public solver_newton_solution_tolerance_set(SOLVER, SOLUTION_TOLERANCE, ERR, ERROR,)
Sets/changes the solution tolerance for a nonlinear Newton solver.
subroutine solver_dae_euler_forward_integrate(FORWARD_EULER_SOLVER, CELLML, N, START_TIME, END_TIME, TIME_INCREMENT, ONLY_ONE_MODEL_INDEX, MODELS_DATA, MAX_NUMBER_STATES, STATE_DATA, MAX_NUMBER_PARAMETERS, PARAMETERS_DATA, MAX_NUMBER_INTERMEDIATES, INTERMEDIATE_DATA, ERR, ERROR,)
Integrate using a forward Euler differential-algebraic equation solver.
subroutine solver_linear_iterative_library_type_get(ITERATIVE_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for an iterative linear solver.
subroutine, public solver_type_set(SOLVER, SOLVE_TYPE, ERR, ERROR,)
Sets/changes the type for a solver.
subroutine, public solver_mumpssetcntl(solver, icntl, val, err, error,)
Sets MUMPS CNTL(icntl)=val through PETSc Mat API (see MUMPS user guide for more info). Must be called after the boundary conditions have been set up.
integer(intg), parameter library_lusol_type
LUSOL library type.
subroutine solver_dae_rush_larson_solve(RUSH_LARSON_SOLVER, ERR, ERROR,)
Solve using a Rush-Larson differential-algebraic equation solver.
integer(intg), parameter, public solver_essl_library
ESSL solver library.
Contains information on an equations set.
recursive subroutine solver_quasi_newton_finalise(QUASI_NEWTON_SOLVER, ERR, ERROR,)
Finalise a Quasi-Newton solver and deallocate all memory.
integer(intg), parameter library_mumps_type
MUMPS library type.
recursive subroutine solver_nonlinear_finalise(NONLINEAR_SOLVER, ERR, ERROR,)
Finalise a nonlinear solver for a solver.
subroutine solver_dae_euler_library_type_get(EULER_DAE_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for an Euler differential-algebraic equation solver.
integer(intg), parameter, public solver_dae_type
A differential-algebraic equation solver.
subroutine solver_linear_direct_solve(LINEAR_DIRECT_SOLVER, ERR, ERROR,)
Solve a linear direct solver.
This module contains all string manipulation and transformation routines.
integer(intg), parameter library_umfpack_type
UMFPack library type.
subroutine, public solvers_create_start(CONTROL_LOOP, SOLVERS, ERR, ERROR,)
Start the creation of a solvers for the control loop.
subroutine solver_daecellmlpetsccontextset(ctx, solver, cellml, dofIdx, err, error,)
Set a CellML PETSc context.
subroutine solver_linear_initialise(SOLVER, ERR, ERROR,)
Initialise a linear solver for a solver.
integer(intg), parameter, public solver_newton_trustregion
Newton trust region nonlinear solver type.
subroutine solver_linear_iterative_library_type_set(ITERATIVE_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Sets/changes the type of library to use for an iterative linear solver.
integer(intg), parameter, public solver_newton_jacobian_not_calculated
The Jacobian values will not be calculated for the nonlinear equations set.
integer(intg), parameter, public solver_full_matrices
Use fully populated solver matrices.
subroutine solver_time_stepping_monitor_petsc(ts, STEPS, TIME, X, CTX, ERR)
Called from the PETSc TS solvers to monitor the dynamic solver.
subroutine, public cellml_cellml_to_field_update(CELLML, ERR, ERROR,)
Updates any mapped fields from the cellml fields.
subroutine, public solver_library_type_get(SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Gets the type of library to use for the solver.
subroutine, public solver_dynamic_linearity_type_set(SOLVER, LINEARITY_TYPE, ERR, ERROR,)
Sets/changes the linearity type for the dynamic solver.
subroutine solver_dae_euler_improved_finalise(IMPROVED_EULER_SOLVER, ERR, ERROR,)
Finalise an improved Euler differential-algebaic equation and deallocate all memory.
subroutine, public solver_newton_linear_solver_get(SOLVER, LINEAR_SOLVER, ERR, ERROR,)
Returns the linear solver associated with a Newton solver.
subroutine solver_dae_adams_moulton_initialise(DAE_SOLVER, ERR, ERROR,)
Initialise an Adams-Moulton solver for a differential-algebraic equation solver.
subroutine, public solver_newton_cellml_solver_get(SOLVER, CELLML_SOLVER, ERR, ERROR,)
Returns the CellML solver associated with a Newton solver.
integer(intg), parameter, public solver_dae_euler
Euler differential-algebraic equation solver.
subroutine solver_dae_crank_nicolson_solve(CRANK_NICOLSON_SOLVER, ERR, ERROR,)
Solve using a Crank-Nicolson differential-algebraic equation solver.
subroutine solvers_finalise(SOLVERS, ERR, ERROR,)
Finalises the solvers and deallocates all memory.
This module contains routines for timing the program.
subroutine, public solver_destroy(SOLVER, ERR, ERROR,)
Destroys a solver.
subroutine, public solver_newton_linesearch_maxstep_set(SOLVER, LINESEARCH_MAXSTEP, ERR, ERROR,)
Sets/changes the line search maximum step for a nonlinear Newton linesearch solver.
Contains information for a CellML evaluation solver.
subroutine, public solverequations_numberofmatricesget(solverEquations, numberOfMatrices, err, error,)
Get the number of solver matrices for the solver equations.
integer(intg), parameter solver_equations_static
Solver equations are static.
subroutine, public solver_newtonmaximumfunctionevaluationsset(SOLVER, MAXIMUM_FUNCTION_EVALUATIONS, ERR, ERROR,)
Sets/changes the maximum number of function evaluations for a nonlinear Newton solver.
subroutine solver_create_finish(SOLVER, ERR, ERROR,)
Finishes the process of creating a solver.
subroutine, public solver_dynamic_linearity_type_get(SOLVER, LINEARITY_TYPE, ERR, ERROR,)
Returns the linearity type for the dynamic solver.
subroutine, public solver_equations_sparsity_type_set(SOLVER_EQUATIONS, SPARSITY_TYPE, ERR, ERROR,)
Sets/changes the sparsity type for solver equations.
subroutine, public solver_geometrictransformationrotationset(solver, pt, axis, theta, incrementIdx, err, error,)
Set the rotation for a geometric transformation.
subroutine, public solver_linear_type_set(SOLVER, LINEAR_SOLVE_TYPE, ERR, ERROR,)
Sets/changes the type of linear solver.
subroutine solver_newton_trustregion_initialise(NEWTON_SOLVER, ERR, ERROR,)
Initialise a Newton trust region solver for a nonlinear solver.
subroutine, public solver_quasinewtonmaximumfunctionevaluationsset(SOLVER, MAXIMUM_FUNCTION_EVALUATIONS, ERR, ERROR,)
Sets/changes the maximum number of function evaluations for a nonlinear Quasi-Newton solver...
This module contains all mathematics support routines.
subroutine solver_dae_bdf_initialise(DAE_SOLVER, ERR, ERROR,)
Initialise a BDF solver for a differential-algebraic equation solver.
subroutine, public solvers_solver_get(SOLVERS, SOLVER_INDEX, SOLVER, ERR, ERROR,)
Returns a pointer to the specified solver in the list of solvers.
Contains information for an Adams-Moulton differential-algebraic equation solver. ...
Contains information for a field defined on a region.
Flags a warning to the user.
integer(intg), parameter, public solver_direct_svd
SVD direct linear solver.
subroutine solver_dae_euler_improved_solve(IMPROVED_EULER_SOLVER, ERR, ERROR,)
Solve using an improved Euler differential-algebraic equation solver.
subroutine, public solver_daecellmlrhsevaluate(model, time, stateStartIdx, stateDataOffset, stateData, parameterStartIdx, parameterDataOffset, parameterData, intermediateStartIdx, intermediateDataOffset, intermediateData, rateStartIdx, rateDataOffset, rateData, err, error,)
Integrate using a forward Euler differential-algebraic equation solver.
integer(intg), parameter, public solver_iterative_block_jacobi_preconditioner
Iterative block Jacobi preconditioner type.
subroutine solver_equations_finalise(SOLVER_EQUATIONS, ERR, ERROR,)
Finalises the solver equations and deallocates all memory.
integer(intg), parameter solver_equations_linear
Solver equations are linear.
subroutine solver_nonlinear_library_type_get(NONLINEAR_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for a nonlinear solver.
subroutine, public solver_newton_jacobian_calculation_type_set(SOLVER, JACOBIAN_CALCULATION_TYPE, ERR, ERROR,)
Sets/changes the type of Jacobian calculation type for a Newton solver.
subroutine, public solver_mumpsseticntl(solver, icntl, ivalue, err, error,)
Sets MUMPS ICNTL(icntl)=ivalue through PETSc Mat API (see MUMPS user guide for more info)...
subroutine solver_newton_create_finish(NEWTON_SOLVER, ERR, ERROR,)
Finishes the process of creating a Newton solver.
subroutine cellml_equations_initialise(SOLVER, ERR, ERROR,)
Initialises the CellML equations for a solver.
integer(intg), parameter, public solver_solution_initialise_no_change
Do not change the solution before a solve.
This module provides an iso_varying_string module, conformant to the API specified in ISO/IEC 1539-2:...
subroutine, public solver_equations_create_finish(SOLVER_EQUATIONS, ERR, ERROR,)
Finishes the process of creating solver equations.
subroutine solver_lineardirectmatriceslibrarytypeget(DIRECT_SOLVER, MATRICES_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for a direct linear solver matrices.
subroutine solver_optimiser_finalise(OPTIMISER_SOLVER, ERR, ERROR,)
Finalise a optimiser solver.
This module handles all solver mapping routines.
subroutine solver_initialise(SOLVERS, SOLVER_INDEX, ERR, ERROR,)
Initialise a solver for a control loop.
integer(intg), parameter, public solver_sparse_matrices
Use sparse solver matrices.
subroutine solver_dae_euler_backward_initialise(EULER_DAE_SOLVER, ERR, ERROR,)
Initialise a backward Euler solver for a differential-algebraic equation solver.
subroutine solvers_initialise(CONTROL_LOOP, ERR, ERROR,)
Initialises the solvers for a control loop.
subroutine, public solver_equations_create_start(SOLVER, SOLVER_EQUATIONS, ERR, ERROR,)
Starts the process of creating solver equations.
integer(intg), parameter, public solver_iterative_jacobi_preconditioner
Jacobi preconditioner type.
subroutine solver_newton_initialise(NONLINEAR_SOLVER, ERR, ERROR,)
Initialise a Newton solver for a nonlinear solver.
subroutine, public solver_matrices_create_start(SOLVER_EQUATIONS, SOLVER_MATRICES, ERR, ERROR,)
Starts the process of creating the solver matrices.
subroutine, public solver_newton_linesearch_type_set(SOLVER, LINESEARCH_TYPE, ERR, ERROR,)
Sets/changes the line search type for a nonlinear Newton linesearch solver.
subroutine solver_dynamic_mean_predicted_calculate(SOLVER, ERR, ERROR,)
Copies the current to previous time-step, calculates mean predicted values, predicted values and prev...
subroutine solver_cellml_evaluator_library_type_set(CELLML_EVALUATOR_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Sets/changes the type of library to use for a CellML evaluator solver.
subroutine, public solver_cellml_evaluator_finalise(CELLML_EVALUATOR_SOLVER, ERR, ERROR,)
Finalise a CellML evaluator solver.
subroutine, public solver_lineariterativeabsolutetoleranceset(SOLVER, ABSOLUTE_TOLERANCE, ERR, ERROR,)
Sets/changes the maximum absolute tolerance for an iterative linear solver.
integer(intg), parameter, public solver_pastix_library
PaStiX solver library.
subroutine, public solver_quasi_newton_cellml_solver_get(SOLVER, CELLML_SOLVER, ERR, ERROR,)
Returns the CellML solver associated with a Quasi-Newton solver.
integer(intg), parameter, public solver_dynamic_type
A dynamic solver.
subroutine, public solver_dynamic_restart_get(SOLVER, RESTART, ERR, ERROR,)
Returns the restart value for a dynamic solver.
subroutine solver_dae_external_initialise(DAE_SOLVER, ERR, ERROR,)
Initialise an external solver for a differential-algebraic equation solver.
subroutine, public solver_dynamic_degree_get(SOLVER, DEGREE, ERR, ERROR,)
Returns the degree of the polynomial used to interpolate time for a dynamic solver.
integer(intg), parameter library_essl_type
ESSL library type.
subroutine solver_equations_initialise(SOLVER, ERR, ERROR,)
Initialises the solver equations for a solver.
integer(intg), parameter, public solver_nonlinear_quasi_newton
Sequential Quasi-Newton nonlinear solver type.
Contains information for mapping field variables to the dynamic matrices in the equations set of the ...
subroutine, public solverequations_rhsvectorget(solverEquations, rhsVector, err, error,)
Get the right hand side vector from the solver equations.
This module contains all program wide constants.
subroutine solver_newton_trustregion_create_finish(TRUSTREGION_SOLVER, ERR, ERROR,)
Finishes the process of creating nonlinear Newton trust region solver.
integer(intg), parameter solver_equations_nonlinear
Solver equations are nonlinear.
subroutine, public solver_library_type_set(SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Sets/changes the type of library type to use for the solver.
subroutine solver_optimiser_initialise(SOLVER, ERR, ERROR,)
Initialise an optimiser solver for a solver.
subroutine solver_dae_euler_improved_initialise(EULER_DAE_SOLVER, ERR, ERROR,)
Initialise an improved Euler solver for a differential-algebraic equation solver. ...
subroutine, public cellml_equations_destroy(CELLML_EQUATIONS, ERR, ERROR,)
Destroys the CellML equations.
subroutine solver_quasi_newton_library_type_set(QUASI_NEWTON_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Sets/changes the type of library to use for a Quasi-Newton solver.
subroutine, public cellml_equations_cellml_add(CELLML_EQUATIONS, CELLML, CELLML_INDEX, ERR, ERROR,)
Adds a CellML environment to a solvers CellML equations.
Flags a warning to the user.
subroutine solver_daecellmlpetsccontextinitialise(ctx, err, error,)
Initialise a CellML PETSc context.
subroutine, public solver_quasi_newton_solution_init_type_set(SOLVER, SOLUTION_INITIALISE_TYPE, ERR, ERROR,)
Sets/changes the solution initialisation for a nonlinear Quasi-Newton solver.
subroutine, public solverequations_vectorget(solverEquations, matrixIndex, vector, err, error,)
Get the vector assiciated with a solver matrix from the solver equations matrices.
integer(intg), parameter, public solver_dynamic_second_degree_gear_scheme
2nd degree Gear dynamic solver
subroutine, public solverequations_residualvectorget(solverEquations, residualVector, err, error,)
Get the residual vector from the solver equations for nonlinear problems.
subroutine, public solver_newton_solution_init_type_set(SOLVER, SOLUTION_INITIALISE_TYPE, ERR, ERROR,)
Sets/changes the solution initialisation for a nonlinear Newton solver.
Contains information on the solver, cellml, dof etc. for which cellml equations are to be evaluated b...
subroutine solver_cellml_evaluator_time_get(CELLML_EVALUATOR_SOLVER, TIME, ERR, ERROR,)
Returns the time for a CellML evaluator solver.
integer(intg), parameter, public solver_newton_convergence_petsc_default
Petsc default convergence test.
subroutine solver_dae_adams_moulton_finalise(ADAMS_MOULTON_SOLVER, ERR, ERROR,)
Finalise an Adams-Moulton differential-algebraic equation solver and deallocate all memory...
subroutine solver_nonlinear_monitor_petsc(snes, ITS, NORM, CTX, ERR)
Called from the PETSc SNES solvers to monitor the Newton nonlinear solver.
subroutine solver_newton_linesearch_initialise(NEWTON_SOLVER, ERR, ERROR,)
Initialise a nonlinear Newton line search solver for a Newton solver.
integer(intg), parameter, public solver_dynamic_houbolt_scheme
Houbolt dynamic solver.
subroutine, public petsc_tssetexactfinaltime(ts, exactFinalTime, err, error,)
Buffer routine to the PETSc TSSetExactFinalTime routine.
integer(intg), parameter, public solver_dynamic_zlamal_scheme
Zlamal dynamic solver.
subroutine, public petsc_tssetsolution(ts, initialSolution, err, error,)
Buffer routine to the PETSc TSSetSolution routine.
subroutine solver_newton_library_type_get(NEWTON_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for a Newton solver.
subroutine solver_dae_euler_forward_finalise(FORWARD_EULER_SOLVER, ERR, ERROR,)
Finalise a forward Euler differential-algebraic equation and deallocate all memory.
subroutine solver_newton_linesearch_solve(LINESEARCH_SOLVER, ERR, ERROR,)
subroutine, public solver_matrices_storage_type_set(SOLVER_MATRICES, STORAGE_TYPE, ERR, ERROR,)
Sets the storage type (sparsity) of the solver matrices.
subroutine solver_dae_runge_kutta_initialise(DAE_SOLVER, ERR, ERROR,)
Initialise a Runge-Kutta solver for a differential-algebraic equation solver.
integer(intg), parameter, public solver_iterative_incomplete_lu_preconditioner
Incomplete LU preconditioner type.
integer(intg), parameter, public solver_dynamic_user_defined_scheme
User specified degree and theta dynamic solver.
integer(intg), parameter, public solver_iterative_conjugate_gradient
Conjugate gradient iterative solver type.
Contains information for a nonlinear solver.
integer(intg), parameter, public solver_quasi_newton_linesearch_basic
Simple damping line search.
subroutine, public solver_geometrictransformationfieldset(solver, field, variableType, err, error,)
Set the field and field variable type for geometric transformation solver.
integer(intg), parameter solver_equations_quasistatic
Solver equations are quasistatic.
subroutine, public solver_quasi_newton_linesearch_maxstep_set(SOLVER, LINESEARCH_MAXSTEP, ERR, ERROR,)
Sets/changes the line search maximum step for a nonlinear Quasi-Newton linesearch solver...
subroutine solver_newton_library_type_set(NEWTON_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Sets/changes the type of library to use for a Newton solver.
integer(intg), parameter, public solver_newton_linesearch
Newton line search nonlinear solver type.
subroutine, public solver_equations_linearity_type_set(SOLVER_EQUATIONS, LINEARITY_TYPE, ERR, ERROR,)
Sets/changes the linearity type for solver equations.
subroutine, public solver_linear_direct_type_set(SOLVER, DIRECT_SOLVER_TYPE, ERR, ERROR,)
Sets/changes the type of direct linear solver.
subroutine, public solver_dynamic_linear_solver_get(SOLVER, LINEAR_SOLVER, ERR, ERROR,)
Returns the linear solver associated with a dynamic solver.
subroutine, public solver_output_type_set(SOLVER, OUTPUT_TYPE, ERR, ERROR,)
Sets/changes the output type for a solver.
integer(intg), parameter, public solver_quasi_newton_linesearch_cp
Critical point secant line search.
integer(intg), parameter, public solver_hypre_library
Hypre solver library.
subroutine, public cellml_equations_create_start(SOLVER, CELLML_EQUATIONS, ERR, ERROR,)
Starts the process of creating CellML equations.
subroutine solver_quasi_newton_linesearch_initialise(QUASI_NEWTON_SOLVER, ERR, ERROR,)
Initialise a nonlinear Quasi-Newton line search solver for a Quasi-Newton solver. ...
subroutine, public petsc_vecdestroy(x, err, error,)
Buffer routine to the PETSc VecDestroy routine.
subroutine solver_dae_bdf_integrate(BDF_SOLVER, CELLML, N, START_TIME, END_TIME, TIME_INCREMENT, ONLY_ONE_MODEL_INDEX, MODELS_DATA, MAX_NUMBER_STATES, STATE_DATA, MAX_NUMBER_PARAMETERS, PARAMETERS_DATA, MAX_NUMBER_INTERMEDIATES, INTERMEDIATE_DATA, ERR, ERROR,)
Integrate using a BDF differential-algebraic equation solver.
integer(intg), parameter, public solver_lusol_library
LUSOL solver library.
integer(intg), parameter, public solver_dae_differential_only
Differential equations only.
integer(intg), parameter, public solver_dae_euler_backward
Backward Euler differential equation solver.
subroutine, public exits(NAME)
Records the exit out of the named procedure.
subroutine, public solver_quasi_newton_linesearch_type_set(SOLVER, LINESEARCH_TYPE, ERR, ERROR,)
Sets/changes the line search type for a nonlinear Quasi-Newton linesearch solver. ...
subroutine solver_linear_direct_cholesky_finalise(DIRECT_SOLVER, ERR, ERROR,)
Finalise a Cholesky direct linear solver and deallocate all memory.
subroutine, public solver_lineariterativesolutioninittypeset(SOLVER, SOLUTION_INITIALISE_TYPE, ERR, ERROR,)
Sets/changes the solution initialise type for an iterative linear solver.
integer(intg), parameter, public solver_quasi_newton_scale_jacobian
Scale by inverting a previously computed Jacobian.
subroutine solver_quasi_newton_solve(QUASI_NEWTON_SOLVER, ERR, ERROR,)
subroutine solver_dae_euler_initialise(DAE_SOLVER, ERR, ERROR,)
Initialise an Euler solver for a differential-algebraic equation solver.
subroutine, public solver_equations_boundary_conditions_get(SOLVER_EQUATIONS, BOUNDARY_CONDITIONS, ERR, ERROR,)
Gets the boundary conditions for solver equations.
This module contains all type definitions in order to avoid cyclic module references.
subroutine solver_linear_direct_initialise(LINEAR_SOLVER, ERR, ERROR,)
Initialise a direct linear solver for a lienar solver.
subroutine, public solver_linear_iterative_gmres_restart_set(SOLVER, GMRES_RESTART, ERR, ERROR,)
Sets/changes the GMRES restart value for a GMRES iterative linear solver.
subroutine, public solver_cellml_equations_get(SOLVER, CELLML_EQUATIONS, ERR, ERROR,)
Returns a pointer to the CellML equations for a solver.
subroutine solver_label_set_vs(SOLVER, LABEL, ERR, ERROR,)
Sets the label of a solver.
Contains information on the equations mapping for nonlinear matrices i.e., how a field variable is ma...
Contains information on the equations matrices and vectors.
subroutine, public petsc_tssetinitialtimestep(ts, initialTime, timeStep, err, error,)
Buffer routine to the PETSc TSSetInitialTimeStep routine.
subroutine solver_dae_euler_forward_solve(FORWARD_EULER_SOLVER, ERR, ERROR,)
Solve using a forward Euler differential-algebraic equation solver.
subroutine solver_eigenproblem_create_finish(EIGENPROBLEM_SOLVER, ERR, ERROR,)
Finishes the process of creating a eigenproblem solver.
integer(intg), parameter, public solver_superlu_library
SuperLU solver library.
subroutine, public solver_quasi_newton_relative_tolerance_set(SOLVER, RELATIVE_TOLERANCE, ERR, ERROR,)
Sets/changes the relative tolerance for a nonlinear Quasi-Newton solver.
subroutine solver_eigenproblem_library_type_set(EIGENPROBLEM_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Sets/changes the type of library to use for an eigenproblem solver.
subroutine solver_linear_iterative_create_finish(LINEAR_ITERATIVE_SOLVER, ERR, ERROR,)
Finishes the process of creating a linear iterative solver.
This module contains all the low-level base routines e.g., all debug, control, and low-level communic...
integer(intg), parameter, public solver_iterative_incomplete_cholesky_preconditioner
Incomplete Cholesky preconditioner type.
integer(intg), parameter, public solver_dae_index_3
Index 3 differential-algebraic equation.
integer(intg), parameter, public solver_iterative_gmres
Generalised minimum residual iterative solver type.
subroutine, public solver_quasinewtonconvergencetesttypeset(solver, convergenceTestType, err, error,)
Sets/changes the convergence test for a Quasi-Newton nonlinear solver.
Contains information of the linear matrices for equations matrices.
integer(intg), parameter, public general_output_type
General output type.
subroutine solver_quasi_newton_trustregion_finalise(TRUSTREGION_SOLVER, ERR, ERROR,)
Finalise a nonlinear Quasi-Newton trust region solver and deallocate all memory.
integer(intg), parameter, public solver_quasi_newton_scale_linesearch
Scale based upon line search lambda.
subroutine solver_eigenproblemmatriceslibrarytypeget(EIGENPROBLEM_SOLVER, MATRICES_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for an eigenproblem solver matrices.
subroutine solver_dae_external_solve(EXTERNAL_SOLVER, ERR, ERROR,)
Solve using an external differential-algebraic equation solver.
subroutine solver_newton_matrices_library_type_get(NEWTON_SOLVER, MATRICES_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for a Newton solver matrices.
subroutine, public solver_dae_euler_solver_type_get(SOLVER, DAE_EULER_TYPE, ERR, ERROR,)
Returns the solve type for an Euler differential-algebraic equation solver.
subroutine solver_dynamic_theta_set_dp(SOLVER, THETA, ERR, ERROR,)
Sets/changes the theta value for a dynamic solver.
integer(intg), parameter, public solver_quasi_newton_linesearch
Quasi-Newton line search nonlinear solver type.
subroutine solver_dae_bdf_solve(BDF_SOLVER, ERR, ERROR,)
Solve using a BDF differential-algebraic equation solver.
integer(intg), parameter, public solver_dynamic_second_degree_liniger1_scheme
1st 2nd degree Liniger dynamic solver
recursive subroutine solver_dynamic_finalise(DYNAMIC_SOLVER, ERR, ERROR,)
Finalise a dynamic solver and deallocates all memory.
subroutine solver_dynamic_create_finish(DYNAMIC_SOLVER, ERR, ERROR,)
Finishes the process of creating a dynamic solver.
Contains information for an external differential-algebraic equation solver.
integer(intg), parameter, public solver_newton_convergence_differentiated_ratio
Sum of differentiated ratios of unconstrained to constrained residuals convergence test...
subroutine, public solver_lineariterativedivergencetoleranceset(SOLVER, DIVERGENCE_TOLERANCE, ERR, ERROR,)
Sets/changes the maximum divergence tolerance for an iterative linear solver.
integer(intg), parameter, public solver_dynamic_second_order
Dynamic solver has second order terms.
subroutine, public solver_quasinewtonlinesearchmonitoroutputset(solver, linesearchMonitorOutputFlag, err, error,)
Enables/disables output monitoring for a nonlinear Quasi-Newton line search solver.
integer(intg), parameter, public solver_dynamic_euler_scheme
Euler (explicit) dynamic solver.
integer(intg), parameter library_hypre_type
Hypre library type.
subroutine, public solver_dynamic_nonlinear_solver_get(SOLVER, NONLINEAR_SOLVER, ERR, ERROR,)
Returns the nonlinear solver associated with a dynamic solver.
integer(intg), parameter, public solver_tao_library
TAO solver library.
subroutine solver_linear_iterative_initialise(LINEAR_SOLVER, ERR, ERROR,)
Initialise an iterative linear solver for a linear solver.
subroutine, public solver_equations_equations_set_add(SOLVER_EQUATIONS, EQUATIONS_SET, EQUATIONS_SET_INDEX, ERR, ERROR,)
Adds equations sets to solver equations.
integer(intg), parameter library_petsc_type
PETSc library type.
integer(intg), parameter, public solver_nonlinear_type
A nonlinear solver.
subroutine, public solver_lineariterativepreconditionertypeset(SOLVER, ITERATIVE_PRECONDITIONER_TYPE, ERR, ERROR,)
Sets/changes the type of preconditioner for an iterative linear solver.
subroutine solver_dae_crank_nicolson_initialise(DAE_SOLVER, ERR, ERROR,)
Initialise a Crank-Nicolson solver for a differential-algebraic equation solver.
subroutine, public solver_quasi_newton_type_set(SOLVER, QUASI_NEWTON_TYPE, ERR, ERROR,)
Sets/changes the type of nonlinear Quasi-Newton solver.
integer(intg), parameter, public solver_geometric_transformation_type
An geometric transformation solver.
integer(intg), parameter, public solver_quasi_newton_restart_none
Never restart.
subroutine, public solver_nonlinear_type_set(SOLVER, NONLINEAR_SOLVE_TYPE, ERR, ERROR,)
Sets/changes the type of nonlinear solver.
Contains information on the state field for a CellML environment.
subroutine, public solver_solution_update(SOLVER, ERR, ERROR,)
Updates the solver solution from the field variables.
subroutine solver_optimiser_library_type_set(OPTIMISER_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Sets/changes the type of library to use for an optimisation solver.
subroutine solver_quasi_newton_create_finish(QUASI_NEWTON_SOLVER, ERR, ERROR,)
Finishes the process of creating a Quasi-Newton solver.
integer(intg), parameter, public solver_solution_initialise_zero
Initialise the solution by zeroing it before a solve.
This module contains all computational environment variables.
integer(intg), parameter, public solver_spooles_library
Spooles solver library.
integer(intg), parameter, public solver_cellml_evaluator_type
A CellML evaluation solver.
subroutine solver_label_set_c(SOLVER, LABEL, ERR, ERROR,)
Sets the label of a solver.
subroutine solver_quasi_newton_library_type_get(QUASI_NEWTON_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for a Quasi-Newton solver.
subroutine solver_matrices_library_type_get(SOLVER_MATRICES, LIBRARY_TYPE, ERR, ERROR,)
Gets the library type for the solver matrices (and vectors)
subroutine solver_dynamic_solve(DYNAMIC_SOLVER, ERR, ERROR,)
Solve a dynamic solver.
subroutine solver_nonlinear_matrices_library_type_get(NONLINEAR_SOLVER, MATRICES_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for a nonlinear solver matrices.
subroutine, public solver_nonlinear_monitor(nonlinearSolver, its, norm, err, error,)
Monitors the nonlinear solve.
subroutine, public solver_dynamic_update_bc_set(SOLVER, UPDATE_BC, ERR, ERROR,)
Sets/changes the bc flag for a dynamic solver.
integer(intg), parameter, public cellml_models_field_not_constant
The CellML environement models field is not constant.
integer(intg), parameter, public solver_newton_linesearch_cubic
Cubic search for Newton line search nonlinear solves.
integer(intg), parameter, public solver_quasi_newton_restart_powell
Restart based upon descent criteria.
integer(intg), parameter, public solver_dae_index_2
Index 2 differential-algebraic equation.
subroutine solver_linear_direct_finalise(LINEAR_DIRECT_SOLVER, ERR, ERROR,)
Finalise a direct linear solver for a linear solver and deallocate all memory.
subroutine solver_geometrictransformationfinalise(geometricTransformationSolver, err, error,)
Finalise a geometric transformation solver for a solver.
subroutine, public petsc_tscreate(communicator, ts, err, error,)
Buffer routine to the PETSc TSCreate routine.
subroutine solver_quasinewtonmatriceslibrarytypeget(QUASI_NEWTON_SOLVER, MATRICES_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for a Quasi-Newton solver matrices.
subroutine solver_eigenproblem_library_type_get(EIGENPROBLEM_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for an eigenproblem solver.
subroutine solver_nonlinear_create_finish(NONLINEAR_SOLVER, ERR, ERROR,)
Finishes the process of creating a nonlinear solver.
integer(intg), parameter, public solver_iterative_no_preconditioner
No preconditioner type.
integer(intg), parameter, public solver_iterative_chebyshev
Chebyshev iterative solver type.
subroutine, public solver_newton_trustregion_tolerance_set(SOLVER, TRUSTREGION_TOLERANCE, ERR, ERROR,)
Sets/changes the trust region tolerance for a nonlinear Newton trust region solver.
subroutine, public solver_equations_destroy(SOLVER_EQUATIONS, ERR, ERROR,)
Destroys the solver equations.
integer(intg), parameter, public solver_dynamic_third_degree_liniger1_scheme
1st 3rd degree Liniger dynamic solver
subroutine, public petsc_vecgetvalues(x, n, indices, values, err, error,)
Buffer routine to the PETSc VecGetValues routine.
subroutine solver_linear_direct_library_type_get(DIRECT_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for a direct linear solver.
subroutine, public solver_newtonconvergencetesttypeset(solver, convergenceTestType, err, error,)
Sets/changes the convergence test for a Newton nonlinear solver.
subroutine solver_matrices_library_type_get(SOLVER, MATRICES_LIBRARY_TYPE, ERR, ERROR,)
Gets the type of library to use for the solver matrices.
subroutine, public petsc_tssolve(ts, x, finalTime, err, error,)
Buffer routine to the PETSc TSSolve routine.
Contains information for an improved Euler differential-algebraic equation solver.
subroutine solver_cellml_evaluator_solve(CELLML_EVALUATOR_SOLVER, ERR, ERROR,)
Solve a CellML evaluator solver.
Contains information about the solver equations for a solver.
subroutine solver_dae_rush_larson_finalise(RUSH_LARSON_SOLVER, ERR, ERROR,)
Finalise a Rush-Larson differential-algebraic equation solver and deallocate all memory.
integer(intg), parameter, public solver_mumps_library
MUMPS solver library.
subroutine solver_quasinewtonlinesearchfinalise(linesearchSolver, err, error,)
Finalise a nonlinear Quasi-Newton line search solver and deallocate all memory.
subroutine, public solver_quasi_newton_restart_set(SOLVER, RESTART, ERR, ERROR,)
Sets/changes the restart of nonlinear Quasi-Newton solver.
subroutine solver_nonlinear_initialise(SOLVER, ERR, ERROR,)
Initialise a nonlinear solver for a solver.
subroutine, public solver_dynamic_times_set(SOLVER, CURRENT_TIME, TIME_INCREMENT, ERR, ERROR,)
Sets/changes the dynamic times for a dynamic solver.
subroutine solver_dae_euler_forward_initialise(EULER_DAE_SOLVER, ERR, ERROR,)
Initialise a forward Euler solver for a differential-algebraic equation solver.
subroutine, public solver_newton_cellml_evaluator_create(SOLVER, CELLML_SOLVER, ERR, ERROR,)
Create a CellML evaluator solver for the Newton solver.
subroutine, public solver_geometrictransformationnumberofloadincrementsset(solver, numberOfIncrements, err, error,)
Set the number of load increments for geometric transformation solver.
subroutine solver_linear_direct_lu_finalise(DIRECT_SOLVER, ERR, ERROR,)
Finalise a LU direct linear solver and deallocate all memory.
subroutine, public solver_time_stepping_monitor(DAE_SOLVER, STEPS, TIME, ERR, ERROR,)
Monitors the differential-algebraic equations solve.
subroutine solver_dae_euler_backward_finalise(BACKWARD_EULER_SOLVER, ERR, ERROR,)
Finalise a backward Euler differential-algebraic equation and deallocate all memory.
integer(intg), parameter, public solver_quasi_newton_trustregion
Quasi-Newton trust region nonlinear solver type.
integer(intg), parameter, public solver_dynamic_second_degree_liniger2_scheme
2nd 2nd degree Liniger dynamic solver
subroutine solver_dae_euler_solve(EULER_SOLVER, ERR, ERROR,)
Solve using an Euler differential-algebraic equation solver.
integer(intg), parameter, public solver_progress_output
Progress output from solver routines.
subroutine solver_dae_euler_backward_solve(BACKWARD_EULER_SOLVER, ERR, ERROR,)
Solve using a backward Euler differential-algebraic equation solver.
subroutine, public petsc_tssundialssettolerance(ts, absTol, relTol, err, error,)
Buffer routine to the PETSc TSSundialsSetTolerance routine.
integer(intg), parameter, public solver_nonlinear_newton
Newton nonlinear solver type.
subroutine, public petsc_tssundialssettype(ts, sundialsType, err, error,)
Buffer routine to the PETSc TSSundialsSetType routine.
subroutine solver_dynamic_library_type_set(DYNAMIC_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Sets/changes the type of library to use for a dynamic solver.
integer(intg), parameter library_spooles_type
SPOOLES library type.
subroutine, public solverequations_matrixget(solverEquations, matrixIndex, matrix, err, error,)
Get a solver matrix from the solver equations matrices.
integer(intg), parameter, public solver_iterative_biconjugate_gradient
Bi-conjugate gradient iterative solver type.
subroutine, public solver_quasi_newton_trustregion_delta0_set(SOLVER, TRUSTREGION_DELTA0, ERR, ERROR,)
Sets/changes the trust region delta0 for a nonlinear Quasi-Newton trust region solver solver...
Contains information for a dynamic solver.
subroutine, public solver_lineariterativemaximumiterationsset(SOLVER, MAXIMUM_ITERATIONS, ERR, ERROR,)
Sets/changes the maximum number of iterations for an iterative linear solver.
integer(intg), parameter, public solver_no_output
No output from the solver routines.
subroutine solver_linear_direct_create_finish(LINEAR_DIRECT_SOLVER, ERR, ERROR,)
Finishes the process of creating a linear direct solver.
subroutine, public solver_variables_dynamic_nonlinear_update(SOLVER, ERR, ERROR,)
Update the field values form the dynamic factor * current solver values AND add in mean predicted dis...
integer(intg), parameter, public solver_quasi_newton_linesearch_l2
Secant line search over the L2 norm of the function.
integer(intg), parameter, public solver_dynamic_linear
Dynamic solver has linear terms.
logical, save, public diagnostics1
.TRUE. if level 1 diagnostic output is active in the current routine
subroutine, public solver_dae_solver_type_set(SOLVER, DAE_SOLVE_TYPE, ERR, ERROR,)
Sets/changes the solve type for an differential-algebraic equation solver.
This module handles all distributed matrix vector routines.
subroutine solver_linear_direct_svd_initialise(DIRECT_SOLVER, ERR, ERROR,)
Initialise a SVD direct linear solver for a direct linear solver.
This module defines all constants shared across interface condition routines.
subroutine, public solver_quasi_newton_solve_type_set(SOLVER, QUASI_NEWTON_SOLVE_TYPE, ERR, ERROR,)
Sets/changes the solve type of nonlinear Quasi-Newton solver.
Contains information for an backward Euler differential-algebraic equation solver.
subroutine, public solver_quasi_newton_linear_solver_get(SOLVER, LINEAR_SOLVER, ERR, ERROR,)
Returns the linear solver associated with a Quasi-Newton solver.
subroutine, public solver_variablesdynamicfieldpreviousvaluesupdate(SOLVER, ERR, ERROR,)
Updates the previous values from the solver solution for dynamic solvers.
This module handles all boundary conditions routines.
Contains information on the models field for a CellML environment.
integer(intg), parameter, public solver_dynamic_hilbert_hughes_taylor2_scheme
1st Hilbert-Hughes-Taylor dynamic solver
This module handles all solver routines.
integer(intg), parameter, public solver_dynamic_bossak_newmark1_scheme
1st Bossak-Newmark dynamic solver
This module is a OpenCMISS(cm) buffer module to OpenCMISS(cellml).
subroutine solver_nonlinear_library_type_set(NONLINEAR_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Sets/changes the type of library to use for a nonlinear solver.
Contains information about an equations matrix.
integer(intg), parameter, public solver_nonlinear_bfgs_inverse
BFGS inverse nonlinear solver type.
recursive subroutine solver_finalise(SOLVER, ERR, ERROR,)
Finalises a solver and deallocates all memory.
subroutine solver_eigenproblem_initialise(SOLVER, ERR, ERROR,)
Initialise a eigenproblem solver for a solver.
subroutine solver_dae_finalise(DAE_SOLVER, ERR, ERROR,)
Finalise a differential-algebraic equation solver and deallocate all memory.
subroutine, public solver_linked_solver_add(SOLVER, SOLVER_TO_LINK, SOLV_TYPE, ERR, ERROR,)
Adds a linked solver to the solver. Also sets the solver type for the linked solver, als well as its linking solver.
subroutine solver_quasinewtonlinesearchcreatefinish(LINESEARCH_SOLVER, ERR, ERROR,)
Finishes the process of creating nonlinear Quasi-Newton line search solver.
subroutine, public solver_dynamic_restart_set(SOLVER, RESTART, ERR, ERROR,)
Sets/changes the restart value for a dynamic solver.
subroutine, public distributed_vector_data_type_set(DISTRIBUTED_VECTOR, DATA_TYPE, ERR, ERROR,)
Sets/changes the data type of a distributed vector.
subroutine, public petsc_tssetproblemtype(ts, probType, err, error,)
Buffer routine to the PETSc TSSetProblemType routine.
subroutine, public solvers_destroy(SOLVERS, ERR, ERROR,)
Destroys the solvers.
subroutine solver_linear_solve(LINEAR_SOLVER, ERR, ERROR,)
Solve a linear solver.
Contains information for a BDF differential-algebraic equation solver.
This module defines all constants shared across interface matrices routines.
subroutine solver_dae_crank_nicolson_finalise(CRANK_NICOLSON_SOLVER, ERR, ERROR,)
Finalise a Crank-Nicolson differential-algebraic equation solver and deallocate all memory...
integer(intg), parameter, public solver_quasi_newton_scale_none
Don't scale the problem.
integer(intg), parameter, public distributed_matrix_block_storage_type
Distributed matrix block storage type.
subroutine solver_cellml_evaluator_initialise(SOLVER, ERR, ERROR,)
Initialise a CellML evaluator solver for a solver.
integer(intg), parameter, public solver_dynamic_wilson_scheme
Wilson dynamic solver.
integer(intg), parameter, public solver_newton_linesearch_nonorms
No norms line search for Newton line search nonlinear solves.
integer(intg), parameter library_lapack_type
LAPACK library type.
subroutine, public solver_geometrictransformationclear(solver, err, error,)
Clear transformation for a geometric transformation solver.
subroutine, public petsc_vecassemblyend(x, err, error,)
Buffer routine to the PETSc VecAssemblyEnd routine.
subroutine solver_dae_runge_kutta_finalise(RUNGE_KUTTA_SOLVER, ERR, ERROR,)
Finalise a Runge-Kutta differential-algebraic equation solver and deallocate all memory.
subroutine solver_label_get_vs(SOLVER, LABEL, ERR, ERROR,)
Returns the label of a solver.
subroutine cellml_equations_finalise(CELLML_EQUATIONS, ERR, ERROR,)
Finalises the CellML equations and deallocates all memory.
integer(intg), parameter, public solver_dynamic_third_degree_gear_scheme
3rd degree Gear dynamic solver
subroutine solver_dae_euler_library_type_set(EULER_DAE_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Sets/changes the type of library to use for an Euler differential-algebraic equation solver...
A buffer type to allow for an array of pointers to a CELLML_TYPE.
integer(intg), parameter, public diagnostic_output_type
Diagnostic output type.
subroutine, public solver_geometrictransformationarbitrarypathset(solver, arbitraryPath, err, error,)
Set the arbitrary path logical for geometric transformation solver.
Contains information on the solver mapping between the global equation sets and the solver matrices...
subroutine solver_geometrictransformationinitialise(solver, err, error,)
Initialise a geometric transformation solver for a solver.
integer(intg), parameter, public solver_number_of_solver_types
Number of different solver types possible.
subroutine solver_linear_direct_cholesky_initialise(DIRECT_SOLVER, ERR, ERROR,)
Initialise a Cholesky direct linear solver for a direct linear solver.
subroutine solver_eigenproblem_solve(EIGENPROBLEM_SOLVER, ERR, ERROR,)
Solve a eigenproblem solver.
subroutine solver_dae_adams_moulton_solve(ADAMS_MOULTON_SOLVER, ERR, ERROR,)
Solve using an Adams-Moulton differential-algebraic equation solver.
subroutine, public solver_dynamic_scheme_set(SOLVER, SCHEME, ERR, ERROR,)
Sets/changes the scheme for a dynamic solver.
subroutine solver_linear_iterative_finalise(LINEAR_ITERATIVE_SOLVER, ERR, ERROR,)
Finalise an iterative linear solver for a linear solver and deallocate all memory.
subroutine solver_dae_runge_kutta_solve(RUNGE_KUTTA_SOLVER, ERR, ERROR,)
Solve using a Runge-Kutta differential-algebraic equation solver.
integer(intg), parameter, public solver_dae_adams_moulton
Adams-Moulton differential-algebraic equation solver.
subroutine solver_dae_euler_finalise(EULER_SOLVER, ERR, ERROR,)
Finalise an Euler differential-algebraic equation solver and deallocate all memory.
subroutine solver_label_get_c(SOLVER, LABEL, ERR, ERROR,)
Returns the label of a solver.
subroutine solver_linear_create_finish(LINEAR_SOLVER, ERR, ERROR,)
Finishes the process of creating a linear solver.
subroutine solver_optimiser_create_finish(OPTIMISER_SOLVER, ERR, ERROR,)
Finishes the process of creating an optimiser solver.
integer(intg), parameter, public solver_dynamic_newmark1_scheme
1st Newmark dynamic solver
integer(intg), parameter, public solver_quasi_newton_goodbroyden
"Good" Broyden Quasi-Newton type
Contains information on the solver matrices and rhs vector.
subroutine, public solver_dae_solver_type_get(SOLVER, DAE_SOLVE_TYPE, ERR, ERROR,)
Returns the solve type for an differential-algebraic equation solver.
Contains information for a field variable defined on a field.
subroutine, public cellml_equations_create_finish(CELLML_EQUATIONS, ERR, ERROR,)
Finishes the process of creating CellML equations.
integer(intg), parameter, public solver_dynamic_nonlinear
Dynamic solver has nonlinear terms.
subroutine solver_dae_library_type_set(DAE_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Sets/changes the type of library to use for a differential-algebraic equation solver.
subroutine, public solver_linked_solver_remove(SOLVER, SOLV_TYPE, ERR, ERROR,)
Adds a linked solver to the solver. Also sets the solver type for the linked solver, als well as its linking solver.
subroutine solver_linear_finalise(LINEAR_SOLVER, ERR, ERROR,)
Finalise a linear solver for a solver.
subroutine solver_quasi_newton_trustregion_solve(TRUSTREGION_SOLVER, ERR, ERROR,)
integer(intg), parameter, public solver_newton_linesearch_quadratic
Quadratic search for Newton line search nonlinear solves.
subroutine, public solver_quasi_newton_restart_type_set(SOLVER, QUASI_NEWTON_RESTART_TYPE, ERR, ERROR,)
Sets/changes the restart type of nonlinear Quasi-Newton solver.
subroutine, public solver_quasi_newton_solution_tolerance_set(SOLVER, SOLUTION_TOLERANCE, ERR, ERROR,)
Sets/changes the solution tolerance for a nonlinear Quasi-Newton solver.
subroutine, public petsc_vecassemblybegin(x, err, error,)
Buffer routine to the PETSc VecAssemblyBegin routine.
This type is a wrapper for the C_PTR which references the actual CellML model definition object...
integer(intg), parameter, public solver_quasi_newton_badbroyden
"Bad" Broyden Quasi-Newton type
subroutine, public solver_newtonlinesearchmonitoroutputset(solver, linesearchMonitorOutputFlag, err, error,)
Enables/disables output monitoring for a nonlinear Newton line search solver.
subroutine solver_optimiser_matrices_library_type_get(OPTIMISER_SOLVER, MATRICES_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for an optimiser solver matrices.
integer(intg), parameter, public solver_dae_external
External (e.g., CellML generated) differential-algebraic equation solver.
integer(intg), parameter, public solver_newton_linesearch_linear
Linear search for Newton line search nonlinear solves.
subroutine, public solver_quasi_newton_absolute_tolerance_set(SOLVER, ABSOLUTE_TOLERANCE, ERR, ERROR,)
Sets/changes the maximum absolute tolerance for a nonlinear Quasi-Newton solver.
integer(intg), parameter, public solver_dynamic_third_degree_liniger2_scheme
2nd 3rd degree Liniger dynamic solver
subroutine solver_daecellmlpetsccontextfinalise(ctx, err, error,)
Finalise a CellML PETSc solver context.
subroutine, public solver_equations_time_dependence_type_set(SOLVER_EQUATIONS, TIME_DEPENDENCE_TYPE, ERR, ERROR,)
Sets/changes the time dependence type for solver equations.
subroutine, public solver_variables_dynamic_field_update(SOLVER, ERR, ERROR,)
Updates the dependent variables from the solver solution for dynamic solvers.
integer(intg), parameter, public solver_direct_cholesky
Cholesky direct linear solver.
integer(intg), parameter, public solver_cmiss_library
CMISS (internal) solver library.
subroutine solver_nonlinear_solve(NONLINEAR_SOLVER, ERR, ERROR,)
subroutine solver_linear_matrices_library_type_get(LINEAR_SOLVER, MATRICES_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for a linear solver matrices.
subroutine solver_cellml_evaluator_create_finish(CELLML_EVALUATOR_SOLVER, ERR, ERROR,)
Finishes the process of creating a CellML evaluator solver.
Contains information for an differential-algebraic equation solver.
This module defines all constants shared across equations set routines.
integer(intg), parameter, public solver_eigenproblem_type
A eigenproblem solver.
subroutine solver_linear_library_type_get(LINEAR_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for a linear solver.
integer(intg), parameter, public solver_nonlinear_sqp
Sequential Quadratic Program nonlinear solver type.
subroutine solver_linear_direct_svd_finalise(LINEAR_DIRECT_SOLVER, ERR, ERROR,)
Finalise a SVD direct linear solver and deallocate all memory.
subroutine, public solver_solver_equations_get(SOLVER, SOLVER_EQUATIONS, ERR, ERROR,)
Returns a pointer to the solver equations for a solver.
integer(intg), parameter, public solver_iterative_richardson
Richardson iterative solver type.
integer(intg), parameter, public distributed_matrix_vector_dp_type
Double precision real distributed matrix-vector data type.
subroutine, public solver_linear_iterative_type_set(SOLVER, ITERATIVE_SOLVER_TYPE, ERR, ERROR,)
Sets/changes the type of iterative linear solver.
integer(intg), parameter, public solver_matrix_output
Solver matrices output from the solver routines plus below.
integer(intg), parameter library_superlu_type
SuperLU library type.
subroutine solver_linear_direct_lu_initialise(DIRECT_SOLVER, ERR, ERROR,)
Initialise a LU direct linear solver for a direct linear solver.
integer(intg), parameter, public solver_umfpack_library
UMFPACK solver library.
subroutine, public solver_matrices_static_assemble(SOLVER, SELECTION_TYPE, ERR, ERROR,)
Assembles the solver matrices and rhs from the static equations.
integer(intg), parameter, public solver_dynamic_galerkin_scheme
Galerkin dynamic solver.
subroutine solver_quasi_newton_initialise(NONLINEAR_SOLVER, ERR, ERROR,)
Initialise a Quasi-Newton solver for a nonlinear solver.
subroutine, public solver_newton_linesearch_alpha_set(SOLVER, LINESEARCH_ALPHA, ERR, ERROR,)
Sets/changes the line search alpha for a Newton linesearch solver.
subroutine, public solver_quasinewtontrustregiontoleranceset(SOLVER, TRUSTREGION_TOLERANCE, ERR, ERROR,)
Sets/changes the trust region tolerance for a nonlinear Quasi-Newton trust region solver...
subroutine, public solverequations_boundaryconditionscreatefinish(SOLVER_EQUATIONS, ERR, ERROR,)
Finishes the creation of boundary conditions for the given solver equations.
integer(intg), parameter, public solver_dynamic_first_degree
Dynamic solver uses a first degree polynomial for time interpolation.
subroutine solver_linear_iterative_solve(LINEAR_ITERATIVE_SOLVER, ERR, ERROR,)
Solves a linear iterative linear solver.
subroutine solver_dae_solve(DAE_SOLVER, ERR, ERROR,)
Solve a differential-algebraic equation solver.
subroutine, public solverequations_jacobianmatrixget(solverEquations, matrix, err, error,)
Get the Jacobian matrix from the solver equations matrices for nonlinear solver equations.
integer(intg), parameter solver_state_iteration_type
An state iteration solver.
subroutine solver_quasi_newton_trustregion_initialise(QUASI_NEWTON_SOLVER, ERR, ERROR,)
Initialise a Quaso-Newton trust region solver for a nonlinear solver.
integer(intg), parameter, public solver_newton_jacobian_fd_calculated
The Jacobian values will be calculated using finite differences for the nonlinear equations set...
subroutine, public solver_newton_type_set(SOLVER, NEWTON_SOLVE_TYPE, ERR, ERROR,)
Sets/changes the type of nonlinear Newton solver.
subroutine, public solverequations_boundaryconditionscreatestart(SOLVER_EQUATIONS, BOUNDARY_CONDITIONS, ERR, ERROR,)
Starts the creation of boundary conditions for the given solver equations, and returns a pointer to t...
subroutine, public petsc_veccreateseq(communicator, n, x, err, error,)
Buffer routine to the PETSc VecCreateSeq routine.
subroutine solver_newton_trustregion_finalise(TRUSTREGION_SOLVER, ERR, ERROR,)
Finalise a nonlinear Newton trust region solver and deallocate all memory.
integer(intg), parameter, public solver_solver_output
Solver specific output from the solver routines plus below.
subroutine, public solver_newton_maximum_iterations_set(SOLVER, MAXIMUM_ITERATIONS, ERR, ERROR,)
Sets/changes the maximum number of iterations for a nonlinear Newton solver.
integer(intg), parameter, public solver_dynamic_newmark2_scheme
2nd Newmark dynamic solver
subroutine, public solver_quasi_newton_scale_type_set(SOLVER, QUASI_NEWTON_SCALE_TYPE, ERR, ERROR,)
Sets/changes the scale type of nonlinear Quasi-Newton solver.
integer(intg), parameter, public solver_dynamic_hilbert_hughes_taylor1_scheme
1st Hilbert-Hughes-Taylor dynamic solver
subroutine, public solver_equations_interface_condition_add(SOLVER_EQUATIONS, INTERFACE_CONDITION, INTERFACE_CONDITION_INDEX, ERR, ERROR,)
Adds an interface condition to the solver equations.
subroutine, public solver_dae_times_set(SOLVER, START_TIME, END_TIME, ERR, ERROR,)
Set/change the times for a differential-algebraic equation solver.
Flags an error condition.
subroutine, public solver_quasi_newton_maximum_iterations_set(SOLVER, MAXIMUM_ITERATIONS, ERR, ERROR,)
Sets/changes the maximum number of iterations for a nonlinear Quasi-Newton solver.
integer(intg), parameter, public solver_linear_type
A linear solver.
integer(intg), parameter library_pastix_type
PaStiX library type.
subroutine solver_dae_initialise(SOLVER, ERR, ERROR,)
Initialise a differential-algebraic equation solver for a solver.
subroutine solver_quasinewtontrustregioncreatefinish(TRUSTREGION_SOLVER, ERR, ERROR,)
Finishes the process of creating nonlinear Quasi-Newton trust region solver.
integer(intg), parameter, public solver_newton_convergence_energy_norm
Energy norm convergence test.
subroutine solver_cellml_evaluator_time_set(CELLML_EVALUATOR_SOLVER, TIME, ERR, ERROR,)
Sets/changes the time for a CellML evaluator solver.
subroutine, public petsc_tssettype(ts, method, err, error,)
Buffer routine to the PETSc TSSetType routine.
subroutine solver_cellml_evaluator_library_type_get(CELLML_EVALUATOR_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Returns the type of library to use for a CellML evaluator solver.
subroutine solver_linear_library_type_set(LINEAR_SOLVER, SOLVER_LIBRARY_TYPE, ERR, ERROR,)
Sets/changes the type of library to use for a linear solver.
real(dp), parameter zero_tolerance
subroutine solver_eigenproblem_finalise(EIGENPROBLEM_SOLVER, ERR, ERROR,)
Finalise a eigenproblem solver for a solver.
integer(intg), parameter, public solver_quasi_newton_restart_periodic
Restart after a fixed number of iterations.
subroutine solver_cellml_evaluate(CELLML_EVALUATOR_SOLVER, CELLML, N, ONLY_ONE_MODEL_INDEX, MODELS_DATA, MAX_NUMBER_STATES, STATE_DATA, MAX_NUMBER_PARAMETERS, PARAMETERS_DATA, MAX_NUMBER_INTERMEDIATES, INTERMEDIATE_DATA, ERR, ERROR,)
Evaluate the CellML equations.
recursive subroutine, public solver_solve(SOLVER, ERR, ERROR,)
Solve the problem.
integer(intg), parameter, public distributed_matrix_diagonal_storage_type
Distributed matrix diagonal storage type.
Contains information for a Rush-Larson differential-algebraic equation solver.
Contains information for a CellML environment.
integer(intg), parameter library_tao_type
TAO library type.
Contains information for mapping field variables to the linear matrices in the equations set of the m...
subroutine, public solver_matrices_library_type_set(SOLVER_MATRICES, LIBRARY_TYPE, ERR, ERROR,)
Sets the library type for the solver matrices (and vectors)
integer(intg), parameter, public solver_lapack_library
LAPACK solver library.
This module contains all kind definitions.
subroutine, public solver_dynamic_ale_set(SOLVER, ALE, ERR, ERROR,)
Sets/changes the ALE flag for a dynamic solver.
integer(intg), parameter, public distributed_matrix_compressed_row_storage_type
Distributed matrix compressed row storage type.
subroutine solver_quasi_newton_linesearch_solve(LINESEARCH_SOLVER, ERR, ERROR,)
integer(intg), parameter, public solver_dae_crank_nicolson
Crank-Nicolson differential-algebraic equation solver.
integer(intg), parameter, public solver_dynamic_second_degree
Dynamic solver uses a second degree polynomial for time interpolation.
subroutine solver_dae_create_finish(DAE_SOLVER, ERR, ERROR,)
Finishes the process of creating a differential-algebraic equation solver.
Contains information of the dynamic matrices for equations matrices.
integer(intg), parameter, public solver_optimiser_type
An optimiser solver.
subroutine, public solver_newton_absolute_tolerance_set(SOLVER, ABSOLUTE_TOLERANCE, ERR, ERROR,)
Sets/changes the maximum absolute tolerance for a nonlinear Newton solver.
subroutine, public solver_quasi_newton_linesearch_steptol_set(SOLVER, LINESEARCH_STEPTOL, ERR, ERROR,)
Sets/changes the line search step tolerance for a nonlinear Quasi-Newton line search solver...
integer(intg), parameter, public solver_dae_runge_kutta
Runge-Kutta differential-algebraic equation solver.