/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
- !> \file
- !> \author Chris Bradley
- !> \brief This is an example program to set up a generated mesh of quadratic Simplex triangle elements.
- !>
- !> \section LICENSE
- !>
- !> Version: MPL 1.1/GPL 2.0/LGPL 2.1
- !>
- !> The contents of this file are subject to the Mozilla Public License
- !> Version 1.1 (the "License"); you may not use this file except in
- !> compliance with the License. You may obtain a copy of the License at
- !> http://www.mozilla.org/MPL/
- !>
- !> Software distributed under the License is distributed on an "AS IS"
- !> basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
- !> License for the specific language governing rights and limitations
- !> under the License.
- !>
- !> The Original Code is OpenCMISS
- !>
- !> The Initial Developer of the Original Code is University of Auckland,
- !> Auckland, New Zealand and University of Oxford, Oxford, United
- !> Kingdom. Portions created by the University of Auckland and University
- !> of Oxford are Copyright (C) 2007 by the University of Auckland and
- !> the University of Oxford. All Rights Reserved.
- !>
- !> Contributor(s):
- !>
- !> Alternatively, the contents of this file may be used under the terms of
- !> either the GNU General Public License Version 2 or later (the "GPL"), or
- !> the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- !> in which case the provisions of the GPL or the LGPL are applicable instead
- !> of those above. If you wish to allow use of your version of this file only
- !> under the terms of either the GPL or the LGPL, and not to allow others to
- !> use your version of this file under the terms of the MPL, indicate your
- !> decision by deleting the provisions above and replace them with the notice
- !> and other provisions required by the GPL or the LGPL. If you do not delete
- !> the provisions above, a recipient may use your version of this file under
- !> the terms of any one of the MPL, the GPL or the LGPL.
- !>
- !> \example Meshes/Simplex/Triangle/Quadratic/src/QuadraticExample.f90
- !! Example program to to set up a generated mesh of quadratic Simplex triangle elements.
- !! \htmlinclude Meshes/Simplex/Triangle/Quadratic/history.html
- !!
- !<
- !> Main program
- PROGRAM QUADRATICTRIANGLESIMPLEXEXAMPLE
- USE OPENCMISS
- USE MPI
- #ifdef WIN32
- USE IFQWIN
- #endif
- IMPLICIT NONE
- !Test program parameters
- REAL(CMISSDP), PARAMETER :: HEIGHT=1.0_CMISSDP
- REAL(CMISSDP), PARAMETER :: WIDTH=2.0_CMISSDP
- INTEGER(CMISSIntg), PARAMETER :: CoordinateSystemUserNumber=1
- INTEGER(CMISSIntg), PARAMETER :: RegionUserNumber=2
- INTEGER(CMISSIntg), PARAMETER :: BasisUserNumber=3
- INTEGER(CMISSIntg), PARAMETER :: GeneratedMeshUserNumber=4
- INTEGER(CMISSIntg), PARAMETER :: MeshUserNumber=5
- INTEGER(CMISSIntg), PARAMETER :: DecompositionUserNumber=6
- INTEGER(CMISSIntg), PARAMETER :: GeometricFieldUserNumber=7
-
- !Program types
-
- !Program variables
- INTEGER(CMISSIntg) :: NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS
-
- INTEGER(CMISSIntg) :: MPI_IERROR
- !CMISS variables
- TYPE(CMISSBasisType) :: Basis
- TYPE(CMISSCoordinateSystemType) :: CoordinateSystem,WorldCoordinateSystem
- TYPE(CMISSDecompositionType) :: Decomposition
- TYPE(CMISSFieldType) :: GeometricField
- TYPE(CMISSFieldsType) :: Fields
- TYPE(CMISSGeneratedMeshType) :: GeneratedMesh
- TYPE(CMISSMeshType) :: Mesh
- TYPE(CMISSRegionType) :: Region,WorldRegion
- #ifdef WIN32
- !Quickwin type
- LOGICAL :: QUICKWIN_STATUS=.FALSE.
- TYPE(WINDOWCONFIG) :: QUICKWIN_WINDOW_CONFIG
- #endif
-
- !Generic CMISS variables
-
- INTEGER(CMISSIntg) :: NumberOfComputationalNodes,ComputationalNodeNumber
- INTEGER(CMISSIntg) :: Err
-
- #ifdef WIN32
- !Initialise QuickWin
- QUICKWIN_WINDOW_CONFIG%TITLE="General Output" !Window title
- QUICKWIN_WINDOW_CONFIG%NUMTEXTROWS=-1 !Max possible number of rows
- QUICKWIN_WINDOW_CONFIG%MODE=QWIN$SCROLLDOWN
- !Set the window parameters
- QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
- !If attempt fails set with system estimated values
- IF(.NOT.QUICKWIN_STATUS) QUICKWIN_STATUS=SETWINDOWCONFIG(QUICKWIN_WINDOW_CONFIG)
- #endif
- !Intialise OpenCMISS
- CALL CMISSInitialise(WorldCoordinateSystem,WorldRegion,Err)
- CALL CMISSErrorHandlingModeSet(CMISS_ERRORS_TRAP_ERROR,Err)
- CALL CMISSDiagnosticsSetOn(CMISS_IN_DIAG_TYPE,(/1,2,3,4,5/),"Diagnostics",(/"MESH_TOPOLOGY_ELEMENTS_CREATE_FINISH"/),Err)
- !Get the computational nodes information
- CALL CMISSComputationalNumberOfNodesGet(NumberOfComputationalNodes,Err)
- CALL CMISSComputationalNodeNumberGet(ComputationalNodeNumber,Err)
-
- NUMBER_GLOBAL_X_ELEMENTS=3
- NUMBER_GLOBAL_Y_ELEMENTS=3
-
- !Broadcast the number of elements in the X & Y directions to the other computational nodes
- CALL MPI_BCAST(NUMBER_GLOBAL_X_ELEMENTS,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
- CALL MPI_BCAST(NUMBER_GLOBAL_Y_ELEMENTS,1,MPI_INTEGER,0,MPI_COMM_WORLD,MPI_IERROR)
- !Start the creation of a new RC coordinate system
- CALL CMISSCoordinateSystem_Initialise(CoordinateSystem,Err)
- CALL CMISSCoordinateSystem_CreateStart(CoordinateSystemUserNumber,CoordinateSystem,Err)
- !Set the coordinate system to be 2D
- CALL CMISSCoordinateSystem_DimensionSet(CoordinateSystem,2,Err)
- !Finish the creation of the coordinate system
- CALL CMISSCoordinateSystem_CreateFinish(CoordinateSystem,Err)
- !Start the creation of the region
- CALL CMISSRegion_Initialise(Region,Err)
- CALL CMISSRegion_CreateStart(RegionUserNumber,WorldRegion,Region,Err)
- !Set the regions coordinate system to the 2D RC coordinate system that we have created
- CALL CMISSRegion_CoordinateSystemSet(Region,CoordinateSystem,Err)
- !Finish the creation of the region
- CALL CMISSRegion_CreateFinish(Region,Err)
- !Start the creation of a basis
- CALL CMISSBasis_Initialise(Basis,Err)
- CALL CMISSBasis_CreateStart(BasisUserNumber,Basis,Err)
- !Set the type to be a Simplex basis
- CALL CMISSBasis_TypeSet(Basis,CMISS_BASIS_SIMPLEX_TYPE,Err)
- !Set the basis to be a triangular basis
- CALL CMISSBasis_NumberOfXiSet(Basis,2,Err)
- !Set the interpolation to be quadratic
- CALL CMISSBasis_InterpolationXiSet(Basis,(/CMISS_BASIS_QUADRATIC_SIMPLEX_INTERPOLATION, &
- & CMISS_BASIS_QUADRATIC_SIMPLEX_INTERPOLATION/),Err)
- !Finish the creation of the basis
- CALL CMISSBasis_CreateFinish(Basis,Err)
-
- !Start the creation of a generated mesh in the region
- CALL CMISSGeneratedMesh_Initialise(GeneratedMesh,Err)
- CALL CMISSGeneratedMesh_CreateStart(GeneratedMeshUserNumber,Region,GeneratedMesh,Err)
- !Set up a regular x*y mesh
- CALL CMISSGeneratedMesh_TypeSet(GeneratedMesh,CMISS_GENERATED_MESH_REGULAR_MESH_TYPE,Err)
- !Set the default basis
- CALL CMISSGeneratedMesh_BasisSet(GeneratedMesh,Basis,Err)
- !Define the mesh on the region
- CALL CMISSGeneratedMesh_ExtentSet(GeneratedMesh,(/WIDTH,HEIGHT/),Err)
- CALL CMISSGeneratedMesh_NumberOfElementsSet(GeneratedMesh,(/NUMBER_GLOBAL_X_ELEMENTS,NUMBER_GLOBAL_Y_ELEMENTS/),Err)
- !Finish the creation of a generated mesh in the region
- CALL CMISSMesh_Initialise(Mesh,Err)
- CALL CMISSGeneratedMesh_CreateFinish(GeneratedMesh,MeshUserNumber,Mesh,Err)
- !Create a decomposition
- CALL CMISSDecomposition_Initialise(Decomposition,Err)
- CALL CMISSDecomposition_CreateStart(DecompositionUserNumber,Mesh,Decomposition,Err)
- !Set the decomposition to be a general decomposition with the specified number of domains
- CALL CMISSDecomposition_TypeSet(Decomposition,CMISS_DECOMPOSITION_CALCULATED_TYPE,Err)
- CALL CMISSDecomposition_NumberOfDomainsSet(Decomposition,NumberOfComputationalNodes,Err)
- !Finish the decomposition
- CALL CMISSDecomposition_CreateFinish(Decomposition,Err)
-
- !Start to create a default (geometric) field on the region
- CALL CMISSField_Initialise(GeometricField,Err)
- CALL CMISSField_CreateStart(GeometricFieldUserNumber,Region,GeometricField,Err)
- !Set the decomposition to use
- CALL CMISSField_MeshDecompositionSet(GeometricField,Decomposition,Err)
- !Set the domain to be used by the field components.
- CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,1,1,Err)
- CALL CMISSField_ComponentMeshComponentSet(GeometricField,CMISS_FIELD_U_VARIABLE_TYPE,2,1,Err)
- !Finish creating the field
- CALL CMISSField_CreateFinish(GeometricField,Err)
- !Update the geometric field parameters
- CALL CMISSGeneratedMesh_GeometricParametersCalculate(GeneratedMesh,GeometricField,Err)
-
- !Export the fields
- CALL CMISSFields_Initialise(Fields,Err)
- CALL CMISSFields_Create(Region,Fields,Err)
- CALL CMISSFields_NodesExport(Fields,"QuadraticTriangleSimplex","FORTRAN",Err)
- CALL CMISSFields_ElementsExport(Fields,"QuadraticTriangleSimplex","FORTRAN",Err)
- CALL CMISSFields_Finalise(Fields,Err)
-
- !Finialise CMISS
- CALL CMISSFinalise(Err)
- WRITE(*,'(A)') "Program successfully completed."
-
- STOP
-
- END PROGRAM QUADRATICTRIANGLESIMPLEXEXAMPLE