OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
gradient_reconstruction2.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!|| gradient_reconstruction2 ../engine/source/ale/alemuscl/gradient_reconstruction2.F
25!||--- called by ------------------------------------------------------
26!|| ale51_gradient_reconstruction2 ../engine/source/ale/alemuscl/ale51_gradient_reconstruction2.F
27!||--- uses -----------------------------------------------------
28!|| ale_connectivity_mod ../common_source/modules/ale/ale_connectivity_mod.F
29!|| alemuscl_mod ../common_source/modules/ale/alemuscl_mod.F
30!|| element_mod ../common_source/modules/elements/element_mod.F90
31!|| segvar_mod ../engine/share/modules/segvar_mod.F
32!||====================================================================
33 SUBROUTINE gradient_reconstruction2(IXQ, X, ALE_CONNECT, NV46, ITRIMAT, SEGVAR)
34C-----------------------------------------------
35C D e s c r i p t i o n
36C This subroutine computes a gradient of the scalar field value in each
37C element:
38C mean square approximation of the gradient in the face related
39C neighborhood of the element
40C-----------------------------------------------
41C M o d u l e s
42C-----------------------------------------------
43 USE alemuscl_mod
44 USE segvar_mod
46 use element_mod , only :nixq
47C-----------------------------------------------
48C I m p l i c i t T y p e s
49C-----------------------------------------------
50#include "implicit_f.inc"
51C-----------------------------------------------
52C C o m m o n B l o c k s
53C-----------------------------------------------
54#include "vect01_c.inc"
55#include "com04_c.inc"
56C-----------------------------------------------
57C D u m m y A r g u m e n t s
58C-----------------------------------------------
59 INTEGER, INTENT(IN) :: NV46
60 INTEGER, INTENT(IN) :: IXQ(NIXQ, NUMELQ)
61 my_real, INTENT(IN) :: x(3, numnod)
62 INTEGER, INTENT(IN) :: ITRIMAT
63 TYPE(t_segvar) :: SEGVAR
64 TYPE(t_ale_connectivity), INTENT(IN) :: ALE_CONNECT
65C-----------------------------------------------
66C L o c a l V a r i a b l e s
67C-----------------------------------------------
68 INTEGER :: I, II, KK, IAD2, LGTH
69 my_real :: yk, zk, yl, zl,yf, zf
70 my_real :: valk, vall
71 my_real :: mat(2, 2), rhs(2), sol(2)
72 INTEGER :: VOIS_ID
73 INTEGER :: FACE_TO_NODE_LOCAL_ID(4, 2), NODEID1, NODEID2
74 my_real :: det, undet
75C-----------------------------------------------
76C S o u r c e L i n e s
77C-----------------------------------------------
78!!! Once for all, associate node local id to a face number
79!!! Face 1
80 face_to_node_local_id(1, 1) = 1 ; face_to_node_local_id(1, 2) = 2
81!!! Face 2
82 face_to_node_local_id(2, 1) = 2 ; face_to_node_local_id(2, 2) = 3
83!!! Face 3
84 face_to_node_local_id(3, 1) = 3 ; face_to_node_local_id(3, 2) = 4
85!!! Face 4
86 face_to_node_local_id(4, 1) = 4 ; face_to_node_local_id(4, 2) = 1
87
88 DO i = lft, llt
89 ii = i + nft
90 !!! Reset mat, rhs
91 mat(1:2, 1:2) = zero ; rhs(1:2) = zero
92 !!! Value of the target function in the element
93 valk = alemuscl_buffer%VOLUME_FRACTION(ii,itrimat)
94 yk = alemuscl_buffer%ELCENTER(ii,2) ;
95 zk = alemuscl_buffer%ELCENTER(ii,3)
96 !!! IXS(2:9, II) : Node global ID
97 iad2 = ale_connect%ee_connect%iad_connect(ii)
98 lgth = ale_connect%ee_connect%iad_connect(ii+1)-iad2
99 DO kk = 1, nv46
100 vois_id = ale_connect%ee_connect%connected(iad2 + kk - 1)
101 IF (vois_id > 0) THEN
102 !!! Value of the target function in the current neighbor
103 vall = alemuscl_buffer%VOLUME_FRACTION(vois_id,itrimat)
104 yl = alemuscl_buffer%ELCENTER(vois_id,2) ;
105 zl = alemuscl_buffer%ELCENTER(vois_id,3) ;
106 ELSE
107 IF(vois_id == 0) THEN
108 vall = valk
109 ELSE
110 !vois_id<0 : means EBCS), -vois_id is seg_id
111 vall = segvar%PHASE_ALPHA(itrimat,-vois_id)
112 ENDIF
113
114 nodeid1 = ixq(1 + face_to_node_local_id(kk, 1), ii)
115 nodeid2 = ixq(1 + face_to_node_local_id(kk, 2), ii)
116
117 yf = half * (x(2, nodeid1) + x(2, nodeid2))
118 zf = half * (x(3, nodeid1) + x(3, nodeid2))
119
120 yl = two * yf - alemuscl_buffer%ELCENTER(ii,2)
121 zl = two * zf - alemuscl_buffer%ELCENTER(ii,3)
122 ENDIF
123
124 !!! Incrementing mat and rhs
125 rhs(1) = rhs(1) + (valk - vall) * (yl - yk)
126 rhs(2) = rhs(2) + (valk - vall) * (zl - zk)
127 mat(1, 1) = mat(1, 1) + (yl - yk) * (yl - yk)
128 mat(1, 2) = mat(1, 2) + (yl - yk) * (zl - zk)
129 mat(2, 1) = mat(2, 1) + (zl - zk) * (yl - yk)
130 mat(2, 2) = mat(2, 2) + (zl - zk) * (zl - zk)
131 ENDDO
132
133 det = mat(1, 1) * mat(2, 2) - mat(2, 1) * mat(1, 2)
134 IF (det == 0) THEN
135 print*, "OUPS"
136 ENDIF
137 undet = one / det
138 sol(1) = undet * (rhs(1) * mat(2,2) - rhs(2) * mat(1,2))
139 sol(2) = undet * (- mat(2,1) * rhs(1) + mat(1, 1) * rhs(2))
140 !!! Solution goes to the gradient
141 alemuscl_buffer%GRAD(ii,2,itrimat) = -sol(1)
142 alemuscl_buffer%GRAD(ii,3,itrimat) = -sol(2)
143 ENDDO ! I = LFT, LLT
144C-----------------------------------------------
145 END SUBROUTINE gradient_reconstruction2
#define my_real
Definition cppsort.cpp:32
subroutine gradient_reconstruction2(ixq, x, ale_connect, nv46, itrimat, segvar)
type(alemuscl_buffer_) alemuscl_buffer