-
Notifications
You must be signed in to change notification settings - Fork 62
/
diffusion_advection_diffusion_routines.f90
650 lines (561 loc) · 30.9 KB
/
diffusion_advection_diffusion_routines.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
!> \file
!> \authors Andrew Cookson
!> \brief This module handles all routines pertaining to diffusion coupled to diffusion.
!>
!> \section LICENSE
!>
!> Version: MPL 1.1/GPL 2.0/LGPL 2.1
!>
!> The contents of this file are subject to the Mozilla Public License
!> Version 1.1 (the "License"); you may not use this file except in
!> compliance with the License. You may obtain a copy of the License at
!> http://www.mozilla.org/MPL/
!>
!> Software distributed under the License is distributed on an "AS IS"
!> basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
!> License for the specific language governing rights and limitations
!> under the License.
!>
!> The Original Code is OpenCMISS
!>
!> The Initial Developer of the Original Code is University of Auckland,
!> Auckland, New Zealand, the University of Oxford, Oxford, United
!> Kingdom and King's College, London, United Kingdom. Portions created
!> by the University of Auckland, the University of Oxford and King's
!> College, London are Copyright (C) 2007-2010 by the University of
!> Auckland, the University of Oxford and King's College, London.
!> All Rights Reserved.
!>
!> Contributor(s): Chris Bradley
!>
!> Alternatively, the contents of this file may be used under the terms of
!> either the GNU General Public License Version 2 or later (the "GPL"), or
!> the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
!> in which case the provisions of the GPL or the LGPL are applicable instead
!> of those above. If you wish to allow use of your version of this file only
!> under the terms of either the GPL or the LGPL, and not to allow others to
!> use your version of this file under the terms of the MPL, indicate your
!> decision by deleting the provisions above and replace them with the notice
!> and other provisions required by the GPL or the LGPL. If you do not delete
!> the provisions above, a recipient may use your version of this file under
!> the terms of any one of the MPL, the GPL or the LGPL.
!>
!>TThis module handles all routines pertaining to diffusion coupled to diffusion.
MODULE DIFFUSION_ADVECTION_DIFFUSION_ROUTINES
USE ADVECTION_DIFFUSION_EQUATION_ROUTINES
USE BaseRoutines
USE BasisRoutines
USE BOUNDARY_CONDITIONS_ROUTINES
USE CONSTANTS
USE CONTROL_LOOP_ROUTINES
USE COORDINATE_ROUTINES
USE DIFFUSION_EQUATION_ROUTINES
USE DistributedMatrixVector
USE DOMAIN_MAPPINGS
USE EquationsRoutines
USE EquationsSetConstants
USE FIELD_ROUTINES
USE FLUID_MECHANICS_IO_ROUTINES
USE INPUT_OUTPUT
USE ISO_VARYING_STRING
USE Kinds
USE Maths
USE MatrixVector
USE MESH_ROUTINES
USE NODE_ROUTINES
USE PROBLEM_CONSTANTS
USE Strings
USE SOLVER_ROUTINES
USE SolverAccessRoutines
USE Timer
USE Types
#include "macros.h"
IMPLICIT NONE
PUBLIC DiffusionAdvectionDiffusion_EquationsSetSetup
PUBLIC DiffusionAdvectionDiffusion_EquationsSetSpecSet
PUBLIC DiffusionAdvectionDiffusion_EquationsSetSolnMethodSet
PUBLIC DIFFUSION_ADVECTION_DIFFUSION_PROBLEM_SETUP
PUBLIC DiffusionAdvectionDiffusion_ProblemSpecificationSet
PUBLIC DiffusionAdvectionDiffusion_FiniteElementCalculate
PUBLIC DIFFUSION_ADVECTION_DIFFUSION_PRE_SOLVE
PUBLIC DIFFUSION_ADVECTION_DIFFUSION_POST_SOLVE
CONTAINS
!
!================================================================================================================================
!
!>Sets/changes the solution method for a coupled diffusion & advection-diffusion equation type of a multi physics equations set class.
SUBROUTINE DiffusionAdvectionDiffusion_EquationsSetSolnMethodSet(EQUATIONS_SET,SOLUTION_METHOD,ERR,ERROR,*)
!Argument variables
TYPE(EQUATIONS_SET_TYPE), POINTER :: EQUATIONS_SET !<A pointer to the equations set to set the solution method for
INTEGER(INTG), INTENT(IN) :: SOLUTION_METHOD !<The solution method to set
INTEGER(INTG), INTENT(OUT) :: ERR !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: ERROR !<The error string
!Local Variables
TYPE(VARYING_STRING) :: LOCAL_ERROR
ENTERS("DiffusionAdvectionDiffusion_EquationsSetSolnMethodSet",ERR,ERROR,*999)
IF(ASSOCIATED(EQUATIONS_SET)) THEN
IF(.NOT.ALLOCATED(EQUATIONS_SET%SPECIFICATION)) THEN
CALL FlagError("Equations set specification is not allocated.",err,error,*999)
ELSE IF(SIZE(EQUATIONS_SET%SPECIFICATION,1)/=3) THEN
CALL FlagError("Equations set specification must have three entries for a "// &
& "diffusion and advection-diffusion type equations set.",err,error,*999)
END IF
SELECT CASE(EQUATIONS_SET%SPECIFICATION(3))
CASE(EQUATIONS_SET_COUPLED_SOURCE_DIFFUSION_ADVEC_DIFFUSION_SUBTYPE)
SELECT CASE(SOLUTION_METHOD)
CASE(EQUATIONS_SET_FEM_SOLUTION_METHOD)
EQUATIONS_SET%SOLUTION_METHOD=EQUATIONS_SET_FEM_SOLUTION_METHOD
CASE(EQUATIONS_SET_BEM_SOLUTION_METHOD)
CALL FlagError("Not implemented.",ERR,ERROR,*999)
CASE(EQUATIONS_SET_FD_SOLUTION_METHOD)
CALL FlagError("Not implemented.",ERR,ERROR,*999)
CASE(EQUATIONS_SET_FV_SOLUTION_METHOD)
CALL FlagError("Not implemented.",ERR,ERROR,*999)
CASE(EQUATIONS_SET_GFEM_SOLUTION_METHOD)
CALL FlagError("Not implemented.",ERR,ERROR,*999)
CASE(EQUATIONS_SET_GFV_SOLUTION_METHOD)
CALL FlagError("Not implemented.",ERR,ERROR,*999)
CASE DEFAULT
LOCAL_ERROR="The specified solution method of "//TRIM(NUMBER_TO_VSTRING(SOLUTION_METHOD,"*",ERR,ERROR))//" is invalid."
CALL FlagError(LOCAL_ERROR,ERR,ERROR,*999)
END SELECT
CASE DEFAULT
LOCAL_ERROR="Equations set subtype of "//TRIM(NUMBER_TO_VSTRING(EQUATIONS_SET%SPECIFICATION(3),"*",ERR,ERROR))// &
& " is not valid for a diffusion & advection-diffusion equation type of a multi physics equations set class."
CALL FlagError(LOCAL_ERROR,ERR,ERROR,*999)
END SELECT
ELSE
CALL FlagError("Equations set is not associated.",ERR,ERROR,*999)
ENDIF
EXITS("DiffusionAdvectionDiffusion_EquationsSetSolnMethodSet")
RETURN
999 ERRORS("DiffusionAdvectionDiffusion_EquationsSetSolnMethodSet",ERR,ERROR)
EXITS("DiffusionAdvectionDiffusion_EquationsSetSolnMethodSet")
RETURN 1
END SUBROUTINE DiffusionAdvectionDiffusion_EquationsSetSolnMethodSet
!
!================================================================================================================================
!
!>Sets up the diffusion & advection-diffusion coupled equation.
SUBROUTINE DiffusionAdvectionDiffusion_EquationsSetSetup(EQUATIONS_SET,EQUATIONS_SET_SETUP,ERR,ERROR,*)
!Argument variables
TYPE(EQUATIONS_SET_TYPE), POINTER :: EQUATIONS_SET !<A pointer to the equations set to setup
TYPE(EQUATIONS_SET_SETUP_TYPE), INTENT(INOUT) :: EQUATIONS_SET_SETUP !<The equations set setup information
INTEGER(INTG), INTENT(OUT) :: ERR !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: ERROR !<The error string
!Local Variables
ENTERS("DiffusionAdvectionDiffusion_EquationsSetSetup",ERR,ERROR,*999)
CALL FlagError("Not implemented.",ERR,ERROR,*999)
EXITS("DiffusionAdvectionDiffusion_EquationsSetSetup")
RETURN
999 ERRORS("DiffusionAdvectionDiffusion_EquationsSetSetup",ERR,ERROR)
EXITS("DiffusionAdvectionDiffusion_EquationsSetSetup")
RETURN 1
END SUBROUTINE DiffusionAdvectionDiffusion_EquationsSetSetup
!
!================================================================================================================================
!
!>Calculates the element stiffness matrices and RHS for a coupled diffusion & advection-diffusion equation finite element equations set.
SUBROUTINE DiffusionAdvectionDiffusion_FiniteElementCalculate(EQUATIONS_SET,ELEMENT_NUMBER,ERR,ERROR,*)
!Argument variables
TYPE(EQUATIONS_SET_TYPE), POINTER :: EQUATIONS_SET !<A pointer to the equations set to perform the finite element calculations on
INTEGER(INTG), INTENT(IN) :: ELEMENT_NUMBER !<The element number to calculate
INTEGER(INTG), INTENT(OUT) :: ERR !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: ERROR !<The error string
!Local Variables
ENTERS("DiffusionAdvectionDiffusion_FiniteElementCalculate",ERR,ERROR,*999)
CALL FlagError("Not implemented.",ERR,ERROR,*999)
EXITS("DiffusionAdvectionDiffusion_FiniteElementCalculate")
RETURN
999 ERRORS("DiffusionAdvectionDiffusion_FiniteElementCalculate",ERR,ERROR)
EXITS("DiffusionAdvectionDiffusion_FiniteElementCalculate")
RETURN 1
END SUBROUTINE DiffusionAdvectionDiffusion_FiniteElementCalculate
!
!================================================================================================================================
!
!>Sets the equation specification for a coupled diffusion & advection-diffusion equation type of a multi physics equations set class.
SUBROUTINE DiffusionAdvectionDiffusion_EquationsSetSpecSet(equationsSet,specification,err,error,*)
!Argument variables
TYPE(EQUATIONS_SET_TYPE), POINTER :: equationsSet !<A pointer to the equations set to set the specification for
INTEGER(INTG), INTENT(IN) :: specification(:) !<The equations set specification to set
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
ENTERS("DiffusionAdvectionDiffusion_EquationsSetSpecSet",err,error,*999)
CALL FlagError("Not implemented.",err,error,*999)
EXITS("DiffusionAdvectionDiffusion_EquationsSetSpecSet")
RETURN
999 ERRORS("DiffusionAdvectionDiffusion_EquationsSetSpecSet",err,error)
EXITS("DiffusionAdvectionDiffusion_EquationsSetSpecSet")
RETURN 1
END SUBROUTINE DiffusionAdvectionDiffusion_EquationsSetSpecSet
!
!================================================================================================================================
!
!>Sets the problem specification for a coupled diffusion & advection-diffusion problem.
SUBROUTINE DiffusionAdvectionDiffusion_ProblemSpecificationSet(problem,problemSpecification,err,error,*)
!Argument variables
TYPE(PROBLEM_TYPE), POINTER :: problem !<A pointer to the problem to set the problem specification for
INTEGER(INTG), INTENT(IN) :: problemSpecification(:) !<The problem specification to set
INTEGER(INTG), INTENT(OUT) :: err !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: error !<The error string
!Local Variables
TYPE(VARYING_STRING) :: localError
INTEGER(INTG) :: problemSubtype
ENTERS("DiffusionAdvectionDiffusion_ProblemSpecificationSet",err,error,*999)
IF(ASSOCIATED(problem)) THEN
IF(SIZE(problemSpecification,1)==3) THEN
SELECT CASE(problemSubtype)
CASE(PROBLEM_COUPLED_SOURCE_DIFFUSION_ADVEC_DIFFUSION_SUBTYPE)
!ok
CASE DEFAULT
localError="The third problem specification of "//TRIM(NumberToVstring(problemSubtype,"*",err,error))// &
& " is not valid for a coupled diffusion & advection-diffusion type of a multi physics problem."
CALL FlagError(localError,err,error,*999)
END SELECT
IF(ALLOCATED(problem%specification)) THEN
CALL FlagError("Problem specification is already allocated.",err,error,*999)
ELSE
ALLOCATE(problem%specification(3),stat=err)
IF(err/=0) CALL FlagError("Could not allocate problem specification.",err,error,*999)
END IF
problem%specification(1:3)=[PROBLEM_MULTI_PHYSICS_CLASS,PROBLEM_DIFFUSION_ADVECTION_DIFFUSION_TYPE, &
& problemSubtype]
ELSE
CALL FlagError("Diffusion advection-diffusion transport problem specification must have 3 entries.",err,error,*999)
END IF
ELSE
CALL FlagError("Problem is not associated.",err,error,*999)
END IF
EXITS("DiffusionAdvectionDiffusion_ProblemSpecificationSet")
RETURN
999 ERRORS("DiffusionAdvectionDiffusion_ProblemSpecificationSet",err,error)
EXITS("DiffusionAdvectionDiffusion_ProblemSpecificationSet")
RETURN 1
END SUBROUTINE DiffusionAdvectionDiffusion_ProblemSpecificationSet
!
!================================================================================================================================
!
!>Sets up the coupled diffusion-diffusion equations problem.
SUBROUTINE DIFFUSION_ADVECTION_DIFFUSION_PROBLEM_SETUP(PROBLEM,PROBLEM_SETUP,ERR,ERROR,*)
!Argument variables
TYPE(PROBLEM_TYPE), POINTER :: PROBLEM !<A pointer to the problem to setup
TYPE(PROBLEM_SETUP_TYPE), INTENT(INOUT) :: PROBLEM_SETUP !<The problem setup information
INTEGER(INTG), INTENT(OUT) :: ERR !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: ERROR !<The error string
!Local Variables
TYPE(CONTROL_LOOP_TYPE), POINTER :: CONTROL_LOOP,CONTROL_LOOP_ROOT
TYPE(SOLVER_TYPE), POINTER :: SOLVER_DIFFUSION, SOLVER_ADVECTION_DIFFUSION
TYPE(SOLVER_EQUATIONS_TYPE), POINTER :: SOLVER_EQUATIONS_DIFFUSION, SOLVER_EQUATIONS_ADVECTION_DIFFUSION
TYPE(SOLVERS_TYPE), POINTER :: SOLVERS
TYPE(VARYING_STRING) :: LOCAL_ERROR
ENTERS("DIFFUSION_ADVECTION_DIFFUSION_PROBLEM_SETUP",ERR,ERROR,*999)
NULLIFY(CONTROL_LOOP)
NULLIFY(SOLVERS)
NULLIFY(SOLVER_DIFFUSION)
NULLIFY(SOLVER_ADVECTION_DIFFUSION)
NULLIFY(SOLVER_EQUATIONS_DIFFUSION)
NULLIFY(SOLVER_EQUATIONS_ADVECTION_DIFFUSION)
IF(ASSOCIATED(PROBLEM)) THEN
IF(.NOT.ALLOCATED(problem%specification)) THEN
CALL FlagError("Problem specification is not allocated.",err,error,*999)
ELSE IF(SIZE(problem%specification,1)<3) THEN
CALL FlagError("Problem specification must have three entries for a diffusion-advection diffusion problem.", &
& err,error,*999)
END IF
SELECT CASE(PROBLEM%SPECIFICATION(3))
!--------------------------------------------------------------------
! coupled source diffusion--advection-diffusion
!--------------------------------------------------------------------
CASE(PROBLEM_COUPLED_SOURCE_DIFFUSION_ADVEC_DIFFUSION_SUBTYPE)
SELECT CASE(PROBLEM_SETUP%SETUP_TYPE)
CASE(PROBLEM_SETUP_INITIAL_TYPE)
SELECT CASE(PROBLEM_SETUP%ACTION_TYPE)
CASE(PROBLEM_SETUP_START_ACTION)
!Do nothing????
CASE(PROBLEM_SETUP_FINISH_ACTION)
!Do nothing???
CASE DEFAULT
LOCAL_ERROR="The action type of "//TRIM(NUMBER_TO_VSTRING(PROBLEM_SETUP%ACTION_TYPE,"*",ERR,ERROR))// &
& " for a setup type of "//TRIM(NUMBER_TO_VSTRING(PROBLEM_SETUP%SETUP_TYPE,"*",ERR,ERROR))// &
& " is invalid for a diffusion & advection-diffusion equation."
CALL FlagError(LOCAL_ERROR,ERR,ERROR,*999)
END SELECT
CASE(PROBLEM_SETUP_CONTROL_TYPE)
SELECT CASE(PROBLEM_SETUP%ACTION_TYPE)
CASE(PROBLEM_SETUP_START_ACTION)
!Set up a time control loop
CALL CONTROL_LOOP_CREATE_START(PROBLEM,CONTROL_LOOP,ERR,ERROR,*999)
CALL CONTROL_LOOP_TYPE_SET(CONTROL_LOOP,PROBLEM_CONTROL_TIME_LOOP_TYPE,ERR,ERROR,*999)
CASE(PROBLEM_SETUP_FINISH_ACTION)
!Finish the control loops
CONTROL_LOOP_ROOT=>PROBLEM%CONTROL_LOOP
CALL CONTROL_LOOP_GET(CONTROL_LOOP_ROOT,CONTROL_LOOP_NODE,CONTROL_LOOP,ERR,ERROR,*999)
CALL CONTROL_LOOP_CREATE_FINISH(CONTROL_LOOP,ERR,ERROR,*999)
CASE DEFAULT
LOCAL_ERROR="The action type of "//TRIM(NUMBER_TO_VSTRING(PROBLEM_SETUP%ACTION_TYPE,"*",ERR,ERROR))// &
& " for a setup type of "//TRIM(NUMBER_TO_VSTRING(PROBLEM_SETUP%SETUP_TYPE,"*",ERR,ERROR))// &
& " is invalid for a coupled diffusion & advection-diffusion equation."
CALL FlagError(LOCAL_ERROR,ERR,ERROR,*999)
END SELECT
CASE(PROBLEM_SETUP_SOLVERS_TYPE)
!Get the control loop
CONTROL_LOOP_ROOT=>PROBLEM%CONTROL_LOOP
CALL CONTROL_LOOP_GET(CONTROL_LOOP_ROOT,CONTROL_LOOP_NODE,CONTROL_LOOP,ERR,ERROR,*999)
SELECT CASE(PROBLEM_SETUP%ACTION_TYPE)
CASE(PROBLEM_SETUP_START_ACTION)
!Start the solvers creation
CALL SOLVERS_CREATE_START(CONTROL_LOOP,SOLVERS,ERR,ERROR,*999)
CALL SOLVERS_NUMBER_SET(SOLVERS,2,ERR,ERROR,*999)
!
!Set the first solver to be a linear solver for the advection-diffusion problem
CALL SOLVERS_SOLVER_GET(SOLVERS,1,SOLVER_ADVECTION_DIFFUSION,ERR,ERROR,*999)
CALL SOLVER_TYPE_SET(SOLVER_ADVECTION_DIFFUSION,SOLVER_DYNAMIC_TYPE,ERR,ERROR,*999)
CALL SOLVER_DYNAMIC_ORDER_SET(SOLVER_ADVECTION_DIFFUSION,SOLVER_DYNAMIC_FIRST_ORDER,ERR,ERROR,*999)
!Set solver defaults
CALL SOLVER_DYNAMIC_DEGREE_SET(SOLVER_ADVECTION_DIFFUSION,SOLVER_DYNAMIC_FIRST_DEGREE,ERR,ERROR,*999)
CALL SOLVER_DYNAMIC_SCHEME_SET(SOLVER_ADVECTION_DIFFUSION,SOLVER_DYNAMIC_CRANK_NICOLSON_SCHEME,ERR,ERROR,*999)
CALL SOLVER_LIBRARY_TYPE_SET(SOLVER_ADVECTION_DIFFUSION,SOLVER_CMISS_LIBRARY,ERR,ERROR,*999)
!
!Set the second solver to be a linear solver for the diffusion problem
CALL SOLVERS_SOLVER_GET(SOLVERS,2,SOLVER_DIFFUSION,ERR,ERROR,*999)
CALL SOLVER_TYPE_SET(SOLVER_DIFFUSION,SOLVER_DYNAMIC_TYPE,ERR,ERROR,*999)
CALL SOLVER_DYNAMIC_ORDER_SET(SOLVER_DIFFUSION,SOLVER_DYNAMIC_FIRST_ORDER,ERR,ERROR,*999)
!Set solver defaults
CALL SOLVER_DYNAMIC_DEGREE_SET(SOLVER_DIFFUSION,SOLVER_DYNAMIC_FIRST_DEGREE,ERR,ERROR,*999)
CALL SOLVER_DYNAMIC_SCHEME_SET(SOLVER_DIFFUSION,SOLVER_DYNAMIC_CRANK_NICOLSON_SCHEME,ERR,ERROR,*999)
CALL SOLVER_LIBRARY_TYPE_SET(SOLVER_DIFFUSION,SOLVER_CMISS_LIBRARY,ERR,ERROR,*999)
!
CASE(PROBLEM_SETUP_FINISH_ACTION)
!Get the solvers
CALL CONTROL_LOOP_SOLVERS_GET(CONTROL_LOOP,SOLVERS,ERR,ERROR,*999)
!Finish the solvers creation
CALL SOLVERS_CREATE_FINISH(SOLVERS,ERR,ERROR,*999)
CASE DEFAULT
LOCAL_ERROR="The action type of "//TRIM(NUMBER_TO_VSTRING(PROBLEM_SETUP%ACTION_TYPE,"*",ERR,ERROR))// &
& " for a setup type of "//TRIM(NUMBER_TO_VSTRING(PROBLEM_SETUP%SETUP_TYPE,"*",ERR,ERROR))// &
& " is invalid for a coupled diffusion & advection-diffusion equation."
CALL FlagError(LOCAL_ERROR,ERR,ERROR,*999)
END SELECT
CASE(PROBLEM_SETUP_SOLVER_EQUATIONS_TYPE)
SELECT CASE(PROBLEM_SETUP%ACTION_TYPE)
CASE(PROBLEM_SETUP_START_ACTION)
!Get the control loop and solvers
CONTROL_LOOP_ROOT=>PROBLEM%CONTROL_LOOP
CALL CONTROL_LOOP_GET(CONTROL_LOOP_ROOT,CONTROL_LOOP_NODE,CONTROL_LOOP,ERR,ERROR,*999)
CALL CONTROL_LOOP_SOLVERS_GET(CONTROL_LOOP,SOLVERS,ERR,ERROR,*999)
!
!Get the advection-diffusion solver and create the advection-diffusion solver equations
CALL SOLVERS_SOLVER_GET(SOLVERS,1,SOLVER_ADVECTION_DIFFUSION,ERR,ERROR,*999)
CALL SOLVER_EQUATIONS_CREATE_START(SOLVER_ADVECTION_DIFFUSION,SOLVER_EQUATIONS_ADVECTION_DIFFUSION,ERR,ERROR,*999)
CALL SOLVER_EQUATIONS_LINEARITY_TYPE_SET(SOLVER_EQUATIONS_ADVECTION_DIFFUSION,SOLVER_EQUATIONS_LINEAR,ERR,ERROR,*999)
CALL SOLVER_EQUATIONS_TIME_DEPENDENCE_TYPE_SET(SOLVER_EQUATIONS_ADVECTION_DIFFUSION, &
& SOLVER_EQUATIONS_FIRST_ORDER_DYNAMIC,ERR,ERROR,*999)
CALL SOLVER_EQUATIONS_SPARSITY_TYPE_SET(SOLVER_EQUATIONS_ADVECTION_DIFFUSION,SOLVER_SPARSE_MATRICES,ERR,ERROR,*999)
!
!Get the diffusion solver and create the diffusion solver equations
CALL SOLVERS_SOLVER_GET(SOLVERS,2,SOLVER_DIFFUSION,ERR,ERROR,*999)
CALL SOLVER_EQUATIONS_CREATE_START(SOLVER_DIFFUSION,SOLVER_EQUATIONS_DIFFUSION,ERR,ERROR,*999)
CALL SOLVER_EQUATIONS_LINEARITY_TYPE_SET(SOLVER_EQUATIONS_DIFFUSION,SOLVER_EQUATIONS_LINEAR,ERR,ERROR,*999)
CALL SOLVER_EQUATIONS_TIME_DEPENDENCE_TYPE_SET(SOLVER_EQUATIONS_DIFFUSION, &
& SOLVER_EQUATIONS_FIRST_ORDER_DYNAMIC,ERR,ERROR,*999)
CALL SOLVER_EQUATIONS_SPARSITY_TYPE_SET(SOLVER_EQUATIONS_DIFFUSION,SOLVER_SPARSE_MATRICES,ERR,ERROR,*999)
!
CASE(PROBLEM_SETUP_FINISH_ACTION)
!Get the control loop
CONTROL_LOOP_ROOT=>PROBLEM%CONTROL_LOOP
CALL CONTROL_LOOP_GET(CONTROL_LOOP_ROOT,CONTROL_LOOP_NODE,CONTROL_LOOP,ERR,ERROR,*999)
CALL CONTROL_LOOP_SOLVERS_GET(CONTROL_LOOP,SOLVERS,ERR,ERROR,*999)
!
!Finish the creation of the advection-diffusion solver equations
CALL SOLVERS_SOLVER_GET(SOLVERS,1,SOLVER_ADVECTION_DIFFUSION,ERR,ERROR,*999)
CALL SOLVER_SOLVER_EQUATIONS_GET(SOLVER_ADVECTION_DIFFUSION,SOLVER_EQUATIONS_ADVECTION_DIFFUSION,ERR,ERROR,*999)
CALL SOLVER_EQUATIONS_CREATE_FINISH(SOLVER_EQUATIONS_ADVECTION_DIFFUSION,ERR,ERROR,*999)
!
!Finish the creation of the diffusion solver equations
CALL SOLVERS_SOLVER_GET(SOLVERS,2,SOLVER_DIFFUSION,ERR,ERROR,*999)
CALL SOLVER_SOLVER_EQUATIONS_GET(SOLVER_DIFFUSION,SOLVER_EQUATIONS_DIFFUSION,ERR,ERROR,*999)
CALL SOLVER_EQUATIONS_CREATE_FINISH(SOLVER_EQUATIONS_DIFFUSION,ERR,ERROR,*999)
!
CASE DEFAULT
LOCAL_ERROR="The action type of "//TRIM(NUMBER_TO_VSTRING(PROBLEM_SETUP%ACTION_TYPE,"*",ERR,ERROR))// &
& " for a setup type of "//TRIM(NUMBER_TO_VSTRING(PROBLEM_SETUP%SETUP_TYPE,"*",ERR,ERROR))// &
& " is invalid for a coupled diffusion & advection-diffusion equation."
CALL FlagError(LOCAL_ERROR,ERR,ERROR,*999)
END SELECT
CASE DEFAULT
LOCAL_ERROR="The setup type of "//TRIM(NUMBER_TO_VSTRING(PROBLEM_SETUP%SETUP_TYPE,"*",ERR,ERROR))// &
& " is invalid for a coupled diffusion & advection-diffusion equation."
CALL FlagError(LOCAL_ERROR,ERR,ERROR,*999)
END SELECT
!-----------------------------------------------------------------
! c a s e d e f a u l t
!-----------------------------------------------------------------
CASE DEFAULT
LOCAL_ERROR="The problem subtype of "//TRIM(NUMBER_TO_VSTRING(PROBLEM%SPECIFICATION(3),"*",ERR,ERROR))// &
& " does not equal a coupled source diffusion & advection-diffusion equation subtype."
CALL FlagError(LOCAL_ERROR,ERR,ERROR,*999)
END SELECT
ELSE
CALL FlagError("Problem is not associated.",ERR,ERROR,*999)
ENDIF
EXITS("DIFFUSION_ADVECTION_DIFFUSION_PROBLEM_SETUP")
RETURN
999 ERRORSEXITS("DIFFUSION_ADVECTION_DIFFUSION_PROBLEM_SETUP",ERR,ERROR)
RETURN 1
END SUBROUTINE DIFFUSION_ADVECTION_DIFFUSION_PROBLEM_SETUP
!
!================================================================================================================================
!
!>Sets up the diffusion-diffusion problem pre-solve.
SUBROUTINE DIFFUSION_ADVECTION_DIFFUSION_PRE_SOLVE(CONTROL_LOOP,SOLVER,ERR,ERROR,*)
!Argument variables
TYPE(CONTROL_LOOP_TYPE), POINTER :: CONTROL_LOOP !<A pointer to the control loop to solve.
TYPE(SOLVER_TYPE), POINTER :: SOLVER !<A pointer to the solver
INTEGER(INTG), INTENT(OUT) :: ERR !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: ERROR !<The error string
!Local Variables
TYPE(VARYING_STRING) :: LOCAL_ERROR
ENTERS("DIFFUSION_ADVECTION_DIFFUSION_PRE_SOLVE",ERR,ERROR,*999)
IF(ASSOCIATED(CONTROL_LOOP)) THEN
IF(ASSOCIATED(SOLVER)) THEN
IF(ASSOCIATED(CONTROL_LOOP%PROBLEM)) THEN
IF(.NOT.ALLOCATED(control_loop%problem%specification)) THEN
CALL FlagError("Problem specification is not allocated.",err,error,*999)
ELSE IF(SIZE(control_loop%problem%specification,1)<3) THEN
CALL FlagError("Problem specification must have three entries for a diffusion-advection diffusion problem.", &
& err,error,*999)
END IF
SELECT CASE(CONTROL_LOOP%PROBLEM%SPECIFICATION(3))
CASE(PROBLEM_COUPLED_SOURCE_DIFFUSION_ADVEC_DIFFUSION_SUBTYPE)
IF(SOLVER%GLOBAL_NUMBER==1) THEN
!copy current value of concentration_one to another variable
CALL AdvectionDiffusion_PreSolveStoreCurrentSoln(CONTROL_LOOP,SOLVER,ERR,ERROR,*999)
!Set source term to be updated value of concentration_two
!CALL ADVECTION_DIFFUSION_EQUATION_PRE_SOLVE_GET_SOURCE_VALUE(CONTROL_LOOP,SOLVER,ERR,ERROR,*999)
!Update indpendent data fields
! CALL WRITE_STRING(GENERAL_OUTPUT_TYPE,"Read in vector data... ",ERR,ERROR,*999)
! CALL ADVECTION_DIFFUSION_PRE_SOLVE_UPDATE_INPUT_DATA(CONTROL_LOOP,SOLVER,ERR,ERROR,*999)
ELSE IF(SOLVER%GLOBAL_NUMBER==2) THEN
!copy current value of concentration_one to another variable
CALL Diffusion_PreSolveStoreCurrentSolution(CONTROL_LOOP,SOLVER,ERR,ERROR,*999)
!compute value of constant source term - evaluated from lamdba*(0.5*(c_1^{t+1}+c_1^{t}) - c_2^{t})
!CALL DIFFUSION_EQUATION_PRE_SOLVE_GET_SOURCE_VALUE(CONTROL_LOOP,SOLVER,ERR,ERROR,*999)
ENDIF
CASE DEFAULT
LOCAL_ERROR="Problem subtype "//TRIM(NUMBER_TO_VSTRING(CONTROL_LOOP%PROBLEM%SPECIFICATION(3),"*",ERR,ERROR))// &
& " is not valid for a diffusion & advection-diffusion type of a multi physics problem class."
CALL FlagError(LOCAL_ERROR,ERR,ERROR,*999)
END SELECT
ELSE
CALL FlagError("Problem is not associated.",ERR,ERROR,*999)
ENDIF
ELSE
CALL FlagError("Solver is not associated.",ERR,ERROR,*999)
ENDIF
ELSE
CALL FlagError("Control loop is not associated.",ERR,ERROR,*999)
ENDIF
EXITS("DIFFUSION_ADVECTION_DIFFUSION_PRE_SOLVE")
RETURN
999 ERRORSEXITS("DIFFUSION_ADVECTION_DIFFUSION_PRE_SOLVE",ERR,ERROR)
RETURN 1
END SUBROUTINE DIFFUSION_ADVECTION_DIFFUSION_PRE_SOLVE
!
!================================================================================================================================
!
!>Sets up the diffusion-diffusion problem post solve.
SUBROUTINE DIFFUSION_ADVECTION_DIFFUSION_POST_SOLVE(CONTROL_LOOP,SOLVER,ERR,ERROR,*)
!Argument variables
TYPE(CONTROL_LOOP_TYPE), POINTER :: CONTROL_LOOP !<A pointer to the control loop to solve.
TYPE(SOLVER_TYPE), POINTER :: SOLVER!<A pointer to the solver
INTEGER(INTG), INTENT(OUT) :: ERR !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: ERROR !<The error string
!Local Variables
TYPE(VARYING_STRING) :: LOCAL_ERROR
ENTERS("DIFFUSION_ADVECTION_DIFFUSION_POST_SOLVE",ERR,ERROR,*999)
IF(ASSOCIATED(CONTROL_LOOP)) THEN
IF(ASSOCIATED(SOLVER)) THEN
IF(ASSOCIATED(CONTROL_LOOP%PROBLEM)) THEN
IF(.NOT.ALLOCATED(control_loop%problem%specification)) THEN
CALL FlagError("Problem specification is not allocated.",err,error,*999)
ELSE IF(SIZE(control_loop%problem%specification,1)<3) THEN
CALL FlagError("Problem specification must have three entries for a diffusion-advection diffusion problem.", &
& err,error,*999)
END IF
SELECT CASE(CONTROL_LOOP%PROBLEM%SPECIFICATION(3))
CASE(PROBLEM_COUPLED_SOURCE_DIFFUSION_ADVEC_DIFFUSION_SUBTYPE)
IF(SOLVER%GLOBAL_NUMBER==1) THEN
! CALL ADVECTION_DIFFUSION_EQUATION_POST_SOLVE(CONTROL_LOOP,SOLVER,ERR,ERROR,*999)
ELSE IF(SOLVER%GLOBAL_NUMBER==2) THEN
! CALL DIFFUSION_EQUATION_POST_SOLVE(CONTROL_LOOP,SOLVER,ERR,ERROR,*999)
ENDIF
CASE DEFAULT
LOCAL_ERROR="Problem subtype "//TRIM(NUMBER_TO_VSTRING(CONTROL_LOOP%PROBLEM%SPECIFICATION(3),"*",ERR,ERROR))// &
& " is not valid for a diffusion & advection-diffusion type of a multi physics problem class."
CALL FlagError(LOCAL_ERROR,ERR,ERROR,*999)
END SELECT
ELSE
CALL FlagError("Problem is not associated.",ERR,ERROR,*999)
ENDIF
ELSE
CALL FlagError("Solver is not associated.",ERR,ERROR,*999)
ENDIF
ELSE
CALL FlagError("Control loop is not associated.",ERR,ERROR,*999)
ENDIF
EXITS("DIFFUSION_ADVECTION_DIFFUSION_POST_SOLVE")
RETURN
999 ERRORSEXITS("DIFFUSION_ADVECTION_DIFFUSION_POST_SOLVE",ERR,ERROR)
RETURN 1
END SUBROUTINE DIFFUSION_ADVECTION_DIFFUSION_POST_SOLVE
!
!================================================================================================================================
!
!>Sets up the diffuion-diffusion problem post solve output data.
SUBROUTINE DiffusionAdvectionDiffusion_PostSolveOutputData(CONTROL_LOOP,SOLVER,ERR,ERROR,*)
!Argument variables
TYPE(CONTROL_LOOP_TYPE), POINTER :: CONTROL_LOOP !<A pointer to the control loop to solve.
TYPE(SOLVER_TYPE), POINTER :: SOLVER !<A pointer to the solver
INTEGER(INTG), INTENT(OUT) :: ERR !<The error code
TYPE(VARYING_STRING), INTENT(OUT) :: ERROR !<The error string
!Local Variables
TYPE(VARYING_STRING) :: LOCAL_ERROR
ENTERS("DiffusionAdvectionDiffusion_PostSolveOutputData",ERR,ERROR,*999)
IF(ASSOCIATED(CONTROL_LOOP)) THEN
IF(ASSOCIATED(SOLVER)) THEN
IF(ASSOCIATED(CONTROL_LOOP%PROBLEM)) THEN
IF(.NOT.ALLOCATED(control_loop%problem%specification)) THEN
CALL FlagError("Problem specification is not allocated.",err,error,*999)
ELSE IF(SIZE(control_loop%problem%specification,1)<3) THEN
CALL FlagError("Problem specification must have three entries for a diffusion-advection diffusion problem.", &
& err,error,*999)
END IF
SELECT CASE(CONTROL_LOOP%PROBLEM%SPECIFICATION(3))
CASE(PROBLEM_COUPLED_SOURCE_DIFFUSION_ADVEC_DIFFUSION_SUBTYPE)
!CALL ADVECTION_DIFFUSION_EQUATION_POST_SOLVE_OUTPUT_DATA(CONTROL_LOOP,SOLVER,ERR,ERROR,*999)
!CALL DIFFUSION_EQUATION_POST_SOLVE_OUTPUT_DATA(CONTROL_LOOP,SOLVER,ERR,ERROR,*999)
CASE DEFAULT
LOCAL_ERROR="Problem subtype "//TRIM(NUMBER_TO_VSTRING(CONTROL_LOOP%PROBLEM%SPECIFICATION(3),"*",ERR,ERROR))// &
& " is not valid for a diffusion & advection-diffusion type of a multi physics problem class."
CALL FlagError(LOCAL_ERROR,ERR,ERROR,*999)
END SELECT
ELSE
CALL FlagError("Problem is not associated.",ERR,ERROR,*999)
ENDIF
ELSE
CALL FlagError("Solver is not associated.",ERR,ERROR,*999)
ENDIF
ELSE
CALL FlagError("Control loop is not associated.",ERR,ERROR,*999)
ENDIF
EXITS("DiffusionAdvectionDiffusion_PostSolveOutputData")
RETURN
999 ERRORS("DiffusionAdvectionDiffusion_PostSolveOutputData",ERR,ERROR)
EXITS("DiffusionAdvectionDiffusion_PostSolveOutputData")
RETURN 1
END SUBROUTINE DiffusionAdvectionDiffusion_PostSolveOutputData
!
!================================================================================================================================
!
END MODULE DIFFUSION_ADVECTION_DIFFUSION_ROUTINES