From 9aa3a12aa9198e5f8b1bbc308123c1ee1b5aa070 Mon Sep 17 00:00:00 2001 From: Chris Bradley Date: Tue, 10 Apr 2018 14:39:04 +1200 Subject: [PATCH 1/2] Update for new computation environment routines. --- src/fortran/cantilever.F90 | 6 ++++-- src/python/cantilever.py | 7 ++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/fortran/cantilever.F90 b/src/fortran/cantilever.F90 index 949f418..5ef8f9f 100644 --- a/src/fortran/cantilever.F90 +++ b/src/fortran/cantilever.F90 @@ -60,6 +60,7 @@ PROGRAM CANTILEVEREXAMPLE !CMISS variables TYPE(cmfe_BasisType) :: DisplacementBasis,PressureBasis TYPE(cmfe_BoundaryConditionsType) :: BoundaryConditions + TYPE(cmfe_ComputationEnvironmentType) :: computationEnvironment TYPE(cmfe_CoordinateSystemType) :: CoordinateSystem, WorldCoordinateSystem TYPE(cmfe_MeshType) :: Mesh TYPE(cmfe_DecompositionType) :: Decomposition @@ -163,8 +164,9 @@ PROGRAM CANTILEVEREXAMPLE WRITE(*,'("Scaling type: ", i3)') ScalingType !Get the number of computational nodes and this computational node number - CALL cmfe_ComputationalNumberOfNodesGet(NumberOfComputationalNodes,Err) - CALL cmfe_ComputationalNodeNumberGet(ComputationalNodeNumber,Err) + CALL cmfe_ComputationEnvironment_Initialise(computationEnvironment,err) + CALL cmfe_ComputationEnvironment_NumberOfWorldNodesGet(computationEnvironment,numberOfComputationalNodes,err) + CALL cmfe_ComputationEnvironment_WorldNodeNumberGet(computationEnvironment,computationalNodeNumber,err) NumberOfDomains=NumberOfComputationalNodes diff --git a/src/python/cantilever.py b/src/python/cantilever.py index bdcf7e1..c5bf187 100644 --- a/src/python/cantilever.py +++ b/src/python/cantilever.py @@ -45,8 +45,9 @@ numberOfXi = 3 # Get the number of computational nodes and this computational node number -numberOfComputationalNodes = iron.ComputationalNumberOfNodesGet() -computationalNodeNumber = iron.ComputationalNodeNumberGet() +computationEnvironment = iron.ComputationEnvironment() +numberOfComputationalNodes = computationEnvironment.NumberOfWorldNodesGet() +computationalNodeNumber = computationEnvironment.WorldNodeNumberGet() # Create a 3D rectangular cartesian coordinate system coordinateSystem = iron.CoordinateSystem() @@ -240,7 +241,7 @@ linearSolver = iron.Solver() problem.SolversCreateStart() problem.SolverGet([iron.ControlLoopIdentifiers.NODE],1,nonLinearSolver) -nonLinearSolver.outputType = iron.SolverOutputTypes.PROGRESS +nonLinearSolver.outputType = iron.SolverOutputTypes.MONITOR nonLinearSolver.NewtonJacobianCalculationTypeSet(iron.JacobianCalculationTypes.FD) nonLinearSolver.NewtonAbsoluteToleranceSet(1e-14) nonLinearSolver.NewtonSolutionToleranceSet(1e-14) From 9b0646ef01cecd14dd23791c8004f2eaea8ccdaf Mon Sep 17 00:00:00 2001 From: Chris Bradley Date: Fri, 27 Apr 2018 20:03:42 +1200 Subject: [PATCH 2/2] Fixes for contexts. --- src/fortran/cantilever.F90 | 25 +++++++++++++++---------- src/python/cantilever.py | 12 ++++++++---- 2 files changed, 23 insertions(+), 14 deletions(-) diff --git a/src/fortran/cantilever.F90 b/src/fortran/cantilever.F90 index 5ef8f9f..822d60b 100644 --- a/src/fortran/cantilever.F90 +++ b/src/fortran/cantilever.F90 @@ -1,5 +1,5 @@ !> Main program -PROGRAM CANTILEVEREXAMPLE +PROGRAM CantileverExample USE OpenCMISS USE OpenCMISS_Iron @@ -61,7 +61,8 @@ PROGRAM CANTILEVEREXAMPLE TYPE(cmfe_BasisType) :: DisplacementBasis,PressureBasis TYPE(cmfe_BoundaryConditionsType) :: BoundaryConditions TYPE(cmfe_ComputationEnvironmentType) :: computationEnvironment - TYPE(cmfe_CoordinateSystemType) :: CoordinateSystem, WorldCoordinateSystem + TYPE(cmfe_ContextType) :: context + TYPE(cmfe_CoordinateSystemType) :: CoordinateSystem TYPE(cmfe_MeshType) :: Mesh TYPE(cmfe_DecompositionType) :: Decomposition TYPE(cmfe_EquationsType) :: Equations @@ -95,8 +96,11 @@ PROGRAM CANTILEVEREXAMPLE #endif !Intialise cmiss - CALL cmfe_Initialise(WorldCoordinateSystem,WorldRegion,Err) - CALL cmfe_ErrorHandlingModeSet(CMFE_ERRORS_TRAP_ERROR,Err) + CALL cmfe_Context_Initialise(context,err) + CALL cmfe_Initialise(context,err) + CALL cmfe_ErrorHandlingModeSet(CMFE_ERRORS_TRAP_ERROR,err) + CALL cmfe_Region_Initialise(worldRegion,err) + CALL cmfe_Context_WorldRegionGet(context,worldRegion,err) CALL cmfe_OutputSetOn("Cantilever",Err) !Read in arguments and overwrite default values @@ -165,6 +169,7 @@ PROGRAM CANTILEVEREXAMPLE !Get the number of computational nodes and this computational node number CALL cmfe_ComputationEnvironment_Initialise(computationEnvironment,err) + CALL cmfe_Context_ComputationEnvironmentGet(context,computationEnvironment,err) CALL cmfe_ComputationEnvironment_NumberOfWorldNodesGet(computationEnvironment,numberOfComputationalNodes,err) CALL cmfe_ComputationEnvironment_WorldNodeNumberGet(computationEnvironment,computationalNodeNumber,err) @@ -172,7 +177,7 @@ PROGRAM CANTILEVEREXAMPLE !Create a 3D rectangular cartesian coordinate system CALL cmfe_CoordinateSystem_Initialise(CoordinateSystem,Err) - CALL cmfe_CoordinateSystem_CreateStart(CoordinateSystemUserNumber,CoordinateSystem,Err) + CALL cmfe_CoordinateSystem_CreateStart(CoordinateSystemUserNumber,context,CoordinateSystem,Err) CALL cmfe_CoordinateSystem_CreateFinish(CoordinateSystem,Err) !Create a region and assign the coordinate system to the region @@ -184,7 +189,7 @@ PROGRAM CANTILEVEREXAMPLE !Define basis function for displacement CALL cmfe_Basis_Initialise(DisplacementBasis,Err) - CALL cmfe_Basis_CreateStart(DisplacementBasisUserNumber,DisplacementBasis,Err) + CALL cmfe_Basis_CreateStart(DisplacementBasisUserNumber,context,DisplacementBasis,Err) SELECT CASE(DisplacementInterpolationType) CASE(1,2,3,4) CALL cmfe_Basis_TypeSet(DisplacementBasis,CMFE_BASIS_LAGRANGE_HERMITE_TP_TYPE,Err) @@ -202,7 +207,7 @@ PROGRAM CANTILEVEREXAMPLE IF(PressureMeshComponent/=1) THEN !Basis for pressure CALL cmfe_Basis_Initialise(PressureBasis,Err) - CALL cmfe_Basis_CreateStart(PressureBasisUserNumber,PressureBasis,Err) + CALL cmfe_Basis_CreateStart(PressureBasisUserNumber,context,PressureBasis,Err) SELECT CASE(PressureInterpolationType) CASE(1,2,3,4) CALL cmfe_Basis_TypeSet(PressureBasis,CMFE_BASIS_LAGRANGE_HERMITE_TP_TYPE,Err) @@ -344,7 +349,7 @@ PROGRAM CANTILEVEREXAMPLE !Define the problem CALL cmfe_Problem_Initialise(Problem,Err) - CALL cmfe_Problem_CreateStart(ProblemUserNumber,[CMFE_PROBLEM_ELASTICITY_CLASS,CMFE_PROBLEM_FINITE_ELASTICITY_TYPE, & + CALL cmfe_Problem_CreateStart(ProblemUserNumber,context,[CMFE_PROBLEM_ELASTICITY_CLASS,CMFE_PROBLEM_FINITE_ELASTICITY_TYPE, & & CMFE_PROBLEM_NO_SUBTYPE],Problem,Err) CALL cmfe_Problem_CreateFinish(Problem,Err) @@ -421,7 +426,7 @@ PROGRAM CANTILEVEREXAMPLE CALL cmfe_Fields_ElementsExport(Fields,"./results/Cantilever","FORTRAN",Err) CALL cmfe_Fields_Finalise(Fields,Err) - CALL cmfe_Finalise(Err) + CALL cmfe_Finalise(context,Err) WRITE(*,'(A)') "Program successfully completed." @@ -436,5 +441,5 @@ SUBROUTINE HANDLE_ERROR(ERROR_STRING) STOP END SUBROUTINE HANDLE_ERROR -END PROGRAM CANTILEVEREXAMPLE +END PROGRAM CantileverExample diff --git a/src/python/cantilever.py b/src/python/cantilever.py index c5bf187..0d79e24 100644 --- a/src/python/cantilever.py +++ b/src/python/cantilever.py @@ -31,6 +31,9 @@ equationsSetUserNumber = 1 problemUserNumber = 1 +worldRegion = iron.Region() +iron.Context.WorldRegionGet(worldRegion) + # Set all diganostic levels on for testing #iron.DiagnosticsSetOn(iron.DiagnosticTypes.All,[1,2,3,4,5],"Diagnostics",["DOMAIN_MAPPINGS_LOCAL_FROM_GLOBAL_CALCULATE"]) @@ -46,12 +49,13 @@ # Get the number of computational nodes and this computational node number computationEnvironment = iron.ComputationEnvironment() +iron.Context.ComputationEnvironmentGet(computationEnvironment) numberOfComputationalNodes = computationEnvironment.NumberOfWorldNodesGet() computationalNodeNumber = computationEnvironment.WorldNodeNumberGet() # Create a 3D rectangular cartesian coordinate system coordinateSystem = iron.CoordinateSystem() -coordinateSystem.CreateStart(coordinateSystemUserNumber) +coordinateSystem.CreateStart(coordinateSystemUserNumber,iron.Context) coordinateSystem.DimensionSet(3) coordinateSystem.CreateFinish() @@ -64,7 +68,7 @@ # Define basis basis = iron.Basis() -basis.CreateStart(basisUserNumber) +basis.CreateStart(basisUserNumber,iron.Context) if InterpolationType in (1,2,3,4): basis.type = iron.BasisTypes.LAGRANGE_HERMITE_TP elif InterpolationType in (7,8,9): @@ -78,7 +82,7 @@ if(usePressureBasis): # Define pressure basis pressureBasis = iron.Basis() - pressureBasis.CreateStart(pressureBasisUserNumber) + pressureBasis.CreateStart(pressureBasisUserNumber,iron.Context) if InterpolationType in (1,2,3,4): pressureBasis.type = iron.BasisTypes.LAGRANGE_HERMITE_TP elif InterpolationType in (7,8,9): @@ -226,7 +230,7 @@ problemSpecification = [iron.ProblemClasses.ELASTICITY, iron.ProblemTypes.FINITE_ELASTICITY, iron.ProblemSubtypes.NONE] -problem.CreateStart(problemUserNumber, problemSpecification) +problem.CreateStart(problemUserNumber,iron.Context,problemSpecification) problem.CreateFinish() # Create the problem control loop