PageRenderTime 122ms CodeModel.GetById 42ms app.highlight 73ms RepoModel.GetById 1ms app.codeStats 0ms

/42TestingPoints/SinglePhysics/NonlinearProblems/DynamicProblems/NavierStokes/3D/TET/CubicVelocityLinearPressure/LEVEL_2/src/LEVEL_2Example.f90

http://github.com/xyan075/examples
FORTRAN Modern | 851 lines | 478 code | 112 blank | 261 comment | 0 complexity | 47be9ec72fa51bf74562373696de8d12 MD5 | raw file
  1!> \file
  2!> \author Sebastian Krittian
  3!> \brief This is an example program to solve a dynamic Stokes 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/NavierStokes/Static/src/StaticExample.f90
 43!! Example program to solve an analytic dynamic Navier-Stokes equation using OpenCMISS calls.
 44!! \par Latest Builds:
 45!! \li <a href='http://autotest.bioeng.auckland.ac.nz/opencmiss-build/logs_x86_64-linux/FluidMechanics/Stokes/Static/build-intel'>Linux Intel Build</a>
 46!! \li <a href='http://autotest.bioeng.auckland.ac.nz/opencmiss-build/logs_x86_64-linux/FluidMechanics/Stokes/Static/build-intel'>Linux GNU Build</a>
 47!!
 48!<
 49
 50!> Main program
 51
 52PROGRAM ANALYTICNAVIERSTOKESEXAMPLE
 53
 54  !
 55  !================================================================================================================================
 56  !
 57
 58  !PROGRAM LIBRARIES
 59
 60  USE OPENCMISS
 61  USE FLUID_MECHANICS_IO_ROUTINES
 62  USE MPI
 63
 64#ifdef WIN32
 65  USE IFQWINCMISS
 66#endif
 67
 68  !
 69  !================================================================================================================================
 70  !
 71
 72  !PROGRAM VARIABLES AND TYPES
 73
 74  IMPLICIT NONE
 75
 76  INTEGER(CMISSIntg), PARAMETER :: EquationsSetFieldUserNumber=1337
 77  TYPE(CMISSFieldType) :: EquationsSetField
 78
 79
 80  !Test program parameters
 81
 82  INTEGER(CMISSIntg), PARAMETER :: CoordinateSystemUserNumber=1
 83  INTEGER(CMISSIntg), PARAMETER :: RegionUserNumber=2
 84  INTEGER(CMISSIntg), PARAMETER :: MeshUserNumber=3
 85  INTEGER(CMISSIntg), PARAMETER :: DecompositionUserNumber=4
 86  INTEGER(CMISSIntg), PARAMETER :: GeometricFieldUserNumber=5
 87  INTEGER(CMISSIntg), PARAMETER :: DependentFieldUserNumberNavierStokes=6
 88  INTEGER(CMISSIntg), PARAMETER :: MaterialsFieldUserNumberNavierStokes=7
 89  INTEGER(CMISSIntg), PARAMETER :: IndependentFieldUserNumberNavierStokes=8
 90  INTEGER(CMISSIntg), PARAMETER :: AnalyticFieldUserNumberNavierStokes=9
 91  INTEGER(CMISSIntg), PARAMETER :: EquationsSetUserNumberNavierStokes=10
 92  INTEGER(CMISSIntg), PARAMETER :: ProblemUserNumber=11
 93
 94  INTEGER(CMISSIntg), PARAMETER :: DomainUserNumber=2
 95  INTEGER(CMISSIntg), PARAMETER :: SolverNavierStokesUserNumber=1
 96  INTEGER(CMISSIntg), PARAMETER :: MaterialsFieldUserNumberNavierStokesMu=1
 97  INTEGER(CMISSIntg), PARAMETER :: MaterialsFieldUserNumberNavierStokesRho=2
 98
 99  !Program types
100
101  TYPE(EXPORT_CONTAINER):: CM
102
103  !Program variables
104
105  INTEGER(CMISSIntg) :: NUMBER_OF_DIMENSIONS
106  
107  INTEGER(CMISSIntg) :: BASIS_TYPE
108  INTEGER(CMISSIntg) :: BASIS_NUMBER_SPACE
109  INTEGER(CMISSIntg) :: BASIS_NUMBER_VELOCITY
110  INTEGER(CMISSIntg) :: BASIS_NUMBER_PRESSURE
111  INTEGER(CMISSIntg) :: BASIS_GAUSS_SPACE
112  INTEGER(CMISSIntg) :: BASIS_GAUSS_VELOCITY
113  INTEGER(CMISSIntg) :: BASIS_GAUSS_PRESSURE
114  INTEGER(CMISSIntg) :: BASIS_XI_INTERPOLATION_SPACE
115  INTEGER(CMISSIntg) :: BASIS_XI_INTERPOLATION_VELOCITY
116  INTEGER(CMISSIntg) :: BASIS_XI_INTERPOLATION_PRESSURE
117  INTEGER(CMISSIntg) :: MESH_NUMBER_OF_COMPONENTS
118  INTEGER(CMISSIntg) :: MESH_COMPONENT_NUMBER_SPACE
119  INTEGER(CMISSIntg) :: MESH_COMPONENT_NUMBER_VELOCITY
120  INTEGER(CMISSIntg) :: MESH_COMPONENT_NUMBER_PRESSURE
121  INTEGER(CMISSIntg) :: NUMBER_OF_NODES_SPACE
122  INTEGER(CMISSIntg) :: NUMBER_OF_NODES_VELOCITY
123  INTEGER(CMISSIntg) :: NUMBER_OF_NODES_PRESSURE
124  INTEGER(CMISSIntg) :: NUMBER_OF_ELEMENT_NODES_SPACE
125  INTEGER(CMISSIntg) :: NUMBER_OF_ELEMENT_NODES_VELOCITY
126  INTEGER(CMISSIntg) :: NUMBER_OF_ELEMENT_NODES_PRESSURE
127  INTEGER(CMISSIntg) :: TOTAL_NUMBER_OF_NODES
128  INTEGER(CMISSIntg) :: TOTAL_NUMBER_OF_ELEMENTS
129  INTEGER(CMISSIntg) :: MAXIMUM_ITERATIONS
130  INTEGER(CMISSIntg) :: RESTART_VALUE
131!   INTEGER(CMISSIntg) :: MPI_IERROR
132
133  INTEGER(CMISSIntg) :: EQUATIONS_NAVIER_STOKES_OUTPUT
134  INTEGER(CMISSIntg) :: COMPONENT_NUMBER
135  INTEGER(CMISSIntg) :: NODE_NUMBER
136  INTEGER(CMISSIntg) :: ELEMENT_NUMBER
137!   INTEGER(CMISSIntg) :: NODE_COUNTER
138!   INTEGER(CMISSIntg) :: CONDITION
139
140  INTEGER(CMISSIntg) :: DYNAMIC_SOLVER_NAVIER_STOKES_OUTPUT_FREQUENCY
141  INTEGER(CMISSIntg) :: DYNAMIC_SOLVER_NAVIER_STOKES_OUTPUT_TYPE
142  INTEGER(CMISSIntg) :: NONLINEAR_SOLVER_NAVIER_STOKES_OUTPUT_TYPE
143  INTEGER(CMISSIntg) :: LINEAR_SOLVER_NAVIER_STOKES_OUTPUT_TYPE
144
145  INTEGER(CMISSIntg) :: ANALYTICAL_TYPE
146  INTEGER(CMISSIntg) :: INPUT_TYPE
147
148  REAL(CMISSDP) :: INITIAL_FIELD_NAVIER_STOKES(3)
149  REAL(CMISSDP) :: DIVERGENCE_TOLERANCE
150  REAL(CMISSDP) :: RELATIVE_TOLERANCE
151  REAL(CMISSDP) :: ABSOLUTE_TOLERANCE
152  REAL(CMISSDP) :: SOLVER_TOLERANCE
153  REAL(CMISSDP) :: LINESEARCH_ALPHA
154  REAL(CMISSDP) :: MAX_STEP
155  REAL(CMISSDP) :: VALUE
156  REAL(CMISSDP) :: MU_PARAM_NAVIER_STOKES
157  REAL(CMISSDP) :: RHO_PARAM_NAVIER_STOKES
158
159  REAL(CMISSDP) :: DYNAMIC_SOLVER_NAVIER_STOKES_START_TIME
160  REAL(CMISSDP) :: DYNAMIC_SOLVER_NAVIER_STOKES_STOP_TIME
161  REAL(CMISSDP) :: DYNAMIC_SOLVER_NAVIER_STOKES_THETA
162  REAL(CMISSDP) :: DYNAMIC_SOLVER_NAVIER_STOKES_TIME_INCREMENT
163
164  LOGICAL :: EXPORT_FIELD_IO
165  LOGICAL :: LINEAR_SOLVER_NAVIER_STOKES_DIRECT_FLAG
166
167  CHARACTER *15 BUFFER
168  CHARACTER *15 OUTPUT_STRING
169
170  !CMISS variables
171
172  !Regions
173  TYPE(CMISSRegionType) :: Region
174  TYPE(CMISSRegionType) :: WorldRegion
175  !Coordinate systems
176  TYPE(CMISSCoordinateSystemType) :: CoordinateSystem
177  TYPE(CMISSCoordinateSystemType) :: WorldCoordinateSystem
178  !Basis
179  TYPE(CMISSBasisType) :: BasisSpace
180  TYPE(CMISSBasisType) :: BasisVelocity
181  TYPE(CMISSBasisType) :: BasisPressure
182  !Nodes
183  TYPE(CMISSNodesType) :: Nodes
184  !Elements
185  TYPE(CMISSMeshElementsType) :: MeshElementsSpace
186  TYPE(CMISSMeshElementsType) :: MeshElementsVelocity
187  TYPE(CMISSMeshElementsType) :: MeshElementsPressure
188  !Meshes
189  TYPE(CMISSMeshType) :: Mesh
190  !Decompositions
191  TYPE(CMISSDecompositionType) :: Decomposition
192  !Fields
193  TYPE(CMISSFieldsType) :: Fields
194  !Field types
195  TYPE(CMISSFieldType) :: GeometricField
196  TYPE(CMISSFieldType) :: DependentFieldNavierStokes
197  TYPE(CMISSFieldType) :: MaterialsFieldNavierStokes
198  TYPE(CMISSFieldType) :: AnalyticFieldNavierStokes
199  !Boundary conditions
200   TYPE(CMISSBoundaryConditionsType) :: BoundaryConditionsNavierStokes
201  !Equations sets
202  TYPE(CMISSEquationsSetType) :: EquationsSetNavierStokes
203  !Equations
204  TYPE(CMISSEquationsType) :: EquationsNavierStokes
205  !Problems
206  TYPE(CMISSProblemType) :: Problem
207  !Control loops
208  TYPE(CMISSControlLoopType) :: ControlLoop
209  !Solvers
210  TYPE(CMISSSolverType) :: DynamicSolverNavierStokes
211  TYPE(CMISSSolverType) :: NonlinearSolverNavierStokes
212  TYPE(CMISSSolverType) :: LinearSolverNavierStokes
213  !Solver equations
214  TYPE(CMISSSolverEquationsType) :: SolverEquationsNavierStokes
215
216#ifdef WIN32
217  !Quickwin type
218  LOGICAL :: QUICKWIN_STATUS=.TRUE.
219  TYPE(WINDOWCONFIG) :: QUICKWIN_WINDOW_CONFIG
220#endif
221  
222  !Generic CMISS variables
223
224  INTEGER(CMISSIntg) :: NumberOfComputationalNodes,ComputationalNodeNumber,BoundaryNodeDomain
225  INTEGER(CMISSIntg) :: EquationsSetIndex
226  INTEGER(CMISSIntg) :: Err
227  
228#ifdef WIN32
229  !Initialise QuickWin
230  QUICKWIN_WINDOW_CONFIG%TITLE="General Output" !Window title
231  QUICKWIN_WINDOW_CONFIG%NUMTEXTROWS=-1 !Max possible number of rows
232  QUICKWIN_WINDOW_CONFIG%MODE=QWIN$SCROLLDOWN
233  !Set the window parameters
234  QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
235  !If attempt fails set with system estimated values
236  IF(.NOT.QUICKWIN_STATUS) QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
237#endif
238
239  !
240  !================================================================================================================================
241  !
242
243  !PROBLEM CONTROL PANEL
244
245  !Import cmHeart mesh information
246  CALL FLUID_MECHANICS_IO_READ_CMHEART(CM,Err)  
247  BASIS_NUMBER_SPACE=CM%ID_M
248  BASIS_NUMBER_VELOCITY=CM%ID_V
249  BASIS_NUMBER_PRESSURE=CM%ID_P
250  NUMBER_OF_DIMENSIONS=CM%D
251  BASIS_TYPE=CM%IT_T
252  BASIS_XI_INTERPOLATION_SPACE=CM%IT_M
253  BASIS_XI_INTERPOLATION_VELOCITY=CM%IT_V
254  BASIS_XI_INTERPOLATION_PRESSURE=CM%IT_P
255  NUMBER_OF_NODES_SPACE=CM%N_M
256  NUMBER_OF_NODES_VELOCITY=CM%N_V
257  NUMBER_OF_NODES_PRESSURE=CM%N_P
258  TOTAL_NUMBER_OF_NODES=CM%N_T
259  TOTAL_NUMBER_OF_ELEMENTS=CM%E_T
260  NUMBER_OF_ELEMENT_NODES_SPACE=CM%EN_M
261  NUMBER_OF_ELEMENT_NODES_VELOCITY=CM%EN_V
262  NUMBER_OF_ELEMENT_NODES_PRESSURE=CM%EN_P
263  !Set initial values
264  INITIAL_FIELD_NAVIER_STOKES(1)=0.0_CMISSDP
265  INITIAL_FIELD_NAVIER_STOKES(2)=0.0_CMISSDP
266  INITIAL_FIELD_NAVIER_STOKES(3)=0.0_CMISSDP
267  !Set material parameters
268  MU_PARAM_NAVIER_STOKES=1.0_CMISSDP
269  RHO_PARAM_NAVIER_STOKES=1.0_CMISSDP
270  !Set interpolation parameters
271  BASIS_GAUSS_SPACE=4
272  BASIS_GAUSS_VELOCITY=4
273  BASIS_GAUSS_PRESSURE=4
274  !Set output parameter
275  !(NoOutput/ProgressOutput/TimingOutput/SolverOutput/SolverMatrixOutput)
276  DYNAMIC_SOLVER_NAVIER_STOKES_OUTPUT_TYPE=CMISS_SOLVER_PROGRESS_OUTPUT
277  NONLINEAR_SOLVER_NAVIER_STOKES_OUTPUT_TYPE=CMISS_SOLVER_PROGRESS_OUTPUT
278  LINEAR_SOLVER_NAVIER_STOKES_OUTPUT_TYPE=CMISS_SOLVER_PROGRESS_OUTPUT
279  !(NoOutput/TimingOutatrixOutput/ElementOutput)
280  EQUATIONS_NAVIER_STOKES_OUTPUT=CMISS_EQUATIONS_NO_OUTPUT
281  !Set time parameter
282  DYNAMIC_SOLVER_NAVIER_STOKES_START_TIME=0.0_CMISSDP
283  DYNAMIC_SOLVER_NAVIER_STOKES_STOP_TIME=0.03000001_CMISSDP
284  DYNAMIC_SOLVER_NAVIER_STOKES_TIME_INCREMENT=0.010_CMISSDP
285  DYNAMIC_SOLVER_NAVIER_STOKES_THETA=1.0_CMISSDP/1.0_CMISSDP
286  !Set result output parameter
287  DYNAMIC_SOLVER_NAVIER_STOKES_OUTPUT_FREQUENCY=1
288  !Set solver parameters
289  LINEAR_SOLVER_NAVIER_STOKES_DIRECT_FLAG=.TRUE.
290  RELATIVE_TOLERANCE=1.0E-5_CMISSDP !default: 1.0E-05_CMISSDP
291  ABSOLUTE_TOLERANCE=1.0E-10_CMISSDP !default: 1.0E-10_CMISSDP
292  SOLVER_TOLERANCE=1.0E-10_CMISSDP !default: 1.0E-10_CMISSDP
293  DIVERGENCE_TOLERANCE=1.0E20 !default: 1.0E5
294  MAXIMUM_ITERATIONS=100000 !default: 100000
295  RESTART_VALUE=300 !default: 30
296  LINESEARCH_ALPHA=1.0
297  MAX_STEP=0.00000001
298
299  !
300  !================================================================================================================================
301  !
302
303  !Different analytical cases
304  ! 1=CMISS_EQUATIONS_SET_STOKES_EQUATION_TWO_DIM_1
305  ! 2=CMISS_EQUATIONS_SET_STOKES_EQUATION_TWO_DIM_2
306  ! 3=CMISS_EQUATIONS_SET_STOKES_EQUATION_TWO_DIM_3
307  ! 4=CMISS_EQUATIONS_SET_STOKES_EQUATION_TWO_DIM_4
308  ! 5=CMISS_EQUATIONS_SET_STOKES_EQUATION_TWO_DIM_5
309  ! 1=CMISS_EQUATIONS_SET_STOKES_EQUATION_THREE_DIM_1
310  ! 2=CMISS_EQUATIONS_SET_STOKES_EQUATION_THREE_DIM_2
311  ! 3=CMISS_EQUATIONS_SET_STOKES_EQUATION_THREE_DIM_3
312  ! 4=CMISS_EQUATIONS_SET_STOKES_EQUATION_THREE_DIM_4
313  ! 5=CMISS_EQUATIONS_SET_STOKES_EQUATION_THREE_DIM_5
314
315
316  WRITE(*,*)'4=NAN, 5=TAYLOR:'
317!   READ(*,*) 
318
319  IF(COMMAND_ARGUMENT_COUNT()==2) THEN
320    CALL GET_COMMAND_ARGUMENT(1,BUFFER)
321    READ(BUFFER,*) INPUT_TYPE
322    CALL GET_COMMAND_ARGUMENT(2,BUFFER)
323    READ(BUFFER,*) OUTPUT_STRING
324  ELSE
325    !TODO more detailed error message
326    WRITE(*,*)'INPUT ERROR!!!'
327  ENDIF
328
329
330
331  IF(INPUT_TYPE==5.AND.NUMBER_OF_DIMENSIONS==2) THEN
332    ANALYTICAL_TYPE=CMISS_EQUATIONS_SET_NAVIER_STOKES_EQUATION_TWO_DIM_5
333  ELSE IF(INPUT_TYPE==5.AND.NUMBER_OF_DIMENSIONS==3) THEN
334    ANALYTICAL_TYPE=CMISS_EQUATIONS_SET_NAVIER_STOKES_EQUATION_THREE_DIM_5
335  ELSE
336    !TODO more detailed error message
337    WRITE(*,*)'INPUT ERROR!!!'
338  ENDIF
339
340  !
341  !================================================================================================================================
342  !
343
344  !INITIALISE OPENCMISS
345
346  CALL CMISSInitialise(WorldCoordinateSystem,WorldRegion,Err)
347
348  !
349  !================================================================================================================================
350  !
351
352  !CHECK COMPUTATIONAL NODE
353
354  !Get the computational nodes information
355  CALL CMISSComputationalNumberOfNodesGet(NumberOfComputationalNodes,Err)
356  CALL CMISSComputationalNodeNumberGet(ComputationalNodeNumber,Err)
357
358  !
359  !================================================================================================================================
360  !
361
362  !COORDINATE SYSTEM
363
364  !Start the creation of a new RC coordinate system
365  CALL CMISSCoordinateSystem_Initialise(CoordinateSystem,Err)
366  CALL CMISSCoordinateSystem_CreateStart(CoordinateSystemUserNumber,CoordinateSystem,Err)
367  !Set the coordinate system dimension
368  CALL CMISSCoordinateSystem_DimensionSet(CoordinateSystem,NUMBER_OF_DIMENSIONS,Err)
369  !Finish the creation of the coordinate system
370  CALL CMISSCoordinateSystem_CreateFinish(CoordinateSystem,Err)
371
372  !
373  !================================================================================================================================
374  !
375
376  !REGION
377
378  !Start the creation of a new region
379  CALL CMISSRegion_Initialise(Region,Err)
380  CALL CMISSRegion_CreateStart(RegionUserNumber,WorldRegion,Region,Err)
381  !Set the regions coordinate system as defined above
382  CALL CMISSRegion_CoordinateSystemSet(Region,CoordinateSystem,Err)
383  !Finish the creation of the region
384  CALL CMISSRegion_CreateFinish(Region,Err)
385
386  !
387  !================================================================================================================================
388  !
389
390  !BASES
391
392  !Start the creation of new bases
393  MESH_NUMBER_OF_COMPONENTS=1
394  CALL CMISSBasis_Initialise(BasisSpace,Err)
395  CALL CMISSBasis_CreateStart(BASIS_NUMBER_SPACE,BasisSpace,Err)
396  !Set the basis type (Lagrange/Simplex)
397  CALL CMISSBasis_TypeSet(BasisSpace,BASIS_TYPE,Err)
398  !Set the basis xi number
399  CALL CMISSBasis_NumberOfXiSet(BasisSpace,NUMBER_OF_DIMENSIONS,Err)
400  !Set the basis xi interpolation and number of Gauss points
401  IF(NUMBER_OF_DIMENSIONS==2) THEN
402    CALL CMISSBasis_InterpolationXiSet(BasisSpace,(/BASIS_XI_INTERPOLATION_SPACE,BASIS_XI_INTERPOLATION_SPACE/),Err)
403    IF(BASIS_TYPE/=CMISS_BASIS_SIMPLEX_TYPE) THEN
404      CALL CMISSBasis_QuadratureNumberOfGaussXiSet(BasisSpace,(/BASIS_GAUSS_SPACE,BASIS_GAUSS_SPACE/),Err)
405    ELSE
406      CALL CMISSBasis_QuadratureOrderSet(BasisSpace,BASIS_GAUSS_SPACE+1,Err)
407    ENDIF
408  ELSE IF(NUMBER_OF_DIMENSIONS==3) THEN
409    CALL CMISSBasis_InterpolationXiSet(BasisSpace,(/BASIS_XI_INTERPOLATION_SPACE,BASIS_XI_INTERPOLATION_SPACE, & 
410      & BASIS_XI_INTERPOLATION_SPACE/),Err)                         
411    IF(BASIS_TYPE/=CMISS_BASIS_SIMPLEX_TYPE) THEN
412      CALL CMISSBasis_QuadratureNumberOfGaussXiSet(BasisSpace,(/BASIS_GAUSS_SPACE,BASIS_GAUSS_SPACE,BASIS_GAUSS_SPACE/), & 
413        & Err)
414    ELSE
415      CALL CMISSBasis_QuadratureOrderSet(BasisSpace,BASIS_GAUSS_SPACE+1,Err)
416    ENDIF
417  ENDIF
418  !Finish the creation of the basis
419  CALL CMISSBasis_CreateFinish(BasisSpace,Err)
420  !Start the creation of another basis
421  IF(BASIS_XI_INTERPOLATION_VELOCITY==BASIS_XI_INTERPOLATION_SPACE) THEN
422    BasisVelocity=BasisSpace
423  ELSE
424    MESH_NUMBER_OF_COMPONENTS=MESH_NUMBER_OF_COMPONENTS+1
425    !Initialise a new velocity basis
426    CALL CMISSBasis_Initialise(BasisVelocity,Err)
427    !Start the creation of a basis
428    CALL CMISSBasis_CreateStart(BASIS_NUMBER_VELOCITY,BasisVelocity,Err)
429    !Set the basis type (Lagrange/Simplex)
430    CALL CMISSBasis_TypeSet(BasisVelocity,BASIS_TYPE,Err)
431    !Set the basis xi number
432    CALL CMISSBasis_NumberOfXiSet(BasisVelocity,NUMBER_OF_DIMENSIONS,Err)
433    !Set the basis xi interpolation and number of Gauss points
434    IF(NUMBER_OF_DIMENSIONS==2) THEN
435      CALL CMISSBasis_InterpolationXiSet(BasisVelocity,(/BASIS_XI_INTERPOLATION_VELOCITY,BASIS_XI_INTERPOLATION_VELOCITY/),Err)
436      IF(BASIS_TYPE/=CMISS_BASIS_SIMPLEX_TYPE) THEN 
437        CALL CMISSBasis_QuadratureNumberOfGaussXiSet(BasisVelocity,(/BASIS_GAUSS_VELOCITY,BASIS_GAUSS_VELOCITY/),Err)
438      ELSE
439        CALL CMISSBasis_QuadratureOrderSet(BasisVelocity,BASIS_GAUSS_VELOCITY+1,Err)
440      ENDIF
441    ELSE IF(NUMBER_OF_DIMENSIONS==3) THEN
442      CALL CMISSBasis_InterpolationXiSet(BasisVelocity,(/BASIS_XI_INTERPOLATION_VELOCITY,BASIS_XI_INTERPOLATION_VELOCITY, & 
443        & BASIS_XI_INTERPOLATION_VELOCITY/),Err)                         
444      IF(BASIS_TYPE/=CMISS_BASIS_SIMPLEX_TYPE) THEN
445        CALL CMISSBasis_QuadratureNumberOfGaussXiSet(BasisVelocity,(/BASIS_GAUSS_VELOCITY,BASIS_GAUSS_VELOCITY, & 
446          & BASIS_GAUSS_VELOCITY/),Err)
447      ELSE
448        CALL CMISSBasis_QuadratureOrderSet(BasisVelocity,BASIS_GAUSS_VELOCITY+1,Err)
449      ENDIF
450    ENDIF
451    !Finish the creation of the basis
452    CALL CMISSBasis_CreateFinish(BasisVelocity,Err)
453  ENDIF
454  !Start the creation of another basis
455  IF(BASIS_XI_INTERPOLATION_PRESSURE==BASIS_XI_INTERPOLATION_SPACE) THEN
456    BasisPressure=BasisSpace
457  ELSE IF(BASIS_XI_INTERPOLATION_PRESSURE==BASIS_XI_INTERPOLATION_VELOCITY) THEN
458    BasisPressure=BasisVelocity
459  ELSE
460    MESH_NUMBER_OF_COMPONENTS=MESH_NUMBER_OF_COMPONENTS+1
461    !Initialise a new pressure basis
462    CALL CMISSBasis_Initialise(BasisPressure,Err)
463    !Start the creation of a basis
464    CALL CMISSBasis_CreateStart(BASIS_NUMBER_PRESSURE,BasisPressure,Err)
465    !Set the basis type (Lagrange/Simplex)
466    CALL CMISSBasis_TypeSet(BasisPressure,BASIS_TYPE,Err)
467    !Set the basis xi number
468    CALL CMISSBasis_NumberOfXiSet(BasisPressure,NUMBER_OF_DIMENSIONS,Err)
469    !Set the basis xi interpolation and number of Gauss points
470    IF(NUMBER_OF_DIMENSIONS==2) THEN
471      CALL CMISSBasis_InterpolationXiSet(BasisPressure,(/BASIS_XI_INTERPOLATION_PRESSURE,BASIS_XI_INTERPOLATION_PRESSURE/),Err)
472      IF(BASIS_TYPE/=CMISS_BASIS_SIMPLEX_TYPE) THEN
473        CALL CMISSBasis_QuadratureNumberOfGaussXiSet(BasisPressure,(/BASIS_GAUSS_PRESSURE,BASIS_GAUSS_PRESSURE/),Err)
474      ELSE
475        CALL CMISSBasis_QuadratureOrderSet(BasisPressure,BASIS_GAUSS_PRESSURE+1,Err)
476      ENDIF
477    ELSE IF(NUMBER_OF_DIMENSIONS==3) THEN
478      CALL CMISSBasis_InterpolationXiSet(BasisPressure,(/BASIS_XI_INTERPOLATION_PRESSURE,BASIS_XI_INTERPOLATION_PRESSURE, & 
479        & BASIS_XI_INTERPOLATION_PRESSURE/),Err)                         
480      IF(BASIS_TYPE/=CMISS_BASIS_SIMPLEX_TYPE) THEN
481        CALL CMISSBasis_QuadratureNumberOfGaussXiSet(BasisPressure,(/BASIS_GAUSS_PRESSURE,BASIS_GAUSS_PRESSURE, & 
482          & BASIS_GAUSS_PRESSURE/),Err)
483      ELSE
484        CALL CMISSBasis_QuadratureOrderSet(BasisPressure,BASIS_GAUSS_PRESSURE+1,Err)
485      ENDIF
486    ENDIF
487    !Finish the creation of the basis
488    CALL CMISSBasis_CreateFinish(BasisPressure,Err)
489  ENDIF
490
491  !
492  !================================================================================================================================
493  !
494
495  !MESH
496
497  !Start the creation of mesh nodes
498  CALL CMISSNodes_Initialise(Nodes,Err)
499  CALL CMISSMesh_Initialise(Mesh,Err)
500  CALL CMISSNodes_CreateStart(Region,TOTAL_NUMBER_OF_NODES,Nodes,Err)
501  CALL CMISSNodes_CreateFinish(Nodes,Err)
502  !Start the creation of the mesh
503  CALL CMISSMesh_CreateStart(MeshUserNumber,Region,NUMBER_OF_DIMENSIONS,Mesh,Err)
504  !Set number of mesh elements
505  CALL CMISSMesh_NumberOfElementsSet(Mesh,TOTAL_NUMBER_OF_ELEMENTS,Err)
506  !Set number of mesh components
507  CALL CMISSMesh_NumberOfComponentsSet(Mesh,MESH_NUMBER_OF_COMPONENTS,Err)
508  !Specify spatial mesh component
509  CALL CMISSMeshElements_Initialise(MeshElementsSpace,Err)
510  CALL CMISSMeshElements_Initialise(MeshElementsVelocity,Err)
511  CALL CMISSMeshElements_Initialise(MeshElementsPressure,Err)
512  MESH_COMPONENT_NUMBER_SPACE=1
513  MESH_COMPONENT_NUMBER_VELOCITY=1
514  MESH_COMPONENT_NUMBER_PRESSURE=1
515  CALL CMISSMeshElements_CreateStart(Mesh,MESH_COMPONENT_NUMBER_SPACE,BasisSpace,MeshElementsSpace,Err)
516  DO ELEMENT_NUMBER=1,TOTAL_NUMBER_OF_ELEMENTS
517    CALL CMISSMeshElements_NodesSet(MeshElementsSpace,ELEMENT_NUMBER,CM%M(ELEMENT_NUMBER,1:NUMBER_OF_ELEMENT_NODES_SPACE),Err)
518  ENDDO
519  CALL CMISSMeshElements_CreateFinish(MeshElementsSpace,Err)
520  !Specify velocity mesh component
521  IF(BASIS_XI_INTERPOLATION_VELOCITY==BASIS_XI_INTERPOLATION_SPACE) THEN
522    MeshElementsVelocity=MeshElementsSpace
523  ELSE
524    MESH_COMPONENT_NUMBER_VELOCITY=MESH_COMPONENT_NUMBER_SPACE+1
525    CALL CMISSMeshElements_CreateStart(Mesh,MESH_COMPONENT_NUMBER_VELOCITY,BasisVelocity,MeshElementsVelocity,Err)
526    DO ELEMENT_NUMBER=1,TOTAL_NUMBER_OF_ELEMENTS
527      CALL CMISSMeshElements_NodesSet(MeshElementsVelocity,ELEMENT_NUMBER,CM%V(ELEMENT_NUMBER, & 
528        & 1:NUMBER_OF_ELEMENT_NODES_VELOCITY),Err)
529    ENDDO
530    CALL CMISSMeshElements_CreateFinish(MeshElementsVelocity,Err)
531  ENDIF
532  !Specify pressure mesh component
533  IF(BASIS_XI_INTERPOLATION_PRESSURE==BASIS_XI_INTERPOLATION_SPACE) THEN
534    MeshElementsPressure=MeshElementsSpace
535    MESH_COMPONENT_NUMBER_PRESSURE=MESH_COMPONENT_NUMBER_SPACE
536  ELSE IF(BASIS_XI_INTERPOLATION_PRESSURE==BASIS_XI_INTERPOLATION_VELOCITY) THEN
537    MeshElementsPressure=MeshElementsVelocity
538    MESH_COMPONENT_NUMBER_PRESSURE=MESH_COMPONENT_NUMBER_VELOCITY
539  ELSE
540    MESH_COMPONENT_NUMBER_PRESSURE=MESH_COMPONENT_NUMBER_VELOCITY+1
541    CALL CMISSMeshElements_CreateStart(Mesh,MESH_COMPONENT_NUMBER_PRESSURE,BasisPressure,MeshElementsPressure,Err)
542    DO ELEMENT_NUMBER=1,TOTAL_NUMBER_OF_ELEMENTS
543      CALL CMISSMeshElements_NodesSet(MeshElementsPressure,ELEMENT_NUMBER,CM%P(ELEMENT_NUMBER, & 
544        & 1:NUMBER_OF_ELEMENT_NODES_PRESSURE),Err)
545    ENDDO
546    CALL CMISSMeshElements_CreateFinish(MeshElementsPressure,Err)
547  ENDIF
548  !Finish the creation of the mesh
549  CALL CMISSMesh_CreateFinish(Mesh,Err)
550
551  !
552  !================================================================================================================================
553  !
554
555  !GEOMETRIC FIELD
556
557  !Create a decomposition
558  CALL CMISSDecomposition_Initialise(Decomposition,Err)
559  CALL CMISSDecomposition_CreateStart(DecompositionUserNumber,Mesh,Decomposition,Err)
560  !Set the decomposition to be a general decomposition with the specified number of domains
561  CALL CMISSDecomposition_TypeSet(Decomposition,CMISS_DECOMPOSITION_CALCULATED_TYPE,Err)
562  CALL CMISSDecomposition_NumberOfDomainsSet(Decomposition,NumberOfComputationalNodes,Err)
563  !Finish the decomposition
564  CALL CMISSDecomposition_CreateFinish(Decomposition,Err)
565
566  !Start to create a default (geometric) field on the region
567  CALL CMISSField_Initialise(GeometricField,Err)
568  CALL CMISSField_CreateStart(GeometricFieldUserNumber,Region,GeometricField,Err)
569  !Set the field type
570  CALL CMISSField_TypeSet(GeometricField,CMISS_FIELD_GEOMETRIC_TYPE,Err)
571  !Set the decomposition to use
572  CALL CMISSField_MeshDecompositionSet(GeometricField,Decomposition,Err)
573  !Set the scaling to use
574  CALL CMISSField_ScalingTypeSet(GeometricField,CMISS_FIELD_NO_SCALING,Err)
575  !Set the mesh component to be used by the field components.
576  DO COMPONENT_NUMBER=1,NUMBER_OF_DIMENSIONS
577    CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,COMPONENT_NUMBER, & 
578      & MESH_COMPONENT_NUMBER_SPACE,Err)
579  ENDDO
580  !Finish creating the field
581  CALL CMISSField_CreateFinish(GeometricField,Err)
582  !Update the geometric field parameters
583  DO NODE_NUMBER=1,NUMBER_OF_NODES_SPACE
584    DO COMPONENT_NUMBER=1,NUMBER_OF_DIMENSIONS
585      VALUE=CM%N(NODE_NUMBER,COMPONENT_NUMBER)
586      CALL CMISSDecomposition_NodeDomainGet(Decomposition,NODE_NUMBER,1,BoundaryNodeDomain,Err)
587      IF(BoundaryNodeDomain==ComputationalNodeNumber) THEN
588        CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, & 
589          & CMISS_NO_GLOBAL_DERIV,NODE_NUMBER,COMPONENT_NUMBER,VALUE,Err)
590      ENDIF
591    ENDDO
592  ENDDO
593  CALL CMISSField_ParameterSetUpdateStart(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,Err)
594  CALL CMISSField_ParameterSetUpdateFinish(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,Err)
595
596  !
597  !================================================================================================================================
598  !
599
600  !EQUATIONS SETS
601
602  !Create the equations set for dynamic Navier-Stokes
603  CALL CMISSEquationsSet_Initialise(EquationsSetNavierStokes,Err)
604  CALL CMISSField_Initialise(EquationsSetField,Err)
605  CALL CMISSEquationsSet_CreateStart(EquationsSetUserNumberNavierStokes,Region,GeometricField, &
606    & CMISS_EQUATIONS_SET_FLUID_MECHANICS_CLASS,CMISS_EQUATIONS_SET_NAVIER_STOKES_EQUATION_TYPE,&
607    & CMISS_EQUATIONS_SET_TRANSIENT_NAVIER_STOKES_SUBTYPE, &
608    & EquationsSetFieldUserNumber,EquationsSetField,EquationsSetNavierStokes,Err)
609  !Set the equations set to be a dynamic Navier-Stokes problem
610  
611  !Finish creating the equations set
612  CALL CMISSEquationsSet_CreateFinish(EquationsSetNavierStokes,Err)
613
614
615  !
616  !================================================================================================================================
617  !
618
619  !DEPENDENT FIELDS
620
621  !Create the equations set dependent field variables for dynamic Navier-Stokes
622  CALL CMISSField_Initialise(DependentFieldNavierStokes,Err)
623  CALL CMISSEquationsSet_DependentCreateStart(EquationsSetNavierStokes,DependentFieldUserNumberNavierStokes, & 
624    & DependentFieldNavierStokes,Err)
625  !Set the mesh component to be used by the field components.
626  DO COMPONENT_NUMBER=1,NUMBER_OF_DIMENSIONS
627    CALL CMISSField_ComponentMeshComponentSet(DependentFieldNavierStokes,CMISS_FIELD_U_VARIABLE_TYPE,COMPONENT_NUMBER, & 
628      & MESH_COMPONENT_NUMBER_VELOCITY,Err)
629    CALL CMISSField_ComponentMeshComponentSet(DependentFieldNavierStokes,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,COMPONENT_NUMBER, & 
630      & MESH_COMPONENT_NUMBER_VELOCITY,Err)
631  ENDDO
632  COMPONENT_NUMBER=NUMBER_OF_DIMENSIONS+1
633    CALL CMISSField_ComponentMeshComponentSet(DependentFieldNavierStokes,CMISS_FIELD_U_VARIABLE_TYPE,COMPONENT_NUMBER, & 
634      & MESH_COMPONENT_NUMBER_PRESSURE,Err)
635    CALL CMISSField_ComponentMeshComponentSet(DependentFieldNavierStokes,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,COMPONENT_NUMBER, & 
636      & MESH_COMPONENT_NUMBER_PRESSURE,Err)
637  !Finish the equations set dependent field variables
638  CALL CMISSEquationsSet_DependentCreateFinish(EquationsSetNavierStokes,Err)
639
640  !Initialise dependent field
641  DO COMPONENT_NUMBER=1,NUMBER_OF_DIMENSIONS
642    CALL CMISSField_ComponentValuesInitialise(DependentFieldNavierStokes,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, & 
643      & COMPONENT_NUMBER,INITIAL_FIELD_NAVIER_STOKES(COMPONENT_NUMBER),Err)
644  ENDDO
645
646
647  !
648  !================================================================================================================================
649  !
650
651  !MATERIALS FIELDS
652
653  !Create the equations set materials field variables for dynamic Navier-Stokes
654  CALL CMISSField_Initialise(MaterialsFieldNavierStokes,Err)
655  CALL CMISSEquationsSet_MaterialsCreateStart(EquationsSetNavierStokes,MaterialsFieldUserNumberNavierStokes, & 
656    & MaterialsFieldNavierStokes,Err)
657  !Finish the equations set materials field variables
658  CALL CMISSEquationsSet_MaterialsCreateFinish(EquationsSetNavierStokes,Err)
659  CALL CMISSField_ComponentValuesInitialise(MaterialsFieldNavierStokes,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, & 
660    & MaterialsFieldUserNumberNavierStokesMu,MU_PARAM_NAVIER_STOKES,Err)
661  CALL CMISSField_ComponentValuesInitialise(MaterialsFieldNavierStokes,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, & 
662    & MaterialsFieldUserNumberNavierStokesRho,RHO_PARAM_NAVIER_STOKES,Err)
663
664  !
665  !================================================================================================================================
666  !
667
668  !ANALYTIC FIELDS
669
670  !Create the equations set analytic field variables for static Navier-Stokes
671  CALL CMISSField_Initialise(AnalyticFieldNavierStokes,Err)
672  IF(NUMBER_OF_DIMENSIONS==2) THEN  
673    CALL CMISSEquationsSet_AnalyticCreateStart(EquationsSetNavierStokes,ANALYTICAL_TYPE,AnalyticFieldUserNumberNavierStokes, &
674      & AnalyticFieldNavierStokes,Err)
675  ELSE
676    CALL CMISSEquationsSet_AnalyticCreateStart(EquationsSetNavierStokes,ANALYTICAL_TYPE,AnalyticFieldUserNumberNavierStokes, &
677      & AnalyticFieldNavierStokes,Err)
678  ENDIF
679  !Finish the equations set analytic field variables
680  CALL CMISSEquationsSet_AnalyticCreateFinish(EquationsSetNavierStokes,Err)
681
682  !
683  !================================================================================================================================
684  !
685
686  !EQUATIONS
687
688
689  !Create the equations set equations
690  CALL CMISSEquations_Initialise(EquationsNavierStokes,Err)
691  CALL CMISSEquationsSet_EquationsCreateStart(EquationsSetNavierStokes,EquationsNavierStokes,Err)
692  !Set the equations matrices sparsity type
693  CALL CMISSEquations_SparsityTypeSet(EquationsNavierStokes,CMISS_EQUATIONS_SPARSE_MATRICES,Err)
694  !Set the equations lumping type
695  CALL CMISSEquations_LumpingTypeSet(EquationsNavierStokes,CMISS_EQUATIONS_UNLUMPED_MATRICES,Err)
696  !Set the equations set output
697  CALL CMISSEquations_OutputTypeSet(EquationsNavierStokes,EQUATIONS_NAVIER_STOKES_OUTPUT,Err)
698  !Finish the equations set equations
699  CALL CMISSEquationsSet_EquationsCreateFinish(EquationsSetNavierStokes,Err)
700
701
702  !
703  !================================================================================================================================
704  !
705
706  !PROBLEMS
707
708  !Start the creation of a problem.
709  CALL CMISSProblem_Initialise(Problem,Err)
710  CALL CMISSControlLoop_Initialise(ControlLoop,Err)
711  CALL CMISSProblem_CreateStart(ProblemUserNumber,Problem,Err)
712  !Set the problem to be a dynamic Navier-Stokes problem
713  CALL CMISSProblem_SpecificationSet(Problem,CMISS_PROBLEM_FLUID_MECHANICS_CLASS,CMISS_PROBLEM_NAVIER_STOKES_EQUATION_TYPE, &
714    & CMISS_PROBLEM_TRANSIENT_NAVIER_STOKES_SUBTYPE,Err)
715  !Finish the creation of a problem.
716  CALL CMISSProblem_CreateFinish(Problem,Err)
717  !Start the creation of the problem control loop
718  CALL CMISSProblem_ControlLoopCreateStart(Problem,Err)
719  !Get the control loop
720  CALL CMISSProblem_ControlLoopGet(Problem,CMISS_CONTROL_LOOP_NODE,ControlLoop,Err)
721  !Set the times
722  CALL CMISSControlLoop_TimesSet(ControlLoop,DYNAMIC_SOLVER_NAVIER_STOKES_START_TIME,DYNAMIC_SOLVER_NAVIER_STOKES_STOP_TIME, & 
723    & DYNAMIC_SOLVER_NAVIER_STOKES_TIME_INCREMENT,Err)
724  !Set the output timing
725  CALL CMISSControlLoop_TimeOutputSet(ControlLoop,DYNAMIC_SOLVER_NAVIER_STOKES_OUTPUT_FREQUENCY,Err)
726  !Finish creating the problem control loop
727  CALL CMISSProblem_ControlLoopCreateFinish(Problem,Err)
728
729  !
730  !================================================================================================================================
731  !
732
733  !SOLVERS
734
735  !Start the creation of the problem solvers
736  CALL CMISSSolver_Initialise(DynamicSolverNavierStokes,Err)
737  CALL CMISSSolver_Initialise(NonlinearSolverNavierStokes,Err)
738  CALL CMISSSolver_Initialise(LinearSolverNavierStokes,Err)
739  CALL CMISSProblem_SolversCreateStart(Problem,Err)
740  !Get the dynamic dymamic solver
741  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,SolverNavierStokesUserNumber,DynamicSolverNavierStokes,Err)
742  !Set the output type
743  CALL CMISSSolver_OutputTypeSet(DynamicSolverNavierStokes,DYNAMIC_SOLVER_NAVIER_STOKES_OUTPUT_TYPE,Err)
744  !Set theta
745  CALL CMISSSolver_DynamicThetaSet(DynamicSolverNavierStokes,DYNAMIC_SOLVER_NAVIER_STOKES_THETA,Err)
746!   CALL CMISSSolverDynamicDynamicSet(DynamicSolverNavierStokes,.TRUE.,Err)
747  !Get the dynamic nonlinear solver
748  CALL CMISSSolver_DynamicNonlinearSolverGet(DynamicSolverNavierStokes,NonlinearSolverNavierStokes,Err)
749  !Set the nonlinear Jacobian type
750  CALL CMISSSolver_NewtonJacobianCalculationTypeSet(NonlinearSolverNavierStokes,CMISS_SOLVER_NEWTON_JACOBIAN_EQUATIONS_CALCULATED, &
751    & Err)
752  !Set the output type
753  CALL CMISSSolver_OutputTypeSet(NonlinearSolverNavierStokes,NONLINEAR_SOLVER_NAVIER_STOKES_OUTPUT_TYPE,Err)
754  !Set the solver settings
755! ! !   CALL CMISSSolver_NewtonAbsoluteToleranceSet(NonlinearSolverNavierStokes,ABSOLUTE_TOLERANCE,Err)
756! ! !   CALL CMISSSolver_NewtonRelativeToleranceSet(NonlinearSolverNavierStokes,ABSOLUTE_TOLERANCE,Err)
757! ! !   CALL CMISSSolver_NewtonSolutionToleranceSet(NonlinearSolverNavierStokes,ABSOLUTE_TOLERANCE,Err)
758  !Get the dynamic nonlinear linear solver
759  CALL CMISSSolver_NewtonLinearSolverGet(NonlinearSolverNavierStokes,LinearSolverNavierStokes,Err)
760  !Set the output type
761  CALL CMISSSolver_OutputTypeSet(LinearSolverNavierStokes,LINEAR_SOLVER_NAVIER_STOKES_OUTPUT_TYPE,Err)
762  !Set the solver settings
763  IF(LINEAR_SOLVER_NAVIER_STOKES_DIRECT_FLAG) THEN
764    CALL CMISSSolver_LinearTypeSet(LinearSolverNavierStokes,CMISS_SOLVER_LINEAR_DIRECT_SOLVE_TYPE,Err)
765    CALL CMISSSolver_LibraryTypeSet(LinearSolverNavierStokes,CMISS_SOLVER_MUMPS_LIBRARY,Err)
766  ELSE
767    CALL CMISSSolver_LinearTypeSet(LinearSolverNavierStokes,CMISS_SOLVER_LINEAR_ITERATIVE_SOLVE_TYPE,Err)
768! ! !     CALL CMISSSolver_LinearIterativeMaximumIterationsSet(LinearSolverNavierStokes,MAXIMUM_ITERATIONS,Err)
769    CALL CMISSSolver_LinearIterativeDivergenceToleranceSet(LinearSolverNavierStokes,DIVERGENCE_TOLERANCE,Err)
770    CALL CMISSSolver_LinearIterativeRelativeToleranceSet(LinearSolverNavierStokes,RELATIVE_TOLERANCE,Err)
771    CALL CMISSSolver_LinearIterativeAbsoluteToleranceSet(LinearSolverNavierStokes,ABSOLUTE_TOLERANCE,Err)
772    CALL CMISSSolver_LinearIterativeGMRESRestartSet(LinearSolverNavierStokes,RESTART_VALUE,Err)
773  ENDIF
774  !Finish the creation of the problem solver
775  CALL CMISSProblem_SolversCreateFinish(Problem,Err)
776
777  !
778  !================================================================================================================================
779  !
780
781  !SOLVER EQUATIONS
782
783  !Start the creation of the problem solver equations
784  CALL CMISSSolver_Initialise(DynamicSolverNavierStokes,Err)
785  CALL CMISSSolverEquations_Initialise(SolverEquationsNavierStokes,Err)
786  CALL CMISSProblem_SolverEquationsCreateStart(Problem,Err)
787  !Get the dynamic solver equations
788  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,SolverNavierStokesUserNumber,DynamicSolverNavierStokes,Err)
789  CALL CMISSSolver_SolverEquationsGet(DynamicSolverNavierStokes,SolverEquationsNavierStokes,Err)
790  !Set the solver equations sparsity
791  CALL CMISSSolverEquations_SparsityTypeSet(SolverEquationsNavierStokes,CMISS_SOLVER_SPARSE_MATRICES,Err)
792  !Add in the equations set
793  CALL CMISSSolverEquations_EquationsSetAdd(SolverEquationsNavierStokes,EquationsSetNavierStokes,EquationsSetIndex,Err)
794  !Finish the creation of the problem solver equations
795  CALL CMISSProblem_SolverEquationsCreateFinish(Problem,Err)
796
797  !
798  !================================================================================================================================
799  !
800
801  !BOUNDARY CONDITIONS
802
803  !Set up the boundary conditions as per the analytic solution
804  CALL CMISSBoundaryConditions_Initialise(BoundaryConditionsNavierStokes,Err)
805  CALL CMISSSolverEquations_BoundaryConditionsCreateStart(SolverEquationsNavierStokes,BoundaryConditionsNavierStokes,Err)
806  CALL CMISSSolverEquations_BoundaryConditionsAnalytic(SolverEquationsNavierStokes,Err)
807  CALL CMISSSolverEquations_BoundaryConditionsCreateFinish(SolverEquationsNavierStokes,Err)
808
809  !
810  !================================================================================================================================
811  !
812
813  !RUN SOLVERS
814  WRITE(*,*)' !RUN SOLVERS'
815  !Turn of PETSc error handling
816  !CALL PETSC_ERRORHANDLING_SET_ON(ERR,ERROR,*999)
817
818  !Solve the problem
819  WRITE(*,'(A)') "Solving problem..."
820  CALL CMISSProblem_Solve(Problem,Err)
821  WRITE(*,'(A)') "Problem solved!"
822
823
824  !Output Analytic analysis
825  CALL CMISSAnalyticAnalysisOutput(DependentFieldNavierStokes,OUTPUT_STRING,Err)
826
827
828  !
829  !================================================================================================================================
830  !
831
832
833  EXPORT_FIELD_IO=.FALSE.
834  IF(EXPORT_FIELD_IO) THEN
835    WRITE(*,'(A)') "Exporting fields..."
836    CALL CMISSFields_Initialise(Fields,Err)
837    CALL CMISSFields_Create(Region,Fields,Err)
838    CALL CMISSFields_NodesExport(Fields,"DynamicNavierStokes","FORTRAN",Err)
839    CALL CMISSFields_ElementsExport(Fields,"DynamicNavierStokes","FORTRAN",Err)
840    CALL CMISSFields_Finalise(Fields,Err)
841    WRITE(*,'(A)') "Field exported!"
842  ENDIF
843  
844  !Finialise CMISS
845!   CALL CMISSFinalise(Err)
846
847  WRITE(*,'(A)') "Program successfully completed."
848  
849  STOP
850
851END PROGRAM ANALYTICNAVIERSTOKESEXAMPLE