PageRenderTime 35ms CodeModel.GetById 12ms app.highlight 19ms RepoModel.GetById 1ms app.codeStats 1ms

/Meshes/Simplex/Triangular/Quadratic/src/QuadraticExample.f90

http://github.com/xyan075/examples
FORTRAN Modern | 212 lines | 92 code | 36 blank | 84 comment | 0 complexity | 4fc05ce678e76a993b8dac2e821009ac MD5 | raw file
  1!> \file
  2!> \author Chris Bradley
  3!> \brief This is an example program to set up a generated mesh of quadratic Simplex triangle elements.
  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 Meshes/Simplex/Triangle/Quadratic/src/QuadraticExample.f90
 43!! Example program to to set up a generated mesh of quadratic Simplex triangle elements.
 44!! \htmlinclude Meshes/Simplex/Triangle/Quadratic/history.html
 45!!
 46!<
 47
 48!> Main program
 49PROGRAM QUADRATICTRIANGLESIMPLEXEXAMPLE
 50
 51  USE OPENCMISS
 52  USE MPI
 53
 54#ifdef WIN32
 55  USE IFQWIN
 56#endif
 57
 58  IMPLICIT NONE
 59
 60  !Test program parameters
 61
 62  REAL(CMISSDP), PARAMETER :: HEIGHT=1.0_CMISSDP
 63  REAL(CMISSDP), PARAMETER :: WIDTH=2.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 
 73  !Program types
 74  
 75  !Program variables
 76
 77  INTEGER(CMISSIntg) :: NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS
 78  
 79  INTEGER(CMISSIntg) :: MPI_IERROR
 80
 81  !CMISS variables
 82
 83  TYPE(CMISSBasisType) :: Basis
 84  TYPE(CMISSCoordinateSystemType) :: CoordinateSystem,WorldCoordinateSystem
 85  TYPE(CMISSDecompositionType) :: Decomposition
 86  TYPE(CMISSFieldType) :: GeometricField
 87  TYPE(CMISSFieldsType) :: Fields
 88  TYPE(CMISSGeneratedMeshType) :: GeneratedMesh  
 89  TYPE(CMISSMeshType) :: Mesh
 90  TYPE(CMISSRegionType) :: Region,WorldRegion
 91
 92#ifdef WIN32
 93  !Quickwin type
 94  LOGICAL :: QUICKWIN_STATUS=.FALSE.
 95  TYPE(WINDOWCONFIG) :: QUICKWIN_WINDOW_CONFIG
 96#endif
 97  
 98  !Generic CMISS variables
 99  
100  INTEGER(CMISSIntg) :: NumberOfComputationalNodes,ComputationalNodeNumber
101  INTEGER(CMISSIntg) :: Err
102  
103#ifdef WIN32
104  !Initialise QuickWin
105  QUICKWIN_WINDOW_CONFIG%TITLE="General Output" !Window title
106  QUICKWIN_WINDOW_CONFIG%NUMTEXTROWS=-1 !Max possible number of rows
107  QUICKWIN_WINDOW_CONFIG%MODE=QWIN$SCROLLDOWN
108  !Set the window parameters
109  QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
110  !If attempt fails set with system estimated values
111  IF(.NOT.QUICKWIN_STATUS) QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
112#endif
113
114  !Intialise OpenCMISS
115  CALL CMISSInitialise(WorldCoordinateSystem,WorldRegion,Err)
116
117  CALL CMISSErrorHandlingModeSet(CMISS_ERRORS_TRAP_ERROR,Err)
118
119  CALL CMISSDiagnosticsSetOn(CMISS_IN_DIAG_TYPE,(/1,2,3,4,5/),"Diagnostics",(/"MESH_TOPOLOGY_ELEMENTS_CREATE_FINISH"/),Err)
120
121  !Get the computational nodes information
122  CALL CMISSComputationalNumberOfNodesGet(NumberOfComputationalNodes,Err)
123  CALL CMISSComputationalNodeNumberGet(ComputationalNodeNumber,Err)
124  
125  NUMBER_GLOBAL_X_ELEMENTS=3
126  NUMBER_GLOBAL_Y_ELEMENTS=3
127      
128  !Broadcast the number of elements in the X & Y directions to the other computational nodes
129  CALL MPI_BCAST(NUMBER_GLOBAL_X_ELEMENTS,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
130  CALL MPI_BCAST(NUMBER_GLOBAL_Y_ELEMENTS,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
131
132  !Start the creation of a new RC coordinate system
133  CALL CMISSCoordinateSystem_Initialise(CoordinateSystem,Err)
134  CALL CMISSCoordinateSystem_CreateStart(CoordinateSystemUserNumber,CoordinateSystem,Err)
135  !Set the coordinate system to be 2D
136  CALL CMISSCoordinateSystem_DimensionSet(CoordinateSystem,2,Err)
137  !Finish the creation of the coordinate system
138  CALL CMISSCoordinateSystem_CreateFinish(CoordinateSystem,Err)
139
140  !Start the creation of the region
141  CALL CMISSRegion_Initialise(Region,Err)
142  CALL CMISSRegion_CreateStart(RegionUserNumber,WorldRegion,Region,Err)
143  !Set the regions coordinate system to the 2D RC coordinate system that we have created
144  CALL CMISSRegion_CoordinateSystemSet(Region,CoordinateSystem,Err)
145  !Finish the creation of the region
146  CALL CMISSRegion_CreateFinish(Region,Err)
147
148  !Start the creation of a basis 
149  CALL CMISSBasis_Initialise(Basis,Err)
150  CALL CMISSBasis_CreateStart(BasisUserNumber,Basis,Err)
151  !Set the type to be a Simplex basis
152  CALL CMISSBasis_TypeSet(Basis,CMISS_BASIS_SIMPLEX_TYPE,Err)
153  !Set the basis to be a triangular basis
154  CALL CMISSBasis_NumberOfXiSet(Basis,2,Err)
155  !Set the interpolation to be quadratic
156  CALL CMISSBasis_InterpolationXiSet(Basis,(/CMISS_BASIS_QUADRATIC_SIMPLEX_INTERPOLATION, &
157    & CMISS_BASIS_QUADRATIC_SIMPLEX_INTERPOLATION/),Err)
158  !Finish the creation of the basis
159  CALL CMISSBasis_CreateFinish(Basis,Err)
160   
161  !Start the creation of a generated mesh in the region
162  CALL CMISSGeneratedMesh_Initialise(GeneratedMesh,Err)
163  CALL CMISSGeneratedMesh_CreateStart(GeneratedMeshUserNumber,Region,GeneratedMesh,Err)
164  !Set up a regular x*y mesh
165  CALL CMISSGeneratedMesh_TypeSet(GeneratedMesh,CMISS_GENERATED_MESH_REGULAR_MESH_TYPE,Err)
166  !Set the default basis
167  CALL CMISSGeneratedMesh_BasisSet(GeneratedMesh,Basis,Err)   
168  !Define the mesh on the region
169  CALL CMISSGeneratedMesh_ExtentSet(GeneratedMesh,(/WIDTH,HEIGHT/),Err)
170  CALL CMISSGeneratedMesh_NumberOfElementsSet(GeneratedMesh,(/NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS/),Err)
171  !Finish the creation of a generated mesh in the region
172  CALL CMISSMesh_Initialise(Mesh,Err)
173  CALL CMISSGeneratedMesh_CreateFinish(GeneratedMesh,MeshUserNumber,Mesh,Err)
174
175  !Create a decomposition
176  CALL CMISSDecomposition_Initialise(Decomposition,Err)
177  CALL CMISSDecomposition_CreateStart(DecompositionUserNumber,Mesh,Decomposition,Err)
178  !Set the decomposition to be a general decomposition with the specified number of domains
179  CALL CMISSDecomposition_TypeSet(Decomposition,CMISS_DECOMPOSITION_CALCULATED_TYPE,Err)
180  CALL CMISSDecomposition_NumberOfDomainsSet(Decomposition,NumberOfComputationalNodes,Err)
181  !Finish the decomposition
182  CALL CMISSDecomposition_CreateFinish(Decomposition,Err)
183  
184  !Start to create a default (geometric) field on the region
185  CALL CMISSField_Initialise(GeometricField,Err)
186  CALL CMISSField_CreateStart(GeometricFieldUserNumber,Region,GeometricField,Err)
187  !Set the decomposition to use
188  CALL CMISSField_MeshDecompositionSet(GeometricField,Decomposition,Err)
189  !Set the domain to be used by the field components.
190  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,Err)
191  CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,2,1,Err)
192  !Finish creating the field
193  CALL CMISSField_CreateFinish(GeometricField,Err)
194
195  !Update the geometric field parameters
196  CALL CMISSGeneratedMesh_GeometricParametersCalculate(GeneratedMesh,GeometricField,Err)
197  
198  !Export the fields
199  CALL CMISSFields_Initialise(Fields,Err)
200  CALL CMISSFields_Create(Region,Fields,Err)
201  CALL CMISSFields_NodesExport(Fields,"QuadraticTriangleSimplex","FORTRAN",Err)
202  CALL CMISSFields_ElementsExport(Fields,"QuadraticTriangleSimplex","FORTRAN",Err)
203  CALL CMISSFields_Finalise(Fields,Err)
204  
205  !Finialise CMISS
206  CALL CMISSFinalise(Err)
207
208  WRITE(*,'(A)') "Program successfully completed."
209  
210  STOP
211  
212END PROGRAM QUADRATICTRIANGLESIMPLEXEXAMPLE