OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
diffusion_mod.F
Go to the documentation of this file.
1Copyright> OpenRadioss
2Copyright> Copyright (C) 1986-2025 Altair Engineering Inc.
3Copyright>
4Copyright> This program is free software: you can redistribute it and/or modify
5Copyright> it under the terms of the GNU Affero General Public License as published by
6Copyright> the Free Software Foundation, either version 3 of the License, or
7Copyright> (at your option) any later version.
8Copyright>
9Copyright> This program is distributed in the hope that it will be useful,
10Copyright> but WITHOUT ANY WARRANTY; without even the implied warranty of
11Copyright> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12Copyright> GNU Affero General Public License for more details.
13Copyright>
14Copyright> You should have received a copy of the GNU Affero General Public License
15Copyright> along with this program. If not, see <https://www.gnu.org/licenses/>.
16Copyright>
17Copyright>
18Copyright> Commercial Alternative: Altair Radioss Software
19Copyright>
20Copyright> As an alternative to this open-source version, Altair also offers Altair Radioss
21Copyright> software under a commercial license. Contact Altair to discuss further if the
22Copyright> commercial version may interest you: https://www.altair.com/radioss/.
23!||====================================================================
24!|| diffusion_mod ../engine/share/modules/diffusion_mod.F
25!||--- called by ------------------------------------------------------
26!|| alemain ../engine/source/ale/alemain.F
27!|| ns_fvm_diffusion ../engine/source/multifluid/ns_fvm_diffusion.F
28!|| radioss2 ../engine/source/engine/radioss2.F
29!|| resol ../engine/source/engine/resol.F
30!|| resol_head ../engine/source/engine/resol_head.F
31!||--- uses -----------------------------------------------------
32!|| linear_solver_mod ../engine/share/modules/linear_solver_mod.F
33!|| matrix_mod ../common_source/linearalgebra/matrix_mod.F
34!|| vector_mod ../common_source/linearalgebra/vector_mod.F
35!||====================================================================
38 USE matrix_mod
39 USE vector_mod
40 IMPLICIT NONE
41#include "my_real.inc"
42! .___________________________. !
43! | | !
44! | ********************** | !
45! | ** Type definitions ** | !
46! | ********************** | !
47! |___________________________| !
48
50 CLASS(t_linear_solver), PRIVATE, POINTER :: linear_solver
51 TYPE(t_cfs_matrix) :: mat
52 TYPE(t_vector) :: rhs
53 DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: sol
54 INTEGER, DIMENSION(:), ALLOCATABLE :: flag_outlet
55 my_real, DIMENSION(:), ALLOCATABLE :: nu
56 INTEGER :: nrhs
57 LOGICAL :: outlet_flagged = .false.
58 CONTAINS
59 PROCEDURE, pass :: init_diffusion
60 PROCEDURE, pass :: solve_diffusion
61 PROCEDURE, pass :: terminate_diffusion
62 PROCEDURE, pass :: get_solution
63 END TYPE t_diffusion
64
65! ._____________________________. !
66! | | !
67! | ************************ | !
68! | ** Interface routines ** | !
69! | ************************ | !
70! |_____________________________| !
71
72 CONTAINS
73!||====================================================================
74!|| init_diffusion ../engine/share/modules/diffusion_mod.F
75!||--- calls -----------------------------------------------------
76!||--- uses -----------------------------------------------------
77!|| ale_connectivity_mod ../common_source/modules/ale/ale_connectivity_mod.F
78!|| linear_solver_mod ../engine/share/modules/linear_solver_mod.F
79!|| spmd_comm_world_mod ../engine/source/mpi/spmd_comm_world.F90
80!||====================================================================
81 SUBROUTINE init_diffusion(this, LINSOL, NRHS, IPARG, ALE_CONNECT)
84C-----------------------------------------------
85C I m p l i c i t T y p e s
86C-----------------------------------------------
87 USE spmd_comm_world_mod, ONLY : spmd_comm_world
88#include "implicit_f.inc"
89C-----------------------------------------------
90C C o m m o n B l o c k s
91C-----------------------------------------------
92! NSPMD
93#include "com01_c.inc"
94! NPARG
95#include "param_c.inc"
96! NUMELS
97#include "com04_c.inc"
98! NSVOIS
99#include "spmd_c.inc"
100C-----------------------------------------------
101C M e s s a g e P a s s i n g
102C-----------------------------------------------
103#include "spmd.inc"
104C-----------------------------------------------
105C D u m m y A r g u m e n t s
106C-----------------------------------------------
107 CLASS(t_diffusion) :: this
108 CLASS(t_linear_solver), INTENT(IN), TARGET :: LINSOL
109 INTEGER, DIMENSION(NPARG, NGROUP), INTENT(IN) :: IPARG
110 INTEGER, INTENT(IN) :: NRHS
111 TYPE(t_ale_connectivity), INTENT(IN) :: ALE_CONNECT
112C-----------------------------------------------
113C L o c a l V a r i a b l e s
114C-----------------------------------------------
115 INTEGER :: MAT_NZ, NG, II, NEL, ITY, MATLAW, NFT, I, JJ, KK
116 INTEGER :: GLOB_DIM, MAX_ID, IAD, LGTH
117#ifdef MPI
118 INTEGER IERR
119#endif
120
121 this%NRHS = nrhs
122! number of non zero values for the diffusion matrix elem <-> elem matrix
123 mat_nz = 0
124 DO ng = 1, ngroup
125 matlaw = iparg(1, ng)
126 IF (matlaw == 151) THEN
127 nel = iparg(2, ng)
128 nft = iparg(3, ng)
129 ity = iparg(5, ng)
130 DO ii = 1, nel
131 i = ii + nft
132 mat_nz = mat_nz + 1
133 iad = ale_connect%EE_CONNECT%IAD_CONNECT(i)
134 lgth = ale_connect%EE_CONNECT%IAD_CONNECT(i+1)-ale_connect%EE_CONNECT%IAD_CONNECT(i)
135 DO jj = 1, lgth
136 kk = ale_connect%EE_CONNECT%CONNECTED(iad + jj - 1)
137 IF (kk > 0) THEN
138 mat_nz = mat_nz + 1
139 ENDIF
140 ENDDO
141 ENDDO
142 ENDIF
143 ENDDO
144! create matrix
145 CALL this%MAT%MATRIX_CREATE(mat_nz)
146! create rhs
147 CALL this%RHS%CREATE(nrhs * numels)
148! global system size
149 glob_dim = numels
150 max_id = maxval(ale_connect%IDGLOB%ID(1:numels + nsvois))
151#ifdef MPI
152 IF (nspmd > 1) THEN
153 CALL mpi_allreduce(max_id, glob_dim, 1, mpi_int, mpi_max, spmd_comm_world, ierr)
154 ENDIF
155#endif
156! solution
157 ALLOCATE(this%SOL(3 * glob_dim))
158! init solver
159 this%LINEAR_SOLVER => linsol
160 CALL this%LINEAR_SOLVER%INIT_SOLVER(glob_dim)
161! set rhs and matrix
162 CALL this%LINEAR_SOLVER%SET_RHS(3, this%RHS)
163 CALL this%LINEAR_SOLVER%SET_MATRIX(this%MAT)
164! diffusion coefficient, outlet flag
165 this%OUTLET_FLAGGED = .false.
166 IF (n2d == 0) THEN
167 ALLOCATE(this%NU(numels + nsvois))
168 this%NU(1:numels + nsvois) = zero
169 ALLOCATE(this%FLAG_OUTLET(6 * numels))
170 this%FLAG_OUTLET(1:6 * numels) = 0
171 ELSE
172 ALLOCATE(this%NU(numelq + numeltg + nqvois + ntgvois))
173 this%NU(1:numelq + numeltg + nqvois + ntgvois) = zero
174 ALLOCATE(this%FLAG_OUTLET(4 * numelq + 3 * numeltg))
175 this%FLAG_OUTLET(1:4 * numelq + 3 * numeltg) = 0
176 ENDIF
177
178 END SUBROUTINE init_diffusion
179
180!||====================================================================
181!|| solve_diffusion ../engine/share/modules/diffusion_mod.F
182!||--- calls -----------------------------------------------------
183!|| get_global_dim ../engine/share/modules/linear_solver_mod.F
184!||--- uses -----------------------------------------------------
185!|| spmd_comm_world_mod ../engine/source/mpi/spmd_comm_world.F90
186!||====================================================================
187 SUBROUTINE solve_diffusion(this)
188C-----------------------------------------------
189C I m p l i c i t T y p e s
190C-----------------------------------------------
191 USE spmd_comm_world_mod, ONLY : spmd_comm_world
192#include "implicit_f.inc"
193 CLASS(t_diffusion) :: this
194 INTEGER :: GLOB_DIM
195
196 glob_dim = this%LINEAR_SOLVER%GET_GLOBAL_DIM()
197 CALL this%LINEAR_SOLVER%SOLVE(this%SOL, this%NRHS * glob_dim)
198
199 END SUBROUTINE solve_diffusion
200
201!||====================================================================
202!|| get_solution ../engine/share/modules/diffusion_mod.F
203!||--- calls -----------------------------------------------------
204!|| get_global_dim ../engine/share/modules/linear_solver_mod.F
205!||--- uses -----------------------------------------------------
206!|| spmd_comm_world_mod ../engine/source/mpi/spmd_comm_world.F90
207!||====================================================================
208 SUBROUTINE get_solution(this, SOL, GLOB_DIM)
209C-----------------------------------------------
210C I m p l i c i t T y p e s
211C-----------------------------------------------
212 USE spmd_comm_world_mod, ONLY : spmd_comm_world
213#include "implicit_f.inc"
214 CLASS(t_diffusion), INTENT(INOUT), TARGET :: this
215 INTEGER, INTENT(OUT) :: GLOB_DIM
216
217 DOUBLE PRECISION, DIMENSION(:), INTENT(INOUT), POINTER :: SOL
218 sol => this%SOL
219 glob_dim = this%LINEAR_SOLVER%GET_GLOBAL_DIM()
220 END SUBROUTINE get_solution
221
222!||====================================================================
223!|| terminate_diffusion ../engine/share/modules/diffusion_mod.F
224!||--- uses -----------------------------------------------------
225!|| spmd_comm_world_mod ../engine/source/mpi/spmd_comm_world.F90
226!||====================================================================
227 SUBROUTINE terminate_diffusion(this)
228C-----------------------------------------------
229C I m p l i c i t T y p e s
230C-----------------------------------------------
231 USE spmd_comm_world_mod, ONLY : spmd_comm_world
232#include "implicit_f.inc"
233 CLASS(t_diffusion), INTENT(INOUT) :: this
234
235
236 CALL this%LINEAR_SOLVER%TERMINATE()
237 CALL this%MAT%MATRIX_DESTROY()
238 CALL this%RHS%DESTROY()
239 IF (ALLOCATED(this%SOL)) DEALLOCATE(this%SOL)
240 IF (ALLOCATED(this%NU)) DEALLOCATE(this%NU)
241 IF (ALLOCATED(this%FLAG_OUTLET)) DEALLOCATE(this%FLAG_OUTLET)
242 END SUBROUTINE terminate_diffusion
243 END MODULE diffusion_mod
#define my_real
Definition cppsort.cpp:32
subroutine mpi_allreduce(sendbuf, recvbuf, cnt, datatype, operation, comm, ierr)
Definition mpi.f:103
subroutine init_diffusion(this, linsol, nrhs, iparg, ale_connect)
subroutine get_solution(this, sol, glob_dim)
subroutine solve_diffusion(this)
subroutine terminate_diffusion(this)