PageRenderTime 94ms CodeModel.GetById 12ms app.highlight 76ms RepoModel.GetById 1ms app.codeStats 0ms

/FluidMechanics/NavierStokes/RoutineCheck/ParallelStatic/src/ParallelStaticExample.f90

http://github.com/xyan075/examples
FORTRAN Modern | 793 lines | 460 code | 105 blank | 228 comment | 0 complexity | 8ef41b9505041bfde45ee3a3f2f7e6e1 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  !
236  !================================================================================================================================
237  !
238
239  !CHECK COMPUTATIONAL NODE
240
241  !Get the computational nodes information
242  CALL CMISSComputationalNumberOfNodesGet(NumberOfComputationalNodes,Err)
243  CALL CMISSComputationalNodeNumberGet(ComputationalNodeNumber,Err)
244
245  !
246  !================================================================================================================================
247  !
248
249  !PROBLEM CONTROL PANEL
250
251  !Import cmHeart mesh information
252  CALL FLUID_MECHANICS_IO_READ_CMHEART(CM,Err)  
253  BASIS_NUMBER_SPACE=CM%ID_M
254  BASIS_NUMBER_VELOCITY=CM%ID_V
255  BASIS_NUMBER_PRESSURE=CM%ID_P
256  NUMBER_OF_DIMENSIONS=CM%D
257  BASIS_TYPE=CM%IT_T
258  BASIS_XI_INTERPOLATION_SPACE=CM%IT_M
259  BASIS_XI_INTERPOLATION_VELOCITY=CM%IT_V
260  BASIS_XI_INTERPOLATION_PRESSURE=CM%IT_P
261  NUMBER_OF_NODES_SPACE=CM%N_M
262  NUMBER_OF_NODES_VELOCITY=CM%N_V
263  NUMBER_OF_NODES_PRESSURE=CM%N_P
264  TOTAL_NUMBER_OF_NODES=CM%N_T
265  TOTAL_NUMBER_OF_ELEMENTS=CM%E_T
266  NUMBER_OF_ELEMENT_NODES_SPACE=CM%EN_M
267  NUMBER_OF_ELEMENT_NODES_VELOCITY=CM%EN_V
268  NUMBER_OF_ELEMENT_NODES_PRESSURE=CM%EN_P
269  !Set initial values
270  INITIAL_FIELD_NAVIER_STOKES(1)=0.0_CMISSDP
271  INITIAL_FIELD_NAVIER_STOKES(2)=0.0_CMISSDP
272  INITIAL_FIELD_NAVIER_STOKES(3)=0.0_CMISSDP
273  !Set boundary conditions
274  FIXED_WALL_NODES_NAVIER_STOKES_FLAG=.TRUE.
275  INLET_WALL_NODES_NAVIER_STOKES_FLAG=.TRUE.
276  IF(FIXED_WALL_NODES_NAVIER_STOKES_FLAG) THEN
277    NUMBER_OF_FIXED_WALL_NODES_NAVIER_STOKES=80
278    ALLOCATE(FIXED_WALL_NODES_NAVIER_STOKES(NUMBER_OF_FIXED_WALL_NODES_NAVIER_STOKES))
279    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, & 
280    & 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, & 
281    & 89,90,91,92,93,94,95,97,99,101,102,103,104,105,106,107,108,111,114,115,116,117,118, & 
282    & 120,122,123,124,125/)
283  ENDIF
284  IF(INLET_WALL_NODES_NAVIER_STOKES_FLAG) THEN
285    NUMBER_OF_INLET_WALL_NODES_NAVIER_STOKES=9
286    ALLOCATE(INLET_WALL_NODES_NAVIER_STOKES(NUMBER_OF_INLET_WALL_NODES_NAVIER_STOKES))
287    INLET_WALL_NODES_NAVIER_STOKES=(/6,15,16,23,36,42,81,82,96/)
288    !Set initial boundary conditions
289    BOUNDARY_CONDITIONS_NAVIER_STOKES(1)=0.0_CMISSDP
290    BOUNDARY_CONDITIONS_NAVIER_STOKES(2)=1.0_CMISSDP
291    BOUNDARY_CONDITIONS_NAVIER_STOKES(3)=0.0_CMISSDP
292  ENDIF
293  !Set material parameters
294  MU_PARAM_NAVIER_STOKES=1.0_CMISSDP
295  RHO_PARAM_NAVIER_STOKES=0.0_CMISSDP
296  !Set interpolation parameters
297  BASIS_XI_GAUSS_SPACE=3
298  BASIS_XI_GAUSS_VELOCITY=3
299  BASIS_XI_GAUSS_PRESSURE=3
300  !Set output parameter
301  !(NoOutput/ProgressOutput/TimingOutput/SolverOutput/SolverMatrixOutput)
302  LINEAR_SOLVER_NAVIER_STOKES_OUTPUT_TYPE=CMISS_SOLVER_PROGRESS_OUTPUT
303  NONLINEAR_SOLVER_NAVIER_STOKES_OUTPUT_TYPE=CMISS_SOLVER_MATRIX_OUTPUT
304  !(NoOutput/TimingOutput/MatrixOutput/ElementOutput)
305  EQUATIONS_NAVIER_STOKES_OUTPUT=CMISS_EQUATIONS_NO_OUTPUT
306  !Set solver parameters
307  LINEAR_SOLVER_NAVIER_STOKES_DIRECT_FLAG=.TRUE.
308  RELATIVE_TOLERANCE=1.0E-5_CMISSDP !default: 1.0E-05_CMISSDP
309  ABSOLUTE_TOLERANCE=1.0E-10_CMISSDP !default: 1.0E-10_CMISSDP
310  DIVERGENCE_TOLERANCE=1.0E20 !default: 1.0E5
311  MAXIMUM_ITERATIONS=100000 !default: 100000
312  RESTART_VALUE=3000 !default: 30
313  LINESEARCH_ALPHA=1.0
314
315  !
316  !================================================================================================================================
317  !
318
319  !COORDINATE SYSTEM
320
321  !Start the creation of a new RC coordinate system
322  CALL CMISSCoordinateSystem_Initialise(CoordinateSystem,Err)
323  CALL CMISSCoordinateSystem_CreateStart(CoordinateSystemUserNumber,CoordinateSystem,Err)
324  !Set the coordinate system dimension
325  CALL CMISSCoordinateSystem_DimensionSet(CoordinateSystem,NUMBER_OF_DIMENSIONS,Err)
326  !Finish the creation of the coordinate system
327  CALL CMISSCoordinateSystem_CreateFinish(CoordinateSystem,Err)
328
329  !
330  !================================================================================================================================
331  !
332
333  !REGION
334
335  !Start the creation of a new region
336  CALL CMISSRegion_Initialise(Region,Err)
337  CALL CMISSRegion_CreateStart(RegionUserNumber,WorldRegion,Region,Err)
338  !Set the regions coordinate system as defined above
339  CALL CMISSRegion_CoordinateSystemSet(Region,CoordinateSystem,Err)
340  !Finish the creation of the region
341  CALL CMISSRegion_CreateFinish(Region,Err)
342
343  !
344  !================================================================================================================================
345  !
346
347  !BASES
348
349  !Start the creation of new bases
350  MESH_NUMBER_OF_COMPONENTS=1
351  CALL CMISSBasis_Initialise(BasisSpace,Err)
352  CALL CMISSBasis_CreateStart(BASIS_NUMBER_SPACE,BasisSpace,Err)
353  !Set the basis type (Lagrange/Simplex)
354  CALL CMISSBasis_TypeSet(BasisSpace,BASIS_TYPE,Err)
355  !Set the basis xi number
356  CALL CMISSBasis_NumberOfXiSet(BasisSpace,NUMBER_OF_DIMENSIONS,Err)
357  !Set the basis xi interpolation and number of Gauss points
358  IF(NUMBER_OF_DIMENSIONS==2) THEN
359    CALL CMISSBasis_InterpolationXiSet(BasisSpace,(/BASIS_XI_INTERPOLATION_SPACE,BASIS_XI_INTERPOLATION_SPACE/),Err)
360    CALL CMISSBasis_QuadratureNumberOfGaussXiSet(BasisSpace,(/BASIS_XI_GAUSS_SPACE,BASIS_XI_GAUSS_SPACE/),Err)
361  ELSE IF(NUMBER_OF_DIMENSIONS==3) THEN
362    CALL CMISSBasis_InterpolationXiSet(BasisSpace,(/BASIS_XI_INTERPOLATION_SPACE,BASIS_XI_INTERPOLATION_SPACE, & 
363      & BASIS_XI_INTERPOLATION_SPACE/),Err)                         
364    CALL CMISSBasis_QuadratureNumberOfGaussXiSet(BasisSpace,(/BASIS_XI_GAUSS_SPACE,BASIS_XI_GAUSS_SPACE,BASIS_XI_GAUSS_SPACE/),Err)
365  ENDIF
366  !Finish the creation of the basis
367  CALL CMISSBasis_CreateFinish(BasisSpace,Err)
368  !Start the creation of another basis
369  IF(BASIS_XI_INTERPOLATION_VELOCITY==BASIS_XI_INTERPOLATION_SPACE) THEN
370    BasisVelocity=BasisSpace
371  ELSE
372    MESH_NUMBER_OF_COMPONENTS=MESH_NUMBER_OF_COMPONENTS+1
373    !Initialise a new velocity basis
374    CALL CMISSBasis_Initialise(BasisVelocity,Err)
375    !Start the creation of a basis
376    CALL CMISSBasis_CreateStart(BASIS_NUMBER_VELOCITY,BasisVelocity,Err)
377    !Set the basis type (Lagrange/Simplex)
378    CALL CMISSBasis_TypeSet(BasisVelocity,BASIS_TYPE,Err)
379    !Set the basis xi number
380    CALL CMISSBasis_NumberOfXiSet(BasisVelocity,NUMBER_OF_DIMENSIONS,Err)
381    !Set the basis xi interpolation and number of Gauss points
382    IF(NUMBER_OF_DIMENSIONS==2) THEN
383      CALL CMISSBasis_InterpolationXiSet(BasisVelocity,(/BASIS_XI_INTERPOLATION_VELOCITY,BASIS_XI_INTERPOLATION_VELOCITY/),Err)
384      CALL CMISSBasis_QuadratureNumberOfGaussXiSet(BasisVelocity,(/BASIS_XI_GAUSS_VELOCITY,BASIS_XI_GAUSS_VELOCITY/),Err)
385    ELSE IF(NUMBER_OF_DIMENSIONS==3) THEN
386      CALL CMISSBasis_InterpolationXiSet(BasisVelocity,(/BASIS_XI_INTERPOLATION_VELOCITY,BASIS_XI_INTERPOLATION_VELOCITY, & 
387        & BASIS_XI_INTERPOLATION_VELOCITY/),Err)                         
388      CALL CMISSBasis_QuadratureNumberOfGaussXiSet(BasisVelocity,(/BASIS_XI_GAUSS_VELOCITY,BASIS_XI_GAUSS_VELOCITY, & 
389        & BASIS_XI_GAUSS_VELOCITY/),Err)
390    ENDIF
391    !Finish the creation of the basis
392    CALL CMISSBasis_CreateFinish(BasisVelocity,Err)
393  ENDIF
394  !Start the creation of another basis
395  IF(BASIS_XI_INTERPOLATION_PRESSURE==BASIS_XI_INTERPOLATION_SPACE) THEN
396    BasisPressure=BasisSpace
397  ELSE IF(BASIS_XI_INTERPOLATION_PRESSURE==BASIS_XI_INTERPOLATION_VELOCITY) THEN
398    BasisPressure=BasisVelocity
399  ELSE
400    MESH_NUMBER_OF_COMPONENTS=MESH_NUMBER_OF_COMPONENTS+1
401    !Initialise a new pressure basis
402    CALL CMISSBasis_Initialise(BasisPressure,Err)
403    !Start the creation of a basis
404    CALL CMISSBasis_CreateStart(BASIS_NUMBER_PRESSURE,BasisPressure,Err)
405    !Set the basis type (Lagrange/Simplex)
406    CALL CMISSBasis_TypeSet(BasisPressure,BASIS_TYPE,Err)
407    !Set the basis xi number
408    CALL CMISSBasis_NumberOfXiSet(BasisPressure,NUMBER_OF_DIMENSIONS,Err)
409    !Set the basis xi interpolation and number of Gauss points
410    IF(NUMBER_OF_DIMENSIONS==2) THEN
411      CALL CMISSBasis_InterpolationXiSet(BasisPressure,(/BASIS_XI_INTERPOLATION_PRESSURE,BASIS_XI_INTERPOLATION_PRESSURE/),Err)
412      CALL CMISSBasis_QuadratureNumberOfGaussXiSet(BasisPressure,(/BASIS_XI_GAUSS_PRESSURE,BASIS_XI_GAUSS_PRESSURE/),Err)
413    ELSE IF(NUMBER_OF_DIMENSIONS==3) THEN
414      CALL CMISSBasis_InterpolationXiSet(BasisPressure,(/BASIS_XI_INTERPOLATION_PRESSURE,BASIS_XI_INTERPOLATION_PRESSURE, & 
415        & BASIS_XI_INTERPOLATION_PRESSURE/),Err)                         
416      CALL CMISSBasis_QuadratureNumberOfGaussXiSet(BasisPressure,(/BASIS_XI_GAUSS_PRESSURE,BASIS_XI_GAUSS_PRESSURE, & 
417        & BASIS_XI_GAUSS_PRESSURE/),Err)
418    ENDIF
419    !Finish the creation of the basis
420    CALL CMISSBasis_CreateFinish(BasisPressure,Err)
421  ENDIF
422
423  !
424  !================================================================================================================================
425  !
426
427  !MESH
428
429  !Start the creation of mesh nodes
430  CALL CMISSNodes_Initialise(Nodes,Err)
431  CALL CMISSMesh_Initialise(Mesh,Err)
432  CALL CMISSNodes_CreateStart(Region,TOTAL_NUMBER_OF_NODES,Nodes,Err)
433  CALL CMISSNodes_CreateFinish(Nodes,Err)
434  !Start the creation of the mesh
435  CALL CMISSMesh_CreateStart(MeshUserNumber,Region,NUMBER_OF_DIMENSIONS,Mesh,Err)
436  !Set number of mesh elements
437  CALL CMISSMesh_NumberOfElementsSet(Mesh,TOTAL_NUMBER_OF_ELEMENTS,Err)
438  !Set number of mesh components
439  CALL CMISSMesh_NumberOfComponentsSet(Mesh,MESH_NUMBER_OF_COMPONENTS,Err)
440  !Specify spatial mesh component
441  CALL CMISSMeshElements_Initialise(MeshElementsSpace,Err)
442  CALL CMISSMeshElements_Initialise(MeshElementsVelocity,Err)
443  CALL CMISSMeshElements_Initialise(MeshElementsPressure,Err)
444  MESH_COMPONENT_NUMBER_SPACE=1
445  MESH_COMPONENT_NUMBER_VELOCITY=1
446  MESH_COMPONENT_NUMBER_PRESSURE=1
447  CALL CMISSMeshElements_CreateStart(Mesh,MESH_COMPONENT_NUMBER_SPACE,BasisSpace,MeshElementsSpace,Err)
448  DO ELEMENT_NUMBER=1,TOTAL_NUMBER_OF_ELEMENTS
449    CALL CMISSMeshElements_NodesSet(MeshElementsSpace,ELEMENT_NUMBER,CM%M(ELEMENT_NUMBER,1:NUMBER_OF_ELEMENT_NODES_SPACE),Err)
450  ENDDO
451  CALL CMISSMeshElements_CreateFinish(MeshElementsSpace,Err)
452  !Specify velocity mesh component
453  IF(BASIS_XI_INTERPOLATION_VELOCITY==BASIS_XI_INTERPOLATION_SPACE) THEN
454    MeshElementsVelocity=MeshElementsSpace
455  ELSE
456    MESH_COMPONENT_NUMBER_VELOCITY=MESH_COMPONENT_NUMBER_SPACE+1
457    CALL CMISSMeshElements_CreateStart(Mesh,MESH_COMPONENT_NUMBER_VELOCITY,BasisVelocity,MeshElementsVelocity,Err)
458    DO ELEMENT_NUMBER=1,TOTAL_NUMBER_OF_ELEMENTS
459      CALL CMISSMeshElements_NodesSet(MeshElementsVelocity,ELEMENT_NUMBER,CM%V(ELEMENT_NUMBER, & 
460        & 1:NUMBER_OF_ELEMENT_NODES_VELOCITY),Err)
461    ENDDO
462    CALL CMISSMeshElements_CreateFinish(MeshElementsVelocity,Err)
463  ENDIF
464  !Specify pressure mesh component
465  IF(BASIS_XI_INTERPOLATION_PRESSURE==BASIS_XI_INTERPOLATION_SPACE) THEN
466    MeshElementsPressure=MeshElementsSpace
467    MESH_COMPONENT_NUMBER_PRESSURE=MESH_COMPONENT_NUMBER_SPACE
468  ELSE IF(BASIS_XI_INTERPOLATION_PRESSURE==BASIS_XI_INTERPOLATION_VELOCITY) THEN
469    MeshElementsPressure=MeshElementsVelocity
470    MESH_COMPONENT_NUMBER_PRESSURE=MESH_COMPONENT_NUMBER_VELOCITY
471  ELSE
472    MESH_COMPONENT_NUMBER_PRESSURE=MESH_COMPONENT_NUMBER_VELOCITY+1
473    CALL CMISSMeshElements_CreateStart(Mesh,MESH_COMPONENT_NUMBER_PRESSURE,BasisPressure,MeshElementsPressure,Err)
474    DO ELEMENT_NUMBER=1,TOTAL_NUMBER_OF_ELEMENTS
475      CALL CMISSMeshElements_NodesSet(MeshElementsPressure,ELEMENT_NUMBER,CM%P(ELEMENT_NUMBER, & 
476        & 1:NUMBER_OF_ELEMENT_NODES_PRESSURE),Err)
477    ENDDO
478    CALL CMISSMeshElements_CreateFinish(MeshElementsPressure,Err)
479  ENDIF
480  !Finish the creation of the mesh
481  CALL CMISSMesh_CreateFinish(Mesh,Err)
482
483  !
484  !================================================================================================================================
485  !
486
487  !GEOMETRIC FIELD
488
489  !Create a decomposition
490  CALL CMISSDecomposition_Initialise(Decomposition,Err)
491  CALL CMISSDecomposition_CreateStart(DecompositionUserNumber,Mesh,Decomposition,Err)
492  !Set the decomposition to be a general decomposition with the specified number of domains
493  CALL CMISSDecomposition_TypeSet(Decomposition,CMISS_DECOMPOSITION_USER_DEFINED_TYPE,Err)
494  CALL CMISSDecomposition_NumberOfDomainsSet(Decomposition,NumberOfComputationalNodes,Err)
495
496  CALL CMISSDecomposition_ElementDomainSet(Decomposition,1,0,Err)
497  CALL CMISSDecomposition_ElementDomainSet(Decomposition,2,0,Err)
498  CALL CMISSDecomposition_ElementDomainSet(Decomposition,3,0,Err)
499  CALL CMISSDecomposition_ElementDomainSet(Decomposition,4,1,Err)
500  CALL CMISSDecomposition_ElementDomainSet(Decomposition,5,1,Err)
501  CALL CMISSDecomposition_ElementDomainSet(Decomposition,6,1,Err)
502  CALL CMISSDecomposition_ElementDomainSet(Decomposition,7,1,Err)
503  CALL CMISSDecomposition_ElementDomainSet(Decomposition,8,1,Err)
504
505
506  !Finish the decomposition
507  CALL CMISSDecomposition_CreateFinish(Decomposition,Err)
508
509  !Start to create a default (geometric) field on the region
510  CALL CMISSField_Initialise(GeometricField,Err)
511  CALL CMISSField_CreateStart(GeometricFieldUserNumber,Region,GeometricField,Err)
512  !Set the field type
513  CALL CMISSField_TypeSet(GeometricField,CMISS_FIELD_GEOMETRIC_TYPE,Err)
514  !Set the decomposition to use
515  CALL CMISSField_MeshDecompositionSet(GeometricField,Decomposition,Err)
516  !Set the scaling to use
517  CALL CMISSField_ScalingTypeSet(GeometricField,CMISS_FIELD_NO_SCALING,Err)
518  !Set the mesh component to be used by the field components.
519  DO COMPONENT_NUMBER=1,NUMBER_OF_DIMENSIONS
520    CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,COMPONENT_NUMBER, & 
521      & MESH_COMPONENT_NUMBER_SPACE,Err)
522  ENDDO
523  !Finish creating the field
524  CALL CMISSField_CreateFinish(GeometricField,Err)
525  !Update the geometric field parameters
526  DO NODE_NUMBER=1,NUMBER_OF_NODES_SPACE
527    DO COMPONENT_NUMBER=1,NUMBER_OF_DIMENSIONS
528      VALUE=CM%N(NODE_NUMBER,COMPONENT_NUMBER)
529      CALL CMISSDecomposition_NodeDomainGet(Decomposition,NODE_NUMBER,1,BoundaryNodeDomain,Err)
530      IF(BoundaryNodeDomain==ComputationalNodeNumber) THEN
531        CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, & 
532          & 1,CMISS_NO_GLOBAL_DERIV,NODE_NUMBER,COMPONENT_NUMBER,VALUE,Err)
533      ENDIF
534    ENDDO
535  ENDDO
536  CALL CMISSField_ParameterSetUpdateStart(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,Err)
537  CALL CMISSField_ParameterSetUpdateFinish(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,Err)
538
539
540
541  !
542  !================================================================================================================================
543  !
544
545  !EQUATIONS SETS
546
547  !Create the equations set for static Navier-Stokes
548  CALL CMISSEquationsSet_Initialise(EquationsSetNavierStokes,Err)
549    CALL CMISSField_Initialise(EquationsSetField,Err)
550CALL CMISSEquationsSet_CreateStart(EquationsSetUserNumberNavierStokes,Region,GeometricField, &
551    & CMISS_EQUATIONS_SET_FLUID_MECHANICS_CLASS,CMISS_EQUATIONS_SET_NAVIER_STOKES_EQUATION_TYPE, &
552      & CMISS_EQUATIONS_SET_STATIC_NAVIER_STOKES_SUBTYPE, &
553    & EquationsSetFieldUserNumber,EquationsSetField,EquationsSetNavierStokes,Err)
554  !Set the equations set to be a static Navier-Stokes problem
555  
556  !Finish creating the equations set
557  CALL CMISSEquationsSet_CreateFinish(EquationsSetNavierStokes,Err)
558
559
560  !
561  !================================================================================================================================
562  !
563
564  !DEPENDENT FIELDS
565
566  !Create the equations set dependent field variables for static Navier-Stokes
567  CALL CMISSField_Initialise(DependentFieldNavierStokes,Err)
568  CALL CMISSEquationsSet_DependentCreateStart(EquationsSetNavierStokes,DependentFieldUserNumberNavierStokes, & 
569    & DependentFieldNavierStokes,Err)
570  !Set the mesh component to be used by the field components.
571  DO COMPONENT_NUMBER=1,NUMBER_OF_DIMENSIONS
572    CALL CMISSField_ComponentMeshComponentSet(DependentFieldNavierStokes,CMISS_FIELD_U_VARIABLE_TYPE,COMPONENT_NUMBER, & 
573      & MESH_COMPONENT_NUMBER_VELOCITY,Err)
574    CALL CMISSField_ComponentMeshComponentSet(DependentFieldNavierStokes,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,COMPONENT_NUMBER, & 
575      & MESH_COMPONENT_NUMBER_VELOCITY,Err)
576  ENDDO
577  COMPONENT_NUMBER=NUMBER_OF_DIMENSIONS+1
578    CALL CMISSField_ComponentMeshComponentSet(DependentFieldNavierStokes,CMISS_FIELD_U_VARIABLE_TYPE,COMPONENT_NUMBER, & 
579      & MESH_COMPONENT_NUMBER_PRESSURE,Err)
580    CALL CMISSField_ComponentMeshComponentSet(DependentFieldNavierStokes,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,COMPONENT_NUMBER, & 
581      & MESH_COMPONENT_NUMBER_PRESSURE,Err)
582  !Finish the equations set dependent field variables
583  CALL CMISSEquationsSet_DependentCreateFinish(EquationsSetNavierStokes,Err)
584
585  !Initialise dependent field
586  DO COMPONENT_NUMBER=1,NUMBER_OF_DIMENSIONS
587    CALL CMISSField_ComponentValuesInitialise(DependentFieldNavierStokes,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, & 
588      & COMPONENT_NUMBER,INITIAL_FIELD_NAVIER_STOKES(COMPONENT_NUMBER),Err)
589  ENDDO
590
591
592  !
593  !================================================================================================================================
594  !
595
596  !MATERIALS FIELDS
597
598  !Create the equations set materials field variables for static Navier-Stokes
599  CALL CMISSField_Initialise(MaterialsFieldNavierStokes,Err)
600  CALL CMISSEquationsSet_MaterialsCreateStart(EquationsSetNavierStokes,MaterialsFieldUserNumberNavierStokes, & 
601    & MaterialsFieldNavierStokes,Err)
602  !Finish the equations set materials field variables
603  CALL CMISSEquationsSet_MaterialsCreateFinish(EquationsSetNavierStokes,Err)
604  CALL CMISSField_ComponentValuesInitialise(MaterialsFieldNavierStokes,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, & 
605    & MaterialsFieldUserNumberNavierStokesMu,MU_PARAM_NAVIER_STOKES,Err)
606  CALL CMISSField_ComponentValuesInitialise(MaterialsFieldNavierStokes,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, & 
607    & MaterialsFieldUserNumberNavierStokesRho,RHO_PARAM_NAVIER_STOKES,Err)
608
609
610  !
611  !================================================================================================================================
612  !
613
614  !EQUATIONS
615
616
617  !Create the equations set equations
618  CALL CMISSEquations_Initialise(EquationsNavierStokes,Err)
619  CALL CMISSEquationsSet_EquationsCreateStart(EquationsSetNavierStokes,EquationsNavierStokes,Err)
620  !Set the equations matrices sparsity type
621  CALL CMISSEquations_SparsityTypeSet(EquationsNavierStokes,CMISS_EQUATIONS_SPARSE_MATRICES,Err)
622  !Set the equations set output
623  CALL CMISSEquations_OutputTypeSet(EquationsNavierStokes,EQUATIONS_NAVIER_STOKES_OUTPUT,Err)
624  !Finish the equations set equations
625  CALL CMISSEquationsSet_EquationsCreateFinish(EquationsSetNavierStokes,Err)
626
627
628  !
629  !================================================================================================================================
630  !
631
632  !PROBLEMS
633
634  !Start the creation of a problem.
635  CALL CMISSProblem_Initialise(Problem,Err)
636  CALL CMISSControlLoop_Initialise(ControlLoop,Err)
637  CALL CMISSProblem_CreateStart(ProblemUserNumber,Problem,Err)
638  !Set the problem to be a static Navier-Stokes problem
639  CALL CMISSProblem_SpecificationSet(Problem,CMISS_PROBLEM_FLUID_MECHANICS_CLASS,CMISS_PROBLEM_NAVIER_STOKES_EQUATION_TYPE, &
640    & CMISS_PROBLEM_STATIC_NAVIER_STOKES_SUBTYPE,Err)
641  !Finish the creation of a problem.
642  CALL CMISSProblem_CreateFinish(Problem,Err)
643  !Start the creation of the problem control loop
644  CALL CMISSProblem_ControlLoopCreateStart(Problem,Err)
645  !Finish creating the problem control loop
646  CALL CMISSProblem_ControlLoopCreateFinish(Problem,Err)
647
648  !
649  !================================================================================================================================
650  !
651
652  !SOLVERS
653
654  !Start the creation of the problem solvers
655  CALL CMISSSolver_Initialise(NonlinearSolverNavierStokes,Err)
656  CALL CMISSSolver_Initialise(LinearSolverNavierStokes,Err)
657  CALL CMISSProblem_SolversCreateStart(Problem,Err)
658  !Get the nonlinear static solver
659  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,SolverNavierStokesUserNumber,NonlinearSolverNavierStokes,Err)
660  !Set the nonlinear Jacobian type
661!   CALL CMISSSolver_NewtonJacobianCalculationTypeSet(NonlinearSolverNavierStokes,CMISS_SOLVER_NEWTON_JACOBIAN_EQUATIONS_CALCULATED,Err)
662  !Set the output type
663  CALL CMISSSolver_OutputTypeSet(NonlinearSolverNavierStokes,NONLINEAR_SOLVER_NAVIER_STOKES_OUTPUT_TYPE,Err)
664  !Set the solver settings
665  CALL CMISSSolver_NewtonAbsoluteToleranceSet(NonlinearSolverNavierStokes,ABSOLUTE_TOLERANCE,Err)
666  CALL CMISSSolver_NewtonRelativeToleranceSet(NonlinearSolverNavierStokes,RELATIVE_TOLERANCE,Err)
667  !Get the nonlinear linear solver
668  CALL CMISSSolver_NewtonLinearSolverGet(NonlinearSolverNavierStokes,LinearSolverNavierStokes,Err)
669  !Set the output type
670  CALL CMISSSolver_OutputTypeSet(LinearSolverNavierStokes,LINEAR_SOLVER_NAVIER_STOKES_OUTPUT_TYPE,Err)
671
672
673  !Set the solver settings
674  IF(LINEAR_SOLVER_NAVIER_STOKES_DIRECT_FLAG) THEN
675    CALL CMISSSolver_LinearTypeSet(LinearSolverNavierStokes,CMISS_SOLVER_LINEAR_DIRECT_SOLVE_TYPE,Err)
676    CALL CMISSSolver_LibraryTypeSet(LinearSolverNavierStokes,CMISS_SOLVER_MUMPS_LIBRARY,Err)
677  ELSE
678    CALL CMISSSolver_LinearTypeSet(LinearSolverNavierStokes,CMISS_SOLVER_LINEAR_ITERATIVE_SOLVE_TYPE,Err)
679    CALL CMISSSolver_LinearIterativeMaximumIterationsSet(LinearSolverNavierStokes,MAXIMUM_ITERATIONS,Err)
680    CALL CMISSSolver_LinearIterativeDivergenceToleranceSet(LinearSolverNavierStokes,DIVERGENCE_TOLERANCE,Err)
681    CALL CMISSSolver_LinearIterativeRelativeToleranceSet(LinearSolverNavierStokes,RELATIVE_TOLERANCE,Err)
682    CALL CMISSSolver_LinearIterativeAbsoluteToleranceSet(LinearSolverNavierStokes,ABSOLUTE_TOLERANCE,Err)
683    CALL CMISSSolver_LinearIterativeGMRESRestartSet(LinearSolverNavierStokes,RESTART_VALUE,Err)
684  ENDIF
685  !Finish the creation of the problem solver
686  CALL CMISSProblem_SolversCreateFinish(Problem,Err)
687
688  !
689  !================================================================================================================================
690  !
691
692  !SOLVER EQUATIONS
693
694  !Start the creation of the problem solver equations
695  CALL CMISSSolver_Initialise(LinearSolverNavierStokes,Err)
696  CALL CMISSSolverEquations_Initialise(SolverEquationsNavierStokes,Err)
697  CALL CMISSProblem_SolverEquationsCreateStart(Problem,Err)
698  !Get the linear solver equations
699  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,SolverNavierStokesUserNumber,LinearSolverNavierStokes,Err)
700  CALL CMISSSolver_SolverEquationsGet(LinearSolverNavierStokes,SolverEquationsNavierStokes,Err)
701  !Set the solver equations sparsity
702  CALL CMISSSolverEquations_SparsityTypeSet(SolverEquationsNavierStokes,CMISS_SOLVER_SPARSE_MATRICES,Err)
703  !Add in the equations set
704  CALL CMISSSolverEquations_EquationsSetAdd(SolverEquationsNavierStokes,EquationsSetNavierStokes,EquationsSetIndex,Err)
705  !Finish the creation of the problem solver equations
706  CALL CMISSProblem_SolverEquationsCreateFinish(Problem,Err)
707
708
709  !
710  !================================================================================================================================
711  !
712
713  !BOUNDARY CONDITIONS
714
715  !Start the creation of the equations set boundary conditions for Stokes
716  CALL CMISSBoundaryConditions_Initialise(BoundaryConditionsNavierStokes,Err)
717  CALL CMISSSolverEquations_BoundaryConditionsCreateStart(SolverEquationsNavierStokes,BoundaryConditionsNavierStokes,Err)
718  !Set fixed wall nodes
719  IF(FIXED_WALL_NODES_NAVIER_STOKES_FLAG) THEN
720    DO NODE_COUNTER=1,NUMBER_OF_FIXED_WALL_NODES_NAVIER_STOKES
721      NODE_NUMBER=FIXED_WALL_NODES_NAVIER_STOKES(NODE_COUNTER)
722      CONDITION=CMISS_BOUNDARY_CONDITION_FIXED_WALL
723      CALL CMISSDecomposition_NodeDomainGet(Decomposition,NODE_NUMBER,1,BoundaryNodeDomain,Err)
724      IF(BoundaryNodeDomain==ComputationalNodeNumber) THEN
725        DO COMPONENT_NUMBER=1,NUMBER_OF_DIMENSIONS
726          VALUE=0.0_CMISSDP
727          CALL CMISSBoundaryConditions_SetNode(BoundaryConditionsNavierStokes,DependentFieldNavierStokes, &
728            & CMISS_FIELD_U_VARIABLE_TYPE,1, &
729            & CMISS_NO_GLOBAL_DERIV, &
730            & NODE_NUMBER,COMPONENT_NUMBER,CONDITION,VALUE,Err)
731        ENDDO
732      ENDIF
733    ENDDO
734  ENDIF
735  !Set velocity boundary conditions
736  IF(INLET_WALL_NODES_NAVIER_STOKES_FLAG) THEN
737    DO NODE_COUNTER=1,NUMBER_OF_INLET_WALL_NODES_NAVIER_STOKES
738      NODE_NUMBER=INLET_WALL_NODES_NAVIER_STOKES(NODE_COUNTER)
739      CONDITION=CMISS_BOUNDARY_CONDITION_FIXED_INLET
740      CALL CMISSDecomposition_NodeDomainGet(Decomposition,NODE_NUMBER,1,BoundaryNodeDomain,Err)
741      IF(BoundaryNodeDomain==ComputationalNodeNumber) THEN
742        DO COMPONENT_NUMBER=1,NUMBER_OF_DIMENSIONS
743          VALUE=BOUNDARY_CONDITIONS_NAVIER_STOKES(COMPONENT_NUMBER)
744          CALL CMISSBoundaryConditions_SetNode(BoundaryConditionsNavierStokes,DependentFieldNavierStokes, &
745            & CMISS_FIELD_U_VARIABLE_TYPE,1, &
746            & CMISS_NO_GLOBAL_DERIV, &
747            & NODE_NUMBER,COMPONENT_NUMBER,CONDITION,VALUE,Err)
748        ENDDO
749      ENDIF
750    ENDDO
751  ENDIF
752  !Finish the creation of the equations set boundary conditions
753  CALL CMISSSolverEquations_BoundaryConditionsCreateFinish(SolverEquationsNavierStokes,Err)
754
755  !
756  !================================================================================================================================
757  !
758
759  !RUN SOLVERS
760
761  !Turn of PETSc error handling
762  !CALL PETSC_ERRORHANDLING_SET_ON(ERR,ERROR,*999)
763
764  !Solve the problem
765  WRITE(*,'(A)') "Solving problem..."
766  CALL CMISSProblem_Solve(Problem,Err)
767  WRITE(*,'(A)') "Problem solved!"
768! 
769  !
770  !================================================================================================================================
771  !
772
773  !OUTPUT
774
775  EXPORT_FIELD_IO=.TRUE.
776  IF(EXPORT_FIELD_IO) THEN
777    WRITE(*,'(A)') "Exporting fields..."
778    CALL CMISSFields_Initialise(Fields,Err)
779    CALL CMISSFields_Create(Region,Fields,Err)
780    CALL CMISSFields_NodesExport(Fields,"StaticNavierStokes","FORTRAN",Err)
781    CALL CMISSFields_ElementsExport(Fields,"StaticNavierStokes","FORTRAN",Err)
782    CALL CMISSFields_Finalise(Fields,Err)
783    WRITE(*,'(A)') "Field exported!"
784  ENDIF
785  
786  !Finialise CMISS
787  CALL CMISSFinalise(Err)
788
789  WRITE(*,'(A)') "Program successfully completed."
790  
791  STOP
792
793END PROGRAM NAVIERSTOKESSTATICEXAMPLE