OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
matrix_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!|| matrix_mod ../common_source/linearalgebra/matrix_mod.F
25!||--- called by ------------------------------------------------------
26!|| diffusion_mod ../engine/share/modules/diffusion_mod.F
27!|| linear_solver_mod ../engine/share/modules/linear_solver_mod.F
28!|| set_matrix ../engine/share/modules/linear_solver_mod.F
29!|| set_matrix_cg ../engine/share/modules/linear_solver_mod.F
30!|| set_matrix_mumps ../engine/share/modules/linear_solver_mod.F
31!||--- calls -----------------------------------------------------
32!|| get_dim ../common_source/linearalgebra/matrix_mod.F
33!||====================================================================
35 implicit none
36#include "my_real.inc"
37
38! ******************************* !
39! Coordinate format Sparse Matrix !
40! ******************************* !
41
43 integer, private :: dim
44 integer, dimension(:), allocatable :: irow, jcol
45 double precision, dimension(:), allocatable :: val
46 contains
47 procedure, pass :: matrix_create
48 procedure, pass :: matrix_destroy
49 procedure, pass :: matrix_associate
50 procedure, pass :: get_dim
51 end type t_cfs_matrix
52
53 contains
54
55! ************ !
56! Mat vec prod !
57! ************ !
58
59!||====================================================================
60!|| prod_vec ../common_source/linearalgebra/matrix_mod.F
61!||--- called by ------------------------------------------------------
62!|| solve_cg ../engine/share/modules/linear_solver_mod.F
63!||--- calls -----------------------------------------------------
64!|| get_dim ../common_source/linearalgebra/matrix_mod.F
65!||--- uses -----------------------------------------------------
66!|| vector_mod ../common_source/linearalgebra/vector_mod.F
67!||====================================================================
68 subroutine prod_vec(this, xvec, bvec)
69 USE vector_mod
70C-----------------------------------------------
71C I m p l i c i t T y p e s
72C-----------------------------------------------
73#include "implicit_f.inc"
74 class(t_cfs_matrix), intent(in) :: this
75 type(t_vector), intent(in) :: xvec
76 type(t_vector), intent(inout) :: bvec
77 integer :: i, j
78
79 integer :: ii
80 bvec%val(1:bvec%get_dim()) = zero
81 do ii = 1, this%dim
82 i = this%irow(ii)
83 j = this%jcol(ii)
84 bvec%val(i) = bvec%val(i) + this%val(ii) * xvec%val(j)
85 enddo
86
87 end subroutine prod_vec
88
89! ******************** !
90! Get Matrix dimension !
91! ******************** !
92
93!||====================================================================
94!|| get_dim ../common_source/linearalgebra/matrix_mod.F
95!||--- called by ------------------------------------------------------
96!|| matrix_mod ../common_source/linearalgebra/matrix_mod.F
97!|| prod_vec ../common_source/linearalgebra/matrix_mod.F
98!|| vector_mod ../common_source/linearalgebra/vector_mod.F
99!||====================================================================
100 function get_dim(this)
101C-----------------------------------------------
102C I m p l i c i t T y p e s
103C-----------------------------------------------
104#include "implicit_f.inc"
105 class(t_cfs_matrix), intent(in) :: this
106 integer :: get_dim
107 get_dim = this%dim
108 end function get_dim
109
110! *************** !
111! Allocate arrays !
112! *************** !
113
114!||====================================================================
115!|| matrix_create ../common_source/linearalgebra/matrix_mod.F
116!||====================================================================
117 subroutine matrix_create(this, nn)
118C-----------------------------------------------
119C I m p l i c i t T y p e s
120C-----------------------------------------------
121#include "implicit_f.inc"
122 class(t_cfs_matrix), intent(inout) :: this
123 integer, intent(in) :: nn
124 this%dim = nn
125 allocate(this%irow(nn), this%jcol(nn), this%val(nn))
126 end subroutine matrix_create
127
128! ********************* !
129! Free allocated memory !
130! ********************* !
131
132!||====================================================================
133!|| matrix_destroy ../common_source/linearalgebra/matrix_mod.F
134!||====================================================================
135 subroutine matrix_destroy(this)
136C-----------------------------------------------
137C I m p l i c i t T y p e s
138C-----------------------------------------------
139#include "implicit_f.inc"
140 class(t_cfs_matrix), intent(inout) :: this
141 if (allocated(this%irow)) deallocate(this%irow)
142 if (allocated(this%jcol)) deallocate(this%jcol)
143 if (allocated(this%val)) deallocate(this%val)
144 end subroutine matrix_destroy
145
146! ******************* !
147! Pointer association !
148! ******************* !
149
150!||====================================================================
151!|| matrix_associate ../common_source/linearalgebra/matrix_mod.F
152!||====================================================================
153 subroutine matrix_associate(this, ptr_irow, ptr_jcol, ptr_val)
154C-----------------------------------------------
155C I m p l i c i t T y p e s
156C-----------------------------------------------
157#include "implicit_f.inc"
158 class(t_cfs_matrix), intent(inout), target :: this
159 integer, dimension(:), pointer :: ptr_irow, ptr_jcol
160 double precision, dimension(:), pointer :: ptr_val
161 ptr_irow => this%irow
162 ptr_jcol => this%jcol
163 ptr_val => this%val
164 end subroutine matrix_associate
165
166! ********** !
167! End module !
168! ********** !
169
170 END MODULE matrix_mod
subroutine matrix_associate(this, ptr_irow, ptr_jcol, ptr_val)
Definition matrix_mod.F:154
subroutine prod_vec(this, xvec, bvec)
Definition matrix_mod.F:69
subroutine matrix_destroy(this)
Definition matrix_mod.F:136
integer function get_dim(this)
Definition matrix_mod.F:101
subroutine matrix_create(this, nn)
Definition matrix_mod.F:118