PageRenderTime 84ms CodeModel.GetById 15ms app.highlight 65ms RepoModel.GetById 1ms app.codeStats 0ms

/ClassicalField/Poisson/AnalyticNonlinearPoisson/src/AnalyticNonlinearPoissonExample.f90

http://github.com/xyan075/examples
FORTRAN Modern | 421 lines | 248 code | 53 blank | 120 comment | 4 complexity | 6926dae0b398f5e3afdc2f7943f5d90a 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/Poisson/AnalyticNonlinearPoisson/src/NonlinearPoissonExample.f90
 43!! Example program to solve a nonlinear Poisson equation using openCMISS calls.
 44!! \htmlinclude ClassicalField/Poisson/AnalyticNonlinearPoisson/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  !Test program parameters
 60
 61  REAL(CMISSDP), PARAMETER :: HEIGHT=0.5_CMISSDP
 62  REAL(CMISSDP), PARAMETER :: WIDTH=0.5_CMISSDP
 63  REAL(CMISSDP), PARAMETER :: LENGTH=1.0_CMISSDP
 64
 65  INTEGER(CMISSIntg), PARAMETER :: CoordinateSystemUserNumber=1
 66  INTEGER(CMISSIntg), PARAMETER :: RegionUserNumber=2
 67  INTEGER(CMISSIntg), PARAMETER :: BasisUserNumber=3
 68  INTEGER(CMISSIntg), PARAMETER :: GeneratedMeshUserNumber=4
 69  INTEGER(CMISSIntg), PARAMETER :: MeshUserNumber=5
 70  INTEGER(CMISSIntg), PARAMETER :: DecompositionUserNumber=6
 71  INTEGER(CMISSIntg), PARAMETER :: GeometricFieldUserNumber=7
 72  INTEGER(CMISSIntg), PARAMETER :: DependentFieldUserNumber=8
 73  INTEGER(CMISSIntg), PARAMETER :: MaterialsFieldUserNumber=9
 74  INTEGER(CMISSIntg), PARAMETER :: AnalyticFieldUserNumber=10
 75  INTEGER(CMISSIntg), PARAMETER :: EquationsSetUserNumber=11
 76  INTEGER(CMISSIntg), PARAMETER :: ProblemUserNumber=12
 77  INTEGER(CMISSIntg), PARAMETER :: EquationsSetFieldUserNumber=13
 78
 79  !Program variables
 80
 81  INTEGER(CMISSIntg) :: NUMBER_DIMENSIONS,INTERPOLATION_TYPE,NUMBER_OF_GAUSS_XI
 82  INTEGER(CMISSIntg) :: NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS,NUMBER_GLOBAL_Z_ELEMENTS
 83  INTEGER(CMISSIntg) :: component_idx
 84  INTEGER(CMISSIntg) :: NUMBER_OF_ARGUMENTS,ARGUMENT_LENGTH,STATUS
 85  CHARACTER(LEN=255) :: COMMAND_ARGUMENT
 86
 87  LOGICAL :: EXPORT_FIELD
 88
 89  !CMISS variables
 90
 91  TYPE(CMISSBasisType) :: Basis
 92  TYPE(CMISSCoordinateSystemType) :: CoordinateSystem,WorldCoordinateSystem
 93  TYPE(CMISSDecompositionType) :: Decomposition
 94  TYPE(CMISSEquationsType) :: Equations
 95  TYPE(CMISSEquationsSetType) :: EquationsSet
 96  TYPE(CMISSFieldType) :: GeometricField,DependentField,MaterialsField,AnalyticField
 97  TYPE(CMISSFieldsType) :: Fields
 98  TYPE(CMISSGeneratedMeshType) :: GeneratedMesh
 99  TYPE(CMISSMeshType) :: Mesh
100  TYPE(CMISSProblemType) :: Problem
101  TYPE(CMISSRegionType) :: Region,WorldRegion
102  TYPE(CMISSSolverType) :: Solver,LinearSolver
103  TYPE(CMISSSolverEquationsType) :: SolverEquations
104  TYPE(CMISSBoundaryConditionsType) :: BoundaryConditions
105  TYPE(CMISSFieldType) :: EquationsSetField
106
107  !Generic CMISS variables
108
109  INTEGER(CMISSIntg) :: EquationsSetIndex
110  INTEGER(CMISSIntg) :: Err
111  INTEGER(CMISSIntg) :: NumberOfComputationalNodes,ComputationalNodeNumber
112
113#ifdef WIN32
114  !Quickwin type
115  LOGICAL :: QUICKWIN_STATUS=.FALSE.
116  TYPE(WINDOWCONFIG) :: QUICKWIN_WINDOW_CONFIG
117
118  !Initialise QuickWin
119  QUICKWIN_WINDOW_CONFIG%TITLE="General Output" !Window title
120  QUICKWIN_WINDOW_CONFIG%NUMTEXTROWS=-1 !Max possible number of rows
121  QUICKWIN_WINDOW_CONFIG%MODE=QWIN$SCROLLDOWN
122  !Set the window parameters
123  QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
124  !If attempt fails set with system estimated values
125  IF(.NOT.QUICKWIN_STATUS) QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
126#endif
127
128  !Get input arguments
129  NUMBER_OF_ARGUMENTS = COMMAND_ARGUMENT_COUNT()
130  IF(NUMBER_OF_ARGUMENTS >= 4) THEN
131    !If we have enough arguments then use the first four for setting up the problem. The subsequent arguments may be used to
132    !pass flags to, say, PETSc.
133    CALL GET_COMMAND_ARGUMENT(1,COMMAND_ARGUMENT,ARGUMENT_LENGTH,STATUS)
134    IF(STATUS>0) CALL HANDLE_ERROR("Error for command argument 1.")
135    READ(COMMAND_ARGUMENT(1:ARGUMENT_LENGTH),*) NUMBER_GLOBAL_X_ELEMENTS
136    IF(NUMBER_GLOBAL_X_ELEMENTS<=0) CALL HANDLE_ERROR("Invalid number of X elements.")
137    CALL GET_COMMAND_ARGUMENT(2,COMMAND_ARGUMENT,ARGUMENT_LENGTH,STATUS)
138    IF(STATUS>0) CALL HANDLE_ERROR("Error for command argument 2.")
139    READ(COMMAND_ARGUMENT(1:ARGUMENT_LENGTH),*) NUMBER_GLOBAL_Y_ELEMENTS
140    IF(NUMBER_GLOBAL_Y_ELEMENTS<0) CALL HANDLE_ERROR("Invalid number of Y elements.")
141    CALL GET_COMMAND_ARGUMENT(3,COMMAND_ARGUMENT,ARGUMENT_LENGTH,STATUS)
142    IF(STATUS>0) CALL HANDLE_ERROR("Error for command argument 3.")
143    READ(COMMAND_ARGUMENT(1:ARGUMENT_LENGTH),*) NUMBER_GLOBAL_Z_ELEMENTS
144    IF(NUMBER_GLOBAL_Z_ELEMENTS<0) CALL HANDLE_ERROR("Invalid number of Z elements.")
145    CALL GET_COMMAND_ARGUMENT(4,COMMAND_ARGUMENT,ARGUMENT_LENGTH,STATUS)
146    IF(STATUS>0) CALL HANDLE_ERROR("Error for command argument 4.")
147    READ(COMMAND_ARGUMENT(1:ARGUMENT_LENGTH),*) INTERPOLATION_TYPE
148    IF(INTERPOLATION_TYPE<=0) CALL HANDLE_ERROR("Invalid Interpolation specification.")
149    IF(NUMBER_GLOBAL_Z_ELEMENTS>0) THEN
150      NUMBER_DIMENSIONS=3
151    ELSEIF(NUMBER_GLOBAL_Y_ELEMENTS>0) THEN
152      NUMBER_DIMENSIONS=2
153    ELSE
154      NUMBER_DIMENSIONS=1
155    ENDIF
156  ELSE
157    !If there are not enough arguments default the problem specification
158    NUMBER_DIMENSIONS=2
159    NUMBER_GLOBAL_X_ELEMENTS=5
160    NUMBER_GLOBAL_Y_ELEMENTS=5
161    NUMBER_GLOBAL_Z_ELEMENTS=0
162    INTERPOLATION_TYPE=1
163  ENDIF
164
165  !Intialise OpenCMISS
166  CALL CMISSInitialise(WorldCoordinateSystem,WorldRegion,Err)
167
168  !Trap all errors
169  CALL CMISSErrorHandlingModeSet(CMISS_ERRORS_TRAP_ERROR,Err)
170
171  !Output to a file
172  CALL CMISSOutputSetOn("NonlinearPoisson",Err)
173
174  !Get the computational nodes information
175  CALL CMISSComputationalNumberOfNodesGet(NumberOfComputationalNodes,Err)
176  CALL CMISSComputationalNodeNumberGet(ComputationalNodeNumber,Err)
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  !Set the coordinate system number of dimensions
182  CALL CMISSCoordinateSystem_DimensionSet(CoordinateSystem,NUMBER_DIMENSIONS,Err)
183  !Finish the creation of the coordinate system
184  CALL CMISSCoordinateSystem_CreateFinish(CoordinateSystem,Err)
185
186  !Start the creation of the region
187  CALL CMISSRegion_Initialise(Region,Err)
188  CALL CMISSRegion_CreateStart(RegionUserNumber,WorldRegion,Region,Err)
189  !Set the regions coordinate system to the 2D RC coordinate system that we have created
190  CALL CMISSRegion_CoordinateSystemSet(Region,CoordinateSystem,Err)
191  !Finish the creation of the region
192  CALL CMISSRegion_CreateFinish(Region,Err)
193
194  !Start the creation of a basis (default is trilinear lagrange)
195  CALL CMISSBasis_Initialise(Basis,Err)
196  CALL CMISSBasis_CreateStart(BasisUserNumber,Basis,Err)
197  CALL CMISSBasis_NumberOfXiSet(Basis,NUMBER_DIMENSIONS,Err)
198  SELECT CASE(INTERPOLATION_TYPE)
199  CASE(1,2,3,4)
200    CALL CMISSBasis_TypeSet(Basis,CMISS_BASIS_LAGRANGE_HERMITE_TP_TYPE,Err)
201  CASE(7,8,9)
202    CALL CMISSBasis_TypeSet(Basis,CMISS_BASIS_SIMPLEX_TYPE,Err)
203  CASE DEFAULT
204    CALL HANDLE_ERROR("Invalid interpolation type.")
205  END SELECT
206  SELECT CASE(INTERPOLATION_TYPE)
207  CASE(1)
208    NUMBER_OF_GAUSS_XI=2
209  CASE(2)
210    NUMBER_OF_GAUSS_XI=3
211  CASE(3,4)
212    NUMBER_OF_GAUSS_XI=4
213  CASE DEFAULT
214    NUMBER_OF_GAUSS_XI=0
215  END SELECT
216  IF(NUMBER_DIMENSIONS==1) THEN
217    CALL CMISSBasis_InterpolationXiSet(Basis,[INTERPOLATION_TYPE],Err)
218    IF(NUMBER_OF_GAUSS_XI>0) THEN
219      CALL CMISSBasis_QuadratureNumberOfGaussXiSet(Basis,[NUMBER_OF_GAUSS_XI],Err)
220    ENDIF
221  ELSEIF(NUMBER_DIMENSIONS==2) THEN
222    CALL CMISSBasis_InterpolationXiSet(Basis,[INTERPOLATION_TYPE,INTERPOLATION_TYPE],Err)
223    IF(NUMBER_OF_GAUSS_XI>0) THEN
224      CALL CMISSBasis_QuadratureNumberOfGaussXiSet(Basis,[NUMBER_OF_GAUSS_XI,NUMBER_OF_GAUSS_XI],Err)
225    ENDIF
226  ELSE
227    CALL CMISSBasis_InterpolationXiSet(Basis,[INTERPOLATION_TYPE,INTERPOLATION_TYPE,INTERPOLATION_TYPE],Err)
228    IF(NUMBER_OF_GAUSS_XI>0) THEN
229      CALL CMISSBasis_QuadratureNumberOfGaussXiSet(Basis,[NUMBER_OF_GAUSS_XI,NUMBER_OF_GAUSS_XI,NUMBER_OF_GAUSS_XI],Err)
230    ENDIF
231  ENDIF
232  !Finish the creation of the basis
233  CALL CMISSBasis_CreateFinish(Basis,Err)
234
235  !Start the creation of a generated mesh in the region
236  CALL CMISSGeneratedMesh_Initialise(GeneratedMesh,Err)
237  CALL CMISSGeneratedMesh_CreateStart(GeneratedMeshUserNumber,Region,GeneratedMesh,Err)
238  !Set up a regular x*y*z mesh
239  CALL CMISSGeneratedMesh_TypeSet(GeneratedMesh,CMISS_GENERATED_MESH_REGULAR_MESH_TYPE,Err)
240  !Set the default basis
241  CALL CMISSGeneratedMesh_BasisSet(GeneratedMesh,Basis,Err)
242  !Define the mesh on the region
243  IF(NUMBER_DIMENSIONS==1) THEN
244    CALL CMISSGeneratedMesh_ExtentSet(GeneratedMesh,[WIDTH],Err)
245    CALL CMISSGeneratedMesh_NumberOfElementsSet(GeneratedMesh,[NUMBER_GLOBAL_X_ELEMENTS],Err)
246  ELSEIF(NUMBER_DIMENSIONS==2) THEN
247    CALL CMISSGeneratedMesh_ExtentSet(GeneratedMesh,[WIDTH,HEIGHT],Err)
248    CALL CMISSGeneratedMesh_NumberOfElementsSet(GeneratedMesh,[NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS],Err)
249  ELSE
250    CALL CMISSGeneratedMesh_ExtentSet(GeneratedMesh,[WIDTH,HEIGHT,LENGTH],Err)
251    CALL CMISSGeneratedMesh_NumberOfElementsSet(GeneratedMesh,[NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS, &
252      & NUMBER_GLOBAL_Z_ELEMENTS],Err)
253  ENDIF
254  !Finish the creation of a generated mesh in the region
255  CALL CMISSMesh_Initialise(Mesh,Err)
256  CALL CMISSGeneratedMesh_CreateFinish(GeneratedMesh,MeshUserNumber,Mesh,Err)
257
258  !Create a decomposition
259  CALL CMISSDecomposition_Initialise(Decomposition,Err)
260  CALL CMISSDecomposition_CreateStart(DecompositionUserNumber,Mesh,Decomposition,Err)
261  !Set the decomposition to be a general decomposition with the specified number of domains
262  CALL CMISSDecomposition_TypeSet(Decomposition,CMISS_DECOMPOSITION_CALCULATED_TYPE,Err)
263  CALL CMISSDecomposition_NumberOfDomainsSet(Decomposition,NumberOfComputationalNodes,Err)
264  !Finish the decomposition
265  CALL CMISSDecomposition_CreateFinish(Decomposition,Err)
266
267  !Start to create a default (geometric) field on the region
268  CALL CMISSField_Initialise(GeometricField,Err)
269  CALL CMISSField_CreateStart(GeometricFieldUserNumber,Region,GeometricField,Err)
270  !Set the decomposition to use
271  CALL CMISSField_MeshDecompositionSet(GeometricField,Decomposition,Err)
272  !Set the domain to be used by the field components.
273  DO component_idx=1,NUMBER_DIMENSIONS
274    CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,component_idx,1,Err)
275  ENDDO
276  !Finish creating the field
277  CALL CMISSField_CreateFinish(GeometricField,Err)
278
279  !Update the geometric field parameters
280  CALL CMISSGeneratedMesh_GeometricParametersCalculate(GeneratedMesh,GeometricField,Err)
281
282  !Create the equations_set
283  CALL CMISSEquationsSet_Initialise(EquationsSet,Err)
284  CALL CMISSField_Initialise(EquationsSetField,Err)
285  CALL CMISSEquationsSet_CreateStart(EquationsSetUserNumber,Region,GeometricField,CMISS_EQUATIONS_SET_CLASSICAL_FIELD_CLASS, &
286    & CMISS_EQUATIONS_SET_POISSON_EQUATION_TYPE,CMISS_EQUATIONS_SET_EXPONENTIAL_SOURCE_POISSON_SUBTYPE, &
287      & EquationsSetFieldUserNumber, &
288    & EquationsSetField,EquationsSet,Err)
289
290  !Finish creating the equations set
291  CALL CMISSEquationsSet_CreateFinish(EquationsSet,Err)
292
293  !Create the equations set dependent field variables
294  CALL CMISSField_Initialise(DependentField,Err)
295  CALL CMISSEquationsSet_DependentCreateStart(EquationsSet,DependentFieldUserNumber,DependentField,Err)
296  !Finish the equations set dependent field variables
297  CALL CMISSEquationsSet_DependentCreateFinish(EquationsSet,Err)
298
299  !Initialise the field to zero
300  CALL CMISSField_ComponentValuesInitialise(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,0.0_CMISSDP, &
301    & Err)
302
303  !Create the equations set material field variables
304  CALL CMISSField_Initialise(MaterialsField,Err)
305  CALL CMISSEquationsSet_MaterialsCreateStart(EquationsSet,MaterialsFieldUserNumber,MaterialsField,Err)
306  !Finish the equations set dependent field variables
307  CALL CMISSEquationsSet_MaterialsCreateFinish(EquationsSet,Err)
308
309  !Create the equations set analytic field variables
310  CALL CMISSField_Initialise(AnalyticField,Err)
311  IF(NUMBER_DIMENSIONS==2) THEN
312    CALL CMISSEquationsSet_AnalyticCreateStart(EquationsSet,CMISS_EQUATIONS_SET_POISSON_EQUATION_TWO_DIM_1, &
313      & AnalyticFieldUserNumber, &
314      & AnalyticField, &
315      & Err)
316  ELSE
317    WRITE(*,'(A)') "One and three dimensions are not implemented."
318    STOP
319  ENDIF
320  !Finish the equations set analytic field variables
321  CALL CMISSEquationsSet_AnalyticCreateFinish(EquationsSet,Err)
322
323  !Create the equations set equations
324  CALL CMISSEquations_Initialise(Equations,Err)
325  CALL CMISSEquationsSet_EquationsCreateStart(EquationsSet,Equations,Err)
326  !Set the equations matrices sparsity type
327  CALL CMISSEquations_SparsityTypeSet(Equations,CMISS_EQUATIONS_SPARSE_MATRICES,Err)
328  !Set the equations set output
329  CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_NO_OUTPUT,Err)
330  !Finish the equations set equations
331  CALL CMISSEquationsSet_EquationsCreateFinish(EquationsSet,Err)
332
333  !Start the creation of a problem.
334  CALL CMISSProblem_Initialise(Problem,Err)
335  CALL CMISSProblem_CreateStart(ProblemUserNumber,Problem,Err)
336  !Set the problem to be a standard Poisson problem
337  CALL CMISSProblem_SpecificationSet(Problem,CMISS_PROBLEM_CLASSICAL_FIELD_CLASS,CMISS_PROBLEM_POISSON_EQUATION_TYPE, &
338    & CMISS_PROBLEM_NONLINEAR_SOURCE_POISSON_SUBTYPE,Err)
339  !Finish the creation of a problem.
340  CALL CMISSProblem_CreateFinish(Problem,Err)
341
342  !Start the creation of the problem control loop
343  CALL CMISSProblem_ControlLoopCreateStart(Problem,Err)
344  !Finish creating the problem control loop
345  CALL CMISSProblem_ControlLoopCreateFinish(Problem,Err)
346
347  !Start the creation of the problem solvers
348  CALL CMISSSolver_Initialise(Solver,Err)
349  CALL CMISSSolver_Initialise(LinearSolver,Err)
350  CALL CMISSProblem_SolversCreateStart(Problem,Err)
351  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,1,Solver,Err)
352  !Set the solver output
353  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_NO_OUTPUT,Err)
354  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_PROGRESS_OUTPUT,Err)
355  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_TIMING_OUTPUT,Err)
356  !CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_SOLVER_OUTPUT,Err)
357  CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_MATRIX_OUTPUT,Err)
358  !Set the Jacobian type
359  CALL CMISSSolver_NewtonJacobianCalculationTypeSet(Solver,CMISS_SOLVER_NEWTON_JACOBIAN_EQUATIONS_CALCULATED,Err)
360  !CALL CMISSSolver_NewtonJacobianCalculationTypeSet(Solver,CMISS_SOLVER_NEWTON_JACOBIAN_FD_CALCULATED,Err)
361  !Get the associated linear solver
362  CALL CMISSSolver_NewtonLinearSolverGet(Solver,LinearSolver,Err)
363  CALL CMISSSolver_LinearIterativeMaximumIterationsSet(LinearSolver,500,Err)
364  !Finish the creation of the problem solver
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  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  !Finish the creation of the problem solver equations
380  CALL CMISSProblem_SolverEquationsCreateFinish(Problem,Err)
381
382  !Set up the boundary conditions as per the analytic solution
383  CALL CMISSBoundaryConditions_Initialise(BoundaryConditions,Err)
384  CALL CMISSSolverEquations_BoundaryConditionsCreateStart(SolverEquations,BoundaryConditions,Err)
385  CALL CMISSSolverEquations_BoundaryConditionsAnalytic(SolverEquations,Err)
386  CALL CMISSSolverEquations_BoundaryConditionsCreateFinish(SolverEquations,Err)
387
388  !Solve the problem
389  CALL CMISSProblem_Solve(Problem,Err)
390
391  !Output Analytic analysis
392  Call CMISSAnalyticAnalysisOutput(DependentField,"",Err)
393
394  EXPORT_FIELD=.TRUE.
395  IF(EXPORT_FIELD) THEN
396    CALL CMISSFields_Initialise(Fields,Err)
397    CALL CMISSFields_Create(Region,Fields,Err)
398    CALL CMISSFields_NodesExport(Fields,"NonlinearPoisson","FORTRAN",Err)
399    CALL CMISSFields_ElementsExport(Fields,"NonlinearPoisson","FORTRAN",Err)
400    CALL CMISSFields_Finalise(Fields,Err)
401  ENDIF
402
403  !Finialise CMISS
404  CALL CMISSFinalise(Err)
405
406  WRITE(*,'(A)') "Program successfully completed."
407
408  STOP
409
410CONTAINS
411
412  SUBROUTINE HANDLE_ERROR(ERROR_STRING)
413
414    CHARACTER(LEN=*), INTENT(IN) :: ERROR_STRING
415
416    WRITE(*,'(">>ERROR: ",A)') ERROR_STRING(1:LEN_TRIM(ERROR_STRING))
417    STOP
418
419  END SUBROUTINE HANDLE_ERROR
420
421END PROGRAM NONLINEARPOISSONEXAMPLE