Path: blob/devel/fem/tests/BlockPoisson2/PoissonAssembly.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 :: Material313233SAVE Visited, Source, Cond, React, Nodes, Basis, dBasisdx343536IF( .NOT. Visited ) THEN37N = Solver % Mesh % MaxElementNodes38ALLOCATE( Source(n), Cond(n), React(n), Basis(n), dBasisdx(n,3), &39Nodes % x(n), Nodes % y(n), Nodes % z(n) )40CALL info('PoissonBulkAssembly','1st time')41Visited = .TRUE.42END IF4344n = Nrow45CALL GetElementNodes( Nodes )46Material => GetMaterial()47React(1:n) = GetReal( Material,'Reaction',Found )48Source(1:n) = GetReal( Material,'Source' )49Cond(1:n) = GetReal( Material,'Conductivity')5051Element => GetCurrentElement()52IntegStuff = GaussPoints( Element )5354DO t=1,IntegStuff % n5556Found = ElementInfo( Element, Nodes, IntegStuff % u(t), &57IntegStuff % v(t), IntegStuff % w(t), detJ, Basis, dBasisdx )5859Weight = IntegStuff % s(t) * detJ6061CondAtIP = SUM( Basis(1:Nrow) * Cond(1:Nrow) )62SourceAtIP = SUM( Basis(1:Nrow) * Source(1:Nrow) )63ReactAtIP = SUM( Basis(1:Nrow) * React(1:Nrow) )6465DO p=1,n66DO q=1,n67STIFF(p,q) = STIFF(p,q) + Weight * CondAtIP * &68SUM(dBasisdx(p,1:3)*dBasisdx(q,1:3))69STIFF(p,q) = STIFF(p,q) + Weight * ReactAtIP * &70Basis(p)*Basis(q)71END DO72FORCE(p) = FORCE(p) + Weight * SourceAtIP * Basis(p)73END DO74END DO7576!------------------------------------------------------------------------------77END SUBROUTINE BulkAssembly78!------------------------------------------------------------------------------79808182!------------------------------------------------------------------------------83SUBROUTINE BoundaryAssembly( Model,Solver,dt,Transient, &84Mass, Damp, Stiff, Force, InElement, nrow, ncol )85!------------------------------------------------------------------------------8687USE DefUtils8889IMPLICIT NONE90!------------------------------------------------------------------------------91TYPE(Model_t) :: Model92TYPE(Solver_t), TARGET :: Solver93LOGICAL :: Transient94REAL(KIND=dp) :: dt95REAL(KIND=dp) :: Stiff(:,:), Damp(:,:), Mass(:,:), Force(:)96TYPE(Element_t), TARGET :: InElement97INTEGER :: Nrow, Ncol98!------------------------------------------------------------------------------99! Local variables100!------------------------------------------------------------------------------101102TYPE(GaussIntegrationPoints_t), TARGET :: IntegStuff103TYPE(Nodes_t) :: Nodes104REAL(KIND=dp), ALLOCATABLE :: Flux(:), Text(:), Coeff(:)105REAL(KIND=dp), ALLOCATABLE :: Basis(:), dBasisdx(:,:)106REAL(KIND=dp) :: FluxAtIP, TextAtIP, CoeffAtIP, Weight, DetJ107INTEGER :: i,j,t,p,q,n108LOGICAL :: Visited = .FALSE., Found, Found2109TYPE(ValueList_t), POINTER :: BC110TYPE(Element_t), POINTER :: Element111112113SAVE Visited, Flux, Text, Coeff, Nodes, Basis, dBasisdx114115116IF( .NOT. Visited ) THEN117N = Solver % Mesh % MaxElementNodes118ALLOCATE( Flux(n), Text(n), Coeff(n), Basis(n), dBasisdx(n,3), &119Nodes % x(n), Nodes % y(n), Nodes % z(n) )120CALL info('PoissonBoundaryAssembly','1st time')121Visited = .TRUE.122END IF123124Element => GetCurrentElement()125n = Nrow126CALL GetElementNodes( Nodes )127128BC => GetBC( )129130Flux(1:n) = GetReal( BC,'Flux',Found )131Coeff(1:n) = GetReal( BC,'Coefficient',Found2 )132IF(.NOT. (Found .OR. Found2)) RETURN133Text(1:n) = GetReal( BC,'External',Found )134135136IntegStuff = GaussPoints( Element )137138DO t=1,IntegStuff % n139140Found = ElementInfo( Element, Nodes, IntegStuff % u(t), &141IntegStuff % v(t), IntegStuff % w(t), detJ, Basis, dBasisdx )142143Weight = IntegStuff % s(t) * detJ144145FluxAtIP = SUM( Basis(1:Nrow) * Flux(1:Nrow) )146CoeffAtIP = SUM( Basis(1:Nrow) * Coeff(1:Nrow) )147TextAtIP = SUM( Basis(1:Nrow) * Text(1:Nrow) )148149DO p=1,n150DO q=1,n151STIFF(p,q) = STIFF(p,q) + Weight * CoeffAtIP * &152Basis(p)*Basis(q)153END DO154FORCE(p) = FORCE(p) + Weight * Basis(p) * &155( FluxAtIP + CoeffAtIP * TextAtIP )156END DO157END DO158159!------------------------------------------------------------------------------160END SUBROUTINE BoundaryAssembly161!------------------------------------------------------------------------------162163164165