PageRenderTime 73ms CodeModel.GetById 16ms app.highlight 52ms RepoModel.GetById 2ms app.codeStats 0ms

/ClassicalField/SCRATCH/LinearPoisson/src/LinearPoissonExample.f90

http://github.com/xyan075/examples
FORTRAN Modern | 411 lines | 201 code | 68 blank | 142 comment | 0 complexity | aa818e215099177767dc7077749e722c MD5 | raw file
  1!> \file
  2!> \author Chris Bradley
  3!> \brief This is an example program to solve a nonlinear Poisson equation using openCMISS calls.
  4!>
  5!> \section LICENSE
  6!>
  7!> Version: MPL 1.1/GPL 2.0/LGPL 2.1
  8!>
  9!> The contents of this file are subject to the Mozilla Public License
 10!> Version 1.1 (the "License"); you may not use this file except in
 11!> compliance with the License. You may obtain a copy of the License at
 12!> http://www.mozilla.org/MPL/
 13!>
 14!> Software distributed under the License is distributed on an "AS IS"
 15!> basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
 16!> License for the specific language governing rights and limitations
 17!> under the License.
 18!>
 19!> The Original Code is OpenCMISS
 20!>
 21!> The Initial Developer of the Original Code is University of Auckland,
 22!> Auckland, New Zealand and University of Oxford, Oxford, United
 23!> Kingdom. Portions created by the University of Auckland and University
 24!> of Oxford are Copyright (C) 2007 by the University of Auckland and
 25!> the University of Oxford. All Rights Reserved.
 26!>
 27!> Contributor(s):
 28!>
 29!> Alternatively, the contents of this file may be used under the terms of
 30!> either the GNU General Public License Version 2 or later (the "GPL"), or
 31!> the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 32!> in which case the provisions of the GPL or the LGPL are applicable instead
 33!> of those above. If you wish to allow use of your version of this file only
 34!> under the terms of either the GPL or the LGPL, and not to allow others to
 35!> use your version of this file under the terms of the MPL, indicate your
 36!> decision by deleting the provisions above and replace them with the notice
 37!> and other provisions required by the GPL or the LGPL. If you do not delete
 38!> the provisions above, a recipient may use your version of this file under
 39!> the terms of any one of the MPL, the GPL or the LGPL.
 40!>
 41
 42!> \example ClassicalField/NonlinearPoisson/src/NonlinearPoissonExample.f90
 43!! Example program to solve a nonlinear Poisson equation using openCMISS calls.
 44!! \htmlinclude ClassicalField/NonlinearPoisson/history.html
 45!<
 46
 47!> Main program
 48PROGRAM NONLINEARPOISSONEXAMPLE
 49
 50  USE OPENCMISS
 51  USE MPI
 52
 53#ifdef WIN32
 54  USE IFQWIN
 55#endif
 56
 57  IMPLICIT NONE
 58
 59  INTEGER(CMISSIntg), PARAMETER :: EquationsSetFieldUserNumber=1337
 60  TYPE(CMISSFieldType) :: EquationsSetField
 61
 62
 63  !Test program parameters
 64
 65! Setup used for quads
 66  REAL(CMISSDP), PARAMETER :: HEIGHT=1.0_CMISSDP/2.0_CMISSDP
 67  REAL(CMISSDP), PARAMETER :: WIDTH=1.0_CMISSDP/2.0_CMISSDP
 68  REAL(CMISSDP), PARAMETER :: LENGTH=0.0_CMISSDP
 69
 70  INTEGER(CMISSIntg), PARAMETER :: CoordinateSystemUserNumber=1
 71  INTEGER(CMISSIntg), PARAMETER :: RegionUserNumber=2
 72  INTEGER(CMISSIntg), PARAMETER :: BasisUserNumber=3
 73  INTEGER(CMISSIntg), PARAMETER :: GeneratedMeshUserNumber=4
 74  INTEGER(CMISSIntg), PARAMETER :: MeshUserNumber=5
 75  INTEGER(CMISSIntg), PARAMETER :: DecompositionUserNumber=6
 76  INTEGER(CMISSIntg), PARAMETER :: GeometricFieldUserNumber=7
 77  INTEGER(CMISSIntg), PARAMETER :: DependentFieldUserNumber=8
 78  INTEGER(CMISSIntg), PARAMETER :: MaterialsFieldUserNumber=9
 79  INTEGER(CMISSIntg), PARAMETER :: AnalyticFieldUserNumber=10
 80  INTEGER(CMISSIntg), PARAMETER :: EquationsSetUserNumber=11
 81  INTEGER(CMISSIntg), PARAMETER :: ProblemUserNumber=12
 82  INTEGER(CMISSIntg), PARAMETER :: SourceFieldUserNumber=13
 83 
 84  INTEGER(CMISSIntg), PARAMETER :: CONSTANT_MATERIALS_COMPONENT=3 !! For 3D this is 4
 85  REAL(CMISSDP) :: DIVERGENCE_TOLERANCE
 86  REAL(CMISSDP) :: RELATIVE_TOLERANCE
 87  REAL(CMISSDP) :: ABSOLUTE_TOLERANCE
 88
 89  !Program types
 90  
 91  !Program variables
 92
 93  INTEGER(CMISSIntg) :: NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS,NUMBER_GLOBAL_Z_ELEMENTS
 94  INTEGER(CMISSIntg) :: NUMBER_OF_DOMAINS
 95  REAL(CMISSDP) :: C_PARAM_POISSON
 96
 97  INTEGER(CMISSIntg) :: MPI_IERROR
 98  LOGICAL :: EXPORT_FIELD
 99  
100
101  !CMISS variables
102
103  TYPE(CMISSBasisType) :: Basis
104  TYPE(CMISSCoordinateSystemType) :: CoordinateSystem,WorldCoordinateSystem
105  TYPE(CMISSDecompositionType) :: Decomposition
106  TYPE(CMISSEquationsType) :: Equations
107  TYPE(CMISSEquationsSetType) :: EquationsSet
108  TYPE(CMISSFieldType) :: GeometricField,DependentField,MaterialsField,AnalyticField,SourceField
109  TYPE(CMISSFieldsType) :: Fields
110  TYPE(CMISSGeneratedMeshType) :: GeneratedMesh  
111  TYPE(CMISSMeshType) :: Mesh
112  TYPE(CMISSProblemType) :: Problem
113  TYPE(CMISSRegionType) :: Region,WorldRegion
114  TYPE(CMISSSolverType) :: Solver,LinearSolver
115  TYPE(CMISSSolverEquationsType) :: SolverEquations
116  TYPE(CMISSBoundaryConditionsType) :: BoundaryConditions
117  INTEGER(CMISSIntg) :: MAXIMUM_ITERATIONS
118  INTEGER(CMISSIntg) :: RESTART_VALUE
119
120
121#ifdef WIN32
122  !Quickwin type
123  LOGICAL :: QUICKWIN_STATUS=.FALSE.
124  TYPE(WINDOWCONFIG) :: QUICKWIN_WINDOW_CONFIG
125#endif
126  
127  !Generic CMISS variables
128  
129  INTEGER(CMISSIntg) :: EquationsSetIndex
130  INTEGER(CMISSIntg) :: Err
131  
132!  INTEGER(CMISSIntg) :: DIAG_LEVEL_LIST(1)
133!  CHARACTER(LEN=255) :: DIAG_ROUTINE_LIST(1)
134
135#ifdef WIN32
136  !Initialise QuickWin
137  QUICKWIN_WINDOW_CONFIG%TITLE="General Output" !Window title
138  QUICKWIN_WINDOW_CONFIG%NUMTEXTROWS=-1 !Max possible number of rows
139  QUICKWIN_WINDOW_CONFIG%MODE=QWIN$SCROLLDOWN
140  !Set the window parameters
141  QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
142  !If attempt fails set with system estimated values
143  IF(.NOT.QUICKWIN_STATUS) QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
144#endif
145
146  !Set material parameter (constant added to all dofs)
147  C_PARAM_POISSON=8.0_CMISSDP  !For 2D
148
149
150  !Initialise OpenCMISS
151  CALL CMISSInitialise(WorldCoordinateSystem,WorldRegion,Err)
152
153  !Set diagnostics
154!  DIAG_LEVEL_LIST(1)=1
155!  DIAG_ROUTINE_LIST(1)="FIELD_MAPPINGS_CALCULATE"
156
157  !CMISS_ALL_DIAG_TYPE/CMISS_IN_DIAG_TYPE/CMISS_FROM_DIAG_TYPE
158!  CALL CMISSDiagnosticsSetOn(CMISS_IN_DIAG_TYPE,DIAG_LEVEL_LIST,"LinearPoissonDiagnostics",DIAG_ROUTINE_LIST,Err)
159
160  NUMBER_GLOBAL_X_ELEMENTS=2
161  NUMBER_GLOBAL_Y_ELEMENTS=2
162  NUMBER_GLOBAL_Z_ELEMENTS=0
163
164  RELATIVE_TOLERANCE=1.0E-13_CMISSDP !default: 1.0E-05_CMISSDP
165  ABSOLUTE_TOLERANCE=1.0E-13_CMISSDP !default: 1.0E-10_CMISSDP
166  DIVERGENCE_TOLERANCE=1.0E5_CMISSDP !default: 1.0E5
167  MAXIMUM_ITERATIONS=10000000_CMISSIntg !default: 100000
168  RESTART_VALUE=30_CMISSIntg !default: 30
169
170  CALL MPI_COMM_SIZE(MPI_COMM_WORLD,NUMBER_OF_DOMAINS,MPI_IERROR)
171
172  !Broadcast the number of elements in the X & Y directions and the number of partitions to the other computational nodes
173  CALL MPI_BCAST(NUMBER_GLOBAL_X_ELEMENTS,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
174  CALL MPI_BCAST(NUMBER_GLOBAL_Y_ELEMENTS,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
175  CALL MPI_BCAST(NUMBER_GLOBAL_Z_ELEMENTS,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
176  CALL MPI_BCAST(NUMBER_OF_DOMAINS,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
177 
178   !Start the creation of a new RC coordinate system
179  CALL CMISSCoordinateSystem_Initialise(CoordinateSystem,Err)
180  CALL CMISSCoordinateSystem_CreateStart(CoordinateSystemUserNumber,CoordinateSystem,Err)
181  IF(NUMBER_GLOBAL_Z_ELEMENTS==0) THEN
182    !Set the coordinate system to be 2D
183    CALL CMISSCoordinateSystem_DimensionSet(CoordinateSystem,2,Err)
184  ELSE
185    !Set the coordinate system to be 3D
186    CALL CMISSCoordinateSystem_DimensionSet(CoordinateSystem,3,Err)
187  ENDIF
188  !Finish the creation of the coordinate system
189  CALL CMISSCoordinateSystem_CreateFinish(CoordinateSystem,Err)
190
191  !Start the creation of the region
192  CALL CMISSRegion_Initialise(Region,Err)
193  CALL CMISSRegion_CreateStart(RegionUserNumber,WorldRegion,Region,Err)
194  !Set the regions coordinate system to the 2D RC coordinate system that we have created
195  CALL CMISSRegion_CoordinateSystemSet(Region,CoordinateSystem,Err)
196  !Finish the creation of the region
197  CALL CMISSRegion_CreateFinish(Region,Err)
198
199  !Start the creation of a basis (default is trilinear lagrange)
200  CALL CMISSBasis_Initialise(Basis,Err)
201  CALL CMISSBasis_CreateStart(BasisUserNumber,Basis,Err)
202  IF(NUMBER_GLOBAL_Z_ELEMENTS==0) THEN
203    !Set the basis to be a bilinear Lagrange basis
204    CALL CMISSBasis_NumberOfXiSet(Basis,2,Err)
205    CALL CMISSBasis_InterpolationXiSet(Basis,(/2,2/),Err) !Quad, linear is default
206    CALL CMISSBasis_QuadratureNumberOfGaussXiSet(Basis,(/3,3/),Err) !3 Gauss per Xi direction per element
207  ELSE
208    !Set the basis to be a trilinear Lagrange basis
209    CALL CMISSBasis_NumberOfXiSet(Basis,3,Err)
210    CALL CMISSBasis_InterpolationXiSet(Basis,(/2,2,2/),Err) !Quad, linear is default
211    CALL CMISSBasis_QuadratureNumberOfGaussXiSet(Basis,(/3,3,3/),Err) !3 Gauss per Xi direction per element
212  ENDIF
213  !Finish the creation of the basis
214  CALL CMISSBasis_CreateFinish(Basis,Err)
215   
216  !Start the creation of a generated mesh in the region
217  CALL CMISSGeneratedMesh_Initialise(GeneratedMesh,Err)
218  CALL CMISSGeneratedMesh_CreateStart(GeneratedMeshUserNumber,Region,GeneratedMesh,Err)
219  !Set up a regular x*y*z mesh
220  CALL CMISSGeneratedMesh_TypeSet(GeneratedMesh,CMISS_GENERATED_MESH_REGULAR_MESH_TYPE,Err)
221  !Set the default basis
222  CALL CMISSGeneratedMesh_BasisSet(GeneratedMesh,Basis,Err)   
223  !Define the mesh on the region
224  IF(NUMBER_GLOBAL_Z_ELEMENTS==0) THEN
225    CALL CMISSGeneratedMesh_ExtentSet(GeneratedMesh,(/WIDTH,HEIGHT/),Err)
226    CALL CMISSGeneratedMesh_NumberOfElementsSet(GeneratedMesh,(/NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS/),Err)
227  ELSE
228    CALL CMISSGeneratedMesh_ExtentSet(GeneratedMesh,(/WIDTH,HEIGHT,LENGTH/),Err)
229    CALL CMISSGeneratedMesh_NumberOfElementsSet(GeneratedMesh,(/NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS, &
230      & NUMBER_GLOBAL_Z_ELEMENTS/),Err)
231  ENDIF    
232  !Finish the creation of a generated mesh in the region
233  CALL CMISSMesh_Initialise(Mesh,Err)
234  CALL CMISSGeneratedMesh_CreateFinish(GeneratedMesh,MeshUserNumber,Mesh,Err)
235
236  !Create a decomposition
237  CALL CMISSDecomposition_Initialise(Decomposition,Err)
238  CALL CMISSDecomposition_CreateStart(DecompositionUserNumber,Mesh,Decomposition,Err)
239  !Set the decomposition to be a general decomposition with the specified number of domains
240  CALL CMISSDecomposition_TypeSet(Decomposition,CMISS_DECOMPOSITION_CALCULATED_TYPE,Err)
241  CALL CMISSDecomposition_NumberOfDomainsSet(Decomposition,NUMBER_OF_DOMAINS,Err)
242  !Finish the decomposition
243  CALL CMISSDecomposition_CreateFinish(Decomposition,Err)
244  
245  !Start to create a default (geometric) field on the region
246  CALL CMISSField_Initialise(GeometricField,Err)
247  CALL CMISSField_CreateStart(GeometricFieldUserNumber,Region,GeometricField,Err) !!!What is wrong with this
248  !Set the decomposition to use
249  CALL CMISSField_MeshDecompositionSet(GeometricField,Decomposition,Err)
250  !Set the domain to be used by the field components.
251  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,Err)
252  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,2,1,Err)
253  IF(NUMBER_GLOBAL_Z_ELEMENTS/=0) THEN
254    CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,3,1,Err)
255  ENDIF
256  !Finish creating the field
257  CALL CMISSField_CreateFinish(GeometricField,Err)
258       
259  !Update the geometric field parameters
260  CALL CMISSGeneratedMesh_GeometricParametersCalculate(GeneratedMesh,GeometricField,Err)
261  
262  !Create the equations_set
263  CALL CMISSEquationsSet_Initialise(EquationsSet,Err)
264    CALL CMISSField_Initialise(EquationsSetField,Err)
265CALL CMISSEquationsSet_CreateStart(EquationsSetUserNumber,Region,GeometricField,CMISS_EQUATIONS_SET_CLASSICAL_FIELD_CLASS, &
266    & CMISS_EQUATIONS_SET_POISSON_EQUATION_TYPE,CMISS_EQUATIONS_SET_CONSTANT_SOURCE_POISSON_SUBTYPE,EquationsSetFieldUserNumber, &
267    & EquationsSetField,EquationsSet,Err)
268  !Set the equations set to be a standard Laplace problem
269  
270  !Finish creating the equations set
271  CALL CMISSEquationsSet_CreateFinish(EquationsSet,Err)
272
273  !Create the equations set dependent field variables
274  CALL CMISSField_Initialise(DependentField,Err)
275  CALL CMISSEquationsSet_DependentCreateStart(EquationsSet,DependentFieldUserNumber,DependentField,Err)
276  !Finish the equations set dependent field variables
277  CALL CMISSEquationsSet_DependentCreateFinish(EquationsSet,Err)
278
279  !Create the equations set material field variables
280  CALL CMISSField_Initialise(MaterialsField,Err)
281  CALL CMISSEquationsSet_MaterialsCreateStart(EquationsSet,MaterialsFieldUserNumber,MaterialsField,Err)
282  !Finish the equations set dependent field variables
283  CALL CMISSEquationsSet_MaterialsCreateFinish(EquationsSet,Err)
284
285  CALL CMISSField_ComponentValuesInitialise(MaterialsField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, &
286    & 1,C_PARAM_POISSON,Err)
287
288
289  !Create the equations set analytic field variables
290  CALL CMISSField_Initialise(AnalyticField,Err)
291  CALL CMISSEquationsSet_AnalyticCreateStart(EquationsSet,CMISS_TEST_CASE_NEUMANN, &
292    & AnalyticFieldUserNumber,AnalyticField,Err)
293
294!Finish the equations set analytic field variables
295  CALL CMISSEquationsSet_AnalyticCreateFinish(EquationsSet,Err)
296  
297
298  !Create the equations set source field variables for Poisson
299  CALL CMISSField_Initialise(SourceField,Err)
300  CALL CMISSEquationsSet_SourceCreateStart(EquationsSet,SourceFieldUserNumber, & 
301    & SourceField,Err)
302!   !Set the mesh component to be used by the field components.
303!   CALL CMISSField_ComponentMeshComponentSet(SourceFieldPoisson,CMISS_FIELD_U_VARIABLE_TYPE,MESH_COMPONENT_NUMBER_SPACE, & 
304!     & MESH_COMPONENT_NUMBER_PRESSURE,Err)
305  !Finish the equations set source field variables
306  CALL CMISSEquationsSet_SourceCreateFinish(EquationsSet,Err)
307
308  !Create the equations set equations
309  CALL CMISSEquations_Initialise(Equations,Err)
310  CALL CMISSEquationsSet_EquationsCreateStart(EquationsSet,Equations,Err)
311  !Set the equations matrices sparsity type
312  CALL CMISSEquations_SparsityTypeSet(Equations,CMISS_EQUATIONS_SPARSE_MATRICES,Err)
313  !Set the equations set output
314  !CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_NO_OUTPUT,Err)
315  !CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_TIMING_OUTPUT,Err)
316!   CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_MATRIX_OUTPUT,Err)
317  !CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_ELEMENT_MATRIX_OUTPUT,Err)
318  !Finish the equations set equations
319  CALL CMISSEquationsSet_EquationsCreateFinish(EquationsSet,Err)
320
321  !Start the creation of a problem.
322  CALL CMISSProblem_Initialise(Problem,Err)
323  CALL CMISSProblem_CreateStart(ProblemUserNumber,Problem,Err)
324  !Set the problem to be a standard Laplace problem
325  CALL CMISSProblem_SpecificationSet(Problem,CMISS_PROBLEM_CLASSICAL_FIELD_CLASS,CMISS_PROBLEM_POISSON_EQUATION_TYPE, &
326    & CMISS_PROBLEM_LINEAR_SOURCE_POISSON_SUBTYPE,Err)
327  !Finish the creation of a problem.
328  CALL CMISSProblem_CreateFinish(Problem,Err)
329
330  !Start the creation of the problem control loop
331  CALL CMISSProblem_ControlLoopCreateStart(Problem,Err)
332  !Finish creating the problem control loop
333  CALL CMISSProblem_ControlLoopCreateFinish(Problem,Err)
334 
335  !Start the creation of the problem solvers
336  CALL CMISSSolver_Initialise(Solver,Err)
337  CALL CMISSSolver_Initialise(LinearSolver,Err)
338  CALL CMISSProblem_SolversCreateStart(Problem,Err)
339  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,1,Solver,Err)
340  !Set the solver output
341  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_NO_OUTPUT,Err)
342  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_PROGRESS_OUTPUT,Err)
343  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_TIMING_OUTPUT,Err)
344  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_SOLVER_OUTPUT,Err)
345!   CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_MATRIX_OUTPUT,Err)
346  !Set the Jacobian type
347  !CALL CMISSSolver_NewtonJacobianCalculationTypeSet(Solver,CMISS_SOLVER_NEWTON_JACOBIAN_EQUATIONS_CALCULATED,Err)
348  !CALL CMISSSolver_NewtonJacobianCalculationTypeSet(Solver,CMISS_SOLVER_NEWTON_JACOBIAN_FD_CALCULATED,Err)
349  !Get the associated linear solver
350  !CALL CMISSSolver_NewtonLinearSolverGet(Solver,LinearSolver,Err)
351  !CALL CMISSSolver_LinearIterativeMaximumIterationsSet(LinearSolver,300,Err)
352  !Finish the creation of the problem solver
353
354!  CALL CMISSSolver_LinearTypeSet(Solver,CMISS_SOLVER_LINEAR_DIRECT_SOLVE_TYPE,Err)
355!  CALL CMISSSolver_LibraryTypeSet(Solver,CMISS_SOLVER_MUMPS_LIBRARY,Err)
356
357    CALL CMISSSolver_LinearTypeSet(Solver,CMISS_SOLVER_LINEAR_ITERATIVE_SOLVE_TYPE,Err)
358    CALL CMISSSolver_LinearIterativeMaximumIterationsSet(Solver,MAXIMUM_ITERATIONS,Err)
359    CALL CMISSSolver_LinearIterativeDivergenceToleranceSet(Solver,DIVERGENCE_TOLERANCE,Err)
360    CALL CMISSSolver_LinearIterativeRelativeToleranceSet(Solver,RELATIVE_TOLERANCE,Err)
361    CALL CMISSSolver_LinearIterativeAbsoluteToleranceSet(Solver,ABSOLUTE_TOLERANCE,Err)
362    CALL CMISSSolver_LinearIterativeGMRESRestartSet(Solver,RESTART_VALUE,Err)
363
364  CALL CMISSProblem_SolversCreateFinish(Problem,Err)
365
366  !Start the creation of the problem solver equations
367  CALL CMISSSolver_Initialise(Solver,Err)
368  CALL CMISSSolverEquations_Initialise(SolverEquations,Err)
369  CALL CMISSProblem_SolverEquationsCreateStart(Problem,Err)
370  !Get the solve equations
371  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,1,Solver,Err)
372
373  CALL CMISSSolver_SolverEquationsGet(Solver,SolverEquations,Err)
374  !Set the solver equations sparsity
375  CALL CMISSSolverEquations_SparsityTypeSet(SolverEquations,CMISS_SOLVER_SPARSE_MATRICES,Err)
376  !CALL CMISSSolverEquations_SparsityTypeSet(SolverEquations,CMISS_SOLVER_FULL_MATRICES,Err)  
377  !Add in the equations set
378  CALL CMISSSolverEquations_EquationsSetAdd(SolverEquations,EquationsSet,EquationsSetIndex,Err)
379
380  !Finish the creation of the problem solver equations
381  CALL CMISSProblem_SolverEquationsCreateFinish(Problem,Err)
382
383  !Set up the boundary conditions as per the analytic solution
384  CALL CMISSBoundaryConditions_Initialise(BoundaryConditions,Err)
385  CALL CMISSSolverEquations_BoundaryConditionsCreateStart(SolverEquations,BoundaryConditions,Err)
386  CALL CMISSSolverEquations_BoundaryConditionsAnalytic(SolverEquations,Err)
387  CALL CMISSSolverEquations_BoundaryConditionsCreateFinish(SolverEquations,Err)
388
389  !Solve the problem
390  CALL CMISSProblem_Solve(Problem,Err)
391
392   !Output Analytic analysis
393   Call CMISSAnalyticAnalysisOutput(DependentField,"AnalyticalPoisson",Err)
394     
395   EXPORT_FIELD=.TRUE. 
396   IF(EXPORT_FIELD) THEN
397     CALL CMISSFields_Initialise(Fields,Err)
398     CALL CMISSFields_Create(Region,Fields,Err)
399     CALL CMISSFields_NodesExport(Fields,"NonlinearPoisson","FORTRAN",Err)
400     CALL CMISSFields_ElementsExport(Fields,"NonlinearPoisson","FORTRAN",Err)
401     CALL CMISSFields_Finalise(Fields,Err)
402   ENDIF
403
404  !Finalise CMISS
405  CALL CMISSFinalise(Err)
406
407  WRITE(*,'(A)') "Program successfully completed."
408  
409  STOP
410  
411END PROGRAM NONLINEARPOISSONEXAMPLE