Path: blob/devel/elmerice/Solvers/ComputeDevStress.F90
3204 views
!/*****************************************************************************/1! *2! * Elmer/Ice, a glaciological add-on to Elmer3! * http://elmerice.elmerfem.org4! *5! *6! * This program is free software; you can redistribute it and/or7! * modify it under the terms of the GNU General Public License8! * as published by the Free Software Foundation; either version 29! * of the License, or (at your option) any later version.10! *11! * This program is distributed in the hope that it will be useful,12! * but WITHOUT ANY WARRANTY; without even the implied warranty of13! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the14! * GNU General Public License for more details.15! *16! * You should have received a copy of the GNU General Public License17! * along with this program (in file fem/GPL-2); if not, write to the18! * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,19! * Boston, MA 02110-1301, USA.20! *21! *****************************************************************************/22! ******************************************************************************23! *24! * Authors: Juha Ruokolainen, Fabien Gillet-Chaulet, Olivier Gagliardini25! * Email: [email protected]26! * Web: http://elmerice.elmerfem.org27! *28! * Original Date: 08 Jun 199729! * Date of modification: 16/01/202430! * Last modification by Julien Brondex (IGE) to make it compatible with31! * Porous Solver32! *****************************************************************************33!> Module containing a solver for computing deviatoric or Cauchy34!> stress from flow solution (NS or Porous solver)35!> 2D SDOFs = 4 (S11, S22, S33, S12)36!> 3D SDOFs = 6 (S11, S22, S33, S12, S23, S31)37!> Keywords : Cauchy (Logical),38!------------------------------------------------------------------------------39RECURSIVE SUBROUTINE ComputeDevStress( Model,Solver,dt,TransientSimulation )40!------------------------------------------------------------------------------4142USE DefUtils4344IMPLICIT NONE4546!------------------------------------------------------------------------------47!******************************************************************************48!49! Solve stress equations for one timestep50!51! ARGUMENTS:52!53! TYPE(Model_t) :: Model,54! INPUT: All model information (mesh,materials,BCs,etc...)55!56! TYPE(Solver_t) :: Solver57! INPUT: Linear equation solver options58!59! REAL(KIND=dp) :: dt,60! INPUT: Timestep size for time dependent simulations (NOTE: Not used61! currently)62!63!******************************************************************************6465TYPE(Model_t) :: Model66TYPE(Solver_t), TARGET :: Solver6768LOGICAL :: TransientSimulation69REAL(KIND=dp) :: dt70!------------------------------------------------------------------------------71! Local variables72!------------------------------------------------------------------------------73TYPE(Solver_t), POINTER :: PSolver7475TYPE(Matrix_t),POINTER :: StiffMatrix7677INTEGER :: i, j, k, l, n, t, iter, NDeg, iSolverName78INTEGER :: dim, STDOFs, StressDOFs, LocalNodes, istat7980TYPE(ValueList_t),POINTER :: Material, BC, BodyForce, Constants81TYPE(Nodes_t) :: ElementNodes82TYPE(Element_t),POINTER :: CurrentElement8384REAL(KIND=dp) :: RelativeChange, UNorm, PrevUNorm8586REAL(KIND=dp), ALLOCATABLE :: Basis(:),ddBasisddx(:,:,:)87REAL(KIND=dp), ALLOCATABLE :: dBasisdx(:,:)88REAL(KIND=dp) :: u, v, w, detJ8990LOGICAL :: stat, CSymmetry9192INTEGER :: NewtonIter, NonlinearIter9394TYPE(Variable_t), POINTER :: StressSol, FlowVariable, DensityVariable, VMisesVariable9596REAL(KIND=dp), POINTER :: Stress(:), Solution(:), &97ForceVector(:), FlowValues(:), DensityValues(:), VMisesValues(:)9899INTEGER, POINTER :: StressPerm(:), NodeIndexes(:), &100FlowPerm(:), DensityPerm(:), VMisesPerm(:)101102LOGICAL :: Isotropic, AllocationsDone = .FALSE., &103Requal0, ComputeVMises104LOGICAL :: GotIt, GotIt_CT, GotIt_TFV, OldKeyword, Cauchy = .FALSE.,UnFoundFatal=.TRUE.,OutOfPlaneFlow105106REAL(KIND=dp), ALLOCATABLE:: LocalMassMatrix(:,:), &107LocalStiffMatrix(:,:), LocalForce(:), &108LocalP(:), &109LocalVelo(:,:), LocalViscosity(:), &110LocalFluidity(:), LocalDensity(:), &111RelativeT(:), ConstantT(:)112113INTEGER :: NumberOfBoundaryNodes, COMP114INTEGER, POINTER :: BoundaryReorder(:)115116REAL(KIND=dp), POINTER :: BoundaryNormals(:,:), &117BoundaryTangent1(:,:), BoundaryTangent2(:,:)118CHARACTER(LEN=MAX_NAME_LEN) :: FlowSolverName, StressSolverName, TempName, DensityName, VMisesName119120REAL(KIND=dp) :: at, at0121!------------------------------------------------------------------------------122SAVE NumberOfBoundaryNodes, BoundaryReorder, BoundaryNormals, &123BoundaryTangent1, BoundaryTangent2124125SAVE Basis, dBasisdx, ddBasisddx126SAVE LocalMassMatrix, LocalStiffMatrix, LocalForce, &127ElementNodes, &128AllocationsDone, &129LocalViscosity, Cauchy, &130LocalFluidity, LocalDensity, &131OldKeyword, RelativeT, ConstantT132133SAVE LocalVelo, LocalP, dim134135! NULLIFY(StressSol, FlowVariable)136137!------------------------------------------------------------------------------138! Read the name of the Flow Solver (NS or Porous)139!------------------------------------------------------------------------------140FlowSolverName = GetString( Solver % Values, 'Flow Solver Name', GotIt )141IF (.NOT.Gotit) THEN142CALL FATAL('ComputeDevStress', '>Flow Solver Name< must be prescribed in Solver &143and set to "Flow Solution" or "Porous".')144ELSE145FlowVariable => VariableGet( Solver % Mesh % Variables, FlowSolverName)146IF ( ASSOCIATED( FlowVariable ) ) THEN147FlowPerm => FlowVariable % Perm148FlowValues => FlowVariable % Values149OutOfPlaneFlow = GetLogical(Solver % Values , 'Out of Plane flow', GotIt)150IF ( .NOT. GotIt ) OutOfPlaneFlow = .FALSE.151ELSE152CALL FATAL('ComputeDevStress', 'Flow Variable not associated. Check consistency between used flow solver &153and prescribed >Flow Solver Name< !')154END IF155END IF156157!!!Switch to integer indice to avoid case sensitivity issues158SELECT CASE(FlowSolverName)159CASE('Flow Solution','flow solution')160iSolverName = 1161CASE('Porous', 'porous')162iSolverName = 2163CASE DEFAULT164CALL FATAL('ComputeDevStress', '>Flow Solver Name< must be either "Flow Solution" or "Porous"')165END SELECT166!------------------------------------------------------------------------------167! Read the name of the Density Variable when using Porous solver168!------------------------------------------------------------------------------169IF (iSolverName == 2) THEN170Constants => GetConstants()171DensityName = GetString(Constants,'Density Name', GotIt)172IF (.NOT.GotIt) THEN173CALL WARN('ComputeDevStress', 'No Keyword >Density Name< defined despite using Porous Solver.&174Using "Density" as default.')175WRITE(DensityName,'(A)') 'Density'176ELSE177WRITE(Message,'(a,a)') 'Variable Name for density: ', DensityName178CALL INFO('ComputeDevStress',Message,Level=12)179END IF180181DensityVariable => VariableGet(Solver % Mesh %Variables, Densityname)182IF ( ASSOCIATED( DensityVariable ) ) THEN183DensityPerm => DensityVariable % Perm184DensityValues => DensityVariable % Values185ELSE186CALL FATAL('ComputeDevStress', 'Density not associated. Required as viscosity=f(D) for Porous !')187END IF188END IF189190ComputeVMises = GetLogical( Solver % Values, 'Compute von Mises Stress', GotIt )191IF (.NOT.GotIt) THEN192ComputeVMises = .FALSE.193ELSE IF (ComputeVMises) THEN194CALL INFO('ComputeDevStress', 'Computing von Mises stress', Level=5)195VMisesName = GetString(Solver % Values,'Von Mises Stress Name', GotIt)196IF (.NOT.GotIT) THEN197WRITE(VMisesName,'(A)') 'Von Mises Stress'198END IF199VMisesVariable => VariableGet(Solver % Mesh % Variables, VMisesname)200IF ( ASSOCIATED( VMisesVariable ) ) THEN201VMisesPerm => VMisesVariable % Perm202VMisesValues => VMisesVariable % Values203CALL INFO('ComputeDevStress', 'Output of von Mises stress to ' // TRIM(VMisesname), Level=3)204ELSE205CALL FATAL('ComputeDevStress', TRIM(VMisesName) // ' not associated, but output requested')206END IF207ELSE208ComputeVMises = .FALSE.209END IF210211!------------------------------------------------------------------------------212! Read constants from constants section of SIF file213!------------------------------------------------------------------------------214!------------------------------------------------------------------------------215! Get variables needed for solution216!------------------------------------------------------------------------------217IF ( .NOT. ASSOCIATED( Solver % Matrix ) ) RETURN218219Solution => Solver % Variable % Values220STDOFs = Solver % Variable % DOFs221222IF ( STDOFs /=1 ) THEN223CALL Fatal( 'ComputeDevStress', 'DOF must be equal to 1' )224END IF225226StressSolverName = GetString( Solver % Values, 'Stress Variable Name', GotIt )227IF (.NOT.Gotit) CALL FATAL('ComputeDevStress', &228'Stress Variable Name not defined')229230StressSol => VariableGet( Solver % Mesh % Variables, TRIM(StressSolverName),&231UnFoundFatal=UnFoundFatal )232StressPerm => StressSol % Perm233StressDOFs = StressSol % DOFs234Stress => StressSol % Values235236dim = CoordinateSystemDimension()237IF (StressDOfs /= 2*dim) THEN238CALL Fatal( 'ComputeDesStress', 'Bad dimension of Stress Variable (4 in 2D, 6 in 3D)' )239ENDIF240241StiffMatrix => Solver % Matrix242ForceVector => StiffMatrix % RHS243Unorm = SQRT( SUM( Stress**2 ) / SIZE(Stress) )244!------------------------------------------------------------------------------245! Allocate some permanent storage, this is done first time only246!------------------------------------------------------------------------------247IF ( .NOT. AllocationsDone .OR. Solver % MeshChanged) THEN248N = Model % MaxElementNodes249250IF ( AllocationsDone ) THEN251DEALLOCATE( ElementNodes % x, &252ElementNodes % y, &253ElementNodes % z, &254LocalVelo, LocalP, &255Basis, ddBasisddx, &256dBasisdx, &257LocalMassMatrix, &258LocalStiffMatrix, &259LocalForce, &260LocalViscosity, &261LocalFluidity, &262LocalDensity, &263RelativeT, &264ConstantT )265END IF266267ALLOCATE( ElementNodes % x( N ), &268ElementNodes % y( N ), &269ElementNodes % z( N ), &270LocalVelo( 3,N ), LocalP( N ), &271Basis( 2*N ),ddBasisddx(1,1,1), dBasisdx( 2*N,3 ), &272LocalMassMatrix( 2*STDOFs*N,2*STDOFs*N ), &273LocalStiffMatrix( 2*STDOFs*N,2*STDOFs*N ), &274LocalForce( 2*STDOFs*N ), &275LocalViscosity(N), &276LocalFluidity(N), LocalDensity(N), &277RelativeT(N), ConstantT(N), STAT=istat )278279IF ( istat /= 0 ) THEN280CALL Fatal( 'ComputeDevStress', 'Memory allocation error.' )281END IF282!------------------------------------------------------------------------------283284AllocationsDone = .TRUE.285END IF286287288!------------------------------------------------------------------------------289NonlinearIter = 1290DO iter=1,NonlinearIter291292at = CPUTime()293at0 = RealTime()294295CALL Info( 'ComputeDevStress', ' ', Level=4 )296CALL Info( 'ComputeDevStress', ' ', Level=4 )297CALL Info( 'ComputeDevStress', ' ', Level=4 )298CALL Info( 'ComputeDevStress', ' ', Level=4 )299CALL Info( 'ComputeDevStress', 'Starting assembly...',Level=4 )300301! Loop over the Stress components [Sxx, Syy, Szz, Sxy, Syz, Szx]302303PrevUNorm = UNorm304305DO COMP = 1, 2*dim306307WRITE(Message,'(a,i3)' ) ' Component : ', COMP308CALL Info( 'ComputeDevStress', Message, Level=5 )309310311!------------------------------------------------------------------------------312CALL DefaultInitialize()313!------------------------------------------------------------------------------314DO t=1,Solver % NumberOFActiveElements315316IF ( RealTime() - at0 > 1.0 ) THEN317WRITE(Message,'(a,i3,a)' ) ' Assembly: ', &318INT(100.0 - 100.0 * (Solver % NumberOfActiveElements-t) / &319(1.0*Solver % NumberOfActiveElements)), ' % done'320CALL Info( 'ComputeDevStress', Message, Level=5 )321at0 = RealTime()322END IF323324CurrentElement => GetActiveElement(t)325n = GetElementNOFNodes()326NodeIndexes => CurrentElement % NodeIndexes327328ElementNodes % x(1:n) = Model % Nodes % x(NodeIndexes(1:n))329ElementNodes % y(1:n) = Model % Nodes % y(NodeIndexes(1:n))330ElementNodes % z(1:n) = Model % Nodes % z(NodeIndexes(1:n))331332Material => GetMaterial()333334!------------------------------------------------------------------------------335! Read in material constants from Material section336!------------------------------------------------------------------------------337!!!! When the Flow Solver is Stokes:338IF (iSolverName == 1) THEN339!! Check for the presence of keywords related to the new vectorized Stokes solver340RelativeT(1:n) = ListGetReal( Material, 'Relative Temperature', n, NodeIndexes, GotIt )341IF (GotIt) THEN342OldKeyword = ListGetLogical( Material, 'Glen Allow Old Keywords', GotIt)343IF (.NOT.(GotIt .AND. OldKeyword)) THEN344CALL FATAL('ComputeDevStress', 'When using ComputeDevStress with IncompressibleNSVec &345>Glen Allow Old Keywords< must be set to True in Material')346END IF347ConstantT(1:n) = ListGetReal( Material, 'Constant Temperature', n, NodeIndexes, GotIt_CT )348TempName = GetString( Material, 'Temperature Field Variable', GotIt_TFV)349IF (.NOT.(GotIt_CT .OR. GotIt_TFV)) THEN350CALL FATAL('ComputeDevStress', '>Constant Temperature< or >Temperature Field Variable< &351must be prescribed in Material')352END IF353!!! In the case of constant T check for consistency between prescribed relative and constant T354IF (GotIt_CT .AND. (.NOT. all(abs(RelativeT(1:n) - ConstantT(1:n))<AEPS))) THEN355CALL FATAL('ComputeDevStress', 'When considering constant temperature, >Constant Temperature< and >Relative &356Temperature< must be consistent')357END IF358END IF359!Get Viscosity at nodes360LocalViscosity(1:n) = GetReal( Material, 'Viscosity', GotIt)361IF(.NOT.GotIt) CALL FATAL('ComputeDevStress','Variable >Viscosity Parameter< not found.')362!Give dummy default nodal values for rheology parameters associated to Porous:363LocalFluidity(1:n) = 1.0_dp364LocalDensity(1:n) = 1.0_dp365366!!!! When the Flow Solver is Porous:367ELSE IF (iSolverName ==2) THEN368! Get fluidity at nodes369LocalFluidity(1:n) = GetReal( Material, 'Fluidity Parameter', GotIt )370IF(.NOT.GotIt) CALL FATAL('ComputeDevStress','Variable >Fluidity Parameter< not found.')371! Get Density at element nodes372! The Density can be a DG variable and it is then safe to call it373! using the permutation vector374IF (DensityVariable%TYPE == Variable_on_nodes_on_elements) THEN375LocalDensity(1:n) = DensityValues(DensityPerm(CurrentElement % DGIndexes(1:n)))376ELSE377LocalDensity(1:n) = DensityValues(DensityPerm(CurrentElement % NodeIndexes(1:n)))378END IF379!Give dummy default nodal values for rheology parameters associated to Stokes:380LocalViscosity(1:n) = 1.0_dp381END IF382!-------------------------------------------------------------------------------------383!Independently of Flow Solver, get nodal velo, nodal pressure and cauchy stress option384!-------------------------------------------------------------------------------------385386! Do we want to return Cauchy or deviatoric stresses ? Deviatoric by default387Cauchy = ListGetLogical( Material , 'Cauchy', Gotit )388IF (.NOT.Gotit) THEN389Cauchy = .FALSE.390WRITE(Message,'(A)') 'Cauchy set to False'391CALL INFO('ComputeDevStress', Message, Level = 20)392END IF393394LocalVelo = 0.0_dp395DO i=1, dim396LocalVelo(i,1:n) = FlowValues((dim+1)*(FlowPerm(NodeIndexes(1:n))-1) + i)397END DO398BodyForce => GetBodyForce()399IF ( dim < 3 .AND. OutOfPlaneFlow ) THEN400LocalVelo(DIM+1,1:n) = ListGetReal(BodyForce,'Out Of Plane Velocity',&401n, NodeIndexes(1:n),GotIt)402IF (.NOT.GotIt) &403CALL WARN('ComputeDevStress',"Out of plane velocity not found")404END IF405406! Get Pressure at element nodes, i.e FlowValues((dim+1)*(FlowPerm(NodeIndexes(1:n))-1) + (dim +1))407LocalP(1:n) = FlowValues((dim+1)*FlowPerm(NodeIndexes(1:n)))408409410CALL LocalMatrix(COMP, LocalMassMatrix, LocalStiffMatrix, &411LocalForce, LocalVelo, LocalP, &412LocalViscosity, LocalFluidity, LocalDensity, &413CurrentElement, n, &414ElementNodes, Cauchy, iSolverName)415416!------------------------------------------------------------------------------417! Update global matrices from local matrices418!------------------------------------------------------------------------------419CALL DefaultUpdateEquations( LocalStiffMatrix, LocalForce )420421END DO422423CALL Info( 'ComputeDevStress', 'Assembly done', Level=4 )424425426CALL DefaultFinishAssembly()427428!------------------------------------------------------------------------------429! Dirichlet boundary conditions430!------------------------------------------------------------------------------431CALL DefaultDirichletBCs()432433!------------------------------------------------------------------------------434435CALL Info( 'ComputeDevStress', 'Set boundaries done', Level=4 )436437!------------------------------------------------------------------------------438! Solve the system and check for convergence439!------------------------------------------------------------------------------440PrevUNorm = UNorm441442UNorm = DefaultSolve()443444DO t=1,Solver % NumberOfActiveElements445CurrentElement => GetActiveElement(t)446n = GetElementNOFNodes()447DO i=1,n448k = CurrentElement % NodeIndexes(i)449Stress( StressDOFs*(StressPerm(k)-1) + COMP ) = &450Solver % Variable % Values( Solver % Variable % Perm(k) )451END DO452END DO453454END DO ! End DO Comp455456457IF (ComputeVMises) THEN458VMisesValues = 0.0_dp459DO k=1,Solver % Mesh % NumberOfNodes460IF (VMisesPerm(k) > 0) THEN461IF (DIM == 3) THEN462DO COMP = 1, 3463i = COMP + 1464IF (COMP == 3) i = 1465VMisesValues(VMisesPerm(k)) = VMisesValues(VMisesPerm(k)) &466+ 0.5_dp *( Stress( StressDOFs*(StressPerm(k)-1) + COMP ) &467- Stress( StressDOFs*(StressPerm(k)-1) + i ) )**2.0_dp &468+ 3.0_dp * (Stress( StressDOFs*(StressPerm(k)-1) + COMP + 3))**2.0_dp469END DO470ELSE IF (DIM == 2) THEN471DO COMP = 1, 2472VMisesValues(VMisesPerm(k)) = VMisesValues(VMisesPerm(k)) &473+ (Stress( StressDOFs*(StressPerm(k)-1) + COMP))**2.0_dp474END DO475VMisesValues(VMisesPerm(k)) = VMisesValues(VMisesPerm(k)) &476- (Stress( StressDOFs*(StressPerm(k)-1) + 1)) &477* (Stress( StressDOFs*(StressPerm(k)-1) + 2)) &478+ 3.0_dp * (Stress( StressDOFs*(StressPerm(k)-1) + 4))**2.0_dp479END IF480VMisesValues(VMisesPerm(k)) = SQRT(VMisesValues(VMisesPerm(k)))481END IF482END DO483END IF484485Unorm = SQRT( SUM( Stress**2 ) / SIZE(Stress) )486Solver % Variable % Norm = Unorm487488IF ( PrevUNorm + UNorm /= 0.0d0 ) THEN489RelativeChange = 2.0d0 * ABS( PrevUNorm - UNorm) / ( PrevUnorm + UNorm)490ELSE491RelativeChange = 0.0d0492END IF493494WRITE( Message, * ) 'Result Norm : ',UNorm, PrevUNorm495CALL Info( 'ComputeDevStress', Message, Level=4 )496WRITE( Message, * ) 'Relative Change : ',RelativeChange497CALL Info( 'ComputeDevStress', Message, Level=4 )498499500!------------------------------------------------------------------------------501END DO ! of nonlinear iter502!------------------------------------------------------------------------------503504505CONTAINS506507508!------------------------------------------------------------------------------509SUBROUTINE LocalMatrix(COMP, MassMatrix, StiffMatrix, ForceVector, &510NodalVelo, NodalP, NodalViscosity, NodalFluidity, NodalDensity, &511Element, n, Nodes, Cauchy, iSolverName )512!------------------------------------------------------------------------------513514USE MaterialModels515USE PorousMaterialModels516517REAL(KIND=dp) :: StiffMatrix(:,:), MassMatrix(:,:)518REAL(KIND=dp) :: NodalVelo(:,:)519REAL(KIND=dp), DIMENSION(:) :: ForceVector, &520NodalViscosity, NodalP, NodalFluidity, NodalDensity521TYPE(Nodes_t) :: Nodes522TYPE(Element_t), POINTER :: Element523LOGICAL :: Cauchy524INTEGER :: n, COMP525INTEGER :: iSolverName526!------------------------------------------------------------------------------527!528REAL(KIND=dp) :: Basis(2*n),ddBasisddx(1,1,1)529REAL(KIND=dp) :: dBasisdx(2*n,3),detJ, pBasis(n)530531REAL(KIND=dp) :: Stress, epsi532533REAL(KIND=dp) :: Pressure534REAL(KIND=dp) :: LGrad(3,3), SR(3,3)535536INTEGER :: i, j, k, p, q, t, dim, cc, NBasis, LinearBasis537538REAL(KIND=dp) :: s, u, v, w, Radius539540REAL(KIND=dp) :: Viscosity, Fluidity, Density, mu(2)541TYPE(GaussIntegrationPoints_t), TARGET :: IntegStuff542543INTEGER :: N_Integ, nd544INTEGER, DIMENSION(6), PARAMETER :: indx = (/1, 2, 3, 1, 2, 3/), &545indy = (/1, 2, 3, 2, 3, 1/)546547REAL(KIND=dp), DIMENSION(:), POINTER :: U_Integ,V_Integ,W_Integ,S_Integ548549LOGICAL :: stat, CSymmetry550551!------------------------------------------------------------------------------552dim = CoordinateSystemDimension()553cc=2*dim554555ForceVector = 0.0_dp556StiffMatrix = 0.0_dp557MassMatrix = 0.0_dp558559IntegStuff = GaussPoints( Element )560561U_Integ => IntegStuff % u562V_Integ => IntegStuff % v563W_Integ => IntegStuff % w564S_Integ => IntegStuff % s565N_Integ = IntegStuff % n566!567! Now we start integrating568!569DO t=1,N_Integ570571u = U_Integ(t)572v = V_Integ(t)573w = W_Integ(t)574575!------------------------------------------------------------------------------576! Basis function values & derivatives at the integration point577!------------------------------------------------------------------------------578stat = ElementInfo(Element,Nodes,u,v,w,detJ, &579Basis,dBasisdx,ddBasisddx,.FALSE.,.FALSE.)580581s = detJ * S_Integ(t)582583Radius = SUM( Nodes % x(1:n) * Basis(1:n) )584CSymmetry = CurrentCoordinateSystem() == AxisSymmetric585IF ( CSymmetry ) s = s * Radius586!587! Deviatoric Strain-Rate at IP588!589LGrad = 0.0_dp590LGrad = MATMUL( NodalVelo(:,1:n), dBasisdx(1:n,:) )591SR = 0.5 * ( LGrad + TRANSPOSE(LGrad) )592IF ( CSymmetry ) THEN593SR(1,3) = 0.0_dp594SR(2,3) = 0.0_dp595SR(3,1) = 0.0_dp596SR(3,2) = 0.0_dp597SR(3,3) = 0.0_dp598IF ( Radius > 10*AEPS ) THEN599SR(3,3) = SUM( Nodalvelo(1,1:n) * Basis(1:n) ) /Radius600601END IF602epsi = SR(1,1)+SR(2,2)+SR(3,3)603DO i=1,3604SR(i,i) = SR(i,i) - epsi/3.0_dp605END DO606ELSE607epsi = SR(1,1)+SR(2,2)+SR(3,3)608DO i=1,dim609SR(i,i) = SR(i,i) - epsi/dim !Deviatoric SR610END DO611END IF612!613! Get Effective Viscosity at IP614!615!!! For the Stokes616IF (iSolverName == 1) THEN617Viscosity = SUM( NodalViscosity(1:n)*Basis(1:n) )618Viscosity = EffectiveViscosity( Viscosity, 1.0_dp, NodalVelo(1,1:n), NodalVelo(2,1:n), NodalVelo(3,1:n), &619Element, Nodes, n, n, u, v, w, LocalIP=t )620!!! For the Porous621ELSE IF (iSolverName == 2) THEN622Fluidity = SUM( NodalFluidity(1:n)*Basis(1:n) )623Density = SUM( NodalDensity(1:n)*Basis(1:n) )624mu = PorousEffectiveViscosity( Fluidity, Density, SR, epsi, &625Element, Nodes, n, n, u, v, w, LocalIP=t ) !!mu=[eta, Kcp]626Viscosity = mu(1)627END IF628629!630! Compute deviatoric stresses or Cauchy stresses at IP for current COMP:631! ----------------------------632633Stress = 2.0 * Viscosity * SR(indx(COMP),indy(COMP))634635IF ((Cauchy).AND.(COMP.LE.3)) THEN636Pressure = SUM( NodalP(1:n)*Basis(1:n) )637Stress = Stress - Pressure638END IF639640DO p=1,n641DO q=1,n642StiffMatrix(p,q) = &643StiffMatrix(p,q) + s*Basis(q)*Basis(p)644END DO645ForceVector(p) = &646ForceVector(p) + s*Stress*Basis(p)647END DO648649END DO650651!------------------------------------------------------------------------------652END SUBROUTINE LocalMatrix653!------------------------------------------------------------------------------654655!------------------------------------------------------------------------------656END SUBROUTINE ComputeDevStress657!------------------------------------------------------------------------------658659660