From cc9a743e6e29c42eee265940191f9a7738dcaab1 Mon Sep 17 00:00:00 2001 From: lorenzo-mechbau Date: Thu, 14 Feb 2019 20:35:08 +1300 Subject: [PATCH 1/9] Backsubstitute fix --- src/equations_set_routines.F90 | 52 ++++++++++++++++++++++++++++++---- 1 file changed, 46 insertions(+), 6 deletions(-) diff --git a/src/equations_set_routines.F90 b/src/equations_set_routines.F90 index 10437fa8..2668e47e 100644 --- a/src/equations_set_routines.F90 +++ b/src/equations_set_routines.F90 @@ -1647,6 +1647,7 @@ SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,err !Local Variables INTEGER(INTG) :: equations_column_idx,equations_column_number,equations_matrix_idx,equations_row_number, & & EQUATIONS_STORAGE_TYPE,rhs_boundary_condition,rhs_global_dof,rhs_variable_dof,rhsVariableType,variable_dof,VARIABLE_TYPE + INTEGER(INTG) :: myComputationalNodeNumber, eqColLocalIdx, domain_idx INTEGER(INTG), POINTER :: COLUMN_INDICES(:),ROW_INDICES(:) REAL(DP) :: DEPENDENT_VALUE,MATRIX_VALUE,RHS_VALUE,SOURCE_VALUE REAL(DP), POINTER :: DEPENDENT_PARAMETERS(:),equationsMatrixData(:),sourceVectorData(:) @@ -1675,6 +1676,8 @@ SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,err ENTERS("EQUATIONS_SET_BACKSUBSTITUTE",err,error,*999) + myComputationalNodeNumber=ComputationalEnvironment_NodeNumberGet(err,error) + IF(ASSOCIATED(equationsSet)) THEN IF(equationsSet%EQUATIONS_SET_FINISHED) THEN dependentField=>equationsSet%DEPENDENT%DEPENDENT_FIELD @@ -1740,7 +1743,7 @@ SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,err CALL DistributedMatrix_DataGet(EQUATIONS_DISTRIBUTED_MATRIX,equationsMatrixData, & & err,error,*999) SELECT CASE(EQUATIONS_STORAGE_TYPE) - CASE(DISTRIBUTED_MATRIX_BLOCK_STORAGE_TYPE) + CASE(DISTRIBUTED_MATRIX_BLOCK_STORAGE_TYPE) ! = sparsity: full !Loop over the non ghosted rows in the equations set DO equations_row_number=1,vectorMapping%numberOfRows RHS_VALUE=0.0_DP @@ -1792,6 +1795,7 @@ SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,err & ROW_INDICES,COLUMN_INDICES,err,error,*999) !Loop over the non-ghosted rows in the equations set DO equations_row_number=1,vectorMapping%numberOfRows + ! Same as other case (BLOCK) RHS_VALUE=0.0_DP rhs_variable_dof=rhsMapping%equationsRowToRHSDOFMap(equations_row_number) rhs_global_dof=RHS_DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP(rhs_variable_dof) @@ -1799,15 +1803,51 @@ SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,err SELECT CASE(rhs_boundary_condition) CASE(BOUNDARY_CONDITION_DOF_FREE) !Back substitute - !Loop over the local columns of the equations matrix + !Loop over the global columns of the equations matrix in the selected row DO equations_column_idx=ROW_INDICES(equations_row_number), & ROW_INDICES(equations_row_number+1)-1 + ! Get the GLOBAL column index equations_column_number=COLUMN_INDICES(equations_column_idx) - variable_dof=equations_column_idx-ROW_INDICES(equations_row_number)+1 - MATRIX_VALUE=equationsMatrixData(equations_column_idx) - DEPENDENT_VALUE=DEPENDENT_PARAMETERS(variable_dof) - RHS_VALUE=RHS_VALUE+MATRIX_VALUE*DEPENDENT_VALUE + ! Get the LOCAL column index for all domains + DO domain_idx=1,COLUMN_DOMAIN_MAPPING%GLOBAL_TO_LOCAL_MAP & + & (equations_column_number)%NUMBER_OF_DOMAINS + ! Select the current domain (=rank) + IF (COLUMN_DOMAIN_MAPPING%GLOBAL_TO_LOCAL_MAP & + & (equations_column_number)%DOMAIN_NUMBER(domain_idx) & + & == myComputationalNodeNumber) THEN + ! Get the local dof on the current domain + eqColLocalIdx = & + & COLUMN_DOMAIN_MAPPING%GLOBAL_TO_LOCAL_MAP & + & (equations_column_number)%LOCAL_NUMBER(domain_idx) + ! We do not consider ghosts + IF (eqColLocalIdx <= & + & COLUMN_DOMAIN_MAPPING%TOTAL_NUMBER_OF_LOCAL) THEN + ! Local dof on rhs + variable_dof=eqColLocalIdx!equations_column_number + ! original line: delete! + ! variable_dof = equations_column_idx-ROW_INDICES(equations_row_number)+1 + ! Global dof in matrix + MATRIX_VALUE=equationsMatrixData(equations_column_idx) + DEPENDENT_VALUE=DEPENDENT_PARAMETERS(variable_dof) + RHS_VALUE=RHS_VALUE+MATRIX_VALUE*DEPENDENT_VALUE + END IF + END IF + END DO ENDDO !equations_column_idx + + !CASE block storage (=FULL) above + !Back substitute + !Loop over the local columns of the equations matrix + !DO equations_column_idx=1,COLUMN_DOMAIN_MAPPING%TOTAL_NUMBER_OF_LOCAL + ! equations_column_number=COLUMN_DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP( & + ! & equations_column_idx) + ! variable_dof=equations_column_idx + ! MATRIX_VALUE=equationsMatrixData(equations_row_number+ & + ! & (equations_column_number-1)*vectorMatrices%totalNumberOfRows) + ! DEPENDENT_VALUE=DEPENDENT_PARAMETERS(variable_dof) + ! RHS_VALUE=RHS_VALUE+MATRIX_VALUE*DEPENDENT_VALUE + !ENDDO !equations_column_idx + CASE(BOUNDARY_CONDITION_DOF_FIXED) !Do nothing CASE(BOUNDARY_CONDITION_DOF_MIXED) From feaa514a63fda48534774aa134762f8257c58b2f Mon Sep 17 00:00:00 2001 From: lorenzo-mechbau Date: Fri, 15 Feb 2019 10:30:12 +1300 Subject: [PATCH 2/9] Clean up comments --- src/equations_set_routines.F90 | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/src/equations_set_routines.F90 b/src/equations_set_routines.F90 index 2668e47e..f9c5c439 100644 --- a/src/equations_set_routines.F90 +++ b/src/equations_set_routines.F90 @@ -1795,7 +1795,7 @@ SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,err & ROW_INDICES,COLUMN_INDICES,err,error,*999) !Loop over the non-ghosted rows in the equations set DO equations_row_number=1,vectorMapping%numberOfRows - ! Same as other case (BLOCK) + ! This bit is the same as the BLOCK case RHS_VALUE=0.0_DP rhs_variable_dof=rhsMapping%equationsRowToRHSDOFMap(equations_row_number) rhs_global_dof=RHS_DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP(rhs_variable_dof) @@ -1808,14 +1808,14 @@ SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,err ROW_INDICES(equations_row_number+1)-1 ! Get the GLOBAL column index equations_column_number=COLUMN_INDICES(equations_column_idx) - ! Get the LOCAL column index for all domains + ! Get the LOCAL column index for all domains (=ranks) DO domain_idx=1,COLUMN_DOMAIN_MAPPING%GLOBAL_TO_LOCAL_MAP & & (equations_column_number)%NUMBER_OF_DOMAINS - ! Select the current domain (=rank) + ! Select the current domain IF (COLUMN_DOMAIN_MAPPING%GLOBAL_TO_LOCAL_MAP & & (equations_column_number)%DOMAIN_NUMBER(domain_idx) & & == myComputationalNodeNumber) THEN - ! Get the local dof on the current domain + ! Get the local dof (column index) on the current domain eqColLocalIdx = & & COLUMN_DOMAIN_MAPPING%GLOBAL_TO_LOCAL_MAP & & (equations_column_number)%LOCAL_NUMBER(domain_idx) @@ -1823,30 +1823,15 @@ SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,err IF (eqColLocalIdx <= & & COLUMN_DOMAIN_MAPPING%TOTAL_NUMBER_OF_LOCAL) THEN ! Local dof on rhs - variable_dof=eqColLocalIdx!equations_column_number - ! original line: delete! - ! variable_dof = equations_column_idx-ROW_INDICES(equations_row_number)+1 - ! Global dof in matrix + variable_dof=eqColLocalIdx + ! Global dof in compressed matrix MATRIX_VALUE=equationsMatrixData(equations_column_idx) DEPENDENT_VALUE=DEPENDENT_PARAMETERS(variable_dof) RHS_VALUE=RHS_VALUE+MATRIX_VALUE*DEPENDENT_VALUE END IF END IF END DO - ENDDO !equations_column_idx - - !CASE block storage (=FULL) above - !Back substitute - !Loop over the local columns of the equations matrix - !DO equations_column_idx=1,COLUMN_DOMAIN_MAPPING%TOTAL_NUMBER_OF_LOCAL - ! equations_column_number=COLUMN_DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP( & - ! & equations_column_idx) - ! variable_dof=equations_column_idx - ! MATRIX_VALUE=equationsMatrixData(equations_row_number+ & - ! & (equations_column_number-1)*vectorMatrices%totalNumberOfRows) - ! DEPENDENT_VALUE=DEPENDENT_PARAMETERS(variable_dof) - ! RHS_VALUE=RHS_VALUE+MATRIX_VALUE*DEPENDENT_VALUE - !ENDDO !equations_column_idx + END DO !equations_column_idx CASE(BOUNDARY_CONDITION_DOF_FIXED) !Do nothing From 7535227ad0751744fcb98fc186804e0ff0366d61 Mon Sep 17 00:00:00 2001 From: lorenzo-mechbau Date: Mon, 18 Feb 2019 13:46:07 +1300 Subject: [PATCH 3/9] In backsubstitute, no dof update if the dof is fixed. --- src/equations_set_routines.F90 | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/equations_set_routines.F90 b/src/equations_set_routines.F90 index f9c5c439..7a18beca 100644 --- a/src/equations_set_routines.F90 +++ b/src/equations_set_routines.F90 @@ -1765,6 +1765,12 @@ SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,err DEPENDENT_VALUE=DEPENDENT_PARAMETERS(variable_dof) RHS_VALUE=RHS_VALUE+MATRIX_VALUE*DEPENDENT_VALUE ENDDO !equations_column_idx + IF(ASSOCIATED(sourceMapping)) THEN + SOURCE_VALUE=sourceVectorData(equations_row_number) + RHS_VALUE=RHS_VALUE-SOURCE_VALUE + ENDIF + CALL Field_ParameterSetUpdateLocalDOF(dependentField,rhsVariableType, & + & FIELD_VALUES_SET_TYPE,rhs_variable_dof,RHS_VALUE,err,error,*999) CASE(BOUNDARY_CONDITION_DOF_FIXED) !Do nothing CASE(BOUNDARY_CONDITION_DOF_MIXED) @@ -1777,12 +1783,6 @@ SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,err & TRIM(NumberToVString(rhs_variable_dof,"*",err,error))//" is invalid." CALL FlagError(localError,err,error,*999) END SELECT - IF(ASSOCIATED(sourceMapping)) THEN - SOURCE_VALUE=sourceVectorData(equations_row_number) - RHS_VALUE=RHS_VALUE-SOURCE_VALUE - ENDIF - CALL Field_ParameterSetUpdateLocalDOF(dependentField,rhsVariableType, & - & FIELD_VALUES_SET_TYPE,rhs_variable_dof,RHS_VALUE,err,error,*999) ENDDO !equations_row_number CASE(DISTRIBUTED_MATRIX_DIAGONAL_STORAGE_TYPE) CALL FlagError("Not implemented.",err,error,*999) @@ -1832,7 +1832,12 @@ SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,err END IF END DO END DO !equations_column_idx - + IF(ASSOCIATED(sourceMapping)) THEN + SOURCE_VALUE=sourceVectorData(equations_row_number) + RHS_VALUE=RHS_VALUE-SOURCE_VALUE + ENDIF + CALL Field_ParameterSetUpdateLocalDOF(dependentField,rhsVariableType, & + & FIELD_VALUES_SET_TYPE,rhs_variable_dof,RHS_VALUE,err,error,*999) CASE(BOUNDARY_CONDITION_DOF_FIXED) !Do nothing CASE(BOUNDARY_CONDITION_DOF_MIXED) @@ -1845,12 +1850,6 @@ SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,err & TRIM(NumberToVString(rhs_variable_dof,"*",err,error))//" is invalid." CALL FlagError(localError,err,error,*999) END SELECT - IF(ASSOCIATED(sourceMapping)) THEN - SOURCE_VALUE=sourceVectorData(equations_row_number) - RHS_VALUE=RHS_VALUE-SOURCE_VALUE - ENDIF - CALL Field_ParameterSetUpdateLocalDOF(dependentField,rhsVariableType, & - & FIELD_VALUES_SET_TYPE,rhs_variable_dof,RHS_VALUE,err,error,*999) ENDDO !equations_row_number CASE(DISTRIBUTED_MATRIX_COMPRESSED_COLUMN_STORAGE_TYPE) CALL FlagError("Not implemented.",err,error,*999) From 0dd1834a1c8cc5970847c320f98742cad54f5c6e Mon Sep 17 00:00:00 2001 From: lorenzo-mechbau Date: Tue, 19 Feb 2019 17:43:27 +1300 Subject: [PATCH 4/9] Added backsubstitute nonlinear (not to be used), must be fixed. --- src/equations_set_routines.F90 | 324 ++++++++++++++++++++++++++++++++- 1 file changed, 323 insertions(+), 1 deletion(-) diff --git a/src/equations_set_routines.F90 b/src/equations_set_routines.F90 index 7a18beca..9ce229d9 100644 --- a/src/equations_set_routines.F90 +++ b/src/equations_set_routines.F90 @@ -109,7 +109,7 @@ MODULE EQUATIONS_SET_ROUTINES PUBLIC EQUATIONS_SET_ASSEMBLE - PUBLIC EQUATIONS_SET_BACKSUBSTITUTE,EQUATIONS_SET_NONLINEAR_RHS_UPDATE + PUBLIC EQUATIONS_SET_BACKSUBSTITUTE,EQUATIONS_SET_NONLINEAR_RHS_UPDATE, EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE PUBLIC EQUATIONS_SET_BOUNDARY_CONDITIONS_ANALYTIC @@ -1939,6 +1939,328 @@ END SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE !================================================================================================================================ ! + !>Backsubstitutes with an equations set to calculate unknown right hand side vectors for the nonlinear case + !>This is a draft!!! Still gives + !>Computes the BS for ALL rhs dofs: select case free/fixed/mixed should be uncommented (sparse case) + SUBROUTINE EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,error,*) + + !Argument variables + TYPE(EQUATIONS_SET_TYPE), POINTER :: equationsSet !equationsSet%DEPENDENT%DEPENDENT_FIELD + IF(ASSOCIATED(dependentField)) THEN + equations=>equationsSet%EQUATIONS + IF(ASSOCIATED(EQUATIONS)) THEN + NULLIFY(vectorEquations) + CALL Equations_VectorEquationsGet(equations,vectorEquations,err,error,*999) + vectorMatrices=>vectorEquations%vectorMatrices + IF(ASSOCIATED(vectorMatrices)) THEN + dynamicMatrices=>vectorMatrices%dynamicMatrices + IF(ASSOCIATED(dynamicMatrices)) THEN + !CALL FlagError("Not implemented.",err,error,*999) + ELSE + linearMatrices=>vectorMatrices%nonlinearMatrices + IF(ASSOCIATED(linearMatrices)) THEN + vectorMapping=>vectorEquations%vectorMapping + IF(ASSOCIATED(vectorMapping)) THEN + linearMapping=>vectorMapping%nonlinearMapping + IF(ASSOCIATED(linearMapping)) THEN + rhsMapping=>vectorMapping%rhsMapping + sourceMapping=>vectorMapping%sourceMapping + IF(ASSOCIATED(rhsMapping)) THEN + IF(ASSOCIATED(BOUNDARY_CONDITIONS)) THEN + IF(ASSOCIATED(sourceMapping)) THEN + sourceVector=>vectorMatrices%sourceVector + IF(ASSOCIATED(sourceVector)) THEN + SOURCE_DISTRIBUTED_VECTOR=>sourceVector%vector + IF(ASSOCIATED(SOURCE_DISTRIBUTED_VECTOR)) THEN + CALL DistributedVector_DataGet(SOURCE_DISTRIBUTED_VECTOR,sourceVectorData,err,error,*999) + ELSE + CALL FlagError("Source distributed vector is not associated.",err,error,*999) + ENDIF + ELSE + CALL FlagError("Source vector is not associated.",err,error,*999) + ENDIF + ENDIF + rhsVariable=>rhsMapping%rhsVariable + IF(ASSOCIATED(rhsVariable)) THEN + rhsVariableType=rhsVariable%VARIABLE_TYPE + RHS_DOMAIN_MAPPING=>rhsVariable%DOMAIN_MAPPING + IF(ASSOCIATED(RHS_DOMAIN_MAPPING)) THEN + CALL BOUNDARY_CONDITIONS_VARIABLE_GET(BOUNDARY_CONDITIONS,rhsVariable,RHS_BOUNDARY_CONDITIONS, & + & err,error,*999) + IF(ASSOCIATED(RHS_BOUNDARY_CONDITIONS)) THEN + !Loop over the equations matrices + DO equations_matrix_idx=1,linearMatrices%numberOfJacobians + DEPENDENT_VARIABLE=>linearMapping%jacobianToVarMap(equations_matrix_idx)%VARIABLE + IF(ASSOCIATED(DEPENDENT_VARIABLE)) THEN + VARIABLE_TYPE=DEPENDENT_VARIABLE%VARIABLE_TYPE + !Get the dependent field variable parameters + CALL Field_ParameterSetDataGet(dependentField,VARIABLE_TYPE,FIELD_VALUES_SET_TYPE, & + & DEPENDENT_PARAMETERS,err,error,*999) + equationsMatrix=>linearMatrices%jacobians(equations_matrix_idx)%ptr + IF(ASSOCIATED(equationsMatrix)) THEN + COLUMN_DOMAIN_MAPPING=>linearMapping%jacobianToVarMap(equations_matrix_idx)% & + & columnDOFSMapping + IF(ASSOCIATED(COLUMN_DOMAIN_MAPPING)) THEN + EQUATIONS_DISTRIBUTED_MATRIX=>equationsMatrix%jacobian + IF(ASSOCIATED(EQUATIONS_DISTRIBUTED_MATRIX)) THEN + CALL DistributedMatrix_StorageTypeGet(EQUATIONS_DISTRIBUTED_MATRIX, & + & EQUATIONS_STORAGE_TYPE,err,error,*999) + CALL DistributedMatrix_DataGet(EQUATIONS_DISTRIBUTED_MATRIX,equationsMatrixData, & + & err,error,*999) + SELECT CASE(EQUATIONS_STORAGE_TYPE) + CASE(DISTRIBUTED_MATRIX_BLOCK_STORAGE_TYPE) ! = sparsity: full + !Loop over the non ghosted rows in the equations set + DO equations_row_number=1,vectorMapping%numberOfRows + RHS_VALUE=0.0_DP + rhs_variable_dof=rhsMapping%equationsRowToRHSDOFMap(equations_row_number) + rhs_global_dof=RHS_DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP(rhs_variable_dof) + rhs_boundary_condition=RHS_BOUNDARY_CONDITIONS%DOF_TYPES(rhs_global_dof) + !For free RHS DOFs, set the right hand side field values by multiplying the + !row by the dependent variable value + SELECT CASE(rhs_boundary_condition) + CASE(BOUNDARY_CONDITION_DOF_FREE) + !Back substitute + !Loop over the local columns of the equations matrix + DO equations_column_idx=1,COLUMN_DOMAIN_MAPPING%TOTAL_NUMBER_OF_LOCAL + equations_column_number=COLUMN_DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP( & + & equations_column_idx) + variable_dof=equations_column_idx + MATRIX_VALUE=equationsMatrixData(equations_row_number+ & + & (equations_column_number-1)*vectorMatrices%totalNumberOfRows) + DEPENDENT_VALUE=DEPENDENT_PARAMETERS(variable_dof) + RHS_VALUE=RHS_VALUE+MATRIX_VALUE*DEPENDENT_VALUE + ENDDO !equations_column_idx + IF(ASSOCIATED(sourceMapping)) THEN + SOURCE_VALUE=sourceVectorData(equations_row_number) + RHS_VALUE=RHS_VALUE-SOURCE_VALUE + ENDIF + CALL Field_ParameterSetUpdateLocalDOF(dependentField,rhsVariableType, & + & FIELD_VALUES_SET_TYPE,rhs_variable_dof,RHS_VALUE,err,error,*999) + CASE(BOUNDARY_CONDITION_DOF_FIXED) + !Do nothing + CASE(BOUNDARY_CONDITION_DOF_MIXED) + !Robin or is it Cauchy??? boundary conditions + CALL FlagError("Not implemented.",err,error,*999) + CASE DEFAULT + localError="The RHS variable boundary condition of "// & + & TRIM(NumberToVString(rhs_boundary_condition,"*",err,error))// & + & " for RHS variable dof number "// & + & TRIM(NumberToVString(rhs_variable_dof,"*",err,error))//" is invalid." + CALL FlagError(localError,err,error,*999) + END SELECT + ENDDO !equations_row_number + CASE(DISTRIBUTED_MATRIX_DIAGONAL_STORAGE_TYPE) + CALL FlagError("Not implemented.",err,error,*999) + CASE(DISTRIBUTED_MATRIX_COLUMN_MAJOR_STORAGE_TYPE) + CALL FlagError("Not implemented.",err,error,*999) + CASE(DISTRIBUTED_MATRIX_ROW_MAJOR_STORAGE_TYPE) + CALL FlagError("Not implemented.",err,error,*999) + CASE(DISTRIBUTED_MATRIX_COMPRESSED_ROW_STORAGE_TYPE) + CALL DistributedMatrix_StorageLocationsGet(EQUATIONS_DISTRIBUTED_MATRIX, & + & ROW_INDICES,COLUMN_INDICES,err,error,*999) + !Loop over the non-ghosted rows in the equations set + DO equations_row_number=1,vectorMapping%numberOfRows + ! Same as other case (BLOCK) + RHS_VALUE=0.0_DP + rhs_variable_dof=rhsMapping%equationsRowToRHSDOFMap(equations_row_number) + rhs_global_dof=RHS_DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP(rhs_variable_dof) + rhs_boundary_condition=RHS_BOUNDARY_CONDITIONS%DOF_TYPES(rhs_global_dof) + !SELECT CASE(rhs_boundary_condition) + !CASE(BOUNDARY_CONDITION_DOF_FREE) + !Back substitute + !Loop over the global columns of the equations matrix in the selected row + DO equations_column_idx=ROW_INDICES(equations_row_number), & + ROW_INDICES(equations_row_number+1)-1 + ! Get the GLOBAL column index + equations_column_number=COLUMN_INDICES(equations_column_idx) + ! Get the LOCAL column index for all domains + DO domain_idx=1,COLUMN_DOMAIN_MAPPING%GLOBAL_TO_LOCAL_MAP & + & (equations_column_number)%NUMBER_OF_DOMAINS + ! Select the current domain (=rank) + IF (COLUMN_DOMAIN_MAPPING%GLOBAL_TO_LOCAL_MAP & + & (equations_column_number)%DOMAIN_NUMBER(domain_idx) & + & == myComputationalNodeNumber) THEN + ! Get the local dof on the current domain + eqColLocalIdx = & + & COLUMN_DOMAIN_MAPPING%GLOBAL_TO_LOCAL_MAP & + & (equations_column_number)%LOCAL_NUMBER(domain_idx) + ! We do not consider ghosts + IF (eqColLocalIdx <= & + & COLUMN_DOMAIN_MAPPING%TOTAL_NUMBER_OF_LOCAL) THEN + ! Local dof on rhs + variable_dof=eqColLocalIdx!equations_column_number + ! original line: delete! + ! variable_dof = equations_column_idx-ROW_INDICES(equations_row_number)+1 + ! Global dof in matrix + MATRIX_VALUE=equationsMatrixData(equations_column_idx) + DEPENDENT_VALUE=DEPENDENT_PARAMETERS(variable_dof) + RHS_VALUE=RHS_VALUE+MATRIX_VALUE*DEPENDENT_VALUE + END IF + END IF + END DO + ENDDO !equations_column_idx + + IF(ASSOCIATED(sourceMapping)) THEN + SOURCE_VALUE=sourceVectorData(equations_row_number) + RHS_VALUE=RHS_VALUE-SOURCE_VALUE + ENDIF + CALL Field_ParameterSetUpdateLocalDOF(dependentField,rhsVariableType, & + & FIELD_VALUES_SET_TYPE,rhs_variable_dof,RHS_VALUE,err,error,*999) + + !CASE block storage (=FULL) above + !Back substitute + !Loop over the local columns of the equations matrix + !DO equations_column_idx=1,COLUMN_DOMAIN_MAPPING%TOTAL_NUMBER_OF_LOCAL + ! equations_column_number=COLUMN_DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP( & + ! & equations_column_idx) + ! variable_dof=equations_column_idx + ! MATRIX_VALUE=equationsMatrixData(equations_row_number+ & + ! & (equations_column_number-1)*vectorMatrices%totalNumberOfRows) + ! DEPENDENT_VALUE=DEPENDENT_PARAMETERS(variable_dof) + ! RHS_VALUE=RHS_VALUE+MATRIX_VALUE*DEPENDENT_VALUE + !ENDDO !equations_column_idx + + !CASE(BOUNDARY_CONDITION_DOF_FIXED) + !Do nothing + !CASE(BOUNDARY_CONDITION_DOF_MIXED) + !Robin or is it Cauchy??? boundary conditions + ! CALL FlagError("Not implemented.",err,error,*999) + !CASE DEFAULT + ! localError="The global boundary condition of "// & + ! & TRIM(NumberToVString(rhs_boundary_condition,"*",err,error))// & + ! & " for RHS variable dof number "// & + ! & TRIM(NumberToVString(rhs_variable_dof,"*",err,error))//" is invalid." + ! CALL FlagError(localError,err,error,*999) + !END SELECT + ENDDO !equations_row_number + CASE(DISTRIBUTED_MATRIX_COMPRESSED_COLUMN_STORAGE_TYPE) + CALL FlagError("Not implemented.",err,error,*999) + CASE(DISTRIBUTED_MATRIX_ROW_COLUMN_STORAGE_TYPE) + CALL FlagError("Not implemented.",err,error,*999) + CASE DEFAULT + localError="The matrix storage type of "// & + & TRIM(NumberToVString(EQUATIONS_STORAGE_TYPE,"*",err,error))//" is invalid." + CALL FlagError(localError,err,error,*999) + END SELECT + CALL DistributedMatrix_DataRestore(EQUATIONS_DISTRIBUTED_MATRIX,equationsMatrixData, & + & err,error,*999) + ELSE + CALL FlagError("Equations matrix distributed matrix is not associated.",err,error,*999) + ENDIF + ELSE + CALL FlagError("Equations column domain mapping is not associated.",err,error,*999) + ENDIF + ELSE + CALL FlagError("Equations equations matrix is not associated.",err,error,*999) + ENDIF + !Restore the dependent field variable parameters + CALL Field_ParameterSetDataRestore(dependentField,VARIABLE_TYPE,FIELD_VALUES_SET_TYPE, & + & DEPENDENT_PARAMETERS,err,error,*999) + ELSE + CALL FlagError("Dependent variable is not associated.",err,error,*999) + ENDIF + ENDDO !equations_matrix_idx + !Start the update of the field parameters + CALL Field_ParameterSetUpdateStart(dependentField,rhsVariableType,FIELD_VALUES_SET_TYPE, & + & err,error,*999) + !Finish the update of the field parameters + CALL Field_ParameterSetUpdateFinish(dependentField,rhsVariableType,FIELD_VALUES_SET_TYPE, & + & err,error,*999) + ELSE + CALL FlagError("RHS boundary conditions variable is not associated.",err,error,*999) + ENDIF + ELSE + CALL FlagError("RHS variable domain mapping is not associated.",err,error,*999) + ENDIF + ELSE + CALL FlagError("RHS variable is not associated.",err,error,*999) + ENDIF + IF(ASSOCIATED(sourceMapping)) THEN + CALL DistributedVector_DataRestore(SOURCE_DISTRIBUTED_VECTOR,sourceVectorData,err,error,*999) + ENDIF + ELSE + CALL FlagError("Boundary conditions are not associated.",err,error,*999) + ENDIF + ELSE + CALL FlagError("Equations mapping RHS mappings is not associated.",err,error,*999) + ENDIF + ELSE + CALL FlagError("Equations mapping linear mapping is not associated.",err,error,*999) + ENDIF + ELSE + CALL FlagError("Equations mapping is not associated.",err,error,*999) + ENDIF + ELSE + CALL FlagError("Equations matrices linear matrices is not associated.",err,error,*999) + ENDIF + ENDIF + ELSE + CALL FlagError("Equations matrices is not associated.",err,error,*999) + ENDIF + ELSE + CALL FlagError("Equations is not associated.",err,error,*999) + ENDIF + ELSE + CALL FlagError("Dependent field is not associated.",err,error,*999) + ENDIF + ELSE + CALL FlagError("Equations set has not been finished.",err,error,*999) + ENDIF + ELSE + CALL FlagError("Equations set is not associated",err,error,*999) + ENDIF + + EXITS("EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE") + RETURN +999 ERRORSEXITS("EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE",err,error) + RETURN 1 + + END SUBROUTINE EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE + + ! + !================================================================================================================================ + ! + !>Updates the right hand side variable from the equations residual vector SUBROUTINE EQUATIONS_SET_NONLINEAR_RHS_UPDATE(equationsSet,BOUNDARY_CONDITIONS,err,error,*) From d7bb85005f98d88b13d130436c60148c8534c967 Mon Sep 17 00:00:00 2001 From: lorenzo-mechbau Date: Tue, 19 Feb 2019 17:45:33 +1300 Subject: [PATCH 5/9] Added backsubstitute nonlinear (commented) in problem_routines for statc nonlinear problems. --- src/problem_routines.F90 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/problem_routines.F90 b/src/problem_routines.F90 index 5121a2ea..78df310a 100644 --- a/src/problem_routines.F90 +++ b/src/problem_routines.F90 @@ -2679,6 +2679,9 @@ SUBROUTINE Problem_SolverEquationsStaticNonlinearSolve(SOLVER_EQUATIONS,err,erro CALL EQUATIONS_SET_BACKSUBSTITUTE(EQUATIONS_SET,SOLVER_EQUATIONS%BOUNDARY_CONDITIONS,err,error,*999) CASE(EQUATIONS_NONLINEAR) CALL EQUATIONS_SET_NONLINEAR_RHS_UPDATE(EQUATIONS_SET,SOLVER_EQUATIONS%BOUNDARY_CONDITIONS,err,error,*999) + ! Use backsubstitute also for the nonlinear case? + ! Still gives a complete vector of zeros, must be revised if one needs e.g. to compute the traction. + !CALL EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE(EQUATIONS_SET,SOLVER_EQUATIONS%BOUNDARY_CONDITIONS,err,error,*999) CASE DEFAULT CALL FlagError("Invalid linearity for equations set equations",err,error,*999) END SELECT From 1d6823e0248f5925df511d086c728b611c81e27e Mon Sep 17 00:00:00 2001 From: lorenzo-mechbau Date: Tue, 19 Feb 2019 18:02:24 +1300 Subject: [PATCH 6/9] Removed some comments. --- src/equations_set_routines.F90 | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/equations_set_routines.F90 b/src/equations_set_routines.F90 index 9ce229d9..7e7344af 100644 --- a/src/equations_set_routines.F90 +++ b/src/equations_set_routines.F90 @@ -2147,19 +2147,6 @@ SUBROUTINE EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIO CALL Field_ParameterSetUpdateLocalDOF(dependentField,rhsVariableType, & & FIELD_VALUES_SET_TYPE,rhs_variable_dof,RHS_VALUE,err,error,*999) - !CASE block storage (=FULL) above - !Back substitute - !Loop over the local columns of the equations matrix - !DO equations_column_idx=1,COLUMN_DOMAIN_MAPPING%TOTAL_NUMBER_OF_LOCAL - ! equations_column_number=COLUMN_DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP( & - ! & equations_column_idx) - ! variable_dof=equations_column_idx - ! MATRIX_VALUE=equationsMatrixData(equations_row_number+ & - ! & (equations_column_number-1)*vectorMatrices%totalNumberOfRows) - ! DEPENDENT_VALUE=DEPENDENT_PARAMETERS(variable_dof) - ! RHS_VALUE=RHS_VALUE+MATRIX_VALUE*DEPENDENT_VALUE - !ENDDO !equations_column_idx - !CASE(BOUNDARY_CONDITION_DOF_FIXED) !Do nothing !CASE(BOUNDARY_CONDITION_DOF_MIXED) From 1178cc1a0e63860e8fe85f61f95667f2c256b01f Mon Sep 17 00:00:00 2001 From: lorenzo-mechbau Date: Wed, 20 Feb 2019 11:12:59 +1300 Subject: [PATCH 7/9] Deleted (wrong) backsubstitute nonlinear. --- src/equations_set_routines.F90 | 310 +-------------------------------- 1 file changed, 5 insertions(+), 305 deletions(-) diff --git a/src/equations_set_routines.F90 b/src/equations_set_routines.F90 index 7e7344af..1ee009e9 100644 --- a/src/equations_set_routines.F90 +++ b/src/equations_set_routines.F90 @@ -109,7 +109,7 @@ MODULE EQUATIONS_SET_ROUTINES PUBLIC EQUATIONS_SET_ASSEMBLE - PUBLIC EQUATIONS_SET_BACKSUBSTITUTE,EQUATIONS_SET_NONLINEAR_RHS_UPDATE, EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE + PUBLIC EQUATIONS_SET_BACKSUBSTITUTE,EQUATIONS_SET_NONLINEAR_RHS_UPDATE!, EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE PUBLIC EQUATIONS_SET_BOUNDARY_CONDITIONS_ANALYTIC @@ -1939,310 +1939,10 @@ END SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE !================================================================================================================================ ! - !>Backsubstitutes with an equations set to calculate unknown right hand side vectors for the nonlinear case - !>This is a draft!!! Still gives - !>Computes the BS for ALL rhs dofs: select case free/fixed/mixed should be uncommented (sparse case) - SUBROUTINE EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,error,*) - - !Argument variables - TYPE(EQUATIONS_SET_TYPE), POINTER :: equationsSet !equationsSet%DEPENDENT%DEPENDENT_FIELD - IF(ASSOCIATED(dependentField)) THEN - equations=>equationsSet%EQUATIONS - IF(ASSOCIATED(EQUATIONS)) THEN - NULLIFY(vectorEquations) - CALL Equations_VectorEquationsGet(equations,vectorEquations,err,error,*999) - vectorMatrices=>vectorEquations%vectorMatrices - IF(ASSOCIATED(vectorMatrices)) THEN - dynamicMatrices=>vectorMatrices%dynamicMatrices - IF(ASSOCIATED(dynamicMatrices)) THEN - !CALL FlagError("Not implemented.",err,error,*999) - ELSE - linearMatrices=>vectorMatrices%nonlinearMatrices - IF(ASSOCIATED(linearMatrices)) THEN - vectorMapping=>vectorEquations%vectorMapping - IF(ASSOCIATED(vectorMapping)) THEN - linearMapping=>vectorMapping%nonlinearMapping - IF(ASSOCIATED(linearMapping)) THEN - rhsMapping=>vectorMapping%rhsMapping - sourceMapping=>vectorMapping%sourceMapping - IF(ASSOCIATED(rhsMapping)) THEN - IF(ASSOCIATED(BOUNDARY_CONDITIONS)) THEN - IF(ASSOCIATED(sourceMapping)) THEN - sourceVector=>vectorMatrices%sourceVector - IF(ASSOCIATED(sourceVector)) THEN - SOURCE_DISTRIBUTED_VECTOR=>sourceVector%vector - IF(ASSOCIATED(SOURCE_DISTRIBUTED_VECTOR)) THEN - CALL DistributedVector_DataGet(SOURCE_DISTRIBUTED_VECTOR,sourceVectorData,err,error,*999) - ELSE - CALL FlagError("Source distributed vector is not associated.",err,error,*999) - ENDIF - ELSE - CALL FlagError("Source vector is not associated.",err,error,*999) - ENDIF - ENDIF - rhsVariable=>rhsMapping%rhsVariable - IF(ASSOCIATED(rhsVariable)) THEN - rhsVariableType=rhsVariable%VARIABLE_TYPE - RHS_DOMAIN_MAPPING=>rhsVariable%DOMAIN_MAPPING - IF(ASSOCIATED(RHS_DOMAIN_MAPPING)) THEN - CALL BOUNDARY_CONDITIONS_VARIABLE_GET(BOUNDARY_CONDITIONS,rhsVariable,RHS_BOUNDARY_CONDITIONS, & - & err,error,*999) - IF(ASSOCIATED(RHS_BOUNDARY_CONDITIONS)) THEN - !Loop over the equations matrices - DO equations_matrix_idx=1,linearMatrices%numberOfJacobians - DEPENDENT_VARIABLE=>linearMapping%jacobianToVarMap(equations_matrix_idx)%VARIABLE - IF(ASSOCIATED(DEPENDENT_VARIABLE)) THEN - VARIABLE_TYPE=DEPENDENT_VARIABLE%VARIABLE_TYPE - !Get the dependent field variable parameters - CALL Field_ParameterSetDataGet(dependentField,VARIABLE_TYPE,FIELD_VALUES_SET_TYPE, & - & DEPENDENT_PARAMETERS,err,error,*999) - equationsMatrix=>linearMatrices%jacobians(equations_matrix_idx)%ptr - IF(ASSOCIATED(equationsMatrix)) THEN - COLUMN_DOMAIN_MAPPING=>linearMapping%jacobianToVarMap(equations_matrix_idx)% & - & columnDOFSMapping - IF(ASSOCIATED(COLUMN_DOMAIN_MAPPING)) THEN - EQUATIONS_DISTRIBUTED_MATRIX=>equationsMatrix%jacobian - IF(ASSOCIATED(EQUATIONS_DISTRIBUTED_MATRIX)) THEN - CALL DistributedMatrix_StorageTypeGet(EQUATIONS_DISTRIBUTED_MATRIX, & - & EQUATIONS_STORAGE_TYPE,err,error,*999) - CALL DistributedMatrix_DataGet(EQUATIONS_DISTRIBUTED_MATRIX,equationsMatrixData, & - & err,error,*999) - SELECT CASE(EQUATIONS_STORAGE_TYPE) - CASE(DISTRIBUTED_MATRIX_BLOCK_STORAGE_TYPE) ! = sparsity: full - !Loop over the non ghosted rows in the equations set - DO equations_row_number=1,vectorMapping%numberOfRows - RHS_VALUE=0.0_DP - rhs_variable_dof=rhsMapping%equationsRowToRHSDOFMap(equations_row_number) - rhs_global_dof=RHS_DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP(rhs_variable_dof) - rhs_boundary_condition=RHS_BOUNDARY_CONDITIONS%DOF_TYPES(rhs_global_dof) - !For free RHS DOFs, set the right hand side field values by multiplying the - !row by the dependent variable value - SELECT CASE(rhs_boundary_condition) - CASE(BOUNDARY_CONDITION_DOF_FREE) - !Back substitute - !Loop over the local columns of the equations matrix - DO equations_column_idx=1,COLUMN_DOMAIN_MAPPING%TOTAL_NUMBER_OF_LOCAL - equations_column_number=COLUMN_DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP( & - & equations_column_idx) - variable_dof=equations_column_idx - MATRIX_VALUE=equationsMatrixData(equations_row_number+ & - & (equations_column_number-1)*vectorMatrices%totalNumberOfRows) - DEPENDENT_VALUE=DEPENDENT_PARAMETERS(variable_dof) - RHS_VALUE=RHS_VALUE+MATRIX_VALUE*DEPENDENT_VALUE - ENDDO !equations_column_idx - IF(ASSOCIATED(sourceMapping)) THEN - SOURCE_VALUE=sourceVectorData(equations_row_number) - RHS_VALUE=RHS_VALUE-SOURCE_VALUE - ENDIF - CALL Field_ParameterSetUpdateLocalDOF(dependentField,rhsVariableType, & - & FIELD_VALUES_SET_TYPE,rhs_variable_dof,RHS_VALUE,err,error,*999) - CASE(BOUNDARY_CONDITION_DOF_FIXED) - !Do nothing - CASE(BOUNDARY_CONDITION_DOF_MIXED) - !Robin or is it Cauchy??? boundary conditions - CALL FlagError("Not implemented.",err,error,*999) - CASE DEFAULT - localError="The RHS variable boundary condition of "// & - & TRIM(NumberToVString(rhs_boundary_condition,"*",err,error))// & - & " for RHS variable dof number "// & - & TRIM(NumberToVString(rhs_variable_dof,"*",err,error))//" is invalid." - CALL FlagError(localError,err,error,*999) - END SELECT - ENDDO !equations_row_number - CASE(DISTRIBUTED_MATRIX_DIAGONAL_STORAGE_TYPE) - CALL FlagError("Not implemented.",err,error,*999) - CASE(DISTRIBUTED_MATRIX_COLUMN_MAJOR_STORAGE_TYPE) - CALL FlagError("Not implemented.",err,error,*999) - CASE(DISTRIBUTED_MATRIX_ROW_MAJOR_STORAGE_TYPE) - CALL FlagError("Not implemented.",err,error,*999) - CASE(DISTRIBUTED_MATRIX_COMPRESSED_ROW_STORAGE_TYPE) - CALL DistributedMatrix_StorageLocationsGet(EQUATIONS_DISTRIBUTED_MATRIX, & - & ROW_INDICES,COLUMN_INDICES,err,error,*999) - !Loop over the non-ghosted rows in the equations set - DO equations_row_number=1,vectorMapping%numberOfRows - ! Same as other case (BLOCK) - RHS_VALUE=0.0_DP - rhs_variable_dof=rhsMapping%equationsRowToRHSDOFMap(equations_row_number) - rhs_global_dof=RHS_DOMAIN_MAPPING%LOCAL_TO_GLOBAL_MAP(rhs_variable_dof) - rhs_boundary_condition=RHS_BOUNDARY_CONDITIONS%DOF_TYPES(rhs_global_dof) - !SELECT CASE(rhs_boundary_condition) - !CASE(BOUNDARY_CONDITION_DOF_FREE) - !Back substitute - !Loop over the global columns of the equations matrix in the selected row - DO equations_column_idx=ROW_INDICES(equations_row_number), & - ROW_INDICES(equations_row_number+1)-1 - ! Get the GLOBAL column index - equations_column_number=COLUMN_INDICES(equations_column_idx) - ! Get the LOCAL column index for all domains - DO domain_idx=1,COLUMN_DOMAIN_MAPPING%GLOBAL_TO_LOCAL_MAP & - & (equations_column_number)%NUMBER_OF_DOMAINS - ! Select the current domain (=rank) - IF (COLUMN_DOMAIN_MAPPING%GLOBAL_TO_LOCAL_MAP & - & (equations_column_number)%DOMAIN_NUMBER(domain_idx) & - & == myComputationalNodeNumber) THEN - ! Get the local dof on the current domain - eqColLocalIdx = & - & COLUMN_DOMAIN_MAPPING%GLOBAL_TO_LOCAL_MAP & - & (equations_column_number)%LOCAL_NUMBER(domain_idx) - ! We do not consider ghosts - IF (eqColLocalIdx <= & - & COLUMN_DOMAIN_MAPPING%TOTAL_NUMBER_OF_LOCAL) THEN - ! Local dof on rhs - variable_dof=eqColLocalIdx!equations_column_number - ! original line: delete! - ! variable_dof = equations_column_idx-ROW_INDICES(equations_row_number)+1 - ! Global dof in matrix - MATRIX_VALUE=equationsMatrixData(equations_column_idx) - DEPENDENT_VALUE=DEPENDENT_PARAMETERS(variable_dof) - RHS_VALUE=RHS_VALUE+MATRIX_VALUE*DEPENDENT_VALUE - END IF - END IF - END DO - ENDDO !equations_column_idx - - IF(ASSOCIATED(sourceMapping)) THEN - SOURCE_VALUE=sourceVectorData(equations_row_number) - RHS_VALUE=RHS_VALUE-SOURCE_VALUE - ENDIF - CALL Field_ParameterSetUpdateLocalDOF(dependentField,rhsVariableType, & - & FIELD_VALUES_SET_TYPE,rhs_variable_dof,RHS_VALUE,err,error,*999) - - !CASE(BOUNDARY_CONDITION_DOF_FIXED) - !Do nothing - !CASE(BOUNDARY_CONDITION_DOF_MIXED) - !Robin or is it Cauchy??? boundary conditions - ! CALL FlagError("Not implemented.",err,error,*999) - !CASE DEFAULT - ! localError="The global boundary condition of "// & - ! & TRIM(NumberToVString(rhs_boundary_condition,"*",err,error))// & - ! & " for RHS variable dof number "// & - ! & TRIM(NumberToVString(rhs_variable_dof,"*",err,error))//" is invalid." - ! CALL FlagError(localError,err,error,*999) - !END SELECT - ENDDO !equations_row_number - CASE(DISTRIBUTED_MATRIX_COMPRESSED_COLUMN_STORAGE_TYPE) - CALL FlagError("Not implemented.",err,error,*999) - CASE(DISTRIBUTED_MATRIX_ROW_COLUMN_STORAGE_TYPE) - CALL FlagError("Not implemented.",err,error,*999) - CASE DEFAULT - localError="The matrix storage type of "// & - & TRIM(NumberToVString(EQUATIONS_STORAGE_TYPE,"*",err,error))//" is invalid." - CALL FlagError(localError,err,error,*999) - END SELECT - CALL DistributedMatrix_DataRestore(EQUATIONS_DISTRIBUTED_MATRIX,equationsMatrixData, & - & err,error,*999) - ELSE - CALL FlagError("Equations matrix distributed matrix is not associated.",err,error,*999) - ENDIF - ELSE - CALL FlagError("Equations column domain mapping is not associated.",err,error,*999) - ENDIF - ELSE - CALL FlagError("Equations equations matrix is not associated.",err,error,*999) - ENDIF - !Restore the dependent field variable parameters - CALL Field_ParameterSetDataRestore(dependentField,VARIABLE_TYPE,FIELD_VALUES_SET_TYPE, & - & DEPENDENT_PARAMETERS,err,error,*999) - ELSE - CALL FlagError("Dependent variable is not associated.",err,error,*999) - ENDIF - ENDDO !equations_matrix_idx - !Start the update of the field parameters - CALL Field_ParameterSetUpdateStart(dependentField,rhsVariableType,FIELD_VALUES_SET_TYPE, & - & err,error,*999) - !Finish the update of the field parameters - CALL Field_ParameterSetUpdateFinish(dependentField,rhsVariableType,FIELD_VALUES_SET_TYPE, & - & err,error,*999) - ELSE - CALL FlagError("RHS boundary conditions variable is not associated.",err,error,*999) - ENDIF - ELSE - CALL FlagError("RHS variable domain mapping is not associated.",err,error,*999) - ENDIF - ELSE - CALL FlagError("RHS variable is not associated.",err,error,*999) - ENDIF - IF(ASSOCIATED(sourceMapping)) THEN - CALL DistributedVector_DataRestore(SOURCE_DISTRIBUTED_VECTOR,sourceVectorData,err,error,*999) - ENDIF - ELSE - CALL FlagError("Boundary conditions are not associated.",err,error,*999) - ENDIF - ELSE - CALL FlagError("Equations mapping RHS mappings is not associated.",err,error,*999) - ENDIF - ELSE - CALL FlagError("Equations mapping linear mapping is not associated.",err,error,*999) - ENDIF - ELSE - CALL FlagError("Equations mapping is not associated.",err,error,*999) - ENDIF - ELSE - CALL FlagError("Equations matrices linear matrices is not associated.",err,error,*999) - ENDIF - ENDIF - ELSE - CALL FlagError("Equations matrices is not associated.",err,error,*999) - ENDIF - ELSE - CALL FlagError("Equations is not associated.",err,error,*999) - ENDIF - ELSE - CALL FlagError("Dependent field is not associated.",err,error,*999) - ENDIF - ELSE - CALL FlagError("Equations set has not been finished.",err,error,*999) - ENDIF - ELSE - CALL FlagError("Equations set is not associated",err,error,*999) - ENDIF - - EXITS("EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE") - RETURN -999 ERRORSEXITS("EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE",err,error) - RETURN 1 - - END SUBROUTINE EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE + !>Backsubstitutes with an equations set to calculate unknown right hand side vectors + !>In the nonlinear case it should (re)compute the residual for Dirichlet fixed dofs!? + !>Dofs with applied traction: here traction is nonzero, but residual is zero...? + !SUBROUTINE EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,error,*) ! !================================================================================================================================ From 20e7ba2fd01c2355c766096a794a3c81763cd25b Mon Sep 17 00:00:00 2001 From: lorenzo-mechbau Date: Wed, 20 Feb 2019 11:20:46 +1300 Subject: [PATCH 8/9] Replaced comments. --- src/equations_set_routines.F90 | 12 +++--------- src/problem_routines.F90 | 3 --- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/src/equations_set_routines.F90 b/src/equations_set_routines.F90 index 1ee009e9..b9040c51 100644 --- a/src/equations_set_routines.F90 +++ b/src/equations_set_routines.F90 @@ -109,7 +109,7 @@ MODULE EQUATIONS_SET_ROUTINES PUBLIC EQUATIONS_SET_ASSEMBLE - PUBLIC EQUATIONS_SET_BACKSUBSTITUTE,EQUATIONS_SET_NONLINEAR_RHS_UPDATE!, EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE + PUBLIC EQUATIONS_SET_BACKSUBSTITUTE,EQUATIONS_SET_NONLINEAR_RHS_UPDATE PUBLIC EQUATIONS_SET_BOUNDARY_CONDITIONS_ANALYTIC @@ -1938,17 +1938,11 @@ END SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE ! !================================================================================================================================ ! + !>Updates the right hand side variable from the equations residual vector - !>Backsubstitutes with an equations set to calculate unknown right hand side vectors !>In the nonlinear case it should (re)compute the residual for Dirichlet fixed dofs!? !>Dofs with applied traction: here traction is nonzero, but residual is zero...? - !SUBROUTINE EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE(equationsSet,BOUNDARY_CONDITIONS,err,error,*) - - ! - !================================================================================================================================ - ! - - !>Updates the right hand side variable from the equations residual vector + !>As it is, it returns an all-zero vector. SUBROUTINE EQUATIONS_SET_NONLINEAR_RHS_UPDATE(equationsSet,BOUNDARY_CONDITIONS,err,error,*) !Argument variables diff --git a/src/problem_routines.F90 b/src/problem_routines.F90 index 78df310a..5121a2ea 100644 --- a/src/problem_routines.F90 +++ b/src/problem_routines.F90 @@ -2679,9 +2679,6 @@ SUBROUTINE Problem_SolverEquationsStaticNonlinearSolve(SOLVER_EQUATIONS,err,erro CALL EQUATIONS_SET_BACKSUBSTITUTE(EQUATIONS_SET,SOLVER_EQUATIONS%BOUNDARY_CONDITIONS,err,error,*999) CASE(EQUATIONS_NONLINEAR) CALL EQUATIONS_SET_NONLINEAR_RHS_UPDATE(EQUATIONS_SET,SOLVER_EQUATIONS%BOUNDARY_CONDITIONS,err,error,*999) - ! Use backsubstitute also for the nonlinear case? - ! Still gives a complete vector of zeros, must be revised if one needs e.g. to compute the traction. - !CALL EQUATIONS_SET_NONLINEAR_BACKSUBSTITUTE(EQUATIONS_SET,SOLVER_EQUATIONS%BOUNDARY_CONDITIONS,err,error,*999) CASE DEFAULT CALL FlagError("Invalid linearity for equations set equations",err,error,*999) END SELECT From 93fa3c63f5bcc40506b84e501fa17bc33bf075b3 Mon Sep 17 00:00:00 2001 From: lorenzo-mechbau Date: Thu, 14 Mar 2019 11:55:05 +1300 Subject: [PATCH 9/9] Corrected convert files for mpich and openmpi. --- utils/convert_mpich | 33 ++++++++++++++++++++++++++++++ utils/{convert => convert_openmpi} | 12 ++++++++--- 2 files changed, 42 insertions(+), 3 deletions(-) create mode 100755 utils/convert_mpich rename utils/{convert => convert_openmpi} (55%) diff --git a/utils/convert_mpich b/utils/convert_mpich new file mode 100755 index 00000000..ad365a1d --- /dev/null +++ b/utils/convert_mpich @@ -0,0 +1,33 @@ +#!/usr/bin/perl -w + +$filename=$ARGV[0]; +$maxrank=0; +for($i=0;$i<=9;$i++) { + $numlines[$i]=0; +} +open(INFILE,"<$filename"); +while($inline = ) { +#Detect rank number in a line such as +#[0] I am 0 of 2 +# if(substr($inline,1,1) eq ":") { +# $ranknum=substr($inline,1,1); + if(substr($inline,0,1) eq "[") { + $ranknum=substr($inline,1,1); + if($ranknum>$maxrank){ + $maxrank=$ranknum; + } + $numlines[$ranknum]++; +#Substring corresponding to e.g. +#I am 0 of 2 +# $lines[$ranknum][$numlines[$ranknum]]=$inline; + $lines[$ranknum][$numlines[$ranknum]]=substr($inline,5) + } +} +close(INFILE); +for($i=0;$i<=$maxrank;$i++) { + open(OUTFILE,">$filename"."."."$i"); + for($j=1;$j<=$numlines[$i];$j++) { + print OUTFILE $lines[$i][$j]; + } + close(OUTFILE); +} diff --git a/utils/convert b/utils/convert_openmpi similarity index 55% rename from utils/convert rename to utils/convert_openmpi index 09e90863..a86db200 100755 --- a/utils/convert +++ b/utils/convert_openmpi @@ -7,13 +7,19 @@ for($i=0;$i<=9;$i++) { } open(INFILE,"<$filename"); while($inline = ) { - if(substr($inline,1,1) eq ":") { - $ranknum=substr($inline,0,1); +#Detect rank number in a line such as +#[1,1]: Basis set start! +# if(substr($inline,1,1) eq ":") { + if(substr($inline,0,3) eq "[1,") { + $ranknum=substr($inline,3,1); if($ranknum>$maxrank){ $maxrank=$ranknum; } $numlines[$ranknum]++; - $lines[$ranknum][$numlines[$ranknum]]=$inline; +#Substring corresponding to e.g. +#Basis set start! +# $lines[$ranknum][$numlines[$ranknum]]=$inline; + $lines[$ranknum][$numlines[$ranknum]]=substr($inline,14) } } close(INFILE);