Skip to content

Commit

Permalink
Merge branch 'devel' of https://github.com/elmercsc/elmerfem into devel
Browse files Browse the repository at this point in the history
  • Loading branch information
Juha Ruokolainen committed Sep 10, 2024
2 parents 6b72f52 + 30dfce5 commit 04714b0
Show file tree
Hide file tree
Showing 23 changed files with 193 additions and 72 deletions.
22 changes: 17 additions & 5 deletions ElmerGUIlogger/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,17 @@ IF(ElmerGUIloggerSTANDALONE)
ENDIF(WIN32)
ENDIF(ElmerGUIloggerSTANDALONE)

IF(WITH_QT5)
IF(WITH_QT6)
MESSAGE(STATUS "------------------------------------------------")
SET(QT6_PKG_LIST Qt6OpenGL Qt6Xml Qt6Gui Qt6Core Qt6OpenGLWidgets Qt6PrintSupport)
FOREACH(_pkg ${QT6_PKG_LIST})
FIND_PACKAGE(${_pkg} PATHS ${QT6_PATH})
ENDFOREACH()
ADD_DEFINITIONS(-DWITH_QT6)
MESSAGE(STATUS " [ElmerGUIlogger] Qt6: " ${Qt6_FOUND})
MESSAGE(STATUS " [ElmerGUIlogger] Qt6 Libraries: ${Qt6OpenGL_LIBRARIES} ${Qt6Xml_LIBRARIES} ${Qt6OpenGLWidgets_LIBRARIES} ${Qt6Gui_LIBRARIES} ${Qt6Core_LIBRARIES} ${Qt6PrintSupport_LIBRARIES}")
MESSAGE(STATUS "------------------------------------------------")
ELSEIF(WITH_QT5)
MESSAGE(STATUS "------------------------------------------------")
SET(QT5_PKG_LIST Qt5OpenGL Qt5Xml Qt5Script Qt5Gui Qt5Core Qt5Widgets Qt5PrintSupport)
FOREACH(_pkg ${QT5_PKG_LIST})
Expand Down Expand Up @@ -37,10 +47,10 @@ SET(SOURCES src/main.cpp src/mainwindow.cpp)
SET(RESOURCES ElmerGUIlogger.qrc)
SET(RC_FILE ElmerGUIlogger.rc)


IF(WITH_QT5)
IF(WITH_QT6)
QT6_ADD_RESOURCES(UI_RESOURCES ElmerGUIlogger.qrc)
ELSEIF(WITH_QT5)
QT5_ADD_RESOURCES(UI_RESOURCES ElmerGUIlogger.qrc)
ADD_DEFINITIONS(-DWITH_QT5)
ELSE()
QT4_ADD_RESOURCES(UI_RESOURCES ElmerGUIlogger.qrc)
MESSAGE(WARNING "QT_USE_FILE: ${QT_USE_FILE}")
Expand All @@ -61,7 +71,9 @@ ENDIF()

ADD_EXECUTABLE(ElmerGUIlogger WIN32 ${SOURCES} ${UI_RESOURCES})

IF(WITH_QT5)
IF(WITH_QT6)
TARGET_LINK_LIBRARIES(ElmerGUIlogger Qt6::OpenGL Qt6::Xml Qt6::OpenGLWidgets Qt6::Gui Qt6::Core Qt6::PrintSupport)
ELSEIF(WITH_QT5)
QT5_USE_MODULES(ElmerGUIlogger OpenGL Xml Script Gui Core Widgets PrintSupport)
ENDIF()

Expand Down
25 changes: 21 additions & 4 deletions ElmerGUItester/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,25 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
PROJECT(ElmerGUItester CXX)


IF(WITH_QT5)
IF(WITH_QT6)
MESSAGE(STATUS "------------------------------------------------")
SET(QT6_PKG_LIST Qt6Gui Qt6Core Qt6OpenGLWidgets)
FOREACH(_pkg ${QT6_PKG_LIST})
FIND_PACKAGE(${_pkg} PATHS ${QT6_PATH})
ENDFOREACH()
MESSAGE(STATUS " [ElmerGUItester] Qt6: " ${Qt6_FOUND})
MESSAGE(STATUS " [ElmerGUItester] Qt6 Libraries: ${Qt6OpenGLWidgets_LIBRARIES} ${Qt6Gui_LIBRARIES} ${Qt6Core_LIBRARIES}")
MESSAGE(STATUS "------------------------------------------------")
ADD_DEFINITIONS(-DWITH_QT6)
ELSEIF(WITH_QT5)
MESSAGE(STATUS "------------------------------------------------")
SET(QT5_PKG_LIST Qt5Gui Qt5Core Qt5Widgets)
FOREACH(_pkg ${QT5_PKG_LIST})
FIND_PACKAGE(${_pkg} PATHS ${QT5_PATH})
ENDFOREACH()
MESSAGE(STATUS " [ElmerGUItester] Qt5: " ${Qt5_FOUND})
MESSAGE(STATUS " [ElmerGUItester] Qt5 Libraries: ${Qt5Widgets_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Core_LIBRARIES}")
MESSAGE(STATUS "------------------------------------------------")
ADD_DEFINITIONS(-DWITH_QT5)
ELSE()
FIND_PACKAGE(Qt4 COMPONENTS QtGui QtCore REQUIRED)
Expand All @@ -27,10 +40,12 @@ SET(SOURCES src/main.cpp src/tester.cpp)
SET(RESOURCES ElmerGUItester.qrc)
SET(WIN32_RC_FILE ElmerGUItester.rc)

IF(WITH_QT5)
IF(WITH_QT6)
QT6_WRAP_UI(UI_HEADERS ${FORMS})
QT6_ADD_RESOURCES(UI_RESOURCES ${RESOURCES})
ELSEIF(WITH_QT5)
QT5_WRAP_UI(UI_HEADERS ${FORMS})
QT5_ADD_RESOURCES(UI_RESOURCES ${RESOURCES})
ADD_DEFINITIONS(-DWITH_QT5)
ELSE()
QT4_WRAP_UI(UI_HEADERS ${FORMS})
QT4_ADD_RESOURCES(UI_RESOURCES ${RESOURCES})
Expand All @@ -49,7 +64,9 @@ ENDIF()
INCLUDE_DIRECTORIES(${APPLICATION_INCLUDE_DIRS})
ADD_EXECUTABLE(ElmerGUItester WIN32 ${SOURCES} ${UI_HEADERS} ${UI_RESOURCES})

IF(WITH_QT5)
IF(WITH_QT6)
TARGET_LINK_LIBRARIES(ElmerGUItester Qt6::OpenGLWidgets Qt6::Gui Qt6::Core)
ELSEIF(WITH_QT5)
QT5_USE_MODULES(ElmerGUItester Gui Core Widgets)
ENDIF()

Expand Down
8 changes: 4 additions & 4 deletions fem/src/BlockSolve.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1843,21 +1843,22 @@ SUBROUTINE BlockPrecMatrix( Solver, NoVar )
str = 'Prec Matrix Density '//I2S(RowVar)
Coeff = ListGetCReal( Params, str, GotIt2)

IF( GotIt .OR. GotIt2 ) THEN
CALL Info('BlockPrecMatrix','Creating simple preconditioning matrix',Level=8)

IF( GotIt .OR. GotIt2 ) THEN
CALL CRS_CopyMatrixTopology( TotMatrix % Submatrix(RowVar,RowVar) % Mat, &
TotMatrix % Submatrix(RowVar,RowVar) % PrecMat )

Amat => TotMatrix % Submatrix(RowVar,RowVar) % PrecMat
VarPerm => TotMatrix % Subvector(RowVar) % Var % Perm
IF( GotIt ) THEN
CALL Info('BlockPrecMatrix','Creating simple preconditioning Laplace matrix',Level=8)
CALL LaplaceMatrixAssembly( Solver, VarPerm, Amat )
Amat % Values = Coeff * Amat % Values
ELSE
CALL Info('BlockPrecMatrix','Creating simple preconditioning mass matrix',Level=8)
CALL MassMatrixAssembly( Solver, VarPerm, Amat )
Amat % Values = Coeff * Amat % Values
END IF
Amat % ParallelInfo => TotMatrix % Submatrix(RowVar,RowVar) % Mat % ParallelInfo
END IF

str = 'Prec Matrix Complex Coeff '//I2S(RowVar)
Expand Down Expand Up @@ -1931,7 +1932,6 @@ SUBROUTINE BlockPrecMatrix( Solver, NoVar )
IF( .NOT. ASSOCIATED( AVar % Solver % Matrix ) ) THEN
CALL Fatal('BlockPrecMatrix','Schur matrix does not exist for: '//str)
END IF

CALL Info('BlockPrecMatrix','Using Schur matrix to precondition block '//I2S(NoVar))
TotMatrix % Submatrix(NoVar,NoVar) % PrecMat => AVar % Solver % Matrix
END IF
Expand Down
60 changes: 45 additions & 15 deletions fem/src/SolverUtils.F90
Original file line number Diff line number Diff line change
Expand Up @@ -1249,26 +1249,26 @@ SUBROUTINE DetermineSoftLimiter( Solver )
ElemFirst, ElemLast, totsize, i2, j2, ind2
REAL(KIND=dp), POINTER :: FieldValues(:), LoadValues(:), &
ElemLimit(:),ElemInit(:), ElemActive(:)
REAL(KIND=dp) :: LimitSign, EqSign, ValEps, LoadEps, val
REAL(KIND=dp) :: LimitSign, EqSign, ValEps, LoadEps, ValEps0, LoadEps0, &
MaxValue, MaxLoad, val
INTEGER, POINTER :: FieldPerm(:), NodeIndexes(:)
LOGICAL :: Found,AnyLimitBC, AnyLimitBF, GotInit, GotActive
LOGICAL, ALLOCATABLE :: LimitDone(:)
LOGICAL, POINTER :: LimitActive(:)
TYPE(ValueList_t), POINTER :: Params, Entity
LOGICAL, ALLOCATABLE :: InterfaceDof(:)
INTEGER :: ConservativeAfterIters, NonlinIter, CoupledIter, DownStreamDirection
LOGICAL :: Conservative, ConservativeAdd, ConservativeRemove, &
LOGICAL :: Conservative, ConservativeAdd, ConservativeRemove, RelativeEps, &
DoAdd, DoRemove, DirectionActive, FirstTime, DownStreamRemove
TYPE(Mesh_t), POINTER :: Mesh

CHARACTER(:), ALLOCATABLE :: Name,LimitName, InitName, ActiveName
CHARACTER(*), PARAMETER :: Caller = 'DetermineSoftLimiter'

Model => CurrentModel
Var => Solver % Variable
Mesh => Solver % Mesh


! Check the iterations counts and determine whether this is the first
! time with this solver.
!------------------------------------------------------------------------
Expand Down Expand Up @@ -1304,7 +1304,6 @@ SUBROUTINE DetermineSoftLimiter( Solver )
END IF
LoadValues => LoadVar % Values


! The variable to be constrained by the soft limiters
FieldValues => Var % Values
FieldPerm => Var % Perm
Expand Down Expand Up @@ -1342,11 +1341,15 @@ SUBROUTINE DetermineSoftLimiter( Solver )
IF(.NOT. Found ) DownStreamDirection = 1
END IF

LoadEps = ListGetConstReal(Params,'Limiter Load Tolerance',Found )
IF(.NOT. Found ) LoadEps = 1.0e-8_dp

ValEps = ListGetConstReal(Params,'Limiter Value Tolerance',Found )
IF(.NOT. Found ) ValEps = 1.0e-8_dp
LoadEps0 = ListGetConstReal(Params,'Limiter Load Tolerance',Found )
IF(.NOT. Found ) LoadEps0 = 1.0e-8_dp
LoadEps = LoadEps0

ValEps0 = ListGetConstReal(Params,'Limiter Value Tolerance',Found )
IF(.NOT. Found ) ValEps0 = 1.0e-8_dp
ValEps = ValEps0

RelativeEps = ListGetLogical(Params,'Limiter Relative Tolerance', Found )

! The user may want to toggle the sign for various kinds of equations
! The default sign that come from standard formulation of Laplace equation.
Expand Down Expand Up @@ -1447,6 +1450,25 @@ SUBROUTINE DetermineSoftLimiter( Solver )
LimitDone = .FALSE.
END IF

IF( RelativeEps ) THEN
IF( dofs == 1 ) THEN
MaxLoad = MAXVAL( ABS( LoadValues ) )
MaxValue = MAXVAL( ABS( Var % Values ) )
ELSE
MaxLoad = MAXVAL( ABS( LoadValues(dof::dofs ) ) )
MaxValue = MAXVAL( ABS( Var % Values(dof::dofs) ) )
END IF
MaxLoad = ParallelReduction(MaxLoad)
MaxValue = ParallelReduction(MaxValue)
IF( InfoActive(20) ) THEN
WRITE(Message,'(A,ES12.3)') 'Using load maximum for scaling: ',MaxLoad
CALL Info(Caller,Message)
WRITE(Message,'(A,ES12.3)') 'Using value maximum for scaling: ',MaxValue
CALL Info(Caller,Message)
END IF
LoadEps = LoadEps0 * MaxLoad
ValEps = ValEps0 * MaxValue
END IF

IF( FirstTime ) THEN
! In the first time set the initial set
Expand Down Expand Up @@ -1701,7 +1723,7 @@ SUBROUTINE DetermineSoftLimiter( Solver )
! This means that set is released only at the boundaries.
IF( ConservativeRemove ) DoRemove = InterfaceDof( ind )
IF( DoRemove ) THEN
IF(LimitActive(ind)) THEN
IF(LimitActive(ind)) THEN
removed = removed + 1
LimitActive(ind) = .FALSE.
END IF
Expand Down Expand Up @@ -8480,7 +8502,7 @@ SUBROUTINE EnforceDirichletConditions( Solver, A, b, OffDiagonal )
CALL Info(Caller,'No Dirichlet conditions to enforce, exiting!',Level=10)
RETURN
ELSE
CALL Info(Caller,'Enforcing Dirichlet conditions...',Level=10)
CALL Info(Caller,'Enforcing total of '//I2S(n)//' Dirichlet conditions.',Level=10)
END IF

! Communicate the Dirichlet conditions for parallel cases since there may be orphans
Expand Down Expand Up @@ -20279,7 +20301,7 @@ SUBROUTINE LaplaceMatrixAssembly( Solver, Perm, A )
CHARACTER(:), ALLOCATABLE :: BoundaryName
TYPE(Nodes_t) :: Nodes
REAL(KIND=dp), ALLOCATABLE :: STIFF(:,:), FORCE(:)
REAL(KIND=dp), POINTER :: Basis(:), dBasisdx(:,:)
REAL(KIND=dp), POINTER :: Basis(:), dBasisdx(:,:), rhs(:)
REAL(KIND=dp) :: detJ, val
LOGICAL :: Stat

Expand All @@ -20290,6 +20312,9 @@ SUBROUTINE LaplaceMatrixAssembly( Solver, Perm, A )
ALLOCATE( Basis(n), dBasisdx(n, 3), FORCE(N), STIFF(N,N), &
Nodes % x(n), Nodes % y(n), Nodes % z(n), &
STAT=istat)

ALLOCATE( rhs(A % NumberOfRows) )
rhs = 0.0_dp

IF(.FALSE.) THEN
N = Mesh % NumberOfNodes
Expand Down Expand Up @@ -20343,11 +20368,12 @@ SUBROUTINE LaplaceMatrixAssembly( Solver, Perm, A )
END DO
END DO

CALL UpdateGlobalEquations( A,STIFF,A % rhs,FORCE,n,1,Perm(Indexes(1:n)) )
CALL UpdateGlobalEquations( A,STIFF,rhs,FORCE,n,1,Perm(Indexes(1:n)) )
END DO

DEALLOCATE( Basis, dBasisdx, FORCE, STIFF, &
Nodes % x, Nodes % y, Nodes % z)
DEALLOCATE( rhs )

END SUBROUTINE LaplaceMatrixAssembly

Expand All @@ -20373,7 +20399,6 @@ SUBROUTINE MassMatrixAssembly( Solver, Perm, A )
REAL(KIND=dp) :: detJ, val
LOGICAL :: Stat


Mesh => Solver % Mesh

N = Mesh % MaxElementNodes
Expand Down Expand Up @@ -20425,6 +20450,11 @@ SUBROUTINE MassMatrixAssembly( Solver, Perm, A )
Nodes % x, Nodes % y, Nodes % z)
DEALLOCATE( rhs )

! We don't currently need to do this as we copy the ParallelInfo from primary matrix.
IF ( Parenv % PEs > 1 ) THEN
! CALL ParallelInitMatrix( Solver, A )
END IF

END SUBROUTINE MassMatrixAssembly


Expand Down
35 changes: 21 additions & 14 deletions fem/src/modules/ElasticSolve.F90
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,11 @@ END FUNCTION ElastInsideResidual
previ = 1
END IF
END IF

IF(previ > 0) THEN
CALL Info('ElasticSolver','Taking previous displacement from PrevValues(:,'//I2S(previ)//')',Level=30)
END IF


time = GetTime()

CALL DefaultStart()
Expand Down Expand Up @@ -860,23 +864,26 @@ END FUNCTION ElastInsideResidual
InertialLoad = 0.0D0

IF ( ASSOCIATED(BodyForce) ) THEN
LoadVector(1,1:n) = GetReal( BodyForce, 'Stress Bodyforce 1', GotIt )
LoadVector(2,1:n) = GetReal( BodyForce, 'Stress Bodyforce 2', GotIt )
IF ( dim > 2 ) THEN
IF( ListCheckPrefix(BodyForce,'Stress Bodyforce') ) THEN
LoadVector(1,1:n) = GetReal( BodyForce, 'Stress Bodyforce 1', GotIt )
LoadVector(2,1:n) = GetReal( BodyForce, 'Stress Bodyforce 2', GotIt )
IF ( dim > 2 ) THEN
LoadVector(3,1:n) = GetReal( BodyForce, 'Stress Bodyforce 3', GotIt )
END IF

InertialLoad(1,1:n) = GetReal( BodyForce, 'Inertial Bodyforce 1', GotIt )
InertialLoad(2,1:n) = GetReal( BodyForce, 'Inertial Bodyforce 2', GotIt )
END IF
END IF

IF ( dim > 2 ) THEN
IF( ListCheckPrefix(BodyForce,'Inertial Bodyforce') ) THEN
InertialLoad(1,1:n) = GetReal( BodyForce, 'Inertial Bodyforce 1', GotIt )
InertialLoad(2,1:n) = GetReal( BodyForce, 'Inertial Bodyforce 2', GotIt )
IF ( dim > 2 ) THEN
InertialLoad(3,1:n) = GetReal( BodyForce, 'Inertial Bodyforce 3', GotIt )
END IF
END IF
END IF

IF( STDOFS > dim ) THEN
LoadVector(STDOFs,1:n) = GetReal( BodyForce, 'Stress Volume Source', GotIt )
END IF
END IF
IF( STDOFS > dim ) THEN
LoadVector(STDOFs,1:n) = GetReal( BodyForce, 'Stress Volume Source', GotIt )
END IF
END IF

!------------------------------------------------------------------------------
! Get values of field variables:
Expand Down
Loading

0 comments on commit 04714b0

Please sign in to comment.