Path: blob/devel/elmerice/UserFunctions/USF_LateralFriction.F90
3196 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: Olivier Gagliardini25! * Email:26! * Web: http://elmerice.elmerfem.org27! *28! * Original Date:29! * Date modifications:30! *31! *32! *****************************************************************************33!> Lateral Friction user functions34!>35!> return the gravity force -g + K * ||u||^(m-1) u36!> where K is the a lateral friction coefficient,37!> m the lateral friction exponent,38!> end u is the velocity vector39!> work only in 2D (no sense in 3D)40!> work for non-structured mesh41FUNCTION LateralFriction_x ( Model, nodenumber, x) RESULT(gx)42USE Types43USE DefUtils44IMPLICIT NONE45TYPE(Model_t) :: Model46INTEGER :: nodenumber47REAL(KIND=dp) :: x, gx, LateralFriction4849gx = LateralFriction ( Model, nodenumber, x, 1 )505152END FUNCTION LateralFriction_x5354FUNCTION LateralFriction_y ( Model, nodenumber, x) RESULT(gy)55USE Types56USE DefUtils57IMPLICIT NONE58TYPE(Model_t) :: Model59INTEGER :: nodenumber60REAL(KIND=dp) :: x, gy, LateralFriction6162gy = LateralFriction ( Model, nodenumber, x, 2 )6364END FUNCTION LateralFriction_y6566676869FUNCTION LateralFriction ( Model, nodenumber, x, axis ) RESULT(gi)70USE types71USE CoordinateSystems72USE SolverUtils73USE ElementDescription74USE DefUtils75IMPLICIT NONE76TYPE(Model_t) :: Model77INTEGER :: nodenumber, axis78REAL(KIND=dp) :: x, gi, Kspring, mm7980TYPE(Nodes_t), SAVE :: Nodes81TYPE(Element_t), POINTER :: CurElement82TYPE(variable_t), POINTER :: FlowVariable83TYPE(ValueList_t), POINTER :: BodyForce, Material8485REAL(KIND=dp), POINTER :: FlowValues(:)86INTEGER, POINTER :: FlowPerm(:)8788REAL(KIND=dp), ALLOCATABLE :: auxReal(:)8990REAL(KIND=dp) :: g(2), Velo(2), NVelo91INTEGER :: i, j, n929394LOGICAL :: FirstTime = .TRUE., GotIt9596CHARACTER(LEN=MAX_NAME_LEN) :: FlowSolverName9798SAVE FirstTime, g, mm, FlowSolverName, auxReal99100BodyForce => GetBodyForce()101material => GetMaterial()102103IF (FirstTime) THEN104105FirstTime = .FALSE.106107n = Model % MaxElementNodes108ALLOCATE( auxReal(n) )109110!---------------------111! Get the gravity vector g112!-------------------------113g(1) = GetConstReal( BodyForce, 'Lateral Friction Gravity 1', GotIt )114g(2) = GetConstReal( BodyForce, 'Lateral Friction Gravity 2', GotIt )115IF (.Not.GotIt ) CALL FATAL('LateralFriction', &116'Gravity vector must be specified')117118119mm = GetConstReal( BodyForce, 'Lateral Friction Exponent', GotIt )120IF (.Not.GotIt ) CALL FATAL('LateralFriction', &121'Lateral Friction Exponent must be defined')122123FlowSolverName = GetString( BodyForce, 'Flow Solver Name', GotIt )124IF (.NOT.Gotit) FlowSolverName = 'Flow Solution'125126ENDIF !FirstTime127128129FlowVariable => VariableGet( Model % Variables, FlowSolverName )130IF ( ASSOCIATED( FlowVariable ) ) THEN131FlowPerm => FlowVariable % Perm132FlowValues => FlowVariable % Values133ELSE134CALL Info('ShapeFactorGravity', &135& 'No variable for velocity associated.', Level=4)136END IF137NVelo = 0.0138DO i=1, 2139Velo(i) = FlowValues(3*(FlowPerm(nodenumber)-1) + i)140NVelo = NVelo + Velo(i)**2.0141END DO142NVelo = SQRT(NVelo)143144!------------------------------------145! Get K coefficient for that nodes146!------------------------------------147CurElement => Model % CurrentElement148n = CurElement % Type % NumberOfNodes149auxReal(1:n) = GetReal( BodyForce, &150'Lateral Friction Coefficient', GotIt )151DO i=1, n152j = CurElement % NodeIndexes (i)153IF (nodenumber == j) EXIT154END DO155Kspring = auxReal(i)156IF ((NVelo > 1.0e-6).AND.(ABS(mm-1.0)>1.0e-6)) Kspring = Kspring * Nvelo**(mm-1.0)157158gi = g(axis) - Kspring*velo(axis)159160END FUNCTION LateralFriction161162163164165166