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