PageRenderTime 90ms CodeModel.GetById 34ms app.highlight 49ms RepoModel.GetById 1ms app.codeStats 1ms

/LinearElasticity/3DExtensionLagrangeBasis/src/3DExtensionLagrangeBasisExample.f90

http://github.com/xyan075/examples
FORTRAN Modern | 518 lines | 329 code | 73 blank | 116 comment | 0 complexity | 6aa9d51076fe508c4f69f9c9d8c2e8f0 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 LinearElasticity3DLagrangeBasis
 48
 49  USE MPI
 50  USE OPENCMISS
 51
 52#ifdef WIN32
 53  USE IFQWIN
 54#endif
 55
 56  IMPLICIT NONE
 57
 58  INTEGER(CMISSIntg), PARAMETER :: EquationsSetFieldUserNumber=1337
 59  TYPE(CMISSFieldType) :: EquationsSetField
 60
 61
 62  !Test program parameters
 63
 64  REAL(CMISSDP), PARAMETER :: LENGTH=120.0_CMISSDP
 65  REAL(CMISSDP), PARAMETER :: WIDTH=160.0_CMISSDP
 66  REAL(CMISSDP), PARAMETER :: HEIGHT=10.0_CMISSDP
 67
 68  INTEGER(CMISSIntg), PARAMETER :: CoordinateSystemUserNumber=1
 69  INTEGER(CMISSIntg), PARAMETER :: NumberOfSpatialCoordinates=3
 70  INTEGER(CMISSIntg), PARAMETER :: RegionUserNumber=1
 71  INTEGER(CMISSIntg), PARAMETER :: Basis1UserNumber=1
 72  INTEGER(CMISSIntg), PARAMETER :: Basis2UserNumber=2
 73  INTEGER(CMISSIntg), PARAMETER :: Basis3UserNumber=3
 74  INTEGER(CMISSIntg), PARAMETER :: MeshUserNumber=1
 75  INTEGER(CMISSIntg), PARAMETER :: DecompositionUserNumber=1
 76
 77  INTEGER(CMISSIntg), PARAMETER :: NumberOfXiCoordinates=3
 78  INTEGER(CMISSIntg), PARAMETER :: TotalNumberOfNodes=8
 79  INTEGER(CMISSIntg), PARAMETER :: NumberOfMeshDimensions=3
 80  INTEGER(CMISSIntg), PARAMETER :: NumberOfMeshComponents=3
 81  INTEGER(CMISSIntg), PARAMETER :: TotalNumberOfElements=1
 82  INTEGER(CMISSIntg), PARAMETER :: MeshComponent1UserNumber=1
 83  INTEGER(CMISSIntg), PARAMETER :: MeshComponent2UserNumber=2
 84  INTEGER(CMISSIntg), PARAMETER :: MeshComponent3UserNumber=3
 85
 86  INTEGER(CMISSIntg), PARAMETER :: FieldGeometryUserNumber=1
 87  INTEGER(CMISSIntg), PARAMETER :: FieldGeometryNumberOfVariables=1
 88  INTEGER(CMISSIntg), PARAMETER :: FieldGeometryNumberOfComponents=3
 89
 90  INTEGER(CMISSIntg), PARAMETER :: FieldDependentUserNumber=2
 91  INTEGER(CMISSIntg), PARAMETER :: FieldDependentNumberOfVariables=2
 92  INTEGER(CMISSIntg), PARAMETER :: FieldDependentNumberOfComponents=3
 93
 94  INTEGER(CMISSIntg), PARAMETER :: FieldMaterialUserNumber=3
 95  INTEGER(CMISSIntg), PARAMETER :: FieldMaterialNumberOfVariables=1
 96  INTEGER(CMISSIntg), PARAMETER :: FieldMaterialNumberOfComponents=6
 97
 98  INTEGER(CMISSIntg), PARAMETER :: EquationSetUserNumber=1
 99  INTEGER(CMISSIntg), PARAMETER :: ProblemUserNumber=1
100
101  REAL(CMISSDP), PARAMETER ::   ZERO = 0.0_CMISSDP
102
103  !Program types
104
105
106  !Program variables
107
108  INTEGER(CMISSIntg) :: NumberGlobalXElements,NumberGlobalYElements,NumberGlobalZElements
109  INTEGER(CMISSIntg) :: MPI_IERROR
110  INTEGER(CMISSIntg) :: EquationsSetIndex  
111  INTEGER(CMISSIntg) :: NumberOfComputationalNodes,NumberOfDomains,ComputationalNodeNumber
112  LOGICAL :: EXPORT_FIELD
113
114  !CMISS variables
115
116  TYPE(CMISSRegionType) :: WorldRegion
117  TYPE(CMISSCoordinateSystemType) :: WorldCoordinateSystem
118    TYPE(CMISSBasisType) :: Basis(3)
119    TYPE(CMISSBoundaryConditionsType) :: BoundaryConditions
120    TYPE(CMISSCoordinateSystemType) :: CoordinateSystem
121    TYPE(CMISSDecompositionType) :: Decomposition
122    TYPE(CMISSEquationsType) :: Equations
123    TYPE(CMISSEquationsSetType) :: EquationsSet
124    TYPE(CMISSFieldType) :: GeometricField,DependentField,MaterialField
125    TYPE(CMISSFieldsType) :: Fields
126    TYPE(CMISSMeshType) :: Mesh
127    TYPE(CMISSNodesType) :: Nodes
128    TYPE(CMISSProblemType) :: Problem
129    TYPE(CMISSRegionType) :: Region
130    TYPE(CMISSSolverType) :: Solver
131    TYPE(CMISSSolverEquationsType) :: SolverEquations
132    TYPE(CMISSMeshElementsType) :: Elements(3)
133
134#ifdef WIN32
135  !Quickwin type
136  LOGICAL :: QUICKWIN_STATUS=.FALSE.
137  TYPE(WINDOWCONFIG) :: QUICKWIN_WINDOW_CONFIG
138#endif
139
140  !Generic CMISS variables
141  INTEGER(CMISSIntg) :: Err
142
143#ifdef WIN32
144  !Initialise QuickWin
145  QUICKWIN_WINDOW_CONFIG%TITLE="General Output" !Window title
146  QUICKWIN_WINDOW_CONFIG%NUMTEXTROWS=-1 !Max possible number of rows
147  QUICKWIN_WINDOW_CONFIG%MODE=QWIN$SCROLLDOWN
148  !Set the window parameters
149  QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
150  !If attempt fails set with system estimated values
151  IF(.NOT.QUICKWIN_STATUS) QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
152#endif
153
154  !Intialise cmiss
155  CALL CMISSInitialise(WorldCoordinateSystem,WorldRegion,Err)
156
157  CALL CMISSErrorHandlingModeSet(CMISS_ERRORS_TRAP_ERROR,Err)
158
159  WRITE(*,'(A)') "Program starting."
160
161  !Set all diganostic levels on for testing
162  CALL CMISSDiagnosticsSetOn(CMISS_FROM_DIAG_TYPE,(/1,2,3,4,5/),"Diagnostics",(/"PROBLEM_FINITE_ELEMENT_CALCULATE"/),Err)
163
164  !Get the number of computational nodes and this computational node number
165  CALL CMISSComputationalNumberOfNodesGet(NumberOfComputationalNodes,Err)
166  CALL CMISSComputationalNodeNumberGet(ComputationalNodeNumber,Err)
167
168  NumberGlobalXElements=1
169  NumberGlobalYElements=1
170  NumberGlobalZElements=1
171  NumberOfDomains=1
172
173  !Broadcast the number of elements in the X,Y and Z directions and the number of partitions to the other computational nodes
174  CALL MPI_BCAST(NumberGlobalXElements,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
175  CALL MPI_BCAST(NumberGlobalYElements,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
176  CALL MPI_BCAST(NumberGlobalZElements,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
177  CALL MPI_BCAST(NumberOfDomains,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
178
179  !Create a CS - default is 3D rectangular cartesian CS with 0,0,0 as origin
180  CALL CMISSCoordinateSystem_Initialise(CoordinateSystem,Err)
181  CALL CMISSCoordinateSystem_CreateStart(CoordinateSystemUserNumber,CoordinateSystem,Err)
182  CALL CMISSCoordinateSystem_TypeSet(CoordinateSystem,CMISS_COORDINATE_RECTANGULAR_CARTESIAN_TYPE,Err)
183  CALL CMISSCoordinateSystem_DimensionSet(CoordinateSystem,NumberOfSpatialCoordinates,Err)
184  CALL CMISSCoordinateSystem_OriginSet(CoordinateSystem,(/0.0_CMISSDP,0.0_CMISSDP,0.0_CMISSDP/),Err)
185  CALL CMISSCoordinateSystem_CreateFinish(CoordinateSystem,Err)
186
187  !Create a region and assign the CS to the region
188  CALL CMISSRegion_Initialise(Region,Err)
189  CALL CMISSRegion_CreateStart(RegionUserNumber,WorldRegion,Region,Err)
190  CALL CMISSRegion_CoordinateSystemSet(Region,CoordinateSystem,Err)
191  CALL CMISSRegion_CreateFinish(Region,Err)
192
193  !Define 3 sets of basis functions, one describing each independent coordinate specified by InterpolationType
194  !NOTE if you change interpolation you need to change Boundary Conditions
195  !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
196
197  CALL CMISSBasis_Initialise(Basis(1),Err)
198  CALL CMISSBasis_CreateStart(Basis1UserNumber,Basis(1),Err)
199  CALL CMISSBasis_TypeSet(Basis(1),CMISS_BASIS_LAGRANGE_HERMITE_TP_TYPE,Err)
200  CALL CMISSBasis_NumberOfXiSet(Basis(1),NumberOfXiCoordinates,Err)
201  CALL CMISSBasis_InterpolationXiSet(Basis(1),(/CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION, &
202    & CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION,CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION/),Err)
203  CALL CMISSBasis_QuadratureNumberOfGaussXiSet(Basis(1), &
204    & (/CMISS_BASIS_MID_QUADRATURE_SCHEME,CMISS_BASIS_MID_QUADRATURE_SCHEME,CMISS_BASIS_MID_QUADRATURE_SCHEME/),Err)
205  CALL CMISSBasis_CreateFinish(Basis(1),Err)
206
207  CALL CMISSBasis_Initialise(Basis(2),Err)
208  CALL CMISSBasis_CreateStart(Basis2UserNumber,Basis(2),Err)
209  CALL CMISSBasis_TypeSet(Basis(2),CMISS_BASIS_LAGRANGE_HERMITE_TP_TYPE,Err)
210  CALL CMISSBasis_NumberOfXiSet(Basis(2),NumberOfXiCoordinates,Err)
211  CALL CMISSBasis_InterpolationXiSet(Basis(2),(/CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION, &
212    & CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION,CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION/),Err)
213  CALL CMISSBasis_QuadratureNumberOfGaussXiSet(Basis(2), &
214    & (/CMISS_BASIS_MID_QUADRATURE_SCHEME,CMISS_BASIS_MID_QUADRATURE_SCHEME,CMISS_BASIS_MID_QUADRATURE_SCHEME/),Err)
215  CALL CMISSBasis_CreateFinish(Basis(2),Err)
216
217  CALL CMISSBasis_Initialise(Basis(3),Err)
218  CALL CMISSBasis_CreateStart(Basis3UserNumber,Basis(3),Err)
219  CALL CMISSBasis_TypeSet(Basis(3),CMISS_BASIS_LAGRANGE_HERMITE_TP_TYPE,Err)
220  CALL CMISSBasis_NumberOfXiSet(Basis(3),NumberOfXiCoordinates,Err)
221  CALL CMISSBasis_InterpolationXiSet(Basis(3),(/CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION, &
222    & CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION,CMISS_BASIS_LINEAR_LAGRANGE_INTERPOLATION/),Err)
223  CALL CMISSBasis_QuadratureNumberOfGaussXiSet(Basis(3), &
224    & (/CMISS_BASIS_MID_QUADRATURE_SCHEME,CMISS_BASIS_MID_QUADRATURE_SCHEME,CMISS_BASIS_MID_QUADRATURE_SCHEME/),Err)
225  CALL CMISSBasis_CreateFinish(Basis(3),Err)
226
227  !Create a mesh
228  CALL CMISSMesh_Initialise(Mesh,Err)
229  CALL CMISSMesh_CreateStart(MeshUserNumber,Region,NumberOfMeshDimensions,Mesh,Err)
230
231  CALL CMISSMesh_NumberOfComponentsSet(Mesh,NumberOfMeshComponents,Err)
232  CALL CMISSMesh_NumberOfElementsSet(Mesh,TotalNumberOfElements,Err)
233
234  !Define nodes for the mesh
235  CALL CMISSNodes_Initialise(Nodes,Err)
236  CALL CMISSNodes_CreateStart(Region,TotalNumberOfNodes,Nodes,Err)
237  CALL CMISSNodes_CreateFinish(Nodes,Err)
238
239  !Create elements for the mesh
240  !Mesh Component 1
241  CALL CMISSMeshElements_Initialise(Elements(1),Err)
242  CALL CMISSMeshElements_CreateStart(Mesh,MeshComponent1UserNumber,Basis(1),Elements(1),Err)
243  CALL CMISSMeshElements_NodesSet(Elements(1),1,(/1,2,3,4,5,6,7,8/),Err)
244  CALL CMISSMeshElements_CreateFinish(Elements(1),Err)
245  !Mesh Component 2
246  CALL CMISSMeshElements_Initialise(Elements(2),Err)
247  CALL CMISSMeshElements_CreateStart(Mesh,MeshComponent2UserNumber,Basis(2),Elements(2),Err)
248  CALL CMISSMeshElements_NodesSet(Elements(2),1,(/1,2,3,4,5,6,7,8/),Err)
249  CALL CMISSMeshElements_CreateFinish(Elements(2),Err)
250  !Mesh Component 3
251  CALL CMISSMeshElements_Initialise(Elements(3),Err)
252  CALL CMISSMeshElements_CreateStart(Mesh,MeshComponent3UserNumber,Basis(3),Elements(3),Err)
253  CALL CMISSMeshElements_NodesSet(Elements(3),1,(/1,2,3,4,5,6,7,8/),Err)
254  CALL CMISSMeshElements_CreateFinish(Elements(3),Err)
255
256  CALL CMISSMesh_CreateFinish(Mesh,Err) 
257
258  !Create a decomposition
259  CALL CMISSDecomposition_Initialise(Decomposition,Err)
260  CALL CMISSDecomposition_CreateStart(DecompositionUserNumber,Mesh,Decomposition,Err)
261  CALL CMISSDecomposition_TypeSet(Decomposition,CMISS_DECOMPOSITION_CALCULATED_TYPE,Err)
262  CALL CMISSDecomposition_NumberOfDomainsSet(Decomposition,NumberOfDomains,Err)
263  CALL CMISSDecomposition_CreateFinish(Decomposition,Err)
264
265  !Create a field to put the geometry (defualt is geometry)
266  CALL CMISSField_Initialise(GeometricField,Err)
267  CALL CMISSField_CreateStart(FieldGeometryUserNumber,Region,GeometricField,Err)
268  CALL CMISSField_MeshDecompositionSet(GeometricField,Decomposition,Err)
269  CALL CMISSField_TypeSet(GeometricField,CMISS_FIELD_GEOMETRIC_TYPE,Err)  
270  CALL CMISSField_NumberOfVariablesSet(GeometricField,FieldGeometryNumberOfVariables,Err)
271  CALL CMISSField_NumberOfComponentsSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,FieldGeometryNumberOfComponents,Err)  
272  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,Err)
273  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,2,2,Err)
274  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,3,3,Err)
275  CALL CMISSField_CreateFinish(GeometricField,Err)
276
277  !Set geometric node coordinates (x)
278  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,1,1, &
279    & 0.0_CMISSDP,Err)
280  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,2,1,LENGTH,Err)
281  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,3,1, &
282    & 0.0_CMISSDP,Err)
283  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,4,1,LENGTH,Err)
284  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,5,1, &
285    & 0.0_CMISSDP,Err)
286  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,6,1,LENGTH,Err)
287  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,7,1, &
288    & 0.0_CMISSDP,Err)
289  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,8,1,LENGTH,Err)
290
291  !Set geometric node coordinates (y)
292  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,1,2, &
293    & 0.0_CMISSDP,Err)
294  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,2,2, &
295    & 0.0_CMISSDP,Err)
296  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,3,2,WIDTH,Err)
297  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,4,2,WIDTH,Err)
298  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,5,2, &
299    & 0.0_CMISSDP,Err)
300  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,6,2, &
301    & 0.0_CMISSDP,Err)
302  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,7,2,WIDTH,Err)
303  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,8,2,WIDTH,Err)
304
305  !Set geometric node coordinates (z)
306  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,1,3, &
307    & 0.0_CMISSDP,Err)
308  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,2,3, &
309    & 0.0_CMISSDP,Err)
310  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,3,3, &
311    & 0.0_CMISSDP,Err)
312  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,4,3, &
313    & 0.0_CMISSDP,Err)
314  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,5,3,HEIGHT,Err)
315  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,6,3,HEIGHT,Err)
316  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,7,3,HEIGHT,Err)
317  CALL CMISSField_ParameterSetUpdateNode(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1,1,8,3,HEIGHT,Err)
318
319  !Create a dependent field with two variables and three components
320  CALL CMISSField_Initialise(DependentField,Err)
321  CALL CMISSField_CreateStart(FieldDependentUserNumber,Region,DependentField,Err)
322  CALL CMISSField_TypeSet(DependentField,CMISS_FIELD_GENERAL_TYPE,Err)  
323  CALL CMISSField_MeshDecompositionSet(DependentField,Decomposition,Err)
324  CALL CMISSField_GeometricFieldSet(DependentField,GeometricField,Err) 
325  CALL CMISSField_DependentTypeSet(DependentField,CMISS_FIELD_DEPENDENT_TYPE,Err) 
326  CALL CMISSField_NumberOfVariablesSet(DependentField,FieldDependentNumberOfVariables,Err)
327  CALL CMISSField_NumberOfComponentsSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,FieldDependentNumberOfComponents,Err)
328  CALL CMISSField_NumberOfComponentsSet(DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,FieldDependentNumberOfComponents,Err)
329  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,Err)
330  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,2,2,Err)
331  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_U_VARIABLE_TYPE,3,3,Err)
332  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,1,1,Err)
333  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,2,2,Err)
334  CALL CMISSField_ComponentMeshComponentSet(DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,3,3,Err)
335  CALL CMISSField_CreateFinish(DependentField,Err)
336
337  !Create a material field and attach it to the geometric field  
338  CALL CMISSField_Initialise(MaterialField,Err)
339  CALL CMISSField_CreateStart(FieldMaterialUserNumber,Region,MaterialField,Err)
340  CALL CMISSField_TypeSet(MaterialField,CMISS_FIELD_MATERIAL_TYPE,Err)
341  CALL CMISSField_MeshDecompositionSet(MaterialField,Decomposition,Err)
342  CALL CMISSField_GeometricFieldSet(MaterialField,GeometricField,Err)
343  CALL CMISSField_NumberOfVariablesSet(MaterialField,FieldMaterialNumberOfVariables,Err)
344  CALL CMISSField_NumberOfComponentsSet(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,FieldMaterialNumberOfComponents,Err)  
345  CALL CMISSField_ComponentMeshComponentSet(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,Err)
346  CALL CMISSField_ComponentMeshComponentSet(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,2,2,Err)
347  CALL CMISSField_ComponentMeshComponentSet(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,3,3,Err)
348  CALL CMISSField_CreateFinish(MaterialField,Err)
349
350  !Set isotropic elasticity material parameters - Young's Modulus & Poisson's Ratio
351  CALL CMISSField_ComponentValuesInitialise(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,1, &
352    & 10.0E3_CMISSDP, &
353    & Err) !E1
354  CALL CMISSField_ComponentValuesInitialise(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,2, &
355    & 10.0E3_CMISSDP, &
356    & Err) !E2
357  CALL CMISSField_ComponentValuesInitialise(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,3, &
358    & 10.0E3_CMISSDP, &
359    & Err) !E3
360  CALL CMISSField_ComponentValuesInitialise(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,4,0.3_CMISSDP, &
361    & Err) !v13
362  CALL CMISSField_ComponentValuesInitialise(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,5,0.3_CMISSDP, &
363    & Err) !v23
364  CALL CMISSField_ComponentValuesInitialise(MaterialField,CMISS_FIELD_U_VARIABLE_TYPE,CMISS_FIELD_VALUES_SET_TYPE,6,0.3_CMISSDP, &
365    & Err) !v12
366
367  !Create a Elasticity Class, Linear Elasticity type, no subtype, EquationsSet
368  CALL CMISSEquationsSet_Initialise(EquationsSet,Err)
369  CALL CMISSField_Initialise(EquationsSetField,Err)
370  CALL CMISSEquationsSet_CreateStart(EquationSetUserNumber,Region,GeometricField,CMISS_EQUATIONS_SET_ELASTICITY_CLASS, &
371    & CMISS_EQUATIONS_SET_LINEAR_ELASTICITY_TYPE,CMISS_EQUATIONS_SET_THREE_DIMENSIONAL_SUBTYPE,EquationsSetFieldUserNumber, &
372    & EquationsSetField,EquationsSet,Err)
373  
374  CALL CMISSEquationsSet_CreateFinish(EquationsSet,Err)
375
376  CALL CMISSEquationsSet_DependentCreateStart(EquationsSet,FieldDependentUserNumber,DependentField,Err) 
377  CALL CMISSEquationsSet_DependentCreateFinish(EquationsSet,Err)
378
379  CALL CMISSEquationsSet_MaterialsCreateStart(EquationsSet,FieldMaterialUserNumber,MaterialField,Err)  
380  CALL CMISSEquationsSet_MaterialsCreateFinish(EquationsSet,Err)
381
382  !Create the equations set equations
383  CALL CMISSEquations_Initialise(Equations,Err)
384  CALL CMISSEquationsSet_EquationsCreateStart(EquationsSet,Equations,Err)
385  CALL CMISSEquations_SparsityTypeSet(EQUATIONS,CMISS_EQUATIONS_SPARSE_MATRICES,Err)
386                                              !CMISS_EQUATIONS_SPARSE_MATRICES=1 !<Use sparse matrices for the equations.
387                                              !CMISS_EQUATIONS_FULL_MATRICES=2 !<Use fully populated matrices for the equations. 
388  CALL CMISSEquations_OutputTypeSet(EQUATIONS,CMISS_EQUATIONS_ELEMENT_MATRIX_OUTPUT,Err)
389                                            !CMISS_EQUATIONS_NO_OUTPUT !<No output from the equations.
390                                            !CMISS_EQUATIONS_TIMING_OUTPUT !<Timing information output.
391                                            !CMISS_EQUATIONS_MATRIX_OUTPUT !<All below and equation matrices output.
392                                            !CMISS_EQUATIONS_ELEMENT_MATRIX_OUTPUT !<All below and Element matrices output.
393  CALL CMISSEquationsSet_EquationsCreateFinish(EquationsSet,Err)
394  
395  !Define the problem
396  CALL CMISSProblem_Initialise(Problem,Err)
397  CALL CMISSProblem_CreateStart(ProblemUserNumber,Problem,Err)
398  CALL CMISSProblem_SpecificationSet(Problem,CMISS_PROBLEM_ELASTICITY_CLASS,CMISS_PROBLEM_LINEAR_ELASTICITY_TYPE, &
399    & CMISS_PROBLEM_NO_SUBTYPE,Err)
400  CALL CMISSProblem_CreateFinish(Problem,Err)
401
402  !Create the problem control loop
403  CALL CMISSProblem_ControlLoopCreateStart(Problem,Err)
404  CALL CMISSProblem_ControlLoopCreateFinish(Problem,Err)
405
406  !Start the creation of the Problem solvers
407  !Create the problem solvers
408  CALL CMISSSolver_Initialise(Solver,Err)
409  CALL CMISSProblem_SolversCreateStart(Problem,Err)
410  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,1,Solver,Err)
411  CALL CMISSSolver_OutputTypeSet(SOLVER,CMISS_SOLVER_MATRIX_OUTPUT,Err)
412                                      !CMISS_SOLVER_NO_OUTPUT !<No output from the solver routines. \see OPENCMISS_SolverOutputTypes,OPENCMISS
413                                      !CMISS_SOLVER_PROGRESS_OUTPUT !<Progress output from solver routines.
414                                      !CMISS_SOLVER_TIMING_OUTPUT !<Timing output from the solver routines plus below.
415                                      !CMISS_SOLVER_SOLVER_OUTPUT !<Solver specific output from the solver routines plus below.
416                                      !CMISS_SOLVER_MATRIX_OUTPUT !<Solver matrices output from the solver routines plus below.
417  CALL CMISSSolver_LibraryTypeSet(SOLVER,CMISS_SOLVER_PETSC_LIBRARY,Err)
418                                        !CMISS_SOLVER_CMISS_LIBRARY     !<CMISS (internal) solver library.
419                                        !CMISS_SOLVER_PETSC_LIBRARY     !<PETSc solver library.
420                                        !CMISS_SOLVER_MUMPS_LIBRARY     !<MUMPS solver library.
421                                        !CMISS_SOLVER_SUPERLU_LIBRARY   !<SuperLU solver library.
422                                        !CMISS_SOLVER_SPOOLES_LIBRARY !<SPOOLES solver library.
423                                        !CMISS_SOLVER_UMFPACK_LIBRARY   !<UMFPACK solver library.
424                                        !CMISS_SOLVER_LUSOL_LIBRARY     !<LUSOL solver library.
425                                        !CMISS_SOLVER_ESSL_LIBRARY      !<ESSL solver library.
426                                        !CMISS_SOLVER_LAPACK_LIBRARY    !<LAPACK solver library.
427                                        !CMISS_SOLVER_TAO_LIBRARY       !<TAO solver library.
428                                        !CMISS_SOLVER_HYPRE_LIBRARY     !<Hypre solver library.
429  CALL CMISSSolver_LinearTypeSet(SOLVER,CMISS_SOLVER_LINEAR_DIRECT_SOLVE_TYPE,Err)
430                                      !CMISS_SOLVER_LINEAR_DIRECT_SOLVE_TYPE    !<Direct linear solver type.
431                                      !CMISS_SOLVER_LINEAR_ITERATIVE_SOLVE_TYPE !<Iterative linear solver type.
432  CALL CMISSProblem_SolversCreateFinish(Problem,Err)
433
434  !Create the problem solver equations
435  CALL CMISSSolver_Initialise(Solver,Err)
436  CALL CMISSSolverEquations_Initialise(SolverEquations,Err)
437  CALL CMISSProblem_SolverEquationsCreateStart(Problem,Err)   
438  CALL CMISSProblem_SolverGet(Problem,CMISS_CONTROL_LOOP_NODE,1,Solver,Err)
439  CALL CMISSSolver_SolverEquationsGet(Solver,SolverEquations,Err)
440  CALL CMISSSolverEquations_SparsityTypeSet(SolverEquations,CMISS_SOLVER_SPARSE_MATRICES,Err)
441                                                          !CMISS_SOLVER_SPARSE_MATRICES !<Use sparse solver matrices.
442                                                          !CMISS_SOLVER_FULL_MATRICES !<Use fully populated solver matrices.
443  CALL CMISSSolverEquations_EquationsSetAdd(SolverEquations,EquationsSet,EquationsSetIndex,Err)
444  CALL CMISSProblem_SolverEquationsCreateFinish(Problem,Err)
445
446  !Prescribe boundary conditions
447  CALL CMISSBoundaryConditions_Initialise(BoundaryConditions,Err)
448  CALL CMISSSolverEquations_BoundaryConditionsCreateStart(SolverEquations,BoundaryConditions,Err)
449
450  !Fix nodes 1,3,5,7 at x=0
451  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,1,1, &
452    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
453  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,3,1, &
454    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
455  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,5,1, &
456    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
457  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,7,1, &
458    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
459
460  !Fix nodes 1,2,5,6 at y=0
461  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,1,2, &
462    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
463  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,2,2, &
464    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
465  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,5,2, &
466    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
467  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,6,2, &
468    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
469
470  !Fix nodes 1,2,3,4 at x=0
471  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,1,3, &
472    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
473  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,2,3, &
474    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
475  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,3,3, &
476    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
477  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,4,3, &
478    & CMISS_BOUNDARY_CONDITION_FIXED,ZERO,Err)
479
480  !Apply force at nodes 1,2,3,4 at x=l
481  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,1,1,2,1, &
482    & CMISS_BOUNDARY_CONDITION_FIXED, &
483    & -400.0_CMISSDP,Err)
484  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,1,1,4,1, &
485    & CMISS_BOUNDARY_CONDITION_FIXED, &
486    & -400.0_CMISSDP,Err)
487  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,1,1,6,1, &
488    & CMISS_BOUNDARY_CONDITION_FIXED, &
489    & -400.0_CMISSDP,Err)
490  CALL CMISSBoundaryConditions_SetNode(BoundaryConditions,DependentField,CMISS_FIELD_DELUDELN_VARIABLE_TYPE,1,1,8,1, &
491    & CMISS_BOUNDARY_CONDITION_FIXED, &
492    & -400.0_CMISSDP,Err)
493
494  CALL CMISSSolverEquations_BoundaryConditionsCreateFinish(SolverEquations,Err)
495
496  !=SOLVE Problem==================================================================================================================
497  !Solve the Problem
498  CALL CMISSProblem_Solve(Problem,Err)
499
500  !=OUTPUT SOLUTION================================================================================================================
501  !!TODO:: Output reaction forces in ipnode files
502  EXPORT_FIELD=.TRUE.
503  IF(EXPORT_FIELD) THEN
504    CALL CMISSFields_Initialise(Fields,Err)
505    CALL CMISSFields_Create(Region,Fields,Err)
506    CALL CMISSFields_NodesExport(Fields,"LinearElasticity3DLinearLagrangeBasisExample","FORTRAN",Err)
507    CALL CMISSFields_ElementsExport(Fields,"LinearElasticity3DLinearLagrangeBasisExample","FORTRAN",Err)
508    CALL CMISSFields_Finalise(Fields,Err)
509  ENDIF
510  CALL CMISSFinalise(Err)
511
512  WRITE(*,'(A)') "Program successfully completed."
513  
514  STOP
515
516END PROGRAM LinearElasticity3DLagrangeBasis
517
518