Path: blob/devel/elmerice/Solvers/AIFlowSolve_nlS2.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: 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_nlS2( 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) :: Radius147148REAL(KIND=dp) :: at, at0149!------------------------------------------------------------------------------150SAVE NumberOfBoundaryNodes,BoundaryReorder,BoundaryNormals, &151BoundaryTangent1, BoundaryTangent2, FabricGrid, viscosityFile152153SAVE TimeForce, Basis, dBasisdx, ddBasisddx154SAVE LocalMassMatrix, LocalStiffMatrix, LoadVector, &155LocalForce, ElementNodes, Alpha, Beta, LocalTemperature, LocalFlowWidth, &156Isotropic,AllocationsDone,ReferenceTemperature,BoundaryDispl, &157NodalAIFlow, K1, K2, E1, E2, E3, Wn, MinSRInvariant, old_body, &158LocalFluidity159160SAVE RefD, RefS, RefSpin, LocalVelo, SlipCoeff161!------------------------------------------------------------------------------162! Read constants from constants section of SIF file163!------------------------------------------------------------------------------164Wn(7) = GetConstReal( Model % Constants, 'Gas Constant', GotIt )165IF (.NOT.GotIt) THEN166WRITE(Message,'(A)') 'VariableGas Constant not found. &167&Setting to 8.314'168CALL INFO('AIFlowSolve', Message, level=20)169Wn(7) = 8.314170ELSE171WRITE(Message,'(A,F10.4)') 'Gas Constant = ', Wn(7)172CALL INFO('AIFlowSolve', Message , level = 20)173END IF174!------------------------------------------------------------------------------175! Get variables needed for solution176!------------------------------------------------------------------------------177IF ( .NOT. ASSOCIATED( Solver % Matrix ) ) RETURN178179AIFlowSol => Solver % Variable180AIFlowPerm => AIFlowSol % Perm181STDOFs = AIFlowSol % DOFs182AIFlow => AIFlowSol % Values183184LocalNodes = COUNT( AIFlowPerm > 0 )185IF ( LocalNodes <= 0 ) RETURN186187TempSol => VariableGet( Solver % Mesh % Variables, 'Temperature' )188IF ( ASSOCIATED( TempSol) ) THEN189TempPerm => TempSol % Perm190Temperature => TempSol % Values191END IF192193FabricVariable => VariableGet(Solver % Mesh % Variables, 'Fabric')194IF ( ASSOCIATED( FabricVariable ) ) THEN195FabricPerm => FabricVariable % Perm196FabricValues => FabricVariable % Values197END IF198199SpinVar => VariableGet(Solver % Mesh %Variables,'Spin')200IF ( ASSOCIATED( SpinVar ) ) THEN201SpinPerm => SpinVar % Perm202SpinValues => SpinVar % Values203END IF204205StrainRateVar => VariableGet(Solver % Mesh % Variables,'StrainRate')206IF ( ASSOCIATED( StrainRateVar ) ) THEN207SRPerm => StrainRateVar % Perm208SRValues => StrainRateVar % Values209END IF210211DevStressVar => &212VariableGet(Solver % Mesh % Variables,'DeviatoricStress')213IF ( ASSOCIATED( DevStressVar ) ) THEN214DSPerm => DevStressVar % Perm215DSValues => DevStressVar % Values216END IF217218IF ( CurrentCoordinateSystem() == AxisSymmetric ) THEN219CSymmetry = .TRUE.220VariableFlowWidth = .TRUE.221END IF222223StiffMatrix => Solver % Matrix224ForceVector => StiffMatrix % RHS225UNorm = Solver % Variable % Norm226227!------------------------------------------------------------------------------228! Allocate some permanent storage, this is done first time only229!------------------------------------------------------------------------------230IF ( .NOT. AllocationsDone .OR. Solver % Mesh % Changed) THEN231N = Model % MaxElementNodes232dim = CoordinateSystemDimension()233234IF ( AllocationsDone ) THEN235DEALLOCATE( ElementNodes % x, &236ElementNodes % y, &237ElementNodes % z, &238BoundaryDispl, &239ReferenceTemperature, &240LocalTemperature, &241LocalFlowWidth, &242K1,K2,E1,E2,E3, &243LocalForce, &244RefD, RefS, RefSpin, &245LocalVelo, &246Basis,ddBasisddx,dBasisdx, &247TimeForce, &248LocalMassMatrix, &249LocalStiffMatrix, &250LoadVector, Alpha, Beta, &251SlipCoeff, LocalFluidity )252END IF253254ALLOCATE( ElementNodes % x( N ), &255ElementNodes % y( N ), &256ElementNodes % z( N ), &257BoundaryDispl( N ), &258ReferenceTemperature( N ), &259LocalTemperature( N ), &260LocalFlowWidth (N), &261K1( N ), K2( N ), E1( N ), E2( N ), E3( N ), &262LocalForce( 2*STDOFs*N ),&263RefS(2*dim*LocalNodes ),&264RefD(2*dim*LocalNodes ),&265RefSpin((2*dim-3)*LocalNodes ),&266LocalVelo( 3,N ),&267Basis( 2*N ),ddBasisddx(1,1,1), dBasisdx( 2*N,3 ), &268TimeForce( 2*STDOFs*N ), &269LocalMassMatrix( 2*STDOFs*N,2*STDOFs*N ), &270LocalStiffMatrix( 2*STDOFs*N,2*STDOFs*N ), &271LoadVector( 4,N ), Alpha( 3,N ), Beta( N ), &272SlipCoeff(3,N), LocalFluidity(N), STAT=istat )273274IF ( istat /= 0 ) THEN275CALL Fatal( 'AIFlowSolve', 'Memory allocation error.' )276END IF277!------------------------------------------------------------------------------278279AllocationsDone = .TRUE.280END IF281282!------------------------------------------------------------------------------283! Do some additional initialization, and go for it284!------------------------------------------------------------------------------285286!------------------------------------------------------------------------------287NonlinearTol = GetConstReal( Solver % Values, &288'Nonlinear System Convergence Tolerance' )289290NewtonTol = GetConstReal( Solver % Values, &291'Nonlinear System Newton After Tolerance' )292293NewtonIter = GetInteger( Solver % Values, &294'Nonlinear System Newton After Iterations' )295296NonlinearIter = GetInteger( Solver % Values, &297'Nonlinear System Max Iterations',GotIt )298299IF ( .NOT.GotIt ) NonlinearIter = 1300!------------------------------------------------------------------------------301302!------------------------------------------------------------------------------303304EquationName = GetString( Solver % Values, 'Equation' )305306FreeSurface = .FALSE.307308!------------------------------------------------------------------------------309DO iter=1,NonlinearIter310311at = CPUTime()312at0 = RealTime()313314CALL Info( 'AIFlowSolve', ' ', Level=4 )315CALL Info( 'AIFlowSolve', ' ', Level=4 )316CALL Info( 'AIFlowSolve', &317'-------------------------------------',Level=4 )318WRITE( Message, * ) 'ANISOTROPIC FLOW SOLVER ITERATION', iter319CALL Info( 'AIFlowSolve', Message,Level=4 )320CALL Info( 'AIFlowSolve', &321'-------------------------------------',Level=4 )322CALL Info( 'AIFlowSolve', ' ', Level=4 )323CALL Info( 'AIFlowSolve', 'Starting assembly...',Level=4 )324!------------------------------------------------------------------------------325CALL DefaultInitialize()326!------------------------------------------------------------------------------327DO t=1,Solver % NumberOFActiveElements328329IF ( RealTime() - at0 > 1.0 ) THEN330WRITE(Message,'(a,i3,a)' ) ' Assembly: ', &331INT(100.0 - 100.0 * (Solver % NumberOfActiveElements-t) / &332(1.0*Solver % NumberOfActiveElements)), ' % done'333CALL Info( 'AIFlowSolve', Message, Level=5 )334at0 = RealTime()335END IF336337CurrentElement => GetActiveElement(t)338339n = GetElementNOFNodes()340NodeIndexes => CurrentElement % NodeIndexes341342ElementNodes % x(1:n) = Model % Nodes % x(NodeIndexes(1:n))343ElementNodes % y(1:n) = Model % Nodes % y(NodeIndexes(1:n))344ElementNodes % z(1:n) = Model % Nodes % z(NodeIndexes(1:n))345346Material => GetMaterial()347348!------------------------------------------------------------------------------349! Read in material constants from Material section350!------------------------------------------------------------------------------351body_id = CurrentElement % BodyId352IF (body_id /= old_body) Then353old_body = body_id354Call GetMaterialDefs()355END IF356357LocalFluidity(1:n) = ListGetReal( Material, &358'Fluidity Parameter', n, NodeIndexes, GotIt,&359UnFoundFatal=UnFoundFatal)360!Previous default value: LocalFluidity(1:n) = 1.0361362363LocalFlowWidth(1:n) = ListGetReal ( Material, &364'FlowWidth', n, NodeIndexes, GotIt)365IF (.NOT. GotIt) THEN366IF (CSymmetry) THEN367DO i=1,n368LocalFlowWidth(i) = ElementNodes % x(i)369END DO370END IF371ELSE372VariableFlowWidth = .TRUE.373END IF374375! Test if flow width is locally constant (infinite radius case)376VariableLocalFlowWidth = .TRUE.377IF (MAXVAL(LocalFlowWidth(1:n))- &378MINVAL(LocalFlowWidth(1:n)) == 0.0) &379VariableLocalFlowWidth = .FALSE.380381!------------------------------------------------------------------------------382! Set body forces383!------------------------------------------------------------------------------384LoadVector = 0.0D0385386BodyForce => GetBodyForce()387IF ( ASSOCIATED( BodyForce ) ) THEN388LoadVector(1,1:n) = LoadVector(1,1:n) + ListGetReal( &389BodyForce, 'AIFlow Force 1', n, NodeIndexes, gotIt)390LoadVector(2,1:n) = LoadVector(2,1:n) + ListGetReal( &391BodyForce, 'AIFlow Force 2', n, NodeIndexes, gotIt)392LoadVector(3,1:n) = LoadVector(3,1:n) + ListGetReal( &393BodyForce, 'AIFlow Force 3', n, NodeIndexes, gotIt)394END IF395!------------------------------------------------------------------------------396! Get element local stiffness & mass matrices397!------------------------------------------------------------------------------398LocalTemperature = 0.0D0399IF ( ASSOCIATED(TempSol) ) THEN400DO i=1,n401k = TempPerm(NodeIndexes(i))402LocalTemperature(i) = Temperature(k)403END DO404ELSE405LocalTemperature(1:n) = 0.0d0406END IF407408! fabric not needed if isotropic409IF(.NOT.Isotropic) THEN410K1(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 1 )411K2(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 2 )412E1(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 3 )413E2(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 4 )414E3(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 5 )415ENDIF416417LocalVelo = 0.0d0418DO i=1,STDOFs - 1419LocalVelo(i,1:n) = AIFlow( STDOFs*(AIFlowPerm(NodeIndexes(1:n))-1) + i)420END DO421422CALL LocalMatrix( LocalMassMatrix, LocalStiffMatrix, &423LocalForce, LoadVector, K1, K2, E1, E2, E3, LocalVelo, &424LocalTemperature, LocalFlowWidth, LocalFluidity, CurrentElement, n, &425ElementNodes, Wn, MinSRInvariant, Isotropic, VariableFlowWidth, &426VariableLocalFlowWidth)427428TimeForce = 0.0d0429CALL NSCondensate(N, N,STDOFs-1,LocalStiffMatrix,LocalForce,TimeForce )430!------------------------------------------------------------------------------431! Update global matrices from local matrices432!------------------------------------------------------------------------------433CALL DefaultUpdateEquations( LocalStiffMatrix, LocalForce )434END DO435436CALL Info( 'AIFlowSolve', 'Assembly done', Level=4 )437CALL DefaultFinishBulkAssembly()438439!------------------------------------------------------------------------------440! Neumann & Newton boundary conditions441!------------------------------------------------------------------------------442DO t = 1, Model % NumberOFBoundaryElements443444CurrentElement => GetBoundaryElement(t)445446IF ( GetElementFamily() == 101 ) CYCLE447IF ( .NOT. ActiveBoundaryElement() ) CYCLE448449n = GetElementNOFNodes()450NodeIndexes => CurrentElement % NodeIndexes451452ElementNodes % x(1:n) = Model % Nodes % x(NodeIndexes(1:n))453ElementNodes % y(1:n) = Model % Nodes % y(NodeIndexes(1:n))454ElementNodes % z(1:n) = Model % Nodes % z(NodeIndexes(1:n))455456BC => GetBC()457IF ( ASSOCIATED( BC ) ) THEN458LoadVector = 0.0D0459Alpha = 0.0D0460Beta = 0.0D0461!------------------------------------------------------------------------------462! Force in given direction BC: \tau\cdot n = F463!------------------------------------------------------------------------------464GotForceBC = .FALSE.465466LoadVector(1,1:n) = &467ListGetReal( BC, 'Force 1', n, NodeIndexes, GotIt )468GotForceBC = GotForceBC .OR. gotIt469470LoadVector(2,1:n) = &471ListGetReal( BC, 'Force 2', n, NodeIndexes, GotIt )472GotForceBC = GotForceBC .OR. gotIt473474LoadVector(3,1:n) = &475ListGetReal( BC, 'Force 3', n, NodeIndexes, GotIt )476GotForceBC = GotForceBC .OR. gotIt477478479Beta(1:n) = &480ListGetReal( BC, 'Normal Force', n, NodeIndexes, GotIt )481GotForceBC = GotForceBC .OR. gotIt482483!------------------------------------------------------------------------------484! slip boundary condition BC: \tau\cdot n = R_k u_k485!------------------------------------------------------------------------------486487SlipCoeff = 0.0d0488SlipCoeff(1,1:n) = ListGetReal( BC, &489'AIFlow Slip Coeff 1', n, NodeIndexes, GotIt )490GotForceBC = GotForceBC .OR. gotIt491492SlipCoeff(2,1:n) = ListGetReal( BC, &493'AIFlow Slip Coeff 2', n, NodeIndexes, GotIt )494GotForceBC = GotForceBC .OR. gotIt495496SlipCoeff(3,1:n) = ListGetReal( BC, &497'AIFlow Slip Coeff 3', n, NodeIndexes, GotIt )498GotForceBC = GotForceBC .OR. gotIt499500NormalTangential = ListGetLogical( BC, &501'Normal-Tangential AIFlow', GotIt )502503IF ( .NOT.GotForceBC ) CYCLE504505!------------------------------------------------------------------------------506CALL LocalMatrixBoundary( LocalStiffMatrix, LocalForce, &507LoadVector, Alpha, Beta, SlipCoeff, NormalTangential, &508CurrentElement, n, ElementNodes, VariableFlowWidth, &509VariableLocalFlowWidth, LocalFlowWidth )510!------------------------------------------------------------------------------511!------------------------------------------------------------------------------512! Update global matrices from local matrices (will also affect513! LocalStiffMatrix and LocalForce if transientsimulation is on).514!------------------------------------------------------------------------------515CALL DefaultUpdateEquations( LocalStiffMatrix, LocalForce )516!------------------------------------------------------------------------------517END IF518END DO519!------------------------------------------------------------------------------520CALL DefaultFinishBoundaryAssembly()521CALL DefaultFinishAssembly()522523!------------------------------------------------------------------------------524! Dirichlet boundary conditions525!------------------------------------------------------------------------------526CALL DefaultDirichletBCs()527!------------------------------------------------------------------------------528529CALL Info( 'AIFlowSolve', 'Set boundaries done', Level=4 )530531!------------------------------------------------------------------------------532! Solve the system and check for convergence533!------------------------------------------------------------------------------534PrevUNorm = UNorm535536UNorm = DefaultSolve()537538IF ( PrevUNorm + UNorm /= 0.0d0 ) THEN539RelativeChange = 2.0d0 * ABS( PrevUNorm - UNorm) / ( PrevUnorm + UNorm)540ELSE541RelativeChange = 0.0d0542END IF543544WRITE( Message, * ) 'Result Norm : ',UNorm, PrevUNorm545CALL Info( 'AIFlowSolve', Message, Level=4 )546WRITE( Message, * ) 'Relative Change : ',RelativeChange547CALL Info( 'AIFlowSolve', Message, Level=4 )548549!------------------------------------------------------------------------------550IF ( RelativeChange < NewtonTol .OR. &551iter > NewtonIter ) NewtonLinearization = .TRUE.552553IF ( RelativeChange < NonLinearTol ) EXIT554555!------------------------------------------------------------------------------556END DO ! of nonlinear iter557!------------------------------------------------------------------------------558559!------------------------------------------------------------------------------560! Compute the StrainRate, Spin and deviatoric Stress561! Nodal values562!------------------------------------------------------------------------------563564IF ((ASSOCIATED( StrainRateVar)).OR.(ASSOCIATED(DevStressVar))&565.OR.(ASSOCIATED(SpinVar))) THEN566RefD=0.567RefS=0.568RefSpin=0.569IF (ASSOCIATED(StrainRateVar)) SRValues = 0.570IF (ASSOCIATED(devStressVar)) DSValues = 0.571IF (ASSOCIATED(SPinVar)) SpinValues = 0.572573DO t=1,Solver % NumberOFActiveElements574575CurrentElement => GetActiveElement(t)576n = GetElementNOFNodes()577NodeIndexes => CurrentElement % NodeIndexes578579body_id = CurrentElement % BodyId580dim = CoordinateSystemDimension()581582!------------------------------------------------------------------------------583! Read in material constants from Material section584!------------------------------------------------------------------------------585IF (body_id /= old_body) Then586old_body = body_id587Call GetMaterialDefs()588END IF589590LocalFluidity(1:n) = ListGetReal( Material, &591'Fluidity Parameter', n, NodeIndexes, GotIt,&592UnFoundFatal=UnFoundFatal)593! Previous default value: LocalFluidity(1:n) = 1.0594595LocalFlowWidth(1:n) = ListGetReal ( Material, &596'FlowWidth', n, NodeIndexes, GotIt)597IF (.NOT. GotIt .AND. CSymmetry) THEN598DO i=1,n599LocalFlowWidth(i) = ElementNodes % x(i)600END DO601END IF602603ElementNodes % x(1:n) = Model % Nodes % x(NodeIndexes(1:n))604ElementNodes % y(1:n) = Model % Nodes % y(NodeIndexes(1:n))605ElementNodes % z(1:n) = Model % Nodes % z(NodeIndexes(1:n))606607! n nodale values of the temperature608609LocalTemperature = 0.0D0610IF ( ASSOCIATED(TempSol) ) THEN611DO i=1,n612k = TempPerm(NodeIndexes(i))613LocalTemperature(i) = Temperature(k)614END DO615ELSE616LocalTemperature(1:n) = 0.0d0617END IF618619! n nodales values of the 5 fabric parameters, not needed if isotropic620IF(.NOT.Isotropic) Then621K1(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 1 )622K2(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 2 )623E1(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 3 )624E2(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 4 )625E3(1:n) = FabricValues( 5 * (FabricPerm(NodeIndexes(1:n))-1) + 5 )626END IF627628! 2D U,V,p STDOFs=3629! 3D U,V,W,p STDOFs=4630LocalVelo = 0.0d0631DO i=1,STDOFs - 1632LocalVelo(i,1:n) = AIFlow( STDOFs*(AIFlowPerm(NodeIndexes(1:n))-1) + i)633END DO634635! Go for all nodes of the element636Do i=1,n637638! u, v, w local coord of node i639u = CurrentElement % Type % NodeU(i)640v = CurrentElement % Type % NodeV(i)641w = CurrentElement % Type % NodeW(i)642643stat = ElementInfo(CurrentElement,ELementNodes,u,v,w,detJ, &644Basis,dBasisdx,ddBasisddx,.FALSE.,.FALSE.)645646! Variable flow width case when R=0 strain, stress not calculated exactly in647! x=0 (I agree it is not very nice, better solution ???)648Requal0 = .False.649IF (( VariableFlowWidth ) .And. &650(SUM(LocalFlowWidth (1:n) * Basis(1:n)) == 0.0)) THEN651Requal0 = .True.652u= u + 0.0001653stat = ElementInfo(CurrentElement,ELementNodes,u,v,w,detJ, &654Basis,dBasisdx,ddBasisddx,.FALSE.,.FALSE.)655END IF656657CALL LocalSD(NodalStresses, NodalStrainRate, NodalSpin, &658LocalVelo, LocalTemperature, LocalFluidity, &659LocalFlowWidth, K1, K2, E1, E2, E3, Basis, dBasisdx, &660CurrentElement, n, ElementNodes, dim, Wn, &661MinSRInvariant, Isotropic, VariableFlowWidth, &662VariableLocalFlowWidth)663664IF (Requal0) NodalSpin = 0.665666IF (ASSOCIATED(StrainRateVar)) &667RefD(2*dim*(SRPerm(NodeIndexes(i))-1)+1 : &6682*dim*SRPerm(NodeIndexes(i))) &669=RefD(2*dim*(SRPerm(NodeIndexes(i))-1)+1 : &6702*dim*SRPerm(NodeIndexes(i))) + 1.671672IF (ASSOCIATED(DevStressVar)) &673RefS(2*dim*(DSPerm(NodeIndexes(i))-1)+1 : &6742*dim*DSPerm(NodeIndexes(i))) &675=RefS(2*dim*(DSPerm(NodeIndexes(i))-1)+1 : &6762*dim*DSPerm(NodeIndexes(i))) + 1.677678IF (ASSOCIATED(SpinVar)) &679RefSpin((2*dim-3)*(SpinPerm(NodeIndexes(i))-1)+1 : &680(2*dim-3)*SpinPerm(NodeIndexes(i))) &681=RefSpin((2*dim-3)*(SpinPerm(NodeIndexes(i))-1)+1 : &682(2*dim-3)*SpinPerm(NodeIndexes(i))) + 1.683684685IF (ASSOCIATED(StrainRateVar)) THEN686comp=0687DO j=1,2*dim688comp=comp+1689SRValues(2*dim*(SRPerm(NodeIndexes(i))-1)+comp)=&690SRValues(2*dim*(SRPerm(NodeIndexes(i))-1)+comp) + &691NodalStrainRate(INDi(j),INDj(j))692END DO693END IF694695IF (ASSOCIATED(DevStressVar)) THEN696comp=0697DO j=1,2*dim698comp=comp+1699DSValues(2*dim*(DSPerm(NodeIndexes(i))-1)+comp)=&700DSValues(2*dim*(DSPerm(NodeIndexes(i))-1)+comp) + &701NodalStresses(INDi(j),INDj(j))702END DO703END IF704705IF (ASSOCIATED(SpinVar)) THEN706comp=0707DO j=1,(2*dim-3)708comp=comp+1709SpinValues((2*dim-3)*(SpinPerm(NodeIndexes(i))-1)+comp)=&710SPinValues((2*dim-3)*(SpinPerm(NodeIndexes(i))-1)+comp) + &711NodalSpin(INDi(j+3),INDj(j+3))712END DO713END IF714715END DO716END DO717718IF (ASSOCIATED(StrainRateVar)) THEN719WHERE(RefD > 0.)720SRVAlues = SRValues / RefD721END WHERE722END IF723724IF (ASSOCIATED(DevStressVar)) THEN725WHERE(RefS > 0.)726DSVAlues = DSValues / RefS727END WHERE728END IF729730IF (ASSOCIATED(SpinVar)) THEN731WHERE(RefSpin > 0.)732SpinVAlues = SpinValues / RefSpin733END WHERE734END IF735736END IF737738!------------------------------------------------------------------------------739! END Compute the StrainRate and Deviatoric Stress740!------------------------------------------------------------------------------741742CONTAINS743744SUBROUTINE GetMaterialDefs()745! check if we are isotropic or not746Isotropic = ListGetLogical( Material , 'Isotropic',Gotit )747IF (.NOT.Gotit) Then748Isotropic = .False.749WRITE(Message,'(A)') 'Isotropic set to False'750CALL INFO('AIFlowSolve', Message, Level = 20)751ELSE752IF ( (ASSOCIATED( FabricVariable )).AND.Isotropic ) Then753WRITE(Message,'(A)') 'Be careful Isotropic is true &754& and Fabric is defined!'755CALL INFO('AIFlowSolve', Message, Level = 1)756END IF757END IF758759IF (.NOT.Isotropic) Then760! Get the viscosity file and store the viscosities into FabricGrid761viscosityFile = ListGetString( Material ,'Viscosity File',GotIt,UnFoundFatal )762OPEN( 1, File = viscosityFile)763DO i=1,813764READ( 1, '(6(e14.8))' ) FabricGrid( 6*(i-1)+1:6*(i-1)+6 )765END DO766CLOSE(1)767ENDIF768769Wn(2) = ListGetConstReal( Material , 'Powerlaw Exponent', GotIt,UnFoundFatal=UnFoundFatal)770!Previous default value: Wn(2) = 1.0771WRITE(Message,'(A,F10.4)') 'Powerlaw Exponent = ', Wn(2)772CALL INFO('AIFlowSolve', Message, Level = 20)773774Wn(3) = ListGetConstReal( Material, 'Activation Energy 1', GotIt,UnFoundFatal=UnFoundFatal)775!Previous default value: Wn(3) = 1.0776WRITE(Message,'(A,F10.4)') 'Activation Energy 1 = ', Wn(3)777CALL INFO('AIFlowSolve', Message, Level = 20)778779Wn(4) = ListGetConstReal( Material, 'Activation Energy 2', GotIt,UnFoundFatal=UnFoundFatal)780!Previous default value: Wn(4) = 1.0781WRITE(Message,'(A,F10.4)') 'Activation Energy 2 = ', Wn(4)782CALL INFO('AIFlowSolve', Message, Level = 20)783784Wn(5) = ListGetConstReal(Material, 'Reference Temperature', GotIt,UnFoundFatal=UnFoundFatal)785!Previous default value: Wn(5) = -10.0 (Celsius)786WRITE(Message,'(A,F10.4)') 'Reference Temperature = ', Wn(5)787CALL INFO('AIFlowSolve', Message, Level = 20)788789Wn(6) = ListGetConstReal( Material, 'Limit Temperature', GotIt,UnFoundFatal=UnFoundFatal)790!Previous default value: Wn(6) = -10.0 (Celsius)791WRITE(Message,'(A,F10.4)') 'Limit Temperature = ', Wn(6)792CALL INFO('AIFlowSolve', Message, Level = 20)793794! Get the Minimum value of the Effective Strain rate795MinSRInvariant = 100.0*AEPS796797IF ( Wn(2) > 1.0 ) THEN798MinSRInvariant = &799ListGetConstReal( Material, 'Min Second Invariant', GotIt )800IF (.NOT.GotIt) THEN801WRITE(Message,'(A)') 'Variable Min Second Invariant not &802&found. Setting to 100.0*AEPS )'803CALL INFO('AIFlowSolve', Message, Level = 20)804ELSE805WRITE(Message,'(A,E14.8)') 'Min Second Invariant = ', MinSRInvariant806CALL INFO('AIFlowSolve', Message, Level = 20)807END IF808END IF809810!------------------------------------------------------------------------------811END SUBROUTINE GetMaterialDefs812!------------------------------------------------------------------------------813814!------------------------------------------------------------------------------815SUBROUTINE LocalMatrix( MassMatrix, StiffMatrix, ForceVector, &816LoadVector, NodalK1, NodalK2, NodalEuler1, NodalEuler2, &817NodalEuler3, NodalVelo, NodalTemperature, NodalFlowWidth, &818NodalFluidity, Element, n, Nodes, Wn, MinSRInvariant, Isotropic, &819VariableFlowWidth, VariableLocalFlowWidth )820821!------------------------------------------------------------------------------822823REAL(KIND=dp) :: StiffMatrix(:,:), MassMatrix(:,:)824REAL(KIND=dp) :: LoadVector(:,:), NodalVelo(:,:)825REAL(KIND=dp) :: Wn(7), MinSRInvariant826REAL(KIND=dp), DIMENSION(:) :: ForceVector, NodalK1, NodalK2, &827NodalEuler1, NodalEuler2, NodalEuler3, NodalTemperature, &828NodalFluidity, NodalFlowWidth829TYPE(Nodes_t) :: Nodes830TYPE(Element_t) :: Element831LOGICAL :: Isotropic, VariableFlowWidth, VariableLocalFlowWidth832INTEGER :: n833!------------------------------------------------------------------------------834!835REAL(KIND=dp) :: Basis(2*n),ddBasisddx(1,1,1)836REAL(KIND=dp) :: dBasisdx(2*n,3),SqrtElementMetric837838REAL(KIND=dp) :: Force(3), K1, K2, Euler1, Euler2, Euler3839Real(kind=dp) :: Bg, BGlenT840841REAL(KIND=dp), DIMENSION(4,4) :: A,M842REAL(KIND=dp) :: Load(3),Temperature, C(6,6)843REAL(KIND=dp) :: nn, ss,pp, LGrad(3,3), SR(3,3), Stress(3,3), D(6), epsi844INTEGER :: INDi(6),INDj(6)845846847INTEGER :: i, j, k, p, q, t, dim, NBasis, ind(3)848849REAL(KIND=dp) :: s,u,v,w, Radius, B(6,3), G(3,6), FW850851REAL(KIND=dp) :: dDispldx(3,3), ai(3), Angle(3), a2(6)852TYPE(GaussIntegrationPoints_t), TARGET :: IntegStuff853854INTEGER :: N_Integ855856REAL(KIND=dp), DIMENSION(:), POINTER :: U_Integ,V_Integ,W_Integ,S_Integ857858LOGICAL :: stat859860INTERFACE861Subroutine R2Ro(a2,dim,ai,angle)862USE Types863REAL(KIND=dp),intent(in) :: a2(6)864Integer :: dim865REAL(KIND=dp),intent(out) :: ai(3), Angle(3)866End Subroutine R2Ro867868Subroutine OPILGGE_ai_nl(ai,Angle,etaI,eta36)869USE Types870REAL(kind=dp), INTENT(in), DIMENSION(3) :: ai871REAL(kind=dp), INTENT(in), DIMENSION(3) :: Angle872REAL(kind=dp), INTENT(in), DIMENSION(:) :: etaI873REAL(kind=dp), INTENT(out), DIMENSION(6,6) :: eta36874END SUBROUTINE OPILGGE_ai_nl875876END INTERFACE877!------------------------------------------------------------------------------878dim = CoordinateSystemDimension()879880ForceVector = 0.0D0881StiffMatrix = 0.0D0882MassMatrix = 0.0D0883884!885! Integration stuff886!887NBasis = 2*n888IntegStuff = GaussPoints( Element, Element % Type % GaussPoints2 )889890U_Integ => IntegStuff % u891V_Integ => IntegStuff % v892W_Integ => IntegStuff % w893S_Integ => IntegStuff % s894N_Integ = IntegStuff % n895!896! Now we start integrating897!898DO t=1,N_Integ899900u = U_Integ(t)901v = V_Integ(t)902w = W_Integ(t)903904!------------------------------------------------------------------------------905! Basis function values & derivatives at the integration point906!------------------------------------------------------------------------------907stat = ElementInfo( Element,Nodes,u,v,w,SqrtElementMetric, &908Basis,dBasisdx,ddBasisddx,.FALSE.,.TRUE. )909910s = SqrtElementMetric * S_Integ(t)911!------------------------------------------------------------------------------912!913! Force at integration point914!915Force = 0.0d0916DO i=1,dim917Force(i) = SUM( LoadVector(i,1:n)*Basis(1:n))918END DO919!920! Temperature at the integration point921!922Temperature = SUM( NodalTemperature(1:n)*Basis(1:n) )923Wn(1) = SUM( NodalFluidity(1:n)*Basis(1:n) )924Bg=BGlenT(Temperature,Wn)925ss=1.0_dp926927! if not isotropic use GOLF928C = 0.0_dp929IF (.NOT.Isotropic) Then930a2(1) = SUM( NodalK1(1:n) * Basis(1:n) )931a2(2) = SUM( NodalK2(1:n) * Basis(1:n) )932a2(3) = 1.d0 - a2(1) - a2(2)933a2(4) = SUM( NodalEuler1(1:n) * Basis(1:n) )934a2(5) = SUM( NodalEuler2(1:n) * Basis(1:n) )935a2(6) = SUM( NodalEuler3(1:n) * Basis(1:n) )936937CALL R2Ro(a2,dim,ai,angle)938CALL OPILGGE_ai_nl(ai,Angle,FabricGrid,C)939! else use isotropic law940ELSE941Do i=1,3942C(i,i)=2.0_dp943End do944Do i=4,6945C(i,i)=1.0_dp946End do947ENDIF948949FW = SUM( NodalFlowWidth(1:n) * Basis(1:n) )950Radius = FW / (SUM( NodalFlowWidth(1:n) * dBasisdx(1:n,1)) )951IF (.NOT. VariableLocalFlowWidth) Radius = 10e7952IF (VariableFlowWidth ) s = s * FW953954!955! Case non-linear956! -----------------------------957958IF ( Wn(2) > 1.0 ) THEN959960Bg=Bg**(1.0/Wn(2))961962LGrad = MATMUL( NodalVelo(:,1:n), dBasisdx(1:n,:) )963SR = 0.5 * ( LGrad + TRANSPOSE(LGrad) )964965IF ( VariableFlowWidth ) THEN966SR(1,3) = 0.0967SR(2,3) = 0.0968SR(3,1) = 0.0969SR(3,2) = 0.0970SR(3,3) = 0.0971IF ( Radius > 10*AEPS ) THEN972SR(3,3) = SUM( Nodalvelo(1,1:n) * Basis(1:n) ) /Radius973END IF974epsi = SR(1,1)+SR(2,2)+SR(3,3)975DO i=1,3976SR(i,i) = SR(i,i) - epsi/3.0977END DO978ELSE979epsi = SR(1,1)+SR(2,2)+SR(3,3)980DO i=1,dim981SR(i,i) = SR(i,i) - epsi/dim982END DO983END IF984985! Compute the invariant986nn = (1.0 - Wn(2))/(2.0*Wn(2))987988IF (.NOT.ISOTROPIC) then ! non linear and anisotropic989D(1) = SR(1,1)990D(2) = SR(2,2)991D(3) = SR(3,3)992D(4) = 2. * SR(1,2)993D(5) = 2. * SR(2,3)994D(6) = 2. * SR(3,1)995996INDi(1:6) = (/ 1, 2, 3, 1, 2, 3 /)997INDj(1:6) = (/ 1, 2, 3, 2, 3, 1 /)998Stress = 0.999DO k = 1, 2*dim1000DO j = 1, 2*dim1001Stress( INDi(k),INDj(k) ) = &1002Stress( INDi(k),INDj(k) ) + C(k,j) * D(j)1003END DO1004IF (k > 3) Stress( INDj(k),INDi(k) ) = Stress( INDi(k),INDj(k) )1005END DO1006ss = 0.0_dp1007pp=0._dp1008DO i = 1, 31009DO j = 1, 31010ss = ss + Stress(i,j)**2.1011pp=pp+SR(i,j)**2.1012END DO1013END DO1014ss=ss/4. ! pour avoir le meme resultat si Isotropic1015!if (Radius.lt.2000) write(*,*) ss,pp,Radius1016IF (ss < MinSRInvariant ) ss = MinSRInvariant1017ss = (2.*ss)**nn1018Else1019ss = 0.0_dp1020DO i = 1, 31021DO j = 1, 31022ss = ss + SR(i,j)**2.1023END DO1024END DO1025IF (ss < MinSRInvariant ) ss = MinSRInvariant1026ss = (2.*ss)**nn1027END IF10281029END IF10301031! Non relative viscosity matrix1032C = C * ss/Bg10331034!1035! Loop over basis functions (of both unknowns and weights)1036!1037A = 0.0d01038M = 0.0d01039B = 0.0d010401041DO p=1,NBasis10421043G = 0.0d010441045IF ( VariableFlowWidth ) THEN1046G(1,1) = dBasisdx(p,1)1047G(1,3) = Basis(p) / Radius1048G(1,4) = dBasisdx(p,2)1049G(2,2) = dBasisdx(p,2)1050G(2,4) = dBasisdx(p,1)1051ELSE1052G(1,1) = dBasisdx(p,1)1053G(2,2) = dBasisdx(p,2)1054G(3,3) = dBasisdx(p,3)1055G(1,4) = dBasisdx(p,2)1056G(2,4) = dBasisdx(p,1)1057G(2,5) = dBasisdx(p,3)1058G(3,5) = dBasisdx(p,2)1059G(1,6) = dBasisdx(p,3)1060G(3,6) = dBasisdx(p,1)1061END IF10621063G = MATMUL( G, C )10641065DO q=1,NBasis10661067B = 0.0d010681069IF ( VariableFlowWidth ) THEN1070B(1,1) = dBasisdx(q,1)1071B(2,2) = dBasisdx(q,2)1072B(3,1) = Basis(q) / Radius1073B(4,1) = dBasisdx(q,2)1074B(4,2) = dBasisdx(q,1)1075ELSE1076B(1,1) = dBasisdx(q,1)1077B(2,2) = dBasisdx(q,2)1078B(3,3) = dBasisdx(q,3)1079B(4,1) = dBasisdx(q,2)1080B(4,2) = dBasisdx(q,1)1081B(5,2) = dBasisdx(q,3)1082B(5,3) = dBasisdx(q,2)1083B(6,1) = dBasisdx(q,3)1084B(6,3) = dBasisdx(q,1)1085END IF10861087A(1:3,1:3) = MATMUL( G, B )10881089! Pressure gradient1090DO i=1,dim1091A(i,dim+1) = -dBasisdx(p,i) * Basis(q)1092END DO1093IF ( VariableFlowWidth ) A(1,dim+1) = A(1,dim+1) - Basis(p) * Basis(q) / Radius10941095! Continuity equation:1096DO i=1,dim1097A(dim+1,i) = dBasisdx(q,i) * Basis(p)1098END DO1099IF ( VariableFlowWidth ) A(dim+1,1) = A(dim+1,1) + Basis(p) * Basis(q) / Radius1100A(dim+1, dim+1) = 0.0d011011102! Add nodal matrix to element matrix1103DO i=1,dim+11104DO j=1,dim+11105StiffMatrix( (dim+1)*(p-1)+i,(dim+1)*(q-1)+j ) = &1106StiffMatrix( (dim+1)*(p-1)+i,(dim+1)*(q-1)+j ) + s*A(i,j)1107END DO1108END DO11091110END DO11111112! The righthand side...1113Load = 0.0d011141115DO i=1,dim1116Load(i) = Load(i) + Force(i) * Basis(p)1117END DO11181119DO i=1,dim1120ForceVector((dim+1)*(p-1)+i) = ForceVector((dim+1)*(p-1)+i) + s*Load(i)1121END DO1122END DO11231124END DO1125!------------------------------------------------------------------------------1126END SUBROUTINE LocalMatrix1127!------------------------------------------------------------------------------11281129!------------------------------------------------------------------------------1130SUBROUTINE LocalMatrixBoundary( BoundaryMatrix, BoundaryVector, &1131LoadVector, NodalAlpha, NodalBeta, NodalSlipCoeff, &1132NormalTangential, Element, n, Nodes, &1133VariableFlowWidth, VariableLocalFlowWidth, NodalFlowWidth )11341135!------------------------------------------------------------------------------1136REAL(KIND=dp) :: BoundaryMatrix(:,:),BoundaryVector(:)1137REAL(KIND=dp) :: NodalAlpha(:,:),NodalBeta(:),LoadVector(:,:)1138REAL(KIND=dp) :: NodalSlipCoeff(:,:), NodalFlowWidth(:)1139TYPE(Element_t),POINTER :: Element1140TYPE(Nodes_t) :: Nodes1141LOGICAL :: NormalTangential1142INTEGER, POINTER :: NodeIndexes(:)1143INTEGER :: n1144!------------------------------------------------------------------------------1145REAL(KIND=dp) :: Basis(n),ddBasisddx(1,1,1)1146REAL(KIND=dp) :: dBasisdx(n,3),SqrtElementMetric, FW11471148REAL(KIND=dp) :: u,v,w,s1149REAL(KIND=dp) :: Force(3),Alpha(3),Beta,Normal(3)1150REAL(KIND=dp), POINTER :: U_Integ(:),V_Integ(:),W_Integ(:),S_Integ(:)1151REAL(KIND=dp) :: Tangent(3),Tangent2(3),Vect(3), SlipCoeff1152REAL(KIND=dp) :: Up,Vp,Wp1153INTEGER :: i,t,q,p,dim,N_Integ, c11541155LOGICAL :: stat, VariableFlowWidth, VariableLocalFlowWidth1156LOGICAL,SAVE :: AllocationDone=.False.11571158TYPE(GaussIntegrationPoints_t), TARGET :: IntegStuff1159!------------------------------------------------------------------------------11601161dim = CoordinateSystemDimension()1162c=dim+111631164BoundaryVector = 0.0D01165BoundaryMatrix = 0.0D01166!1167! Integration stuff1168!1169IntegStuff = GaussPoints( element )1170U_Integ => IntegStuff % u1171V_Integ => IntegStuff % v1172W_Integ => IntegStuff % w1173S_Integ => IntegStuff % s1174N_Integ = IntegStuff % n11751176NodeIndexes => Element % NodeIndexes11771178NodalFlowWidth(1:n) = ListGetReal ( Material, &1179'FlowWidth', n, NodeIndexes, GotIt)1180IF (.NOT. GotIt .AND. CSymmetry) THEN1181DO i=1,n1182NodalFlowWidth(i) = Nodes % x(i)1183END DO1184END IF1185!1186! Now we start integrating1187!1188DO t=1,N_Integ11891190u = U_Integ(t)1191v = V_Integ(t)1192w = W_Integ(t)11931194!------------------------------------------------------------------------------1195! Basis function values & derivatives at the integration point1196!------------------------------------------------------------------------------1197stat = ElementInfo( Element, Nodes, u, v, w, SqrtElementMetric, &1198Basis, dBasisdx, ddBasisddx, .FALSE. )11991200FW = SUM( NodalFlowWidth(1:n) * Basis(1:n) )12011202s = SqrtElementMetric * S_Integ(t)12031204IF (.NOT. VariableLocalFlowWidth ) Radius = 10e71205IF ( VariableFlowWidth ) s= s * FW12061207!------------------------------------------------------------------------------1208Force = 0.0D01209DO i=1,dim1210Force(i) = SUM( LoadVector(i,1:n)*Basis(1:n) )1211Alpha(i) = SUM( NodalAlpha(i,1:n)*Basis(1:n) )1212END DO12131214Normal = NormalVector( Element,Nodes,u,v,.TRUE. )1215Force = Force + SUM( NodalBeta(1:n)*Basis(1:n) ) * Normal12161217SELECT CASE( Element % TYPE % DIMENSION )1218CASE(1)1219Tangent(1) = Normal(2)1220Tangent(2) = -Normal(1)1221Tangent(3) = 0.0d01222CASE(2)1223CALL TangentDirections( Normal, Tangent, Tangent2 )1224END SELECT12251226IF ( ANY( NodalSlipCoeff(:,:) /= 0.0d0 ) ) THEN1227DO p=1,n1228DO q=1,n1229DO i=1,DIM1230SlipCoeff = SUM( NodalSlipCoeff(i,1:n) * Basis(1:n) )12311232IF (NormalTangential ) THEN1233SELECT CASE(i)1234CASE(1)1235Vect = Normal1236CASE(2)1237Vect = Tangent1238CASE(3)1239Vect = Tangent21240END SELECT12411242DO j=1,DIM1243DO k=1,DIM1244BoundaryMatrix( (p-1)*c+j,(q-1)*c+k ) = &1245BoundaryMatrix( (p-1)*c+j,(q-1)*c+k ) + &1246s * SlipCoeff * Basis(q) * Basis(p) * Vect(j) * Vect(k)1247END DO1248END DO1249ELSE1250BoundaryMatrix( (p-1)*c+i,(q-1)*c+i ) = &1251BoundaryMatrix( (p-1)*c+i,(q-1)*c+i ) + &1252s * SlipCoeff * Basis(q) * Basis(p)1253END IF1254END DO1255END DO1256END DO1257END IF1258125912601261DO p=1,N1262DO q=1,N1263DO i=1,dim1264BoundaryMatrix((p-1)*(dim+1)+i,(q-1)*(dim+1)+i) = &1265BoundaryMatrix((p-1)*(dim+1)+i,(q-1)*(dim+1)+i) + &1266s * Alpha(i) * Basis(q) * Basis(p)1267END DO1268END DO1269END DO12701271DO q=1,N1272DO i=1,dim1273BoundaryVector((q-1)*(dim+1)+i) = BoundaryVector((q-1)*(dim+1)+i) + &1274s * Basis(q) * Force(i)1275END DO1276END DO12771278END DO1279!------------------------------------------------------------------------------1280END SUBROUTINE LocalMatrixBoundary1281!------------------------------------------------------------------------------128212831284!------------------------------------------------------------------------------1285SUBROUTINE LocalSD( Stress, StrainRate, Spin, &1286NodalVelo, NodalTemp, NodalFluidity, NodalFlowWidth, &1287NodalK1, NodalK2, NodalE1, NodalE2, NodalE3, &1288Basis, dBasisdx, Element, n, Nodes, dim, Wn, MinSRInvariant, &1289Isotropic, VariableFlowWidth, VariableLocalFlowWidth )1290!------------------------------------------------------------------------------1291! Subroutine to compute the nodal Strain-Rate, Stress, ...1292!------------------------------------------------------------------------------1293INTEGER :: n, dim1294INTEGER :: INDi(6),INDj(6)1295REAL(KIND=dp) :: Stress(:,:), StrainRate(:,:), Spin(:,:)1296REAL(KIND=dp) :: NodalVelo(:,:), NodalTemp(:), NodalFluidity(:), &1297NodalFlowWidth(:)1298REAL(KIND=dp) :: Basis(2*n), ddBasisddx(1,1,1)1299REAL(KIND=dp) :: dBasisdx(2*n,3)1300REAL(KIND=dp) :: detJ1301REAL(KIND=dp) :: NodalK1(:), NodalK2(:)1302REAL(KIND=dp) :: NodalE1(:), NodalE2(:), NodalE3(:)1303REAL(KIND=dp) :: u, v, w1304REAL(KIND=dp) :: Wn(7), D(6), MinSRInvariant1305LOGICAL :: Isotropic,VariableFlowWidth, VariableLocalFlowWidth13061307TYPE(Nodes_t) :: Nodes1308TYPE(Element_t) :: Element1309!------------------------------------------------------------------------------1310LOGICAL :: stat1311INTEGER :: i,j,k,p,q1312REAL(KIND=dp) :: LGrad(3,3), Radius, Temp, ai(3), Angle(3),a2(6)1313REAL(KIND=dp) :: C(6,6), epsi1314Real(kind=dp) :: Bg, BGlenT, ss, nn1315!------------------------------------------------------------------------------1316INTERFACE1317Subroutine R2Ro(a2,dim,ai,angle)1318USE Types1319REAL(KIND=dp),intent(in) :: a2(6)1320Integer :: dim1321REAL(KIND=dp),intent(out) :: ai(3), Angle(3)1322End Subroutine R2Ro13231324Subroutine OPILGGE_ai_nl(ai,Angle,etaI,eta36)1325USE Types1326REAL(kind=dp), INTENT(in), DIMENSION(3) :: ai1327REAL(kind=dp), INTENT(in), DIMENSION(3) :: Angle1328REAL(kind=dp), INTENT(in), DIMENSION(:) :: etaI1329REAL(kind=dp), INTENT(out), DIMENSION(6,6) :: eta361330END SUBROUTINE OPILGGE_ai_nl1331END INTERFACE1332!------------------------------------------------------------------------------13331334!1335! Temperature at the integration point1336Temp = SUM( NodalTemp(1:n)*Basis(1:n) )1337Wn(1) = SUM( NodalFluidity(1:n)*Basis(1:n) )133813391340Stress = 0.01341StrainRate = 0.01342Spin = 0.01343!1344! Compute strainRate :1345! -------------------13461347LGrad = MATMUL( NodalVelo(:,1:n), dBasisdx(1:n,:) )13481349StrainRate = 0.5 * ( LGrad + TRANSPOSE(LGrad) )13501351IF ( VariableFlowWidth ) THEN13521353StrainRate(1,3) = 0.01354StrainRate(2,3) = 0.01355StrainRate(3,1) = 0.01356StrainRate(3,2) = 0.01357StrainRate(3,3) = 0.013581359IF (SUM( NodalFlowWidth(1:n) * dBasisdx(1:n,1)) == 0) THEN1360Radius = 10e71361ELSE1362Radius = SUM( NodalFlowWidth(1:n) * Basis(1:n) ) / &1363(SUM( NodalFlowWidth(1:n) * dBasisdx(1:n,1)) )1364END IF13651366IF ( Radius > 10*AEPS ) THEN1367StrainRate(3,3) = SUM( Nodalvelo(1,1:n) * Basis(1:n) ) / Radius1368END IF1369epsi = StrainRate(1,1)+StrainRate(2,2)+StrainRate(3,3)1370DO i=1,31371StrainRate(i,i) = StrainRate(i,i) - epsi/3.01372END DO1373ELSE1374epsi = StrainRate(1,1)+StrainRate(2,2)+StrainRate(3,3)1375DO i=1,dim1376StrainRate(i,i) = StrainRate(i,i) - epsi/dim1377END DO1378END IF13791380!1381! Compute Spin :1382! --------------13831384Spin = 0.5 * ( LGrad - TRANSPOSE(LGrad) )13851386!1387! Compute deviatoric stresses:1388! ----------------------------13891390IF (.Not.Isotropic) then1391C = 0.0_dp1392! Material parameters at that point1393a2(1) = SUM( NodalK1(1:n) * Basis(1:n) )1394a2(2) = SUM( NodalK2(1:n) * Basis(1:n) )1395a2(3) = 1.d0 - a2(1) - a2(2)1396a2(4) = SUM( NodalE1(1:n) * Basis(1:n) )1397a2(5) = SUM( NodalE2(1:n) * Basis(1:n) )1398a2(6) = SUM( NodalE3(1:n) * Basis(1:n) )13991400CALL R2Ro(a2,dim,ai,Angle)1401CALL OPILGGE_ai_nl(ai,Angle,FabricGrid,C)14021403!1404! Compute deviatoric stresses:1405! ----------------------------1406D(1) = StrainRate(1,1)1407D(2) = StrainRate(2,2)1408D(3) = StrainRate(3,3)1409D(4) = 2. * StrainRate(1,2)1410D(5) = 2. * StrainRate(2,3)1411D(6) = 2. * StrainRate(3,1)14121413INDi(1:6) = (/ 1, 2, 3, 1, 2, 3 /)1414INDj(1:6) = (/ 1, 2, 3, 2, 3, 1 /)1415DO k = 1, 2*dim1416DO j = 1, 2*dim1417Stress( INDi(k),INDj(k) ) = &1418Stress( INDi(k),INDj(k) ) + C(k,j) * D(j)1419END DO1420IF (k > 3) Stress( INDj(k),INDi(k) ) = Stress( INDi(k),INDj(k) )1421END DO14221423ELSE ! ISOTROPIC CASE1424Stress=2._dp * StrainRate1425END IF142614271428! non relative viscosities1429! Glen fluidity1430Bg=BGlenT(Temp,Wn)1431ss=1.0_dp1432! Case Non linear1433IF (Wn(2) > 1.0) THEN1434Bg=Bg**(1.0/Wn(2))14351436ss = 0.0_dp1437DO i = 1, 31438DO j = 1, 31439ss = ss + Stress(i,j)**21440END DO1441END DO1442nn = (1.0 - Wn(2))/(2.0*Wn(2))1443ss = (ss / 2.0)**nn14441445IF (ss < MinSRInvariant ) ss = MinSRInvariant144614471448END IF14491450Stress=Stress*ss/Bg1451145214531454!------------------------------------------------------------------------------1455END SUBROUTINE LocalSD1456!------------------------------------------------------------------------------1457!1458!------------------------------------------------------------------------------1459END SUBROUTINE AIFlowSolver_nlS21460!------------------------------------------------------------------------------146114621463