Skip to content

Commit

Permalink
Minor fix for variable creation when block order of components is tan…
Browse files Browse the repository at this point in the history
…gled.
  • Loading branch information
raback committed Nov 19, 2024
1 parent fa0b467 commit 34a2dcb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
17 changes: 16 additions & 1 deletion fem/src/BlockSolve.F90
Original file line number Diff line number Diff line change
Expand Up @@ -472,9 +472,9 @@ SUBROUTINE BlockInitMatrix( Solver, BlockMatrix, BlockDofs, FieldDofs, SkipVar )
IF(ASSOCIATED( Var ) ) THEN
CALL Info(Caller,'Using existing variable > '//VarName//' <')
ELSE
CALL Info(Caller,'Variable > '//VarName//' < does not exist, creating')
PSolver => Solver
IF( BlockMatrix % GotBlockStruct ) THEN
CALL Info(Caller,'Variable > '//VarName//' < does not exist, creating from existing Perm')
j = COUNT( BlockMatrix % BlockStruct == i )
IF( j == 0 ) THEN
CALL Fatal(Caller,'Invalid > Block Structure < given!')
Expand All @@ -483,6 +483,7 @@ SUBROUTINE BlockInitMatrix( Solver, BlockMatrix, BlockDofs, FieldDofs, SkipVar )
ELSE
Var => CreateBlockVariable(PSolver, i, VarName )
END IF
CALL Info(Caller,'Variable > '//VarName//' < does not exist, creating')
END IF

BlockMatrix % SubVector(i) % Var => Var
Expand Down Expand Up @@ -544,13 +545,27 @@ SUBROUTINE BlockInitVar( Solver, BlockMatrix, BlockIndex )
Vals = 0.0_dp

IF( PRESENT(BlockIndex) ) THEN
CALL Info('BlockInitVar','Using BlockIndex to pick variable and perm',Level=20)
NULLIFY(VarPerm)
m = SIZE(Solver % Variable % Perm)
ALLOCATE(VarPerm(m))
VarPerm = 0
#if 0
! This works only when dofs follow each other systematically.
WHERE( BlockIndex == i )
VarPerm = Solver % Variable % Perm - BlockMatrix % Offset(i)
END WHERE
#else
k = 0
DO j=1,SIZE(Solver % Variable % Perm)
IF(BlockIndex(j) == i) THEN
k = k+1
VarPerm(j) = k
END IF
END DO
#endif
IF( ANY( VarPerm < 0) ) CALL Fatal('BlockInitVar','Negative Perm!')

CALL VariableAdd( Mesh % Variables,Mesh,PSolver,VarName,1,Vals,&
Output = .FALSE., Perm = VarPerm )
ELSE
Expand Down
2 changes: 1 addition & 1 deletion fem/tests/ElastPelem2dPmultgBoomer/case.sif
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Header
End

Simulation
Max Output Level = 5
Max Output Level = 25
Coordinate System = Cartesian
Coordinate Mapping(3) = 1 2 3
Simulation Type = Steady state
Expand Down
2 changes: 1 addition & 1 deletion fem/tests/mgdyn_hypre_ams_many/case.sif
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ End


! Electromagnetic field energy
Solver 1 :: Reference Norm = 1.42980690E-07
!Solver 1 :: Reference Norm = 1.42980690E-07
Solver 3 :: Show Norm Index = 2
Solver 3 :: Reference Norm = 8.32659888E-06

Expand Down
3 changes: 2 additions & 1 deletion fem/tests/mgdyn_steady_plate/case.sif
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Header
End

Simulation
Max Output Level = 20
Max Output Level = 7
Coordinate System = "Cartesian"
Simulation Type = Steady
Steady State Max Iterations = 1
Expand Down Expand Up @@ -64,6 +64,7 @@ Solver 1
Fix Input Current Density = Logical False

Linear System Block Mode = Logical True
Optimize Bandwidth = False

Block Gauss-Seidel = Logical True
Block Hor-Ver System = Logical True
Expand Down

0 comments on commit 34a2dcb

Please sign in to comment.