Path: blob/devel/elmerice/UserFunctions/USF_WaterTransfer.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: Basile de Fleurian25! * Email: [email protected]; [email protected]26! * Web: http://elmerice.elmerfem.org27! *28! * Original Date: 02 Jully 201329!------------------------------------------------------------------------------30! Transfer of the water between two drainage systems,transfer is computed to go31! from the EPL layer to the sediment one giving positive value of the transfer32! when water flows in this way and negative in the other;33! This function requires two hydrological solvers (inefficient and efficient)34!-----------------------------------------------------------------------------3536FUNCTION EPLToIDS(Model,nodenumber,x) RESULT(Transfer)37USE DefUtils38USE types39USE CoordinateSystems40USE SolverUtils41USE ElementDescription4243IMPLICIT NONE44!-----------------------------------------------45! External variables46!-----------------------------------------------47TYPE(Model_t) :: Model48INTEGER :: nodenumber49REAL(KIND=dp) :: Transfer, x50!-----------------------------------------------51! Local variables52!-----------------------------------------------5354TYPE(Element_t),POINTER :: Element55TYPE(Variable_t), POINTER :: IDSHead, EPLHead, PipingMask56TYPE(ValueList_t), POINTER :: Constants, Material, BodyForce5758REAL(KIND=dp), POINTER :: IDSValues(:), EPLValues(:), MaskValues(:)59REAL(KIND=dp), ALLOCATABLE :: g(:,:)60REAL(KIND=dp), ALLOCATABLE :: Density(:), Gravity(:), &61EPLComp(:), EPLPorosity(:), EPLThick(:), EPLStoring(:),&62IDSComp(:), IDSPorosity(:), IDSThick(:), IDSStoring(:),&63IDSTrans(:),UpperLimit(:), LeakFact(:)64REAL(KIND=dp)::WatComp6566INTEGER, POINTER :: IDSPerm(:), EPLPerm(:), MaskPerm(:)67INTEGER :: material_id, bf_id68INTEGER :: N, istat, i, k6970LOGICAL :: FirstTime=.TRUE., &71Found= .FALSE., &72AllocationsDone= .FALSE., &73UnFoundFatal=.TRUE.7475SAVE g, &76Density, &77Gravity, &78EPLComp, &79EPLPorosity, &80EPLThick, &81EPLStoring, &82IDSComp, &83IDSPorosity, &84IDSThick, &85IDSStoring, &86IDSTrans, &87UpperLimit, &88LeakFact, &89FirstTime, &90Found, &91AllocationsDone9293IF (FirstTime)THEN94FirstTime = .FALSE.95IF ( AllocationsDone ) THEN96DEALLOCATE(g, &97Density, &98Gravity, &99EPLComp, &100EPLPorosity, &101EPLThick, &102EPLStoring, &103IDSComp, &104IDSPorosity, &105IDSThick, &106IDSStoring, &107IDSTrans, &108UpperLimit, &109LeakFact)110111END IF112113N = Model % MaxElementNodes114ALLOCATE(g( 3,N ), &115Density( N ), &116Gravity( N ), &117EPLComp( N ), &118EPLPorosity( N ), &119EPLThick( N ), &120EPLStoring( N ), &121IDSComp( N ), &122IDSPorosity( N ), &123IDSThick( N ), &124IDSStoring( N ), &125IDSTrans( N ), &126UpperLimit( N ), &127LeakFact( N ), &128STAT=istat)129130IF ( istat /= 0 ) THEN131CALL FATAL( 'USF_WaterTransfer', 'Memory allocation error' )132ELSE133WRITE(Message,'(a)') 'Memory allocation done'134CALL INFO("WaterTransfer",Message,Level=4)135END IF136AllocationsDone = .TRUE.137END IF138139140!Get the Mask141!------------142PipingMask => VariableGet( Model % Variables, 'Open EPL',UnFoundFatal=UnFoundFatal)143MaskPerm => PipingMask % Perm144MaskValues => PipingMask % Values145146IF(MaskValues(MaskPerm(nodenumber)).GE.0.0)THEN147!EPL is not active, no transfer148Transfer = 0.0149ELSE150151!Get the EPL and IDS water Heads152!-------------------------------------153EPLHead => VariableGet( Model % Variables, 'EPLHead',UnFoundFatal=UnFoundFatal)154EPLPerm => EPLHead % Perm155EPLValues => EPLHead % Values156157IDSHead => VariableGet( Model % Variables, 'IDSHead',UnFoundFatal=UnFoundFatal)158IDSPerm => IDSHead % Perm159IDSValues => IDSHead % Values160161!Get Parameters needed to compute the storing coefficient162!-------------------------------------------------------163Element => Model % CurrentElement164Material => GetMaterial(Element)165N = GetElementNOFNodes(Element)166Constants => GetConstants()167BodyForce => GetBodyForce()168169IF (.NOT.ASSOCIATED(Material)) THEN170WRITE (Message,'(A)') 'No Material found for boundary element no. '171CALL FATAL("WaterTransfer",Message)172ELSE173material_id = GetMaterialId( Element, Found)174IF(.NOT.Found) THEN175WRITE (Message,'(A)') 'No Material ID found for boundary element no. '176CALL FATAL("WaterTransfer",Message)177END IF178END IF179180!Generic parameters181!------------------182WatComp = GetConstReal( Constants, &183'Water Compressibility', Found)184IF ( .NOT.Found ) THEN185WatComp = 5.04e-4186END IF187188Density(1:N) = ListGetReal( Material, 'Water Density', N, Element % NodeIndexes, Found,&189UnfoundFatal=UnFoundFatal)190!Previous default value: Density = 1.0055e-18191192IF ( ASSOCIATED( BodyForce ) ) THEN193bf_id = GetBodyForceId()194g = 0.0_dp195g(1,1:N) = GetConstReal( Model % BodyForces(bf_id) % Values, 'Flow BodyForce 1',Found)196g(2,1:N) = GetConstReal( Model % BodyForces(bf_id) % Values, 'Flow BodyForce 2',Found)197g(3,1:N) = GetConstReal( Model % BodyForces(bf_id) % Values, 'Flow BodyForce 3',Found)198Gravity(1:N) = SQRT(SUM(g**2.0/N))199END IF200201!EPL Parameters202!--------------203EPLComp(1:N) = listGetReal( Material,'EPL Compressibility', N, Element % NodeIndexes, Found,&204UnfoundFatal=UnFoundFatal)205!Previous default value: EPLComp(1:N) = 1.0D-2206207EPLPorosity(1:N) = listGetReal( Material,'EPL Porosity', N, Element % NodeIndexes, Found,&208UnfoundFatal=UnFoundFatal)209!Previous default value: EPLPorosity(1:N) = 0.4D00210211EPLThick(1:N) = listGetReal( Material,'EPL Thickness', N, Element % NodeIndexes, Found,&212UnfoundFatal=UnFoundFatal)213!Previous default value: EPLThick(1:N) = 10.0D00214215!Inefficient Drainage System Parameters216!--------------------------------------217IDSComp(1:N) = listGetReal( Material,'IDS Compressibility', N, Element % NodeIndexes, Found,&218UnfoundFatal=UnFoundFatal)219!Previous default value: IDSComp(1:N) = 1.0D-2220221IDSPorosity(1:N) = listGetReal( Material,'IDS Porosity', N, Element % NodeIndexes, Found,&222UnfoundFatal=UnFoundFatal)223!Previous default value: IDSPorosity(1:N) = 0.4D00224225IDSThick(1:N) = listGetReal( Material,'IDS Thickness', N, Element % NodeIndexes, Found,&226UnfoundFatal=UnFoundFatal)227!Previous default value: IDSThick(1:N) = 10.0D00228229!Computing the Storing coefficient of the EPL230!-------------------------------------------231EPLStoring(1:N) = EPLThick(1:N) * &232Gravity(1:N) * EPLPorosity(1:N) * Density(1:N) * &233(WatComp + EPLComp(1:N)/EPLPorosity(1:N))234235!Computing the Storing coefficient of the Inefficient Drainage System236!-------------------------------------------------------------------237IDSStoring(1:N) = IDSThick(1:N) * &238Gravity(1:N) * IDSPorosity(1:N) * Density(1:N) * &239(WatComp + IDSComp(1:N)/IDSPorosity(1:N))240241!Get Inefficient Drainage System Transmitivity242!---------------------------------------------243IDSTrans(1:N) = listGetReal( Material,'IDS Transmitivity', N, Element % NodeIndexes, Found,&244UnfoundFatal=UnFoundFatal)245!Previous default value: IDSTrans(1:N) = 1.5D04246247!Get Inefficient Drainage System Upper Limit248!-------------------------------------------249UpperLimit(1:n) = ListGetReal(Material,'IDSHead Upper Limit',&250N, Element % NodeIndexes, Found)251IF (.NOT. Found) THEN252WRITE(Message,'(a)') 'No upper limit of solution for element no.'253CALL INFO("WaterTransfer", Message, level=10)254END IF255256!Getting parameters needed by the Transfer Equation257!--------------------------------------------------258LeakFact(1:n) = ListGetReal( Material, 'Leakage Factor', N, Element % NodeIndexes, Found,&259UnfoundFatal=UnFoundFatal)260!Previous default value: LeakFact(1:N) = 50.0D00261262!Computation of the Transfer263!---------------------------264DO i=1,N265k = Element % NodeIndexes(i)266IF(nodenumber.EQ. k)THEN267IF((IDSValues(IDSPerm(k)).GE.UpperLimit(i)).AND. &268(EPLValues(EPLPerm(k)).GT.IDSValues(IDSPerm(k))))THEN269!If Inefficient Drainage System Head is at upper limit and EPL Head greater than Inefficient Drainage System Head270! Then do nothing271Transfer = 0.0272ELSE273Transfer = IDSTrans(i) &274*(EPLValues(EPLPerm(k)) - IDSValues(IDSPerm(k))) &275/(IDSThick(i) * LeakFact(i))276IF(Transfer.GT.0.0)THEN !Positive Transfer is from EPL to IDS277Transfer = Transfer * EPLStoring(i)278ELSEIF(Transfer.LT.0.0)THEN !Negative Transfer from IDS to EPL279Transfer = Transfer * IDSStoring(i)280END IF281END IF282EXIT283END IF284END DO285END IF286287END FUNCTION EPLToIDS288289290