Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
HyodaMatrix.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7// ****************************************************************************
8// * HyodaMatrix.cc (C) 2000-2016 *
9// ****************************************************************************
10#include "arcane/IMesh.h"
11#include "arcane/IApplication.h"
12#include "arcane/IParallelMng.h"
13#include "arcane/IVariableMng.h"
14#include "arcane/utils/ITraceMng.h"
15#include "arcane/IVariableAccessor.h"
16#include "arcane/FactoryService.h"
17#include "arcane/ServiceFinder2.h"
18#include "arcane/SharedVariable.h"
19#include "arcane/CommonVariables.h"
20#include "arcane/utils/ScopedPtr.h"
21#include "arcane/AbstractService.h"
22#include "arcane/VariableCollection.h"
24#include "arcane/utils/PlatformUtils.h"
25#include "arcane/utils/IOnlineDebuggerService.h"
26#include "arcane/ITransferValuesParallelOperation.h"
27
28#ifndef GL_MULTISAMPLE
29#define GL_MULTISAMPLE 0x809D
30#endif
31
32#include "arcane/hyoda/HyodaIceTGlobal.h"
33#include "arcane/hyoda/Hyoda.h"
34#include "arcane/hyoda/HyodaArc.h"
35#include "arcane/hyoda/HyodaTcp.h"
36#include "arcane/hyoda/HyodaIceT.h"
37#include "arcane/hyoda/HyodaMatrix.h"
38#include "arcane/hyoda/HyodaMix.h"
39extern void ppmWrite(const char*, const unsigned char*, int width, int height);
40
41namespace
42{
43 static Arcane::HyodaMatrix* HyodaMatrixCallbackHandle = NULL;
44 void drawGLCallback(void){
45 if (!HyodaMatrixCallbackHandle) return;
46 HyodaMatrixCallbackHandle->drawGL();
47 }
48}
49
50
51/*---------------------------------------------------------------------------*/
52/*---------------------------------------------------------------------------*/
53
54ARCANE_BEGIN_NAMESPACE
55
56/*---------------------------------------------------------------------------*/
57/*---------------------------------------------------------------------------*/
58
59
60/******************************************************************************
61 * HyodaMatrix
62 *****************************************************************************/
63HyodaMatrix::HyodaMatrix(Hyoda *hd,
64 ISubDomain *sd,
65 ITraceMng *tm,
66 unsigned int w,
67 unsigned int h,
68 HyodaTcp *_tcp): TraceAccessor(tm),
69 hyoda(hd),
70 m_sub_domain(sd),
71 icetContext(NULL),
72 icetCommunicator(NULL),
73 osMesaContext(NULL),
74 rank(sd->parallelMng()->commRank()),
75 num_proc(sd->parallelMng()->commSize()),
76 m_screen_width(w),
77 m_screen_height(h),
78 m_image_buffer(NULL),
79 scale(0.),
80 rot_x(0.),
81 rot_y(0.),
82 rot_z(0.),
83 m_tcp(_tcp),
84 m_hyoda_matrix_cpu(0)
85 //m_hyoda_matrix_n(0),
86 //m_hyoda_matrix_i(NULL),
87 //m_hyoda_matrix_j(NULL),
88 //m_hyoda_matrix_val(NULL)
89{
90 debug()<<"\33[35m[HyodaMatrix::HyodaMatrix] New "
91 << ", screen_width="<<m_screen_width
92 << ", screen_height="<<m_screen_height
93 << "\33[m";
94
95 m_hyoda_matrix_n=(int*)calloc(8,sizeof(int));
96 m_hyoda_matrix_i=(int**)calloc(8,sizeof(int*));
97 m_hyoda_matrix_j=(int**)calloc(8,sizeof(int*));
98 m_hyoda_matrix_val=(double**)calloc(8,sizeof(double*));
99
100 m_pov_sxyzip[0]=
101 m_pov_sxyzip[1]=
102 m_pov_sxyzip[2]=
103 m_pov_sxyzip[3]=
104 m_pov_sxyzip[4]=
105 m_pov_sxyzip[5]=0.0;
106
107 /* specify Z, stencil, accum sizes */
108 osMesaContext = OSMesaCreateContextExt(OSMESA_RGBA, 8, 0, 0, NULL);
109 if (!osMesaContext) fatal()<<"\33[35mOSMesaCreateContext failed!\33[m\n";
110 /* Allocate the image buffer */
111 m_image_buffer=malloc(renderSize());
112 if (!m_image_buffer) fatal()<<"\33[35mAlloc image failed!\33[m\n";
113 /* Bind the image to the context and make it current */
114 if (!OSMesaMakeCurrent(osMesaContext,
115 m_image_buffer,
116 GL_UNSIGNED_BYTE,
117 m_screen_width,
118 m_screen_height ))
119 fatal()<<"\33[35mOSMesaMakeCurrent failed!\33[m\n";
120 {
121 int z, s, a;
122 glGetIntegerv(GL_DEPTH_BITS, &z);
123 glGetIntegerv(GL_STENCIL_BITS, &s);
124 glGetIntegerv(GL_ACCUM_RED_BITS, &a);
125 debug()<<"\33[35m[HyodaMatrix] Depth="<<z<<", Stencil="<<s<<", Accum="<<a<<"\33[m";
126 }
127 // IceT system init
128 #warning IceT needs MPI_Init
129 //IceTBitField diag_level = ICET_DIAG_ALL_NODES | ICET_DIAG_WARNINGS;
130 if (sd->parallelMng()->isParallel()){
131 debug() << "\33[35m[HyodaMatrix] isParallel icetCreateMPICommunicator @"
132 << sd->parallelMng()->getMPICommunicator()<< "\33[m";
133 icetCommunicator = icetCreateMPICommunicator(*(MPI_Comm*)sd->parallelMng()->getMPICommunicator());
134 }else{
135 debug()<<"\33[35m[HyodaMatrix] MPI_COMM_SELF icetCreateMPICommunicator\33[m";
136 icetCommunicator = icetCreateMPICommunicator(MPI_COMM_SELF);
137 }
138 icetContext = icetCreateContext(icetCommunicator);
139
140 // iceT GL
141 icetGLInitialize();
142 icetGLDrawCallback(drawGLCallback);
143 HyodaMatrixCallbackHandle=this;
144 icetResetTiles();
145 icetAddTile(0, 0, m_screen_width, m_screen_height, 0);
146 icetStrategy(ICET_STRATEGY_SEQUENTIAL);
147 icetSingleImageStrategy(ICET_SINGLE_IMAGE_STRATEGY_AUTOMATIC);
148 //icetDiagnostics(diag_level);
149 icetSetColorFormat(ICET_IMAGE_COLOR_RGBA_UBYTE);
150 icetSetDepthFormat(ICET_IMAGE_DEPTH_FLOAT);
151 icetCompositeMode(ICET_COMPOSITE_MODE_Z_BUFFER);
152 icetBoundingBoxd(-1.0f, +1.0f, -1.0f, +1.0f, -4.0f, 16.0f);
153 setLeftRightBottomTop();
154 icetDisable(ICET_FLOATING_VIEWPORT);
155 icetEnable(ICET_ORDERED_COMPOSITE);
156 initGL();
157 checkIceTError();
158 debug()<<"\33[35m[HyodaMatrix] checkOglError\33[m";
159 checkOglError();
160 traceMng()->flush();
161 }
162
163
164// ****************************************************************************
165// * setIJVal
166// ****************************************************************************
167void HyodaMatrix::setIJVal(int cpu, int n, int *i, int *j, double *val){
168 m_hyoda_matrix_cpu=math::max(cpu,m_hyoda_matrix_cpu);
169 m_hyoda_matrix_n[cpu]=n;
170 m_hyoda_matrix_i[cpu]=i;
171 m_hyoda_matrix_j[cpu]=j;
172 m_hyoda_matrix_val[cpu]=val;
173 debug()<<"\33[7m[HyodaMatrix::setIJVal] cpu="<<cpu<<",n="<<n
174 <<", m_hyoda_matrix_cpu="<<m_hyoda_matrix_cpu<<"\33[m";
175}
176
177
178/******************************************************************************
179 * Initialisation de la base ortho qui servira à glOrtho: left, right, bottom, top
180 *****************************************************************************/
181void HyodaMatrix::setLeftRightBottomTop(){
182 lrbtnf[0]=lrbtnf[1]=lrbtnf[2]=lrbtnf[3]=0.0;
183 lrbtnf[4]=-4.0; // On commence avec un Z-min par défaut pour le 2D
184 lrbtnf[5]=+16.0; // Idem avec le Z-max, pour le 2D par défaut
185
186 int min_i=+123456789;
187 int max_i=-123456789;
188 int min_j=+123456789;
189 int max_j=-123456789;
190
191 for(int cpu=0;cpu<=m_hyoda_matrix_cpu;cpu+=1){
192 debug()<<"\33[7m[HyodaMatrix::setLeftRightBottomTop] cpu="<<cpu<<"/"<<m_hyoda_matrix_cpu
193 <<", m_hyoda_matrix_n[cpu]="<<m_hyoda_matrix_n[cpu]<<"\33[m";
194 for(int k=0;k<m_hyoda_matrix_n[cpu];k+=1){
195 min_i = math::min(min_i,m_hyoda_matrix_i[cpu][k]);
196 max_i = math::max(max_i,m_hyoda_matrix_i[cpu][k]);
197 min_j = math::min(min_j,m_hyoda_matrix_j[cpu][k]);
198 max_j = math::max(max_j,m_hyoda_matrix_j[cpu][k]);
199 }
200 }
201 lrbtnf[0]= min_j; // left
202 lrbtnf[1]= max_j; // right
203 lrbtnf[2]= min_i; // bottom
204 lrbtnf[3]= max_j; // top
205 debug()<<"\33[35m[HyodaMatrix::setLeftRightBottomTop] min_i="<< min_i<<"\33[m";
206 debug()<<"\33[35m[HyodaMatrix::setLeftRightBottomTop] max_i="<< max_i<<"\33[m";
207 debug()<<"\33[35m[HyodaMatrix::setLeftRightBottomTop] min_j="<< min_j<<"\33[m";
208 debug()<<"\33[35m[HyodaMatrix::setLeftRightBottomTop] max_j="<< max_j<<"\33[m";
209
210 UniqueArray<Real> rdcMin(3);
211 UniqueArray<Real> rdcMax(3);
212 rdcMin[0]=lrbtnf[0]; // left
213 rdcMin[1]=lrbtnf[2]; // bottom
214 rdcMin[2]=lrbtnf[4]; // near
215 m_sub_domain->parallelMng()->reduce(Parallel::ReduceMin,rdcMin.view());
216 rdcMax[0]=lrbtnf[1]; // right
217 rdcMax[1]=lrbtnf[3]; // top
218 rdcMax[2]=lrbtnf[5]; // far
219 m_sub_domain->parallelMng()->reduce(Parallel::ReduceMax,rdcMax.view());
220 lrbtnf[0]=rdcMin[0]; // left
221 lrbtnf[1]=rdcMax[0]; // right
222 lrbtnf[2]=rdcMin[1]; // bottom
223 lrbtnf[3]=rdcMax[1]; // top
224 lrbtnf[4]=rdcMin[2]; // near
225 lrbtnf[5]=rdcMax[2]; // far
226 debug()<<"\33[35m[HyodaMatrix::setLeftRightBottomTop] left =" << lrbtnf[0]<<"\33[m";
227 debug()<<"\33[35m[HyodaMatrix::setLeftRightBottomTop] right =" << lrbtnf[1]<<"\33[m";
228 debug()<<"\33[35m[HyodaMatrix::setLeftRightBottomTop] bottom =" << lrbtnf[2]<<"\33[m";
229 debug()<<"\33[35m[HyodaMatrix::setLeftRightBottomTop] top =" << lrbtnf[3]<<"\33[m";
230 debug()<<"\33[35m[HyodaMatrix::setLeftRightBottomTop] near =" << lrbtnf[4]<<"\33[m";
231 debug()<<"\33[35m[HyodaMatrix::setLeftRightBottomTop] far =" << lrbtnf[5]<<"\33[m";
232}
233
234
235/******************************************************************************
236 * sxyz
237 *****************************************************************************/
238void HyodaMatrix::sxyzip(double *pov){
239 scale=pov[0];
240 rot_x=pov[1];
241 rot_y=pov[2];
242 rot_z=pov[3];
243 debug()<<"\33[35m[HyodaMatrix::sxyzi] scale="<<scale<<
244 ", rot_x="<<rot_x<<", rot_y="<<rot_y<<", rot_z="<<rot_z<<"\33[m";
245}
246
247
248/******************************************************************************
249 * imgSize
250 *****************************************************************************/
251int HyodaMatrix::renderSize(void){
252 return m_screen_width*m_screen_height*4*sizeof(GLubyte);
253}
254
255
256/******************************************************************************
257 * ~HyodaMatrix
258 *****************************************************************************/
259HyodaMatrix::~HyodaMatrix(){
260 free(m_image_buffer);
261 checkOglError();
262 checkIceTError();
263 debug()<<"\33[35m~HyodaMatrix"<<"\33[m";
264 icetDestroyContext(icetContext);
265 OSMesaDestroyContext(osMesaContext);
266}
267
268
269
270/******************************************************************************
271 * render
272 *****************************************************************************/
273void HyodaMatrix::render(void){
274 debug()<<"\33[35m[HyodaMatrix] render\33[m";
275 icetGLDrawCallback(drawGLCallback);
276 // Tout le monde participe au rendering
277 // Mais on blinde cette section contre les erreurs FPU qu'iceT a tendance à jeter
278 platform::enableFloatingException(false);
279 IceTImage image=icetGLDrawFrame();
280 platform::enableFloatingException(true);
281 checkOglError();
282 checkIceTError();
283
284 m_sub_domain->parallelMng()->barrier();
285
286 // Seul le CPU 0 possède l'image résultante pour l'instant
287 if (rank==0){
288 // Now fetch image's address
289 unsigned char* imgAddress=icetImageGetColorub(image);
290
291 // Si la variable d'environement ARCANE_HYODA_MATRIX_PPM est settée, on dump l'image dans un fichier
292 if (!platform::getEnvironmentVariable("ARCANE_HYODA_MATRIX_PPM").null()){
293 char filename[3883];
294 snprintf(filename,3883,"/tmp/HyODA_Mtx_%04d.ppm",
295 m_sub_domain->commonVariables().globalIteration());
296 debug()<<"\33[33m[HyodaIceT::render] \33[33mARCANE_HYODA_MATRIX_PPM\33[m "
297 << icetImageGetWidth(image) << "x" << icetImageGetHeight(image)
298 << " image " << filename;
299 ppmWrite(filename, imgAddress,(int)m_screen_width, (int)m_screen_height);
300 }
301
302 debug()<<"\33[35m[HyodaMatrix::render] sending header packet for image!\33[m";
303 char icePacketHeader[8];
304 // On écrit le 'MatrixIceTHeader' QHyodaTcpSwitch
305 *(unsigned int*)&icePacketHeader[0]=0x78f78f67ul;
306 // On pousse la taille du paquet
307 *(unsigned int*)&icePacketHeader[4]=8;
308 m_tcp->send(icePacketHeader,8);
309 m_tcp->waitForAcknowledgment();
310 debug()<<"\33[35m[HyodaMatrix::render] sending image packet!, renderSize="<<renderSize()<<"\33[m";
311 m_tcp->send((void*)imgAddress, renderSize());
312 m_tcp->waitForAcknowledgment();
313 debug()<<"\33[35m[HyodaMatrix::render] Waiting for POV answer!\33[m";
314 m_tcp->recvPov(m_pov_sxyzip);
315 }
316
317 m_sub_domain->parallelMng()->barrier();
318
319 // On dépiote la réponse
320 UniqueArray<Real> pov_to_broadcast(0);
321 pov_to_broadcast.add(m_pov_sxyzip[0]);
322 pov_to_broadcast.add(m_pov_sxyzip[1]);
323 pov_to_broadcast.add(m_pov_sxyzip[2]);
324 pov_to_broadcast.add(m_pov_sxyzip[3]);
325 pov_to_broadcast.add(m_pov_sxyzip[4]);
326 pov_to_broadcast.add(m_pov_sxyzip[5]);
327 debug()<<"\33[35m[Hyoda::hook] broadcasting pov..."<<"\33[m";
328 m_sub_domain->parallelMng()->broadcast(pov_to_broadcast.view(),0);
329 m_pov_sxyzip[0]=pov_to_broadcast[0];
330 m_pov_sxyzip[1]=pov_to_broadcast[1];
331 m_pov_sxyzip[2]=pov_to_broadcast[2];
332 m_pov_sxyzip[3]=pov_to_broadcast[3];
333 m_pov_sxyzip[4]=pov_to_broadcast[4];
334 m_pov_sxyzip[5]=pov_to_broadcast[5];
335 sxyzip(m_pov_sxyzip);
336 debug()<<"\33[35m[Hyoda::hook] pov done"<<"\33[m";
337 debug()<<"\33[35m[HyodaMatrix::render] sxyzip:"
338 << "scale=" << m_pov_sxyzip[0]
339 << ", x=" << m_pov_sxyzip[1]
340 << ", y=" << m_pov_sxyzip[2]
341 << ", z=" << m_pov_sxyzip[3]
342 << ", i=" << m_pov_sxyzip[4]
343 << ", p=" << m_pov_sxyzip[5]
344 << "\33[m";
345}
346
347
348/******************************************************************************
349 * GL init
350 *****************************************************************************/
351void HyodaMatrix::initGL(void){
352 debug()<<"\33[35m[HyodaMatrix] initGL in"<<"\33[m";
353 checkOglError();
354 glViewport(0, 0, m_screen_width,m_screen_height);
355 glEnable(GL_DITHER);
356 glEnable(GL_DEPTH_TEST);
357 glEnable(GL_MULTISAMPLE);
358 glEnable(GL_POINT_SMOOTH);
359 //glEnable(GL_POLYGON_SMOOTH);
360 //glEnable(GL_LINE_SMOOTH);
361 glPointSize(1.0);
362 glLineWidth(1.0);
363 glDepthFunc(GL_LESS);
364 glShadeModel(GL_SMOOTH);
365 glShadeModel(GL_FLAT);
366 glLineStipple(1, 0x0101);
367 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
368 glClearDepth(1.0);
369 glColor3f(0.0f, 0.0f, 0.0f); // Black points
370 glClearColor(0.0, 0.0, 0.0, 0.0); // Black background
371 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
372 debug()<<"\33[35m[HyodaMatrix] initGL out"<<"\33[m";
373 checkOglError();
374}
375
376
377/******************************************************************************
378 * drawGLCallback
379 *****************************************************************************/
380void HyodaMatrix::drawGL(void){
381 debug()<<"\33[35m[HyodaMatrix] drawGL"<<"\33[m";
382 glPushMatrix();
383 glShadeModel(GL_SMOOTH);
384 glMatrixMode(GL_PROJECTION);
385 glLoadIdentity();
386
387 setLeftRightBottomTop();
388
389 Real length=lrbtnf[1]-lrbtnf[0];
390 Real height=lrbtnf[3]-lrbtnf[2];
391 //glOrtho(lrbtnf[0], lrbtnf[1], lrbtnf[2], lrbtnf[3], lrbtnf[4], lrbtnf[5]);
392 glOrtho(lrbtnf[0]-length/4., lrbtnf[1]+length/4., lrbtnf[2]-height/4., lrbtnf[3]+height/4., lrbtnf[4], lrbtnf[5]);
393 //glFrustum(lrbtnf[0], lrbtnf[1], lrbtnf[2], lrbtnf[3], lrbtnf[4], lrbtnf[5]);
394 //glTranslatef(0.0f, 0.0f, -4.0f);
395 // et on applique les transformation venant de l'IHM
396 glRotatef(rot_x, 1.0f, 0.0f, 0.0f);
397 glRotatef(rot_y, 0.0f, 1.0f, 0.0f);
398 glRotatef(rot_z, 0.0f, 0.0f, 1.0f);
399 glScalef(scale, scale, scale);
400 glMatrixMode(GL_MODELVIEW);
401 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
402 drawMatrix();
403 glPopMatrix();
404 glFlush();
405 glFinish();
406 checkOglError();
407}
408
409// ****************************************************************************
410// * OpenGL tools
411// ****************************************************************************
412static inline void glVertex(Real3 p){
413 glVertex2d(p.x,p.y);
414}
415
416inline static int glQuadFull(Real3 p0, Real3 p1, Real3 p2, Real3 p3, Real3 rgb){
417 glColor3d(rgb.x, rgb.y, rgb.z);
418 //glBegin(GL_LINES);
419 glVertex(p0);
420 glVertex(p1);
421 glVertex(p1);
422 glVertex(p2);
423 glVertex(p2);
424 glVertex(p3);
425 glVertex(p3);
426 glVertex(p0);
427 glEnd();
428 glBegin(GL_POLYGON);
429 glVertex(p0);
430 glVertex(p1);
431 glVertex(p2);
432 glVertex(p3);
433 glEnd();
434 return 0;
435}
436
437/******************************************************************************
438 * drawArcaneMesh
439 *****************************************************************************/
440void HyodaMatrix::drawMatrix(void){
441 debug()<<"\33[35m[HyodaMatrix] drawMatrix"<<"\33[m";
442 Real3 rgb;
443 Real imin=+HUGE_VAL; Real imax=-HUGE_VAL;
444 Real jmin=+HUGE_VAL; Real jmax=-HUGE_VAL;
445 Real cmin=+HUGE_VAL; Real cmax=-HUGE_VAL;
446 int n=0;
447 for(int cpu=0;cpu<=m_hyoda_matrix_cpu;cpu+=1){
448 iceRowMinMax(cpu,imin,imax);
449 iceColMinMax(cpu,jmin,jmax);
450 iceValMinMax(cpu,cmin,cmax);
451 n+=m_hyoda_matrix_n[cpu];
452 }
453 debug()<<"\33[35m[HyodaMatrix] imin="<<imin<<", imax="<<imax<<"\33[m";
454 debug()<<"\33[35m[HyodaMatrix] jmin="<<jmin<<", jmax="<<jmax<<"\33[m";
455 debug()<<"\33[35m[HyodaMatrix] cmin="<<cmin<<", cmax="<<cmax<<"\33[m";
456 debug()<<"\33[35m[HyodaMatrix] n="<<n<<"\33[m";
457 for(int cpu=0;cpu<=m_hyoda_matrix_cpu;cpu+=1){
458 for(int k=0;k<m_hyoda_matrix_n[cpu];k+=1){
459 const double value=m_hyoda_matrix_j[cpu][k];
460 const Real3 p(imax-m_hyoda_matrix_i[cpu][k],m_hyoda_matrix_j[cpu][k],0);
461 const Real3 n0=p+Real3(-0.5,-0.5,0.0);
462 const Real3 n1=p+Real3(+0.5,-0.5,0.0);
463 const Real3 n2=p+Real3(+0.5,+0.5,0.0);
464 const Real3 n3=p+Real3(-0.5,+0.5,0.0);
465 glBegin(GL_LINES);
466 setColor(cmin,cmax,value,rgb);
467 glQuadFull(n0,n1,n2,n3,rgb);
468 }
469 checkOglError();
470 }
471 checkOglError();
472}
473
474
475// ****************************************************************************
476// * iceColorMinMax
477// ****************************************************************************
478void HyodaMatrix::iceValMinMax(int cpu,Real &min, Real &max){
479 for(int k=0;k<m_hyoda_matrix_n[cpu];k+=1){
480 const Real val=m_hyoda_matrix_j[cpu][k];
481 min = math::min(min,val);
482 max = math::max(max,val);
483 }
484 //min=m_sub_domain->parallelMng()->reduce(Parallel::ReduceMin, min);
485 //max=m_sub_domain->parallelMng()->reduce(Parallel::ReduceMax, max);
486 debug()<<"\33[35m[iceValMinMax] cpu="<<cpu<<", min="<<min<<", max="<<max<<"\33[m";
487}
488
489
490void HyodaMatrix::iceRowMinMax(int cpu, Real &min, Real &max){
491 for(int k=0;k<m_hyoda_matrix_n[cpu];k+=1){
492 const Real val=m_hyoda_matrix_i[cpu][k];
493 min = math::min(min,val);
494 max = math::max(max,val);
495 }
496 //min=m_sub_domain->parallelMng()->reduce(Parallel::ReduceMin, min);
497 //max=m_sub_domain->parallelMng()->reduce(Parallel::ReduceMax, max);
498 debug()<<"\33[35m[iceRowMinMax] cpu="<<cpu<<", min="<<min<<", max="<<max<<"\33[m";
499}
500
501void HyodaMatrix::iceColMinMax(int cpu, Real &min, Real &max){
502 for(int k=0;k<m_hyoda_matrix_n[cpu];k+=1){
503 const Real val=m_hyoda_matrix_j[cpu][k];
504 min = math::min(min,val);
505 max = math::max(max,val);
506 }
507 //min=m_sub_domain->parallelMng()->reduce(Parallel::ReduceMin, min);
508 //max=m_sub_domain->parallelMng()->reduce(Parallel::ReduceMax, max);
509 debug()<<"\33[35m[iceColMinMax] cpu="<<cpu<<", min="<<min<<", max="<<max<<"\33[m";
510}
511
512
513
514/******************************************************************************
515 * color
516 *****************************************************************************/
517void HyodaMatrix::
518setColor(double min, double max, double v, Real3 &rgb)
519{
520 ARCANE_ASSERT(min<=max,("setColor min<=max"));
521 if (min==max){
522 min=0.0;
523 max=1.0;
524 }
525 double mid=max-min;
526 ARCANE_ASSERT(mid!=0.,("setColor mid!=0."));
527 rgb.x=rgb.y=rgb.z=1.0;
528 if (v<min) v=min;
529 if (v>max) v=max;
530 if (v<(min+0.25*mid)){
531 rgb.x=0.;
532 rgb.y=4.*(v-min)/mid;
533 }else if (v<(min+0.5*mid)){
534 rgb.x=0.;
535 rgb.z=1.+4*(min+0.25*mid-v)/mid;
536 }else if (v<(min+0.75*mid)){
537 rgb.x=4*(v-min-0.5*mid)/mid;
538 rgb.z=0.;
539 }else{
540 rgb.y=1.+4*(min+0.75*mid-v)/mid;
541 rgb.z=0.;
542 }
543}
544
545
546/******************************************************************************
547 * checkIceTError
548 *****************************************************************************/
549void HyodaMatrix::checkIceTError(void){
550#define CASE_ERROR(ename) case ename: debug() << "## IceT status = \33[35m" << #ename << "\33[m"; break;
551 switch (icetGetError()) {
552 case(ICET_NO_ERROR): break;
553 CASE_ERROR(ICET_SANITY_CHECK_FAIL);
554 CASE_ERROR(ICET_INVALID_ENUM);
555 CASE_ERROR(ICET_BAD_CAST);
556 CASE_ERROR(ICET_OUT_OF_MEMORY);
557 CASE_ERROR(ICET_INVALID_OPERATION);
558 CASE_ERROR(ICET_INVALID_VALUE);
559 default:debug()<<"\33[35m## UNKNOWN ICET ERROR CODE!!!!!\33[m";
560 }
561#undef CASE_ERROR
562}
563
564
565/******************************************************************************
566 * checkMatrixError
567 *****************************************************************************/
568void HyodaMatrix::checkOglError(void){
569#define CASE_ERROR(ename) case ename: debug() << "\33[35m## OpenGL status = " << #ename << "\33[m"; break;
570 switch (glGetError()) {
571 case(GL_NO_ERROR):break;
572 CASE_ERROR(GL_INVALID_ENUM);
573 CASE_ERROR(GL_INVALID_VALUE);
574 CASE_ERROR(GL_INVALID_OPERATION);
575 CASE_ERROR(GL_STACK_OVERFLOW);
576 CASE_ERROR(GL_STACK_UNDERFLOW);
577 CASE_ERROR(GL_OUT_OF_MEMORY);
578#ifdef GL_TABLE_TOO_LARGE
579 CASE_ERROR(GL_TABLE_TOO_LARGE);
580#endif
581 default:debug()<<"\33[35m## UNKNOWN GL ERROR CODE!!!!!\33[m";
582 }
583#undef CASE_ERROR
584}
585
586
587/*---------------------------------------------------------------------------*/
588/*---------------------------------------------------------------------------*/
589
590ARCANE_END_NAMESPACE
591
592/*---------------------------------------------------------------------------*/
593/*---------------------------------------------------------------------------*/
594
595
Fichier de configuration d'Arcane.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
T max(const T &a, const T &b, const T &c)
Retourne le maximum de trois éléments.
Definition MathUtils.h:392
ARCCORE_HOST_DEVICE Real2 min(Real2 a, Real2 b)
Retourne le minimum de deux Real2.
Definition MathUtils.h:336