Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Contexts #6

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions src/fortran/cantilever.F90
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
!> Main program
PROGRAM CANTILEVEREXAMPLE
PROGRAM CantileverExample

USE OpenCMISS
USE OpenCMISS_Iron
Expand Down Expand Up @@ -60,7 +60,9 @@ PROGRAM CANTILEVEREXAMPLE
!CMISS variables
TYPE(cmfe_BasisType) :: DisplacementBasis,PressureBasis
TYPE(cmfe_BoundaryConditionsType) :: BoundaryConditions
TYPE(cmfe_CoordinateSystemType) :: CoordinateSystem, WorldCoordinateSystem
TYPE(cmfe_ComputationEnvironmentType) :: computationEnvironment
TYPE(cmfe_ContextType) :: context
TYPE(cmfe_CoordinateSystemType) :: CoordinateSystem
TYPE(cmfe_MeshType) :: Mesh
TYPE(cmfe_DecompositionType) :: Decomposition
TYPE(cmfe_EquationsType) :: Equations
Expand Down Expand Up @@ -94,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
Expand Down Expand Up @@ -163,14 +168,16 @@ 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_Context_ComputationEnvironmentGet(context,computationEnvironment,err)
CALL cmfe_ComputationEnvironment_NumberOfWorldNodesGet(computationEnvironment,numberOfComputationalNodes,err)
CALL cmfe_ComputationEnvironment_WorldNodeNumberGet(computationEnvironment,computationalNodeNumber,err)

NumberOfDomains=NumberOfComputationalNodes

!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
Expand All @@ -182,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)
Expand All @@ -200,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)
Expand Down Expand Up @@ -342,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)

Expand Down Expand Up @@ -419,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."

Expand All @@ -434,5 +441,5 @@ SUBROUTINE HANDLE_ERROR(ERROR_STRING)
STOP
END SUBROUTINE HANDLE_ERROR

END PROGRAM CANTILEVEREXAMPLE
END PROGRAM CantileverExample

19 changes: 12 additions & 7 deletions src/python/cantilever.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])

Expand All @@ -45,12 +48,14 @@
numberOfXi = 3

# Get the number of computational nodes and this computational node number
numberOfComputationalNodes = iron.ComputationalNumberOfNodesGet()
computationalNodeNumber = iron.ComputationalNodeNumberGet()
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()

Expand All @@ -63,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):
Expand All @@ -77,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):
Expand Down Expand Up @@ -225,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
Expand All @@ -240,7 +245,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)
Expand Down