45 MODULE problem_routines
62 USE interface_conditions_routines
63 USE interface_routines
91 INTERFACE problem_cellml_equations_get
92 MODULE PROCEDURE problem_cellml_equations_get_0
93 MODULE PROCEDURE problem_cellml_equations_get_1
96 INTERFACE problem_control_loop_get
97 MODULE PROCEDURE problem_control_loop_get_0
98 MODULE PROCEDURE problem_control_loop_get_1
101 INTERFACE problem_solver_equations_get
102 MODULE PROCEDURE problem_solver_equations_get_0
103 MODULE PROCEDURE problem_solver_equations_get_1
106 INTERFACE problem_solver_get
107 MODULE PROCEDURE problem_solver_get_0
108 MODULE PROCEDURE problem_solver_get_1
111 PUBLIC problems_initialise,problems_finalise
113 PUBLIC problem_cellml_equations_create_start,problem_cellml_equations_create_finish
115 PUBLIC problem_cellml_equations_get
117 PUBLIC problem_create_start,problem_create_finish,problem_destroy
119 PUBLIC problem_specificationget,problem_specificationsizeget
121 PUBLIC problem_control_loop_create_start,problem_control_loop_create_finish
123 PUBLIC problem_control_loop_destroy
125 PUBLIC problem_control_loop_get
127 PUBLIC problem_solverdaecellmlrhsevaluate
129 PUBLIC problem_solverequationsboundaryconditionsanalytic
131 PUBLIC problem_solver_equations_create_start,problem_solver_equations_create_finish
133 PUBLIC problem_solver_equations_destroy
135 PUBLIC problem_solver_equations_get
137 PUBLIC problem_solver_jacobian_evaluate,problem_solver_residual_evaluate
139 PUBLIC problem_solver_get
141 PUBLIC problem_solvernonlinearmonitor
145 PUBLIC problem_solvers_create_start,problem_solvers_create_finish
147 PUBLIC problem_solvers_destroy
149 PUBLIC problem_user_number_find
158 SUBROUTINE problem_cellml_equations_create_finish(PROBLEM,ERR,ERROR,*)
162 INTEGER(INTG),
INTENT(OUT) :: err
167 enters(
"PROBLEM_CELLML_EQUATIONS_CREATE_FINISH",err,error,*999)
169 IF(
ASSOCIATED(problem))
THEN 171 CALL problem_setup_initialise(problem_setup_info,err,error,*999)
175 CALL problem_setup(problem,problem_setup_info,err,error,*999)
177 CALL problem_setup_finalise(problem_setup_info,err,error,*999)
179 CALL flagerror(
"Problem is not associated.",err,error,*999)
182 exits(
"PROBLEM_CELLML_EQUATIONS_CREATE_FINISH")
184 999 errorsexits(
"PROBLEM_CELLML_EQUATIONS_CREATE_FINISH",err,error)
186 END SUBROUTINE problem_cellml_equations_create_finish
193 SUBROUTINE problem_cellml_equations_create_start(PROBLEM,ERR,ERROR,*)
197 INTEGER(INTG),
INTENT(OUT) :: err
202 enters(
"PROBLEM_CELLML_EQUATIONS_CREATE_START",err,error,*999)
204 IF(
ASSOCIATED(problem))
THEN 206 CALL problem_setup_initialise(problem_setup_info,err,error,*999)
210 CALL problem_setup(problem,problem_setup_info,err,error,*999)
212 CALL problem_setup_finalise(problem_setup_info,err,error,*999)
214 CALL flagerror(
"Problem is not associated.",err,error,*999)
217 exits(
"PROBLEM_CELLML_EQUATIONS_CREATE_START")
219 999 errorsexits(
"PROBLEM_CELLML_EQUATIONS_CREATE_START",err,error)
221 END SUBROUTINE problem_cellml_equations_create_start
228 SUBROUTINE problem_cellml_equations_get_0(PROBLEM,CONTROL_LOOP_IDENTIFIER,SOLVER_INDEX,CELLML_EQUATIONS,ERR,ERROR,*)
232 INTEGER(INTG),
INTENT(IN) :: control_loop_identifier
233 INTEGER(INTG),
INTENT(IN) :: solver_index
235 INTEGER(INTG),
INTENT(OUT) :: err
239 enters(
"PROBLEM_CELLML_EQUATIONS_GET_0",err,error,*999)
241 CALL problem_cellml_equations_get_1(problem,[control_loop_identifier],solver_index,cellml_equations,err,error,*999)
243 exits(
"PROBLEM_CELLML_EQUATIONS_GET_0")
245 999 errorsexits(
"PROBLEM_CELLML_EQUATIONS_GET_0",err,error)
247 END SUBROUTINE problem_cellml_equations_get_0
254 SUBROUTINE problem_cellml_equations_get_1(PROBLEM,CONTROL_LOOP_IDENTIFIER,SOLVER_INDEX,CELLML_EQUATIONS,ERR,ERROR,*)
258 INTEGER(INTG),
INTENT(IN) :: control_loop_identifier(:)
259 INTEGER(INTG),
INTENT(IN) :: solver_index
261 INTEGER(INTG),
INTENT(OUT) :: err
269 enters(
"PROBLEM_CELLML_EQUATIONS_GET_1",err,error,*999)
271 IF(
ASSOCIATED(problem))
THEN 272 IF(
ASSOCIATED(cellml_equations))
THEN 273 CALL flagerror(
"The CellML equations is already associated.",err,error,*999)
275 NULLIFY(cellml_equations)
276 control_loop_root=>problem%CONTROL_LOOP
277 IF(
ASSOCIATED(control_loop_root))
THEN 278 NULLIFY(control_loop)
279 CALL control_loop_get(control_loop_root,control_loop_identifier,control_loop,err,error,*999)
280 solvers=>control_loop%SOLVERS
281 IF(
ASSOCIATED(solvers))
THEN 282 IF(solver_index>0.AND.solver_index<=solvers%NUMBER_OF_SOLVERS)
THEN 283 solver=>solvers%SOLVERS(solver_index)%PTR
284 IF(
ASSOCIATED(solver))
THEN 285 cellml_equations=>solver%CELLML_EQUATIONS
286 IF(.NOT.
ASSOCIATED(cellml_equations))
CALL flagerror(
"CellML equations is not associated.",err,error,*999)
288 CALL flagerror(
"Solver is not associated.",err,error,*999)
291 local_error=
"The specified solver index of "//
trim(
number_to_vstring(solver_index,
"*",err,error))// &
292 &
" is invalid. The index must be > 0 and <= "// &
294 CALL flagerror(local_error,err,error,*999)
297 CALL flagerror(
"Solvers is not associated.",err,error,*999)
300 CALL flagerror(
"Problem control loop is not associated.",err,error,*999)
304 CALL flagerror(
"Problem is not associated.",err,error,*999)
307 exits(
"PROBLEM_CELLML_EQUATIONS_GET_1")
309 999 errorsexits(
"PROBLEM_CELLML_EQUATIONS_GET_1",err,error)
311 END SUBROUTINE problem_cellml_equations_get_1
318 SUBROUTINE problem_cellml_equations_solve(CELLML_EQUATIONS,ERR,ERROR,*)
322 INTEGER(INTG),
INTENT(OUT) :: err
327 enters(
"PROBLEM_CELLML_EQUATIONS_SOLVE",err,error,*999)
329 IF(
ASSOCIATED(cellml_equations))
THEN 330 IF(cellml_equations%CELLML_EQUATIONS_FINISHED)
THEN 331 solver=>cellml_equations%SOLVER
332 IF(
ASSOCIATED(solver))
THEN 337 CALL flagerror(
"CellML equations solver is not associated.",err,error,*999)
340 CALL flagerror(
"CellML equations have not been finished.",err,error,*999)
343 CALL flagerror(
"CellML equations is not associated.",err,error,*999)
346 exits(
"PROBLEM_CELLML_EQUATIONS_SOLVE")
348 999 errorsexits(
"PROBLEM_CELLML_EQUATIONS_SOLVE",err,error)
351 END SUBROUTINE problem_cellml_equations_solve
358 SUBROUTINE problem_solverdaecellmlrhsevaluate(cellML,time,dofIdx,stateData,rateData,err,error,*)
362 REAL(DP),
INTENT(IN) :: time
363 INTEGER(INTG),
INTENT(IN) :: dofidx
364 REAL(DP),
POINTER :: statedata(:)
365 REAL(DP),
POINTER :: ratedata(:)
366 INTEGER(INTG),
INTENT(OUT) :: err
369 INTEGER(INTG) :: dofordertype,intermediatedataoffset,maxnumberofintermediates,maxnumberofparameters,maxnumberofstates, &
370 modelidx,parameterdataoffset
371 INTEGER(INTG),
POINTER :: modelsdata(:)
372 REAL(DP),
POINTER :: intermediatedata(:),parameterdata(:)
374 TYPE(
field_type),
POINTER :: intermediatefield,modelsfield,parametersfield
377 enters(
"Problem_SolverDAECellMLRHSEvaluate",err,error,*999)
379 IF(
ASSOCIATED(cellml))
THEN 380 maxnumberofstates=cellml%MAXIMUM_NUMBER_OF_STATE
381 maxnumberofintermediates=cellml%MAXIMUM_NUMBER_OF_INTERMEDIATE
382 maxnumberofparameters=cellml%MAXIMUM_NUMBER_OF_PARAMETERS
384 IF(
ASSOCIATED(cellml%MODELS_FIELD))
THEN 385 modelsfield=>cellml%MODELS_FIELD%MODELS_FIELD
386 IF(
ASSOCIATED(modelsfield))
THEN 387 NULLIFY(modelsvariable)
388 CALL field_variableget(modelsfield,field_u_variable_type,modelsvariable,err,error,*999)
389 CALL field_dofordertypeget(modelsfield,field_u_variable_type,dofordertype,err,error,*999)
390 CALL field_parametersetdataget(modelsfield,field_u_variable_type,field_values_set_type,modelsdata,err,error,*999)
391 modelidx=modelsdata(dofidx)
392 model=>cellml%models(modelidx)%ptr
393 IF(
ASSOCIATED(model))
THEN 394 IF(dofordertype==field_separated_component_dof_order)
THEN 395 parameterdataoffset=modelsvariable%TOTAL_NUMBER_OF_DOFS
396 intermediatedataoffset=modelsvariable%TOTAL_NUMBER_OF_DOFS
398 parameterdataoffset=maxnumberofparameters
399 intermediatedataoffset=maxnumberofintermediates
401 NULLIFY(parameterdata)
403 IF(
ASSOCIATED(cellml%PARAMETERS_FIELD))
THEN 404 parametersfield=>cellml%PARAMETERS_FIELD%PARAMETERS_FIELD
405 IF(
ASSOCIATED(parametersfield))
THEN 406 CALL field_parametersetdataget(parametersfield,field_u_variable_type,field_values_set_type,parameterdata, &
411 NULLIFY(intermediatedata)
412 IF(
ASSOCIATED(cellml%INTERMEDIATE_FIELD))
THEN 413 intermediatefield=>cellml%INTERMEDIATE_FIELD%INTERMEDIATE_FIELD
414 IF(
ASSOCIATED(intermediatefield))
THEN 415 CALL field_parametersetdataget(intermediatefield,field_u_variable_type,field_values_set_type,intermediatedata, &
422 intermediatedataoffset,intermediatedata,1,1,ratedata,err,error,*999)
425 CALL flagerror(
"Model is not associated.",err,error,*999)
428 CALL flagerror(
"Models field not associated.",err,error,*999)
431 CALL flagerror(
"CellML models field is not associated.",err,error,*999)
434 CALL flagerror(
"CellML is not associated.",err,error,*999)
437 exits(
"Problem_SolverDAECellMLRHSEvaluate")
439 999 errorsexits(
"Problem_SolverDAECellMLRHSEvaluate",err,error)
442 END SUBROUTINE problem_solverdaecellmlrhsevaluate
449 RECURSIVE SUBROUTINE problem_control_loop_solve(CONTROL_LOOP,ERR,ERROR,*)
452 TYPE(control_loop_type),
POINTER :: control_loop
453 INTEGER(INTG),
INTENT(OUT) :: err
454 TYPE(varying_string),
INTENT(OUT) :: error
456 INTEGER(INTG) :: iteration_idx,loop_idx,solver_idx
457 TYPE(control_loop_type),
POINTER :: control_loop2
458 TYPE(control_loop_fixed_type),
POINTER :: fixed_loop
459 TYPE(control_loop_simple_type),
POINTER :: simple_loop
460 TYPE(control_loop_time_type),
POINTER :: time_loop
461 TYPE(control_loop_while_type),
POINTER :: while_loop
462 TYPE(control_loop_load_increment_type),
POINTER :: load_increment_loop
463 TYPE(solver_type),
POINTER :: solver
464 TYPE(solvers_type),
POINTER :: solvers
465 TYPE(varying_string) :: local_error
467 enters(
"PROBLEM_CONTROL_LOOP_SOLVE",err,error,*999)
469 IF(
ASSOCIATED(control_loop))
THEN 470 IF(control_loop%CONTROL_LOOP_FINISHED)
THEN 472 IF(control_loop%OUTPUT_TYPE>=control_loop_progress_output)
THEN 473 CALL write_string(general_output_type,
"",err,error,*999)
474 CALL write_string_value(general_output_type,
"Control loop: ",control_loop%LABEL,err,error,*999)
475 CALL write_string_value(general_output_type,
" Control loop level = ",control_loop%CONTROL_LOOP_LEVEL,err,error,*999)
476 CALL write_string_value(general_output_type,
" Sub loop index = ",control_loop%SUB_LOOP_INDEX,err,error,*999)
478 SELECT CASE(control_loop%LOOP_TYPE)
479 CASE(problem_control_simple_type)
480 simple_loop=>control_loop%SIMPLE_LOOP
481 IF(
ASSOCIATED(simple_loop))
THEN 482 IF(control_loop%OUTPUT_TYPE>=control_loop_progress_output)
THEN 483 CALL write_string(general_output_type,
"",err,error,*999)
484 CALL write_string(general_output_type,
"Simple control loop: ",err,error,*999)
486 CALL problem_control_loop_pre_loop(control_loop,err,error,*999)
487 IF(control_loop%NUMBER_OF_SUB_LOOPS==0)
THEN 489 solvers=>control_loop%SOLVERS
490 IF(
ASSOCIATED(solvers))
THEN 491 DO solver_idx=1,solvers%NUMBER_OF_SOLVERS
492 solver=>solvers%SOLVERS(solver_idx)%PTR
494 CALL problem_solver_solve(solver,err,error,*999)
498 CALL flagerror(
"Control loop solvers is not associated.",err,error,*999)
502 DO loop_idx=1,control_loop%NUMBER_OF_SUB_LOOPS
503 control_loop2=>control_loop%SUB_LOOPS(loop_idx)%PTR
504 CALL problem_control_loop_solve(control_loop2,err,error,*999)
507 CALL problem_control_loop_post_loop(control_loop,err,error,*999)
509 CALL flagerror(
"Control loop simple loop is not associated.",err,error,*999)
511 CASE(problem_control_fixed_loop_type)
512 fixed_loop=>control_loop%FIXED_LOOP
513 IF(
ASSOCIATED(fixed_loop))
THEN 514 DO iteration_idx=fixed_loop%START_ITERATION,fixed_loop%STOP_ITERATION,fixed_loop%ITERATION_INCREMENT
515 IF(control_loop%OUTPUT_TYPE>=control_loop_progress_output)
THEN 516 CALL write_string(general_output_type,
"",err,error,*999)
517 CALL write_string_value(general_output_type,
"Fixed control loop iteration: ",iteration_idx,err,error,*999)
519 fixed_loop%ITERATION_NUMBER=iteration_idx
520 CALL problem_control_loop_pre_loop(control_loop,err,error,*999)
521 IF(control_loop%NUMBER_OF_SUB_LOOPS==0)
THEN 523 solvers=>control_loop%SOLVERS
524 IF(
ASSOCIATED(solvers))
THEN 525 DO solver_idx=1,solvers%NUMBER_OF_SOLVERS
526 solver=>solvers%SOLVERS(solver_idx)%PTR
528 CALL problem_solver_solve(solver,err,error,*999)
532 CALL flagerror(
"Control loop solvers is not associated.",err,error,*999)
536 DO loop_idx=1,control_loop%NUMBER_OF_SUB_LOOPS
537 control_loop2=>control_loop%SUB_LOOPS(loop_idx)%PTR
538 CALL problem_control_loop_solve(control_loop2,err,error,*999)
541 CALL problem_control_loop_post_loop(control_loop,err,error,*999)
544 CALL flagerror(
"Control loop fixed loop is not associated.",err,error,*999)
546 CASE(problem_control_time_loop_type)
547 time_loop=>control_loop%TIME_LOOP
548 IF(
ASSOCIATED(time_loop))
THEN 550 time_loop%CURRENT_TIME=time_loop%START_TIME
553 IF (time_loop%NUMBER_OF_ITERATIONS==0)
THEN 554 time_loop%NUMBER_OF_ITERATIONS=ceiling((time_loop%STOP_TIME-time_loop%START_TIME)/time_loop%TIME_INCREMENT)
556 ELSEIF (ceiling((time_loop%STOP_TIME-time_loop%START_TIME)/time_loop%TIME_INCREMENT) &
557 & /= time_loop%NUMBER_OF_ITERATIONS)
THEN 558 time_loop%TIME_INCREMENT = (time_loop%STOP_TIME-time_loop%START_TIME)/time_loop%NUMBER_OF_ITERATIONS
561 time_loop%ITERATION_NUMBER=0
562 DO WHILE(time_loop%ITERATION_NUMBER<time_loop%NUMBER_OF_ITERATIONS)
563 IF(control_loop%OUTPUT_TYPE>=control_loop_progress_output)
THEN 564 CALL write_string(general_output_type,
"",err,error,*999)
565 CALL write_string_value(general_output_type,
"Time control loop iteration: ",time_loop%ITERATION_NUMBER, &
567 CALL write_string_value(general_output_type,
" Total number of iterations: ",time_loop%NUMBER_OF_ITERATIONS, &
569 CALL write_string_value(general_output_type,
" Current time = ",time_loop%CURRENT_TIME, &
571 CALL write_string_value(general_output_type,
" Stop time = ",time_loop%STOP_TIME, &
573 CALL write_string_value(general_output_type,
" Time increment = ",time_loop%TIME_INCREMENT, &
577 CALL problem_control_loop_pre_loop(control_loop,err,error,*999)
578 IF(control_loop%NUMBER_OF_SUB_LOOPS==0)
THEN 580 solvers=>control_loop%SOLVERS
581 IF(
ASSOCIATED(solvers))
THEN 582 DO solver_idx=1,solvers%NUMBER_OF_SOLVERS
583 solver=>solvers%SOLVERS(solver_idx)%PTR
585 CALL problem_solver_solve(solver,err,error,*999)
589 CALL flagerror(
"Control loop solvers is not associated.",err,error,*999)
593 DO loop_idx=1,control_loop%NUMBER_OF_SUB_LOOPS
594 control_loop2=>control_loop%SUB_LOOPS(loop_idx)%PTR
595 CALL problem_control_loop_solve(control_loop2,err,error,*999)
599 CALL problem_control_loop_post_loop(control_loop,err,error,*999)
601 time_loop%ITERATION_NUMBER=time_loop%ITERATION_NUMBER+1
602 time_loop%GLOBAL_ITERATION_NUMBER=time_loop%GLOBAL_ITERATION_NUMBER+1
603 time_loop%CURRENT_TIME=time_loop%CURRENT_TIME+time_loop%TIME_INCREMENT
606 CALL flagerror(
"Control loop time loop is not associated.",err,error,*999)
608 CASE(problem_control_while_loop_type)
609 while_loop=>control_loop%WHILE_LOOP
610 IF(
ASSOCIATED(while_loop))
THEN 611 while_loop%ITERATION_NUMBER=0
612 while_loop%CONTINUE_LOOP=.true.
613 DO WHILE(while_loop%CONTINUE_LOOP.AND.while_loop%ITERATION_NUMBER &
614 & <while_loop%MAXIMUM_NUMBER_OF_ITERATIONS)
615 while_loop%ITERATION_NUMBER=while_loop%ITERATION_NUMBER+1
616 IF(control_loop%OUTPUT_TYPE>=control_loop_progress_output)
THEN 617 CALL write_string(general_output_type,
"",err,error,*999)
618 CALL write_string_value(general_output_type,
"While control loop iteration: ",while_loop%ITERATION_NUMBER, &
620 CALL write_string_value(general_output_type,
" Maximum number of iterations = ", &
621 & while_loop%MAXIMUM_NUMBER_OF_ITERATIONS,err,error,*999)
623 CALL problem_control_loop_pre_loop(control_loop,err,error,*999)
624 IF(control_loop%NUMBER_OF_SUB_LOOPS==0)
THEN 626 solvers=>control_loop%SOLVERS
627 IF(
ASSOCIATED(solvers))
THEN 628 DO solver_idx=1,solvers%NUMBER_OF_SOLVERS
629 solver=>solvers%SOLVERS(solver_idx)%PTR
630 IF(
ASSOCIATED(solver))
THEN 631 IF(
ASSOCIATED(solver%SOLVER_EQUATIONS))
THEN 632 CALL problem_solver_load_increment_apply(solver%SOLVER_EQUATIONS,1, &
635 CALL problem_solver_solve(solver,err,error,*999)
637 CALL flagerror(
"Solver is not associated.",err,error,*999)
641 CALL flagerror(
"Control loop solvers is not associated.",err,error,*999)
645 DO loop_idx=1,control_loop%NUMBER_OF_SUB_LOOPS
646 control_loop2=>control_loop%SUB_LOOPS(loop_idx)%PTR
647 CALL problem_control_loop_solve(control_loop2,err,error,*999)
650 CALL problem_control_loop_post_loop(control_loop,err,error,*999)
653 CALL flagerror(
"Control loop while loop is not associated.",err,error,*999)
655 CASE(problem_control_load_increment_loop_type)
656 load_increment_loop=>control_loop%LOAD_INCREMENT_LOOP
657 IF(
ASSOCIATED(load_increment_loop))
THEN 658 load_increment_loop%ITERATION_NUMBER=0
659 IF (load_increment_loop%MAXIMUM_NUMBER_OF_ITERATIONS<1)
THEN 661 CALL flagerror(
"Automatic load incrementing is not implemented yet.",err,error,*999)
664 DO WHILE(load_increment_loop%ITERATION_NUMBER<load_increment_loop%MAXIMUM_NUMBER_OF_ITERATIONS)
665 load_increment_loop%ITERATION_NUMBER=load_increment_loop%ITERATION_NUMBER+1
666 IF(control_loop%OUTPUT_TYPE>=control_loop_progress_output)
THEN 667 CALL write_string(general_output_type,
"",err,error,*999)
668 CALL write_string_value(general_output_type,
"Load increment control loop iteration: ", &
669 & load_increment_loop%ITERATION_NUMBER,err,error,*999)
670 CALL write_string_value(general_output_type,
" Maximum number of iterations = ", &
671 & load_increment_loop%MAXIMUM_NUMBER_OF_ITERATIONS,err,error,*999)
673 CALL problem_control_loop_pre_loop(control_loop,err,error,*999)
674 IF(control_loop%NUMBER_OF_SUB_LOOPS==0)
THEN 676 solvers=>control_loop%SOLVERS
677 IF(
ASSOCIATED(solvers))
THEN 678 DO solver_idx=1,solvers%NUMBER_OF_SOLVERS
679 solver=>solvers%SOLVERS(solver_idx)%PTR
680 IF(
ASSOCIATED(solver))
THEN 681 IF(
ASSOCIATED(solver%SOLVER_EQUATIONS))
THEN 683 CALL problem_solver_load_increment_apply(solver%SOLVER_EQUATIONS,load_increment_loop%ITERATION_NUMBER, &
684 & load_increment_loop%MAXIMUM_NUMBER_OF_ITERATIONS,err,error,*999)
686 CALL problem_solver_solve(solver,err,error,*999)
688 CALL flagerror(
"Solver is not associated.",err,error,*999)
692 CALL flagerror(
"Control loop solvers is not associated.",err,error,*999)
696 DO loop_idx=1,control_loop%NUMBER_OF_SUB_LOOPS
697 control_loop2=>control_loop%SUB_LOOPS(loop_idx)%PTR
698 CALL problem_control_loop_solve(control_loop2,err,error,*999)
701 CALL problem_control_loop_post_loop(control_loop,err,error,*999)
705 CALL flagerror(
"Control loop while loop is not associated.",err,error,*999)
708 local_error=
"The control loop loop type of "//trim(number_to_vstring(control_loop%LOOP_TYPE,
"*",err,error))// &
710 CALL flagerror(local_error,err,error,*999)
713 CALL flagerror(
"Control loop has not been finished.",err,error,*999)
716 CALL flagerror(
"Control loop is not associated",err,error,*999)
719 exits(
"PROBLEM_CONTROL_LOOP_SOLVE")
721 999 errorsexits(
"PROBLEM_CONTROL_LOOP_SOLVE",err,error)
723 END SUBROUTINE problem_control_loop_solve
730 SUBROUTINE problem_create_finish(PROBLEM,ERR,ERROR,*)
733 TYPE(problem_type),
POINTER :: problem
734 INTEGER(INTG),
INTENT(OUT) :: err
735 TYPE(varying_string),
INTENT(OUT) :: error
737 INTEGER(INTG) :: problem_idx
738 TYPE(problem_setup_type) :: problem_setup_info
740 enters(
"PROBLEM_CREATE_FINISH",err,error,*999)
742 IF(
ASSOCIATED(problem))
THEN 744 CALL problem_setup_initialise(problem_setup_info,err,error,*999)
745 problem_setup_info%SETUP_TYPE=problem_setup_initial_type
746 problem_setup_info%ACTION_TYPE=problem_setup_finish_action
748 CALL problem_setup(problem,problem_setup_info,err,error,*999)
750 CALL problem_setup_finalise(problem_setup_info,err,error,*999)
752 problem%PROBLEM_FINISHED=.true.
754 CALL flagerror(
"Problem is not associated.",err,error,*999)
757 IF(diagnostics1)
THEN 758 CALL write_string_value(diagnostic_output_type,
"Number of problems = ",problems%NUMBER_OF_PROBLEMS,err,error,*999)
759 DO problem_idx=1,problems%NUMBER_OF_PROBLEMS
760 CALL write_string_value(diagnostic_output_type,
"Problem number = ",problem_idx,err,error,*999)
761 CALL write_string_value(diagnostic_output_type,
" User number = ",problems%PROBLEMS(problem_idx)%PTR%USER_NUMBER, &
763 CALL write_string_value(diagnostic_output_type,
" Global number = ",problems%PROBLEMS(problem_idx)%PTR%GLOBAL_NUMBER, &
765 CALL write_string_vector(diagnostic_output_type,1,1,
SIZE(problems%PROBLEMS(problem_idx)%PTR%SPECIFICATION,1),8,8, &
766 & problems%PROBLEMS(problem_idx)%PTR%SPECIFICATION,
'(" Problem specification = ",8(X,I3))',
'(16X,8(X,I3))', &
771 exits(
"PROBLEM_CREATE_FINISH")
773 999 errorsexits(
"PROBLEM_CREATE_FINISH",err,error)
776 END SUBROUTINE problem_create_finish
783 SUBROUTINE problem_create_start(USER_NUMBER,PROBLEM_SPECIFICATION,PROBLEM,ERR,ERROR,*)
786 INTEGER(INTG),
INTENT(IN) :: user_number
787 INTEGER(INTG),
INTENT(IN) :: problem_specification(:)
788 TYPE(problem_type),
POINTER :: problem
789 INTEGER(INTG),
INTENT(OUT) :: err
790 TYPE(varying_string),
INTENT(OUT) :: error
792 INTEGER(INTG) :: problem_idx
793 TYPE(problem_type),
POINTER :: new_problem
794 TYPE(problem_ptr_type),
POINTER :: new_problems(:)
795 TYPE(problem_setup_type) :: problem_setup_info
796 TYPE(varying_string) :: local_error
799 NULLIFY(new_problems)
801 enters(
"PROBLEM_CREATE_START",err,error,*999)
803 IF(
ASSOCIATED(problem))
THEN 804 CALL flagerror(
"Problem is already associated.",err,error,*999)
807 CALL problem_user_number_find(user_number,problem,err,error,*999)
808 IF(
ASSOCIATED(problem))
THEN 809 local_error=
"Problem number "//trim(number_to_vstring(user_number,
"*",err,error))//
" has already been created." 810 CALL flagerror(local_error,err,error,*999)
813 ALLOCATE(new_problem,stat=err)
814 IF(err/=0)
CALL flagerror(
"Could not allocate new problem.",err,error,*999)
816 CALL problem_initialise(new_problem,err,error,*999)
818 new_problem%USER_NUMBER=user_number
819 new_problem%GLOBAL_NUMBER=problems%NUMBER_OF_PROBLEMS+1
820 new_problem%PROBLEMS=>problems
822 CALL problem_specificationset(new_problem,problem_specification,err,error,*999)
824 new_problem%PROBLEM_FINISHED=.false.
826 CALL problem_setup_initialise(problem_setup_info,err,error,*999)
827 problem_setup_info%SETUP_TYPE=problem_setup_initial_type
828 problem_setup_info%ACTION_TYPE=problem_setup_start_action
830 CALL problem_setup(new_problem,problem_setup_info,err,error,*999)
832 CALL problem_setup_finalise(problem_setup_info,err,error,*999)
834 ALLOCATE(new_problems(problems%NUMBER_OF_PROBLEMS+1),stat=err)
835 IF(err/=0)
CALL flagerror(
"Could not allocate new problems.",err,error,*999)
836 DO problem_idx=1,problems%NUMBER_OF_PROBLEMS
837 new_problems(problem_idx)%PTR=>problems%PROBLEMS(problem_idx)%PTR
839 new_problems(problems%NUMBER_OF_PROBLEMS+1)%PTR=>new_problem
840 IF(
ASSOCIATED(problems%PROBLEMS))
DEALLOCATE(problems%PROBLEMS)
841 problems%PROBLEMS=>new_problems
842 problems%NUMBER_OF_PROBLEMS=problems%NUMBER_OF_PROBLEMS+1
847 exits(
"PROBLEM_CREATE_START")
849 999 errorsexits(
"PROBLEM_CREATE_START",err,error)
851 END SUBROUTINE problem_create_start
858 SUBROUTINE problem_destroy(PROBLEM,ERR,ERROR,*)
861 TYPE(problem_type),
POINTER :: problem
862 INTEGER(INTG),
INTENT(OUT) :: err
863 TYPE(varying_string),
INTENT(OUT) :: error
865 INTEGER(INTG) :: problem_idx,problem_position
866 TYPE(problem_ptr_type),
POINTER :: new_problems(:)
868 NULLIFY(new_problems)
870 enters(
"PROBLEM_DESTROY",err,error,*999)
872 IF(
ASSOCIATED(problem))
THEN 873 IF(
ASSOCIATED(problems%PROBLEMS))
THEN 875 problem_position=problem%GLOBAL_NUMBER
878 CALL problem_finalise(problem,err,error,*999)
881 IF(problems%NUMBER_OF_PROBLEMS>1)
THEN 882 ALLOCATE(new_problems(problems%NUMBER_OF_PROBLEMS-1),stat=err)
883 IF(err/=0)
CALL flagerror(
"Could not allocate new problems.",err,error,*999)
884 DO problem_idx=1,problems%NUMBER_OF_PROBLEMS
885 IF(problem_idx<problem_position)
THEN 886 new_problems(problem_idx)%PTR=>problems%PROBLEMS(problem_idx)%PTR
887 ELSE IF(problem_idx>problem_position)
THEN 888 problems%PROBLEMS(problem_idx)%PTR%GLOBAL_NUMBER=problems%PROBLEMS(problem_idx)%PTR%GLOBAL_NUMBER-1
889 new_problems(problem_idx-1)%PTR=>problems%PROBLEMS(problem_idx)%PTR
892 DEALLOCATE(problems%PROBLEMS)
893 problems%PROBLEMS=>new_problems
894 problems%NUMBER_OF_PROBLEMS=problems%NUMBER_OF_PROBLEMS-1
896 DEALLOCATE(problems%PROBLEMS)
897 problems%NUMBER_OF_PROBLEMS=0
901 CALL flagerror(
"Problem problems is not associated.",err,error,*999)
904 CALL flagerror(
"Problem is not associated.",err,error,*998)
907 exits(
"PROBLEM_DESTROY")
909 999
IF(
ASSOCIATED(new_problems))
DEALLOCATE(new_problems)
910 998 errorsexits(
"PROBLEM_DESTROY",err,error)
912 END SUBROUTINE problem_destroy
919 SUBROUTINE problem_setup_finalise(PROBLEM_SETUP_INFO,ERR,ERROR,*)
922 TYPE(problem_setup_type),
INTENT(OUT) :: problem_setup_info
923 INTEGER(INTG),
INTENT(OUT) :: err
924 TYPE(varying_string),
INTENT(OUT) :: error
927 enters(
"PROBLEM_SETUP_FINALISE",err,error,*999)
929 problem_setup_info%SETUP_TYPE=0
930 problem_setup_info%ACTION_TYPE=0
932 exits(
"PROBLEM_SETUP_FINALISE")
934 999 errorsexits(
"PROBLEM_SETUP_FINALISE",err,error)
936 END SUBROUTINE problem_setup_finalise
943 SUBROUTINE problem_setup_initialise(PROBLEM_SETUP_INFO,ERR,ERROR,*)
946 TYPE(problem_setup_type),
INTENT(OUT) :: problem_setup_info
947 INTEGER(INTG),
INTENT(OUT) :: err
948 TYPE(varying_string),
INTENT(OUT) :: error
951 enters(
"PROBLEM_SETUP_INITIALISE",err,error,*999)
953 problem_setup_info%SETUP_TYPE=0
954 problem_setup_info%ACTION_TYPE=0
956 exits(
"PROBLEM_SETUP_INITIALISE")
958 999 errorsexits(
"PROBLEM_SETUP_INITIALISE",err,error)
960 END SUBROUTINE problem_setup_initialise
967 SUBROUTINE problem_finalise(PROBLEM,ERR,ERROR,*)
970 TYPE(problem_type),
POINTER :: problem
971 INTEGER(INTG),
INTENT(OUT) :: err
972 TYPE(varying_string),
INTENT(OUT) :: error
975 enters(
"PROBLEM_FINALISE",err,error,*999)
977 IF(
ASSOCIATED(problem))
THEN 978 IF(
ASSOCIATED(problem%CONTROL_LOOP))
CALL control_loop_destroy(problem%CONTROL_LOOP,err,error,*999)
979 IF(
ALLOCATED(problem%SPECIFICATION))
DEALLOCATE(problem%SPECIFICATION)
983 exits(
"PROBLEM_FINALISE")
985 999 errorsexits(
"PROBLEM_FINALISE",err,error)
987 END SUBROUTINE problem_finalise
994 SUBROUTINE problem_initialise(PROBLEM,ERR,ERROR,*)
997 TYPE(problem_type),
POINTER :: problem
998 INTEGER(INTG),
INTENT(OUT) :: err
999 TYPE(varying_string),
INTENT(OUT) :: error
1002 enters(
"PROBLEM_INITIALISE",err,error,*999)
1004 IF(
ASSOCIATED(problem))
THEN 1005 problem%USER_NUMBER=0
1006 problem%GLOBAL_NUMBER=0
1007 problem%PROBLEM_FINISHED=.false.
1008 NULLIFY(problem%PROBLEMS)
1009 NULLIFY(problem%CONTROL_LOOP)
1011 CALL flagerror(
"Problem is not associated.",err,error,*999)
1014 exits(
"PROBLEM_INITIALISE")
1016 999 errorsexits(
"PROBLEM_INITIALISE",err,error)
1018 END SUBROUTINE problem_initialise
1025 SUBROUTINE problem_control_loop_create_finish(PROBLEM,ERR,ERROR,*)
1028 TYPE(problem_type),
POINTER :: problem
1029 INTEGER(INTG),
INTENT(OUT) :: err
1030 TYPE(varying_string),
INTENT(OUT) :: error
1032 TYPE(problem_setup_type) :: problem_setup_info
1034 enters(
"PROBLEM_CONTROL_LOOP_CREATE_FINISH",err,error,*999)
1036 IF(
ASSOCIATED(problem))
THEN 1037 IF(
ASSOCIATED(problem%CONTROL_LOOP))
THEN 1038 IF(problem%CONTROL_LOOP%CONTROL_LOOP_FINISHED)
THEN 1039 CALL flagerror(
"Problem control loop has already been finished.",err,error,*999)
1042 CALL problem_setup_initialise(problem_setup_info,err,error,*999)
1043 problem_setup_info%SETUP_TYPE=problem_setup_control_type
1044 problem_setup_info%ACTION_TYPE=problem_setup_finish_action
1046 CALL problem_setup(problem,problem_setup_info,err,error,*999)
1048 CALL problem_setup_finalise(problem_setup_info,err,error,*999)
1050 problem%CONTROL_LOOP%CONTROL_LOOP_FINISHED=.true.
1053 CALL flagerror(
"The problem control loop is not associated.",err,error,*999)
1056 CALL flagerror(
"Problem is not associated.",err,error,*999)
1059 exits(
"PROBLEM_CONTROL_LOOP_CREATE_FINISH")
1061 999 errorsexits(
"PROBLEM_CONTROL_LOOP_CREATE_FINISH",err,error)
1063 END SUBROUTINE problem_control_loop_create_finish
1074 SUBROUTINE problem_control_loop_create_start(PROBLEM,ERR,ERROR,*)
1077 TYPE(problem_type),
POINTER :: problem
1078 INTEGER(INTG),
INTENT(OUT) :: err
1079 TYPE(varying_string),
INTENT(OUT) :: error
1081 TYPE(problem_setup_type) :: problem_setup_info
1083 enters(
"PROBLEM_CONTROL_LOOP_CREATE_START",err,error,*999)
1085 IF(
ASSOCIATED(problem))
THEN 1086 IF(
ASSOCIATED(problem%CONTROL_LOOP))
THEN 1087 CALL flagerror(
"The problem control loop is already associated.",err,error,*999)
1090 CALL problem_setup_initialise(problem_setup_info,err,error,*999)
1091 problem_setup_info%SETUP_TYPE=problem_setup_control_type
1092 problem_setup_info%ACTION_TYPE=problem_setup_start_action
1094 CALL problem_setup(problem,problem_setup_info,err,error,*999)
1096 CALL problem_setup_finalise(problem_setup_info,err,error,*999)
1099 CALL flagerror(
"Problem is not associated.",err,error,*999)
1102 exits(
"PROBLEM_CONTROL_LOOP_CREATE_START")
1104 999 errorsexits(
"PROBLEM_CONTROL_LOOP_CREATE_START",err,error)
1106 END SUBROUTINE problem_control_loop_create_start
1113 SUBROUTINE problem_control_loop_destroy(PROBLEM,ERR,ERROR,*)
1116 TYPE(problem_type),
POINTER :: problem
1117 INTEGER(INTG),
INTENT(OUT) :: err
1118 TYPE(varying_string),
INTENT(OUT) :: error
1121 enters(
"PROBLEM_CONTROL_LOOP_DESTROY",err,error,*999)
1123 IF(
ASSOCIATED(problem))
THEN 1124 IF(
ASSOCIATED(problem%CONTROL_LOOP))
THEN 1125 CALL control_loop_destroy(problem%CONTROL_LOOP,err,error,*999)
1127 CALL flagerror(
"Problem control loop is not associated.",err,error,*999)
1130 CALL flagerror(
"Problem is not associated.",err,error,*999)
1133 exits(
"PROBLEM_CONTROL_LOOP_DESTROY")
1135 999 errorsexits(
"PROBLEM_CONTROL_LOOP_DESTROY",err,error)
1137 END SUBROUTINE problem_control_loop_destroy
1144 SUBROUTINE problem_control_loop_get_0(PROBLEM,CONTROL_LOOP_IDENTIFIER,CONTROL_LOOP,ERR,ERROR,*)
1147 TYPE(problem_type),
POINTER :: problem
1148 INTEGER(INTG),
INTENT(IN) :: control_loop_identifier
1149 TYPE(control_loop_type),
POINTER :: control_loop
1150 INTEGER(INTG),
INTENT(OUT) :: err
1151 TYPE(varying_string),
INTENT(OUT) :: error
1154 enters(
"PROBLEM_CONTROL_LOOP_GET_0",err,error,*999)
1156 CALL problem_control_loop_get_1(problem,[control_loop_identifier],control_loop,err,error,*999)
1158 exits(
"PROBLEM_CONTROL_LOOP_GET_0")
1160 999 errorsexits(
"PROBLEM_CONTROL_LOOP_GET_0",err,error)
1162 END SUBROUTINE problem_control_loop_get_0
1169 SUBROUTINE problem_control_loop_get_1(PROBLEM,CONTROL_LOOP_IDENTIFIER,CONTROL_LOOP,ERR,ERROR,*)
1172 TYPE(problem_type),
POINTER :: problem
1173 INTEGER(INTG),
INTENT(IN) :: control_loop_identifier(:)
1174 TYPE(control_loop_type),
POINTER :: control_loop
1175 INTEGER(INTG),
INTENT(OUT) :: err
1176 TYPE(varying_string),
INTENT(OUT) :: error
1178 TYPE(control_loop_type),
POINTER :: control_loop_root
1180 enters(
"PROBLEM_CONTROL_LOOP_GET_1",err,error,*999)
1182 IF(
ASSOCIATED(problem))
THEN 1183 IF(
ASSOCIATED(control_loop))
THEN 1184 CALL flagerror(
"Control loop is already associated.",err,error,*999)
1186 control_loop_root=>problem%CONTROL_LOOP
1187 IF(
ASSOCIATED(control_loop_root))
THEN 1188 NULLIFY(control_loop)
1189 CALL control_loop_get(control_loop_root,control_loop_identifier,control_loop,err,error,*999)
1191 CALL flagerror(
"Problem control loop is not associated.",err,error,*999)
1195 CALL flagerror(
"Problem is not associated.",err,error,*999)
1198 exits(
"PROBLEM_CONTROL_LOOP_GET_1")
1200 999 errorsexits(
"PROBLEM_CONTROL_LOOP_GET_1",err,error)
1202 END SUBROUTINE problem_control_loop_get_1
1209 SUBROUTINE problem_setup(problem,problemSetupInfo,err,error,*)
1212 TYPE(problem_type),
POINTER :: problem
1213 TYPE(problem_setup_type),
INTENT(INOUT) :: problemsetupinfo
1214 INTEGER(INTG),
INTENT(OUT) :: err
1215 TYPE(varying_string),
INTENT(OUT) :: error
1217 TYPE(varying_string) :: localerror
1219 enters(
"Problem_Setup",err,error,*999)
1221 IF(
ASSOCIATED(problem))
THEN 1222 IF(.NOT.
ALLOCATED(problem%specification))
THEN 1223 CALL flagerror(
"Problem specification is not allocated.",err,error,*999)
1224 ELSE IF(
SIZE(problem%specification,1)<1)
THEN 1225 CALL flagerror(
"Problem specification must have at least one entry.",err,error,*999)
1227 SELECT CASE(problem%specification(1))
1228 CASE(problem_elasticity_class)
1229 CALL elasticity_problem_setup(problem,problemsetupinfo,err,error,*999)
1230 CASE(problem_fluid_mechanics_class)
1231 CALL fluid_mechanics_problem_setup(problem,problemsetupinfo,err,error,*999)
1232 CASE(problem_bioelectrics_class)
1233 CALL bioelectric_problem_setup(problem,problemsetupinfo,err,error,*999)
1234 CASE(problem_electromagnetics_class)
1235 CALL flagerror(
"Not implemented.",err,error,*999)
1236 CASE(problem_classical_field_class)
1237 CALL classical_field_problem_setup(problem,problemsetupinfo,err,error,*999)
1238 CASE(problem_fitting_class)
1239 CALL fitting_problem_setup(problem,problemsetupinfo,err,error,*999)
1240 CASE(problem_modal_class)
1241 CALL flagerror(
"Not implemented.",err,error,*999)
1242 CASE(problem_multi_physics_class)
1243 CALL multi_physics_problem_setup(problem,problemsetupinfo,err,error,*999)
1245 localerror=
"The first problem specification of "//trim(numbertovstring(problem%specification(1),
"*",err,error))// &
1247 CALL flagerror(localerror,err,error,*999)
1250 CALL flagerror(
"Problem is not associated.",err,error,*999)
1253 exits(
"Problem_Setup")
1255 999 errorsexits(
"Problem_Setup",err,error)
1258 END SUBROUTINE problem_setup
1265 SUBROUTINE problem_solver_equations_get_0(PROBLEM,CONTROL_LOOP_IDENTIFIER,SOLVER_INDEX,SOLVER_EQUATIONS,ERR,ERROR,*)
1268 TYPE(problem_type),
POINTER :: problem
1269 INTEGER(INTG),
INTENT(IN) :: control_loop_identifier
1270 INTEGER(INTG),
INTENT(IN) :: solver_index
1271 TYPE(solver_equations_type),
POINTER :: solver_equations
1272 INTEGER(INTG),
INTENT(OUT) :: err
1273 TYPE(varying_string),
INTENT(OUT) :: error
1276 enters(
"PROBLEM_SOLVER_EQUATIONS_GET_0",err,error,*999)
1278 CALL problem_solver_equations_get_1(problem,[control_loop_identifier],solver_index,solver_equations,err,error,*999)
1280 exits(
"PROBLEM_SOLVER_EQUATIONS_GET_0")
1282 999 errorsexits(
"PROBLEM_SOLVER_EQUATIONS_GET_0",err,error)
1284 END SUBROUTINE problem_solver_equations_get_0
1291 SUBROUTINE problem_solver_equations_get_1(PROBLEM,CONTROL_LOOP_IDENTIFIER,SOLVER_INDEX,SOLVER_EQUATIONS,ERR,ERROR,*)
1294 TYPE(problem_type),
POINTER :: problem
1295 INTEGER(INTG),
INTENT(IN) :: control_loop_identifier(:)
1296 INTEGER(INTG),
INTENT(IN) :: solver_index
1297 TYPE(solver_equations_type),
POINTER :: solver_equations
1298 INTEGER(INTG),
INTENT(OUT) :: err
1299 TYPE(varying_string),
INTENT(OUT) :: error
1301 TYPE(control_loop_type),
POINTER :: control_loop,control_loop_root
1302 TYPE(solver_type),
POINTER :: solver
1303 TYPE(solvers_type),
POINTER :: solvers
1304 TYPE(varying_string) :: local_error
1306 enters(
"PROBLEM_SOLVER_EQUATIONS_GET_1",err,error,*999)
1308 IF(
ASSOCIATED(problem))
THEN 1309 IF(
ASSOCIATED(solver_equations))
THEN 1310 CALL flagerror(
"The solver equations is already associated.",err,error,*999)
1312 NULLIFY(solver_equations)
1313 control_loop_root=>problem%CONTROL_LOOP
1314 IF(
ASSOCIATED(control_loop_root))
THEN 1315 NULLIFY(control_loop)
1316 CALL control_loop_get(control_loop_root,control_loop_identifier,control_loop,err,error,*999)
1317 solvers=>control_loop%SOLVERS
1318 IF(
ASSOCIATED(solvers))
THEN 1319 IF(solver_index>0.AND.solver_index<=solvers%NUMBER_OF_SOLVERS)
THEN 1320 solver=>solvers%SOLVERS(solver_index)%PTR
1321 IF(
ASSOCIATED(solver))
THEN 1322 solver_equations=>solver%SOLVER_EQUATIONS
1323 IF(.NOT.
ASSOCIATED(solver_equations))
CALL flagerror(
"Solver equations is not associated.",err,error,*999)
1325 CALL flagerror(
"Solver is not associated.",err,error,*999)
1328 local_error=
"The specified solver index of "//trim(number_to_vstring(solver_index,
"*",err,error))// &
1329 &
" is invalid. The index must be > 0 and <= "// &
1330 & trim(number_to_vstring(solvers%NUMBER_OF_SOLVERS,
"*",err,error))//
"." 1331 CALL flagerror(local_error,err,error,*999)
1334 CALL flagerror(
"Solvers is not associated.",err,error,*999)
1337 CALL flagerror(
"Problem control loop is not associated.",err,error,*999)
1341 CALL flagerror(
"Problem is not associated.",err,error,*999)
1344 exits(
"PROBLEM_SOLVER_EQUATIONS_GET_1")
1346 999 errorsexits(
"PROBLEM_SOLVER_EQUATIONS_GET_1",err,error)
1348 END SUBROUTINE problem_solver_equations_get_1
1355 SUBROUTINE problem_solver_jacobian_evaluate(SOLVER,ERR,ERROR,*)
1358 TYPE(solver_type),
POINTER :: solver, linking_solver
1359 INTEGER(INTG),
INTENT(OUT) :: err
1360 TYPE(varying_string),
INTENT(OUT) :: error
1362 INTEGER(INTG) :: equations_set_idx,solver_matrix_idx
1363 TYPE(equations_set_type),
POINTER :: equations_set
1364 TYPE(solver_type),
POINTER :: cellml_solver
1365 TYPE(newton_solver_type),
POINTER :: newton_solver
1366 TYPE(solver_equations_type),
POINTER :: solver_equations
1367 TYPE(solver_mapping_type),
POINTER :: solver_mapping
1368 TYPE(solver_matrices_type),
POINTER :: solver_matrices
1369 TYPE(solver_matrix_type),
POINTER :: solver_matrix
1370 TYPE(varying_string) :: local_error
1372 enters(
"PROBLEM_SOLVER_JACOBIAN_EVALUATE",err,error,*999)
1374 IF(
ASSOCIATED(solver))
THEN 1375 IF(solver%SOLVER_FINISHED)
THEN 1376 solver_equations=>solver%SOLVER_EQUATIONS
1377 IF(
ASSOCIATED(solver_equations))
THEN 1378 solver_mapping=>solver_equations%SOLVER_MAPPING
1379 IF(
ASSOCIATED(solver_mapping))
THEN 1380 IF(solver%OUTPUT_TYPE>=solver_matrix_output)
THEN 1381 solver_matrices=>solver_equations%SOLVER_MATRICES
1382 IF(
ASSOCIATED(solver_matrices))
THEN 1383 CALL write_string(general_output_type,
"",err,error,*999)
1384 CALL write_string(general_output_type,
"Solver vector values:",err,error,*999)
1385 DO solver_matrix_idx=1,solver_matrices%NUMBER_OF_MATRICES
1386 solver_matrix=>solver_matrices%MATRICES(solver_matrix_idx)%PTR
1387 IF(
ASSOCIATED(solver_matrix))
THEN 1388 CALL write_string_value(general_output_type,
"Solver matrix : ",solver_matrix_idx,err,error,*999)
1389 CALL distributed_vector_output(general_output_type,solver_matrix%SOLVER_VECTOR,err,error,*999)
1391 local_error=
"Solver matrix is not associated for solver matrix index "// &
1392 & trim(number_to_vstring(solver_matrix_idx,
"*",err,error))//
"." 1393 CALL flagerror(local_error,err,error,*999)
1397 CALL flagerror(
"Solver equations solver matrices is not associated.",err,error,*999)
1400 IF(solver%SOLVE_TYPE==solver_nonlinear_type)
THEN 1402 linking_solver=>solver%LINKING_SOLVER
1403 IF(
ASSOCIATED(linking_solver))
THEN 1404 IF(linking_solver%SOLVE_TYPE==solver_dynamic_type)
THEN 1406 CALL solver_variables_dynamic_nonlinear_update(solver,err,error,*999)
1409 newton_solver=>solver%NONLINEAR_SOLVER%NEWTON_SOLVER
1410 IF(
ASSOCIATED(newton_solver))
THEN 1411 cellml_solver=>newton_solver%CELLML_EVALUATOR_SOLVER
1412 IF(
ASSOCIATED(cellml_solver))
THEN 1413 CALL solver_solve(cellml_solver,err,error,*999)
1416 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
1419 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
1420 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
1422 CALL equations_set_jacobian_evaluate(equations_set,err,error,*999)
1425 CALL solver_matrices_dynamic_assemble(solver,solver_matrices_jacobian_only,err,error,*999)
1427 CALL flagerror(
"Solver equations linking solver mapping is not dynamic.",err,error,*999)
1432 CALL solver_variables_field_update(solver,err,error,*999)
1435 newton_solver=>solver%NONLINEAR_SOLVER%NEWTON_SOLVER
1436 IF(
ASSOCIATED(newton_solver))
THEN 1437 cellml_solver=>newton_solver%CELLML_EVALUATOR_SOLVER
1438 IF(
ASSOCIATED(cellml_solver))
THEN 1439 CALL solver_solve(cellml_solver,err,error,*999)
1442 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
1445 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
1446 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
1448 CALL equations_set_jacobian_evaluate(equations_set,err,error,*999)
1458 CALL solver_matrices_static_assemble(solver,solver_matrices_jacobian_only,err,error,*999)
1461 CALL flagerror(
"Solver equations solver type is not associated.",err,error,*999)
1464 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
1467 CALL flagerror(
"Solver solver equations mapping is not associated.",err,error,*999)
1470 CALL flagerror(
"Solver has not been finished.",err,error,*999)
1473 CALL flagerror(
"Solver is not associated.",err,error,*999)
1476 exits(
"PROBLEM_SOLVER_JACOBIAN_EVALUATE")
1478 999 errorsexits(
"PROBLEM_SOLVER_JACOBIAN_EVALUATE",err,error)
1480 END SUBROUTINE problem_solver_jacobian_evaluate
1487 SUBROUTINE problem_solver_residual_evaluate(SOLVER,ERR,ERROR,*)
1490 TYPE(solver_type),
POINTER :: solver
1491 INTEGER(INTG),
INTENT(OUT) :: err
1492 TYPE(varying_string),
INTENT(OUT) :: error
1494 INTEGER(INTG) :: equations_set_idx,solver_matrix_idx
1495 TYPE(equations_set_type),
POINTER :: equations_set
1496 TYPE(solver_type),
POINTER :: cellml_solver,linking_solver
1497 TYPE(solver_equations_type),
POINTER :: solver_equations
1498 TYPE(solver_mapping_type),
POINTER :: solver_mapping
1499 TYPE(solver_matrices_type),
POINTER :: solver_matrices
1500 TYPE(solver_matrix_type),
POINTER :: solver_matrix
1502 TYPE(varying_string) :: local_error
1504 NULLIFY(cellml_solver)
1505 NULLIFY(linking_solver)
1507 enters(
"PROBLEM_SOLVER_RESIDUAL_EVALUATE",err,error,*999)
1509 IF(
ASSOCIATED(solver))
THEN 1510 IF(solver%SOLVER_FINISHED)
THEN 1511 solver_equations=>solver%SOLVER_EQUATIONS
1512 IF(
ASSOCIATED(solver_equations))
THEN 1513 solver_mapping=>solver_equations%SOLVER_MAPPING
1514 IF(
ASSOCIATED(solver_mapping))
THEN 1515 IF(solver%OUTPUT_TYPE>=solver_matrix_output)
THEN 1516 solver_matrices=>solver_equations%SOLVER_MATRICES
1517 IF(
ASSOCIATED(solver_matrices))
THEN 1518 CALL write_string(general_output_type,
"",err,error,*999)
1519 CALL write_string(general_output_type,
"Solver vector values:",err,error,*999)
1520 DO solver_matrix_idx=1,solver_matrices%NUMBER_OF_MATRICES
1521 solver_matrix=>solver_matrices%MATRICES(solver_matrix_idx)%PTR
1522 IF(
ASSOCIATED(solver_matrix))
THEN 1523 CALL write_string_value(general_output_type,
"Solver matrix : ",solver_matrix_idx,err,error,*999)
1524 CALL distributed_vector_output(general_output_type,solver_matrix%SOLVER_VECTOR,err,error,*999)
1526 local_error=
"Solver matrix is not associated for solver matrix index "// &
1527 & trim(number_to_vstring(solver_matrix_idx,
"*",err,error))//
"." 1528 CALL flagerror(local_error,err,error,*999)
1532 CALL flagerror(
"Solver equations solver matrices is not associated.",err,error,*999)
1535 IF(solver%SOLVE_TYPE==solver_nonlinear_type)
THEN 1537 linking_solver=>solver%LINKING_SOLVER
1538 IF(
ASSOCIATED(linking_solver))
THEN 1539 IF(linking_solver%SOLVE_TYPE==solver_dynamic_type)
THEN 1541 CALL solver_variables_dynamic_nonlinear_update(solver,err,error,*999)
1543 CALL problem_pre_residual_evaluate(solver,err,error,*999)
1547 SELECT CASE(solver%NONLINEAR_SOLVER%NONLINEAR_SOLVE_TYPE)
1548 CASE(solver_nonlinear_newton)
1549 cellml_solver=>solver%NONLINEAR_SOLVER%NEWTON_SOLVER%CELLML_EVALUATOR_SOLVER
1550 CASE(solver_nonlinear_quasi_newton)
1551 cellml_solver=>solver%NONLINEAR_SOLVER%QUASI_NEWTON_SOLVER%CELLML_EVALUATOR_SOLVER
1553 local_error=
"Linked CellML solver is not implemented for nonlinear solver type " &
1554 & //trim(number_to_vstring(solver%NONLINEAR_SOLVER%NONLINEAR_SOLVE_TYPE,
"*",err,error))//
"." 1555 CALL flagerror(local_error,err,error,*999)
1557 IF(
ASSOCIATED(cellml_solver))
CALL solver_solve(cellml_solver,err,error,*999)
1559 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
1560 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
1561 SELECT CASE(equations_set%EQUATIONS%LINEARITY)
1562 CASE(equations_linear)
1564 CALL equations_set_assemble(equations_set,err,error,*999)
1565 CASE(equations_nonlinear)
1567 CALL equations_set_residual_evaluate(equations_set,err,error,*999)
1571 CALL solver_matrices_dynamic_assemble(solver,solver_matrices_rhs_residual_only,err,error,*999)
1573 CALL flagerror(
"Solver equations linking solver mapping is not dynamic.",err,error,*999)
1578 CALL solver_variables_field_update(solver,err,error,*999)
1580 CALL problem_pre_residual_evaluate(solver,err,error,*999)
1583 SELECT CASE(solver%NONLINEAR_SOLVER%NONLINEAR_SOLVE_TYPE)
1584 CASE(solver_nonlinear_newton)
1585 cellml_solver=>solver%NONLINEAR_SOLVER%NEWTON_SOLVER%CELLML_EVALUATOR_SOLVER
1586 CASE(solver_nonlinear_quasi_newton)
1587 cellml_solver=>solver%NONLINEAR_SOLVER%QUASI_NEWTON_SOLVER%CELLML_EVALUATOR_SOLVER
1589 local_error=
"Linked CellML solver is not implemented for nonlinear solver type " &
1590 & //trim(number_to_vstring(solver%NONLINEAR_SOLVER%NONLINEAR_SOLVE_TYPE,
"*",err,error))//
"." 1591 CALL flagerror(local_error,err,error,*999)
1593 IF(
ASSOCIATED(cellml_solver))
CALL solver_solve(cellml_solver,err,error,*999)
1595 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
1596 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
1597 SELECT CASE(equations_set%EQUATIONS%LINEARITY)
1598 CASE(equations_linear)
1600 CALL equations_set_assemble(equations_set,err,error,*999)
1601 CASE(equations_nonlinear)
1603 CALL equations_set_residual_evaluate(equations_set,err,error,*999)
1615 CALL solver_matrices_static_assemble(solver,solver_matrices_rhs_residual_only,err,error,*999)
1618 CALL flagerror(
"Solver equations solver type is not associated.",err,error,*999)
1621 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
1624 CALL flagerror(
"Solver solver equations mapping is not associated.",err,error,*999)
1626 CALL problem_post_residual_evaluate(solver,err,error,*999)
1628 CALL flagerror(
"Solver has not been finished.",err,error,*999)
1631 CALL flagerror(
"Solver is not associated.",err,error,*999)
1634 exits(
"PROBLEM_SOLVER_RESIDUAL_EVALUATE")
1636 999 errorsexits(
"PROBLEM_SOLVER_RESIDUAL_EVALUATE",err,error)
1639 END SUBROUTINE problem_solver_residual_evaluate
1646 SUBROUTINE problem_pre_residual_evaluate(SOLVER,ERR,ERROR,*)
1649 TYPE(solver_type),
POINTER :: solver
1650 INTEGER(INTG),
INTENT(OUT) :: err
1651 TYPE(varying_string),
INTENT(OUT) :: error
1653 INTEGER(INTG) :: equations_set_idx
1654 TYPE(equations_set_type),
POINTER :: equations_set
1655 TYPE(equations_type),
POINTER :: equations
1656 TYPE(solver_equations_type),
POINTER :: solver_equations
1657 TYPE(solver_mapping_type),
POINTER :: solver_mapping
1658 TYPE(varying_string) :: local_error
1660 enters(
"PROBLEM_PRE_RESIDUAL_EVALUATE",err,error,*999)
1662 IF(
ASSOCIATED(solver))
THEN 1663 IF(solver%SOLVER_FINISHED)
THEN 1664 solver_equations=>solver%SOLVER_EQUATIONS
1665 IF(
ASSOCIATED(solver_equations))
THEN 1666 solver_mapping=>solver_equations%SOLVER_MAPPING
1667 IF(
ASSOCIATED(solver_mapping))
THEN 1668 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
1669 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
1670 IF(
ASSOCIATED(equations_set))
THEN 1671 equations=>equations_set%EQUATIONS
1672 IF(
ASSOCIATED(equations))
THEN 1673 IF(equations%EQUATIONS_FINISHED)
THEN 1674 SELECT CASE(equations%LINEARITY)
1675 CASE(equations_linear)
1676 CALL flagerror(
"Can not pre-evaluate a residual for linear equations.",err,error,*999)
1677 CASE(equations_nonlinear)
1678 SELECT CASE(equations%TIME_DEPENDENCE)
1679 CASE(equations_static,equations_quasistatic,equations_first_order_dynamic)
1680 SELECT CASE(equations_set%SOLUTION_METHOD)
1681 CASE(equations_set_fem_solution_method)
1682 IF(.NOT.
ALLOCATED(equations_set%SPECIFICATION))
THEN 1683 CALL flagerror(
"Equations set specification is not allocated.",err,error,*999)
1684 ELSE IF(
SIZE(equations_set%SPECIFICATION,1)<1)
THEN 1685 CALL flagerror(
"Equations set specification must have at least one entry.",err,error,*999)
1687 SELECT CASE(equations_set%specification(1))
1688 CASE(equations_set_elasticity_class)
1689 CALL elasticity_finiteelementpreresidualevaluate(equations_set,err,error,*999)
1690 CASE(equations_set_fluid_mechanics_class)
1691 CALL fluidmechanics_finiteelementpreresidualevaluate(equations_set,err,error,*999)
1692 CASE(equations_set_electromagnetics_class)
1694 CASE(equations_set_classical_field_class)
1696 CASE(equations_set_bioelectrics_class)
1698 CASE(equations_set_modal_class)
1700 CASE(equations_set_multi_physics_class)
1703 local_error=
"The first equations set specification of "// &
1704 & trim(numbertovstring(equations_set%specification(1),
"*",err,error))//
" is not valid." 1705 CALL flagerror(local_error,err,error,*999)
1707 CASE(equations_set_nodal_solution_method)
1708 SELECT CASE(equations_set%SPECIFICATION(1))
1709 CASE(equations_set_fluid_mechanics_class)
1712 local_error=
"The first equations set specification of "// &
1713 & trim(numbertovstring(equations_set%SPECIFICATION(1),
"*",err,error))//
" is not valid." 1714 CALL flag_error(local_error,err,error,*999)
1716 CASE(equations_set_bem_solution_method)
1717 CALL flagerror(
"Not implemented.",err,error,*999)
1718 CASE(equations_set_fd_solution_method)
1719 CALL flagerror(
"Not implemented.",err,error,*999)
1720 CASE(equations_set_fv_solution_method)
1721 CALL flagerror(
"Not implemented.",err,error,*999)
1722 CASE(equations_set_gfem_solution_method)
1723 CALL flagerror(
"Not implemented.",err,error,*999)
1724 CASE(equations_set_gfv_solution_method)
1725 CALL flagerror(
"Not implemented.",err,error,*999)
1727 local_error=
"The equations set solution method of "// &
1728 & trim(number_to_vstring(equations_set%SOLUTION_METHOD,
"*",err,error))// &
1730 CALL flagerror(local_error,err,error,*999)
1732 CASE(equations_second_order_dynamic)
1733 CALL flagerror(
"Not implemented.",err,error,*999)
1734 CASE(equations_time_stepping)
1735 CALL flagerror(
"Not implemented.",err,error,*999)
1737 local_error=
"The equations set time dependence type of "// &
1738 & trim(number_to_vstring(equations%TIME_DEPENDENCE,
"*",err,error))//
" is invalid." 1739 CALL flagerror(local_error,err,error,*999)
1741 CASE(equations_nonlinear_bcs)
1742 CALL flagerror(
"Not implemented.",err,error,*999)
1744 local_error=
"The equations linearity of "// &
1745 & trim(number_to_vstring(equations%LINEARITY,
"*",err,error))//
" is invalid." 1746 CALL flagerror(local_error,err,error,*999)
1749 CALL flagerror(
"Equations have not been finished.",err,error,*999)
1752 CALL flagerror(
"Equations set equations is not associated.",err,error,*999)
1755 CALL flagerror(
"Equations set is not associated.",err,error,*999)
1759 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
1762 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
1765 CALL flagerror(
"Solver has not been finished.",err,error,*999)
1768 CALL flagerror(
"Solver is not associated.",err,error,*999)
1771 exits(
"PROBLEM_PRE_RESIDUAL_EVALUATE")
1773 999 errorsexits(
"PROBLEM_PRE_RESIDUAL_EVALUATE",err,error)
1776 END SUBROUTINE problem_pre_residual_evaluate
1783 SUBROUTINE problem_post_residual_evaluate(SOLVER,ERR,ERROR,*)
1786 TYPE(solver_type),
POINTER :: solver
1787 INTEGER(INTG),
INTENT(OUT) :: err
1788 TYPE(varying_string),
INTENT(OUT) :: error
1790 INTEGER(INTG) :: equations_set_idx
1791 TYPE(equations_set_type),
POINTER :: equations_set
1792 TYPE(equations_type),
POINTER :: equations
1793 TYPE(solver_equations_type),
POINTER :: solver_equations
1794 TYPE(solver_mapping_type),
POINTER :: solver_mapping
1795 TYPE(varying_string) :: local_error
1797 enters(
"PROBLEM_POST_RESIDUAL_EVALUATE",err,error,*999)
1799 IF(
ASSOCIATED(solver))
THEN 1800 IF(solver%SOLVER_FINISHED)
THEN 1801 solver_equations=>solver%SOLVER_EQUATIONS
1802 IF(
ASSOCIATED(solver_equations))
THEN 1803 solver_mapping=>solver_equations%SOLVER_MAPPING
1804 IF(
ASSOCIATED(solver_mapping))
THEN 1805 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
1806 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
1807 IF(
ASSOCIATED(equations_set))
THEN 1808 equations=>equations_set%EQUATIONS
1809 IF(
ASSOCIATED(equations))
THEN 1810 IF(equations%EQUATIONS_FINISHED)
THEN 1811 SELECT CASE(equations%LINEARITY)
1812 CASE(equations_linear)
1813 CALL flagerror(
"Can not post-evaluate a residual for linear equations.",err,error,*999)
1814 CASE(equations_nonlinear)
1815 SELECT CASE(equations%TIME_DEPENDENCE)
1816 CASE(equations_static,equations_quasistatic,equations_first_order_dynamic)
1817 SELECT CASE(equations_set%SOLUTION_METHOD)
1818 CASE(equations_set_fem_solution_method)
1819 IF(.NOT.
ALLOCATED(equations_set%SPECIFICATION))
THEN 1820 CALL flagerror(
"Equations set specification is not allocated.",err,error,*999)
1821 ELSE IF(
SIZE(equations_set%SPECIFICATION,1)<1)
THEN 1822 CALL flagerror(
"Equations set specification must have at least one entry.",err,error,*999)
1824 SELECT CASE(equations_set%SPECIFICATION(1))
1825 CASE(equations_set_elasticity_class)
1826 CALL elasticity_finiteelementpostresidualevaluate(equations_set,err,error,*999)
1827 CASE(equations_set_fluid_mechanics_class)
1829 CASE(equations_set_electromagnetics_class)
1831 CASE(equations_set_classical_field_class)
1833 CASE(equations_set_bioelectrics_class)
1835 CASE(equations_set_modal_class)
1837 CASE(equations_set_multi_physics_class)
1840 local_error=
"The first equations set specification of "// &
1841 & trim(numbertovstring(equations_set%SPECIFICATION(1),
"*",err,error))//
" is not valid." 1842 CALL flag_error(local_error,err,error,*999)
1844 CASE(equations_set_nodal_solution_method)
1845 SELECT CASE(equations_set%SPECIFICATION(1))
1846 CASE(equations_set_fluid_mechanics_class)
1849 local_error=
"The first equations set specification of "// &
1850 & trim(numbertovstring(equations_set%specification(1),
"*",err,error))// &
1851 &
" is not valid with the nodal solution method." 1852 CALL flag_error(local_error,err,error,*999)
1854 CASE(equations_set_bem_solution_method)
1855 CALL flagerror(
"Not implemented.",err,error,*999)
1856 CASE(equations_set_fd_solution_method)
1857 CALL flagerror(
"Not implemented.",err,error,*999)
1858 CASE(equations_set_fv_solution_method)
1859 CALL flagerror(
"Not implemented.",err,error,*999)
1860 CASE(equations_set_gfem_solution_method)
1861 CALL flagerror(
"Not implemented.",err,error,*999)
1862 CASE(equations_set_gfv_solution_method)
1863 CALL flagerror(
"Not implemented.",err,error,*999)
1865 local_error=
"The equations set solution method of "// &
1866 & trim(number_to_vstring(equations_set%SOLUTION_METHOD,
"*",err,error))// &
1868 CALL flagerror(local_error,err,error,*999)
1870 CASE(equations_second_order_dynamic)
1871 CALL flagerror(
"Not implemented.",err,error,*999)
1872 CASE(equations_time_stepping)
1873 CALL flagerror(
"Not implemented.",err,error,*999)
1875 local_error=
"The equations set time dependence type of "// &
1876 & trim(number_to_vstring(equations%TIME_DEPENDENCE,
"*",err,error))//
" is invalid." 1877 CALL flagerror(local_error,err,error,*999)
1879 CASE(equations_nonlinear_bcs)
1880 CALL flagerror(
"Not implemented.",err,error,*999)
1882 local_error=
"The equations linearity of "// &
1883 & trim(number_to_vstring(equations%LINEARITY,
"*",err,error))//
" is invalid." 1884 CALL flagerror(local_error,err,error,*999)
1887 CALL flagerror(
"Equations have not been finished.",err,error,*999)
1890 CALL flagerror(
"Equations set equations is not associated.",err,error,*999)
1893 CALL flagerror(
"Equations set is not associated.",err,error,*999)
1897 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
1900 CALL flagerror(
"Solver solver equations is not associated.",err,error,*999)
1903 CALL flagerror(
"Solver has not been finished.",err,error,*999)
1906 CALL flagerror(
"Solver is not associated.",err,error,*999)
1909 exits(
"PROBLEM_POST_RESIDUAL_EVALUATE")
1911 999 errorsexits(
"PROBLEM_POST_RESIDUAL_EVALUATE",err,error)
1914 END SUBROUTINE problem_post_residual_evaluate
1921 SUBROUTINE problem_solvers_create_finish(PROBLEM,ERR,ERROR,*)
1924 TYPE(problem_type),
POINTER :: problem
1925 INTEGER(INTG),
INTENT(OUT) :: err
1926 TYPE(varying_string),
INTENT(OUT) :: error
1928 TYPE(problem_setup_type) :: problem_setup_info
1930 enters(
"PROBLEM_SOLVERS_CREATE_FINISH",err,error,*999)
1932 IF(
ASSOCIATED(problem))
THEN 1934 CALL problem_setup_initialise(problem_setup_info,err,error,*999)
1935 problem_setup_info%SETUP_TYPE=problem_setup_solvers_type
1936 problem_setup_info%ACTION_TYPE=problem_setup_finish_action
1938 CALL problem_setup(problem,problem_setup_info,err,error,*999)
1940 CALL problem_setup_finalise(problem_setup_info,err,error,*999)
1942 CALL flagerror(
"Problem is not associated.",err,error,*999)
1945 exits(
"PROBLEM_SOLVERS_CREATE_FINISH")
1947 999 errorsexits(
"PROBLEM_SOLVERS_CREATE_FINISH",err,error)
1949 END SUBROUTINE problem_solvers_create_finish
1956 SUBROUTINE problem_solvers_create_start(PROBLEM,ERR,ERROR,*)
1959 TYPE(problem_type),
POINTER :: problem
1960 INTEGER(INTG),
INTENT(OUT) :: err
1961 TYPE(varying_string),
INTENT(OUT) :: error
1963 TYPE(problem_setup_type) :: problem_setup_info
1965 enters(
"PROBLEM_SOLVERS_CREATE_START",err,error,*999)
1967 IF(
ASSOCIATED(problem))
THEN 1969 CALL problem_setup_initialise(problem_setup_info,err,error,*999)
1970 problem_setup_info%SETUP_TYPE=problem_setup_solvers_type
1971 problem_setup_info%ACTION_TYPE=problem_setup_start_action
1973 CALL problem_setup(problem,problem_setup_info,err,error,*999)
1975 CALL problem_setup_finalise(problem_setup_info,err,error,*999)
1977 CALL flagerror(
"Problem is not associated.",err,error,*999)
1980 exits(
"PROBLEM_SOLVERS_CREATE_START")
1982 999 errorsexits(
"PROBLEM_SOLVERS_CREATE_START",err,error)
1984 END SUBROUTINE problem_solvers_create_start
1991 SUBROUTINE problem_solve(PROBLEM,ERR,ERROR,*)
1994 TYPE(problem_type),
POINTER :: problem
1995 INTEGER(INTG),
INTENT(OUT) :: err
1996 TYPE(varying_string),
INTENT(OUT) :: error
1998 TYPE(control_loop_type),
POINTER :: control_loop
2000 enters(
"PROBLEM_SOLVE",err,error,*999)
2002 IF(
ASSOCIATED(problem))
THEN 2003 IF(problem%PROBLEM_FINISHED)
THEN 2004 control_loop=>problem%CONTROL_LOOP
2005 IF(
ASSOCIATED(control_loop))
THEN 2006 CALL problem_control_loop_solve(control_loop,err,error,*999)
2008 CALL flagerror(
"Problem control loop is not associated.",err,error,*999)
2011 CALL flagerror(
"Problem has not been finished.",err,error,*999)
2014 CALL flagerror(
"Problem is not associated",err,error,*999)
2017 exits(
"PROBLEM_SOLVE")
2019 999 errorsexits(
"PROBLEM_SOLVE",err,error)
2021 END SUBROUTINE problem_solve
2028 SUBROUTINE problem_solver_load_increment_apply(SOLVER_EQUATIONS,ITERATION_NUMBER,MAXIMUM_NUMBER_OF_ITERATIONS,ERR,ERROR,*)
2031 TYPE(solver_equations_type),
POINTER :: solver_equations
2032 INTEGER(INTG),
INTENT(IN) :: iteration_number
2033 INTEGER(INTG),
INTENT(IN) :: maximum_number_of_iterations
2034 INTEGER(INTG),
INTENT(OUT) :: err
2035 TYPE(varying_string),
INTENT(OUT) :: error
2037 TYPE(solver_mapping_type),
POINTER :: solver_mapping
2038 TYPE(equations_set_type),
POINTER :: equations_set
2039 INTEGER(INTG) :: equations_set_idx
2041 enters(
"PROBLEM_SOLVER_LOAD_INCREMENT_APPLY",err,error,*999)
2043 IF(
ASSOCIATED(solver_equations))
THEN 2044 solver_mapping=>solver_equations%SOLVER_MAPPING
2045 IF(
ASSOCIATED(solver_mapping))
THEN 2047 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
2048 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
2049 CALL equations_set_load_increment_apply(equations_set,solver_equations%BOUNDARY_CONDITIONS,iteration_number, &
2050 & maximum_number_of_iterations,err,error,*999)
2053 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
2056 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
2059 exits(
"PROBLEM_SOLVER_LOAD_INCREMENT_APPLY")
2061 999 errorsexits(
"PROBLEM_SOLVER_LOAD_INCREMENT_APPLY",err,error)
2064 END SUBROUTINE problem_solver_load_increment_apply
2071 SUBROUTINE problem_control_loop_pre_loop(CONTROL_LOOP,ERR,ERROR,*)
2074 TYPE(control_loop_type),
POINTER :: control_loop
2075 INTEGER(INTG),
INTENT(OUT) :: err
2076 TYPE(varying_string),
INTENT(OUT) :: error
2078 TYPE(varying_string) :: local_error
2080 enters(
"PROBLEM_CONTROL_LOOP_PRE_LOOP",err,error,*999)
2082 IF(
ASSOCIATED(control_loop))
THEN 2083 IF(
ASSOCIATED(control_loop%PROBLEM))
THEN 2085 IF(control_loop%LOOP_TYPE==problem_control_time_loop_type)
THEN 2086 CALL problem_control_loop_previous_values_update(control_loop,err,error,*999)
2088 IF(.NOT.
ALLOCATED(control_loop%PROBLEM%SPECIFICATION))
THEN 2089 CALL flagerror(
"Problem specification is not allocated.",err,error,*999)
2090 ELSE IF(
SIZE(control_loop%PROBLEM%SPECIFICATION,1)<1)
THEN 2091 CALL flagerror(
"Problem specification must have at least one entry.",err,error,*999)
2093 SELECT CASE(control_loop%PROBLEM%SPECIFICATION(1))
2094 CASE(problem_elasticity_class)
2095 CALL elasticity_control_loop_pre_loop(control_loop,err,error,*999)
2096 CASE(problem_bioelectrics_class)
2098 CASE(problem_fluid_mechanics_class)
2099 CALL fluid_mechanics_control_loop_pre_loop(control_loop,err,error,*999)
2100 CASE(problem_electromagnetics_class)
2102 CASE(problem_classical_field_class)
2104 CASE(problem_fitting_class)
2106 CASE(problem_modal_class)
2108 CASE(problem_multi_physics_class)
2109 CALL multi_physics_control_loop_pre_loop(control_loop,err,error,*999)
2111 local_error=
"Problem class "//trim(number_to_vstring(control_loop%PROBLEM%SPECIFICATION(1),
"*",err,error))//
" & 2113 CALL flagerror(local_error,err,error,*999)
2116 CALL flagerror(
"Problem is not associated.",err,error,*999)
2119 CALL flagerror(
"Control loop is not associated.",err,error,*999)
2121 exits(
"PROBLEM_CONTROL_LOOP_PRE_LOOP")
2123 999 errorsexits(
"PROBLEM_CONTROL_LOOP_PRE_LOOP",err,error)
2125 END SUBROUTINE problem_control_loop_pre_loop
2132 SUBROUTINE problem_control_loop_post_loop(CONTROL_LOOP,ERR,ERROR,*)
2135 TYPE(control_loop_type),
POINTER :: control_loop
2136 INTEGER(INTG),
INTENT(OUT) :: err
2137 TYPE(varying_string),
INTENT(OUT) :: error
2139 TYPE(varying_string) :: local_error
2141 enters(
"PROBLEM_CONTROL_LOOP_POST_LOOP",err,error,*999)
2143 IF(
ASSOCIATED(control_loop))
THEN 2144 IF(
ASSOCIATED(control_loop%PROBLEM))
THEN 2145 IF(.NOT.
ALLOCATED(control_loop%PROBLEM%SPECIFICATION))
THEN 2146 CALL flagerror(
"Problem specification is not allocated.",err,error,*999)
2147 ELSE IF(
SIZE(control_loop%PROBLEM%SPECIFICATION,1)<1)
THEN 2148 CALL flagerror(
"Problem specification must have at least one entry.",err,error,*999)
2150 SELECT CASE(control_loop%PROBLEM%SPECIFICATION(1))
2151 CASE(problem_elasticity_class)
2152 CALL elasticity_controllooppostloop(control_loop,err,error,*999)
2153 CASE(problem_bioelectrics_class)
2154 CALL bioelectric_control_loop_post_loop(control_loop,err,error,*999)
2155 CASE(problem_fluid_mechanics_class)
2156 CALL fluid_mechanics_control_loop_post_loop(control_loop,err,error,*999)
2157 CASE(problem_electromagnetics_class)
2159 CASE(problem_classical_field_class)
2160 IF(
SIZE(control_loop%PROBLEM%SPECIFICATION,1)<2)
THEN 2161 CALL flagerror(
"Problem specification must have at least two entries.",err,error,*999)
2163 CALL classical_field_control_loop_post_loop(control_loop,err,error,*999)
2164 SELECT CASE(control_loop%PROBLEM%SPECIFICATION(2))
2165 CASE(problem_reaction_diffusion_equation_type)
2166 CALL reaction_diffusion_control_loop_post_loop(control_loop,err,error,*999)
2170 CASE(problem_fitting_class)
2172 CASE(problem_modal_class)
2174 CASE(problem_multi_physics_class)
2175 CALL multi_physics_control_loop_post_loop(control_loop,err,error,*999)
2177 local_error=
"The first problem specification of "// &
2178 & trim(numbertovstring(control_loop%problem%specification(1),
"*",err,error))// &
2180 CALL flagerror(local_error,err,error,*999)
2183 CALL flagerror(
"Problem is not associated.",err,error,*999)
2186 CALL flagerror(
"Control loop is not associated.",err,error,*999)
2189 exits(
"PROBLEM_CONTROL_LOOP_POST_LOOP")
2191 999 errorsexits(
"PROBLEM_CONTROL_LOOP_POST_LOOP",err,error)
2194 END SUBROUTINE problem_control_loop_post_loop
2201 SUBROUTINE problem_solver_pre_solve(SOLVER,ERR,ERROR,*)
2204 TYPE(solver_type),
POINTER :: solver
2205 INTEGER(INTG),
INTENT(OUT) :: err
2206 TYPE(varying_string),
INTENT(OUT) :: error
2208 TYPE(control_loop_type),
POINTER :: control_loop
2209 TYPE(problem_type),
POINTER :: problem
2210 TYPE(solvers_type),
POINTER :: solvers
2211 TYPE(varying_string) :: local_error
2213 enters(
"PROBLEM_SOLVER_PRE_SOLVE",err,error,*999)
2215 IF(
ASSOCIATED(solver))
THEN 2216 solvers=>solver%SOLVERS
2217 IF(
ASSOCIATED(solvers))
THEN 2218 control_loop=>solvers%CONTROL_LOOP
2219 IF(
ASSOCIATED(control_loop))
THEN 2220 problem=>control_loop%PROBLEM
2221 IF(
ASSOCIATED(problem))
THEN 2222 IF(.NOT.
ALLOCATED(problem%SPECIFICATION))
THEN 2223 CALL flagerror(
"Problem specification is not allocated.",err,error,*999)
2224 ELSE IF(
SIZE(problem%SPECIFICATION,1)<1)
THEN 2225 CALL flagerror(
"Problem specification must have at least one entry.",err,error,*999)
2227 SELECT CASE(problem%SPECIFICATION(1))
2228 CASE(problem_elasticity_class)
2229 CALL elasticity_pre_solve(control_loop,solver,err,error,*999)
2230 CASE(problem_bioelectrics_class)
2231 CALL bioelectric_pre_solve(solver,err,error,*999)
2232 CASE(problem_fluid_mechanics_class)
2233 CALL fluid_mechanics_pre_solve(control_loop,solver,err,error,*999)
2234 CASE(problem_electromagnetics_class)
2236 CASE(problem_classical_field_class)
2237 CALL classical_field_pre_solve(control_loop,solver,err,error,*999)
2238 CASE(problem_fitting_class)
2239 CALL fitting_pre_solve(control_loop,solver,err,error,*999)
2240 CASE(problem_modal_class)
2242 CASE(problem_multi_physics_class)
2243 CALL multi_physics_pre_solve(control_loop,solver,err,error,*999)
2245 local_error=
"The problem class of "//trim(number_to_vstring(problem%SPECIFICATION(1),
"*",err,error))//
" & 2247 CALL flagerror(local_error,err,error,*999)
2250 CALL flagerror(
"Control loop problem is not associated.",err,error,*999)
2253 CALL flagerror(
"Solvers control loop is not associated.",err,error,*999)
2256 CALL flagerror(
"Solver solvers is not associated.",err,error,*999)
2259 CALL flagerror(
"Solver is not associated.",err,error,*999)
2262 exits(
"PROBLEM_SOLVER_PRE_SOLVE")
2264 999 errorsexits(
"PROBLEM_SOLVER_PRE_SOLVE",err,error)
2266 END SUBROUTINE problem_solver_pre_solve
2273 SUBROUTINE problem_solver_post_solve(SOLVER,ERR,ERROR,*)
2276 TYPE(solver_type),
POINTER :: solver
2277 INTEGER(INTG),
INTENT(OUT) :: err
2278 TYPE(varying_string),
INTENT(OUT) :: error
2280 TYPE(control_loop_type),
POINTER :: control_loop
2281 TYPE(problem_type),
POINTER :: problem
2282 TYPE(solvers_type),
POINTER :: solvers
2283 TYPE(varying_string) :: local_error
2285 enters(
"PROBLEM_SOLVER_POST_SOLVE",err,error,*999)
2287 IF(
ASSOCIATED(solver))
THEN 2288 solvers=>solver%SOLVERS
2289 IF(
ASSOCIATED(solvers))
THEN 2290 control_loop=>solvers%CONTROL_LOOP
2291 IF(
ASSOCIATED(control_loop))
THEN 2292 problem=>control_loop%PROBLEM
2293 IF(
ASSOCIATED(problem))
THEN 2294 IF(.NOT.
ALLOCATED(problem%SPECIFICATION))
THEN 2295 CALL flagerror(
"Problem specification is not allocated.",err,error,*999)
2296 ELSE IF(
SIZE(problem%SPECIFICATION,1)<1)
THEN 2297 CALL flagerror(
"Problem specification must have at least one entry.",err,error,*999)
2299 SELECT CASE(problem%SPECIFICATION(1))
2300 CASE(problem_elasticity_class)
2301 CALL elasticity_post_solve(control_loop,solver,err,error,*999)
2302 CASE(problem_bioelectrics_class)
2303 CALL bioelectric_post_solve(solver,err,error,*999)
2304 CASE(problem_fluid_mechanics_class)
2305 CALL fluid_mechanics_post_solve(control_loop,solver,err,error,*999)
2306 CASE(problem_electromagnetics_class)
2308 CASE(problem_classical_field_class)
2310 CALL classical_field_post_solve(control_loop,solver,err,error,*999)
2311 CASE(problem_fitting_class)
2312 CALL fitting_post_solve(control_loop,solver,err,error,*999)
2313 CASE(problem_modal_class)
2315 CASE(problem_multi_physics_class)
2316 CALL multi_physics_post_solve(control_loop,solver,err,error,*999)
2318 local_error=
"The problem class of "//trim(number_to_vstring(control_loop%PROBLEM%SPECIFICATION(1),
"*",err,error))//
" & 2320 CALL flagerror(local_error,err,error,*999)
2323 CALL flagerror(
"Control loop problem is not associated.",err,error,*999)
2326 CALL flagerror(
"Solvers control loop is not associated.",err,error,*999)
2329 CALL flagerror(
"Solver solvers is not associated.",err,error,*999)
2332 CALL flagerror(
"Solver is not associated.",err,error,*999)
2335 exits(
"PROBLEM_SOLVER_POST_SOLVE")
2337 999 errorsexits(
"PROBLEM_SOLVER_POST_SOLVE",err,error)
2340 END SUBROUTINE problem_solver_post_solve
2347 SUBROUTINE problem_solver_equations_solve(SOLVER_EQUATIONS,ERR,ERROR,*)
2350 TYPE(solver_equations_type),
POINTER :: solver_equations
2351 INTEGER(INTG),
INTENT(OUT) :: err
2352 TYPE(varying_string),
INTENT(OUT) :: error
2354 TYPE(varying_string) :: local_error
2356 enters(
"PROBLEM_SOLVER_EQUATIONS_SOLVE",err,error,*999)
2358 IF(
ASSOCIATED(solver_equations))
THEN 2359 IF(solver_equations%SOLVER_EQUATIONS_FINISHED)
THEN 2360 SELECT CASE(solver_equations%TIME_DEPENDENCE)
2361 CASE(solver_equations_static)
2362 SELECT CASE(solver_equations%LINEARITY)
2363 CASE(solver_equations_linear)
2364 CALL problem_solverequationsstaticlinearsolve(solver_equations,err,error,*999)
2365 CASE(solver_equations_nonlinear)
2366 CALL problem_solverequationsstaticnonlinearsolve(solver_equations,err,error,*999)
2368 local_error=
"The solver equations linearity of "//trim(number_to_vstring(solver_equations%LINEARITY,
"*",err,error))// &
2370 CALL flagerror(local_error,err,error,*999)
2372 CASE(solver_equations_quasistatic)
2373 SELECT CASE(solver_equations%LINEARITY)
2374 CASE(solver_equations_linear)
2375 CALL problem_solverequationsquasistaticlinearsolve(solver_equations,err,error,*999)
2376 CASE(solver_equations_nonlinear)
2377 CALL problem_solverequationsquasistaticnonlinearsolve(solver_equations,err,error,*999)
2379 local_error=
"The solver equations linearity of "//trim(number_to_vstring(solver_equations%LINEARITY,
"*",err,error))// &
2381 CALL flagerror(local_error,err,error,*999)
2383 CASE(solver_equations_first_order_dynamic,solver_equations_second_order_dynamic)
2384 SELECT CASE(solver_equations%LINEARITY)
2385 CASE(solver_equations_linear)
2386 CALL problem_solverequationsdynamiclinearsolve(solver_equations,err,error,*999)
2387 CASE(solver_equations_nonlinear)
2388 CALL problem_solverequationsdynamicnonlinearsolve(solver_equations,err,error,*999)
2390 local_error=
"The solver equations linearity of "//trim(number_to_vstring(solver_equations%LINEARITY,
"*",err,error))// &
2392 CALL flagerror(local_error,err,error,*999)
2395 local_error=
"The solver equations time dependence type of "// &
2396 & trim(number_to_vstring(solver_equations%TIME_DEPENDENCE,
"*",err,error))//
" is invalid." 2397 CALL flagerror(local_error,err,error,*999)
2400 CALL flagerror(
"Solver equations have not been finished.",err,error,*999)
2403 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
2406 exits(
"PROBLEM_SOLVER_EQUATIONS_SOLVE")
2408 999 errorsexits(
"PROBLEM_SOLVER_EQUATIONS_SOLVE",err,error)
2410 END SUBROUTINE problem_solver_equations_solve
2417 SUBROUTINE problem_solverequationsdynamiclinearsolve(SOLVER_EQUATIONS,ERR,ERROR,*)
2420 TYPE(solver_equations_type),
POINTER :: solver_equations
2421 INTEGER(INTG),
INTENT(OUT) :: err
2422 TYPE(varying_string),
INTENT(OUT) :: error
2424 INTEGER(INTG) :: equations_set_idx,loop_idx
2425 REAL(DP) :: current_time,time_increment
2426 TYPE(control_loop_type),
POINTER :: control_loop,control_time_loop
2427 TYPE(equations_set_type),
POINTER :: equations_set
2428 TYPE(solver_type),
POINTER :: solver
2429 TYPE(solver_mapping_type),
POINTER :: solver_mapping
2430 TYPE(solvers_type),
POINTER :: solvers
2432 enters(
"Problem_SolverEquationsDynamicLinearSolve",err,error,*999)
2434 IF(
ASSOCIATED(solver_equations))
THEN 2435 solver=>solver_equations%SOLVER
2436 IF(
ASSOCIATED(solver))
THEN 2437 solvers=>solver%SOLVERS
2438 IF(
ASSOCIATED(solvers))
THEN 2439 control_loop=>solvers%CONTROL_LOOP
2440 IF(
ASSOCIATED(control_loop))
THEN 2441 solver_mapping=>solver_equations%SOLVER_MAPPING
2442 IF(
ASSOCIATED(solver_mapping))
THEN 2444 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
2445 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
2447 CALL equations_set_assemble(equations_set,err,error,*999)
2451 control_time_loop=>control_loop
2452 DO loop_idx=1,control_loop%CONTROL_LOOP_LEVEL
2453 IF(control_time_loop%LOOP_TYPE==problem_control_time_loop_type)
THEN 2454 CALL control_loop_current_times_get(control_time_loop,current_time,time_increment,err,error,*999)
2457 IF(
ASSOCIATED(control_loop%PARENT_LOOP))
THEN 2458 control_time_loop=>control_time_loop%PARENT_LOOP
2460 CALL flagerror(
"Could not find a time control loop.",err,error,*999)
2464 CALL solver_dynamic_times_set(solver,current_time,time_increment,err,error,*999)
2466 CALL solver_solve(solver,err,error,*999)
2468 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
2469 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
2470 CALL equations_set_backsubstitute(equations_set,solver_equations%BOUNDARY_CONDITIONS,err,error,*999)
2473 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
2476 CALL flagerror(
"Solvers control loop is not associated.",err,error,*999)
2479 CALL flagerror(
"Solver solvers is not associated.",err,error,*999)
2482 CALL flagerror(
"Solver equations solver is not associated.",err,error,*999)
2485 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
2488 exits(
"Problem_SolverEquationsDynamicLinearSolve")
2490 999 errorsexits(
"Problem_SolverEquationsDynamicLinearSolve",err,error)
2493 END SUBROUTINE problem_solverequationsdynamiclinearsolve
2500 SUBROUTINE problem_solverequationsdynamicnonlinearsolve(SOLVER_EQUATIONS,ERR,ERROR,*)
2503 TYPE(solver_equations_type),
POINTER :: solver_equations
2504 INTEGER(INTG),
INTENT(OUT) :: err
2505 TYPE(varying_string),
INTENT(OUT) :: error
2507 INTEGER(INTG) :: equations_set_idx,loop_idx,interface_condition_idx
2508 REAL(DP) :: current_time,time_increment
2509 TYPE(control_loop_type),
POINTER :: control_loop,control_time_loop
2510 TYPE(equations_type),
POINTER :: equations
2511 TYPE(equations_set_type),
POINTER :: equations_set
2512 TYPE(interface_condition_type),
POINTER :: interface_condition
2513 TYPE(solver_type),
POINTER :: solver
2514 TYPE(dynamic_solver_type),
POINTER :: dynamic_solver
2515 TYPE(solver_mapping_type),
POINTER :: solver_mapping
2516 TYPE(solvers_type),
POINTER :: solvers
2517 TYPE(varying_string) :: local_error
2519 enters(
"Problem_SolverEquationsDynamicNonlinearSolve",err,error,*999)
2521 IF(
ASSOCIATED(solver_equations))
THEN 2522 solver=>solver_equations%SOLVER
2523 IF(
ASSOCIATED(solver))
THEN 2524 dynamic_solver=>solver%DYNAMIC_SOLVER
2525 IF(
ASSOCIATED(dynamic_solver))
THEN 2526 solvers=>solver%SOLVERS
2527 IF(
ASSOCIATED(solver))
THEN 2528 control_loop=>solvers%CONTROL_LOOP
2529 IF(
ASSOCIATED(control_loop))
THEN 2530 solver_mapping=>solver_equations%SOLVER_MAPPING
2531 IF(
ASSOCIATED(solver_mapping))
THEN 2532 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
2533 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
2534 IF(dynamic_solver%RESTART.OR..NOT.dynamic_solver%SOLVER_INITIALISED) then
2536 equations=>equations_set%EQUATIONS
2537 IF(
ASSOCIATED(equations))
THEN 2538 SELECT CASE(equations%LINEARITY)
2539 CASE(equations_linear)
2541 CALL equations_set_assemble(equations_set,err,error,*999)
2542 CASE(equations_nonlinear)
2544 CALL equations_set_residual_evaluate(equations_set,err,error,*999)
2545 CASE(equations_nonlinear_bcs)
2546 CALL flagerror(
"Not implemented.",err,error,*999)
2548 local_error=
"The equations linearity type of "// &
2549 & trim(number_to_vstring(equations%LINEARITY,
"*",err,error))// &
2551 CALL flagerror(local_error,err,error,*999)
2554 CALL flagerror(
"Equations set equations is not associated.",err,error,*999)
2559 DO interface_condition_idx=1,solver_mapping%NUMBER_OF_INTERFACE_CONDITIONS
2560 interface_condition=>solver_mapping%INTERFACE_CONDITIONS(interface_condition_idx)%PTR
2561 CALL interface_condition_assemble(interface_condition,err,error,*999)
2565 control_time_loop=>control_loop
2566 DO loop_idx=1,control_loop%CONTROL_LOOP_LEVEL
2567 IF(control_time_loop%LOOP_TYPE==problem_control_time_loop_type)
THEN 2568 CALL control_loop_current_times_get(control_time_loop,current_time,time_increment,err,error,*999)
2571 IF(
ASSOCIATED(control_loop%PARENT_LOOP))
THEN 2572 control_time_loop=>control_time_loop%PARENT_LOOP
2574 CALL flagerror(
"Could not find a time control loop.",err,error,*999)
2578 CALL solver_dynamic_times_set(solver,current_time,time_increment,err,error,*999)
2580 CALL solver_solve(solver,err,error,*999)
2582 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
2585 CALL flagerror(
"Solvers control loop is not associated.",err,error,*999)
2588 CALL flagerror(
"Solver solvers is not associated.",err,error,*999)
2591 CALL flagerror(
"Solver dynamic solver is not associated.",err,error,*999)
2594 CALL flagerror(
"Solver equations solver is not associated.",err,error,*999)
2597 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
2600 exits(
"Problem_SolverEquationsDynamicNonlinearSolve")
2602 999 errors(
"Problem_SolverEquationsDynamicNonlinearSolve",err,error)
2603 exits(
"Problem_SolverEquationsDynamicNonlinearSolve")
2606 END SUBROUTINE problem_solverequationsdynamicnonlinearsolve
2613 SUBROUTINE problem_solverequationsquasistaticlinearsolve(SOLVER_EQUATIONS,ERR,ERROR,*)
2616 TYPE(solver_equations_type),
POINTER :: solver_equations
2617 INTEGER(INTG),
INTENT(OUT) :: err
2618 TYPE(varying_string),
INTENT(OUT) :: error
2620 INTEGER(INTG) :: equations_set_idx
2622 TYPE(control_loop_type),
POINTER :: control_loop
2623 TYPE(equations_set_type),
POINTER :: equations_set
2624 TYPE(solver_type),
POINTER :: solver
2625 TYPE(solver_mapping_type),
POINTER :: solver_mapping
2626 TYPE(solvers_type),
POINTER :: solvers
2628 enters(
"Problem_SolverEquationsQuasistaticLinearSolve",err,error,*999)
2630 IF(
ASSOCIATED(solver_equations))
THEN 2631 solver=>solver_equations%SOLVER
2632 IF(
ASSOCIATED(solver))
THEN 2633 solvers=>solver%SOLVERS
2634 IF(
ASSOCIATED(solvers))
THEN 2635 control_loop=>solvers%CONTROL_LOOP
2636 IF(
ASSOCIATED(control_loop))
THEN 2637 solver_mapping=>solver_equations%SOLVER_MAPPING
2638 IF(
ASSOCIATED(solver_mapping))
THEN 2640 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
2641 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
2644 CALL equations_set_assemble(equations_set,err,error,*999)
2649 CALL solver_solve(solver,err,error,*999)
2651 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
2652 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
2653 CALL equations_set_backsubstitute(equations_set,solver_equations%BOUNDARY_CONDITIONS,err,error,*999)
2656 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
2659 CALL flagerror(
"Solvers control loop is not associated.",err,error,*999)
2662 CALL flagerror(
"Solver solvers is not associated.",err,error,*999)
2665 CALL flagerror(
"Solver equations solver is not associated.",err,error,*999)
2668 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
2671 exits(
"Problem_SolverEquationsQuasistaticLinearSolve")
2673 999 errors(
"Problem_SolverEquationsQuasistaticLinearSolve",err,error)
2674 exits(
"Problem_SolverEquationsQuasistaticLinearSolve")
2677 END SUBROUTINE problem_solverequationsquasistaticlinearsolve
2684 SUBROUTINE problem_solverequationsquasistaticnonlinearsolve(SOLVER_EQUATIONS,ERR,ERROR,*)
2687 TYPE(solver_equations_type),
POINTER :: solver_equations
2688 INTEGER(INTG),
INTENT(OUT) :: err
2689 TYPE(varying_string),
INTENT(OUT) :: error
2691 INTEGER(INTG) :: equations_set_idx
2692 TYPE(control_loop_type),
POINTER :: control_loop
2693 TYPE(equations_set_type),
POINTER :: equations_set
2694 TYPE(solver_type),
POINTER :: solver
2695 TYPE(solver_mapping_type),
POINTER :: solver_mapping
2696 TYPE(solvers_type),
POINTER :: solvers
2698 enters(
"Problem_SolverEquationsQuasistaticNonlinearSolve",err,error,*999)
2700 IF(
ASSOCIATED(solver_equations))
THEN 2701 solver=>solver_equations%SOLVER
2702 IF(
ASSOCIATED(solver))
THEN 2703 solvers=>solver%SOLVERS
2704 IF(
ASSOCIATED(solvers))
THEN 2705 control_loop=>solvers%CONTROL_LOOP
2706 IF(
ASSOCIATED(control_loop))
THEN 2707 solver_mapping=>solver_equations%SOLVER_MAPPING
2708 IF(
ASSOCIATED(solver_mapping))
THEN 2710 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
2711 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
2714 CALL equations_set_assemble(equations_set,err,error,*999)
2722 CALL solver_solve(solver,err,error,*999)
2724 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
2727 CALL flagerror(
"Solvers control loop is not associated.",err,error,*999)
2730 CALL flagerror(
"Solver solvers is not associated.",err,error,*999)
2733 CALL flagerror(
"Solver equations solver is not associated.",err,error,*999)
2736 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
2739 exits(
"Problem_SolverEquationsQuasistaticNonlinearSolve")
2741 999 errors(
"Problem_SolverEquationsQuasistaticNonlinearSolve",err,error)
2742 exits(
"Problem_SolverEquationsQuasistaticNonlinearSolve")
2745 END SUBROUTINE problem_solverequationsquasistaticnonlinearsolve
2752 SUBROUTINE problem_solverequationsstaticlinearsolve(SOLVER_EQUATIONS,ERR,ERROR,*)
2755 TYPE(solver_equations_type),
POINTER :: solver_equations
2756 INTEGER(INTG),
INTENT(OUT) :: err
2757 TYPE(varying_string),
INTENT(OUT) :: error
2759 INTEGER(INTG) :: equations_set_idx,interface_condition_idx
2760 TYPE(equations_set_type),
POINTER :: equations_set
2761 TYPE(interface_condition_type),
POINTER :: interface_condition
2762 TYPE(solver_type),
POINTER :: solver
2763 TYPE(solver_mapping_type),
POINTER :: solver_mapping
2766 CHARACTER(12) :: cvar
2767 INTEGER :: phase(2) = [ 0, 0 ]
2771 enters(
"Problem_SolverEquationsStaticLinearSolve",err,error,*999)
2773 IF(
ASSOCIATED(solver_equations))
THEN 2774 solver=>solver_equations%SOLVER
2775 IF(
ASSOCIATED(solver))
THEN 2776 solver_mapping=>solver_equations%SOLVER_MAPPING
2777 IF(
ASSOCIATED(solver_mapping))
THEN 2779 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
2781 WRITE (cvar,
'(a8,i2)')
'Assemble',equations_set_idx
2782 CALL tau_phase_create_dynamic(phase,cvar)
2783 CALL tau_phase_start(phase)
2785 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
2788 CALL equations_set_assemble(equations_set,err,error,*999)
2790 CALL tau_phase_stop(phase)
2794 DO interface_condition_idx=1,solver_mapping%NUMBER_OF_INTERFACE_CONDITIONS
2796 WRITE (cvar,
'(a8,i2)')
'Interface',interface_condition_idx
2797 CALL tau_phase_create_dynamic(phase,cvar)
2798 CALL tau_phase_start(phase)
2800 interface_condition=>solver_mapping%INTERFACE_CONDITIONS(interface_condition_idx)%PTR
2801 CALL interface_condition_assemble(interface_condition,err,error,*999)
2803 CALL tau_phase_stop(phase)
2808 CALL solver_solve(solver,err,error,*999)
2811 CALL tau_static_phase_start(
'EQUATIONS_SET_BACKSUBSTITUTE()')
2814 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
2815 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
2816 CALL equations_set_backsubstitute(equations_set,solver_equations%BOUNDARY_CONDITIONS,err,error,*999)
2819 CALL tau_static_phase_stop(
'EQUATIONS_SET_BACKSUBSTITUTE()')
2822 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
2825 CALL flagerror(
"Solver equations solver is not associated.",err,error,*999)
2828 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
2831 exits(
"Problem_SolverEquationsStaticLinearSolve")
2833 999 errorsexits(
"Problem_SolverEquationsStaticLinearSolve",err,error)
2836 END SUBROUTINE problem_solverequationsstaticlinearsolve
2843 SUBROUTINE problem_solverequationsstaticnonlinearsolve(SOLVER_EQUATIONS,ERR,ERROR,*)
2846 TYPE(solver_equations_type),
POINTER :: solver_equations
2847 INTEGER(INTG),
INTENT(OUT) :: err
2848 TYPE(varying_string),
INTENT(OUT) :: error
2850 INTEGER(INTG) :: equations_set_idx,interface_condition_idx
2851 TYPE(equations_set_type),
POINTER :: equations_set
2852 TYPE(equations_type),
POINTER :: equations
2853 TYPE(interface_condition_type),
POINTER :: interface_condition
2854 TYPE(solver_type),
POINTER :: solver
2855 TYPE(solver_mapping_type),
POINTER :: solver_mapping
2858 CHARACTER(12) :: cvar
2859 INTEGER :: phase(2) = [ 0, 0 ]
2862 enters(
"Problem_SolverEquationsStaticNonlinearSolve",err,error,*999)
2864 IF(
ASSOCIATED(solver_equations))
THEN 2865 solver=>solver_equations%SOLVER
2866 IF(
ASSOCIATED(solver))
THEN 2867 solver_mapping=>solver_equations%SOLVER_MAPPING
2868 IF(
ASSOCIATED(solver_mapping))
THEN 2870 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
2871 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
2873 CALL equations_set_assemble(equations_set,err,error,*999)
2876 DO interface_condition_idx=1,solver_mapping%NUMBER_OF_INTERFACE_CONDITIONS
2878 WRITE (cvar,
'(a8,i2)')
'Interface',interface_condition_idx
2879 CALL tau_phase_create_dynamic(phase,cvar)
2880 CALL tau_phase_start(phase)
2882 interface_condition=>solver_mapping%INTERFACE_CONDITIONS(interface_condition_idx)%PTR
2883 CALL interface_condition_assemble(interface_condition,err,error,*999)
2885 CALL tau_phase_stop(phase)
2889 CALL solver_solve(solver,err,error,*999)
2892 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
2893 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
2894 equations=>equations_set%EQUATIONS
2895 IF(
ASSOCIATED(equations))
THEN 2896 SELECT CASE(equations%LINEARITY)
2897 CASE(equations_linear,equations_nonlinear_bcs)
2898 CALL equations_set_backsubstitute(equations_set,solver_equations%BOUNDARY_CONDITIONS,err,error,*999)
2899 CASE(equations_nonlinear)
2900 CALL equations_set_nonlinear_rhs_update(equations_set,solver_equations%BOUNDARY_CONDITIONS,err,error,*999)
2902 CALL flagerror(
"Invalid linearity for equations set equations",err,error,*999)
2905 CALL flagerror(
"Equations set equations is not associated.",err,error,*999)
2909 CALL flagerror(
"Solver equations solver mapping not associated.",err,error,*999)
2912 CALL flagerror(
"Solver equations solver is not associated.",err,error,*999)
2915 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
2918 exits(
"Problem_SolverEquationsStaticNonlinearSolve")
2920 999 errorsexits(
"Problem_SolverEquationsStaticNonlinearSolve",err,error)
2923 END SUBROUTINE problem_solverequationsstaticnonlinearsolve
2931 SUBROUTINE problem_solver_solve(SOLVER,ERR,ERROR,*)
2934 TYPE(solver_type),
POINTER :: solver
2935 INTEGER(INTG),
INTENT(OUT) :: err
2936 TYPE(varying_string),
INTENT(OUT) :: error
2939 enters(
"PROBLEM_SOLVER_SOLVE",err,error,*999)
2941 IF(
ASSOCIATED(solver))
THEN 2943 IF(solver%OUTPUT_TYPE>=solver_progress_output)
THEN 2944 CALL write_string(general_output_type,
"",err,error,*999)
2945 CALL write_string_value(general_output_type,
"Solver: ",solver%LABEL,err,error,*999)
2946 CALL write_string_value(general_output_type,
" Solver index = ",solver%GLOBAL_NUMBER,err,error,*999)
2950 CALL tau_static_phase_start(
'Pre solve')
2952 CALL problem_solver_pre_solve(solver,err,error,*999)
2954 CALL tau_static_phase_stop(
'Pre solve')
2956 CALL tau_static_phase_start(
'Solve')
2959 IF(
ASSOCIATED(solver%SOLVER_EQUATIONS))
THEN 2961 CALL problem_solver_equations_solve(solver%SOLVER_EQUATIONS,err,error,*999)
2964 IF(
ASSOCIATED(solver%CELLML_EQUATIONS))
THEN 2966 CALL problem_cellml_equations_solve(solver%CELLML_EQUATIONS,err,error,*999)
2967 ELSEIF(solver%SOLVE_TYPE==solver_geometric_transformation_type)
THEN 2968 CALL problem_solvergeometrictransformationsolve(solver%geometricTransformationSolver,err,error,*999)
2970 CALL flagerror(
"Solver does not have any equations associated.",err,error,*999)
2975 CALL tau_static_phase_stop(
'Solve')
2977 CALL tau_static_phase_start(
'Post solve')
2979 CALL problem_solver_post_solve(solver,err,error,*999)
2981 CALL tau_static_phase_stop(
'Post solve')
2985 CALL flagerror(
"Solver is not associated.",err,error,*999)
2988 exits(
"PROBLEM_SOLVER_SOLVE")
2990 999 errorsexits(
"PROBLEM_SOLVER_SOLVE",err,error)
2993 END SUBROUTINE problem_solver_solve
3000 SUBROUTINE problem_solvers_destroy(PROBLEM,ERR,ERROR,*)
3003 TYPE(problem_type),
POINTER :: problem
3004 INTEGER(INTG),
INTENT(OUT) :: err
3005 TYPE(varying_string),
INTENT(OUT) :: error
3008 enters(
"PROBLEM_SOLVERS_DESTROY",err,error,*999)
3010 IF(
ASSOCIATED(problem))
THEN 3011 IF(
ASSOCIATED(problem%CONTROL_LOOP))
THEN 3012 CALL control_loop_solvers_destroy(problem%CONTROL_LOOP,err,error,*999)
3014 CALL flagerror(
"Problem control loop is not associated.",err,error,*999)
3017 CALL flagerror(
"Problem is not associated.",err,error,*999)
3020 exits(
"PROBLEM_SOLVERS_DESTROY")
3022 999 errorsexits(
"PROBLEM_SOLVERS_DESTROY",err,error)
3024 END SUBROUTINE problem_solvers_destroy
3031 SUBROUTINE problem_solverequationsboundaryconditionsanalytic(SOLVER_EQUATIONS,ERR,ERROR,*)
3034 TYPE(solver_equations_type),
POINTER :: solver_equations
3035 INTEGER(INTG),
INTENT(OUT) :: err
3036 TYPE(varying_string),
INTENT(OUT) :: error
3038 INTEGER(INTG) :: equations_set_idx
3039 TYPE(boundary_conditions_type),
POINTER :: boundary_conditions
3040 TYPE(solver_mapping_type),
POINTER :: solver_mapping
3041 TYPE(equations_set_type),
POINTER :: equations_set
3043 enters(
"Problem_SolverEquationsBoundaryConditionsAnalytic",err,error,*999)
3045 IF(
ASSOCIATED(solver_equations))
THEN 3046 IF(solver_equations%SOLVER_EQUATIONS_FINISHED)
THEN 3047 boundary_conditions=>solver_equations%BOUNDARY_CONDITIONS
3048 IF(
ASSOCIATED(boundary_conditions))
THEN 3049 solver_mapping=>solver_equations%SOLVER_MAPPING
3050 IF(
ASSOCIATED(solver_mapping))
THEN 3051 DO equations_set_idx=1,solver_mapping%NUMBER_OF_EQUATIONS_SETS
3052 equations_set=>solver_mapping%EQUATIONS_SETS(equations_set_idx)%PTR
3053 IF(
ASSOCIATED(equations_set))
THEN 3054 CALL equations_set_boundary_conditions_analytic(equations_set,boundary_conditions,err,error,*999)
3056 CALL flagerror(
"Equations set is not associated for index "//trim(number_to_vstring(equations_set_idx,
"*", &
3057 & err,error))//
".",err,error,*999)
3061 CALL flagerror(
"Solver equations solver mapping is not associated.",err,error,*999)
3064 CALL flagerror(
"Solver equations boundary conditions are not associated.",err,error,*999)
3067 CALL flagerror(
"Solver equations has not been finished.",err,error,*999)
3070 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
3073 exits(
"Problem_SolverEquationsBoundaryConditionsAnalytic")
3075 999 errors(
"Problem_SolverEquationsBoundaryConditionsAnalytic",err,error)
3076 exits(
"Problem_SolverEquationsBoundaryConditionsAnalytic")
3079 END SUBROUTINE problem_solverequationsboundaryconditionsanalytic
3086 SUBROUTINE problem_solver_equations_create_finish(PROBLEM,ERR,ERROR,*)
3089 TYPE(problem_type),
POINTER :: problem
3090 INTEGER(INTG),
INTENT(OUT) :: err
3091 TYPE(varying_string),
INTENT(OUT) :: error
3093 TYPE(problem_setup_type) :: problem_setup_info
3095 enters(
"PROBLEM_SOLVER_EQUATIONS_CREATE_FINISH",err,error,*999)
3097 IF(
ASSOCIATED(problem))
THEN 3099 CALL problem_setup_initialise(problem_setup_info,err,error,*999)
3100 problem_setup_info%SETUP_TYPE=problem_setup_solver_equations_type
3101 problem_setup_info%ACTION_TYPE=problem_setup_finish_action
3103 CALL problem_setup(problem,problem_setup_info,err,error,*999)
3105 CALL problem_setup_finalise(problem_setup_info,err,error,*999)
3107 CALL flagerror(
"Problem is not associated.",err,error,*999)
3110 exits(
"PROBLEM_SOLVER_EQUATIONS_CREATE_FINISH")
3112 999 errorsexits(
"PROBLEM_SOLVER_EQUATIONS_CREATE_FINISH",err,error)
3114 END SUBROUTINE problem_solver_equations_create_finish
3125 SUBROUTINE problem_solver_equations_create_start(PROBLEM,ERR,ERROR,*)
3128 TYPE(problem_type),
POINTER :: problem
3129 INTEGER(INTG),
INTENT(OUT) :: err
3130 TYPE(varying_string),
INTENT(OUT) :: error
3132 TYPE(problem_setup_type) :: problem_setup_info
3134 enters(
"PROBLEM_SOLVER_EQUATIONS_CREATE_START",err,error,*999)
3136 IF(
ASSOCIATED(problem))
THEN 3138 CALL problem_setup_initialise(problem_setup_info,err,error,*999)
3139 problem_setup_info%SETUP_TYPE=problem_setup_solver_equations_type
3140 problem_setup_info%ACTION_TYPE=problem_setup_start_action
3142 CALL problem_setup(problem,problem_setup_info,err,error,*999)
3144 CALL problem_setup_finalise(problem_setup_info,err,error,*999)
3146 CALL flagerror(
"Problem is not associated.",err,error,*999)
3149 exits(
"PROBLEM_SOLVER_EQUATIONS_CREATE_START")
3151 999 errorsexits(
"PROBLEM_SOLVER_EQUATIONS_CREATE_START",err,error)
3153 END SUBROUTINE problem_solver_equations_create_start
3162 SUBROUTINE problem_solver_equations_destroy(PROBLEM,ERR,ERROR,*)
3165 TYPE(problem_type),
POINTER :: problem
3166 INTEGER(INTG),
INTENT(OUT) :: err
3167 TYPE(varying_string),
INTENT(OUT) :: error
3169 TYPE(control_loop_type),
POINTER :: control_loop
3171 enters(
"PROBLEM_SOLVER_EQUATIONS_DESTROY",err,error,*999)
3173 IF(
ASSOCIATED(problem))
THEN 3174 control_loop=>problem%CONTROL_LOOP
3175 IF(
ASSOCIATED(control_loop))
THEN 3176 CALL control_loop_solver_equations_destroy(control_loop,err,error,*999)
3178 CALL flagerror(
"Problem control loop is not associated.",err,error,*999)
3181 CALL flagerror(
"Problem is not associated.",err,error,*999)
3184 exits(
"PROBLEM_SOLVER_EQUATIONS_DESTROY")
3186 999 errorsexits(
"PROBLEM_SOLVER_EQUATIONS_DESTROY",err,error)
3188 END SUBROUTINE problem_solver_equations_destroy
3195 SUBROUTINE problem_solvergeometrictransformationsolve(geometricTransformationSolver,err,error,*) !\todo: Add rotation operations.
3198 TYPE(geometrictransformationsolvertype),
POINTER :: geometrictransformationsolver
3199 INTEGER(INTG),
INTENT(OUT) :: err
3200 TYPE(varying_string),
INTENT(OUT) :: error
3202 TYPE(field_variable_type),
POINTER :: fieldvariable
3203 TYPE(solver_type),
POINTER :: solver
3204 TYPE(solvers_type),
POINTER :: solvers
3205 TYPE(control_loop_type),
POINTER :: controlloop
3206 TYPE(control_loop_load_increment_type),
POINTER :: loadincrementloop
3207 TYPE(control_loop_simple_type),
POINTER :: simpleloop
3208 TYPE(control_loop_fixed_type),
POINTER :: fixedloop
3209 TYPE(control_loop_while_type),
POINTER :: whileloop
3210 INTEGER(INTG) :: componentidx,versionidx,derivativeidx,nodeidx,nogeomcomp
3211 INTEGER(INTG) :: localnodenumber,usernodenumber,incrementidx,iterationnumber
3212 REAL(DP) :: nodalparameters(3),nodalparameterstrans(3),transformationmatrix(4,4)
3213 TYPE(domain_type),
POINTER :: domain
3214 TYPE(domain_nodes_type),
POINTER :: domainnodes
3215 LOGICAL :: transformbc=.false.,samebases=.true.
3217 enters(
"Problem_SolverGeometricTransformationSolve",err,error,*999)
3219 IF(
ASSOCIATED(geometrictransformationsolver))
THEN 3220 IF(
ASSOCIATED(geometrictransformationsolver%field))
THEN 3221 fieldvariable=>geometrictransformationsolver%field%VARIABLE_TYPE_MAP(geometrictransformationsolver%fieldVariableType)%PTR
3222 IF(
ASSOCIATED(fieldvariable%PARAMETER_SETS%SET_TYPE(field_boundary_conditions_set_type)%PTR)) transformbc=.true.
3223 nogeomcomp=
SIZE(geometrictransformationsolver%transformationMatrices,1)-1
3226 IF(geometrictransformationsolver%numberOfIncrements>1)
THEN 3227 solver=>geometrictransformationsolver%solver
3228 IF(
ASSOCIATED(solver))
THEN 3229 solvers=>solver%SOLVERS
3230 IF(
ASSOCIATED(solvers))
THEN 3231 controlloop=>solvers%CONTROL_LOOP
3232 IF(
ASSOCIATED(controlloop))
THEN 3233 SELECT CASE(controlloop%LOOP_TYPE)
3234 CASE(problem_control_simple_type)
3235 simpleloop=>controlloop%SIMPLE_LOOP
3236 IF(
ASSOCIATED(simpleloop))
THEN 3239 CALL flagerror(
"Simple loop is not associated.",err,error,*999)
3241 CASE(problem_control_fixed_loop_type)
3242 fixedloop=>controlloop%FIXED_LOOP
3243 IF(
ASSOCIATED(fixedloop))
THEN 3244 iterationnumber=fixedloop%ITERATION_NUMBER
3246 CALL flagerror(
"Fixed loop is not associated.",err,error,*999)
3248 CASE(problem_control_time_loop_type)
3249 CALL flagerror(
"Geometric transformation for time loop is not implemented.",err,error,*999)
3250 CASE(problem_control_while_loop_type)
3251 whileloop=>controlloop%WHILE_LOOP
3252 IF(
ASSOCIATED(whileloop))
THEN 3253 iterationnumber=whileloop%ITERATION_NUMBER
3255 CALL flagerror(
"Simple loop is not associated.",err,error,*999)
3257 CASE(problem_control_load_increment_loop_type)
3258 loadincrementloop=>controlloop%LOAD_INCREMENT_LOOP
3259 IF(
ASSOCIATED(loadincrementloop))
THEN 3260 iterationnumber=loadincrementloop%ITERATION_NUMBER
3262 CALL flagerror(
"Load increment loop is not associated.",err,error,*999)
3265 IF(iterationnumber>geometrictransformationsolver%numberOfIncrements)
THEN 3267 incrementidx=mod(iterationnumber-1,geometrictransformationsolver%numberOfIncrements)+1
3269 incrementidx=iterationnumber
3272 CALL flagerror(
"Control loop is not associated.",err,error,*999)
3275 CALL flagerror(
"Solvers is not associated.",err,error,*999)
3278 CALL flagerror(
"Solver is not associated.",err,error,*999)
3284 IF(geometrictransformationsolver%arbitraryPath .OR. geometrictransformationsolver%numberOfIncrements==1)
THEN 3285 transformationmatrix(1:nogeomcomp+1,1:nogeomcomp+1)=geometrictransformationsolver%transformationMatrices &
3286 & (1:nogeomcomp+1,1:nogeomcomp+1,incrementidx)
3288 IF(incrementidx==1)
THEN 3289 transformationmatrix(1:nogeomcomp,1:nogeomcomp)=geometrictransformationsolver%transformationMatrices &
3290 & (1:nogeomcomp,1:nogeomcomp,1)
3292 DO componentidx=1,nogeomcomp
3293 transformationmatrix(componentidx,componentidx)=1.0_dp
3297 IF(
ALLOCATED(geometrictransformationsolver%scalings))
THEN 3298 transformationmatrix(1:nogeomcomp,nogeomcomp+1)=geometrictransformationsolver%transformationMatrices &
3299 & (1:nogeomcomp,nogeomcomp+1,1)*geometrictransformationsolver%scalings(incrementidx)
3301 transformationmatrix(1:nogeomcomp,nogeomcomp+1)=geometrictransformationsolver%transformationMatrices &
3302 & (1:nogeomcomp,nogeomcomp+1,1)/geometrictransformationsolver%numberOfIncrements
3308 DO componentidx=1,nogeomcomp-1
3309 IF(fieldvariable%COMPONENTS(componentidx)%MESH_COMPONENT_NUMBER/= &
3310 & fieldvariable%COMPONENTS(componentidx+1)%MESH_COMPONENT_NUMBER) samebases=.false.
3313 domain=>fieldvariable%COMPONENTS(1)%DOMAIN
3314 IF(
ASSOCIATED(domain))
THEN 3315 domainnodes=>domain%TOPOLOGY%NODES
3316 DO nodeidx=1,domainnodes%NUMBER_OF_NODES
3317 localnodenumber=domainnodes%NODES(nodeidx)%LOCAL_NUMBER
3318 usernodenumber=domainnodes%NODES(nodeidx)%USER_NUMBER
3319 DO derivativeidx=1,domainnodes%NODES(nodeidx)%NUMBER_OF_DERIVATIVES
3320 DO versionidx=1,domainnodes%NODES(nodeidx)%DERIVATIVES(derivativeidx)%numberOfVersions
3321 DO componentidx=1,nogeomcomp
3322 CALL field_parameter_set_get_node(geometrictransformationsolver%field,geometrictransformationsolver% &
3323 & fieldvariabletype,field_values_set_type,versionidx,derivativeidx,usernodenumber,componentidx, &
3324 & nodalparameters(componentidx),err,error,*999)
3327 usernodenumber=domainnodes%NODES(nodeidx)%USER_NUMBER
3328 nodalparameterstrans(1:nogeomcomp)=matmul(transformationmatrix(1:nogeomcomp,1:nogeomcomp), &
3329 & nodalparameters(1:nogeomcomp))
3330 DO componentidx=1,nogeomcomp
3331 CALL field_parameter_set_update_node(geometrictransformationsolver%field,geometrictransformationsolver% &
3332 & fieldvariabletype,field_values_set_type,versionidx,derivativeidx,usernodenumber,componentidx, &
3333 & nodalparameterstrans(componentidx),err,error,*999)
3334 IF(derivativeidx==1)
THEN 3335 CALL field_parameter_set_add_node(geometrictransformationsolver%field,geometrictransformationsolver% &
3336 & fieldvariabletype,field_values_set_type,versionidx,derivativeidx,usernodenumber,componentidx, &
3337 & transformationmatrix(componentidx,1+nogeomcomp),err,error,*999)
3339 IF(transformbc)
THEN 3340 CALL field_parameter_set_update_node(geometrictransformationsolver%field,geometrictransformationsolver% &
3341 & fieldvariabletype,field_boundary_conditions_set_type,versionidx,derivativeidx,usernodenumber, &
3342 & componentidx,nodalparameterstrans(componentidx),err,error,*999)
3343 IF(derivativeidx==1)
THEN 3344 CALL field_parameter_set_add_node(geometrictransformationsolver%field,geometrictransformationsolver% &
3345 & fieldvariabletype,field_boundary_conditions_set_type,versionidx,derivativeidx,usernodenumber, &
3346 & componentidx,transformationmatrix(componentidx,1+nogeomcomp),err,error,*999)
3354 CALL flagerror(
"Domain is not associated.",err,error,*999)
3357 CALL flagerror(
"Transformation for different component bases not implemented.",err,error,*999)
3360 CALL flagerror(
"The field of geometric transformation solver is not associated.",err,error,*999)
3363 CALL flagerror(
"Geometric transformation solver is not associated.",err,error,*999)
3366 exits(
"Problem_SolverGeometricTransformationSolve")
3368 999 errorsexits(
"Problem_SolverGeometricTransformationSolve",err,error)
3370 END SUBROUTINE problem_solvergeometrictransformationsolve
3377 SUBROUTINE problem_solver_get_0(PROBLEM,CONTROL_LOOP_IDENTIFIER,SOLVER_INDEX,SOLVER,ERR,ERROR,*)
3380 TYPE(problem_type),
POINTER :: problem
3381 INTEGER(INTG),
INTENT(IN) :: control_loop_identifier
3382 INTEGER(INTG),
INTENT(IN) :: solver_index
3383 TYPE(solver_type),
POINTER :: solver
3384 INTEGER(INTG),
INTENT(OUT) :: err
3385 TYPE(varying_string),
INTENT(OUT) :: error
3388 enters(
"PROBLEM_SOLVER_GET_0",err,error,*999)
3390 CALL problem_solver_get_1(problem,[control_loop_identifier],solver_index,solver,err,error,*999)
3392 exits(
"PROBLEM_SOLVER_GET_0")
3394 999 errorsexits(
"PROBLEM_SOLVER_GET_0",err,error)
3396 END SUBROUTINE problem_solver_get_0
3403 SUBROUTINE problem_solver_get_1(PROBLEM,CONTROL_LOOP_IDENTIFIER,SOLVER_INDEX,SOLVER,ERR,ERROR,*)
3406 TYPE(problem_type),
POINTER :: problem
3407 INTEGER(INTG),
INTENT(IN) :: control_loop_identifier(:)
3408 INTEGER(INTG),
INTENT(IN) :: solver_index
3409 TYPE(solver_type),
POINTER :: solver
3410 INTEGER(INTG),
INTENT(OUT) :: err
3411 TYPE(varying_string),
INTENT(OUT) :: error
3413 TYPE(control_loop_type),
POINTER :: control_loop,control_loop_root
3414 TYPE(solvers_type),
POINTER :: solvers
3415 TYPE(varying_string) :: local_error
3417 enters(
"PROBLEM_SOLVER_GET_1",err,error,*998)
3419 IF(
ASSOCIATED(problem))
THEN 3420 IF(
ASSOCIATED(solver))
THEN 3421 CALL flagerror(
"Solver is already associated.",err,error,*998)
3423 control_loop_root=>problem%CONTROL_LOOP
3424 IF(
ASSOCIATED(control_loop_root))
THEN 3425 NULLIFY(control_loop)
3426 CALL control_loop_get(control_loop_root,control_loop_identifier,control_loop,err,error,*999)
3427 solvers=>control_loop%SOLVERS
3428 IF(
ASSOCIATED(solvers))
THEN 3429 IF(solver_index>0.AND.solver_index<=solvers%NUMBER_OF_SOLVERS)
THEN 3430 solver=>solvers%SOLVERS(solver_index)%PTR
3431 IF(.NOT.
ASSOCIATED(solver))
CALL flagerror(
"Solvers solver is not associated.",err,error,*999)
3433 local_error=
"The specified solver index of "//trim(number_to_vstring(solver_index,
"*",err,error))// &
3434 &
" is invalid. The index must be > 0 and <= "// &
3435 & trim(number_to_vstring(solvers%NUMBER_OF_SOLVERS,
"*",err,error))//
"." 3436 CALL flagerror(local_error,err,error,*999)
3439 CALL flagerror(
"Control loop solvers is not associated.",err,error,*999)
3442 CALL flagerror(
"Problem control loop is not associated.",err,error,*999)
3446 CALL flagerror(
"Problem is not associated.",err,error,*998)
3449 exits(
"PROBLEM_SOLVER_GET_1")
3452 998 errorsexits(
"PROBLEM_SOLVER_GET_1",err,error)
3454 END SUBROUTINE problem_solver_get_1
3461 SUBROUTINE problem_solvernonlinearmonitor(solver,iterationNumber,residualNorm,err,error,*)
3464 TYPE(solver_type),
POINTER :: solver
3465 INTEGER(INTG),
INTENT(IN) :: iterationnumber
3466 REAL(DP),
INTENT(IN) :: residualnorm
3467 INTEGER(INTG),
INTENT(OUT) :: err
3468 TYPE(varying_string),
INTENT(OUT) :: error
3470 INTEGER(INTG) :: interfaceconditionidx
3471 TYPE(solvers_type),
POINTER :: solvers
3472 TYPE(control_loop_type),
POINTER :: controlloop
3473 TYPE(problem_type),
POINTER :: problem
3474 TYPE(nonlinear_solver_type),
POINTER :: nonlinearsolver
3475 TYPE(solver_equations_type),
POINTER :: solverequations
3476 TYPE(solver_mapping_type),
POINTER :: solvermapping
3477 TYPE(interface_condition_type),
POINTER :: interfacecondition
3478 TYPE(interface_type),
POINTER :: interface
3479 LOGICAL :: reproject
3480 TYPE(varying_string) :: localerror
3482 enters(
"Problem_SolverNonlinearMonitor",err,error,*998)
3484 IF(
ASSOCIATED(solver))
THEN 3485 solvers=>solver%SOLVERS
3486 IF(
ASSOCIATED(solvers))
THEN 3487 controlloop=>solvers%CONTROL_LOOP
3488 IF(
ASSOCIATED(controlloop))
THEN 3489 problem=>controlloop%PROBLEM
3490 IF(
ASSOCIATED(problem))
THEN 3491 IF(.NOT.
ALLOCATED(problem%specification))
THEN 3492 CALL flagerror(
"Problem specification is not allocated.",err,error,*999)
3493 ELSE IF(
SIZE(problem%specification,1)<1)
THEN 3494 CALL flagerror(
"Problem specification must have at least one entry.",err,error,*999)
3496 SELECT CASE(problem%SPECIFICATION(1))
3497 CASE(problem_elasticity_class)
3498 IF(
SIZE(problem%specification,1)/=3)
THEN 3499 CALL flagerror(
"Problem specification must have three entries for an elasticity problem.",err,error,*999)
3501 SELECT CASE(problem%SPECIFICATION(2))
3502 CASE(problem_linear_elasticity_type,problem_finite_elasticity_type)
3504 IF(solver%SOLVE_TYPE==solver_nonlinear_type)
THEN 3505 nonlinearsolver=>solver%NONLINEAR_SOLVER
3506 IF(
ASSOCIATED(nonlinearsolver))
THEN 3507 CALL problem_solvernewtonfieldsoutput(solver,iterationnumber,err,error,*999)
3510 CASE(problem_linear_elasticity_contact_type,problem_finite_elasticity_contact_type)
3511 SELECT CASE(problem%SPECIFICATION(3))
3512 CASE(problem_le_contact_transform_subtype,problem_fe_contact_transform_subtype)
3513 IF(iterationnumber==0)
THEN 3518 CASE(problem_le_contact_transform_reproject_subtype,problem_le_contact_reproject_subtype, &
3519 & problem_fe_contact_transform_reproject_subtype,problem_fe_contact_reproject_subtype)
3522 localerror=
"The problem subtype of "//trim(number_to_vstring(problem%SPECIFICATION(3),
"*",err,error))//
" & 3524 CALL flagerror(localerror,err,error,*999)
3527 solverequations=>solver%SOLVER_EQUATIONS
3528 IF(
ASSOCIATED(solverequations))
THEN 3529 solvermapping=>solverequations%SOLVER_MAPPING
3530 IF(
ASSOCIATED(solvermapping))
THEN 3531 DO interfaceconditionidx=1,solvermapping%NUMBER_OF_INTERFACE_CONDITIONS
3532 interfacecondition=>solvermapping%INTERFACE_CONDITIONS(interfaceconditionidx)%PTR
3533 IF(
ASSOCIATED(interfacecondition))
THEN 3534 IF(interfacecondition%OPERATOR==interface_condition_fls_contact_reproject_operator .OR. &
3535 & interfacecondition%OPERATOR==interface_condition_fls_contact_operator)
THEN 3536 IF(interfacecondition%integrationType==interface_condition_data_points_integration)
THEN 3537 interface=>interfacecondition%INTERFACE
3538 IF(
ASSOCIATED(interface))
THEN 3539 CALL write_string(general_output_type,
"**************** Reproject! ****************",err,error,*999)
3540 CALL interfacepointsconnectivity_datareprojection(interface,interfacecondition,err,error,*999)
3541 CALL interface_condition_assemble(interfacecondition,err,error,*999)
3543 CALL flagerror(
"Interface is not associated for nonlinear solver equations mapping.", &
3549 CALL flagerror(
"Interface condition is not associated for nonlinear solver equations mapping.", &
3554 CALL flagerror(
"Nonlinear solver equations mapping is not associated.",err,error,*999)
3557 CALL flagerror(
"Nonlinear solver equations is not associated.",err,error,*999)
3561 IF(solver%SOLVE_TYPE==solver_nonlinear_type)
THEN 3562 nonlinearsolver=>solver%NONLINEAR_SOLVER
3563 IF(
ASSOCIATED(nonlinearsolver))
THEN 3564 CALL problem_solvernewtonfieldsoutput(solver,iterationnumber,err,error,*999)
3568 localerror=
"The problem type of "//trim(number_to_vstring(problem%SPECIFICATION(2),
"*",err,error))//
" & 3570 CALL flagerror(localerror,err,error,*999)
3572 CASE(problem_bioelectrics_class,problem_fluid_mechanics_class,problem_electromagnetics_class, &
3573 & problem_classical_field_class,problem_fitting_class,problem_modal_class,problem_multi_physics_class)
3576 localerror=
"The problem class of "//trim(number_to_vstring(problem%SPECIFICATION(1),
"*",err,error))//
" & 3578 CALL flagerror(localerror,err,error,*999)
3581 CALL flagerror(
"Problem is not associated.",err,error,*999)
3584 CALL flagerror(
"Problem control loop is not associated.",err,error,*999)
3588 IF(solver%SOLVE_TYPE==solver_nonlinear_type)
THEN 3589 nonlinearsolver=>solver%NONLINEAR_SOLVER
3590 IF(
ASSOCIATED(nonlinearsolver))
THEN 3591 CALL solver_nonlinear_monitor(nonlinearsolver,iterationnumber,residualnorm,err,error,*999)
3593 CALL flagerror(
"Nonlinear solver is not associated.",err,error,*999)
3596 localerror=
"Invalid solve type. The solve type of "//trim(number_to_vstring(solver%SOLVE_TYPE,
"*",err,error))// &
3597 &
" does not correspond to a nonlinear solver." 3598 CALL flagerror(localerror,err,error,*999)
3601 CALL flagerror(
"Solver is not associated.",err,error,*999)
3604 exits(
"Problem_SolverNonlinearMonitor")
3607 998 errorsexits(
"Problem_SolverNonlinearMonitor",err,error)
3609 END SUBROUTINE problem_solvernonlinearmonitor
3616 SUBROUTINE problem_solvernewtonfieldsoutput(solver,iterationNumber,err,error,*)
3619 TYPE(solver_type),
POINTER :: solver
3620 INTEGER(INTG),
INTENT(IN) :: iterationnumber
3621 INTEGER(INTG),
INTENT(OUT) :: err
3622 TYPE(varying_string),
INTENT(OUT) :: error
3624 INTEGER(INTG) :: equationssetidx,load_step
3625 LOGICAL :: direxists
3626 TYPE(region_type),
POINTER :: region
3627 TYPE(solver_mapping_type),
POINTER :: solvermapping
3628 TYPE(fields_type),
POINTER :: fields
3629 TYPE(varying_string) :: filename,method,directory
3631 INTEGER(INTG) :: interfaceconditionidx, interfaceelementnumber, datapointidx, globaldatapointnumber, coupledmeshelementnumber, &
3632 & coupledMeshFaceLineNumber, coupledMeshIdx,component
3633 TYPE(interface_type),
POINTER :: interface
3634 TYPE(interface_condition_type),
POINTER :: interfacecondition
3635 TYPE(interfacepointsconnectivitytype),
POINTER :: pointsconnectivity
3636 TYPE(field_type),
POINTER :: coupledmeshdependentfield
3637 TYPE(field_interpolation_parameters_ptr_type),
POINTER :: interpolationparameters(:)
3638 TYPE(field_interpolated_point_ptr_type),
POINTER :: interpolatedpoints(:)
3639 TYPE(field_interpolated_point_type),
POINTER :: interpolatedpoint
3640 TYPE(decompositionelementdatapointstype),
POINTER :: decompositionelementdata
3641 TYPE(data_points_type),
POINTER :: interfacedatapoints
3642 TYPE(data_projection_type),
POINTER :: dataprojection
3644 TYPE(problem_type),
POINTER :: problem
3646 INTEGER(INTG) :: iunit
3647 CHARACTER(LEN=100) :: filenameoutput,groupname
3649 TYPE(varying_string) :: filetocheck,localerror
3650 LOGICAL :: fileexists
3651 INTEGER(INTG) :: firstiterationnumber, solve_call, max_solve_calls
3653 enters(
"Problem_SolverNewtonFieldsOutput",err,error,*999)
3655 IF(
ASSOCIATED(solver%SOLVER_EQUATIONS))
THEN 3656 solvermapping=>solver%SOLVER_EQUATIONS%SOLVER_MAPPING
3657 problem=>solver%SOLVERS%CONTROL_LOOP%PROBLEM
3659 IF(.NOT.
ALLOCATED(problem%SPECIFICATION))
THEN 3660 CALL flagerror(
"Problem specification is not allocated.",err,error,*999)
3661 ELSE IF(
SIZE(problem%SPECIFICATION,1)<1)
THEN 3662 CALL flagerror(
"Problem specification must have at least one entry.",err,error,*999)
3664 SELECT CASE(problem%SPECIFICATION(1))
3665 CASE(problem_elasticity_class)
3666 IF(
SIZE(problem%specification,1)/=3)
THEN 3667 CALL flagerror(
"Problem specification must have three entries for an elasticity problem.",err,error,*999)
3669 SELECT CASE(problem%SPECIFICATION(2))
3670 CASE(problem_linear_elasticity_type,problem_finite_elasticity_type,problem_linear_elasticity_contact_type, &
3671 & problem_finite_elasticity_contact_type)
3673 IF(diagnostics1)
THEN 3674 directory=
"results_iter/" 3675 INQUIRE(file=char(directory),exist=direxists)
3676 IF(.NOT.direxists)
THEN 3677 CALL system(char(
"mkdir "//directory))
3684 firstiterationnumber=0
3685 DO solve_call=1,max_solve_calls
3686 filetocheck=directory// &
3687 &
"mesh"//trim(number_to_vstring(coupledmeshidx,
"*",err,error))// &
3688 &
"_solveCall"//trim(number_to_vstring(solve_call,
"*",err,error))// &
3689 &
"_load"//trim(number_to_vstring(load_step,
"*",err,error))// &
3690 &
"_iter"//trim(number_to_vstring(firstiterationnumber,
"*",err,error))//
".part0.exnode" 3691 INQUIRE(file=char(filetocheck),exist=fileexists)
3692 IF(.NOT.fileexists)
THEN 3697 load_step=solver%SOLVERS%CONTROL_LOOP%LOAD_INCREMENT_LOOP%ITERATION_NUMBER
3699 IF((iterationnumber > 0).OR.(load_step > 1))
THEN 3700 solve_call = solve_call - 1
3703 WRITE(*,
'(1X,''SolveCall: '',I4)') solve_call
3704 WRITE(*,
'(1X,'' LoadStep: '',I4)') load_step
3705 WRITE(*,
'(1X,'' Iteration: '',I4)') iterationnumber
3707 DO equationssetidx=1,solvermapping%NUMBER_OF_EQUATIONS_SETS
3708 region=>solvermapping%EQUATIONS_SETS(equationssetidx)%PTR%REGION
3709 IF(
ASSOCIATED(region))
THEN 3711 fields=>region%FIELDS
3712 filename=directory//
"mesh"//trim(number_to_vstring(equationssetidx,
"*",err,error))// &
3713 &
"_solveCall"//trim(number_to_vstring(solve_call,
"*",err,error))// &
3714 &
"_load"//trim(number_to_vstring(load_step,
"*",err,error))// &
3715 &
"_iter"//trim(number_to_vstring(iterationnumber,
"*",err,error))
3717 CALL field_io_elements_export(fields,filename,method,err,error,*999)
3718 CALL field_io_nodes_export(fields,filename,method,err,error,*999)
3720 CALL flagerror(
"Region is not associated.",err,error,*999)
3726 localerror=
"The problem type of "//trim(number_to_vstring(problem%SPECIFICATION(2),
"*",err,error))//
" & 3728 CALL flagerror(localerror,err,error,*999)
3730 CASE(problem_bioelectrics_class,problem_fluid_mechanics_class,problem_electromagnetics_class, &
3731 & problem_classical_field_class,problem_fitting_class,problem_modal_class,problem_multi_physics_class)
3734 localerror=
"The problem class of "//trim(number_to_vstring(problem%SPECIFICATION(1),
"*",err,error))//
" & 3736 CALL flagerror(localerror,err,error,*999)
3739 SELECT CASE(problem%SPECIFICATION(1))
3740 CASE(problem_elasticity_class)
3741 SELECT CASE(problem%SPECIFICATION(2))
3742 CASE(problem_linear_elasticity_type,problem_finite_elasticity_type)
3744 CASE(problem_linear_elasticity_contact_type,problem_finite_elasticity_contact_type)
3746 IF(diagnostics1)
THEN 3748 DO interfaceconditionidx=1,solvermapping%NUMBER_OF_INTERFACE_CONDITIONS
3749 interfacecondition=>solvermapping%INTERFACE_CONDITIONS(interfaceconditionidx)%PTR
3750 interface=>solvermapping%INTERFACE_CONDITIONS(interfaceconditionidx)%PTR%interface
3751 pointsconnectivity=>interface%pointsConnectivity
3752 interfacedatapoints=>interface%DATA_POINTS
3753 IF(
ASSOCIATED(pointsconnectivity))
THEN 3754 DO coupledmeshidx=1,interface%NUMBER_OF_COUPLED_MESHES
3755 filenameoutput=directory//
"PointsConnectivity"//trim(number_to_vstring(coupledmeshidx,
"*",err,error))// &
3756 &
"_solveCall"//trim(number_to_vstring(solve_call,
"*",err,error))// &
3757 &
"_load"//trim(number_to_vstring(load_step,
"*",err,error))// &
3758 &
"_iter"//trim(number_to_vstring(iterationnumber,
"*",err,error))//
".exdata" 3759 OPEN(unit=iunit,file=filenameoutput,status=
"UNKNOWN",action=
"WRITE",iostat=err)
3760 groupname=
"PointsConnectivity"//trim(number_to_vstring(coupledmeshidx,
"*",err,error))
3761 WRITE(iunit,
'( '' Group name: '',A)') groupname
3762 WRITE(iunit,
'(1X,''#Fields=4'')')
3763 WRITE(iunit,
'(1X,''1) coordinates, coordinate, rectangular cartesian, #Components=3'')')
3764 WRITE(iunit,
'(1X,'' x. Value index= 1, #Derivatives=0'')')
3765 WRITE(iunit,
'(1X,'' y. Value index= 2, #Derivatives=0'')')
3766 WRITE(iunit,
'(1X,'' z. Value index= 3, #Derivatives=0'')')
3767 WRITE(iunit,
'(1X,''2) error, field, rectangular cartesian, #Components=3'')')
3768 WRITE(iunit,
'(1X,'' x. Value index= 4, #Derivatives=0'')')
3769 WRITE(iunit,
'(1X,'' y. Value index= 5, #Derivatives=0'')')
3770 WRITE(iunit,
'(1X,'' z. Value index= 6, #Derivatives=0'')')
3771 WRITE(iunit,
'(1X,''3) projectedCoordinate, field, rectangular cartesian, #Components=3'')')
3772 WRITE(iunit,
'(1X,'' x. Value index= 7, #Derivatives=0'')')
3773 WRITE(iunit,
'(1X,'' y. Value index= 8, #Derivatives=0'')')
3774 WRITE(iunit,
'(1X,'' z. Value index= 9, #Derivatives=0'')')
3775 WRITE(iunit,
'(1X,''4) exitTag, field, rectangular cartesian, #Components=1'')')
3776 WRITE(iunit,
'(1X,'' tag. Value index= 10, #Derivatives=0'')')
3777 coupledmeshdependentfield=>interfacecondition%DEPENDENT%EQUATIONS_SETS(coupledmeshidx)%PTR% &
3778 & dependent%DEPENDENT_FIELD
3779 NULLIFY(interpolationparameters)
3780 CALL field_interpolation_parameters_initialise(coupledmeshdependentfield,interpolationparameters,err,error, &
3781 & *999,field_geometric_components_type)
3782 NULLIFY(interpolatedpoints)
3783 CALL field_interpolated_points_initialise(interpolationparameters,interpolatedpoints,err,error,*999, &
3784 & field_geometric_components_type)
3785 interpolatedpoint=>interpolatedpoints(field_u_variable_type)%PTR
3786 dataprojection=>interfacedatapoints%DATA_PROJECTIONS(coupledmeshidx+1)%PTR
3787 DO interfaceelementnumber=1,
SIZE(pointsconnectivity%coupledElements,1)
3788 decompositionelementdata=>interfacecondition%LAGRANGE%LAGRANGE_FIELD%DECOMPOSITION%TOPOLOGY%dataPoints% &
3789 & elementdatapoint(interfaceelementnumber)
3790 DO datapointidx=1,decompositionelementdata%numberOfProjectedData
3791 globaldatapointnumber=decompositionelementdata%dataIndices(datapointidx)%globalNumber
3792 WRITE(iunit,
'(1X,''Node:'',I4)') globaldatapointnumber
3794 WRITE(iunit,
'(1X,3E25.15)') interfacedatapoints%DATA_POINTS(globaldatapointnumber)%position(component)
3796 coupledmeshelementnumber=pointsconnectivity%pointsConnectivity(globaldatapointnumber,coupledmeshidx)% &
3797 & coupledmeshelementnumber
3798 coupledmeshfacelinenumber=coupledmeshdependentfield%DECOMPOSITION%TOPOLOGY%ELEMENTS% &
3799 & elements(coupledmeshelementnumber)% &
3800 & element_faces(pointsconnectivity%pointsConnectivity(globaldatapointnumber,coupledmeshidx)% &
3801 & elementlinefacenumber)
3802 CALL field_interpolation_parameters_face_get(field_values_set_type,coupledmeshfacelinenumber, &
3803 & interpolationparameters(field_u_variable_type)%PTR,err,error,*999,field_geometric_components_type)
3804 CALL field_interpolate_xi(no_part_deriv,pointsconnectivity%pointsConnectivity(globaldatapointnumber, &
3805 & coupledmeshidx)%reducedXi(:),interpolatedpoint,err,error,*999,field_geometric_components_type)
3807 WRITE(iunit,
'(1X,3E25.15)') interpolatedpoint%VALUES(component,no_part_deriv) - &
3808 & interfacedatapoints%DATA_POINTS(globaldatapointnumber)%position(component)
3811 WRITE(iunit,
'(1X,3E25.15)') interpolatedpoint%VALUES(component,no_part_deriv)
3813 WRITE(iunit,
'(1X,I2)') dataprojection%DATA_PROJECTION_RESULTS(globaldatapointnumber)%EXIT_TAG
3816 CALL field_interpolation_parameters_finalise(interpolationparameters,err,error,*999)
3817 CALL field_interpolated_points_finalise(interpolatedpoints,err,error,*999)
3825 localerror=
"The problem type of "//trim(number_to_vstring(problem%SPECIFICATION(2),
"*",err,error))//
" & 3827 CALL flagerror(localerror,err,error,*999)
3829 CASE(problem_bioelectrics_class,problem_fluid_mechanics_class,problem_electromagnetics_class, &
3830 & problem_classical_field_class,problem_fitting_class,problem_modal_class,problem_multi_physics_class)
3833 localerror=
"The problem class of "//trim(number_to_vstring(problem%SPECIFICATION(1),
"*",err,error))//
" & 3835 CALL flagerror(localerror,err,error,*999)
3839 CALL flagerror(
"Solver equations is not associated.",err,error,*999)
3842 exits(
"Problem_SolverNewtonFieldsOutput")
3844 999 errorsexits(
"Problem_SolverNewtonFieldsOutput",err,error)
3846 END SUBROUTINE problem_solvernewtonfieldsoutput
3853 SUBROUTINE problem_specificationget(problem,problemSpecification,err,error,*)
3856 TYPE(problem_type),
POINTER :: problem
3857 INTEGER(INTG),
INTENT(INOUT) :: problemspecification(:)
3858 INTEGER(INTG),
INTENT(OUT) :: err
3859 TYPE(varying_string),
INTENT(OUT) :: error
3861 INTEGER(INTG) :: specificationlength
3863 enters(
"Problem_SpecificationGet",err,error,*999)
3865 IF(
ASSOCIATED(problem))
THEN 3866 IF(problem%problem_finished)
THEN 3867 IF(.NOT.
ALLOCATED(problem%specification))
THEN 3868 CALL flagerror(
"Problem specification is not allocated.",err,error,*999)
3870 specificationlength=
SIZE(problem%specification,1)
3871 IF(
SIZE(problemspecification,1)>=specificationlength)
THEN 3872 problemspecification(1:specificationlength)=problem%specification(1:specificationlength)
3874 CALL flagerror(
"The problem specification size is "//trim(numbertovstring(specificationlength,
"*",err,error))// &
3875 &
" but the input array only has size "//trim(numbertovstring(
SIZE(problemspecification,1),
"*",err,error))//
".", &
3879 CALL flagerror(
"Problem has not been finished.",err,error,*999)
3882 CALL flagerror(
"Problem is not associated.",err,error,*999)
3885 exits(
"Problem_SpecificationGet")
3887 999 errorsexits(
"Problem_SpecificationGet",err,error)
3890 END SUBROUTINE problem_specificationget
3897 SUBROUTINE problem_specificationset(problem,problemSpecification,err,error,*)
3900 TYPE(problem_type),
POINTER :: problem
3901 INTEGER(INTG),
INTENT(IN) :: problemspecification(:)
3902 INTEGER(INTG),
INTENT(OUT) :: err
3903 TYPE(varying_string),
INTENT(OUT) :: error
3905 TYPE(varying_string) :: localerror
3906 INTEGER(INTG) :: problemclass
3908 enters(
"Problem_SpecificationSet",err,error,*999)
3910 IF(
ASSOCIATED(problem))
THEN 3911 IF(problem%problem_finished)
THEN 3912 CALL flagerror(
"Problem has been finished.",err,error,*999)
3914 IF(
SIZE(problemspecification,1)<1)
THEN 3915 CALL flagerror(
"Problem specification array must have one or more entries.",err,error,*999)
3917 problemclass=problemspecification(1)
3918 SELECT CASE(problemclass)
3919 CASE(problem_elasticity_class)
3920 CALL elasticity_problemspecificationset(problem,problemspecification,err,error,*999)
3921 CASE(problem_fluid_mechanics_class)
3922 CALL fluidmechanics_problemspecificationset(problem,problemspecification,err,error,*999)
3923 CASE(problem_electromagnetics_class)
3924 CALL flagerror(
"Not implemented.",err,error,*999)
3925 CASE(problem_classical_field_class)
3926 CALL classicalfield_problemspecificationset(problem,problemspecification,err,error,*999)
3927 CASE(problem_bioelectrics_class)
3928 CALL bioelectric_problemspecificationset(problem,problemspecification,err,error,*999)
3929 CASE(problem_modal_class)
3930 CALL flagerror(
"Not implemented.",err,error,*999)
3931 CASE(problem_fitting_class)
3932 CALL fitting_problemspecificationset(problem,problemspecification,err,error,*999)
3933 CASE(problem_optimisation_class)
3934 CALL flagerror(
"Not implemented.",err,error,*999)
3935 CASE(problem_multi_physics_class)
3936 CALL multiphysics_problemspecificationset(problem,problemspecification,err,error,*999)
3938 localerror=
"The first problems specification of "//trim(numbertovstring(problemclass,
"*",err,error))//
" is not valid." 3939 CALL flagerror(localerror,err,error,*999)
3943 CALL flagerror(
"Problem is not associated.",err,error,*999)
3946 exits(
"Problem_SpecificationSet")
3948 999 errorsexits(
"Problem_SpecificationSet",err,error)
3951 END SUBROUTINE problem_specificationset
3958 SUBROUTINE problem_specificationsizeget(problem,specificationSize,err,error,*)
3961 TYPE(problem_type),
POINTER :: problem
3962 INTEGER(INTG),
INTENT(OUT) :: specificationsize
3963 INTEGER(INTG),
INTENT(OUT) :: err
3964 TYPE(varying_string),
INTENT(OUT) :: error
3967 enters(
"Problem_SpecificationSizeGet",err,error,*999)
3970 IF(
ASSOCIATED(problem))
THEN 3971 IF(problem%problem_finished)
THEN 3972 IF(.NOT.
ALLOCATED(problem%specification))
THEN 3973 CALL flagerror(
"Problem specification is not allocated.",err,error,*999)
3975 specificationsize=
SIZE(problem%specification,1)
3977 CALL flagerror(
"Problem has not been finished.",err,error,*999)
3980 CALL flagerror(
"Problem is not associated.",err,error,*999)
3983 exits(
"Problem_SpecificationSizeGet")
3985 999 errorsexits(
"Problem_SpecificationSizeGet",err,error)
3988 END SUBROUTINE problem_specificationsizeget
3995 SUBROUTINE problem_user_number_find(USER_NUMBER,PROBLEM,ERR,ERROR,*)
3998 INTEGER(INTG),
INTENT(IN) :: user_number
3999 TYPE(problem_type),
POINTER :: problem
4000 INTEGER(INTG),
INTENT(OUT) :: err
4001 TYPE(varying_string),
INTENT(OUT) :: error
4003 INTEGER(INTG) :: problem_idx
4005 enters(
"PROBLEM_USER_NUMBER_FIND",err,error,*999)
4007 IF(
ASSOCIATED(problem))
THEN 4008 CALL flagerror(
"Problem is already associated.",err,error,*999)
4011 DO WHILE(problem_idx<=problems%NUMBER_OF_PROBLEMS.AND..NOT.
ASSOCIATED(problem))
4012 IF(problems%PROBLEMS(problem_idx)%PTR%USER_NUMBER==user_number)
THEN 4013 problem=>problems%PROBLEMS(problem_idx)%PTR
4015 problem_idx=problem_idx+1
4020 exits(
"PROBLEM_USER_NUMBER_FIND")
4022 999 errorsexits(
"PROBLEM_USER_NUMBER_FIND",err,error)
4024 END SUBROUTINE problem_user_number_find
4031 SUBROUTINE problems_finalise(ERR,ERROR,*)
4034 INTEGER(INTG),
INTENT(OUT) :: err
4035 TYPE(varying_string),
INTENT(OUT) :: error
4038 enters(
"PROBLEMS_FINALISE",err,error,*999)
4040 DO WHILE(problems%NUMBER_OF_PROBLEMS>0)
4041 CALL problem_destroy(problems%PROBLEMS(1)%PTR,err,error,*999)
4044 exits(
"PROBLEMS_FINALISE")
4046 999 errorsexits(
"PROBLEMS_FINALISE",err,error)
4048 END SUBROUTINE problems_finalise
4055 SUBROUTINE problems_initialise(ERR,ERROR,*)
4058 INTEGER(INTG),
INTENT(OUT) :: err
4059 TYPE(varying_string),
INTENT(OUT) :: error
4062 enters(
"PROBLEMS_INITIALISE",err,error,*999)
4064 problems%NUMBER_OF_PROBLEMS=0
4065 NULLIFY(problems%PROBLEMS)
4067 exits(
"PROBLEMS_INITIALISE")
4069 999 errorsexits(
"PROBLEMS_INITIALISE",err,error)
4071 END SUBROUTINE problems_initialise
4078 RECURSIVE SUBROUTINE problem_control_loop_previous_values_update(CONTROL_LOOP,ERR,ERROR,*)
4081 TYPE(control_loop_type),
POINTER :: control_loop
4082 INTEGER(INTG),
INTENT(OUT) :: err
4083 TYPE(varying_string),
INTENT(OUT) :: error
4085 TYPE(solvers_type),
POINTER :: solvers
4086 TYPE(solver_type),
POINTER :: solver
4087 INTEGER(INTG) :: solver_idx
4091 enters(
"PROBLEM_CONTROL_LOOP_PREVIOUS_VALUES_UPDATE",err,error,*999)
4093 IF(
ASSOCIATED(control_loop))
THEN 4094 IF(control_loop%NUMBER_OF_SUB_LOOPS==0)
THEN 4096 solvers=>control_loop%SOLVERS
4097 IF(
ASSOCIATED(solvers))
THEN 4098 DO solver_idx=1,solvers%NUMBER_OF_SOLVERS
4099 solver=>solvers%SOLVERS(solver_idx)%PTR
4100 SELECT CASE(solver%SOLVE_TYPE)
4101 CASE(solver_dynamic_type)
4102 CALL solver_variablesdynamicfieldpreviousvaluesupdate(solver,err,error,*999)
4108 CALL flagerror(
"Control loop solvers is not associated.",err,error,*999)
4112 CALL flagerror(
"Control loop is not associated.",err,error,*999)
4115 exits(
"PROBLEM_CONTROL_LOOP_PREVIOUS_VALUES_UPDATE")
4117 999 errorsexits(
"PROBLEM_CONTROL_LOOP_PREVIOUS_VALUES_UPDATE",err,error)
4120 END SUBROUTINE problem_control_loop_previous_values_update
4127 END MODULE problem_routines
4134 SUBROUTINE problem_solverjacobianevaluatepetsc(snes,x,A,B,ctx,err)
4141 USE problem_routines
4155 INTEGER(INTG),
INTENT(INOUT) :: err
4157 INTEGER(INTG) :: dummyerr
4167 IF(
ASSOCIATED(ctx))
THEN 4168 solverequations=>ctx%SOLVER_EQUATIONS
4169 IF(
ASSOCIATED(solverequations))
THEN 4170 solvermatrices=>solverequations%SOLVER_MATRICES
4171 IF(
ASSOCIATED(solvermatrices))
THEN 4172 IF(solvermatrices%NUMBER_OF_MATRICES==1)
THEN 4173 solvermatrix=>solvermatrices%matrices(1)%ptr
4174 IF(
ASSOCIATED(solvermatrix))
THEN 4175 solvervector=>solvermatrix%SOLVER_VECTOR
4176 IF(
ASSOCIATED(solvervector))
THEN 4179 CALL problem_solver_jacobian_evaluate(ctx,err,error,*999)
4183 CALL flagerror(
"Solver vector is not associated.",err,error,*998)
4186 CALL flagerror(
"Solver matrix is not associated.",err,error,*998)
4189 localerror=
"The number of solver matrices of "// &
4191 &
" is invalid. There should be 1 solver matrix." 4192 CALL flagerror(localerror,err,error,*998)
4195 CALL flagerror(
"Solver equations solver matrices is not associated.",err,error,*998)
4198 CALL flagerror(
"Solver solver equations is not associated.",err,error,*998)
4201 nonlinearsolver=>ctx%NONLINEAR_SOLVER
4202 IF(
ASSOCIATED(nonlinearsolver))
THEN 4203 SELECT CASE(nonlinearsolver%NONLINEAR_SOLVE_TYPE)
4205 newtonsolver=>nonlinearsolver%NEWTON_SOLVER
4206 IF(
ASSOCIATED(newtonsolver))
THEN 4207 newtonsolver%TOTAL_NUMBER_OF_JACOBIAN_EVALUATIONS=newtonsolver%TOTAL_NUMBER_OF_JACOBIAN_EVALUATIONS+1
4209 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*998)
4212 quasinewtonsolver=>nonlinearsolver%QUASI_NEWTON_SOLVER
4213 IF(
ASSOCIATED(quasinewtonsolver))
THEN 4214 quasinewtonsolver%TOTAL_NUMBER_OF_JACOBIAN_EVALUATIONS=quasinewtonsolver%TOTAL_NUMBER_OF_JACOBIAN_EVALUATIONS+1
4216 CALL flagerror(
"Nonlinear solver Quasi-Newton solver is not associated.",err,error,*998)
4222 CALL flagerror(
"Solver nonlinear solver is not associated.",err,error,*998)
4225 CALL flagerror(
"Solver context is not associated.",err,error,*998)
4231 997
CALL flagwarning(
"Error evaluating nonlinear Jacobian.",err,error,*996)
4233 END SUBROUTINE problem_solverjacobianevaluatepetsc
4241 SUBROUTINE problem_solverjacobianfdcalculatepetsc(snes,x,A,B,ctx,err)
4249 USE problem_routines
4264 INTEGER(INTG),
INTENT(INOUT) :: err
4266 INTEGER(INTG) :: dummyerr
4278 IF(
ASSOCIATED(ctx))
THEN 4279 nonlinearsolver=>ctx%NONLINEAR_SOLVER
4280 IF(
ASSOCIATED(nonlinearsolver))
THEN 4281 solverequations=>ctx%SOLVER_EQUATIONS
4282 IF(
ASSOCIATED(solverequations))
THEN 4283 solvermatrices=>solverequations%SOLVER_MATRICES
4284 IF(
ASSOCIATED(solvermatrices))
THEN 4285 IF(solvermatrices%NUMBER_OF_MATRICES==1)
THEN 4286 solvermatrix=>solvermatrices%matrices(1)%ptr
4287 IF(
ASSOCIATED(solvermatrix))
THEN 4288 SELECT CASE(solverequations%SPARSITY_TYPE)
4290 SELECT CASE(nonlinearsolver%NONLINEAR_SOLVE_TYPE)
4292 newtonsolver=>nonlinearsolver%NEWTON_SOLVER
4293 IF(
ASSOCIATED(newtonsolver))
THEN 4294 linesearchsolver=>newtonsolver%LINESEARCH_SOLVER
4295 IF(
ASSOCIATED(linesearchsolver))
THEN 4296 jacobianmatfdcoloring=>linesearchsolver%jacobianMatFDColoring
4298 CALL flagerror(
"Newton solver linesearch solver is not associated.",err,error,*999)
4301 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
4304 quasinewtonsolver=>nonlinearsolver%QUASI_NEWTON_SOLVER
4305 IF(
ASSOCIATED(quasinewtonsolver))
THEN 4306 quasinewtonlinesearchsolver=>quasinewtonsolver%LINESEARCH_SOLVER
4307 IF(
ASSOCIATED(quasinewtonlinesearchsolver))
THEN 4308 jacobianmatfdcoloring=>quasinewtonlinesearchsolver%jacobianMatFDColoring
4310 CALL flagerror(
"Quasi-Newton solver linesearch solver is not associated.",err,error,*999)
4313 CALL flagerror(
"Nonlinear solver quasi Newton solver is not associated.",err,error,*999)
4316 localerror=
"The nonlinear solver type of "// &
4319 CALL flagerror(localerror,err,error,*999)
4321 IF(
ASSOCIATED(jacobianmatfdcoloring))
THEN 4324 CALL flagerror(
"Linesearch solver FD colouring is not associated.",err,error,*998)
4329 localerror=
"The specified solver equations sparsity type of "// &
4331 CALL flagerror(localerror,err,error,*999)
4339 CALL flagerror(
"Solver matrix is not associated.",err,error,*998)
4342 localerror=
"The number of solver matrices of "// &
4344 &
" is invalid. There should be 1 solver matrix." 4345 CALL flagerror(localerror,err,error,*998)
4348 CALL flagerror(
"Solver equations solver matrices is not associated.",err,error,*998)
4351 CALL flagerror(
"Solver solver equations is not associated.",err,error,*998)
4354 CALL flagerror(
"Nonlinear solver is not associated.",err,error,*998)
4357 CALL flagerror(
"Solver context is not associated.",err,error,*998)
4363 997
CALL flagwarning(
"Error evaluating nonlinear Jacobian.",err,error,*996)
4366 END SUBROUTINE problem_solverjacobianfdcalculatepetsc
4373 SUBROUTINE problem_solverresidualevaluatepetsc(snes,x,f,ctx,err)
4380 USE problem_routines
4392 INTEGER(INTG),
INTENT(INOUT) :: err
4394 INTEGER(INTG) :: dummyerr
4404 IF(
ASSOCIATED(ctx))
THEN 4405 nonlinearsolver=>ctx%NONLINEAR_SOLVER
4406 IF(
ASSOCIATED(nonlinearsolver))
THEN 4407 newtonsolver=>nonlinearsolver%NEWTON_SOLVER
4408 IF(
ASSOCIATED(newtonsolver))
THEN 4409 solverequations=>ctx%SOLVER_EQUATIONS
4410 IF(
ASSOCIATED(solverequations))
THEN 4411 solvermatrices=>solverequations%SOLVER_MATRICES
4412 IF(
ASSOCIATED(solvermatrices))
THEN 4413 IF(solvermatrices%NUMBER_OF_MATRICES==1)
THEN 4414 solvermatrix=>solvermatrices%MATRICES(1)%PTR
4415 IF(
ASSOCIATED(solvermatrix))
THEN 4416 solvervector=>solvermatrix%SOLVER_VECTOR
4417 IF(
ASSOCIATED(solvervector))
THEN 4418 residualvector=>solvermatrices%RESIDUAL
4419 IF(
ASSOCIATED(residualvector))
THEN 4423 CALL problem_solver_residual_evaluate(ctx,err,error,*999)
4428 CALL flagerror(
"Residual vector is not associated.",err,error,*997)
4431 CALL flagerror(
"Solver vector is not associated.",err,error,*997)
4434 CALL flagerror(
"Solver matrix is not associated.",err,error,*997)
4437 localerror=
"The number of solver matrices of "// &
4439 &
" is invalid. There should be 1 solver matrix." 4440 CALL flagerror(localerror,err,error,*997)
4443 CALL flagerror(
"Solver equations solver matrices is not associated.",err,error,*997)
4446 CALL flagerror(
"Solver solver equations is not associated.",err,error,*997)
4449 nonlinearsolver=>ctx%NONLINEAR_SOLVER
4450 IF(
ASSOCIATED(nonlinearsolver))
THEN 4451 SELECT CASE(nonlinearsolver%NONLINEAR_SOLVE_TYPE)
4453 newtonsolver=>nonlinearsolver%NEWTON_SOLVER
4454 IF(
ASSOCIATED(newtonsolver))
THEN 4455 newtonsolver%TOTAL_NUMBER_OF_FUNCTION_EVALUATIONS=newtonsolver%TOTAL_NUMBER_OF_FUNCTION_EVALUATIONS+1
4457 CALL flagerror(
"Newton solver is not associated.",err,error,*997)
4460 quasinewtonsolver=>nonlinearsolver%QUASI_NEWTON_SOLVER
4461 IF(
ASSOCIATED(quasinewtonsolver))
THEN 4462 quasinewtonsolver%TOTAL_NUMBER_OF_FUNCTION_EVALUATIONS=quasinewtonsolver%TOTAL_NUMBER_OF_FUNCTION_EVALUATIONS+1
4464 CALL flagerror(
"Quasi-Newton solver is not associated.",err,error,*997)
4470 CALL flagerror(
"Nonlinear solve is not associated.", err,error,*997)
4473 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*997)
4476 CALL flagerror(
"Solver nonlinear solver is not associated.",err,error,*997)
4479 CALL flagerror(
"Solver context is not associated.",err,error,*997)
4486 996
CALL flagwarning(
"Error evaluating nonlinear residual.",err,error,*995)
4489 END SUBROUTINE problem_solverresidualevaluatepetsc
4496 SUBROUTINE problem_solverconvergencetestpetsc(snes,iterationNumber,xnorm,gnorm,fnorm,reason,ctx,err)
4504 USE problem_routines
4513 INTEGER(INTG),
INTENT(INOUT) :: iterationnumber
4514 REAL(DP),
INTENT(INOUT) :: xnorm
4515 REAL(DP),
INTENT(INOUT) :: gnorm
4516 REAL(DP),
INTENT(INOUT) :: fnorm
4517 INTEGER(INTG),
INTENT(INOUT) :: reason
4519 INTEGER(INTG),
INTENT(INOUT) :: err
4526 REAL(DP) :: energy,normalisedenergy
4527 TYPE(varying_string) :: error,localerror
4529 IF(
ASSOCIATED(ctx))
THEN 4530 nonlinearsolver=>ctx%NONLINEAR_SOLVER
4531 IF(
ASSOCIATED(nonlinearsolver))
THEN 4532 SELECT CASE(nonlinearsolver%NONLINEAR_SOLVE_TYPE)
4534 newtonsolver=>nonlinearsolver%NEWTON_SOLVER
4535 IF(
ASSOCIATED(newtonsolver))
THEN 4536 reason=petsc_snes_converged_iterating
4537 SELECT CASE(newtonsolver%convergenceTestType)
4539 IF(iterationnumber>0)
THEN 4549 IF(iterationnumber==1)
THEN 4550 IF(abs(energy)<zero_tolerance)
THEN 4551 reason=petsc_snes_converged_fnorm_abs
4553 newtonsolver%convergenceTest%energyFirstIter=energy
4554 newtonsolver%convergenceTest%normalisedEnergy=1.0
4557 normalisedenergy=energy/newtonsolver%convergenceTest%energyFirstIter
4558 newtonsolver%convergenceTest%normalisedEnergy=normalisedenergy
4559 IF(abs(normalisedenergy)<newtonsolver%ABSOLUTE_TOLERANCE)
THEN 4560 reason=petsc_snes_converged_fnorm_abs
4561 newtonsolver%convergenceTest%energyFirstIter=0.0_dp
4562 newtonsolver%convergenceTest%normalisedEnergy=0.0_dp
4571 CALL flagerror(
"Differentiated ratio convergence test not implemented.",err,error,*999)
4574 & newtonsolver%convergenceTestType,
"*",err,error))//
" is invalid." 4575 CALL flagerror(localerror,err,error,*999)
4578 CALL flagerror(
"Nonlinear solver Newton solver is not associated.",err,error,*999)
4581 quasinewtonsolver=>nonlinearsolver%QUASI_NEWTON_SOLVER
4582 IF(
ASSOCIATED(quasinewtonsolver))
THEN 4583 reason=petsc_snes_converged_iterating
4584 SELECT CASE(quasinewtonsolver%convergenceTestType)
4586 IF(iterationnumber>0)
THEN 4596 IF(iterationnumber==1)
THEN 4597 IF(abs(energy)<zero_tolerance)
THEN 4598 reason=petsc_snes_converged_fnorm_abs
4600 quasinewtonsolver%convergenceTest%energyFirstIter=energy
4601 quasinewtonsolver%convergenceTest%normalisedEnergy=1.0
4604 normalisedenergy=energy/quasinewtonsolver%convergenceTest%energyFirstIter
4605 quasinewtonsolver%convergenceTest%normalisedEnergy=normalisedenergy
4606 IF(abs(normalisedenergy)<quasinewtonsolver%ABSOLUTE_TOLERANCE)
THEN 4607 reason=petsc_snes_converged_fnorm_abs
4608 quasinewtonsolver%convergenceTest%energyFirstIter=0.0_dp
4609 quasinewtonsolver%convergenceTest%normalisedEnergy=0.0_dp
4617 quasinewtonsolver%convergenceTest%energyFirstIter=0.0_dp
4618 quasinewtonsolver%convergenceTest%normalisedEnergy=0.0_dp
4621 CALL flagerror(
"Differentiated ratio convergence test not implemented.",err,error,*999)
4623 localerror=
"The specified convergence test type of "//trim(
numbertovstring( &
4624 & quasinewtonsolver%convergenceTestType,
"*",err,error))//
" is invalid." 4625 CALL flagerror(localerror,err,error,*999)
4628 CALL flagerror(
"Nonlinear solver quasi Newton solver is not associated.",err,error,*999)
4634 CALL flagerror(
"Solver nonlinear solver is not associated.",err,error,*999)
4637 CALL flagerror(
"Solver context is not associated.",err,error,*999)
4642 998
CALL flagwarning(
"Error in convergence test.",err,error,*997)
4645 END SUBROUTINE problem_solverconvergencetestpetsc
4653 SUBROUTINE problem_solverdaecellmlrhspetsc(ts,time,states,rates,ctx,err)
4658 USE problem_routines
4665 REAL(DP),
INTENT(INOUT) :: time
4669 INTEGER(INTG),
INTENT(INOUT) :: err
4673 TYPE(varying_string) :: error
4674 INTEGER(INTG) :: dofidx
4675 REAL(DP),
POINTER :: statedata(:)
4679 IF(
ASSOCIATED(ctx))
THEN 4681 IF(
ASSOCIATED(solver))
THEN 4683 IF(
ASSOCIATED(cellml))
THEN 4689 CALL problem_solverdaecellmlrhsevaluate(cellml,time,dofidx,statedata,ctx%rates,err,error,*999)
4693 CALL petsc_vecsetvalues(rates,
SIZE(statedata,1),ctx%ratesIndices,ctx%rates,petsc_insert_values,err,error,*999)
4694 CALL vecassemblybegin(rates,err,error,*999)
4695 CALL vecassemblyend(rates,err,error,*999)
4697 CALL flagerror(
"Context cellml is not associated.",err,error,*999)
4700 CALL flagerror(
"Context solver is not associated.",err,error,*999)
4703 CALL flagerror(
"Context is not associated.",err,error,*999)
4708 998
CALL flagwarning(
"Error calling Problem_SolverDAECellMLRHSPetsc routine from PETSc.",err,error,*997)
4711 END SUBROUTINE problem_solverdaecellmlrhspetsc
4719 SUBROUTINE problem_solvernonlinearmonitorpetsc(snes,iterationNumber,residualNorm,context,err)
4726 USE problem_routines
4734 INTEGER(INTG),
INTENT(INOUT) :: iterationnumber
4735 REAL(DP),
INTENT(INOUT) :: residualnorm
4737 INTEGER(INTG),
INTENT(INOUT) :: err
4743 IF(
ASSOCIATED(context))
THEN 4744 nonlinearsolver=>context%NONLINEAR_SOLVER
4745 IF(
ASSOCIATED(nonlinearsolver))
THEN 4746 solver=>nonlinearsolver%SOLVER
4747 IF(
ASSOCIATED(solver))
THEN 4748 CALL problem_solvernonlinearmonitor(solver,iterationnumber,residualnorm,err,error,*999)
4750 CALL flagerror(
"Solver is not associated.",err,error,*999)
4753 CALL flagerror(
"Solver nonlinear solver is not associated.",err,error,*999)
4756 CALL flagerror(
"Solver context is not associated.",err,error,*999)
4762 998
CALL flagwarning(
"Error evaluating nonlinear residual.",err,error,*997)
4765 END SUBROUTINE problem_solvernonlinearmonitorpetsc
subroutine, public enters(NAME, ERR, ERROR,)
Records the entry into the named procedure and initialises the error code.
subroutine, public distributed_vector_override_set_on(DISTRIBUTED_VECTOR, OVERRIDE_VECTOR, ERR, ERROR,)
Sets the override vector for a distributed vector.
Contains information about the CellML equations for a solver.
This module handles all solver matrix and rhs routines.
This module handles all problem wide constants.
This module handles all multi physics class routines.
Converts a number to its equivalent varying string representation.
This module is a CMISS buffer module to the PETSc library.
subroutine, public petsc_vecsetvalues(x, n, indices, values, insertMode, err, error,)
Buffer routine to the PETSc VecSetValues routine.
This module contains types related to the PETSc library.
Contains information on the type of solver to be used.
Contains information for a Quasi-Newton line search nonlinear solver.
This module handles all elasticity class routines.
This module contains all string manipulation and transformation routines.
Flags a warning to the user.
Contains information on the solvers to be used in a control loop.
integer(intg), parameter, public solver_full_matrices
Use fully populated solver matrices.
subroutine, public petsc_snescomputejacobiandefault(snes, x, j, b, ctx, err, error,)
Buffer routine to the PETSc SNESComputeJacobianDefault routine.
This module contains routines for timing the program.
Contains information on the problems defined.
Contains information for a field defined on a region.
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.
Contains information on a control loop.
This module provides an iso_varying_string module, conformant to the API specified in ISO/IEC 1539-2:...
integer(intg), parameter, public solver_sparse_matrices
Use sparse solver matrices.
subroutine, public petsc_snescomputejacobiandefaultcolor(snes, x, j, b, ctx, err, error,)
Buffer routine to the PETSc SNESComputeJacobianDefaultColor routine.
This module handles all classical field class routines.
integer(intg), parameter, public solver_nonlinear_quasi_newton
Sequential Quasi-Newton nonlinear solver type.
Contains information for a Newton nonlinear solver.
Contains information on the solver, cellml, dof etc. for which cellml equations are to be evaluated b...
Contains information for a nonlinear solver.
subroutine, public petsc_snesgetlinesearch(snes, lineSearch, err, error,)
Buffer routine to the PETSc SNESGetLineSearch routine.
subroutine, public distributed_matrix_override_set_on(DISTRIBUTED_MATRIX, OVERRIDE_MATRIX, ERR, ERROR,)
Sets the override matrix for a distributed matrix.
subroutine, public exits(NAME)
Records the exit out of the named procedure.
This module contains all type definitions in order to avoid cyclic module references.
This module contains all the low-level base routines e.g., all debug, control, and low-level communic...
integer(intg), parameter, public general_output_type
General output type.
Contains information on the solver matrix.
This module handles all fluid mechanics class routines.
Returns the specified control loop as indexed by the control loop identifier from the control loop ro...
Contains information for a Quasi-Newton nonlinear solver.
integer(intg), parameter, public solver_newton_convergence_differentiated_ratio
Sum of differentiated ratios of unconstrained to constrained residuals convergence test...
subroutine, public petsc_sneslinesearchgetvecs(lineSearch, x, f, y, w, g, err, error,)
Buffer routine to the PETSc SNESLineSearchGetVecs routine.
subroutine, public petsc_vecinitialise(x, err, error,)
subroutine, public petsc_vecrestorearrayreadf90(x, array, err, error,)
Buffer routine to the PETSc VecRestoreArrayReadF90 routine.
integer(intg), parameter problem_setup_finish_action
Finish setup action.
Contains information about the solver equations for a solver.
Contains information for a problem.
integer(intg), parameter problem_setup_cellml_equations_type
CellML equations setup for a problem.
integer(intg), parameter, public solver_nonlinear_newton
Newton nonlinear solver type.
subroutine, public writeerror(err, error,)
Writes the error string.
Contains the information for a vector that is distributed across a number of domains.
subroutine, public distributed_vector_override_set_off(DISTRIBUTED_VECTOR, ERR, ERROR,)
Turns off the override vector for a distributed vector.
This module handles all distributed matrix vector routines.
This module defines all constants shared across interface condition routines.
This module handles all solver routines.
Implements lists of Field IO operation.
This module handles all reaction diffusion equation routines.
integer(intg), parameter, public solver_matrices_jacobian_only
Select only the Jacobian solver matrix.
Contains information on the solver matrices and rhs vector.
Contains information for a field variable defined on a field.
This module handles all Galerkin projection routines.
This type is a wrapper for the C_PTR which references the actual CellML model definition object...
subroutine, public petsc_vecdot(x, y, dotProduct, err, error,)
Buffer routine to the PETSc VecDot routine.
integer(intg), parameter problem_setup_start_action
Start setup action.
subroutine, public petsc_sneslinesearchinitialise(lineSearch, err, error,)
This module handles all control loop routines.
This module defines all constants shared across equations set routines.
This module handles all bioelectric class routines.
integer(intg), parameter, public solver_matrix_output
Solver matrices output from the solver routines plus below.
subroutine, public petsc_sneslinesearchfinalise(lineSearch, err, error,)
Contains information for a Newton line search nonlinear solver.
subroutine, public distributed_matrix_override_set_off(DISTRIBUTED_MATRIX, ERR, ERROR,)
Turns off the override matrix for a distributed matrix.
This module handles all equations set routines.
subroutine, public petsc_vecgetarrayreadf90(x, array, err, error,)
Buffer routine to the PETSc VecGetArrayReadF90 routine.
Flags an error condition.
This module handles all finite elasticity routines.
integer(intg), parameter, public solver_newton_convergence_energy_norm
Energy norm convergence test.
recursive subroutine, public solver_solve(SOLVER, ERR, ERROR,)
Solve the problem.
Contains information for a CellML environment.
This module contains all kind definitions.
subroutine, public solver_matrices_output(ID, SELECTION_TYPE, SOLVER_MATRICES, ERR, ERROR,)
Outputs the solver matrices.