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