PageRenderTime 82ms CodeModel.GetById 8ms app.highlight 68ms RepoModel.GetById 1ms app.codeStats 1ms

/FiniteElasticity/UniAxialExtension/src/UniAxialExtensionExample.f90

http://github.com/xyan075/examples
FORTRAN Modern | 491 lines | 331 code | 67 blank | 93 comment | 0 complexity | 938ede0bb56d866244e5003150856265 MD5 | raw file
  1!> \file
  2!> \author Chris Bradley
  3!> \brief This is an example program to solve a finite elasticity 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): Kumar Mithraratne, Adam Reeve
 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 FiniteElasticity/UniAxialExtension/src/UniAxialExtensionExample.f90
 43!! Example program to solve a finite elasticity equation using openCMISS calls.
 44!! \par Latest Builds:
 45!! \li <a href='http://autotest.bioeng.auckland.ac.nz/opencmiss-build/logs_x86_64-linux/FiniteElasticity/UniAxialExtension/build-intel'>Linux Intel Build</a>
 46!! \li <a href='http://autotest.bioeng.auckland.ac.nz/opencmiss-build/logs_x86_64-linux/FiniteElasticity/UniAxialExtension/build-gnu'>Linux GNU Build</a>
 47!<
 48
 49!> Main program
 50PROGRAM UNIAXIALEXTENSIONEXAMPLE
 51
 52  USE OPENCMISS
 53  USE MPI
 54
 55#ifdef WIN32
 56  USE IFQWIN
 57#endif
 58
 59  IMPLICIT NONE
 60
 61  !Test program parameters
 62
 63  REAL(CMISSDP), PARAMETER :: HEIGHT=1.0_CMISSDP
 64  REAL(CMISSDP), PARAMETER :: WIDTH=1.0_CMISSDP
 65  REAL(CMISSDP), PARAMETER :: LENGTH=1.0_CMISSDP
 66
 67  INTEGER(CMISSIntg), PARAMETER :: CoordinateSystemUserNumber=1
 68  INTEGER(CMISSIntg), PARAMETER :: NumberOfSpatialCoordinates=3
 69  INTEGER(CMISSIntg), PARAMETER :: RegionUserNumber=1
 70  INTEGER(CMISSIntg), PARAMETER :: BasisUserNumber=1
 71  INTEGER(CMISSIntg), PARAMETER :: MeshUserNumber=1
 72  INTEGER(CMISSIntg), PARAMETER :: DecompositionUserNumber=1
 73
 74  INTEGER(CMISSIntg), PARAMETER :: NumberOfXiCoordinates=3
 75  INTEGER(CMISSIntg), PARAMETER :: TotalNumberOfNodes=8
 76  INTEGER(CMISSIntg), PARAMETER :: NumberOfMeshDimensions=3
 77  INTEGER(CMISSIntg), PARAMETER :: NumberOfMeshComponents=1
 78  INTEGER(CMISSIntg), PARAMETER :: TotalNumberOfElements=1
 79  INTEGER(CMISSIntg), PARAMETER :: MeshComponentNumber=1
 80
 81  INTEGER(CMISSIntg), PARAMETER :: FieldGeometryUserNumber=1
 82  INTEGER(CMISSIntg), PARAMETER :: FieldGeometryNumberOfVariables=1
 83  INTEGER(CMISSIntg), PARAMETER :: FieldGeometryNumberOfComponents=3
 84
 85  INTEGER(CMISSIntg), PARAMETER :: FieldFibreUserNumber=2
 86  INTEGER(CMISSIntg), PARAMETER :: FieldFibreNumberOfVariables=1
 87  INTEGER(CMISSIntg), PARAMETER :: FieldFibreNumberOfComponents=3
 88
 89  INTEGER(CMISSIntg), PARAMETER :: FieldMaterialUserNumber=3
 90  INTEGER(CMISSIntg), PARAMETER :: FieldMaterialNumberOfVariables=1
 91  INTEGER(CMISSIntg), PARAMETER :: FieldMaterialNumberOfComponents=2
 92
 93  INTEGER(CMISSIntg), PARAMETER :: FieldDependentUserNumber=4
 94  INTEGER(CMISSIntg), PARAMETER :: FieldDependentNumberOfVariables=2
 95  INTEGER(CMISSIntg), PARAMETER :: FieldDependentNumberOfComponents=4
 96
 97  INTEGER(CMISSIntg), PARAMETER :: EquationSetUserNumber=1
 98  INTEGER(CMISSIntg), PARAMETER :: EquationsSetFieldUserNumber=13
 99  INTEGER(CMISSIntg), PARAMETER :: ProblemUserNumber=1
100
101  !Program types
102
103
104  !Program variables
105
106  INTEGER(CMISSIntg) :: NumberGlobalXElements,NumberGlobalYElements,NumberGlobalZElements
107  INTEGER(CMISSIntg) :: MPI_IERROR
108  INTEGER(CMISSIntg) :: EquationsSetIndex  
109  INTEGER(CMISSIntg) :: NumberOfComputationalNodes,NumberOfDomains,ComputationalNodeNumber
110
111  !CMISS variables
112
113  TYPE(CMISSBasisType) :: Basis
114  TYPE(CMISSBoundaryConditionsType) :: BoundaryConditions
115  TYPE(CMISSCoordinateSystemType) :: CoordinateSystem, WorldCoordinateSystem
116  TYPE(CMISSMeshType) :: Mesh
117  TYPE(CMISSDecompositionType) :: Decomposition
118  TYPE(CMISSEquationsType) :: Equations
119  TYPE(CMISSEquationsSetType) :: EquationsSet
120  TYPE(CMISSFieldType) :: GeometricField,FibreField,MaterialField,DependentField,EquationsSetField
121  TYPE(CMISSFieldsType) :: Fields
122  TYPE(CMISSProblemType) :: Problem
123  TYPE(CMISSRegionType) :: Region,WorldRegion
124  TYPE(CMISSSolverType) :: Solver,LinearSolver
125  TYPE(CMISSSolverEquationsType) :: SolverEquations
126  TYPE(CMISSNodesType) :: Nodes
127  TYPE(CMISSMeshElementsType) :: Elements
128
129  !REAL(CMISSDP), POINTER :: FieldData(:)
130
131#ifdef WIN32
132  !Quickwin type
133  LOGICAL :: QUICKWIN_STATUS=.FALSE.
134  TYPE(WINDOWCONFIG) :: QUICKWIN_WINDOW_CONFIG
135#endif
136
137  !Generic CMISS variables
138  INTEGER(CMISSIntg) :: Err
139
140#ifdef WIN32
141  !Initialise QuickWin
142  QUICKWIN_WINDOW_CONFIG%TITLE="General Output" !Window title
143  QUICKWIN_WINDOW_CONFIG%NUMTEXTROWS=-1 !Max possible number of rows
144  QUICKWIN_WINDOW_CONFIG%MODE=QWIN$SCROLLDOWN
145  !Set the window parameters
146  QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
147  !If attempt fails set with system estimated values
148  IF(.NOT.QUICKWIN_STATUS) QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
149#endif
150
151  !Intialise cmiss
152  CALL CMISSInitialise(WorldCoordinateSystem,WorldRegion,Err)
153
154  CALL CMISSErrorHandlingModeSet(CMISS_ERRORS_TRAP_ERROR,Err)
155
156  WRITE(*,'(A)') "Program starting."
157
158  !Set all diganostic levels on for testing
159  CALL CMISSDiagnosticsSetOn(CMISS_FROM_DIAG_TYPE,(/1,2,3,4,5/),"Diagnostics",(/"PROBLEM_FINITE_ELEMENT_CALCULATE"/),Err)
160
161  !Get the number of computational nodes and this computational node number
162  CALL CMISSComputationalNumberOfNodesGet(NumberOfComputationalNodes,Err)
163  CALL CMISSComputationalNodeNumberGet(ComputationalNodeNumber,Err)
164
165  NumberGlobalXElements=1
166  NumberGlobalYElements=1
167  NumberGlobalZElements=1   
168  NumberOfDomains=1
169
170  !Broadcast the number of elements in the X,Y and Z directions and the number of partitions to the other computational nodes
171  CALL MPI_BCAST(NumberGlobalXElements,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
172  CALL MPI_BCAST(NumberGlobalYElements,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
173  CALL MPI_BCAST(NumberGlobalZElements,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
174  CALL MPI_BCAST(NumberOfDomains,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
175
176  !Create a CS - default is 3D rectangular cartesian CS with 0,0,0 as origin
177  CALL CMISSCoordinateSystem_Initialise(CoordinateSystem,Err)
178  CALL CMISSCoordinateSystem_CreateStart(CoordinateSystemUserNumber,CoordinateSystem,Err)
179  CALL CMISSCoordinateSystem_TypeSet(CoordinateSystem,CMISS_COORDINATE_RECTANGULAR_CARTESIAN_TYPE,Err)
180  CALL CMISSCoordinateSystem_DimensionSet(CoordinateSystem,NumberOfSpatialCoordinates,Err)
181  CALL CMISSCoordinateSystem_OriginSet(CoordinateSystem,(/0.0_CMISSDP,0.0_CMISSDP,0.0_CMISSDP/),Err)
182  CALL CMISSCoordinateSystem_CreateFinish(CoordinateSystem,Err)
183
184  !Create a region and assign the CS to the region
185  CALL CMISSRegion_Initialise(Region,Err)
186  CALL CMISSRegion_CreateStart(RegionUserNumber,WorldRegion,Region,Err)
187  CALL CMISSRegion_CoordinateSystemSet(Region,CoordinateSystem,Err)
188  CALL CMISSRegion_CreateFinish(Region,Err)
189
190  !Define basis function - tri-linear Lagrange  
191  CALL CMISSBasis_Initialise(Basis,Err)
192  CALL CMISSBasis_CreateStart(BasisUserNumber,Basis,Err) 
193  CALL CMISSBasis_TypeSet(Basis,CMISS_BASIS_LAGRANGE_HERMITE_TP_TYPE,Err)
194  CALL CMISSBasis_NumberOfXiSet(Basis,NumberOfXiCoordinates,Err)
195  CALL CMISSBasis_InterpolationXiSet(Basis,(/CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION, &
196    & CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION,CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION/),Err)
197  CALL CMISSBasis_QuadratureNumberOfGaussXiSet(Basis, &
198    & (/CMISS_BASIS_MID_QUADRATURE_SCHEME,CMISS_BASIS_MID_QUADRATURE_SCHEME,CMISS_BASIS_MID_QUADRATURE_SCHEME/),Err)  
199  CALL CMISSBasis_CreateFinish(Basis,Err)
200
201  !Create a mesh
202  CALL CMISSMesh_Initialise(Mesh,Err)
203  CALL CMISSMesh_CreateStart(MeshUserNumber,Region,NumberOfMeshDimensions,Mesh,Err)    
204
205  CALL CMISSMesh_NumberOfComponentsSet(Mesh,NumberOfMeshComponents,Err) 
206  CALL CMISSMesh_NumberOfElementsSet(Mesh,TotalNumberOfElements,Err)  
207
208  !Define nodes for the mesh
209  CALL CMISSNodes_Initialise(Nodes,Err)
210  CALL CMISSNodes_CreateStart(Region,TotalNumberOfNodes,Nodes,Err)
211  CALL CMISSNodes_CreateFinish(Nodes,Err)
212
213  CALL CMISSMeshElements_Initialise(Elements,Err)
214  CALL CMISSMeshElements_CreateStart(Mesh,MeshComponentNumber,Basis,Elements,Err)
215  CALL CMISSMeshElements_NodesSet(Elements,1,(/1,2,3,4,5,6,7,8/),Err)
216  CALL CMISSMeshElements_CreateFinish(Elements,Err)
217
218  CALL CMISSMesh_CreateFinish(Mesh,Err) 
219
220  !Create a decomposition
221  CALL CMISSDecomposition_Initialise(Decomposition,Err)
222  CALL CMISSDecomposition_CreateStart(DecompositionUserNumber,Mesh,Decomposition,Err)
223  CALL CMISSDecomposition_TypeSet(Decomposition,CMISS_DECOMPOSITION_CALCULATED_TYPE,Err)
224  CALL CMISSDecomposition_NumberOfDomainsSet(Decomposition,NumberOfDomains,Err)
225  CALL CMISSDecomposition_CreateFinish(Decomposition,Err)
226
227  !Create a field to put the geometry (defualt is geometry)
228  CALL CMISSField_Initialise(GeometricField,Err)
229  CALL CMISSField_CreateStart(FieldGeometryUserNumber,Region,GeometricField,Err)
230  CALL CMISSField_MeshDecompositionSet(GeometricField,Decomposition,Err)
231  CALL CMISSField_TypeSet(GeometricField,CMISS_FIELD_GEOMETRIC_TYPE,Err)  
232  CALL CMISSField_NumberOfVariablesSet(GeometricField,FieldGeometryNumberOfVariables,Err)
233  CALL CMISSField_NumberOfComponentsSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,FieldGeometryNumberOfComponents,Err)  
234  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,1,MeshComponentNumber,Err)
235  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,2,MeshComponentNumber,Err)
236  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,3,MeshComponentNumber,Err)
237  CALL CMISSField_VariableLabelSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,"Geometry",Err)
238  CALL CMISSField_CreateFinish(GeometricField,Err)
239
240  !node 1
241  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,1,1, &
242    & 0.0_CMISSDP,Err)
243  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,1,2, &
244    & 0.0_CMISSDP,Err)
245  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,1,3, &
246    & 0.0_CMISSDP,Err)
247  !node 2
248  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,2,1, &
249    & 1.0_CMISSDP,Err)
250  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,2,2, &
251    & 0.0_CMISSDP,Err)
252  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,2,3, &
253    & 0.0_CMISSDP,Err)
254  !node 3
255  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,3,1, &
256    & 0.0_CMISSDP,Err)
257  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,3,2, &
258    & 1.0_CMISSDP,Err)
259  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,3,3, &
260    & 0.0_CMISSDP,Err)
261  !node 4
262  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,4,1, &
263    & 1.0_CMISSDP,Err)
264  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,4,2, &
265    & 1.0_CMISSDP,Err)
266  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,4,3, &
267    & 0.0_CMISSDP,Err)
268  !node 5
269  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,5,1, &
270    & 0.0_CMISSDP,Err)
271  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,5,2, &
272    & 0.0_CMISSDP,Err)
273  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,5,3, &
274    & 1.0_CMISSDP,Err)
275  !node 6
276  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,6,1, &
277    & 1.0_CMISSDP,Err)
278  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,6,2, &
279    & 0.0_CMISSDP,Err)
280  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,6,3, &
281    & 1.0_CMISSDP,Err)
282  !node 7
283  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,7,1, &
284    & 0.0_CMISSDP,Err)
285  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,7,2, &
286    & 1.0_CMISSDP,Err)
287  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,7,3, &
288    & 1.0_CMISSDP,Err)
289  !node 8
290  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,8,1, &
291    & 1.0_CMISSDP,Err)
292  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,8,2, &
293    & 1.0_CMISSDP,Err)
294  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,8,3, &
295    & 1.0_CMISSDP,Err)
296
297  !Create a fibre field and attach it to the geometric field  
298  CALL CMISSField_Initialise(FibreField,Err)
299  CALL CMISSField_CreateStart(FieldFibreUserNumber,Region,FibreField,Err)
300  CALL CMISSField_TypeSet(FibreField,CMISS_FIELD_FIBRE_TYPE,Err)
301  CALL CMISSField_MeshDecompositionSet(FibreField,Decomposition,Err)        
302  CALL CMISSField_GeometricFieldSet(FibreField,GeometricField,Err)
303  CALL CMISSField_NumberOfVariablesSet(FibreField,FieldFibreNumberOfVariables,Err)
304  CALL CMISSField_NumberOfComponentsSet(FibreField,CMISS_FIELD_U_VARIABLE_TYPE,FieldFibreNumberOfComponents,Err)  
305  CALL CMISSField_ComponentMeshComponentSet(FibreField,CMISS_FIELD_U_VARIABLE_TYPE,1,MeshComponentNumber,Err)
306  CALL CMISSField_ComponentMeshComponentSet(FibreField,CMISS_FIELD_U_VARIABLE_TYPE,2,MeshComponentNumber,Err)
307  CALL CMISSField_ComponentMeshComponentSet(FibreField,CMISS_FIELD_U_VARIABLE_TYPE,3,MeshComponentNumber,Err)
308  CALL CMISSField_VariableLabelSet(FibreField,CMISS_FIELD_U_VARIABLE_TYPE,"Fibre",Err)
309  CALL CMISSField_CreateFinish(FibreField,Err)
310
311  !Create a material field and attach it to the geometric field  
312  CALL CMISSField_Initialise(MaterialField,Err)
313  CALL CMISSField_CreateStart(FieldMaterialUserNumber,Region,MaterialField,Err)
314  CALL CMISSField_TypeSet(MaterialField,CMISS_FIELD_MATERIAL_TYPE,Err)
315  CALL CMISSField_MeshDecompositionSet(MaterialField,Decomposition,Err)        
316  CALL CMISSField_GeometricFieldSet(MaterialField,GeometricField,Err)
317  CALL CMISSField_NumberOfVariablesSet(MaterialField,FieldMaterialNumberOfVariables,Err)
318  CALL CMISSField_NumberOfComponentsSet(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,FieldMaterialNumberOfComponents,Err)  
319  CALL CMISSField_ComponentMeshComponentSet(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,1,MeshComponentNumber,Err)
320  CALL CMISSField_ComponentMeshComponentSet(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,2,MeshComponentNumber,Err)
321  CALL CMISSField_VariableLabelSet(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,"Material",Err)
322  CALL CMISSField_CreateFinish(MaterialField,Err)
323
324  !Set Mooney-Rivlin constants c10 and c01 to 2.0 and 6.0 respectively.
325  CALL CMISSField_ComponentValuesInitialise(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,2.0_CMISSDP,Err)
326  CALL CMISSField_ComponentValuesInitialise(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,2,6.0_CMISSDP,Err)
327
328  !Create a dependent field with two variables and four components
329  CALL CMISSField_Initialise(DependentField,Err)
330  CALL CMISSField_CreateStart(FieldDependentUserNumber,Region,DependentField,Err)
331  CALL CMISSField_TypeSet(DependentField,CMISS_FIELD_GENERAL_TYPE,Err)  
332  CALL CMISSField_MeshDecompositionSet(DependentField,Decomposition,Err)
333  CALL CMISSField_GeometricFieldSet(DependentField,GeometricField,Err) 
334  CALL CMISSField_DependentTypeSet(DependentField,CMISS_FIELD_DEPENDENT_TYPE,Err) 
335  CALL CMISSField_NumberOfVariablesSet(DependentField,FieldDependentNumberOfVariables,Err)
336  CALL CMISSField_NumberOfComponentsSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,FieldDependentNumberOfComponents,Err)
337  CALL CMISSField_NumberOfComponentsSet(DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,FieldDependentNumberOfComponents,Err)
338  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,MeshComponentNumber,Err)
339  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,2,MeshComponentNumber,Err)
340  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,3,MeshComponentNumber,Err)  
341  CALL CMISSField_ComponentInterpolationSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,4,CMISS_FIELD_ELEMENT_BASED_INTERPOLATION, &
342    & Err)
343  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,1,MeshComponentNumber,Err)
344  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,2,MeshComponentNumber,Err)
345  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,3,MeshComponentNumber,Err)  
346  CALL CMISSField_ComponentInterpolationSet(DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,4, &
347    & CMISS_FIELD_ELEMENT_BASED_INTERPOLATION,Err)
348  CALL CMISSField_VariableLabelSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,"Dependent",Err)
349  CALL CMISSField_CreateFinish(DependentField,Err)  
350
351  !Create the equations_set
352  CALL CMISSField_Initialise(EquationsSetField,Err)
353  CALL CMISSEquationsSet_Initialise(EquationsSet,Err)
354  CALL CMISSEquationsSet_CreateStart(EquationSetUserNumber,Region,FibreField,CMISS_EQUATIONS_SET_ELASTICITY_CLASS, &
355    & CMISS_EQUATIONS_SET_FINITE_ELASTICITY_TYPE,CMISS_EQUATIONS_SET_NO_SUBTYPE,EquationsSetFieldUserNumber,EquationsSetField,&
356    & EquationsSet,Err)
357  CALL CMISSEquationsSet_CreateFinish(EquationsSet,Err)
358
359  CALL CMISSEquationsSet_DependentCreateStart(EquationsSet,FieldDependentUserNumber,DependentField,Err) 
360  CALL CMISSEquationsSet_DependentCreateFinish(EquationsSet,Err)
361
362  CALL CMISSEquationsSet_MaterialsCreateStart(EquationsSet,FieldMaterialUserNumber,MaterialField,Err)  
363  CALL CMISSEquationsSet_MaterialsCreateFinish(EquationsSet,Err)
364
365  !Create the equations set equations
366  CALL CMISSEquations_Initialise(Equations,Err)
367  CALL CMISSEquationsSet_EquationsCreateStart(EquationsSet,Equations,Err)
368  CALL CMISSEquations_SparsityTypeSet(Equations,CMISS_EQUATIONS_SPARSE_MATRICES,Err)
369  CALL CMISSEquations_OutputTypeSet(Equations,CMISS_EQUATIONS_NO_OUTPUT,Err)
370  CALL CMISSEquationsSet_EquationsCreateFinish(EquationsSet,Err)   
371
372  !Initialise dependent field from undeformed geometry and displacement bcs and set hydrostatic pressure
373  CALL CMISSField_ParametersToFieldParametersComponentCopy(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, &
374    & 1,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,Err)
375  CALL CMISSField_ParametersToFieldParametersComponentCopy(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, &
376    & 2,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,2,Err)
377  CALL CMISSField_ParametersToFieldParametersComponentCopy(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE, &
378    & 3,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,3,Err)
379  CALL CMISSField_ComponentValuesInitialise(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,4,-8.0_CMISSDP, &
380    & Err)
381
382  !Define the problem
383  CALL CMISSProblem_Initialise(Problem,Err)
384  CALL CMISSProblem_CreateStart(ProblemUserNumber,Problem,Err)
385  CALL CMISSProblem_SpecificationSet(Problem,CMISS_PROBLEM_ELASTICITY_CLASS,CMISS_PROBLEM_FINITE_ELASTICITY_TYPE, &
386    & CMISS_PROBLEM_NO_SUBTYPE,Err)
387  CALL CMISSProblem_CreateFinish(Problem,Err)
388
389  !Create the problem control loop
390  CALL CMISSProblem_ControlLoopCreateStart(Problem,Err)
391  CALL CMISSProblem_ControlLoopCreateFinish(Problem,Err)
392
393  !Create the problem solvers
394  CALL CMISSSolver_Initialise(Solver,Err)
395  CALL CMISSSolver_Initialise(LinearSolver,Err)
396  CALL CMISSProblem_SolversCreateStart(Problem,Err)
397  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,1,Solver,Err)
398  CALL CMISSSolver_OutputTypeSet(Solver,CMISS_SOLVER_PROGRESS_OUTPUT,Err)
399  CALL CMISSSolver_NewtonJacobianCalculationTypeSet(Solver,CMISS_SOLVER_NEWTON_JACOBIAN_FD_CALCULATED,Err)
400  CALL CMISSSolver_NewtonLinearSolverGet(Solver,LinearSolver,Err)
401  CALL CMISSSolver_LinearTypeSet(LinearSolver,CMISS_SOLVER_LINEAR_DIRECT_SOLVE_TYPE,Err)
402  CALL CMISSProblem_SolversCreateFinish(Problem,Err)
403
404  !Create the problem solver equations
405  CALL CMISSSolver_Initialise(Solver,Err)
406  CALL CMISSSolverEquations_Initialise(SolverEquations,Err)
407  CALL CMISSProblem_SolverEquationsCreateStart(Problem,Err)   
408  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,1,Solver,Err)
409  CALL CMISSSolver_SolverEquationsGet(Solver,SolverEquations,Err)
410  CALL CMISSSolverEquations_SparsityTypeSet(SolverEquations,CMISS_SOLVER_SPARSE_MATRICES,Err)
411  CALL CMISSSolverEquations_EquationsSetAdd(SolverEquations,EquationsSet,EquationsSetIndex,Err)
412  CALL CMISSProblem_SolverEquationsCreateFinish(Problem,Err)
413
414  !Prescribe boundary conditions (absolute nodal parameters)
415  CALL CMISSBoundaryConditions_Initialise(BoundaryConditions,Err)
416  CALL CMISSSolverEquations_BoundaryConditionsCreateStart(SolverEquations,BoundaryConditions,Err)
417
418  !Fix nodes 1,3,5,7 at x=0 and nodes 2,4,6,8 at x=1.1
419  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,1,1, &
420    & CMISS_BOUNDARY_CONDITION_FIXED, &
421    & 0.0_CMISSDP,Err)
422  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,2,1, &
423    & CMISS_BOUNDARY_CONDITION_FIXED, &
424    & 1.1_CMISSDP,Err)
425  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,3,1, &
426    & CMISS_BOUNDARY_CONDITION_FIXED, &
427    & 0.0_CMISSDP,Err)
428  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,4,1, &
429    & CMISS_BOUNDARY_CONDITION_FIXED, &
430    & 1.1_CMISSDP,Err)
431  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,5,1, &
432    & CMISS_BOUNDARY_CONDITION_FIXED, &
433    & 0.0_CMISSDP,Err)
434  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,6,1, &
435    & CMISS_BOUNDARY_CONDITION_FIXED, &
436    & 1.1_CMISSDP,Err)
437  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,7,1, &
438    & CMISS_BOUNDARY_CONDITION_FIXED, &
439    & 0.0_CMISSDP,Err)
440  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,8,1, &
441    & CMISS_BOUNDARY_CONDITION_FIXED, &
442    & 1.1_CMISSDP,Err)
443
444  !Fix nodes 1,2,5,6 at y=0
445  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,1,2, &
446    & CMISS_BOUNDARY_CONDITION_FIXED, &
447    & 0.0_CMISSDP,Err)
448  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,2,2, &
449    & CMISS_BOUNDARY_CONDITION_FIXED, &
450    & 0.0_CMISSDP,Err)
451  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,5,2, &
452    & CMISS_BOUNDARY_CONDITION_FIXED, &
453    & 0.0_CMISSDP,Err)
454  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,6,2, &
455    & CMISS_BOUNDARY_CONDITION_FIXED, &
456    & 0.0_CMISSDP,Err)
457
458  !Fix nodes 1,2,3,4 at x=0
459  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,1,3, &
460    & CMISS_BOUNDARY_CONDITION_FIXED, &
461    & 0.0_CMISSDP,Err)
462  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,2,3, &
463    & CMISS_BOUNDARY_CONDITION_FIXED, &
464    & 0.0_CMISSDP,Err)
465  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,3,3, &
466    & CMISS_BOUNDARY_CONDITION_FIXED, &
467    & 0.0_CMISSDP,Err)
468  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,4,3, &
469    & CMISS_BOUNDARY_CONDITION_FIXED, &
470    & 0.0_CMISSDP,Err)
471
472  CALL CMISSSolverEquations_BoundaryConditionsCreateFinish(SolverEquations,Err)
473
474  !Solve problem
475  CALL CMISSProblem_Solve(Problem,Err)
476
477  !Output solution  
478  CALL CMISSFields_Initialise(Fields,Err)
479  CALL CMISSFields_Create(Region,Fields,Err)
480  CALL CMISSFields_NodesExport(Fields,"UniaxialExtension","FORTRAN",Err)
481  CALL CMISSFields_ElementsExport(Fields,"UniaxialExtension","FORTRAN",Err)
482  CALL CMISSFields_Finalise(Fields,Err)
483
484  CALL CMISSFinalise(Err)
485
486  WRITE(*,'(A)') "Program successfully completed."
487
488  STOP
489
490END PROGRAM UNIAXIALEXTENSIONEXAMPLE
491