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

Utils convert #175

Open
wants to merge 9 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
67 changes: 47 additions & 20 deletions src/equations_set_routines.F90
Original file line number Diff line number Diff line change
Expand Up @@ -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(:)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -1762,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)
Expand All @@ -1774,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)
Expand All @@ -1792,22 +1795,49 @@ 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
! 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)
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 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
ENDDO !equations_column_idx
! 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
IF (COLUMN_DOMAIN_MAPPING%GLOBAL_TO_LOCAL_MAP &
& (equations_column_number)%DOMAIN_NUMBER(domain_idx) &
& == myComputationalNodeNumber) THEN
! 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)
! We do not consider ghosts
IF (eqColLocalIdx <= &
& COLUMN_DOMAIN_MAPPING%TOTAL_NUMBER_OF_LOCAL) THEN
! Local dof on rhs
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
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)
Expand All @@ -1820,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)
Expand Down Expand Up @@ -1914,8 +1938,11 @@ END SUBROUTINE EQUATIONS_SET_BACKSUBSTITUTE
!
!================================================================================================================================
!

!>Updates the right hand side variable from the equations residual vector

!>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...?
!>As it is, it returns an all-zero vector.
SUBROUTINE EQUATIONS_SET_NONLINEAR_RHS_UPDATE(equationsSet,BOUNDARY_CONDITIONS,err,error,*)

!Argument variables
Expand Down
33 changes: 33 additions & 0 deletions utils/convert_mpich
Original file line number Diff line number Diff line change
@@ -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 = <INFILE> ) {
#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);
}
12 changes: 9 additions & 3 deletions utils/convert → utils/convert_openmpi
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ for($i=0;$i<=9;$i++) {
}
open(INFILE,"<$filename");
while($inline = <INFILE> ) {
if(substr($inline,1,1) eq ":") {
$ranknum=substr($inline,0,1);
#Detect rank number in a line such as
#[1,1]<stdout>: 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);
Expand Down