Path: blob/devel/elmerice/Solvers/ExportVertically.F90
3203 views
!/*****************************************************************************/1! *2! * Elmer, A Finite Element Software for Multiphysical Problems3! *4! * Copyright 1st April 1995 - , CSC - Scientific Computing Ltd., Finland5! *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! * ExportVertically Solver to export vertically a variable computed on25! * the upper or lower boundary in the whole domain26! *27! ******************************************************************************28! *29! * Authors: Olivier Gagliardini30! * Email: [email protected]31! * Web: http://www.csc.fi/elmer32! *33! * Original Date: 30 April 201034! *35! *****************************************************************************363738! *****************************************************************************39SUBROUTINE ExportVertically( Model,Solver,dt,TransientSimulation )40!DEC$ATTRIBUTES DLLEXPORT :: ExportVertically41!------------------------------------------------------------------------------42!******************************************************************************43!44! Export vertically the SSABasal Velocity (given as a Dirichlet Boundary condition)45! Compute also the vertical velocity and the pressure46!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 & nonlinear equation solver options54!55! REAL(KIND=dp) :: dt,56! INPUT: Timestep size for time dependent simulations57!58! LOGICAL :: TransientSimulation59! INPUT: Steady state or transient simulation60!61!******************************************************************************62USE DefUtils6364IMPLICIT NONE65!------------------------------------------------------------------------------66TYPE(Solver_t) :: Solver67TYPE(Model_t) :: Model6869REAL(KIND=dp) :: dt70LOGICAL :: TransientSimulation71!------------------------------------------------------------------------------72! Local variables73!------------------------------------------------------------------------------74TYPE(Element_t),POINTER :: CurrentElement, Element75TYPE(Matrix_t),POINTER :: StiffMatrix76TYPE(ValueList_t), POINTER :: SolverParams, BodyForce, Material77TYPE(Variable_t), POINTER :: PointerToVariable7879LOGICAL :: AllocationsDone = .FALSE.8081INTEGER :: i, n, m, t, istat, p, Indexes(128)82INTEGER, POINTER :: Permutation(:)8384REAL(KIND=dp), POINTER :: ForceVector(:), VariableValues(:)85REAL(KIND=dp) :: Norm8687REAL(KIND=dp), ALLOCATABLE :: STIFF(:,:), FORCE(:)8889CHARACTER(LEN=MAX_NAME_LEN) :: SolverName909192SAVE STIFF, FORCE, AllocationsDone, SolverName93!------------------------------------------------------------------------------94PointerToVariable => Solver % Variable95Permutation => PointerToVariable % Perm96VariableValues => PointerToVariable % Values97WRITE(SolverName, '(A)') 'ExportVertically'9899100!--------------------------------------------------------------101!Allocate some permanent storage, this is done first time only:102!--------------------------------------------------------------103IF ( (.NOT. AllocationsDone) .OR. Solver % Mesh % Changed ) THEN104N = Solver % Mesh % MaxElementNodes ! just big enough for elemental arrays105M = Model % Mesh % NumberOfNodes106IF (AllocationsDone) DEALLOCATE(FORCE, STIFF)107108ALLOCATE( FORCE(N), STIFF(N,N), STAT=istat )109110IF ( istat /= 0 ) THEN111CALL Fatal( SolverName, 'Memory allocation error.' )112END IF113114AllocationsDone = .TRUE.115CALL INFO( SolverName, 'Memory allocation done.',Level=1 )116END IF117118StiffMatrix => Solver % Matrix119ForceVector => StiffMatrix % RHS120121122! No non-linear iteration, no time dependency123VariableValues = 0.0d0124Norm = Solver % Variable % Norm125126127!Initialize the system and do the assembly:128!------------------------------------------129CALL DefaultInitialize()130! bulk assembly131DO t=1,Solver % NumberOfActiveElements132Element => GetActiveElement(t)133IF (ParEnv % myPe .NE. Element % partIndex) CYCLE134n = GetElementNOFNodes()135136137CALL LocalMatrix ( STIFF, FORCE, Element, n )138139CALL DefaultUpdateEquations( STIFF, FORCE )140END DO141142CALL DefaultFinishAssembly()143144! Dirichlet145CALL DefaultDirichletBCs()146147!Solve the system148Norm = DefaultSolve()149150151CONTAINS152153!------------------------------------------------------------------------------154SUBROUTINE LocalMatrix( STIFF, FORCE, Element, n )155!------------------------------------------------------------------------------156REAL(KIND=dp) :: STIFF(:,:), FORCE(:)157INTEGER :: n158TYPE(Element_t), POINTER :: Element159!------------------------------------------------------------------------------160REAL(KIND=dp) :: Basis(n), dBasisdx(n,3), ddBasisddx(n,3,3), detJ161LOGICAL :: Stat162INTEGER :: t, p, q , dim163TYPE(GaussIntegrationPoints_t) :: IP164165TYPE(Nodes_t) :: Nodes166SAVE Nodes167!------------------------------------------------------------------------------168CALL GetElementNodes( Nodes )169STIFF = 0.0d0170FORCE = 0.0d0171172dim = CoordinateSystemDimension()173174175IP = GaussPoints( Element )176DO t=1,IP % n177stat = ElementInfo( Element, Nodes, IP % U(t), IP % V(t), &178IP % W(t), detJ, Basis, dBasisdx, ddBasisddx, .FALSE. )179180DO p=1,n181DO q=1,n182STIFF(p,q) = STIFF(p,q) + IP % S(t) * detJ * dBasisdx(q,dim)*dBasisdx(p,dim)183END DO184END DO185186END DO187!------------------------------------------------------------------------------188END SUBROUTINE LocalMatrix189!------------------------------------------------------------------------------190191!------------------------------------------------------------------------------192END SUBROUTINE ExportVertically193!------------------------------------------------------------------------------194195196197198