PageRenderTime 39ms CodeModel.GetById 3ms app.highlight 32ms RepoModel.GetById 1ms app.codeStats 0ms

/ClassicalField/AdvectionDiffusion/StaticAdvectionDiffusion_FieldML/src/StaticAdvectionDiffusion_FieldMLExample.f90

http://github.com/xyan075/examples
FORTRAN Modern | 452 lines | 204 code | 72 blank | 176 comment | 4 complexity | a1bda3cef7be47c65b7c1c0e277858f7 MD5 | raw file
  1!> \file
  2!> \author Chris Bradley
  3!> \brief This is an example program to solve a diffusion equation using openCMISS calls.
  4!>
  5!> \section LICENSE
  6!>
  7!> Version: MPL 1.1/GPL 2.0/LGPL 2.1
  8!>
  9!> The contents of this file are subject to the Mozilla Public License
 10!> Version 1.1 (the "License"); you may not use this file except in
 11!> compliance with the License. You may obtain a copy of the License at
 12!> http://www.mozilla.org/MPL/
 13!>
 14!> Software distributed under the License is distributed on an "AS IS"
 15!> basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 16!> License for the specific language governing rights and limitations
 17!> under the License.
 18!>
 19!> The Original Code is openCMISS
 20!>
 21!> The Initial Developer of the Original Code is University of Auckland,
 22!> Auckland, New Zealand and University of Oxford, Oxford, United
 23!> Kingdom. Portions created by the University of Auckland and University
 24!> of Oxford are Copyright (C) 2007 by the University of Auckland and
 25!> the University of Oxford. All Rights Reserved.
 26!>
 27!> Contributor(s):
 28!>
 29!> Alternatively, the contents of this file may be used under the terms of
 30!> either the GNU General Public License Version 2 or later (the "GPL"), or
 31!> the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 32!> in which case the provisions of the GPL or the LGPL are applicable instead
 33!> of those above. If you wish to allow use of your version of this file only
 34!> under the terms of either the GPL or the LGPL, and not to allow others to
 35!> use your version of this file under the terms of the MPL, indicate your
 36!> decision by deleting the provisions above and replace them with the notice
 37!> and other provisions required by the GPL or the LGPL. If you do not delete
 38!> the provisions above, a recipient may use your version of this file under
 39!> the terms of any one of the MPL, the GPL or the LGPL.
 40!>
 41
 42!> \example ClassicalField/AdvectionDiffusion/StaticAdvectionDiffusion_FieldML/src/StaticAdvectionDiffusion_FieldMLExample.f90
 43!! Example program to solve a diffusion equation using openCMISS calls.
 44!!
 45!! \htmlinclude ClassicalField/AdvectionDiffusion/StaticAdvectionDiffusion_FieldML/history.html
 46!<
 47
 48!> Main program
 49PROGRAM STATICADVECTIONDIFFUSIONEXAMPLE
 50
 51  USE OPENCMISS
 52  USE FIELDML_API
 53  USE MPI
 54
 55
 56#ifdef WIN32
 57  USE IFQWIN
 58#endif
 59
 60  IMPLICIT NONE
 61
 62  !Test program parameters
 63
 64  REAL(CMISSDP), PARAMETER :: HEIGHT=1.0_CMISSDP
 65  REAL(CMISSDP), PARAMETER :: WIDTH=2.0_CMISSDP
 66  REAL(CMISSDP), PARAMETER :: LENGTH=3.0_CMISSDP 
 67  REAL(CMISSDP), POINTER :: GEOMETRIC_PARAMETERS(:)
 68  
 69  INTEGER(CMISSIntg), PARAMETER :: CoordinateSystemUserNumber=1
 70  INTEGER(CMISSIntg), PARAMETER :: RegionUserNumber=2
 71  INTEGER(CMISSIntg), PARAMETER :: BasisUserNumber=3
 72  INTEGER(CMISSIntg), PARAMETER :: GeneratedMeshUserNumber=4
 73  INTEGER(CMISSIntg), PARAMETER :: MeshUserNumber=5
 74  INTEGER(CMISSIntg), PARAMETER :: DecompositionUserNumber=6
 75  INTEGER(CMISSIntg), PARAMETER :: GeometricFieldUserNumber=7
 76  INTEGER(CMISSIntg), PARAMETER :: EquationsSetFieldUserNumber=8
 77  INTEGER(CMISSIntg), PARAMETER :: DependentFieldUserNumber=9
 78  INTEGER(CMISSIntg), PARAMETER :: MaterialsFieldUserNumber=10
 79  INTEGER(CMISSIntg), PARAMETER :: EquationsSetUserNumber=11
 80  INTEGER(CMISSIntg), PARAMETER :: ProblemUserNumber=12
 81  INTEGER(CMISSIntg), PARAMETER :: ControlLoopNode=0
 82  INTEGER(CMISSIntg), PARAMETER :: IndependentFieldUserNumber=13
 83  INTEGER(CMISSIntg), PARAMETER :: AnalyticFieldUserNumber=14
 84  INTEGER(CMISSIntg), PARAMETER :: SourceFieldUserNumber=15
 85
 86  INTEGER(CMISSIntg), PARAMETER :: MeshComponentNumber=1
 87
 88  !Program types
 89  
 90  !Program variables
 91
 92  INTEGER(CMISSIntg) :: NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS,NUMBER_GLOBAL_Z_ELEMENTS
 93  INTEGER(CMISSIntg) :: NUMBER_OF_DOMAINS
 94  
 95  INTEGER(CMISSIntg) :: MPI_IERROR
 96  
 97    !CMISS variables
 98
 99  TYPE(CMISSBasisType) :: Basis
100  TYPE(CMISSBoundaryConditionsType) :: BoundaryConditions
101  TYPE(CMISSCoordinateSystemType) :: CoordinateSystem,WorldCoordinateSystem
102  TYPE(CMISSDecompositionType) :: Decomposition
103  TYPE(CMISSEquationsType) :: Equations
104  TYPE(CMISSEquationsSetType) :: EquationsSet
105  TYPE(CMISSFieldType) :: GeometricField,EquationsSetField,DependentField,MaterialsField,IndependentField,AnalyticField,SourceField
106  TYPE(CMISSFieldsType) :: Fields
107  TYPE(CMISSGeneratedMeshType) :: GeneratedMesh  
108  TYPE(CMISSMeshType) :: Mesh
109  TYPE(CMISSProblemType) :: Problem
110  TYPE(CMISSControlLoopType) :: ControlLoop
111  TYPE(CMISSRegionType) :: Region,WorldRegion
112  TYPE(CMISSSolverType) :: Solver, LinearSolver
113  TYPE(CMISSSolverEquationsType) :: SolverEquations
114
115  LOGICAL :: EXPORT_FIELD,IMPORT_FIELD
116 
117
118#ifdef WIN32
119  !Quickwin type
120  LOGICAL :: QUICKWIN_STATUS=.FALSE.
121  TYPE(WINDOWCONFIG) :: QUICKWIN_WINDOW_CONFIG
122#endif
123  
124  !Generic CMISS variables
125  
126  INTEGER(CMISSIntg) :: EquationsSetIndex
127  INTEGER(CMISSIntg) :: FirstNodeNumber,LastNodeNumber
128  INTEGER(CMISSIntg) :: Err
129
130  INTEGER(CMISSIntg) :: dimensions, i
131  
132  !FieldML variables
133  CHARACTER(KIND=C_CHAR,LEN=*), PARAMETER :: outputDirectory = ""
134  CHARACTER(KIND=C_CHAR,LEN=*), PARAMETER :: outputFilename = "StaticAdvectionDiffusion.xml"
135  CHARACTER(KIND=C_CHAR,LEN=*), PARAMETER :: basename = "static_advection_diffusion"
136  CHARACTER(KIND=C_CHAR,LEN=*), PARAMETER :: dataFormat = "PLAIN_TEXT"
137
138  TYPE(CMISSFieldMLIOType) :: fieldmlInfo
139
140  
141#ifdef WIN32
142  !Initialise QuickWin
143  QUICKWIN_WINDOW_CONFIG%TITLE="General Output" !Window title
144  QUICKWIN_WINDOW_CONFIG%NUMTEXTROWS=-1 !Max possible number of rows
145  QUICKWIN_WINDOW_CONFIG%MODE=QWIN$SCROLLDOWN
146  !Set the window parameters
147  QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
148  !If attempt fails set with system estimated values
149  IF(.NOT.QUICKWIN_STATUS) QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
150#endif
151
152  !Intialise OpenCMISS
153  CALL CMISSInitialise(WorldCoordinateSystem,WorldRegion,Err)
154
155  CALL CMISSErrorHandlingModeSet(CMISS_ERRORS_TRAP_ERROR,Err)
156
157  NUMBER_GLOBAL_X_ELEMENTS=50
158  NUMBER_GLOBAL_Y_ELEMENTS=100
159  NUMBER_GLOBAL_Z_ELEMENTS=0
160  NUMBER_OF_DOMAINS=1
161
162
163  CALL MPI_BCAST(NUMBER_GLOBAL_X_ELEMENTS,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
164  CALL MPI_BCAST(NUMBER_GLOBAL_Y_ELEMENTS,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
165  CALL MPI_BCAST(NUMBER_GLOBAL_Z_ELEMENTS,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
166  CALL MPI_BCAST(NUMBER_OF_DOMAINS,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
167  
168  IF( NUMBER_GLOBAL_Z_ELEMENTS == 0 ) THEN
169    dimensions = 2
170  ELSE
171    dimensions = 3
172  ENDIF
173
174  !Start the creation of a new RC coordinate system
175  CALL CMISSCoordinateSystem_Initialise(CoordinateSystem,Err)
176  CALL CMISSCoordinateSystem_CreateStart(CoordinateSystemUserNumber,CoordinateSystem,Err)
177  CALL CMISSCoordinateSystem_DimensionSet(CoordinateSystem,dimensions,Err)
178  !Finish the creation of the coordinate system
179  CALL CMISSCoordinateSystem_CreateFinish(CoordinateSystem,Err)
180  
181  !Start the creation of the region
182  CALL CMISSRegion_Initialise(Region,Err)
183  CALL CMISSRegion_CreateStart(RegionUserNumber,WorldRegion,Region,Err)
184  !Set the regions coordinate system to the 2D RC coordinate system that we have created
185  CALL CMISSRegion_CoordinateSystemSet(Region,CoordinateSystem,Err)
186  !Finish the creation of the region
187  CALL CMISSRegion_CreateFinish(Region,Err)
188  
189  !Start the creation of a basis (default is trilinear lagrange)
190  CALL CMISSBasis_Initialise(Basis,Err)
191  CALL CMISSBasis_CreateStart(BasisUserNumber,Basis,Err)
192  CALL CMISSBasis_NumberOfXiSet(Basis,dimensions,Err)
193  !Finish the creation of the basis
194  CALL CMISSBasis_CreateFinish(BASIS,Err)
195  
196  !Start the creation of a generated mesh in the region
197  CALL CMISSGeneratedMesh_Initialise(GeneratedMesh,Err)
198  CALL CMISSGeneratedMesh_CreateStart(GeneratedMeshUserNumber,Region,GeneratedMesh,Err)
199  !Set up a regular x*y*z mesh
200  CALL CMISSGeneratedMesh_TypeSet(GeneratedMesh,CMISS_GENERATED_MESH_REGULAR_MESH_TYPE,Err)
201  !Set the default basis
202  CALL CMISSGeneratedMesh_BasisSet(GeneratedMesh,Basis,Err)   
203  !Define the mesh on the region
204  IF(dimensions == 2) THEN
205    CALL CMISSGeneratedMesh_ExtentSet(GeneratedMesh,(/WIDTH,HEIGHT/),Err)
206    CALL CMISSGeneratedMesh_NumberOfElementsSet(GeneratedMesh,(/NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS/),Err)
207  ELSE
208    CALL CMISSGeneratedMesh_ExtentSet(GeneratedMesh,(/WIDTH,HEIGHT,LENGTH/),Err)
209    CALL CMISSGeneratedMesh_NumberOfElementsSet(GeneratedMesh,(/NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS, &
210      & NUMBER_GLOBAL_Z_ELEMENTS/),Err)
211  ENDIF
212  !Finish the creation of a generated mesh in the region
213  CALL CMISSMesh_Initialise(Mesh,Err)
214  CALL CMISSGeneratedMesh_CreateFinish(GeneratedMesh,MeshUserNumber,Mesh,Err)
215  
216  !Create a decomposition
217  CALL CMISSDecomposition_Initialise(Decomposition,Err)
218  CALL CMISSDecomposition_CreateStart(DecompositionUserNumber,Mesh,Decomposition,Err)
219  !Set the decomposition to be a general decomposition with the specified number of domains
220  CALL CMISSDecomposition_TypeSet(Decomposition,CMISS_DECOMPOSITION_CALCULATED_TYPE,Err)
221  CALL CMISSDecomposition_NumberOfDomainsSet(Decomposition,NUMBER_OF_DOMAINS,Err)
222  !Finish the decomposition
223  CALL CMISSDecomposition_CreateFinish(Decomposition,Err)
224  
225  !Start to create a default (geometric) field on the region
226  CALL CMISSField_Initialise(GeometricField,Err)
227  CALL CMISSField_CreateStart(GeometricFieldUserNumber,Region,GeometricField,Err)
228  !Set the decomposition to use
229  CALL CMISSField_MeshDecompositionSet(GeometricField,Decomposition,Err)
230  !Set the domain to be used by the field components.
231  DO i = 1, dimensions
232    CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,i,MeshComponentNumber,Err)
233  ENDDO
234  !Finish creating the field
235  CALL CMISSField_CreateFinish(GeometricField,Err)
236  
237  !Update the geometric field parameters
238  CALL CMISSGeneratedMesh_GeometricParametersCalculate(GeneratedMesh,GeometricField,Err)
239  
240  !Create the equations_set
241  CALL CMISSEquationsSet_Initialise(EquationsSet,Err)
242    CALL CMISSField_Initialise(EquationsSetField,Err)
243  CALL CMISSEquationsSet_CreateStart(EquationsSetUserNumber,Region,GeometricField,CMISS_EQUATIONS_SET_CLASSICAL_FIELD_CLASS, &
244    & CMISS_EQUATIONS_SET_ADVECTION_DIFFUSION_EQUATION_TYPE,CMISS_EQUATIONS_SET_CONSTANT_SOURCE_STATIC_ADVEC_DIFF_SUBTYPE,&
245    & EquationsSetFieldUserNumber,EquationsSetField,EquationsSet,Err)
246  !Set the equations set to be a standard Laplace problem
247  !Finish creating the equations set
248  CALL CMISSEquationsSet_CreateFinish(EquationsSet,Err)
249
250  !Create the equations set dependent field variables
251  CALL CMISSField_Initialise(DependentField,Err)
252  CALL CMISSEquationsSet_DependentCreateStart(EquationsSet,DependentFieldUserNumber,DependentField,Err)
253  !Finish the equations set dependent field variables
254  CALL CMISSEquationsSet_DependentCreateFinish(EquationsSet,Err)
255
256  !Create the equations set material field variables
257  CALL CMISSField_Initialise(MaterialsField,Err)
258  CALL CMISSEquationsSet_MaterialsCreateStart(EquationsSet,MaterialsFieldUserNumber,MaterialsField,Err)
259  !Finish the equations set dependent field variables
260  CALL CMISSEquationsSet_MaterialsCreateFinish(EquationsSet,Err)
261
262  !Create the equations set source field variables
263  !For comparison withe analytical solution used here, the source field must be set to the following:
264  !f(x,y) = 2.0*tanh(-0.1E1+Alpha*(TanPhi*x-y))*(1.0-pow(tanh(-0.1E1+Alpha*(TanPhi*x-y)),2.0))*Alpha*Alpha*TanPhi*TanPhi
265  !+2.0*tanh(-0.1E1+Alpha*(TanPhi*x-y))*(1.0-pow(tanh(-0.1E1+Alpha*(TanPhi*x-y)),2.0))*Alpha*Alpha
266  !-Peclet*(-sin(6.0*y)*(1.0-pow(tanh(-0.1E1+Alpha*(TanPhi*x-y)),2.0))*Alpha*TanPhi+cos(6.0*x)*(1.0-pow(tanh(-0.1E1+Alpha*(TanPhi*x-y)),2.0))*Alpha)
267  CALL CMISSField_Initialise(SourceField,Err)
268  CALL CMISSEquationsSet_SourceCreateStart(EquationsSet,SourceFieldUserNumber,SourceField,Err)
269  CALL CMISSField_ComponentInterpolationSet(SourceField,CMISS_FIELD_U_VARIABLE_TYPE,1,CMISS_FIELD_NODE_BASED_INTERPOLATION,Err)
270  !Finish the equations set dependent field variables
271  CALL CMISSEquationsSet_SourceCreateFinish(EquationsSet,Err)
272
273  CALL CMISSField_ParameterSetDataGet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,GEOMETRIC_PARAMETERS, &
274    & Err)
275  !Create the equations set independent field variables
276  CALL CMISSField_Initialise(IndependentField,Err)
277  CALL CMISSEquationsSet_IndependentCreateStart(EquationsSet,IndependentFieldUserNumber,IndependentField,Err)
278  IF( dimensions == 2 ) THEN
279  !For comparison withe analytical solution used here, the independent field must be set to the following:
280  !w(x,y)=(sin 6y,cos 6x) FIELD_U_VARIABLE_TYPE,1,FIELD_NODE_BASED_INTERPOLATION
281!   CALL CMISSField_ComponentInterpolationSet(IndependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,CMISS_FIELD_NODE_BASED_INTERPOLATION,Err) 
282!   CALL CMISSField_ComponentInterpolationSet(IndependentField,CMISS_FIELD_U_VARIABLE_TYPE,2,CMISS_FIELD_NODE_BASED_INTERPOLATION,Err)
283  !Loop over nodes to set the appropriate function value
284!    DO
285
286!    ENDDO
287  ENDIF
288  !Finish the equations set dependent field variables
289  CALL CMISSEquationsSet_IndependentCreateFinish(EquationsSet,Err)
290
291  !Create the equations set analytic field variables
292  CALL CMISSField_Initialise(AnalyticField,Err)
293  IF( dimensions == 2) THEN  
294    CALL CMISSEquationsSet_AnalyticCreateStart(EquationsSet,CMISS_EQUATIONS_SET_ADVECTION_DIFFUSION_EQUATION_TWO_DIM_1,&
295      & AnalyticFieldUserNumber,AnalyticField,Err)
296  ELSE
297    WRITE(*,'(A)') "Three dimensions is not implemented."
298    STOP
299  ENDIF
300  !Finish the equations set analytic field variables
301  CALL CMISSEquationsSet_AnalyticCreateFinish(EquationsSet,Err)
302
303  !Create the equations set equations
304  CALL CMISSEquations_Initialise(Equations,Err)
305  CALL CMISSEquationsSet_EquationsCreateStart(EquationsSet,Equations,Err)
306  !Set the equations matrices sparsity type
307  CALL CMISSEquations_SparsityTypeSet(Equations,CMISS_EQUATIONS_SPARSE_MATRICES,Err)
308  !Set the equations set output
309  !CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_NO_OUTPUT,Err)
310  !CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_TIMING_OUTPUT,Err)
311  !CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_MATRIX_OUTPUT,Err)
312  !CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_ELEMENT_MATRIX_OUTPUT,Err)
313  !Finish the equations set equations
314  CALL CMISSEquationsSet_EquationsCreateFinish(EquationsSet,Err)
315  
316!   !Create the equations set boundary conditions
317!   CALL CMISSBoundaryConditions_Initialise(BoundaryConditions,Err)
318!   CALL CMISSEquationsSetBoundaryConditionsCreateStart(EquationsSet,BoundaryConditions,Err)
319!   !Set the first node to 0.0 and the last node to 1.0
320!   FirstNodeNumber=1
321!   IF( dimensions == 2 ) THEN
322!     LastNodeNumber=(NUMBER_GLOBAL_X_ELEMENTS+1)*(NUMBER_GLOBAL_Y_ELEMENTS+1)
323!   ELSE
324!     LastNodeNumber=(NUMBER_GLOBAL_X_ELEMENTS+1)*(NUMBER_GLOBAL_Y_ELEMENTS+1)*(NUMBER_GLOBAL_Z_ELEMENTS+1)
325!   ENDIF
326!   CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,CMISS_FIELD_U_VARIABLE_TYPE,1,FirstNodeNumber,1, &
327!     & CMISS_BOUNDARY_CONDITION_FIXED,0.0_CMISSDP,Err)
328!   CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,1,LastNodeNumber,1, &
329!     & CMISS_BOUNDARY_CONDITION_FIXED,1.0_CMISSDP,Err)
330!   !Finish the creation of the equations set boundary conditions
331!   CALL CMISSEquationsSetBoundaryConditionsCreateFinish(EquationsSet,Err)
332
333!   EXPORT_FIELD=.TRUE.
334!   IF(EXPORT_FIELD) THEN
335!     CALL CMISSFields_Initialise(Fields,Err)
336!     CALL CMISSFields_Create(Region,Fields,Err)
337!     CALL CMISSFields_NodesExport(Fields,"StaticAdvectionDiffusionInitial","FORTRAN",Err)
338!     CALL CMISSFields_ElementsExport(Fields,"StaticAdvectionDiffusionInitial","FORTRAN",Err)
339!     CALL CMISSFields_Finalise(Fields,Err)
340! 
341!   ENDIF
342
343
344  !Create the problem
345  CALL CMISSProblem_Initialise(Problem,Err)
346  CALL CMISSProblem_CreateStart(ProblemUserNumber,Problem,Err)
347  !Set the problem to be a no source static advection Diffusion problem
348!   CALL CMISSProblem_SpecificationSet(Problem,CMISS_PROBLEM_CLASSICAL_FIELD_CLASS,CMISS_PROBLEM_ADVECTION_DIFFUSION_EQUATION_TYPE, &
349!     & CMISS_PROBLEM_NO_SOURCE_STATIC_ADVEC_DIFF_SUBTYPE,Err)
350  CALL CMISSProblem_SpecificationSet(Problem,CMISS_PROBLEM_CLASSICAL_FIELD_CLASS,CMISS_PROBLEM_ADVECTION_DIFFUSION_EQUATION_TYPE, &
351    & CMISS_PROBLEM_LINEAR_SOURCE_STATIC_ADVEC_DIFF_SUBTYPE,Err)
352  !Finish the creation of a problem.
353  CALL CMISSProblem_CreateFinish(Problem,Err)
354
355  !Create the problem control
356  CALL CMISSProblem_ControlLoopCreateStart(Problem,Err)
357  !CALL CMISSControlLoop_Initialise(ControlLoop,Err)
358  !Get the control loop
359  !CALL CMISSProblem_ControlLoopGet(Problem,ControlLoopNode,ControlLoop,Err)
360  !Set the times
361  !CALL CMISSControlLoop_TimesSet(ControlLoop,0.0_CMISSDP,1.0_CMISSDP,0.1_CMISSDP,Err)
362  !Finish creating the problem control loop
363  CALL CMISSProblem_ControlLoopCreateFinish(Problem,Err)
364
365  !Start the creation of the problem solvers
366!  
367! !   !For the Direct Solver MUMPS, uncomment the below two lines and comment out the above five
368! !   CALL SOLVER_LINEAR_TYPE_SET(LINEAR_SOLVER,SOLVER_LINEAR_DIRECT_SOLVE_TYPE,ERR,ERROR,*999)
369! !   CALL SOLVER_LINEAR_DIRECT_TYPE_SET(LINEAR_SOLVER,SOLVER_DIRECT_MUMPS,ERR,ERROR,*999) 
370! 
371
372  CALL CMISSSolver_Initialise(Solver,Err)
373  !CALL CMISSSolver_Initialise(LinearSolver,Err)
374  CALL CMISSProblem_SolversCreateStart(Problem,Err)
375  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,1,Solver,Err)
376  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_NO_OUTPUT,Err)
377  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_PROGRESS_OUTPUT,Err)
378  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_TIMING_OUTPUT,Err)
379  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_SOLVER_OUTPUT,Err)
380  CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_PROGRESS_OUTPUT,Err)
381  !CALL CMISSSolver_DynamicLinearSolverGet(Solver,LinearSolver,Err)
382  !CALL CMISSSolver_LinearIterativeMaximumIterationsSet(LinearSolver,300,Err)
383  !Finish the creation of the problem solver
384  CALL CMISSProblem_SolversCreateFinish(Problem,Err)
385
386
387  !Create the problem solver equations
388  CALL CMISSSolver_Initialise(Solver,Err)
389  CALL CMISSSolverEquations_Initialise(SolverEquations,Err)
390  CALL CMISSProblem_SolverEquationsCreateStart(Problem,Err)
391  !Get the solve equations
392  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,1,Solver,Err)
393  CALL CMISSSolver_SolverEquationsGet(Solver,SolverEquations,Err)
394  !Set the solver equations sparsity
395  CALL CMISSSolverEquations_SparsityTypeSet(SolverEquations,CMISS_SOLVER_SPARSE_MATRICES,Err)
396  !CALL CMISSSolverEquations_SparsityTypeSet(SolverEquations,CMISS_SOLVER_FULL_MATRICES,Err)  
397  !Add in the equations set
398  CALL CMISSSolverEquations_EquationsSetAdd(SolverEquations,EquationsSet,EquationsSetIndex,Err)
399  !Finish the creation of the problem solver equations
400  CALL CMISSProblem_SolverEquationsCreateFinish(Problem,Err)
401  CALL CMISSBoundaryConditions_Initialise(BoundaryConditions,Err)
402  CALL CMISSSolverEquations_BoundaryConditionsCreateStart(SolverEquations,BoundaryConditions,Err)
403  CALL CMISSSolverEquations_BoundaryConditionsAnalytic(SolverEquations,Err)
404  CALL CMISSSolverEquations_BoundaryConditionsCreateFinish(SolverEquations,Err)
405  
406  !Solve the problem
407  CALL CMISSProblem_Solve(Problem,Err)
408
409 !Output Analytic analysis
410  Call CMISSAnalyticAnalysisOutput(DependentField,"StaticAdvectionDiffusionAnalytics",Err)
411
412  EXPORT_FIELD=.TRUE.
413  IF(EXPORT_FIELD) THEN
414    !CALL CMISSFields_Initialise(Fields,Err)
415    !CALL CMISSFields_Create(Region,Fields,Err)
416    !CALL CMISSFields_NodesExport(Fields,"StaticAdvectionDiffusion","FORTRAN",Err)
417    !CALL CMISSFields_ElementsExport(Fields,"StaticAdvectionDiffusion","FORTRAN",Err)
418    !CALL CMISSFields_Finalise(Fields,Err)
419   
420    CALL CMISSFieldMLIO_Initialise( fieldmlInfo, err ) 
421    CALL CMISSFieldML_OutputCreate( Mesh, outputDirectory, basename, dataFormat, fieldmlInfo, err )
422
423    CALL CMISSFieldML_OutputAddField( fieldmlInfo, baseName//".geometric", dataFormat, GeometricField, &
424      & CMISS_FIELD_U_VARIABLE_TYPE, CMISS_FIELD_VALUES_SET_TYPE, err )
425
426    CALL CMISSFieldML_OutputAddField( fieldmlInfo, baseName//".dependent", dataFormat, DependentField, &
427      & CMISS_FIELD_U_VARIABLE_TYPE, CMISS_FIELD_VALUES_SET_TYPE, err )
428
429    CALL CMISSFieldML_OutputAddField( fieldmlInfo, baseName//".independent", dataFormat, IndependentField, &
430      & CMISS_FIELD_U_VARIABLE_TYPE, CMISS_FIELD_VALUES_SET_TYPE, err )
431
432    CALL CMISSFieldML_OutputAddField( fieldmlInfo, baseName//".source", dataFormat, SourceField, &
433      & CMISS_FIELD_U_VARIABLE_TYPE, CMISS_FIELD_VALUES_SET_TYPE, err )
434
435    CALL CMISSFieldML_OutputAddField( fieldmlInfo, baseName//".materials", dataFormat, MaterialsField, &
436      & CMISS_FIELD_U_VARIABLE_TYPE, CMISS_FIELD_VALUES_SET_TYPE, err )
437
438    !CALL FieldmlOutputAddField( fieldmlInfo, baseName//".analytic", dataFormat, region, mesh, AnalyticField, &
439    !  & CMISS_FIELD_U_VARIABLE_TYPE, CMISS_FIELD_VALUES_SET_TYPE, err )
440    
441    CALL CMISSFieldML_OutputWrite( fieldmlInfo, outputFilename, err )
442    
443    CALL CMISSFieldMLIO_Finalise( fieldmlInfo, err )
444
445  ENDIF
446
447  !CALL CMISSFinalise(Err)
448  WRITE(*,'(A)') "Program successfully completed."
449  
450  STOP
451
452END PROGRAM STATICADVECTIONDIFFUSIONEXAMPLE