PageRenderTime 58ms CodeModel.GetById 30ms app.highlight 24ms RepoModel.GetById 1ms app.codeStats 0ms

/LinearElasticity/2DExtensionPlaneStressLagrangeBasis/src/2DExtensionPlaneStressLagrangeBasisExample.f90

http://github.com/xyan075/examples
FORTRAN Modern | 442 lines | 269 code | 71 blank | 102 comment | 0 complexity | 4f863b5a5b68ef38f3a54878e3da4370 MD5 | raw file
  1! \file
  2!> \author Chris Bradley
  3!> \brief This is an example program to solve a linear 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):
 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 LinearElasticity/src/LinearElasticityExample.f90
 43!! Example program to solve a linear elasticity equation using openCMISS calls.
 44!<
 45
 46!> Main program
 47PROGRAM LinearElasticity2DExtensionPlaneStressLagrangeBasis
 48
 49  USE MPI
 50  USE OPENCMISS
 51
 52#ifdef WIN32
 53  USE IFQWIN
 54#endif
 55
 56  IMPLICIT NONE
 57
 58  !Test program parameters
 59
 60  REAL(CMISSDP), PARAMETER :: ORIGIN(3)=(/0.0_CMISSDP,0.0_CMISSDP,0.0_CMISSDP/)
 61  REAL(CMISSDP), PARAMETER :: LENGTH=120.0_CMISSDP
 62  REAL(CMISSDP), PARAMETER :: WIDTH=160.0_CMISSDP
 63
 64  INTEGER(CMISSIntg), PARAMETER :: CoordinateSystemUserNumber=1
 65  INTEGER(CMISSIntg), PARAMETER :: NumberOfSpatialCoordinates=2
 66  INTEGER(CMISSIntg), PARAMETER :: RegionUserNumber=1
 67  INTEGER(CMISSIntg), PARAMETER :: Basis1UserNumber=1
 68  INTEGER(CMISSIntg), PARAMETER :: Basis2UserNumber=2
 69  INTEGER(CMISSIntg), PARAMETER :: MeshUserNumber=1
 70  INTEGER(CMISSIntg), PARAMETER :: DecompositionUserNumber=1
 71
 72  INTEGER(CMISSIntg), PARAMETER :: NumberOfXiCoordinates=2
 73  INTEGER(CMISSIntg), PARAMETER :: TotalNumberOfNodes=4
 74  INTEGER(CMISSIntg), PARAMETER :: NumberOfMeshDimensions=2
 75  INTEGER(CMISSIntg), PARAMETER :: NumberOfMeshComponents=2
 76  INTEGER(CMISSIntg), PARAMETER :: TotalNumberOfElements=1
 77  INTEGER(CMISSIntg), PARAMETER :: MeshComponent1UserNumber=1
 78  INTEGER(CMISSIntg), PARAMETER :: MeshComponent2UserNumber=2
 79
 80  INTEGER(CMISSIntg), PARAMETER :: FieldGeometryUserNumber=1
 81  INTEGER(CMISSIntg), PARAMETER :: FieldGeometryNumberOfVariables=1
 82  INTEGER(CMISSIntg), PARAMETER :: FieldGeometryNumberOfComponents=2
 83
 84  INTEGER(CMISSIntg), PARAMETER :: FieldDependentUserNumber=2
 85  INTEGER(CMISSIntg), PARAMETER :: FieldDependentNumberOfVariables=2
 86  INTEGER(CMISSIntg), PARAMETER :: FieldDependentNumberOfComponents=2
 87
 88  INTEGER(CMISSIntg), PARAMETER :: FieldMaterialUserNumber=3
 89  INTEGER(CMISSIntg), PARAMETER :: FieldMaterialNumberOfVariables=1
 90  INTEGER(CMISSIntg), PARAMETER :: FieldMaterialNumberOfComponents=3
 91
 92  INTEGER(CMISSIntg), PARAMETER :: EquationSetUserNumber=1
 93  INTEGER(CMISSIntg), PARAMETER :: EquationsSetFieldUserNumber=4
 94
 95  INTEGER(CMISSIntg), PARAMETER :: ProblemUserNumber=1
 96
 97  REAL(CMISSDP), PARAMETER ::   ZERO = 0.0_CMISSDP
 98
 99  !Program types
100
101
102  !Program variables
103
104  INTEGER(CMISSIntg) :: NumberGlobalXElements,NumberGlobalYElements
105  INTEGER(CMISSIntg) :: MPI_IERROR
106  INTEGER(CMISSIntg) :: EquationsSetIndex  
107  INTEGER(CMISSIntg) :: NumberOfComputationalNodes,NumberOfDomains,ComputationalNodeNumber
108  INTEGER(CMISSIntg) :: node_idx,component_idx
109  REAL(CMISSDP) :: Value1,Value2
110  LOGICAL :: EXPORT_FIELD
111
112  !CMISS variables
113
114  TYPE(CMISSRegionType) :: WorldRegion
115  TYPE(CMISSCoordinateSystemType) :: WorldCoordinateSystem
116  TYPE(CMISSBasisType) :: Basis(2)
117  TYPE(CMISSBoundaryConditionsType) :: BoundaryConditions
118  TYPE(CMISSCoordinateSystemType) :: CoordinateSystem
119  TYPE(CMISSDecompositionType) :: Decomposition
120  TYPE(CMISSEquationsType) :: Equations
121  TYPE(CMISSEquationsSetType) :: EquationsSet
122  TYPE(CMISSFieldType) :: GeometricField,DependentField,MaterialField
123  TYPE(CMISSFieldsType) :: Fields
124  TYPE(CMISSMeshType) :: Mesh
125  TYPE(CMISSNodesType) :: Nodes
126  TYPE(CMISSProblemType) :: Problem
127  TYPE(CMISSRegionType) :: Region
128  TYPE(CMISSFieldType) :: EquationsSetField
129  TYPE(CMISSSolverType) :: Solver
130  TYPE(CMISSSolverEquationsType) :: SolverEquations
131  TYPE(CMISSMeshElementsType) :: Elements(2)
132
133#ifdef WIN32
134  !Quickwin type
135  LOGICAL :: QUICKWIN_STATUS=.FALSE.
136  TYPE(WINDOWCONFIG) :: QUICKWIN_WINDOW_CONFIG
137#endif
138
139  !Generic CMISS variables
140  INTEGER(CMISSIntg) :: Err
141
142#ifdef WIN32
143  !Initialise QuickWin
144  QUICKWIN_WINDOW_CONFIG%TITLE="General Output" !Window title
145  QUICKWIN_WINDOW_CONFIG%NUMTEXTROWS=-1 !Max possible number of rows
146  QUICKWIN_WINDOW_CONFIG%MODE=QWIN$SCROLLDOWN
147  !Set the window parameters
148  QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
149  !If attempt fails set with system estimated values
150  IF(.NOT.QUICKWIN_STATUS) QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
151#endif
152
153  !Intialise cmiss
154  CALL CMISSInitialise(WorldCoordinateSystem,WorldRegion,Err)
155
156  CALL CMISSErrorHandlingModeSet(CMISS_ERRORS_TRAP_ERROR,Err)
157
158  WRITE(*,'(A)') "Program starting."
159
160  !Set all diganostic levels on for testing
161  CALL CMISSDiagnosticsSetOn(CMISS_FROM_DIAG_TYPE,(/1,2,3,4,5/),"Diagnostics",(/"PROBLEM_FINITE_ELEMENT_CALCULATE"/),Err)
162
163  !Get the number of computational nodes and this computational node number
164  CALL CMISSComputationalNumberOfNodesGet(NumberOfComputationalNodes,Err)
165  CALL CMISSComputationalNodeNumberGet(ComputationalNodeNumber,Err)
166
167  NumberGlobalXElements=1
168  NumberGlobalYElements=1
169  NumberOfDomains=1
170
171  !Broadcast the number of elements in the X,Y and Z directions and the number of partitions to the other computational nodes
172  CALL MPI_BCAST(NumberGlobalXElements,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
173  CALL MPI_BCAST(NumberGlobalYElements,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,(ORIGIN),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 2 sets of basis functions, one describing each independent coordinate specified by InterpolationType
191  !NOTE if you change interpolation you need to change Boundary Conditions
192  !NOTE:: Num of Gauss points must be the same across X,Y & Z coordinates and be sufficient to accurately integrate the hightest order interpolation being used
193
194  CALL CMISSBasis_Initialise(Basis(1),Err)
195  CALL CMISSBasis_CreateStart(Basis1UserNumber,Basis(1),Err)
196  CALL CMISSBasis_TypeSet(Basis(1),CMISS_BASIS_LAGRANGE_HERMITE_TP_TYPE,Err)
197  CALL CMISSBasis_NumberOfXiSet(Basis(1),NumberOfXiCoordinates,Err)
198  CALL CMISSBasis_InterpolationXiSet(Basis(1),(/CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION, &
199    & CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION/), &
200    & Err)
201  CALL CMISSBasis_QuadratureNumberOfGaussXiSet(Basis(1),(/CMISS_BASIS_MID_QUADRATURE_SCHEME,CMISS_BASIS_MID_QUADRATURE_SCHEME/),Err)
202  CALL CMISSBasis_CreateFinish(Basis(1),Err)
203
204  CALL CMISSBasis_Initialise(Basis(2),Err)
205  CALL CMISSBasis_CreateStart(Basis2UserNumber,Basis(2),Err)
206  CALL CMISSBasis_TypeSet(Basis(2),CMISS_BASIS_LAGRANGE_HERMITE_TP_TYPE,Err)
207  CALL CMISSBasis_NumberOfXiSet(Basis(2),NumberOfXiCoordinates,Err)
208  CALL CMISSBasis_InterpolationXiSet(Basis(2),(/CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION, &
209    & CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION/), &
210    & Err)
211  CALL CMISSBasis_QuadratureNumberOfGaussXiSet(Basis(2),(/CMISS_BASIS_MID_QUADRATURE_SCHEME,CMISS_BASIS_MID_QUADRATURE_SCHEME/),Err)
212  CALL CMISSBasis_CreateFinish(Basis(2),Err)
213
214  !Create a mesh
215  CALL CMISSMesh_Initialise(Mesh,Err)
216  CALL CMISSMesh_CreateStart(MeshUserNumber,Region,NumberOfMeshDimensions,Mesh,Err)
217
218  CALL CMISSMesh_NumberOfComponentsSet(Mesh,NumberOfMeshComponents,Err)
219  CALL CMISSMesh_NumberOfElementsSet(Mesh,TotalNumberOfElements,Err)
220
221  !Define nodes for the mesh
222  CALL CMISSNodes_Initialise(Nodes,Err)
223  CALL CMISSNodes_CreateStart(Region,TotalNumberOfNodes,Nodes,Err)
224  CALL CMISSNodes_CreateFinish(Nodes,Err)
225
226  !Create elements for the mesh
227  !Mesh Component 1
228  CALL CMISSMeshElements_Initialise(Elements(1),Err)
229  CALL CMISSMeshElements_CreateStart(Mesh,MeshComponent1UserNumber,Basis(1),Elements(1),Err)
230  CALL CMISSMeshElements_NodesSet(Elements(1),1,(/1,2,3,4/),Err)
231  CALL CMISSMeshElements_CreateFinish(Elements(1),Err)
232  !Mesh Component 2
233  CALL CMISSMeshElements_Initialise(Elements(2),Err)
234  CALL CMISSMeshElements_CreateStart(Mesh,MeshComponent2UserNumber,Basis(2),Elements(2),Err)
235  CALL CMISSMeshElements_NodesSet(Elements(2),1,(/1,2,3,4/),Err)
236  CALL CMISSMeshElements_CreateFinish(Elements(2),Err)
237
238  CALL CMISSMesh_CreateFinish(Mesh,Err) 
239
240  !Create a decomposition
241  CALL CMISSDecomposition_Initialise(Decomposition,Err)
242  CALL CMISSDecomposition_CreateStart(DecompositionUserNumber,Mesh,Decomposition,Err)
243  CALL CMISSDecomposition_TypeSet(Decomposition,CMISS_DECOMPOSITION_CALCULATED_TYPE,Err)
244  CALL CMISSDecomposition_NumberOfDomainsSet(Decomposition,NumberOfDomains,Err)
245  CALL CMISSDecomposition_CreateFinish(Decomposition,Err)
246
247  !Create a field to put the geometry (defualt is geometry)
248  CALL CMISSField_Initialise(GeometricField,Err)
249  CALL CMISSField_CreateStart(FieldGeometryUserNumber,Region,GeometricField,Err)
250  CALL CMISSField_MeshDecompositionSet(GeometricField,Decomposition,Err)
251  CALL CMISSField_TypeSet(GeometricField,CMISS_FIELD_GEOMETRIC_TYPE,Err)  
252  CALL CMISSField_NumberOfVariablesSet(GeometricField,FieldGeometryNumberOfVariables,Err)
253  CALL CMISSField_VariableLabelSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,"Geometry",Err)
254  CALL CMISSField_NumberOfComponentsSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,FieldGeometryNumberOfComponents,Err)  
255  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,Err)
256  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,2,2,Err)
257  CALL CMISSField_CreateFinish(GeometricField,Err)
258
259  !Set geometric node coordinates (x)
260  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,1,1, &
261    & 0.0_CMISSDP,Err)
262  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,2,1,LENGTH,Err)
263  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,3,1, &
264    & 0.0_CMISSDP,Err)
265  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,4,1,LENGTH,Err)
266
267  !Set geometric node coordinates (y)
268  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,1,2, &
269    & 0.0_CMISSDP,Err)
270  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,2,2, &
271    & 0.0_CMISSDP,Err)
272  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,3,2,WIDTH,Err)
273  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,4,2,WIDTH,Err)
274
275  !Create a dependent field with two variables and three components
276  CALL CMISSField_Initialise(DependentField,Err)
277  CALL CMISSField_CreateStart(FieldDependentUserNumber,Region,DependentField,Err)
278  CALL CMISSField_TypeSet(DependentField,CMISS_FIELD_GENERAL_TYPE,Err)  
279  CALL CMISSField_MeshDecompositionSet(DependentField,Decomposition,Err)
280  CALL CMISSField_GeometricFieldSet(DependentField,GeometricField,Err) 
281  CALL CMISSField_DependentTypeSet(DependentField,CMISS_FIELD_DEPENDENT_TYPE,Err) 
282  CALL CMISSField_NumberOfVariablesSet(DependentField,FieldDependentNumberOfVariables,Err)
283  CALL CMISSField_VariableLabelSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,"Dependent",Err)
284  CALL CMISSField_NumberOfComponentsSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,FieldDependentNumberOfComponents,Err)
285  CALL CMISSField_NumberOfComponentsSet(DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,FieldDependentNumberOfComponents,Err)
286  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,Err)
287  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,2,2,Err)
288  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,1,1,Err)
289  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,2,2,Err)
290  CALL CMISSField_CreateFinish(DependentField,Err)
291
292  !Create a material field and attach it to the geometric field  
293  CALL CMISSField_Initialise(MaterialField,Err)
294  CALL CMISSField_CreateStart(FieldMaterialUserNumber,Region,MaterialField,Err)
295  CALL CMISSField_TypeSet(MaterialField,CMISS_FIELD_MATERIAL_TYPE,Err)
296  CALL CMISSField_MeshDecompositionSet(MaterialField,Decomposition,Err)
297  CALL CMISSField_GeometricFieldSet(MaterialField,GeometricField,Err)
298  CALL CMISSField_NumberOfVariablesSet(MaterialField,FieldMaterialNumberOfVariables,Err)
299  CALL CMISSField_VariableLabelSet(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,"Material",Err)
300  CALL CMISSField_NumberOfComponentsSet(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,FieldMaterialNumberOfComponents,Err)  
301  CALL CMISSField_ComponentMeshComponentSet(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,Err)
302  CALL CMISSField_ComponentMeshComponentSet(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,2,2,Err)
303  CALL CMISSField_CreateFinish(MaterialField,Err)
304
305  !Set isotropic elasticity material parameters - Young's Modulus & Poisson's Ratio, thickness
306  CALL CMISSField_ComponentValuesInitialise(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,0.036_CMISSDP, &
307    & Err) !thickness
308  CALL CMISSField_ComponentValuesInitialise(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,2,30E6_CMISSDP, &
309    & Err) !E
310  CALL CMISSField_ComponentValuesInitialise(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,3,0.25_CMISSDP, &
311    & Err) !v
312
313
314  !Create a Elasticity Class, Linear Elasticity type, no subtype, EquationsSet
315  CALL CMISSEquationsSet_Initialise(EquationsSet,Err)
316  CALL CMISSField_Initialise(EquationsSetField,Err)
317  CALL CMISSEquationsSet_CreateStart(EquationSetUserNumber,Region,GeometricField,CMISS_EQUATIONS_SET_ELASTICITY_CLASS, &
318    & CMISS_EQUATIONS_SET_LINEAR_ELASTICITY_TYPE,CMISS_EQUATIONS_SET_TWO_DIMENSIONAL_PLANE_STRESS_SUBTYPE, &
319      & EquationsSetFieldUserNumber,EquationsSetField, &
320    & EquationsSet,Err)
321  
322  CALL CMISSEquationsSet_CreateFinish(EquationsSet,Err)
323
324  CALL CMISSEquationsSet_DependentCreateStart(EquationsSet,FieldDependentUserNumber,DependentField,Err) 
325  CALL CMISSEquationsSet_DependentCreateFinish(EquationsSet,Err)
326
327  CALL CMISSEquationsSet_MaterialsCreateStart(EquationsSet,FieldMaterialUserNumber,MaterialField,Err)  
328  CALL CMISSEquationsSet_MaterialsCreateFinish(EquationsSet,Err)
329
330  !Create the equations set equations
331  CALL CMISSEquations_Initialise(Equations,Err)
332  CALL CMISSEquationsSet_EquationsCreateStart(EquationsSet,Equations,Err)
333  CALL CMISSEquations_SparsityTypeSet(EQUATIONS,CMISS_EQUATIONS_SPARSE_MATRICES,Err)
334                                              !CMISS_EQUATIONS_SPARSE_MATRICES=1 !<Use sparse matrices for the equations.
335                                              !CMISS_EQUATIONS_FULL_MATRICES=2 !<Use fully populated matrices for the equations. 
336  CALL CMISSEquations_OutputTypeSet(EQUATIONS,CMISS_EQUATIONS_ELEMENT_MATRIX_OUTPUT,Err)
337                                            !CMISS_EQUATIONS_NO_OUTPUT !<No output from the equations.
338                                            !CMISS_EQUATIONS_TIMING_OUTPUT !<Timing information output.
339                                            !CMISS_EQUATIONS_MATRIX_OUTPUT !<All below and equation matrices output.
340                                            !CMISS_EQUATIONS_ELEMENT_MATRIX_OUTPUT !<All below and Element matrices output.
341  CALL CMISSEquationsSet_EquationsCreateFinish(EquationsSet,Err)
342  
343  !Define the problem
344  CALL CMISSProblem_Initialise(Problem,Err)
345  CALL CMISSProblem_CreateStart(ProblemUserNumber,Problem,Err)
346  CALL CMISSProblem_SpecificationSet(Problem,CMISS_PROBLEM_ELASTICITY_CLASS,CMISS_PROBLEM_LINEAR_ELASTICITY_TYPE, &
347    & CMISS_PROBLEM_NO_SUBTYPE,Err)
348  CALL CMISSProblem_CreateFinish(Problem,Err)
349
350  !Create the problem control loop
351  CALL CMISSProblem_ControlLoopCreateStart(Problem,Err)
352  CALL CMISSProblem_ControlLoopCreateFinish(Problem,Err)
353
354  !Start the creation of the Problem solvers
355  !Create the problem solvers
356  CALL CMISSSolver_Initialise(Solver,Err)
357  CALL CMISSProblem_SolversCreateStart(Problem,Err)
358  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,1,Solver,Err)
359  CALL CMISSSolver_OutputTypeSet(SOLVER,CMISS_SOLVER_MATRIX_OUTPUT,Err)
360                                      !CMISS_SOLVER_NO_OUTPUT !<No output from the solver routines. \see OPENCMISS_SolverOutputTypes,OPENCMISS
361                                      !CMISS_SOLVER_PROGRESS_OUTPUT !<Progress output from solver routines.
362                                      !CMISS_SOLVER_TIMING_OUTPUT !<Timing output from the solver routines plus below.
363                                      !CMISS_SOLVER_SOLVER_OUTPUT !<Solver specific output from the solver routines plus below.
364                                      !CMISS_SOLVER_MATRIX_OUTPUT !<Solver matrices output from the solver routines plus below.
365  CALL CMISSSolver_LibraryTypeSet(SOLVER,CMISS_SOLVER_PETSC_LIBRARY,Err)
366  CALL CMISSSolver_LinearTypeSet(SOLVER,CMISS_SOLVER_LINEAR_DIRECT_SOLVE_TYPE,Err)
367                                      !CMISS_SOLVER_LINEAR_DIRECT_SOLVE_TYPE    !<Direct linear solver type.
368                                      !CMISS_SOLVER_LINEAR_ITERATIVE_SOLVE_TYPE !<Iterative linear solver type.
369  CALL CMISSProblem_SolversCreateFinish(Problem,Err)
370
371  !Create the problem solver equations
372  CALL CMISSSolver_Initialise(Solver,Err)
373  CALL CMISSSolverEquations_Initialise(SolverEquations,Err)
374  CALL CMISSProblem_SolverEquationsCreateStart(Problem,Err)   
375  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,1,Solver,Err)
376  CALL CMISSSolver_SolverEquationsGet(Solver,SolverEquations,Err)
377  CALL CMISSSolverEquations_SparsityTypeSet(SolverEquations,CMISS_SOLVER_SPARSE_MATRICES,Err)
378                                                          !CMISS_SOLVER_SPARSE_MATRICES !<Use sparse solver matrices.
379                                                          !CMISS_SOLVER_FULL_MATRICES !<Use fully populated solver matrices.
380  CALL CMISSSolverEquations_EquationsSetAdd(SolverEquations,EquationsSet,EquationsSetIndex,Err)
381  CALL CMISSProblem_SolverEquationsCreateFinish(Problem,Err)
382
383  !Prescribe boundary conditions
384  CALL CMISSBoundaryConditions_Initialise(BoundaryConditions,Err)
385  CALL CMISSSolverEquations_BoundaryConditionsCreateStart(SolverEquations,BoundaryConditions,Err)
386
387  !Fix nodes 1,3 at x=0
388  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,1,1, &
389    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
390  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,3,1, &
391    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
392
393  !Fix nodes 1,2 at y=0
394  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,1,2, &
395    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
396  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,2,2, &
397    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
398
399  !Apply force at nodes 2,4 at x=l
400  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,1,1,2,1, &
401    & CMISS_BOUNDARY_CONDITION_FIXED, &
402    & -800.0_CMISSDP,Err)
403  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,1,1,4,1, &
404    & CMISS_BOUNDARY_CONDITION_FIXED, &
405    & -800.0_CMISSDP,Err)
406
407  CALL CMISSSolverEquations_BoundaryConditionsCreateFinish(SolverEquations,Err)
408
409  !=SOLVE Problem==================================================================================================================
410  !Solve the Problem
411  CALL CMISSProblem_Solve(Problem,Err)
412
413  !Add dependent field to geometric field
414  DO node_idx=1,TotalNumberOfNodes
415    DO component_idx=1,FieldGeometryNumberOfComponents
416      CALL CMISSField_ParameterSetGetNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,node_idx, &
417        & component_idx,Value1,Err)
418      CALL CMISSField_ParameterSetGetNode(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,node_idx, &
419        & component_idx,Value2,Err)
420      CALL CMISSField_ParameterSetAddNode(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,node_idx, &
421        & component_idx,Value1+Value2,Err)
422    ENDDO
423  ENDDO
424
425  !=OUTPUT SOLUTION================================================================================================================
426  EXPORT_FIELD=.TRUE.
427  IF(EXPORT_FIELD) THEN
428    CALL CMISSFields_Initialise(Fields,Err)
429    CALL CMISSFields_Create(Region,Fields,Err)
430    CALL CMISSFields_NodesExport(Fields,"LinearElasticity2DExtensionPlaneStressLagrangeBasisExample","FORTRAN",Err)
431    CALL CMISSFields_ElementsExport(Fields,"LinearElasticity2DExtensionPlaneStressLagrangeBasisExample","FORTRAN",Err)
432    CALL CMISSFields_Finalise(Fields,Err)
433  ENDIF
434  CALL CMISSFinalise(Err)
435
436  WRITE(*,'(A)') "Program successfully completed."
437  
438  STOP
439
440END PROGRAM LinearElasticity2DExtensionPlaneStressLagrangeBasis
441
442