PageRenderTime 43ms CodeModel.GetById 10ms app.highlight 27ms RepoModel.GetById 2ms app.codeStats 0ms

/FluidMechanics/Burgers/StaticBurgers/src/StaticBurgersExample.f90

http://github.com/xyan075/examples
FORTRAN Modern | 486 lines | 222 code | 67 blank | 197 comment | 0 complexity | 4c1cbf7a7faed5abef8304867208e0c9 MD5 | raw file
  1!> \file
  2!> \author David Ladd
  3!> \brief This is an example program to solve a viscous burgers 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 FluidMechanics/Burgers/StaticBurgers/src/BurgersExample.f90
 43!! Example program to solve a burgers equation using openCMISS calls.
 44!! \htmlinclude FluidMechanics/Burgers/StaticBurgers/history.html
 45!<
 46
 47!> Main program
 48PROGRAM STATICBURGERSEXAMPLE
 49
 50
 51  USE OPENCMISS
 52  USE MPI
 53
 54
 55#ifdef WIN32
 56  USE IFQWIN
 57#endif
 58
 59  IMPLICIT NONE
 60
 61  !-----------------------------------------------------------------------------------------------------------
 62  ! PROGRAM VARIABLES AND TYPES
 63  !-----------------------------------------------------------------------------------------------------------
 64
 65  INTEGER(CMISSIntg), PARAMETER :: EquationsSetFieldUserNumber=1337
 66  TYPE(CMISSFieldType) :: EquationsSetField
 67
 68  !Test program parameters
 69  
 70  INTEGER(CMISSIntg), PARAMETER :: CoordinateSystemUserNumber=1
 71  INTEGER(CMISSIntg), PARAMETER :: RegionUserNumber=2
 72  INTEGER(CMISSIntg), PARAMETER :: BasisUserNumber=3
 73  INTEGER(CMISSIntg), PARAMETER :: GeneratedMeshUserNumber=4
 74  INTEGER(CMISSIntg), PARAMETER :: MeshUserNumber=5
 75  INTEGER(CMISSIntg), PARAMETER :: DecompositionUserNumber=6
 76  INTEGER(CMISSIntg), PARAMETER :: GeometricFieldUserNumber=7
 77  INTEGER(CMISSIntg), PARAMETER :: DependentFieldUserNumber=8
 78  INTEGER(CMISSIntg), PARAMETER :: MaterialsFieldUserNumber=9
 79  INTEGER(CMISSIntg), PARAMETER :: EquationsSetUserNumber=10
 80  INTEGER(CMISSIntg), PARAMETER :: ProblemUserNumber=11
 81  INTEGER(CMISSIntg), PARAMETER :: ControlLoopNode=0
 82  INTEGER(CMISSIntg), PARAMETER :: AnalyticFieldUserNumber=12
 83  INTEGER(CMISSIntg), PARAMETER :: SolverUserNumber=1
 84  
 85  !Program variables
 86
 87  INTEGER(CMISSIntg) :: NUMBER_GLOBAL_X_ELEMENTS
 88  INTEGER(CMISSIntg) :: NUMBER_OF_DOMAINS
 89  INTEGER(CMISSIntg) :: COMPONENT_NUMBER
 90
 91  INTEGER(CMISSIntg) :: MAXIMUM_ITERATIONS
 92  INTEGER(CMISSIntg) :: RESTART_VALUE
 93  
 94  INTEGER(CMISSIntg) :: MPI_IERROR
 95
 96  INTEGER(CMISSIntg) :: NONLINEAR_SOLVER_OUTPUT_TYPE
 97  INTEGER(CMISSIntg) :: LINEAR_SOLVER_OUTPUT_TYPE
 98
 99  REAL(CMISSDP) :: DIVERGENCE_TOLERANCE
100  REAL(CMISSDP) :: RELATIVE_TOLERANCE
101  REAL(CMISSDP) :: ABSOLUTE_TOLERANCE
102  REAL(CMISSDP) :: LINESEARCH_ALPHA
103
104  LOGICAL :: LINEAR_SOLVER_DIRECT_FLAG
105
106  REAL(CMISSDP) :: NU_PARAM
107  REAL(CMISSDP) :: LENGTH
108
109  INTEGER(CMISSIntg) :: NODE_NUMBER
110  INTEGER(CMISSIntg) :: ELEMENT_NUMBER
111  INTEGER(CMISSIntg) :: NODE_COUNTER
112  INTEGER(CMISSIntg) :: CONDITION
113
114  INTEGER(CMISSIntg) :: FirstNodeNumber,LastNodeNumber,FirstNodeDomain,LastNodeDomain
115  
116  !Program types
117
118  TYPE(CMISSBasisType) :: Basis
119  TYPE(CMISSBoundaryConditionsType) :: BoundaryConditions
120  TYPE(CMISSCoordinateSystemType) :: CoordinateSystem,WorldCoordinateSystem
121  TYPE(CMISSDecompositionType) :: Decomposition
122  TYPE(CMISSEquationsType) :: Equations
123  TYPE(CMISSEquationsSetType) :: EquationsSet
124  TYPE(CMISSFieldType) :: GeometricField,DependentField,MaterialsField,AnalyticField
125  TYPE(CMISSFieldsType) :: Fields
126  TYPE(CMISSGeneratedMeshType) :: GeneratedMesh  
127  TYPE(CMISSMeshType) :: Mesh
128  TYPE(CMISSNodesType) :: Nodes
129  TYPE(CMISSProblemType) :: Problem
130  TYPE(CMISSControlLoopType) :: ControlLoop
131  TYPE(CMISSRegionType) :: Region,WorldRegion
132  TYPE(CMISSSolverType) :: Solver, LinearSolver, NonlinearSolver
133  TYPE(CMISSSolverEquationsType) :: SolverEquations
134
135  LOGICAL :: EXPORT_FIELD
136
137#ifdef WIN32
138  !Quickwin type
139  LOGICAL :: QUICKWIN_STATUS=.FALSE.
140  TYPE(WINDOWCONFIG) :: QUICKWIN_WINDOW_CONFIG
141#endif
142  
143  !Generic CMISS variables
144  
145  INTEGER(CMISSIntg) :: NumberOfComputationalNodes,ComputationalNodeNumber,BoundaryNodeDomain
146  INTEGER(CMISSIntg) :: EquationsSetIndex
147  INTEGER(CMISSIntg) :: Err
148
149  
150#ifdef WIN32
151  !Initialise QuickWin
152  QUICKWIN_WINDOW_CONFIG%TITLE="General Output" !Window title
153  QUICKWIN_WINDOW_CONFIG%NUMTEXTROWS=-1 !Max possible number of rows
154  QUICKWIN_WINDOW_CONFIG%MODE=QWIN$SCROLLDOWN
155  !Set the window parameters
156  QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
157  !If attempt fails set with system estimated values
158  IF(.NOT.QUICKWIN_STATUS) QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
159#endif
160
161  !Intialise OpenCMISS
162  CALL CMISSInitialise(WorldCoordinateSystem,WorldRegion,Err)
163
164  !Get the computational nodes information
165  CALL CMISSComputationalNumberOfNodesGet(NumberOfComputationalNodes,Err)
166  CALL CMISSComputationalNodeNumberGet(ComputationalNodeNumber,Err)
167
168  !-----------------------------------------------------------------------------------------------------------
169  ! PROBLEM CONTROL PANEL
170  !-----------------------------------------------------------------------------------------------------------
171  
172  ! Set number of elements for FEM discretization
173  NUMBER_GLOBAL_X_ELEMENTS=4
174  NUMBER_OF_DOMAINS=NumberOfComputationalNodes
175
176  ! Set viscous coefficient
177  NU_PARAM = 1.0_CMISSDP
178  ! Set length of domain
179  LENGTH = 1.0_CMISSDP
180
181  !Set solver parameters
182  LINEAR_SOLVER_DIRECT_FLAG=.FALSE.
183  RELATIVE_TOLERANCE=1.0E-6_CMISSDP !default: 1.0E-05_CMISSDP
184  ABSOLUTE_TOLERANCE=1.0E-6_CMISSDP !default: 1.0E-10_CMISSDP
185  DIVERGENCE_TOLERANCE=1.0E5 !default: 1.0E5
186  MAXIMUM_ITERATIONS=100000 !default: 100000
187  RESTART_VALUE=3000 !default: 30
188  LINESEARCH_ALPHA=1.0
189
190
191  !Set all diganostic levels on for testing
192  CALL MPI_BCAST(NUMBER_GLOBAL_X_ELEMENTS,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
193  CALL MPI_BCAST(NUMBER_OF_DOMAINS,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
194
195  !-----------------------------------------------------------------------------------------------------------
196  !COORDINATE SYSTEM
197  !-----------------------------------------------------------------------------------------------------------
198  !Start the creation of a new RC coordinate system
199  CALL CMISSCoordinateSystem_Initialise(CoordinateSystem,Err)
200  CALL CMISSCoordinateSystem_CreateStart(CoordinateSystemUserNumber,CoordinateSystem,Err)
201  !Set the coordinate system to be 1D
202  CALL CMISSCoordinateSystem_DimensionSet(CoordinateSystem,1,Err)
203  !Finish the creation of the coordinate system
204  CALL CMISSCoordinateSystem_CreateFinish(CoordinateSystem,Err) 
205
206  !-----------------------------------------------------------------------------------------------------------
207  !REGION
208  !-----------------------------------------------------------------------------------------------------------
209  !Start the creation of the region
210  CALL CMISSRegion_Initialise(Region,Err)
211  CALL CMISSRegion_CreateStart(RegionUserNumber,WorldRegion,Region,Err)
212  CALL CMISSRegion_LabelSet(Region,"BurgersRegion",Err)
213  !Set the regions coordinate system to the 1D RC coordinate system that we have created
214  CALL CMISSRegion_CoordinateSystemSet(Region,CoordinateSystem,Err)
215  !Finish the creation of the region
216  CALL CMISSRegion_CreateFinish(Region,Err)
217  
218  !-----------------------------------------------------------------------------------------------------------
219  !BASIS
220  !-----------------------------------------------------------------------------------------------------------
221  !Start the creation of a basis
222  CALL CMISSBasis_Initialise(Basis,Err)
223  CALL CMISSBasis_CreateStart(BasisUserNumber,Basis,Err)
224  CALL CMISSBasis_TypeSet(Basis,CMISS_BASIS_LAGRANGE_HERMITE_TP_TYPE,Err)
225  CALL CMISSBasis_NumberOfXiSet(Basis,1,Err)
226  !Set the basis xi interpolation and number of Gauss points
227  CALL CMISSBasis_InterpolationXiSet(Basis,(/CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION/),Err)
228  CALL CMISSBasis_QuadratureNumberOfGaussXiSet(Basis,(/2/),Err)
229  !Finish the creation of the basis
230  CALL CMISSBasis_CreateFinish(Basis,Err)
231
232  !-----------------------------------------------------------------------------------------------------------
233  !MESH
234  !-----------------------------------------------------------------------------------------------------------
235  !Start the creation of a generated mesh in the region
236  CALL CMISSGeneratedMesh_Initialise(GeneratedMesh,Err)
237  CALL CMISSGeneratedMesh_CreateStart(GeneratedMeshUserNumber,Region,GeneratedMesh,Err)
238  !Set up a regular x mesh
239  CALL CMISSGeneratedMesh_TypeSet(GeneratedMesh,CMISS_GENERATED_MESH_REGULAR_MESH_TYPE,Err)
240  !Set the default basis
241  CALL CMISSGeneratedMesh_BasisSet(GeneratedMesh,Basis,Err)   
242  !Define the mesh on the region
243  CALL CMISSGeneratedMesh_ExtentSet(GeneratedMesh,(/LENGTH/),Err)
244  CALL CMISSGeneratedMesh_NumberOfElementsSet(GeneratedMesh,(/NUMBER_GLOBAL_X_ELEMENTS/),Err)
245  !Finish the creation of a generated mesh in the region
246  CALL CMISSMesh_Initialise(Mesh,Err)
247  CALL CMISSGeneratedMesh_CreateFinish(GeneratedMesh,MeshUserNumber,Mesh,Err)
248
249  !-----------------------------------------------------------------------------------------------------------  
250  !GEOMETRIC FIELD
251  !-----------------------------------------------------------------------------------------------------------
252
253  !Create a decomposition
254  CALL CMISSDecomposition_Initialise(Decomposition,Err)
255  CALL CMISSDecomposition_CreateStart(DecompositionUserNumber,Mesh,Decomposition,Err)
256  !Set the decomposition to be a general decomposition with the specified number of domains
257  CALL CMISSDecomposition_TypeSet(Decomposition,CMISS_DECOMPOSITION_CALCULATED_TYPE,Err)
258  CALL CMISSDecomposition_NumberOfDomainsSet(Decomposition,NUMBER_OF_DOMAINS,Err)
259  !Finish the decomposition
260  CALL CMISSDecomposition_CreateFinish(Decomposition,Err)
261  
262  !Start to create a default (geometric) field on the region
263  CALL CMISSField_Initialise(GeometricField,Err)
264  CALL CMISSField_CreateStart(GeometricFieldUserNumber,Region,GeometricField,Err)
265  !Set the decomposition to use
266  CALL CMISSField_MeshDecompositionSet(GeometricField,Decomposition,Err)
267  !Set the scaling to use
268  CALL CMISSField_ScalingTypeSet(GeometricField,CMISS_FIELD_NO_SCALING,Err)
269  !Set the domain to be used by the field components.
270  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,Err)
271  !Finish creating the field
272  CALL CMISSField_CreateFinish(GeometricField,Err)  
273  !Update the geometric field parameters
274  CALL CMISSGeneratedMesh_GeometricParametersCalculate(GeneratedMesh,GeometricField,Err)
275
276  !-----------------------------------------------------------------------------------------------------------  
277  !EQUATIONS SETS
278  !-----------------------------------------------------------------------------------------------------------
279  
280  !Create the equations_set for a static nonlinear burgers equation
281  CALL CMISSEquationsSet_Initialise(EquationsSet,Err)
282  CALL CMISSField_Initialise(EquationsSetField,Err)
283  CALL CMISSEquationsSet_CreateStart(EquationsSetUserNumber,Region,GeometricField,CMISS_EQUATIONS_SET_FLUID_MECHANICS_CLASS, &
284    & CMISS_EQUATIONS_SET_BURGERS_EQUATION_TYPE,CMISS_EQUATIONS_SET_STATIC_BURGERS_SUBTYPE,EquationsSetFieldUserNumber, &
285    & EquationsSetField,EquationsSet,Err)
286  !Finish creating the equations set
287  CALL CMISSEquationsSet_CreateFinish(EquationsSet,Err)
288
289  !-----------------------------------------------------------------------------------------------------------
290  ! DEPENDENT FIELD
291  !-----------------------------------------------------------------------------------------------------------
292  !Create the equations set dependent field variables
293  CALL CMISSField_Initialise(DependentField,Err)
294  CALL CMISSEquationsSet_DependentCreateStart(EquationsSet,DependentFieldUserNumber,DependentField,Err)
295  !Set the mesh component to be used by the field components.
296  COMPONENT_NUMBER = 1
297  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,COMPONENT_NUMBER, & 
298    & COMPONENT_NUMBER,Err)
299  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,COMPONENT_NUMBER, & 
300    & COMPONENT_NUMBER,Err)
301  !Finish the equations set dependent field variables
302  CALL CMISSEquationsSet_DependentCreateFinish(EquationsSet,Err)
303  !Initialise dependent field
304  CALL CMISSField_ComponentValuesInitialise(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, & 
305    & COMPONENT_NUMBER,0.0_CMISSDP,Err)
306
307  !-----------------------------------------------------------------------------------------------------------
308  ! MATERIALS FIELD
309  !-----------------------------------------------------------------------------------------------------------
310  !Create the equations set material field variables
311  CALL CMISSField_Initialise(MaterialsField,Err)
312  CALL CMISSEquationsSet_MaterialsCreateStart(EquationsSet,MaterialsFieldUserNumber,MaterialsField,Err)
313  !Finish the equations set material field variables
314  CALL CMISSEquationsSet_MaterialsCreateFinish(EquationsSet,Err)
315  !Initialise materials field
316  CALL CMISSField_ComponentValuesInitialise(MaterialsField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, & 
317    & 1,NU_PARAM,Err)
318
319  !-----------------------------------------------------------------------------------------------------------
320  ! ANALYTIC FIELD
321  !-----------------------------------------------------------------------------------------------------------
322  !Create the equations set analytic field variables
323  !CALL CMISSField_Initialise(AnalyticField,Err)
324  !CALL CMISSEquationsSet_AnalyticCreateStart(EquationsSet,CMISS_EQUATIONS_SET_BURGERS_EQUATION_ONE_DIM_1,AnalyticFieldUserNumber, & 
325  ! & AnalyticField,Err)
326  !Finish the equations set analytic field variables
327  !CALL CMISSEquationsSet_AnalyticCreateFinish(EquationsSet,Err)
328
329  !-----------------------------------------------------------------------------------------------------------  
330  ! EQUATIONS
331  !-----------------------------------------------------------------------------------------------------------
332  !Create the equations set equations
333  CALL CMISSEquations_Initialise(Equations,Err)
334  CALL CMISSEquationsSet_EquationsCreateStart(EquationsSet,Equations,Err)
335  !Set the equations matrices sparsity type (Sparse/Full)
336  CALL CMISSEquations_SparsityTypeSet(Equations,CMISS_EQUATIONS_FULL_MATRICES,Err)
337  !Set the equations set output (NoOutput/TimingOutput/MatrixOutput/SolverMatrix/ElementMatrixOutput)
338  CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_NO_OUTPUT,Err)
339  !Finish the equations set equations
340  CALL CMISSEquationsSet_EquationsCreateFinish(EquationsSet,Err)
341
342  !Create the equations set boundary conditions
343  !CALL CMISSEquationsSetBoundaryConditionsAnalytic(EquationsSet,Err)
344
345  !-----------------------------------------------------------------------------------------------------------
346  !PROBLEM
347  !-----------------------------------------------------------------------------------------------------------
348  !Create the problem
349  CALL CMISSProblem_Initialise(Problem,Err)
350  CALL CMISSProblem_CreateStart(ProblemUserNumber,Problem,Err)
351  !Set the problem to be a static Burgers problem
352  CALL CMISSProblem_SpecificationSet(Problem,CMISS_PROBLEM_FLUID_MECHANICS_CLASS,CMISS_PROBLEM_BURGERS_EQUATION_TYPE, &
353    & CMISS_PROBLEM_STATIC_BURGERS_SUBTYPE,Err)
354  !Finish the creation of a problem.
355  CALL CMISSProblem_CreateFinish(Problem,Err)
356
357  !Create the problem control
358  CALL CMISSControlLoop_Initialise(ControlLoop,Err)
359  CALL CMISSProblem_ControlLoopCreateStart(Problem,Err)
360  !Get the control loop
361  !CALL CMISSProblem_ControlLoopGet(Problem,CMISS_CONTROL_LOOP_NODE,ControlLoop,Err)
362
363  !Finish creating the problem control loop
364  CALL CMISSProblem_ControlLoopCreateFinish(Problem,Err)
365
366  !-----------------------------------------------------------------------------------------------------------
367  !SOLVER
368  !-----------------------------------------------------------------------------------------------------------
369  !Start the creation of the problem solvers
370  !CALL CMISSSolver_Initialise(Solver,Err)
371  CALL CMISSSolver_Initialise(NonlinearSolver,Err)
372  CALL CMISSSolver_Initialise(LinearSolver,Err)
373  CALL CMISSProblem_SolversCreateStart(Problem,Err)
374
375  !Get the nonlinear solver
376  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,SolverUserNumber,NonlinearSolver,Err)
377  !Set the nonlinear Jacobian type
378  CALL CMISSSolver_NewtonJacobianCalculationTypeSet(NonlinearSolver,CMISS_SOLVER_NEWTON_JACOBIAN_EQUATIONS_CALCULATED,Err)
379  !Set the output type (No/Progress/Timing/Solver)
380  CALL CMISSSolver_OutputTypeSet(NonlinearSolver,CMISS_SOLVER_MATRIX_OUTPUT,Err)
381  !Set the solver settings
382  CALL CMISSSolver_NewtonAbsoluteToleranceSet(NonlinearSolver,ABSOLUTE_TOLERANCE,Err)
383  CALL CMISSSolver_NewtonRelativeToleranceSet(NonlinearSolver,RELATIVE_TOLERANCE,Err)
384  !Get the nonlinear linear solver
385  CALL CMISSSolver_NewtonLinearSolverGet(NonlinearSolver,LinearSolver,Err)
386  !Set the output type
387  CALL CMISSSolver_OutputTypeSet(LinearSolver,CMISS_SOLVER_MATRIX_OUTPUT,Err)
388
389  !Set the solver settings
390  IF(LINEAR_SOLVER_DIRECT_FLAG) THEN
391    CALL CMISSSolver_LinearTypeSet(LinearSolver,CMISS_SOLVER_LINEAR_DIRECT_SOLVE_TYPE,Err)
392    CALL CMISSSolver_LibraryTypeSet(LinearSolver,CMISS_SOLVER_MUMPS_LIBRARY,Err)
393  ELSE
394    CALL CMISSSolver_LinearTypeSet(LinearSolver,CMISS_SOLVER_LINEAR_ITERATIVE_SOLVE_TYPE,Err)
395    CALL CMISSSolver_LinearIterativeMaximumIterationsSet(LinearSolver,MAXIMUM_ITERATIONS,Err)
396    CALL CMISSSolver_LinearIterativeDivergenceToleranceSet(LinearSolver,DIVERGENCE_TOLERANCE,Err)
397    CALL CMISSSolver_LinearIterativeRelativeToleranceSet(LinearSolver,RELATIVE_TOLERANCE,Err)
398    CALL CMISSSolver_LinearIterativeAbsoluteToleranceSet(LinearSolver,ABSOLUTE_TOLERANCE,Err)
399    CALL CMISSSolver_LinearIterativeGMRESRestartSet(LinearSolver,RESTART_VALUE,Err)
400  ENDIF
401  !Finish the creation of the problem solver
402  CALL CMISSProblem_SolversCreateFinish(Problem,Err)
403
404
405  !-----------------------------------------------------------------------------------------------------------
406  !SOLVER EQUATIONS
407  !-----------------------------------------------------------------------------------------------------------
408  !Create the problem solver equations
409  CALL CMISSSolver_Initialise(LinearSolver,Err)
410  CALL CMISSSolverEquations_Initialise(SolverEquations,Err)
411  CALL CMISSProblem_SolverEquationsCreateStart(Problem,Err)
412  !Get the solver equations
413  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,1,LinearSolver,Err)
414  CALL CMISSSolver_SolverEquationsGet(LinearSolver,SolverEquations,Err)
415  !Set the solver equations sparsity (Sparse/Full)
416  CALL CMISSSolverEquations_SparsityTypeSet(SolverEquations,CMISS_SOLVER_FULL_MATRICES,Err)  
417  !Add in the equations set
418  CALL CMISSSolverEquations_EquationsSetAdd(SolverEquations,EquationsSet,EquationsSetIndex,Err)
419  !Finish the creation of the problem solver equations
420  CALL CMISSProblem_SolverEquationsCreateFinish(Problem,Err)
421
422  !-----------------------------------------------------------------------------------------------------------
423  !BOUNDARY CONDITIONS
424  !-----------------------------------------------------------------------------------------------------------
425  !Set up the boundary conditions
426  CALL CMISSBoundaryConditions_Initialise(BoundaryConditions,Err)
427  CALL CMISSSolverEquations_BoundaryConditionsCreateStart(SolverEquations,BoundaryConditions,Err)
428  !Set the fixed boundary conditions at the first node and last nodes
429  FirstNodeNumber=1
430  COMPONENT_NUMBER=1
431  CALL CMISSNodes_Initialise(Nodes,Err)
432  CALL CMISSRegion_NodesGet(Region,Nodes,Err)
433  CALL CMISSNodes_NumberOfNodesGet(Nodes,LastNodeNumber,Err)
434  CALL CMISSDecomposition_NodeDomainGet(Decomposition,FirstNodeNumber,1,FirstNodeDomain,Err)
435  CALL CMISSDecomposition_NodeDomainGet(Decomposition,LastNodeNumber,1,LastNodeDomain,Err)
436  IF(FirstNodeDomain==ComputationalNodeNumber) THEN
437    CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1, &
438      & CMISS_NO_GLOBAL_DERIV,FirstNodeNumber,COMPONENT_NUMBER,CMISS_BOUNDARY_CONDITION_FIXED, &
439      & 1.0_CMISSDP,Err)
440  ENDIF
441  IF(LastNodeDomain==ComputationalNodeNumber) THEN
442    CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1, &
443      & CMISS_NO_GLOBAL_DERIV,LastNodeNumber,COMPONENT_NUMBER,CMISS_BOUNDARY_CONDITION_FIXED, &
444      & 0.0_CMISSDP,Err)
445  ENDIF
446  CALL CMISSSolverEquations_BoundaryConditionsCreateFinish(SolverEquations,Err)
447  !-----------------------------------------------------------------------------------------------------------
448  !SOLVE
449  !-----------------------------------------------------------------------------------------------------------
450  !Solve the problem
451  CALL CMISSProblem_Solve(Problem,Err)
452
453  !-----------------------------------------------------------------------------------------------------------
454  !OUTPUT
455  !-----------------------------------------------------------------------------------------------------------
456  !Output Analytic analysis
457  !Call CMISSAnalyticAnalysisOutput(DependentField,"BurgersAnalytics_1D",Err)
458
459  !export fields
460  EXPORT_FIELD=.TRUE.
461  IF(EXPORT_FIELD) THEN
462    CALL CMISSFields_Initialise(Fields,Err)
463    CALL CMISSFields_Create(Region,Fields,Err)
464    CALL CMISSFields_NodesExport(Fields,"Burgers_1D","FORTRAN",Err)
465    CALL CMISSFields_ElementsExport(Fields,"Burgers_1D","FORTRAN",Err)
466    CALL CMISSFields_Finalise(Fields,Err)
467  ENDIF
468  
469  !Output timing summary
470  !CALL TIMING_SUMMARY_OUTPUT(ERR,ERROR,*999)
471
472  !Calculate the stop times and write out the elapsed user and system times
473!   CALL CPU_TIMER(USER_CPU,STOP_USER_TIME,ERR,ERROR,*999)
474!   CALL CPU_TIMER(SYSTEM_CPU,STOP_SYSTEM_TIME,ERR,ERROR,*999)
475! 
476!   CALL WRITE_STRING_TWO_VALUE(GENERAL_OUTPUT_TYPE,"User time = ",STOP_USER_TIME(1)-START_USER_TIME(1),", System time = ", &
477!     & STOP_SYSTEM_TIME(1)-START_SYSTEM_TIME(1),ERR,ERROR,*999)
478!   
479  !CALL CMISS_FINALISE(ERR,ERROR,*999)
480  !CALL CMISSFinalise(Err)
481  WRITE(*,'(A)') "Program successfully completed."
482  
483
484  STOP
485  
486END PROGRAM STATICBURGERSEXAMPLE