Path: blob/devel/fem/tests/BlockPoisson3/BlockPoissonAssembly.f90
3206 views
1!------------------------------------------------------------------------------2SUBROUTINE BulkAssembly( Model,Solver,dt,Transient, &3Mass, Damp, Stiff, Force, InElement, nrow, ncol )4!------------------------------------------------------------------------------56USE DefUtils789IMPLICIT NONE10!------------------------------------------------------------------------------11TYPE(Model_t) :: Model12TYPE(Solver_t), TARGET :: Solver13LOGICAL :: Transient14REAL(KIND=dp) :: dt15REAL(KIND=dp) :: Stiff(:,:), Damp(:,:), Mass(:,:), Force(:)16TYPE(Element_t), TARGET :: InElement17INTEGER :: Nrow, Ncol18!------------------------------------------------------------------------------19! Local variables20!------------------------------------------------------------------------------2122TYPE(GaussIntegrationPoints_t), TARGET :: IntegStuff23TYPE(Nodes_t) :: Nodes24REAL(KIND=dp), ALLOCATABLE :: Source(:), Cond(:), React(:)25REAL(KIND=dp), ALLOCATABLE :: Basis(:), dBasisdx(:,:)26REAL(KIND=dp) :: SourceAtIP, CondAtIP, ReactAtIp, Weight, DetJ27INTEGER :: i,j,t,p,q,n28LOGICAL :: Visited = .FALSE., Found29TYPE(Element_t), POINTER :: Element30TYPE(ValueList_t), POINTER :: Material, Params31CHARACTER(LEN=MAX_NAME_LEN) :: str32333435SAVE Visited, Source, Cond, React, Nodes, Basis, dBasisdx, Params363738IF( .NOT. Visited ) THEN39N = Solver % Mesh % MaxElementNodes40ALLOCATE( Source(n), Cond(n), React(n), Basis(n), dBasisdx(n,3), &41Nodes % x(n), Nodes % y(n), Nodes % z(n) )42CALL info('PoissonBulkAssembly','1st time')43Params => CurrentModel % Solver % Values44Visited = .TRUE.45END IF4647n = Nrow48CALL GetElementNodes( Nodes )49Material => GetMaterial()5051i = ListGetInteger( Params,'Block Matrix Row')52j = ListGetInteger( Params,'Block Matrix Column')5354WRITE (str,'(A,I1,I1)') 'Conductivity ',i,j55Cond(1:n) = GetReal( Material,str,Found)5657WRITE (str,'(A,I1,I1)') 'Reaction ',i,j58React(1:n) = GetReal( Material,str,Found )5960IF( i == j ) THEN61WRITE (str,'(A,I1)') 'Source ',i62Source(1:n) = GetReal( Material,str,Found)63ELSE64Source(1:n) = 0.0_dp65END IF6667IF( .FALSE. ) THEN68PRINT *,'ij:',i,j69PRINT *,'coeffs:',Cond(1),React(1),Source(1)70END IF71727374Element => GetCurrentElement()75IntegStuff = GaussPoints( Element )7677DO t=1,IntegStuff % n7879Found = ElementInfo( Element, Nodes, IntegStuff % u(t), &80IntegStuff % v(t), IntegStuff % w(t), detJ, Basis, dBasisdx )8182Weight = IntegStuff % s(t) * detJ8384CondAtIP = SUM( Basis(1:Nrow) * Cond(1:Nrow) )85SourceAtIP = SUM( Basis(1:Nrow) * Source(1:Nrow) )86ReactAtIP = SUM( Basis(1:Nrow) * React(1:Nrow) )8788DO p=1,n89DO q=1,n90STIFF(p,q) = STIFF(p,q) + Weight * CondAtIP * &91SUM(dBasisdx(p,1:3)*dBasisdx(q,1:3))92STIFF(p,q) = STIFF(p,q) + Weight * ReactAtIP * &93Basis(p)*Basis(q)94END DO95FORCE(p) = FORCE(p) + Weight * SourceAtIP * Basis(p)96END DO97END DO9899!------------------------------------------------------------------------------100END SUBROUTINE BulkAssembly101!------------------------------------------------------------------------------102103104105!------------------------------------------------------------------------------106SUBROUTINE BoundaryAssembly( Model,Solver,dt,Transient, &107Mass, Damp, Stiff, Force, InElement, nrow, ncol )108!------------------------------------------------------------------------------109110USE DefUtils111112IMPLICIT NONE113!------------------------------------------------------------------------------114TYPE(Model_t) :: Model115TYPE(Solver_t), TARGET :: Solver116LOGICAL :: Transient117REAL(KIND=dp) :: dt118REAL(KIND=dp) :: Stiff(:,:), Damp(:,:), Mass(:,:), Force(:)119TYPE(Element_t), TARGET :: InElement120INTEGER :: Nrow, Ncol121!------------------------------------------------------------------------------122! Local variables123!------------------------------------------------------------------------------124125TYPE(GaussIntegrationPoints_t), TARGET :: IntegStuff126TYPE(Nodes_t) :: Nodes127REAL(KIND=dp), ALLOCATABLE :: Flux(:), Text(:), Coeff(:)128REAL(KIND=dp), ALLOCATABLE :: Basis(:), dBasisdx(:,:)129REAL(KIND=dp) :: FluxAtIP, TextAtIP, CoeffAtIP, Weight, DetJ130INTEGER :: i,j,t,p,q,n131LOGICAL :: Visited = .FALSE., Found, Found2132TYPE(ValueList_t), POINTER :: BC133TYPE(Element_t), POINTER :: Element134135136SAVE Visited, Flux, Text, Coeff, Nodes, Basis, dBasisdx137138139IF( .NOT. Visited ) THEN140N = Solver % Mesh % MaxElementNodes141ALLOCATE( Flux(n), Text(n), Coeff(n), Basis(n), dBasisdx(n,3), &142Nodes % x(n), Nodes % y(n), Nodes % z(n) )143CALL info('PoissonBoundaryAssembly','1st time')144Visited = .TRUE.145END IF146147Element => GetCurrentElement()148n = Nrow149CALL GetElementNodes( Nodes )150151BC => GetBC( )152153Flux(1:n) = GetReal( BC,'Flux',Found )154Coeff(1:n) = GetReal( BC,'Coefficient',Found2 )155IF(.NOT. (Found .OR. Found2)) RETURN156Text(1:n) = GetReal( BC,'External',Found )157158159IntegStuff = GaussPoints( Element )160161DO t=1,IntegStuff % n162163Found = ElementInfo( Element, Nodes, IntegStuff % u(t), &164IntegStuff % v(t), IntegStuff % w(t), detJ, Basis, dBasisdx )165166Weight = IntegStuff % s(t) * detJ167168FluxAtIP = SUM( Basis(1:Nrow) * Flux(1:Nrow) )169CoeffAtIP = SUM( Basis(1:Nrow) * Coeff(1:Nrow) )170TextAtIP = SUM( Basis(1:Nrow) * Text(1:Nrow) )171172DO p=1,n173DO q=1,n174STIFF(p,q) = STIFF(p,q) + Weight * CoeffAtIP * &175Basis(p)*Basis(q)176END DO177FORCE(p) = FORCE(p) + Weight * Basis(p) * &178( FluxAtIP + CoeffAtIP * TextAtIP )179END DO180END DO181182!------------------------------------------------------------------------------183END SUBROUTINE BoundaryAssembly184!------------------------------------------------------------------------------185186187188