Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmerice/Solvers/ExportVertically.F90
3203 views
1
!/*****************************************************************************/
2
! *
3
! * Elmer, A Finite Element Software for Multiphysical Problems
4
! *
5
! * Copyright 1st April 1995 - , CSC - Scientific Computing Ltd., Finland
6
! *
7
! * This program is free software; you can redistribute it and/or
8
! * modify it under the terms of the GNU General Public License
9
! * as published by the Free Software Foundation; either version 2
10
! * of the License, or (at your option) any later version.
11
! *
12
! * This program is distributed in the hope that it will be useful,
13
! * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
! * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
! * GNU General Public License for more details.
16
! *
17
! * You should have received a copy of the GNU General Public License
18
! * along with this program (in file fem/GPL-2); if not, write to the
19
! * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
! * Boston, MA 02110-1301, USA.
21
! *
22
! *****************************************************************************/
23
!/*****************************************************************************/
24
! *
25
! * ExportVertically Solver to export vertically a variable computed on
26
! * the upper or lower boundary in the whole domain
27
! *
28
! ******************************************************************************
29
! *
30
! * Authors: Olivier Gagliardini
31
! * Email: [email protected]
32
! * Web: http://www.csc.fi/elmer
33
! *
34
! * Original Date: 30 April 2010
35
! *
36
! *****************************************************************************
37
38
39
! *****************************************************************************
40
SUBROUTINE ExportVertically( Model,Solver,dt,TransientSimulation )
41
!DEC$ATTRIBUTES DLLEXPORT :: ExportVertically
42
!------------------------------------------------------------------------------
43
!******************************************************************************
44
!
45
! Export vertically the SSABasal Velocity (given as a Dirichlet Boundary condition)
46
! Compute also the vertical velocity and the pressure
47
!
48
! ARGUMENTS:
49
!
50
! TYPE(Model_t) :: Model,
51
! INPUT: All model information (mesh, materials, BCs, etc...)
52
!
53
! TYPE(Solver_t) :: Solver
54
! INPUT: Linear & nonlinear equation solver options
55
!
56
! REAL(KIND=dp) :: dt,
57
! INPUT: Timestep size for time dependent simulations
58
!
59
! LOGICAL :: TransientSimulation
60
! INPUT: Steady state or transient simulation
61
!
62
!******************************************************************************
63
USE DefUtils
64
65
IMPLICIT NONE
66
!------------------------------------------------------------------------------
67
TYPE(Solver_t) :: Solver
68
TYPE(Model_t) :: Model
69
70
REAL(KIND=dp) :: dt
71
LOGICAL :: TransientSimulation
72
!------------------------------------------------------------------------------
73
! Local variables
74
!------------------------------------------------------------------------------
75
TYPE(Element_t),POINTER :: CurrentElement, Element
76
TYPE(Matrix_t),POINTER :: StiffMatrix
77
TYPE(ValueList_t), POINTER :: SolverParams, BodyForce, Material
78
TYPE(Variable_t), POINTER :: PointerToVariable
79
80
LOGICAL :: AllocationsDone = .FALSE.
81
82
INTEGER :: i, n, m, t, istat, p, Indexes(128)
83
INTEGER, POINTER :: Permutation(:)
84
85
REAL(KIND=dp), POINTER :: ForceVector(:), VariableValues(:)
86
REAL(KIND=dp) :: Norm
87
88
REAL(KIND=dp), ALLOCATABLE :: STIFF(:,:), FORCE(:)
89
90
CHARACTER(LEN=MAX_NAME_LEN) :: SolverName
91
92
93
SAVE STIFF, FORCE, AllocationsDone, SolverName
94
!------------------------------------------------------------------------------
95
PointerToVariable => Solver % Variable
96
Permutation => PointerToVariable % Perm
97
VariableValues => PointerToVariable % Values
98
WRITE(SolverName, '(A)') 'ExportVertically'
99
100
101
!--------------------------------------------------------------
102
!Allocate some permanent storage, this is done first time only:
103
!--------------------------------------------------------------
104
IF ( (.NOT. AllocationsDone) .OR. Solver % Mesh % Changed ) THEN
105
N = Solver % Mesh % MaxElementNodes ! just big enough for elemental arrays
106
M = Model % Mesh % NumberOfNodes
107
IF (AllocationsDone) DEALLOCATE(FORCE, STIFF)
108
109
ALLOCATE( FORCE(N), STIFF(N,N), STAT=istat )
110
111
IF ( istat /= 0 ) THEN
112
CALL Fatal( SolverName, 'Memory allocation error.' )
113
END IF
114
115
AllocationsDone = .TRUE.
116
CALL INFO( SolverName, 'Memory allocation done.',Level=1 )
117
END IF
118
119
StiffMatrix => Solver % Matrix
120
ForceVector => StiffMatrix % RHS
121
122
123
! No non-linear iteration, no time dependency
124
VariableValues = 0.0d0
125
Norm = Solver % Variable % Norm
126
127
128
!Initialize the system and do the assembly:
129
!------------------------------------------
130
CALL DefaultInitialize()
131
! bulk assembly
132
DO t=1,Solver % NumberOfActiveElements
133
Element => GetActiveElement(t)
134
IF (ParEnv % myPe .NE. Element % partIndex) CYCLE
135
n = GetElementNOFNodes()
136
137
138
CALL LocalMatrix ( STIFF, FORCE, Element, n )
139
140
CALL DefaultUpdateEquations( STIFF, FORCE )
141
END DO
142
143
CALL DefaultFinishAssembly()
144
145
! Dirichlet
146
CALL DefaultDirichletBCs()
147
148
!Solve the system
149
Norm = DefaultSolve()
150
151
152
CONTAINS
153
154
!------------------------------------------------------------------------------
155
SUBROUTINE LocalMatrix( STIFF, FORCE, Element, n )
156
!------------------------------------------------------------------------------
157
REAL(KIND=dp) :: STIFF(:,:), FORCE(:)
158
INTEGER :: n
159
TYPE(Element_t), POINTER :: Element
160
!------------------------------------------------------------------------------
161
REAL(KIND=dp) :: Basis(n), dBasisdx(n,3), ddBasisddx(n,3,3), detJ
162
LOGICAL :: Stat
163
INTEGER :: t, p, q , dim
164
TYPE(GaussIntegrationPoints_t) :: IP
165
166
TYPE(Nodes_t) :: Nodes
167
SAVE Nodes
168
!------------------------------------------------------------------------------
169
CALL GetElementNodes( Nodes )
170
STIFF = 0.0d0
171
FORCE = 0.0d0
172
173
dim = CoordinateSystemDimension()
174
175
176
IP = GaussPoints( Element )
177
DO t=1,IP % n
178
stat = ElementInfo( Element, Nodes, IP % U(t), IP % V(t), &
179
IP % W(t), detJ, Basis, dBasisdx, ddBasisddx, .FALSE. )
180
181
DO p=1,n
182
DO q=1,n
183
STIFF(p,q) = STIFF(p,q) + IP % S(t) * detJ * dBasisdx(q,dim)*dBasisdx(p,dim)
184
END DO
185
END DO
186
187
END DO
188
!------------------------------------------------------------------------------
189
END SUBROUTINE LocalMatrix
190
!------------------------------------------------------------------------------
191
192
!------------------------------------------------------------------------------
193
END SUBROUTINE ExportVertically
194
!------------------------------------------------------------------------------
195
196
197
198