PageRenderTime 123ms CodeModel.GetById 80ms app.highlight 37ms RepoModel.GetById 2ms app.codeStats 0ms

/ClassicalField/SCRATCH/LinearPoissonNeumannCubic/src/LinearPoissonNeumannCubicExample.f90

http://github.com/xyan075/examples
FORTRAN Modern | 412 lines | 202 code | 68 blank | 142 comment | 0 complexity | 749dfbeaadb4899a2b4f7922c1465555 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 LINEARPOISSONEXAMPLE
 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/3.0_CMISSDP
 67  REAL(CMISSDP), PARAMETER :: WIDTH=1.0_CMISSDP/3.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_ALL_DIAG_TYPE,[1,2,3,4,5],"Diagnostics",[""],Err)
159
160  NUMBER_GLOBAL_X_ELEMENTS=8
161  NUMBER_GLOBAL_Y_ELEMENTS=8
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_InterpolationXiSet(Basis,(/3,3/),Err) !Cubic, linear is default
207    CALL CMISSBasis_QuadratureNumberOfGaussXiSet(Basis,(/4,4/),Err) !3 Gauss per Xi direction per element
208  ELSE
209    !Set the basis to be a trilinear Lagrange basis
210    CALL CMISSBasis_NumberOfXiSet(Basis,3,Err)
211    CALL CMISSBasis_InterpolationXiSet(Basis,(/2,2,2/),Err) !Quad, linear is default
212    CALL CMISSBasis_QuadratureNumberOfGaussXiSet(Basis,(/3,3,3/),Err) !3 Gauss per Xi direction per element
213  ENDIF
214  !Finish the creation of the basis
215  CALL CMISSBasis_CreateFinish(Basis,Err)
216   
217  !Start the creation of a generated mesh in the region
218  CALL CMISSGeneratedMesh_Initialise(GeneratedMesh,Err)
219  CALL CMISSGeneratedMesh_CreateStart(GeneratedMeshUserNumber,Region,GeneratedMesh,Err)
220  !Set up a regular x*y*z mesh
221  CALL CMISSGeneratedMesh_TypeSet(GeneratedMesh,CMISS_GENERATED_MESH_REGULAR_MESH_TYPE,Err)
222  !Set the default basis
223  CALL CMISSGeneratedMesh_BasisSet(GeneratedMesh,Basis,Err)   
224  !Define the mesh on the region
225  IF(NUMBER_GLOBAL_Z_ELEMENTS==0) THEN
226    CALL CMISSGeneratedMesh_ExtentSet(GeneratedMesh,(/WIDTH,HEIGHT/),Err)
227    CALL CMISSGeneratedMesh_NumberOfElementsSet(GeneratedMesh,(/NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS/),Err)
228  ELSE
229    CALL CMISSGeneratedMesh_ExtentSet(GeneratedMesh,(/WIDTH,HEIGHT,LENGTH/),Err)
230    CALL CMISSGeneratedMesh_NumberOfElementsSet(GeneratedMesh,(/NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS, &
231      & NUMBER_GLOBAL_Z_ELEMENTS/),Err)
232  ENDIF    
233  !Finish the creation of a generated mesh in the region
234  CALL CMISSMesh_Initialise(Mesh,Err)
235  CALL CMISSGeneratedMesh_CreateFinish(GeneratedMesh,MeshUserNumber,Mesh,Err)
236
237  !Create a decomposition
238  CALL CMISSDecomposition_Initialise(Decomposition,Err)
239  CALL CMISSDecomposition_CreateStart(DecompositionUserNumber,Mesh,Decomposition,Err)
240  !Set the decomposition to be a general decomposition with the specified number of domains
241  CALL CMISSDecomposition_TypeSet(Decomposition,CMISS_DECOMPOSITION_CALCULATED_TYPE,Err)
242  CALL CMISSDecomposition_NumberOfDomainsSet(Decomposition,NUMBER_OF_DOMAINS,Err)
243  !Finish the decomposition
244  CALL CMISSDecomposition_CreateFinish(Decomposition,Err)
245  
246  !Start to create a default (geometric) field on the region
247  CALL CMISSField_Initialise(GeometricField,Err)
248  CALL CMISSField_CreateStart(GeometricFieldUserNumber,Region,GeometricField,Err) !!!What is wrong with this
249  !Set the decomposition to use
250  CALL CMISSField_MeshDecompositionSet(GeometricField,Decomposition,Err)
251  !Set the domain to be used by the field components.
252  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,Err)
253  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,2,1,Err)
254  IF(NUMBER_GLOBAL_Z_ELEMENTS/=0) THEN
255    CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,3,1,Err)
256  ENDIF
257  !Finish creating the field
258  CALL CMISSField_CreateFinish(GeometricField,Err)
259       
260  !Update the geometric field parameters
261  CALL CMISSGeneratedMesh_GeometricParametersCalculate(GeneratedMesh,GeometricField,Err)
262  
263  !Create the equations_set
264  CALL CMISSEquationsSet_Initialise(EquationsSet,Err)
265    CALL CMISSField_Initialise(EquationsSetField,Err)
266CALL CMISSEquationsSet_CreateStart(EquationsSetUserNumber,Region,GeometricField,CMISS_EQUATIONS_SET_CLASSICAL_FIELD_CLASS, &
267    & CMISS_EQUATIONS_SET_POISSON_EQUATION_TYPE,CMISS_EQUATIONS_SET_CONSTANT_SOURCE_POISSON_SUBTYPE,EquationsSetFieldUserNumber, &
268    & EquationsSetField,EquationsSet,Err)
269  !Set the equations set to be a standard Laplace problem
270  
271  !Finish creating the equations set
272  CALL CMISSEquationsSet_CreateFinish(EquationsSet,Err)
273
274  !Create the equations set dependent field variables
275  CALL CMISSField_Initialise(DependentField,Err)
276  CALL CMISSEquationsSet_DependentCreateStart(EquationsSet,DependentFieldUserNumber,DependentField,Err)
277  !Finish the equations set dependent field variables
278  CALL CMISSEquationsSet_DependentCreateFinish(EquationsSet,Err)
279
280  !Create the equations set material field variables
281  CALL CMISSField_Initialise(MaterialsField,Err)
282  CALL CMISSEquationsSet_MaterialsCreateStart(EquationsSet,MaterialsFieldUserNumber,MaterialsField,Err)
283  !Finish the equations set dependent field variables
284  CALL CMISSEquationsSet_MaterialsCreateFinish(EquationsSet,Err)
285
286  CALL CMISSField_ComponentValuesInitialise(MaterialsField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, &
287    & 1,C_PARAM_POISSON,Err)
288
289
290  !Create the equations set analytic field variables
291  CALL CMISSField_Initialise(AnalyticField,Err)
292  CALL CMISSEquationsSet_AnalyticCreateStart(EquationsSet,CMISS_TEST_CASE_NEUMANN_CUBIC, &
293    & AnalyticFieldUserNumber,AnalyticField,Err)
294
295!Finish the equations set analytic field variables
296  CALL CMISSEquationsSet_AnalyticCreateFinish(EquationsSet,Err)
297  
298
299  !Create the equations set source field variables for Poisson
300  CALL CMISSField_Initialise(SourceField,Err)
301  CALL CMISSEquationsSet_SourceCreateStart(EquationsSet,SourceFieldUserNumber, & 
302    & SourceField,Err)
303!   !Set the mesh component to be used by the field components.
304!   CALL CMISSField_ComponentMeshComponentSet(SourceFieldPoisson,CMISS_FIELD_U_VARIABLE_TYPE,MESH_COMPONENT_NUMBER_SPACE, & 
305!     & MESH_COMPONENT_NUMBER_PRESSURE,Err)
306  !Finish the equations set source field variables
307  CALL CMISSEquationsSet_SourceCreateFinish(EquationsSet,Err)
308
309  !Create the equations set equations
310  CALL CMISSEquations_Initialise(Equations,Err)
311  CALL CMISSEquationsSet_EquationsCreateStart(EquationsSet,Equations,Err)
312  !Set the equations matrices sparsity type
313  CALL CMISSEquations_SparsityTypeSet(Equations,CMISS_EQUATIONS_SPARSE_MATRICES,Err)
314  !Set the equations set output
315  !CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_NO_OUTPUT,Err)
316  !CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_TIMING_OUTPUT,Err)
317!   CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_MATRIX_OUTPUT,Err)
318  !CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_ELEMENT_MATRIX_OUTPUT,Err)
319  !Finish the equations set equations
320  CALL CMISSEquationsSet_EquationsCreateFinish(EquationsSet,Err)
321
322  !Start the creation of a problem.
323  CALL CMISSProblem_Initialise(Problem,Err)
324  CALL CMISSProblem_CreateStart(ProblemUserNumber,Problem,Err)
325  !Set the problem to be a standard Laplace problem
326  CALL CMISSProblem_SpecificationSet(Problem,CMISS_PROBLEM_CLASSICAL_FIELD_CLASS,CMISS_PROBLEM_POISSON_EQUATION_TYPE, &
327    & CMISS_PROBLEM_LINEAR_SOURCE_POISSON_SUBTYPE,Err)
328  !Finish the creation of a problem.
329  CALL CMISSProblem_CreateFinish(Problem,Err)
330
331  !Start the creation of the problem control loop
332  CALL CMISSProblem_ControlLoopCreateStart(Problem,Err)
333  !Finish creating the problem control loop
334  CALL CMISSProblem_ControlLoopCreateFinish(Problem,Err)
335 
336  !Start the creation of the problem solvers
337  CALL CMISSSolver_Initialise(Solver,Err)
338  CALL CMISSSolver_Initialise(LinearSolver,Err)
339  CALL CMISSProblem_SolversCreateStart(Problem,Err)
340  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,1,Solver,Err)
341  !Set the solver output
342  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_NO_OUTPUT,Err)
343  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_PROGRESS_OUTPUT,Err)
344  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_TIMING_OUTPUT,Err)
345  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_SOLVER_OUTPUT,Err)
346!   CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_MATRIX_OUTPUT,Err)
347  !Set the Jacobian type
348  !CALL CMISSSolver_NewtonJacobianCalculationTypeSet(Solver,CMISS_SOLVER_NEWTON_JACOBIAN_EQUATIONS_CALCULATED,Err)
349  !CALL CMISSSolver_NewtonJacobianCalculationTypeSet(Solver,CMISS_SOLVER_NEWTON_JACOBIAN_FD_CALCULATED,Err)
350  !Get the associated linear solver
351  !CALL CMISSSolver_NewtonLinearSolverGet(Solver,LinearSolver,Err)
352  !CALL CMISSSolver_LinearIterativeMaximumIterationsSet(LinearSolver,300,Err)
353  !Finish the creation of the problem solver
354
355!  CALL CMISSSolver_LinearTypeSet(Solver,CMISS_SOLVER_LINEAR_DIRECT_SOLVE_TYPE,Err)
356!  CALL CMISSSolver_LibraryTypeSet(Solver,CMISS_SOLVER_MUMPS_LIBRARY,Err)
357
358    CALL CMISSSolver_LinearTypeSet(Solver,CMISS_SOLVER_LINEAR_ITERATIVE_SOLVE_TYPE,Err)
359    CALL CMISSSolver_LinearIterativeMaximumIterationsSet(Solver,MAXIMUM_ITERATIONS,Err)
360    CALL CMISSSolver_LinearIterativeDivergenceToleranceSet(Solver,DIVERGENCE_TOLERANCE,Err)
361    CALL CMISSSolver_LinearIterativeRelativeToleranceSet(Solver,RELATIVE_TOLERANCE,Err)
362    CALL CMISSSolver_LinearIterativeAbsoluteToleranceSet(Solver,ABSOLUTE_TOLERANCE,Err)
363    CALL CMISSSolver_LinearIterativeGMRESRestartSet(Solver,RESTART_VALUE,Err)
364
365  CALL CMISSProblem_SolversCreateFinish(Problem,Err)
366
367  !Start the creation of the problem solver equations
368  CALL CMISSSolver_Initialise(Solver,Err)
369  CALL CMISSSolverEquations_Initialise(SolverEquations,Err)
370  CALL CMISSProblem_SolverEquationsCreateStart(Problem,Err)
371  !Get the solve equations
372  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,1,Solver,Err)
373
374  CALL CMISSSolver_SolverEquationsGet(Solver,SolverEquations,Err)
375  !Set the solver equations sparsity
376  CALL CMISSSolverEquations_SparsityTypeSet(SolverEquations,CMISS_SOLVER_SPARSE_MATRICES,Err)
377  !CALL CMISSSolverEquations_SparsityTypeSet(SolverEquations,CMISS_SOLVER_FULL_MATRICES,Err)  
378  !Add in the equations set
379  CALL CMISSSolverEquations_EquationsSetAdd(SolverEquations,EquationsSet,EquationsSetIndex,Err)
380
381  !Finish the creation of the problem solver equations
382  CALL CMISSProblem_SolverEquationsCreateFinish(Problem,Err)
383
384  !Set up the boundary conditions as per the analytic solution
385  CALL CMISSBoundaryConditions_Initialise(BoundaryConditions,Err)
386  CALL CMISSSolverEquations_BoundaryConditionsCreateStart(SolverEquations,BoundaryConditions,Err)
387  CALL CMISSSolverEquations_BoundaryConditionsAnalytic(SolverEquations,Err)
388  CALL CMISSSolverEquations_BoundaryConditionsCreateFinish(SolverEquations,Err)
389
390  !Solve the problem
391  CALL CMISSProblem_Solve(Problem,Err)
392
393   !Output Analytic analysis
394   Call CMISSAnalyticAnalysisOutput(DependentField,"AnalyticalPoisson",Err)
395     
396   EXPORT_FIELD=.TRUE. 
397   IF(EXPORT_FIELD) THEN
398     CALL CMISSFields_Initialise(Fields,Err)
399     CALL CMISSFields_Create(Region,Fields,Err)
400     CALL CMISSFields_NodesExport(Fields,"NonlinearPoisson","FORTRAN",Err)
401     CALL CMISSFields_ElementsExport(Fields,"NonlinearPoisson","FORTRAN",Err)
402     CALL CMISSFields_Finalise(Fields,Err)
403   ENDIF
404
405  !Finalise CMISS
406  CALL CMISSFinalise(Err)
407
408  WRITE(*,'(A)') "Program successfully completed."
409  
410  STOP
411  
412END PROGRAM LINEARPOISSONEXAMPLE