Path: blob/devel/elmerice/Solvers/AIFlowSolve_nlD2.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: Juha Ruokolainen26! * Web: http://elmerice.elmerfem.org27! *28! * Original Date:29! * Date of modification: April 08 => non linear30! * May 09 => N-T (see mail Juha 20 Feb 2006) OG31! * Dec 15 =>2.5D FlowWidth O. Passalacqua32! *33! *****************************************************************************34!> Module containing a solver for (primarily thermal) anisotropic flow35RECURSIVE SUBROUTINE AIFlowSolver_nlD2( Model,Solver,dt,TransientSimulation )36!------------------------------------------------------------------------------3738USE DefUtils3940IMPLICIT NONE4142!------------------------------------------------------------------------------43!******************************************************************************44!45! Solve stress equations for one timestep46!47! ARGUMENTS:48!49! TYPE(Model_t) :: Model,50! INPUT: All model information (mesh,materials,BCs,etc...)51!52! TYPE(Solver_t) :: Solver53! INPUT: Linear equation solver options54!55! REAL(KIND=dp) :: dt,56! INPUT: Timestep size for time dependent simulations (NOTE: Not used57! currently)58!59!******************************************************************************6061TYPE(Model_t) :: Model62TYPE(Solver_t), TARGET :: Solver6364LOGICAL :: TransientSimulation65REAL(KIND=dp) :: dt66!------------------------------------------------------------------------------67! Local variables68!------------------------------------------------------------------------------69TYPE(Solver_t), POINTER :: PSolver7071TYPE(Matrix_t),POINTER :: StiffMatrix7273INTEGER :: i, j, k, l, n, t, iter, NDeg, STDOFs, LocalNodes, istat74INTEGER :: dim, comp7576TYPE(ValueList_t),POINTER :: Material, BC, BodyForce77TYPE(Nodes_t) :: ElementNodes78TYPE(Element_t),POINTER :: CurrentElement7980REAL(KIND=dp) :: RelativeChange, UNorm, PrevUNorm, Gravity(3), &81Normal(3), NewtonTol, NonlinearTol, s, Wn(7), MinSRInvariant828384REAL(KIND=dp) :: NodalStresses(3,3), &85NodalStrainRate(3,3), NodalSpin(3,3)8687REAL(KIND=dp), ALLOCATABLE :: Basis(:),ddBasisddx(:,:,:)88REAL(KIND=dp), ALLOCATABLE :: dBasisdx(:,:), SlipCoeff(:,:)89REAL(KIND=dp) :: u,v,w,detJ9091LOGICAL :: stat, CSymmetry = .FALSE., VariableFlowWidth = .FALSE., &92VariableLocalFlowWidth9394INTEGER, PARAMETER :: INDi(1:6) = (/ 1, 2, 3, 1, 2, 3 /) ,&95INDj(1:6)=(/ 1, 2, 3, 2, 3, 1 /)9697INTEGER :: NewtonIter, NonlinearIter9899TYPE(Variable_t), POINTER :: AIFlowSol, TempSol, Var, FabricVariable100TYPE(Variable_t), POINTER :: SpinVar101REAL(KIND=dp), POINTER :: SpinValues(:)102INTEGER, POINTER :: SpinPerm(:)103104TYPE(Variable_t), POINTER :: DevStressVar105REAL(KIND=dp), POINTER :: DSValues(:)106INTEGER, POINTER :: DSPerm(:)107108TYPE(Variable_t), POINTER :: StrainRateVar109REAL(KIND=dp), POINTER :: SRValues(:)110INTEGER, POINTER :: SRPerm(:)111112REAL(KIND=dp), POINTER :: Temperature(:),AIFlow(:),Work(:,:), &113ForceVector(:), VonMises(:), NodalAIFlow(:), AIFlowComp(:), &114FabricValues(:)115116CHARACTER(LEN=MAX_NAME_LEN) :: EquationName117118INTEGER, POINTER :: TempPerm(:), AIFlowPerm(:), NodeIndexes(:), &119FabricPerm(:)120121INTEGER :: AIFlowType122LOGICAL :: GotForceBC, GotIt, NewtonLinearization = .FALSE., &123NormalTangential=.FALSE., UnFoundFatal=.TRUE.124125INTEGER :: body_id,bf_id126INTEGER :: old_body = -1127LOGICAL :: Isotropic, AllocationsDone = .FALSE., FreeSurface, &128Requal0129130REAL(KIND=dp) :: FabricGrid(4878)131132REAL(KIND=dp), ALLOCATABLE:: LocalMassMatrix(:,:), &133LocalStiffMatrix(:,:), LoadVector(:,:), LocalForce(:), &134LocalTemperature(:), Alpha(:,:), Beta(:), &135ReferenceTemperature(:), BoundaryDispl(:), K1(:), K2(:), E1(:), &136E2(:), E3(:), TimeForce(:), RefS(:), RefD(:), RefSpin(:), &137LocalVelo(:,:), LocalFluidity(:), LocalFlowWidth(:)138139INTEGER :: NumberOfBoundaryNodes140INTEGER, POINTER :: BoundaryReorder(:)141142REAL(KIND=dp) :: Bu, Bv, Bw, RM(3,3)143REAL(KIND=dp), POINTER :: BoundaryNormals(:,:), &144BoundaryTangent1(:,:), BoundaryTangent2(:,:)145CHARACTER(LEN=MAX_NAME_LEN) :: viscosityFile146REAL(KIND=dp) :: Radius147REAL(KIND=dp) :: at, at0148!------------------------------------------------------------------------------149SAVE NumberOfBoundaryNodes,BoundaryReorder,BoundaryNormals, &150BoundaryTangent1, BoundaryTangent2, FabricGrid, viscosityFile151152SAVE TimeForce, Basis, dBasisdx, ddBasisddx153SAVE LocalMassMatrix, LocalStiffMatrix, LoadVector, &154LocalForce, ElementNodes, Alpha, Beta, LocalTemperature, LocalFlowWidth, &155Isotropic,AllocationsDone,ReferenceTemperature,BoundaryDispl, &156NodalAIFlow, K1, K2, E1, E2, E3, Wn, MinSRInvariant, old_body, &157LocalFluidity158159SAVE RefD, RefS, RefSpin, LocalVelo, SlipCoeff160!------------------------------------------------------------------------------161! Read constants from constants section of SIF file162!------------------------------------------------------------------------------163Wn(7) = GetConstReal( Model % Constants, 'Gas Constant', GotIt )164IF (.NOT.GotIt) THEN165WRITE(Message,'(A)') 'VariableGas Constant not found. &166&Setting to 8.314'167CALL INFO('AIFlowSolve', Message, level=20)168Wn(7) = 8.314169ELSE170WRITE(Message,'(A,F10.4)') 'Gas Constant = ', Wn(7)171CALL INFO('AIFlowSolve', Message , level = 20)172END IF173!------------------------------------------------------------------------------174! Get variables needed for solution175!------------------------------------------------------------------------------176IF ( .NOT. ASSOCIATED( Solver % Matrix ) ) RETURN177178AIFlowSol => Solver % Variable179AIFlowPerm => AIFlowSol % Perm180STDOFs = AIFlowSol % DOFs181AIFlow => AIFlowSol % Values182183LocalNodes = COUNT( AIFlowPerm > 0 )184IF ( LocalNodes <= 0 ) RETURN185186TempSol => VariableGet( Solver % Mesh % Variables, 'Temperature' )187IF ( ASSOCIATED( TempSol) ) THEN188TempPerm => TempSol % Perm189Temperature => TempSol % Values190END IF191192FabricVariable => VariableGet(Solver % Mesh % Variables, 'Fabric')193IF ( ASSOCIATED( FabricVariable ) ) THEN194FabricPerm => FabricVariable % Perm195FabricValues => FabricVariable % Values196END IF197198SpinVar => VariableGet(Solver % Mesh %Variables,'Spin')199IF ( ASSOCIATED( SpinVar ) ) THEN200SpinPerm => SpinVar % Perm201SpinValues => SpinVar % Values202END IF203204StrainRateVar => VariableGet(Solver % Mesh % Variables,'StrainRate')205IF ( ASSOCIATED( StrainRateVar ) ) THEN206SRPerm => StrainRateVar % Perm207SRValues => StrainRateVar % Values208END IF209210DevStressVar => &211VariableGet(Solver % Mesh % Variables,'DeviatoricStress')212IF ( ASSOCIATED( DevStressVar ) ) THEN213DSPerm => DevStressVar % Perm214DSValues => DevStressVar % Values215END IF216217IF ( CurrentCoordinateSystem() == AxisSymmetric ) THEN218CSymmetry = .TRUE.219VariableFlowWidth = .TRUE.220END IF221222StiffMatrix => Solver % Matrix223ForceVector => StiffMatrix % RHS224UNorm = Solver % Variable % Norm225226!------------------------------------------------------------------------------227! Allocate some permanent storage, this is done first time only228!------------------------------------------------------------------------------229IF ( .NOT. AllocationsDone .OR. Solver % Mesh % Changed) THEN230N = Model % MaxElementNodes231dim = CoordinateSystemDimension()232233IF ( AllocationsDone ) THEN234DEALLOCATE( ElementNodes % x, &235ElementNodes % y, &236ElementNodes % z, &237BoundaryDispl, &238ReferenceTemperature, &239LocalTemperature, &240LocalFlowWidth, &241K1,K2,E1,E2,E3, &242LocalForce, &243RefD, RefS, RefSpin, &244LocalVelo, &245Basis,ddBasisddx,dBasisdx, &246TimeForce, &247LocalMassMatrix, &248LocalStiffMatrix, &249LoadVector, Alpha, Beta, &250SlipCoeff, LocalFluidity )251END IF252253ALLOCATE( ElementNodes % x( N ), &254ElementNodes % y( N ), &255ElementNodes % z( N ), &256BoundaryDispl( N ), &257ReferenceTemperature( N ), &258LocalTemperature( N ), &259LocalFlowWidth (N), &260K1( N ), K2( N ), E1( N ), E2( N ), E3( N ), &261LocalForce( 2*STDOFs*N ),&262RefS(2*dim*LocalNodes ),&263RefD(2*dim*LocalNodes ),&264RefSpin((2*dim-3)*LocalNodes ),&265LocalVelo( 3,N ),&266Basis( 2*N ),ddBasisddx(1,1,1), dBasisdx( 2*N,3 ), &267TimeForce( 2*STDOFs*N ), &268LocalMassMatrix( 2*STDOFs*N,2*STDOFs*N ), &269LocalStiffMatrix( 2*STDOFs*N,2*STDOFs*N ), &270LoadVector( 4,N ), Alpha( 3,N ), Beta( N ), &271SlipCoeff(3,N), LocalFluidity(N), STAT=istat )272273IF ( istat /= 0 ) THEN274CALL Fatal( 'AIFlowSolve', 'Memory allocation error.' )275END IF276!------------------------------------------------------------------------------277278AllocationsDone = .TRUE.279END IF280281!------------------------------------------------------------------------------282! Do some additional initialization, and go for it283!------------------------------------------------------------------------------284285!------------------------------------------------------------------------------286NonlinearTol = GetConstReal( Solver % Values, &287'Nonlinear System Convergence Tolerance' )288289NewtonTol = GetConstReal( Solver % Values, &290'Nonlinear System Newton After Tolerance' )291292NewtonIter = GetInteger( Solver % Values, &293'Nonlinear System Newton After Iterations' )294295NonlinearIter = GetInteger( Solver % Values, &296'Nonlinear System Max Iterations',GotIt )297298IF ( .NOT.GotIt ) NonlinearIter = 1299!------------------------------------------------------------------------------300301!------------------------------------------------------------------------------302303EquationName = GetString( Solver % Values, 'Equation' )304305FreeSurface = .FALSE.306307!------------------------------------------------------------------------------308DO iter=1,NonlinearIter309310at = CPUTime()311at0 = RealTime()312313CALL Info( 'AIFlowSolve', ' ', Level=4 )314CALL Info( 'AIFlowSolve', ' ', Level=4 )315CALL Info( 'AIFlowSolve', &316'-------------------------------------',Level=4 )317WRITE( Message, * ) 'ANISOTROPIC FLOW SOLVER ITERATION', iter318CALL Info( 'AIFlowSolve', Message,Level=4 )319CALL Info( 'AIFlowSolve', &320'-------------------------------------',Level=4 )321CALL Info( 'AIFlowSolve', ' ', Level=4 )322CALL Info( 'AIFlowSolve', 'Starting assembly...',Level=4 )323!------------------------------------------------------------------------------324CALL DefaultInitialize()325!------------------------------------------------------------------------------326DO t=1,Solver % NumberOFActiveElements327328IF ( RealTime() - at0 > 1.0 ) THEN329WRITE(Message,'(a,i3,a)' ) ' Assembly: ', &330INT(100.0 - 100.0 * (Solver % NumberOfActiveElements-t) / &331(1.0*Solver % NumberOfActiveElements)), ' % done'332CALL Info( 'AIFlowSolve', Message, Level=5 )333at0 = RealTime()334END IF335336CurrentElement => GetActiveElement(t)337338n = GetElementNOFNodes()339NodeIndexes => CurrentElement % NodeIndexes340341ElementNodes % x(1:n) = Model % Nodes % x(NodeIndexes(1:n))342ElementNodes % y(1:n) = Model % Nodes % y(NodeIndexes(1:n))343ElementNodes % z(1:n) = Model % Nodes % z(NodeIndexes(1:n))344345Material => GetMaterial()346347!------------------------------------------------------------------------------348! Read in material constants from Material section349!------------------------------------------------------------------------------350body_id = CurrentElement % BodyId351IF (body_id /= old_body) Then352old_body = body_id353Call GetMaterialDefs()354END IF355356LocalFluidity(1:n) = ListGetReal( Material, &357'Fluidity Parameter', n, NodeIndexes, GotIt,UnFoundFatal=UnFoundFatal)358!Previous default value: LocalFluidity(1:n) = 1.0359360361LocalFlowWidth(1:n) = ListGetReal ( Material, &362'FlowWidth', n, NodeIndexes, GotIt)363IF (.NOT. GotIt) THEN364IF (CSymmetry) THEN365DO i=1,n366LocalFlowWidth(i) = ElementNodes % x(i)367END DO368END IF369ELSE370VariableFlowWidth = .TRUE.371END IF372373! Test if flow width is locally constant (infinite radius case)374VariableLocalFlowWidth = .TRUE.375IF (MAXVAL(LocalFlowWidth(1:n))- &376MINVAL(LocalFlowWidth(1:n)) == 0.0) &377VariableLocalFlowWidth = .FALSE.378379!------------------------------------------------------------------------------380! Set body forces381!------------------------------------------------------------------------------382LoadVector = 0.0D0383384BodyForce => GetBodyForce()385IF ( ASSOCIATED( BodyForce ) ) THEN386LoadVector(1,1:n) = LoadVector(1,1:n) + ListGetReal( &387BodyForce, 'AIFlow Force 1', n, NodeIndexes, gotIt)388LoadVector(2,1:n) = LoadVector(2,1:n) + ListGetReal( &389BodyForce, 'AIFlow Force 2', n, NodeIndexes, gotIt)390LoadVector(3,1:n) = LoadVector(3,1:n) + ListGetReal( &391BodyForce, 'AIFlow Force 3', n, NodeIndexes, gotIt)392END IF393!------------------------------------------------------------------------------394! Get element local stiffness & mass matrices395!------------------------------------------------------------------------------396LocalTemperature = 0.0D0397IF ( ASSOCIATED(TempSol) ) THEN398DO i=1,n399k = TempPerm(NodeIndexes(i))400LocalTemperature(i) = Temperature(k)401END DO402ELSE403LocalTemperature(1:n) = 0.0d0404END IF405406! fabric not needed if isotropic407IF(.NOT.Isotropic) THEN408K1(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 1 )409K2(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 2 )410E1(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 3 )411E2(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 4 )412E3(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 5 )413ENDIF414415LocalVelo = 0.0d0416DO i=1,STDOFs - 1417LocalVelo(i,1:n) = AIFlow( STDOFs*(AIFlowPerm(NodeIndexes(1:n))-1) + i)418END DO419420CALL LocalMatrix( LocalMassMatrix, LocalStiffMatrix, &421LocalForce, LoadVector, K1, K2, E1, E2, E3, LocalVelo, &422LocalTemperature, LocalFlowWidth, LocalFluidity, CurrentElement, n, &423ElementNodes, Wn, MinSRInvariant, Isotropic, VariableFlowWidth, &424VariableLocalFlowWidth)425426TimeForce = 0.0d0427CALL NSCondensate(N, N,STDOFs-1,LocalStiffMatrix,LocalForce,TimeForce )428!------------------------------------------------------------------------------429! Update global matrices from local matrices430!------------------------------------------------------------------------------431CALL DefaultUpdateEquations( LocalStiffMatrix, LocalForce )432END DO433CALL DefaultFinishBulkAssembly()434CALL Info( 'AIFlowSolve', 'Assembly done', Level=4 )435436!------------------------------------------------------------------------------437! Neumann & Newton boundary conditions438!------------------------------------------------------------------------------439DO t = 1, Model % NumberOFBoundaryElements440441CurrentElement => GetBoundaryElement(t)442443IF ( GetElementFamily() == 101 ) CYCLE444IF ( .NOT. ActiveBoundaryElement() ) CYCLE445446n = GetElementNOFNodes()447NodeIndexes => CurrentElement % NodeIndexes448449ElementNodes % x(1:n) = Model % Nodes % x(NodeIndexes(1:n))450ElementNodes % y(1:n) = Model % Nodes % y(NodeIndexes(1:n))451ElementNodes % z(1:n) = Model % Nodes % z(NodeIndexes(1:n))452453BC => GetBC()454IF ( ASSOCIATED( BC ) ) THEN455LoadVector = 0.0D0456Alpha = 0.0D0457Beta = 0.0D0458!------------------------------------------------------------------------------459! Force in given direction BC: \tau\cdot n = F460!------------------------------------------------------------------------------461GotForceBC = .FALSE.462463LoadVector(1,1:n) = &464ListGetReal( BC, 'Force 1', n, NodeIndexes, GotIt )465GotForceBC = GotForceBC .OR. gotIt466467LoadVector(2,1:n) = &468ListGetReal( BC, 'Force 2', n, NodeIndexes, GotIt )469GotForceBC = GotForceBC .OR. gotIt470471LoadVector(3,1:n) = &472ListGetReal( BC, 'Force 3', n, NodeIndexes, GotIt )473GotForceBC = GotForceBC .OR. gotIt474475Beta(1:n) = &476ListGetReal( BC, 'Normal Force', n, NodeIndexes, GotIt )477GotForceBC = GotForceBC .OR. gotIt478479!------------------------------------------------------------------------------480! slip boundary condition BC: \tau\cdot n = R_k u_k481!------------------------------------------------------------------------------482483SlipCoeff = 0.0d0484SlipCoeff(1,1:n) = ListGetReal( BC, &485'AIFlow Slip Coeff 1', n, NodeIndexes, GotIt )486GotForceBC = GotForceBC .OR. gotIt487488SlipCoeff(2,1:n) = ListGetReal( BC, &489'AIFlow Slip Coeff 2', n, NodeIndexes, GotIt )490GotForceBC = GotForceBC .OR. gotIt491492SlipCoeff(3,1:n) = ListGetReal( BC, &493'AIFlow Slip Coeff 3', n, NodeIndexes, GotIt )494GotForceBC = GotForceBC .OR. gotIt495496NormalTangential = ListGetLogical( BC, &497'Normal-Tangential AIFlow', GotIt )498499IF ( .NOT.GotForceBC ) CYCLE500501!------------------------------------------------------------------------------502CALL LocalMatrixBoundary( LocalStiffMatrix, LocalForce, &503LoadVector, Alpha, Beta, SlipCoeff, NormalTangential, &504CurrentElement, n, ElementNodes, VariableFlowWidth, &505VariableLocalFlowWidth, LocalFlowWidth )506!------------------------------------------------------------------------------507!------------------------------------------------------------------------------508! Update global matrices from local matrices (will also affect509! LocalStiffMatrix and LocalForce if transientsimulation is on).510!------------------------------------------------------------------------------511CALL DefaultUpdateEquations( LocalStiffMatrix, LocalForce )512!------------------------------------------------------------------------------513END IF514END DO515!------------------------------------------------------------------------------516CALL DefaultFinishBoundaryAssembly()517CALL DefaultFinishAssembly()518519!------------------------------------------------------------------------------520! Dirichlet boundary conditions521!------------------------------------------------------------------------------522CALL DefaultDirichletBCs()523!------------------------------------------------------------------------------524525CALL Info( 'AIFlowSolve', 'Set boundaries done', Level=4 )526527!------------------------------------------------------------------------------528! Solve the system and check for convergence529!------------------------------------------------------------------------------530PrevUNorm = UNorm531532UNorm = DefaultSolve()533534IF ( PrevUNorm + UNorm /= 0.0d0 ) THEN535RelativeChange = 2.0d0 * ABS( PrevUNorm - UNorm) / ( PrevUnorm + UNorm)536ELSE537RelativeChange = 0.0d0538END IF539540WRITE( Message, * ) 'Result Norm : ',UNorm, PrevUNorm541CALL Info( 'AIFlowSolve', Message, Level=4 )542WRITE( Message, * ) 'Relative Change : ',RelativeChange543CALL Info( 'AIFlowSolve', Message, Level=4 )544545!------------------------------------------------------------------------------546IF ( RelativeChange < NewtonTol .OR. &547iter > NewtonIter ) NewtonLinearization = .TRUE.548549IF ( RelativeChange < NonLinearTol ) EXIT550551!------------------------------------------------------------------------------552END DO ! of nonlinear iter553!------------------------------------------------------------------------------554555!------------------------------------------------------------------------------556! Compute the StrainRate, Spin and deviatoric Stress557! Nodal values558!------------------------------------------------------------------------------559560IF ((ASSOCIATED( StrainRateVar)).OR.(ASSOCIATED(DevStressVar))&561.OR.(ASSOCIATED(SpinVar))) THEN562RefD=0.563RefS=0.564RefSpin=0.565IF (ASSOCIATED(StrainRateVar)) SRValues = 0.566IF (ASSOCIATED(devStressVar)) DSValues = 0.567IF (ASSOCIATED(SPinVar)) SpinValues = 0.568569DO t=1,Solver % NumberOFActiveElements570571CurrentElement => GetActiveElement(t)572n = GetElementNOFNodes()573NodeIndexes => CurrentElement % NodeIndexes574575body_id = CurrentElement % BodyId576dim = CoordinateSystemDimension()577578!------------------------------------------------------------------------------579! Read in material constants from Material section580!------------------------------------------------------------------------------581IF (body_id /= old_body) Then582old_body = body_id583Call GetMaterialDefs()584END IF585586LocalFluidity(1:n) = ListGetReal( Material, &587'Fluidity Parameter', n, NodeIndexes, GotIt,&588UnFoundFatal=UnFoundFatal)589!Previous default value: LocalFluidity(1:n) = 1.0590591LocalFlowWidth(1:n) = ListGetReal ( Material, &592'FlowWidth', n, NodeIndexes, GotIt)593IF (.NOT. GotIt .AND. CSymmetry) THEN594DO i=1,n595LocalFlowWidth(i) = ElementNodes % x(i)596END DO597END IF598599ElementNodes % x(1:n) = Model % Nodes % x(NodeIndexes(1:n))600ElementNodes % y(1:n) = Model % Nodes % y(NodeIndexes(1:n))601ElementNodes % z(1:n) = Model % Nodes % z(NodeIndexes(1:n))602603! n nodale values of the temperature604605LocalTemperature = 0.0D0606IF ( ASSOCIATED(TempSol) ) THEN607DO i=1,n608k = TempPerm(NodeIndexes(i))609LocalTemperature(i) = Temperature(k)610END DO611ELSE612LocalTemperature(1:n) = 0.0d0613END IF614615! n nodales values of the 5 fabric parameters, not needed if isotropic616IF(.NOT.Isotropic) Then617K1(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 1 )618K2(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 2 )619E1(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 3 )620E2(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 4 )621E3(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 5 )622END IF623624! 2D U,V,p STDOFs=3625! 3D U,V,W,p STDOFs=4626LocalVelo = 0.0d0627DO i=1,STDOFs - 1628LocalVelo(i,1:n) = AIFlow( STDOFs*(AIFlowPerm(NodeIndexes(1:n))-1) + i)629END DO630631! Go for all nodes of the element632Do i=1,n633634! u, v, w local coord of node i635u = CurrentElement % Type % NodeU(i)636v = CurrentElement % Type % NodeV(i)637w = CurrentElement % Type % NodeW(i)638639stat = ElementInfo(CurrentElement,ELementNodes,u,v,w,detJ, &640Basis,dBasisdx,ddBasisddx,.FALSE.,.FALSE.)641642! Variable flow width case when R=0 strain, stress not calculated exactly in643! x=0 (I agree it is not very nice, better solution ???)644Requal0 = .False.645IF (( VariableFlowWidth ) .And. &646(SUM(LocalFlowWidth (1:n) * Basis(1:n)) == 0.0)) THEN647Requal0 = .True.648u= u + 0.0001649stat = ElementInfo(CurrentElement,ELementNodes,u,v,w,detJ, &650Basis,dBasisdx,ddBasisddx,.FALSE.,.FALSE.)651END IF652653CALL LocalSD(NodalStresses, NodalStrainRate, NodalSpin, &654LocalVelo, LocalTemperature, LocalFluidity, &655LocalFlowWidth, K1, K2, E1, E2, E3, Basis, dBasisdx, &656CurrentElement, n, ElementNodes, dim, Wn, &657MinSRInvariant, Isotropic, VariableFlowWidth, &658VariableLocalFlowWidth)659660IF (Requal0) NodalSpin = 0.661662IF (ASSOCIATED(StrainRateVar)) &663RefD(2*dim*(SRPerm(NodeIndexes(i))-1)+1 : &6642*dim*SRPerm(NodeIndexes(i))) &665=RefD(2*dim*(SRPerm(NodeIndexes(i))-1)+1 : &6662*dim*SRPerm(NodeIndexes(i))) + 1.667668IF (ASSOCIATED(DevStressVar)) &669RefS(2*dim*(DSPerm(NodeIndexes(i))-1)+1 : &6702*dim*DSPerm(NodeIndexes(i))) &671=RefS(2*dim*(DSPerm(NodeIndexes(i))-1)+1 : &6722*dim*DSPerm(NodeIndexes(i))) + 1.673674IF (ASSOCIATED(SpinVar)) &675RefSpin((2*dim-3)*(SpinPerm(NodeIndexes(i))-1)+1 : &676(2*dim-3)*SpinPerm(NodeIndexes(i))) &677=RefSpin((2*dim-3)*(SpinPerm(NodeIndexes(i))-1)+1 : &678(2*dim-3)*SpinPerm(NodeIndexes(i))) + 1.679680681IF (ASSOCIATED(StrainRateVar)) THEN682comp=0683DO j=1,2*dim684comp=comp+1685SRValues(2*dim*(SRPerm(NodeIndexes(i))-1)+comp)=&686SRValues(2*dim*(SRPerm(NodeIndexes(i))-1)+comp) + &687NodalStrainRate(INDi(j),INDj(j))688END DO689END IF690691IF (ASSOCIATED(DevStressVar)) THEN692comp=0693DO j=1,2*dim694comp=comp+1695DSValues(2*dim*(DSPerm(NodeIndexes(i))-1)+comp)=&696DSValues(2*dim*(DSPerm(NodeIndexes(i))-1)+comp) + &697NodalStresses(INDi(j),INDj(j))698END DO699END IF700701IF (ASSOCIATED(SpinVar)) THEN702comp=0703DO j=1,(2*dim-3)704comp=comp+1705SpinValues((2*dim-3)*(SpinPerm(NodeIndexes(i))-1)+comp)=&706SPinValues((2*dim-3)*(SpinPerm(NodeIndexes(i))-1)+comp) + &707NodalSpin(INDi(j+3),INDj(j+3))708END DO709END IF710711END DO712END DO713714IF (ASSOCIATED(StrainRateVar)) THEN715WHERE(RefD > 0.)716SRVAlues = SRValues / RefD717END WHERE718END IF719720IF (ASSOCIATED(DevStressVar)) THEN721WHERE(RefS > 0.)722DSVAlues = DSValues / RefS723END WHERE724END IF725726IF (ASSOCIATED(SpinVar)) THEN727WHERE(RefSpin > 0.)728SpinVAlues = SpinValues / RefSpin729END WHERE730END IF731732END IF733734!------------------------------------------------------------------------------735! END Compute the StrainRate and Deviatoric Stress736!------------------------------------------------------------------------------737738CONTAINS739740SUBROUTINE GetMaterialDefs()741! check if we are isotropic or not742Isotropic = ListGetLogical( Material , 'Isotropic',Gotit )743IF (.NOT.Gotit) Then744Isotropic = .False.745WRITE(Message,'(A)') 'Isotropic set to False'746CALL INFO('AIFlowSolve', Message, Level = 20)747ELSE748IF ( (ASSOCIATED( FabricVariable )).AND.Isotropic ) Then749WRITE(Message,'(A)') 'Be careful Isotropic is true &750& and Fabric is defined!'751CALL INFO('AIFlowSolve', Message, Level = 1)752END IF753END IF754755IF (.NOT.Isotropic) Then756! Get the viscosity file and store the viscosities into FabricGrid757viscosityFile = ListGetString( Material ,'Viscosity File',GotIt,UnFoundFatal )758OPEN( 1, File = viscosityFile)759DO i=1,813760READ( 1, '(6(e14.8))' ) FabricGrid( 6*(i-1)+1:6*(i-1)+6 )761END DO762CLOSE(1)763ENDIF764765Wn(2) = ListGetConstReal( Material , 'Powerlaw Exponent', GotIt,UnFoundFatal=UnFoundFatal)766!Previous default value: Wn(2) = 1.0767WRITE(Message,'(A,F10.4)') 'Powerlaw Exponent = ', Wn(2)768CALL INFO('AIFlowSolve', Message, Level = 20)769770Wn(3) = ListGetConstReal( Material, 'Activation Energy 1', GotIt,UnFoundFatal=UnFoundFatal)771!Previous default value: Wn(3) = 1.0772WRITE(Message,'(A,F10.4)') 'Activation Energy 1 = ', Wn(3)773CALL INFO('AIFlowSolve', Message, Level = 20)774775Wn(4) = ListGetConstReal( Material, 'Activation Energy 2', GotIt,UnFoundFatal=UnFoundFatal)776!Previous default value: Wn(4) = 1.0777WRITE(Message,'(A,F10.4)') 'Activation Energy 2 = ', Wn(4)778CALL INFO('AIFlowSolve', Message, Level = 20)779780Wn(5) = ListGetConstReal(Material, 'Reference Temperature', GotIt,UnFoundFatal=UnFoundFatal)781!Previous default value: Wn(5) = -10.0 (Celsius)782WRITE(Message,'(A,F10.4)') 'Reference Temperature = ', Wn(5)783CALL INFO('AIFlowSolve', Message, Level = 20)784785Wn(6) = ListGetConstReal( Material, 'Limit Temperature', GotIt,UnFoundFatal=UnFoundFatal)786!Previous default value: Wn(6) = -10.0 (Celsius)787WRITE(Message,'(A,F10.4)') 'Limit Temperature = ', Wn(6)788CALL INFO('AIFlowSolve', Message, Level = 20)789790! Get the Minimum value of the Effective Strain rate791MinSRInvariant = 100.0*AEPS792793IF ( Wn(2) > 1.0 ) THEN794MinSRInvariant = &795ListGetConstReal( Material, 'Min Second Invariant', GotIt )796IF (.NOT.GotIt) THEN797WRITE(Message,'(A)') 'Variable Min Second Invariant not &798&found. Setting to 100.0*AEPS )'799CALL INFO('AIFlowSolve', Message, Level = 20)800ELSE801WRITE(Message,'(A,E14.8)') 'Min Second Invariant = ', MinSRInvariant802CALL INFO('AIFlowSolve', Message, Level = 20)803END IF804END IF805806!------------------------------------------------------------------------------807END SUBROUTINE GetMaterialDefs808!------------------------------------------------------------------------------809810!------------------------------------------------------------------------------811SUBROUTINE LocalMatrix( MassMatrix, StiffMatrix, ForceVector, &812LoadVector, NodalK1, NodalK2, NodalEuler1, NodalEuler2, &813NodalEuler3, NodalVelo, NodalTemperature, NodalFlowWidth, &814NodalFluidity, Element, n, Nodes, Wn, MinSRInvariant, Isotropic, &815VariableFlowWidth, VariableLocalFlowWidth )816817!------------------------------------------------------------------------------818819REAL(KIND=dp) :: StiffMatrix(:,:), MassMatrix(:,:)820REAL(KIND=dp) :: LoadVector(:,:), NodalVelo(:,:)821REAL(KIND=dp) :: Wn(7), MinSRInvariant822REAL(KIND=dp), DIMENSION(:) :: ForceVector, NodalK1, NodalK2, &823NodalEuler1, NodalEuler2, NodalEuler3, NodalTemperature, &824NodalFluidity, NodalFlowWidth825TYPE(Nodes_t) :: Nodes826TYPE(Element_t) :: Element827LOGICAL :: Isotropic, VariableFlowWidth, VariableLocalFlowWidth828INTEGER :: n829!------------------------------------------------------------------------------830!831REAL(KIND=dp) :: Basis(2*n),ddBasisddx(1,1,1)832REAL(KIND=dp) :: dBasisdx(2*n,3),SqrtElementMetric833834REAL(KIND=dp) :: Force(3), K1, K2, Euler1, Euler2, Euler3835Real(kind=dp) :: Bg, BGlenT836837REAL(KIND=dp), DIMENSION(4,4) :: A,M838REAL(KIND=dp) :: Load(3),Temperature, C(6,6)839REAL(KIND=dp) :: nn, ss,pp, LGrad(3,3), SR(3,3), Stress(3,3), D(6), epsi840INTEGER :: INDi(6),INDj(6)841842843INTEGER :: i, j, k, p, q, t, dim, NBasis, ind(3)844845REAL(KIND=dp) :: s,u,v,w, Radius, B(6,3), G(3,6), FW846847REAL(KIND=dp) :: dDispldx(3,3), ai(3), Angle(3), a2(6)848TYPE(GaussIntegrationPoints_t), TARGET :: IntegStuff849850INTEGER :: N_Integ851852REAL(KIND=dp), DIMENSION(:), POINTER :: U_Integ,V_Integ,W_Integ,S_Integ853854LOGICAL :: stat855856INTERFACE857Subroutine R2Ro(a2,dim,ai,angle)858USE Types859REAL(KIND=dp),intent(in) :: a2(6)860Integer :: dim861REAL(KIND=dp),intent(out) :: ai(3), Angle(3)862End Subroutine R2Ro863864Subroutine OPILGGE_ai_nl(ai,Angle,etaI,eta36)865USE Types866REAL(kind=dp), INTENT(in), DIMENSION(3) :: ai867REAL(kind=dp), INTENT(in), DIMENSION(3) :: Angle868REAL(kind=dp), INTENT(in), DIMENSION(:) :: etaI869REAL(kind=dp), INTENT(out), DIMENSION(6,6) :: eta36870END SUBROUTINE OPILGGE_ai_nl871872END INTERFACE873!------------------------------------------------------------------------------874dim = CoordinateSystemDimension()875876ForceVector = 0.0D0877StiffMatrix = 0.0D0878MassMatrix = 0.0D0879880!881! Integration stuff882!883NBasis = 2*n884IntegStuff = GaussPoints( Element, Element % Type % GaussPoints2 )885886U_Integ => IntegStuff % u887V_Integ => IntegStuff % v888W_Integ => IntegStuff % w889S_Integ => IntegStuff % s890N_Integ = IntegStuff % n891!892! Now we start integrating893!894DO t=1,N_Integ895896u = U_Integ(t)897v = V_Integ(t)898w = W_Integ(t)899900!------------------------------------------------------------------------------901! Basis function values & derivatives at the integration point902!------------------------------------------------------------------------------903stat = ElementInfo( Element,Nodes,u,v,w,SqrtElementMetric, &904Basis,dBasisdx,ddBasisddx,.FALSE.,.TRUE. )905906s = SqrtElementMetric * S_Integ(t)907!------------------------------------------------------------------------------908!909! Force at integration point910!911Force = 0.0d0912DO i=1,dim913Force(i) = SUM( LoadVector(i,1:n)*Basis(1:n))914END DO915!916! Temperature at the integration point917!918Temperature = SUM( NodalTemperature(1:n)*Basis(1:n) )919Wn(1) = SUM( NodalFluidity(1:n)*Basis(1:n) )920Bg=BGlenT(Temperature,Wn)921ss=1.0_dp922923! if not isotropic use GOLF924C = 0.0_dp925IF (.NOT.Isotropic) Then926a2(1) = SUM( NodalK1(1:n) * Basis(1:n) )927a2(2) = SUM( NodalK2(1:n) * Basis(1:n) )928a2(3) = 1.d0 - a2(1) - a2(2)929a2(4) = SUM( NodalEuler1(1:n) * Basis(1:n) )930a2(5) = SUM( NodalEuler2(1:n) * Basis(1:n) )931a2(6) = SUM( NodalEuler3(1:n) * Basis(1:n) )932933CALL R2Ro(a2,dim,ai,angle)934CALL OPILGGE_ai_nl(ai,Angle,FabricGrid,C)935! else use isotropic law936ELSE937Do i=1,3938C(i,i)=2.0_dp939End do940Do i=4,6941C(i,i)=1.0_dp942End do943ENDIF944945FW = SUM( NodalFlowWidth(1:n) * Basis(1:n) )946Radius = FW / (SUM( NodalFlowWidth(1:n) * dBasisdx(1:n,1)) )947IF (.NOT. VariableLocalFlowWidth) Radius = 10e7948IF (VariableFlowWidth ) s = s * FW949950!951! Case non-linear952! -----------------------------953954IF ( Wn(2) > 1.0 ) THEN955956Bg=Bg**(1.0/Wn(2))957958LGrad = MATMUL( NodalVelo(:,1:n), dBasisdx(1:n,:) )959SR = 0.5 * ( LGrad + TRANSPOSE(LGrad) )960961IF ( VariableFlowWidth ) THEN962SR(1,3) = 0.0963SR(2,3) = 0.0964SR(3,1) = 0.0965SR(3,2) = 0.0966SR(3,3) = 0.0967IF ( Radius > 10*AEPS ) THEN968SR(3,3) = SUM( Nodalvelo(1,1:n) * Basis(1:n) ) /Radius969END IF970epsi = SR(1,1)+SR(2,2)+SR(3,3)971DO i=1,3972SR(i,i) = SR(i,i) - epsi/3.0973END DO974ELSE975epsi = SR(1,1)+SR(2,2)+SR(3,3)976DO i=1,dim977SR(i,i) = SR(i,i) - epsi/dim978END DO979END IF980981! Compute the invariant982nn = (1.0 - Wn(2))/(2.0*Wn(2))983ss = 0.0_dp984DO i = 1, 3985DO j = 1, 3986ss = ss + SR(i,j)**2.987END DO988END DO989IF (ss < MinSRInvariant ) ss = MinSRInvariant990ss = (2.*ss)**nn991END IF992993! Non relative viscosity matrix994C = C * ss/Bg995996!997! Loop over basis functions (of both unknowns and weights)998!999A = 0.0d01000M = 0.0d01001B = 0.0d010021003DO p=1,NBasis10041005G = 0.0d010061007IF ( VariableFlowWidth ) THEN1008G(1,1) = dBasisdx(p,1)1009G(1,3) = Basis(p) / Radius1010G(1,4) = dBasisdx(p,2)1011G(2,2) = dBasisdx(p,2)1012G(2,4) = dBasisdx(p,1)1013ELSE1014G(1,1) = dBasisdx(p,1)1015G(2,2) = dBasisdx(p,2)1016G(3,3) = dBasisdx(p,3)1017G(1,4) = dBasisdx(p,2)1018G(2,4) = dBasisdx(p,1)1019G(2,5) = dBasisdx(p,3)1020G(3,5) = dBasisdx(p,2)1021G(1,6) = dBasisdx(p,3)1022G(3,6) = dBasisdx(p,1)1023END IF10241025G = MATMUL( G, C )10261027DO q=1,NBasis10281029B = 0.0d010301031IF ( VariableFlowWidth ) THEN1032B(1,1) = dBasisdx(q,1)1033B(2,2) = dBasisdx(q,2)1034B(3,1) = Basis(q) / Radius1035B(4,1) = dBasisdx(q,2)1036B(4,2) = dBasisdx(q,1)1037ELSE1038B(1,1) = dBasisdx(q,1)1039B(2,2) = dBasisdx(q,2)1040B(3,3) = dBasisdx(q,3)1041B(4,1) = dBasisdx(q,2)1042B(4,2) = dBasisdx(q,1)1043B(5,2) = dBasisdx(q,3)1044B(5,3) = dBasisdx(q,2)1045B(6,1) = dBasisdx(q,3)1046B(6,3) = dBasisdx(q,1)1047END IF10481049A(1:3,1:3) = MATMUL( G, B )10501051! Pressure gradient1052DO i=1,dim1053A(i,dim+1) = -dBasisdx(p,i) * Basis(q)1054END DO1055IF ( VariableFlowWidth ) A(1,dim+1) = A(1,dim+1) - Basis(p) * Basis(q) / Radius10561057! Continuity equation:1058DO i=1,dim1059A(dim+1,i) = dBasisdx(q,i) * Basis(p)1060END DO1061IF ( VariableFlowWidth ) A(dim+1,1) = A(dim+1,1) + Basis(p) * Basis(q) / Radius1062A(dim+1, dim+1) = 0.0d010631064! Add nodal matrix to element matrix1065DO i=1,dim+11066DO j=1,dim+11067StiffMatrix( (dim+1)*(p-1)+i,(dim+1)*(q-1)+j ) = &1068StiffMatrix( (dim+1)*(p-1)+i,(dim+1)*(q-1)+j ) + s*A(i,j)1069END DO1070END DO10711072END DO10731074! The righthand side...1075Load = 0.0d010761077DO i=1,dim1078Load(i) = Load(i) + Force(i) * Basis(p)1079END DO10801081DO i=1,dim1082ForceVector((dim+1)*(p-1)+i) = ForceVector((dim+1)*(p-1)+i) + s*Load(i)1083END DO1084END DO10851086END DO1087!------------------------------------------------------------------------------1088END SUBROUTINE LocalMatrix1089!------------------------------------------------------------------------------10901091!------------------------------------------------------------------------------1092SUBROUTINE LocalMatrixBoundary( BoundaryMatrix, BoundaryVector, &1093LoadVector, NodalAlpha, NodalBeta, NodalSlipCoeff, &1094NormalTangential, Element, n, Nodes, &1095VariableFlowWidth, VariableLocalFlowWidth, NodalFlowWidth )10961097!------------------------------------------------------------------------------1098REAL(KIND=dp) :: BoundaryMatrix(:,:),BoundaryVector(:)1099REAL(KIND=dp) :: NodalAlpha(:,:),NodalBeta(:),LoadVector(:,:)1100REAL(KIND=dp) :: NodalSlipCoeff(:,:), NodalFlowWidth(:)1101TYPE(Element_t),POINTER :: Element1102TYPE(Nodes_t) :: Nodes1103LOGICAL :: NormalTangential1104INTEGER, POINTER :: NodeIndexes(:)1105INTEGER :: n1106!------------------------------------------------------------------------------1107REAL(KIND=dp) :: Basis(n),ddBasisddx(1,1,1)1108REAL(KIND=dp) :: dBasisdx(n,3),SqrtElementMetric, FW11091110REAL(KIND=dp) :: u,v,w,s1111REAL(KIND=dp) :: Force(3),Alpha(3),Beta,Normal(3)1112REAL(KIND=dp), POINTER :: U_Integ(:),V_Integ(:),W_Integ(:),S_Integ(:)1113REAL(KIND=dp) :: Tangent(3),Tangent2(3),Vect(3), SlipCoeff1114REAL(KIND=dp) :: Up,Vp,Wp1115INTEGER :: i,t,q,p,dim,N_Integ, c11161117LOGICAL :: stat, VariableFlowWidth, VariableLocalFlowWidth1118LOGICAL,SAVE :: AllocationDone=.False.11191120TYPE(GaussIntegrationPoints_t), TARGET :: IntegStuff1121!------------------------------------------------------------------------------11221123dim = CoordinateSystemDimension()1124c=dim+111251126BoundaryVector = 0.0D01127BoundaryMatrix = 0.0D01128!1129! Integration stuff1130!1131IntegStuff = GaussPoints( element )1132U_Integ => IntegStuff % u1133V_Integ => IntegStuff % v1134W_Integ => IntegStuff % w1135S_Integ => IntegStuff % s1136N_Integ = IntegStuff % n11371138NodeIndexes => Element % NodeIndexes11391140NodalFlowWidth(1:n) = ListGetReal ( Material, &1141'FlowWidth', n, NodeIndexes, GotIt)1142IF (.NOT. GotIt .AND. CSymmetry) THEN1143DO i=1,n1144NodalFlowWidth(i) = Nodes % x(i)1145END DO1146END IF1147!1148! Now we start integrating1149!1150DO t=1,N_Integ11511152u = U_Integ(t)1153v = V_Integ(t)1154w = W_Integ(t)11551156!------------------------------------------------------------------------------1157! Basis function values & derivatives at the integration point1158!------------------------------------------------------------------------------1159stat = ElementInfo( Element, Nodes, u, v, w, SqrtElementMetric, &1160Basis, dBasisdx, ddBasisddx, .FALSE. )11611162FW = SUM( NodalFlowWidth(1:n) * Basis(1:n) )11631164s = SqrtElementMetric * S_Integ(t)11651166IF (.NOT. VariableLocalFlowWidth ) Radius = 10e71167IF ( VariableFlowWidth ) s= s * FW11681169!------------------------------------------------------------------------------1170Force = 0.0D01171DO i=1,dim1172Force(i) = SUM( LoadVector(i,1:n)*Basis(1:n) )1173Alpha(i) = SUM( NodalAlpha(i,1:n)*Basis(1:n) )1174END DO11751176Normal = NormalVector( Element,Nodes,u,v,.TRUE. )1177Force = Force + SUM( NodalBeta(1:n)*Basis(1:n) ) * Normal11781179SELECT CASE( Element % TYPE % DIMENSION )1180CASE(1)1181Tangent(1) = Normal(2)1182Tangent(2) = -Normal(1)1183Tangent(3) = 0.0d01184CASE(2)1185CALL TangentDirections( Normal, Tangent, Tangent2 )1186END SELECT11871188IF ( ANY( NodalSlipCoeff(:,:) /= 0.0d0 ) ) THEN1189DO p=1,n1190DO q=1,n1191DO i=1,DIM1192SlipCoeff = SUM( NodalSlipCoeff(i,1:n) * Basis(1:n) )11931194IF (NormalTangential ) THEN1195SELECT CASE(i)1196CASE(1)1197Vect = Normal1198CASE(2)1199Vect = Tangent1200CASE(3)1201Vect = Tangent21202END SELECT12031204DO j=1,DIM1205DO k=1,DIM1206BoundaryMatrix( (p-1)*c+j,(q-1)*c+k ) = &1207BoundaryMatrix( (p-1)*c+j,(q-1)*c+k ) + &1208s * SlipCoeff * Basis(q) * Basis(p) * Vect(j) * Vect(k)1209END DO1210END DO1211ELSE1212BoundaryMatrix( (p-1)*c+i,(q-1)*c+i ) = &1213BoundaryMatrix( (p-1)*c+i,(q-1)*c+i ) + &1214s * SlipCoeff * Basis(q) * Basis(p)1215END IF1216END DO1217END DO1218END DO1219END IF1220122112221223DO p=1,N1224DO q=1,N1225DO i=1,dim1226BoundaryMatrix((p-1)*(dim+1)+i,(q-1)*(dim+1)+i) = &1227BoundaryMatrix((p-1)*(dim+1)+i,(q-1)*(dim+1)+i) + &1228s * Alpha(i) * Basis(q) * Basis(p)1229END DO1230END DO1231END DO12321233DO q=1,N1234DO i=1,dim1235BoundaryVector((q-1)*(dim+1)+i) = BoundaryVector((q-1)*(dim+1)+i) + &1236s * Basis(q) * Force(i)1237END DO1238END DO12391240END DO1241!------------------------------------------------------------------------------1242END SUBROUTINE LocalMatrixBoundary1243!------------------------------------------------------------------------------124412451246!------------------------------------------------------------------------------1247SUBROUTINE LocalSD( Stress, StrainRate, Spin, &1248NodalVelo, NodalTemp, NodalFluidity, NodalFlowWidth, &1249NodalK1, NodalK2, NodalE1, NodalE2, NodalE3, &1250Basis, dBasisdx, Element, n, Nodes, dim, Wn, MinSRInvariant, &1251Isotropic, VariableFlowWidth, VariableLocalFlowWidth )1252!------------------------------------------------------------------------------1253! Subroutine to compute the nodal Strain-Rate, Stress, ...1254!------------------------------------------------------------------------------1255INTEGER :: n, dim1256INTEGER :: INDi(6),INDj(6)1257REAL(KIND=dp) :: Stress(:,:), StrainRate(:,:), Spin(:,:)1258REAL(KIND=dp) :: NodalVelo(:,:), NodalTemp(:), NodalFluidity(:), &1259NodalFlowWidth(:)1260REAL(KIND=dp) :: Basis(2*n), ddBasisddx(1,1,1)1261REAL(KIND=dp) :: dBasisdx(2*n,3)1262REAL(KIND=dp) :: detJ1263REAL(KIND=dp) :: NodalK1(:), NodalK2(:)1264REAL(KIND=dp) :: NodalE1(:), NodalE2(:), NodalE3(:)1265REAL(KIND=dp) :: u, v, w1266REAL(KIND=dp) :: Wn(7), D(6), MinSRInvariant1267LOGICAL :: Isotropic,VariableFlowWidth, VariableLocalFlowWidth12681269TYPE(Nodes_t) :: Nodes1270TYPE(Element_t) :: Element1271!------------------------------------------------------------------------------1272LOGICAL :: stat1273INTEGER :: i,j,k,p,q1274REAL(KIND=dp) :: LGrad(3,3), Radius, Temp, ai(3), Angle(3),a2(6)1275REAL(KIND=dp) :: C(6,6), epsi1276Real(kind=dp) :: Bg, BGlenT, ss, nn1277!------------------------------------------------------------------------------1278INTERFACE1279Subroutine R2Ro(a2,dim,ai,angle)1280USE Types1281REAL(KIND=dp),intent(in) :: a2(6)1282Integer :: dim1283REAL(KIND=dp),intent(out) :: ai(3), Angle(3)1284End Subroutine R2Ro12851286Subroutine OPILGGE_ai_nl(ai,Angle,etaI,eta36)1287USE Types1288REAL(kind=dp), INTENT(in), DIMENSION(3) :: ai1289REAL(kind=dp), INTENT(in), DIMENSION(3) :: Angle1290REAL(kind=dp), INTENT(in), DIMENSION(:) :: etaI1291REAL(kind=dp), INTENT(out), DIMENSION(6,6) :: eta361292END SUBROUTINE OPILGGE_ai_nl1293END INTERFACE1294!------------------------------------------------------------------------------12951296!1297! Temperature at the integration point1298Temp = SUM( NodalTemp(1:n)*Basis(1:n) )1299Wn(1) = SUM( NodalFluidity(1:n)*Basis(1:n) )130013011302Stress = 0.01303StrainRate = 0.01304Spin = 0.01305!1306! Compute strainRate :1307! -------------------13081309LGrad = MATMUL( NodalVelo(:,1:n), dBasisdx(1:n,:) )13101311StrainRate = 0.5 * ( LGrad + TRANSPOSE(LGrad) )13121313IF ( VariableFlowWidth ) THEN13141315StrainRate(1,3) = 0.01316StrainRate(2,3) = 0.01317StrainRate(3,1) = 0.01318StrainRate(3,2) = 0.01319StrainRate(3,3) = 0.013201321IF (SUM( NodalFlowWidth(1:n) * dBasisdx(1:n,1)) == 0) THEN1322Radius = 10e71323ELSE1324Radius = SUM( NodalFlowWidth(1:n) * Basis(1:n) ) / &1325(SUM( NodalFlowWidth(1:n) * dBasisdx(1:n,1)) )1326END IF13271328IF ( Radius > 10*AEPS ) THEN1329StrainRate(3,3) = SUM( Nodalvelo(1,1:n) * Basis(1:n) ) / Radius1330END IF1331epsi = StrainRate(1,1)+StrainRate(2,2)+StrainRate(3,3)1332DO i=1,31333StrainRate(i,i) = StrainRate(i,i) - epsi/3.01334END DO1335ELSE1336epsi = StrainRate(1,1)+StrainRate(2,2)+StrainRate(3,3)1337DO i=1,dim1338StrainRate(i,i) = StrainRate(i,i) - epsi/dim1339END DO1340END IF13411342!1343! Compute Spin :1344! --------------13451346Spin = 0.5 * ( LGrad - TRANSPOSE(LGrad) )13471348!1349! Compute deviatoric stresses:1350! ----------------------------13511352IF (.Not.Isotropic) then1353C = 0.0_dp1354! Material parameters at that point1355a2(1) = SUM( NodalK1(1:n) * Basis(1:n) )1356a2(2) = SUM( NodalK2(1:n) * Basis(1:n) )1357a2(3) = 1.d0 - a2(1) - a2(2)1358a2(4) = SUM( NodalE1(1:n) * Basis(1:n) )1359a2(5) = SUM( NodalE2(1:n) * Basis(1:n) )1360a2(6) = SUM( NodalE3(1:n) * Basis(1:n) )13611362CALL R2Ro(a2,dim,ai,Angle)1363CALL OPILGGE_ai_nl(ai,Angle,FabricGrid,C)13641365!1366! Compute deviatoric stresses:1367! ----------------------------1368D(1) = StrainRate(1,1)1369D(2) = StrainRate(2,2)1370D(3) = StrainRate(3,3)1371D(4) = 2. * StrainRate(1,2)1372D(5) = 2. * StrainRate(2,3)1373D(6) = 2. * StrainRate(3,1)13741375INDi(1:6) = (/ 1, 2, 3, 1, 2, 3 /)1376INDj(1:6) = (/ 1, 2, 3, 2, 3, 1 /)1377DO k = 1, 2*dim1378DO j = 1, 2*dim1379Stress( INDi(k),INDj(k) ) = &1380Stress( INDi(k),INDj(k) ) + C(k,j) * D(j)1381END DO1382IF (k > 3) Stress( INDj(k),INDi(k) ) = Stress( INDi(k),INDj(k) )1383END DO13841385ELSE ! ISOTROPIC CASE1386Stress=2._dp * StrainRate1387END IF138813891390! non relative viscosities1391! Glen fluidity1392Bg=BGlenT(Temp,Wn)1393ss=1.0_dp1394! Case Non linear1395IF (Wn(2) > 1.0) THEN1396Bg=Bg**(1.0/Wn(2))13971398ss = 0.0_dp1399DO i = 1, 31400DO j = 1, 31401ss = ss + StrainRate(i,j)**21402END DO1403END DO1404nn = (1.0 - Wn(2))/(2.0*Wn(2))1405ss = (2.*ss)**nn14061407IF (ss < MinSRInvariant ) ss = MinSRInvariant140814091410END IF14111412Stress=Stress*ss/Bg1413141414151416!------------------------------------------------------------------------------1417END SUBROUTINE LocalSD1418!------------------------------------------------------------------------------1419!1420!------------------------------------------------------------------------------1421END SUBROUTINE AIFlowSolver_nlD21422!------------------------------------------------------------------------------142314241425