PageRenderTime 73ms CodeModel.GetById 14ms app.highlight 53ms RepoModel.GetById 1ms app.codeStats 0ms

/FluidMechanics/NavierStokes/RoutineCheck/Static/src/StaticExample.f90

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