OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
sensor_temp0.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!|| sensor_temp0 ../engine/source/tools/sensor/sensor_temp0.F
25!||--- called by ------------------------------------------------------
26!|| resol ../engine/source/engine/resol.F
27!||--- calls -----------------------------------------------------
28!|| sum_6_float ../engine/source/system/parit.F
29!||--- uses -----------------------------------------------------
30!|| groupdef_mod ../common_source/modules/groupdef_mod.F
31!|| sensor_mod ../common_source/modules/sensor_mod.F90
32!|| spmd_mod ../engine/source/mpi/spmd_mod.F90
33!||====================================================================
34 SUBROUTINE sensor_temp0(NSENSOR,SENSOR_TAB,IGRNOD,TEMP,WEIGHT,COMM_SENS17,SENSOR_STRUCT)
35c-----------------------------------------------------------------------
36!$COMMENT
37! SENSOR_TEMP description :
38! computation of min/max or mean temperature
39! SENSOR_TEMP organization :
40! - computation of local min/max/mean temperature
41! - communication between processor and globalization
42! - of min/max/mean
43!$ENDCOMMENT
44c-----------------------------------------------
45C M o d u l e s
46c-----------------------------------------------
47 USE spmd_mod
48 USE groupdef_mod
49 USE sensor_mod
50C-----------------------------------------------
51C I m p l i c i t T y p e s
52C-----------------------------------------------
53#include "implicit_f.inc"
54#include "comlock.inc"
55C-----------------------------------------------
56C C o m m o n B l o c k s
57C-----------------------------------------------
58#include "com04_c.inc"
59#include "com08_c.inc"
60#include "parit_c.inc"
61#include "com01_c.inc"
62C-----------------------------------------------
63C D u m m y A r g u m e n t s
64C-----------------------------------------------
65 INTEGER ,INTENT(IN) :: NSENSOR
66 my_real :: temp(numnod)
67 TYPE(group_) ,DIMENSION(NGRNOD) ,INTENT(IN) :: IGRNOD
68 TYPE (SENSOR_STR_),DIMENSION(NSENSOR), INTENT(INOUT) :: SENSOR_TAB
69 TYPE (sensor_comm),INTENT(INOUT) :: COMM_SENS17
70 TYPE (sensor_type),INTENT(INOUT),DIMENSION(NSENSOR) :: sensor_struct
71 INTEGER, DIMENSION(NUMNOD), INTENT(in) :: WEIGHT
72C----------------------------------------------------------
73C Local Variables
74C----------------------------------------------------------
75 INTEGER :: ISENS,INDEX_SUM6FLOAT
76 INTEGER :: I,IGN,INOD,NNOD,IJK,KJI
77 my_real, DIMENSION(:), ALLOCATABLE :: temp_max,temp_min,temp_avg
78 INTEGER :: INDEX_MIN_MAX,INDEX_MEAN,TOTAL_NUMBER_NOD,DIM_FOR_MEAN
79 my_real, DIMENSION(:), ALLOCATABLE :: temp_node
80 REAL(kind=8), dimension(:), ALLOCATABLE :: sbuff_min,sbuff_max,sbuff_mean
81 REAL(kind=8), dimension(:), ALLOCATABLE :: rbuff_min,rbuff_max,rbuff_mean
82c----------------------------------------------------------
83c SENSOR_TEMP%VAR(1) = TEMP_MAX
84c SENSOR_TEMP%VAR(2) = TEMP_MIN
85c SENSOR_TEMP%VAR(3) = TEMP_AVG
86C=======================================================================
87 ! -----------------
88 ! local arrays for min/max/mean
89 ALLOCATE( temp_max(comm_sens17%NUM_SENS) )
90 ALLOCATE( temp_min(comm_sens17%NUM_SENS) )
91 ALLOCATE( temp_avg(comm_sens17%NUM_SENS) )
92
93 temp_max(1:comm_sens17%NUM_SENS) = zero
94 temp_min(1:comm_sens17%NUM_SENS) = zero
95 temp_avg(1:comm_sens17%NUM_SENS) = zero
96
97 ! --------------------------
98 ! loop over the sensor temp
99 DO ijk=1,comm_sens17%NUM_SENS
100 isens = comm_sens17%ID_SENS(ijk) ! id of sensor temp
101 IF (sensor_tab(isens)%STATUS == 1) cycle ! already activated
102c
103 IF (tt == zero) sensor_tab(isens)%VAR(2) = ep20 ! initialize Temp min
104 ign = sensor_tab(isens)%IPARAM(1)
105c
106 nnod = igrnod(ign)%NENTITY
107 temp_max(ijk) = sensor_tab(isens)%VAR(1)
108 temp_min(ijk) = sensor_tab(isens)%VAR(2)
109 temp_avg(ijk) = zero
110 ALLOCATE( temp_node(nnod) )
111 index_sum6float = 0
112 ! -----------------
113 ! loop over the local nodes
114 ! the computation is done only for main nodes (weight = 1)
115 DO i=1,nnod
116 inod = igrnod(ign)%ENTITY(i)
117 IF (weight(inod)==1) THEN
118 temp_max(ijk) = max(temp_max(ijk), temp(inod))
119 temp_min(ijk) = min(temp_min(ijk), temp(inod))
120 temp_avg(ijk) = temp_avg(ijk) + temp(inod)
121 index_sum6float = index_sum6float + 1
122 temp_node(index_sum6float) = temp(inod)
123 ENDIF
124 ENDDO
125 ! -----------------
126 ! for mean temp sensor : need to use sum_6_float to guarantee the parith/on
127 IF (iparit > 0) THEN
128 CALL sum_6_float(1,index_sum6float,temp_node,sensor_struct(isens)%FBSAV6_SENS(1,1,1),1)
129 ELSE
130 sensor_struct(isens)%FBSAV6_SENS(1,1,1) = temp_avg(ijk)
131 ENDIF
132 ! -----------------
133 DEALLOCATE( temp_node )
134 ENDDO
135 ! --------------------------
136
137 ! --------------------------
138 ! communication for min/max sensor
139 IF (comm_sens17%BUFFER_SIZE_MIN_MAX > 0) THEN
140 ALLOCATE( sbuff_min(comm_sens17%BUFFER_SIZE_MIN_MAX) )
141 ALLOCATE( rbuff_min(comm_sens17%BUFFER_SIZE_MIN_MAX) )
142 ALLOCATE( sbuff_max(comm_sens17%BUFFER_SIZE_MIN_MAX) )
143 ALLOCATE( rbuff_max(comm_sens17%BUFFER_SIZE_MIN_MAX) )
144 index_min_max = 0
145 ! --------------------
146 ! initialize the buffer for mpi comm
147 DO ijk=1,comm_sens17%NUM_SENS
148 isens = comm_sens17%ID_SENS(ijk)
149 index_min_max = index_min_max+ 1
150 sbuff_max(index_min_max) = temp_max(ijk)
151 sbuff_min(index_min_max) =-temp_min(ijk)
152 ENDDO
153 ! --------------------
154 ! reduction with mpi comm
155 IF (nspmd > 1) THEN
156 CALL spmd_allreduce(sbuff_max,rbuff_max,comm_sens17%BUFFER_SIZE_MIN_MAX,spmd_max )
157 CALL spmd_allreduce(sbuff_min,rbuff_min,comm_sens17%BUFFER_SIZE_MIN_MAX,spmd_min)
158
159 ELSE
160 rbuff_max(:) = sbuff_max(:)
161 rbuff_min(:) = sbuff_min(:)
162 ENDIF
163 ! --------------------
164
165 ! --------------------
166 ! save the data in SENSOR structure
167 index_min_max = 0
168 DO ijk=1,comm_sens17%NUM_SENS
169 isens = comm_sens17%ID_SENS(ijk)
170 index_min_max = index_min_max + 1
171 sensor_tab(isens)%VAR(1) = rbuff_max(index_min_max) ! max temp
172 sensor_tab(isens)%VAR(2) =-rbuff_min(index_min_max) ! min temp
173 ENDDO
174 ! --------------------
175 DEALLOCATE( sbuff_max )
176 DEALLOCATE( rbuff_max )
177 DEALLOCATE( sbuff_min )
178 DEALLOCATE( rbuff_min )
179 ENDIF
180 ! --------------------------
181 ! mpi communication for mean temperature
182 IF (comm_sens17%BUFFER_SIZE_MEAN > 0) THEN
183 ALLOCATE( sbuff_mean(comm_sens17%BUFFER_SIZE_MEAN) )
184 ALLOCATE( rbuff_mean(comm_sens17%BUFFER_SIZE_MEAN) )
185 ! parith/on : 6 values per sensor / parith/off : only 1 value
186 IF (iparit > 0) THEN
187 dim_for_mean = 6
188 ELSE
189 dim_for_mean = 1
190 ENDIF
191 ! ----------------
192 ! initialize the buffer
193 index_mean = 0
194 DO ijk=1,comm_sens17%NUM_SENS
195 isens = comm_sens17%ID_SENS(ijk)
196 DO kji=1,dim_for_mean
197 index_mean = index_mean + 1
198 sbuff_mean(index_mean) = sensor_struct(isens)%FBSAV6_SENS(1,kji,1)
199 ENDDO
200 ENDDO
201 ! ----------------
202 ! reduction with mpi comm
203 IF (nspmd > 1) THEN
204 CALL spmd_allreduce(sbuff_mean,rbuff_mean,comm_sens17%BUFFER_SIZE_MEAN,spmd_sum )
205 ELSE
206 rbuff_mean(:) = sbuff_mean(:)
207 ENDIF
208 ! ----------------
209 ! save the Rbuffer in %FBSAV6_SENS
210 index_mean = 0
211 DO ijk=1,comm_sens17%NUM_SENS
212 isens = comm_sens17%ID_SENS(ijk)
213 DO kji=1,dim_for_mean
214 index_mean = index_mean + 1
215 sensor_struct(isens)%FBSAV6_SENS(1,kji,1) = rbuff_mean(index_mean)
216 ENDDO
217 ENDDO
218 ! ----------------
219
220 ! ----------------
221 ! computation of mean : Temp_mean = sum(FBSAV6_SENS[i],i=1,6) for parith/on
222 DO ijk=1,comm_sens17%NUM_SENS
223 isens = comm_sens17%ID_SENS(ijk)
224 IF (iparit > 0) THEN
225 DO kji=2,dim_for_mean
226 sensor_struct(isens)%FBSAV6_SENS(1,1,1) = sensor_struct(isens)%FBSAV6_SENS(1,1,1) +
227 . sensor_struct(isens)%FBSAV6_SENS(1,kji,1)
228 ENDDO
229 ENDIF
230 total_number_nod = sensor_tab(isens)%IPARAM(2)
231 sensor_tab(isens)%VAR(3) = sensor_struct(isens)%FBSAV6_SENS(1,1,1) / total_number_nod
232 DO kji=1,dim_for_mean
233 sensor_struct(isens)%FBSAV6_SENS(1,kji,1) = zero
234 ENDDO
235 ENDDO
236 ! ----------------
237 DEALLOCATE( sbuff_mean )
238 DEALLOCATE( rbuff_mean )
239 ENDIF
240 ! --------------------------
241
242 DEALLOCATE( temp_max )
243 DEALLOCATE( temp_min )
244 DEALLOCATE( temp_avg )
245c----------------------------------------------------------
246 RETURN
247 END SUBROUTINE sensor_temp0
#define my_real
Definition cppsort.cpp:32
#define min(a, b)
Definition macros.h:20
#define max(a, b)
Definition macros.h:21
subroutine sum_6_float(jft, jlt, f, f6, n)
Definition parit.F:64
subroutine sensor_temp0(nsensor, sensor_tab, igrnod, temp, weight, comm_sens17, sensor_struct)