Path: blob/devel/fem/tests/BlockLinElast1/BlockLinElast.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) :: Solver13LOGICAL :: Transient14REAL(KIND=dp) :: dt15TYPE(Element_t):: InElement16INTEGER :: Nrow, Ncol17REAL(KIND=dp) :: Stiff(:,:), Damp(:,:), Mass(:,:), Force(:)18!------------------------------------------------------------------------------19! Local variables20!------------------------------------------------------------------------------2122TYPE(GaussIntegrationPoints_t) :: IntegStuff23TYPE(Nodes_t) :: Nodes24REAL(KIND=dp), ALLOCATABLE :: Basis(:), dBasisdx(:,:)25REAL(KIND=dp), ALLOCATABLE :: Source(:)26REAL(KIND=dp) :: Young, Poisson, Lame1, Lame227REAL(KIND=dp) :: SourceAtIP, Weight, DetJ28INTEGER :: i,j,k,t,p,q,n, nd,dim29LOGICAL :: Visited = .FALSE., Found30TYPE(Element_t), POINTER :: Element31TYPE(ValueList_t), POINTER :: Material, Params3233SAVE Visited, Source, Nodes, Basis, dBasisdx, Params3435dim = CoordinateSystemDimension()3637IF( .NOT. Visited ) THEN38n = Solver % Mesh % MaxElementDOFs39ALLOCATE( Source(n), Basis(n), dBasisdx(n,3) )40CALL info('PoissonBulkAssembly','1st time')41Params => GetSolverParams()42Visited = .TRUE.43END IF4445n = GetElementNOFNodes()46nd = GetElementNOFDOFs()47CALL GetElementNodes( Nodes )48Material => GetMaterial()4950i = GetInteger( Params,'Block Matrix Row')51j = GetInteger( Params,'Block Matrix Column')52Source(1:n) = GetReal( Material,'Source',Found)5354Young = GetCReal( Material, 'Youngs modulus', Found )55Poisson = GetCReal( Material, 'Poisson Ratio', Found )5657Lame1 = Young*Poisson/((1+Poisson)*(1-2*Poisson))58Lame2 = Young/(2*(1+Poisson))5960Element => GetCurrentElement()61IntegStuff = GaussPoints( Element )626364DO t=1,IntegStuff % n65Found = ElementInfo( Element, Nodes, IntegStuff % u(t), &66IntegStuff % v(t), IntegStuff % w(t), detJ, Basis, dBasisdx )6768Weight = IntegStuff % s(t) * detJ6970SourceAtIP = SUM( Basis(1:n) * Source(1:n) )7172IF ( i==j ) THEN73STIFF(1:nd,1:nd) = STIFF(1:nd,1:nd) + &74Weight*Lame2*MATMUL(dBasisdx,TRANSPOSE(dBasisdx))75FORCE(1:nd) = FORCE(1:nd) + Weight * SourceAtIP * Basis(1:nd)76END IF7778DO p=1,nd79DO q=1,nd80STIFF(p,q) = STIFF(p,q) + &81Weight*Lame1*dBasisdx(q,j)*dBasisdx(p,i)82STIFF(p,q) = STIFF(p,q) + &83Weight*Lame2*dBasisdx(q,i)*dBasisdx(p,j)84END DO85END DO86END DO87!------------------------------------------------------------------------------88END SUBROUTINE BulkAssembly89!------------------------------------------------------------------------------909192!------------------------------------------------------------------------------93SUBROUTINE BoundaryAssembly( Model,Solver,dt,Transient, &94Mass, Damp, Stiff, Force, InElement, nrow, ncol )95!------------------------------------------------------------------------------9697USE DefUtils9899IMPLICIT NONE100!------------------------------------------------------------------------------101TYPE(Model_t) :: Model102TYPE(Solver_t), TARGET :: Solver103LOGICAL :: Transient104REAL(KIND=dp) :: dt105REAL(KIND=dp) :: Stiff(:,:), Damp(:,:), Mass(:,:), Force(:)106TYPE(Element_t), TARGET :: InElement107INTEGER :: Nrow, Ncol108!------------------------------------------------------------------------------109! Local variables110!------------------------------------------------------------------------------111112TYPE(GaussIntegrationPoints_t), TARGET :: IntegStuff113TYPE(Nodes_t) :: Nodes114REAL(KIND=dp), ALLOCATABLE :: Flux(:), Text(:), Coeff(:)115REAL(KIND=dp), ALLOCATABLE :: Basis(:), dBasisdx(:,:)116REAL(KIND=dp) :: FluxAtIP, TextAtIP, CoeffAtIP, Weight, DetJ117INTEGER :: i,j,t,p,q,n118LOGICAL :: Visited = .FALSE., Found, Found2119TYPE(ValueList_t), POINTER :: BC120TYPE(Element_t), POINTER :: Element121122123SAVE Visited, Flux, Text, Coeff, Nodes, Basis, dBasisdx124125126IF( .NOT. Visited ) THEN127N = Solver % Mesh % MaxElementNodes128ALLOCATE( Flux(n), Text(n), Coeff(n), Basis(n), dBasisdx(n,3), &129Nodes % x(n), Nodes % y(n), Nodes % z(n) )130CALL info('PoissonBoundaryAssembly','1st time')131Visited = .TRUE.132END IF133134Element => GetCurrentElement()135n = Nrow136CALL GetElementNodes( Nodes )137138BC => GetBC( )139140Flux(1:n) = GetReal( BC,'Flux',Found )141Coeff(1:n) = GetReal( BC,'Coefficient',Found2 )142IF(.NOT. (Found .OR. Found2)) RETURN143Text(1:n) = GetReal( BC,'External',Found )144145146IntegStuff = GaussPoints( Element )147148DO t=1,IntegStuff % n149150Found = ElementInfo( Element, Nodes, IntegStuff % u(t), &151IntegStuff % v(t), IntegStuff % w(t), detJ, Basis, dBasisdx )152153Weight = IntegStuff % s(t) * detJ154155FluxAtIP = SUM( Basis(1:Nrow) * Flux(1:Nrow) )156CoeffAtIP = SUM( Basis(1:Nrow) * Coeff(1:Nrow) )157TextAtIP = SUM( Basis(1:Nrow) * Text(1:Nrow) )158159DO p=1,n160DO q=1,n161STIFF(p,q) = STIFF(p,q) + Weight * CoeffAtIP * &162Basis(p)*Basis(q)163END DO164FORCE(p) = FORCE(p) + Weight * Basis(p) * &165( FluxAtIP + CoeffAtIP * TextAtIP )166END DO167END DO168169!------------------------------------------------------------------------------170END SUBROUTINE BoundaryAssembly171!------------------------------------------------------------------------------172173174175