Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
KdiPostProcessor.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 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/* KdiPostProcessor.cc (C) 2000-2025 */
9/* */
10/* Post-processing with the KDI tool. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/Collection.h"
15#include "arcane/utils/Enumerator.h"
16#include "arcane/utils/Iostream.h"
17#include "arcane/utils/ScopedPtr.h"
18#include "arcane/utils/StringBuilder.h"
19#include "arcane/utils/CheckedConvert.h"
20#include "arcane/utils/JSONWriter.h"
21#include "arcane/utils/IOException.h"
22
23#include "arcane/core/PostProcessorWriterBase.h"
24#include "arcane/core/Directory.h"
25#include "arcane/core/FactoryService.h"
26#include "arcane/core/IDataWriter.h"
27#include "arcane/core/IData.h"
28#include "arcane/core/IItemFamily.h"
29#include "arcane/core/VariableCollection.h"
30#include "arcane/core/IParallelMng.h"
31#include "arcane/core/IMesh.h"
32
33#include "arcane/std/KdiPostProcessor_axl.h"
34
35#include "arcane/core/internal/VtkCellTypes.h"
36#include "arcane/std/internal/Kdi.h"
37
38// Timers. Not active for now
39#define tic(a)
40#define tac(a)
41
42// To function, KDI must be installed and the following variables
43// must be set
44// export PYTHONPATH=/path/to/kdi/pykdi/src
45// export KDI_DICTIONARY_PATH=/path/to/kdi/pykdi/src/pykdi/dictionary
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
49
50namespace Arcane
51{
52
53/*---------------------------------------------------------------------------*/
54/*---------------------------------------------------------------------------*/
55
56class KdiDataWriter
57: public TraceAccessor
58, public IDataWriter
59{
60 public:
61
62 KdiDataWriter(IMesh* mesh, ItemGroupCollection groups);
63
64 public:
65
66 void beginWrite(const VariableCollection& vars) override;
67 void endWrite() override;
68 void setMetaData(const String& meta_data) override;
69 void write(IVariable* var, IData* data) override;
70
71 public:
72
73 void setTimes(RealConstArrayView times) { m_times = times; }
74 void setDirectoryName(const String& dir_name) { m_directory_name = dir_name; }
75
76 private:
77
78 IMesh* m_mesh;
79
82
85
88
91
92 bool m_is_master_io = false;
93
97 KDIBase* m_kdi_base = nullptr;
100 KDIChunk* m_kdi_chunk_partless = nullptr;
101
102 private:
103
104 template <typename DataType> PyArrayObject*
105 _numpyDataSet1D(Span<const DataType> values);
106 template <typename DataType> PyArrayObject*
107 _numpyDataSet1D(IData* data);
108 template <typename DataType> PyArrayObject*
109 _numpyDataSet2D(Span2<const DataType> values);
110
111 PyArrayObject* _numpyDataSetReal3D(IData* data);
112 PyArrayObject* _numpyDataSetReal2D(IData* data);
113
114 String _getFileNameForTimeIndex(Int32 index)
115 {
116 StringBuilder sb(m_mesh->name());
117 if (index >= 0) {
118 sb += "_";
119 sb += index;
120 }
121 sb += ".hdf";
122 return sb.toString();
123 }
124};
125
126/*---------------------------------------------------------------------------*/
127/*---------------------------------------------------------------------------*/
128
129KdiDataWriter::
130KdiDataWriter(IMesh* mesh, ItemGroupCollection groups)
131: TraceAccessor(mesh->traceMng())
132, m_mesh(mesh)
133, m_groups(groups)
134{
135 static bool python_initialize = false;
136 if (!python_initialize) {
137 // https://stackoverflow.com/questions/52828873/how-does-import-array-in-numpy-c-api-work
138 // auto start = chrono::steady_clock::now();
139 // OLD clock_t begin = clock();
140 tic("initialize");
141 Py_Initialize();
142 import_array1();
143 // auto end = chrono::steady_clock::now();
144 // cout << "Elapsed time in milliseconds: "
145 // << chrono::duration_cast<chrono::milliseconds>(end - start).count()
146 // << " ms" << endl;
147 // OLD clock_t end = clock();
148 // OLD calculates the elapsed time by finding the difference (end - begin) and
149 // OLD dividing the difference by CLOCKS_PER_SEC to convert to seconds
150 // OLD double time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
151 // OLD printf("The elapsed time is %f seconds", time_spent);
152 tac("initialize");
153
154 python_initialize = true;
155 }
156}
157
158/*---------------------------------------------------------------------------*/
159/*---------------------------------------------------------------------------*/
160
161void KdiDataWriter::
162beginWrite(const VariableCollection& vars)
163{
164 tic("beginWrite");
165
166 ARCANE_UNUSED(vars);
167
168 IParallelMng* pm = m_mesh->parallelMng();
169 const Int32 nb_rank = pm->commSize();
170
171 m_is_master_io = true;
172
173 Int32 time_index = m_times.size();
174 const bool is_first_call = (time_index < 2);
175 if (is_first_call)
176 pwarning() << "The implementation in 'Kdi' format is experimental";
177
178 String filename = _getFileNameForTimeIndex(time_index);
179
180 Directory dir(m_directory_name);
181
182 m_full_filename = dir.file(filename);
183 info(4) << "KdiDataWriter::beginWrite() file=" << m_full_filename;
184
185 if (time_index <= 1) {
186 if (m_is_master_io) {
187 dir.createDirectory();
188 }
189 }
190
191 info() << "KDI begin";
192 info() << "KDI createBase full_filename=" << m_full_filename;
193 std::string full_filename = m_full_filename.localstr();
194 m_kdi_full_filename = full_filename.substr(0, full_filename.find_last_of("/\\") + 1) + "Mesh_kdi";
195 info() << "KDI createBase kdi_full_filename=" << m_kdi_full_filename;
196 if (!m_kdi_base) {
197 info() << "KDI createBase m_kdi_base=nullptr";
198 // indicates if a file is readable (and thus if it exists)
199 std::string filename = m_kdi_full_filename + ".json";
200 ifstream fichier(filename.c_str());
201 if (!fichier.fail()) {
202 info() << "KDI createBase " << m_kdi_full_filename << " exist";
203 tic("loadVTKHDF");
204 m_kdi_base = loadVTKHDF(m_kdi_full_filename);
205 tac("loadVTKHDF");
206 info() << "KDI createBase in file";
207 }
208 else {
209 if (nb_rank != 1) {
210 ARCANE_FATAL("Today, not support parallel execution!");
211 }
212 info() << "KDI createBase " << m_kdi_full_filename << " not exist";
213 tic("createBase");
214 m_kdi_base = createBase(nb_rank, true); // true : activates traces
215 tac("createBase");
216 info() << "KDI createBase in memory";
217 }
218 }
219 else {
220 info() << "KDI already createBase";
221 }
222 info() << "KDI update";
223 m_kdi_base->update("UnstructuredGrid", "/mymesh");
224 info() << "KDI chunk";
225 double float_step = m_times[time_index - 1];
226 Int32 my_rank = pm->commRank();
227 info() << "KDI chunk " << float_step << " " << my_rank;
228 m_kdi_chunk = m_kdi_base->chunk(float_step, my_rank);
229 m_kdi_chunk_partless = m_kdi_base->chunk(float_step);
230
231 CellGroup all_cells = m_mesh->allCells();
232 NodeGroup all_nodes = m_mesh->allNodes();
233
234 const Int32 nb_cell = all_cells.size();
235 const Int32 nb_node = all_nodes.size();
236
237 Int32 total_nb_connected_node = 0;
238 {
239 ENUMERATE_CELL (icell, all_cells) {
240 Cell cell = *icell;
241 total_nb_connected_node += cell.nodeIds().size();
242 }
243 }
244
245 // For connectivity, the array size is equal
246 // to the number of cells plus 1.
247 UniqueArray<Int64> cells_connectivity(total_nb_connected_node);
248 UniqueArray<Int64> cells_offset(nb_cell + 1);
249 UniqueArray<unsigned char> cells_ghost_type(nb_cell);
250 UniqueArray<unsigned char> cells_type(nb_cell);
251 UniqueArray<Int64> cells_uid(nb_cell);
252 cells_offset[0] = 0;
253 {
254 Int32 connected_node_index = 0;
255 ENUMERATE_CELL (icell, all_cells) {
256 Int32 index = icell.index();
257 Cell cell = *icell;
258
259 cells_uid[index] = icell->uniqueId();
260
261 Byte ghost_type = 0;
262 bool is_ghost = !cell.isOwn();
263 if (is_ghost)
264 ghost_type = VtkUtils::CellGhostTypes::DUPLICATECELL;
265 cells_ghost_type[index] = ghost_type;
266
267 unsigned char vtk_type = VtkUtils::arcaneToVtkCellType(cell.type());
268 cells_type[index] = vtk_type;
269 for (NodeLocalId node : cell.nodeIds()) {
270 cells_connectivity[connected_node_index] = node;
271 ++connected_node_index;
272 }
273 cells_offset[index + 1] = connected_node_index;
274 }
275 }
276
277 {
278 info() << "KDI chunk set connectivity begin";
279 info() << "KDI DTYPE C++ connectivity";
280 PyArrayObject* parray = _numpyDataSet1D<Int64>(cells_connectivity);
281 m_kdi_chunk->set("/mymesh/cells/connectivity", parray);
282 info() << "KDI chunk set connectivity end";
283 }
284 {
285 info() << "KDI chunk set cells types begin";
286 // PyArrayObject* parray = _numpyDataSet1D<unsigned char>(cells_type);
287 info() << "KDI DTYPE C++ cells types";
288 PyArrayObject* parray = _numpyDataSet1D<unsigned char>(cells_type);
289 m_kdi_chunk->set("/mymesh/cells/types", parray);
290 info() << "KDI chunk set cells types end";
291 }
292
293 // Saves the unique IDs, types, and coordinates of the nodes.
294 {
295 UniqueArray<Int64> nodes_uid(nb_node);
296 UniqueArray<unsigned char> nodes_ghost_type(nb_node);
297 VariableNodeReal3& nodes_coordinates(m_mesh->nodesCoordinates());
298 UniqueArray2<Real> points;
299 points.resize(nb_node, 3);
300 ENUMERATE_NODE (inode, all_nodes) {
301 Int32 index = inode.index();
302 Node node = *inode;
303
304 nodes_uid[index] = inode->uniqueId();
305
306 Byte ghost_type = 0;
307 bool is_ghost = !node.isOwn();
308 if (is_ghost)
309 ghost_type = VtkUtils::PointGhostTypes::DUPLICATEPOINT;
310 nodes_ghost_type[index] = ghost_type;
311
312 Real3 pos = nodes_coordinates[inode];
313 points[index][0] = pos.x;
314 points[index][1] = pos.y;
315 points[index][2] = pos.z;
316 }
317
318 {
319 info() << "KDI chunk set connectivity begin";
320 PyArrayObject* parray = _numpyDataSet2D<Real>(points);
321 m_kdi_chunk->set("/mymesh/points/cartesianCoordinates", parray);
322 info() << "KDI chunk set connectivity end";
323 }
324 // Fields points
325 {
326 const std::string namefield = m_kdi_base->update_fields("/mymesh/points/fields", "GlobalNodeId");
327 assert(namefield == "/mymesh/points/fields/GlobalNodeId");
328 info() << "KDI chunk set GlobalNodeId begin";
329 info() << "KDI DTYPE C++ GlobalNodeId";
330 PyArrayObject* parray = _numpyDataSet1D<Int64>(nodes_uid);
331 m_kdi_chunk->set(namefield, parray);
332 info() << "KDI chunk set GlobalNodeId end";
333 }
334 {
335 const std::string namefield = m_kdi_base->update_fields("/mymesh/points/fields", "vtkGhostType");
336 assert(namefield == "/mymesh/points/fields/vtkGhostType");
337 info() << "KDI chunk set node vtkGhostType begin";
338 info() << "KDI DTYPE C++ node vtkGhostType";
339 PyArrayObject* parray = _numpyDataSet1D<unsigned char>(nodes_ghost_type);
340 m_kdi_chunk->set(namefield, parray);
341 info() << "KDI chunk set node vtkGhostType end";
342 }
343 }
344
345 // Fields cells
346 {
347 const std::string namefield = m_kdi_base->update_fields("/mymesh/cells/fields", "GlobalCellId");
348 assert(namefield == "/mymesh/cells/fields/GlobalCellId");
349 info() << "KDI chunk set GlobalCellId begin";
350 info() << "KDI DTYPE C++ cell GlobalCellId";
351 PyArrayObject* parray = _numpyDataSet1D<Int64>(cells_uid);
352 m_kdi_chunk->set(namefield, parray);
353 info() << "KDI chunk set GlobalCellId end";
354 }
355 {
356 const std::string namefield = m_kdi_base->update_fields("/mymesh/cells/fields", "vtkGhostType");
357 assert(namefield == "/mymesh/cells/fields/vtkGhostType");
358 info() << "KDI chunk set cell vtkGhostType begin";
359 info() << "KDI DTYPE C++ cell vtkGhostType";
360 PyArrayObject* parray = _numpyDataSet1D<unsigned char>(cells_ghost_type);
361 m_kdi_chunk->set(namefield, parray);
362 info() << "KDI chunk set cell vtkGhostType end";
363 }
364 tac("beginWrite");
365}
366
367/*---------------------------------------------------------------------------*/
368/*---------------------------------------------------------------------------*/
369
370// https://omz-software.com/pythonista/numpy/reference/c-api.dtype.html
371// https://numpy.org/doc/stable/reference/arrays.dtypes.html
372namespace
373{
374 template <typename DataType> class KDITraits;
375
376 template <> class KDITraits<Int64>
377 {
378 public:
379
380 static int kdiType()
381 {
382 std::cout << "KDI DTYPE C++ PyArray_LONG" << std::endl;
383 return NPY_INT64;
384 }
385 };
386
387 template <> class KDITraits<Int32>
388 {
389 public:
390
391 static int kdiType()
392 {
393 std::cout << "KDI DTYPE C++ PyArray_INT" << std::endl;
394 return NPY_INT32;
395 }
396 };
397
398 template <> class KDITraits<double>
399 {
400 public:
401
402 static int kdiType()
403 {
404 std::cout << "KDI DTYPE C++ PyArray_DOUBLE" << std::endl;
405 return NPY_FLOAT64;
406 }
407 };
408
409 template <> class KDITraits<unsigned char>
410 {
411 public:
412
413 static int kdiType()
414 {
415 std::cout << "KDI DTYPE C++ PyArray_UINT8" << std::endl;
416 return NPY_UINT8;
417 }
418 };
419
420} // namespace
421
422/*---------------------------------------------------------------------------*/
423/*---------------------------------------------------------------------------*/
424
425// https://github.com/BorgwardtLab/GraphKernels/blob/master/src/GKextCPy/eigen.i
426template <typename DataType> PyArrayObject* KdiDataWriter::
427_numpyDataSet1D(Span<const DataType> values)
428{
429 info() << "KDI _numpyDataSet1D begin";
430 bool trace{ true };
431 npy_intp dims[]{ values.size() };
432 const int py_type = KDITraits<DataType>::kdiType();
433 info() << "KDI DTYPE C++ py_type " << py_type;
434 PyArrayObject* vec_array = reinterpret_cast<PyArrayObject*>(PyArray_SimpleNew(1, dims, py_type));
435 DataType* vec_array_pointer = static_cast<DataType*>(PyArray_DATA(vec_array));
436 KTRACE(trace, vec_array_pointer);
437 std::copy(values.data(), values.data() + values.size(), vec_array_pointer);
438 info() << "KDI _numpyDataSet1D end";
439 return vec_array;
440}
441
442/*---------------------------------------------------------------------------*/
443/*---------------------------------------------------------------------------*/
444
445// https://github.com/BorgwardtLab/GraphKernels/blob/master/src/GKextCPy/eigen.i
446template <typename DataType> PyArrayObject* KdiDataWriter::
447_numpyDataSet2D(Span2<const DataType> values)
448{
449 info() << "KDI _numpyDataSet2D begin";
450 bool trace{ true };
451 npy_intp dims[2] = { values.dim1Size(), values.dim2Size() };
452 const int py_type = KDITraits<DataType>::kdiType();
453 PyArrayObject* vec_array = reinterpret_cast<PyArrayObject*>(PyArray_SimpleNew(2, dims, py_type));
454 DataType* vec_array_pointer = static_cast<DataType*>(PyArray_DATA(vec_array));
455 KTRACE(trace, vec_array_pointer);
456 std::copy(values.data(), values.data() + values.dim1Size() * values.dim2Size(), vec_array_pointer);
457 info() << "KDI _numpyDataSet2D end";
458 return vec_array;
459}
460
461/*---------------------------------------------------------------------------*/
462/*---------------------------------------------------------------------------*/
463
464void KdiDataWriter::
465endWrite()
466{
467 tic("endWrite");
468
469 tic("saveVTKHDF");
470 m_kdi_chunk_partless->saveVTKHDF(m_kdi_full_filename);
471 tac("saveVTKHDF");
472 // m_kdi_base = loadVTKHDF(m_kdi_full_filename);
473 // Not useful since this object is destroyed after each write
474
475 // Writes the file containing the times (from ParaView version 5.5)
476 // https://www.paraview.org/Wiki/ParaView_Release_Notes#JSON_based_new_meta_file_format_for_series_added
477 //
478 // Example:
479 // {
480 // "file-series-version" : "1.0",
481 // "files" : [
482 // { "name" : "foo1.vtk", "time" : 0 },
483 // { "name" : "foo2.vtk", "time" : 5.5 },
484 // { "name" : "foo3.vtk", "time" : 11.2 }
485 // ]
486 // }
487
488 if (!m_is_master_io)
489 return;
490
491 tac("endWrite");
492}
493
494/*---------------------------------------------------------------------------*/
495/*---------------------------------------------------------------------------*/
496
498setMetaData(const String& meta_data)
499{
500 ARCANE_UNUSED(meta_data);
501}
502
503/*---------------------------------------------------------------------------*/
504/*---------------------------------------------------------------------------*/
505
507write(IVariable* var, IData* data)
508{
509 tic("write");
510
511 info(4) << "Write Kdi var=" << var->name();
512
513 eItemKind item_kind = var->itemKind();
514
515 if (var->dimension() != 1)
516 ARCANE_FATAL("Only export of scalar item variable is implemented (name={0})", var->name());
517
518 {
519 info() << "KDI chunk set " << var->name() << " begin";
520 std::string namefield;
521 switch (item_kind) {
522 case IK_Cell:
523 namefield = m_kdi_base->update_fields("/mymesh/cells/fields", var->name().localstr());
524 break;
525 case IK_Node:
526 namefield = m_kdi_base->update_fields("/mymesh/points/fields", var->name().localstr());
527 break;
528 default:
529 ARCANE_FATAL("Only export of 'Cell' or 'Node' variable is implemented (name={0})", var->name());
530 }
531
532 info() << "KDI DTYPE C++ var->name() " << var->name();
533
534 eDataType data_type = var->dataType();
535 PyArrayObject* parray = nullptr;
536 switch (data_type) {
537 case DT_Real:
538 parray = _numpyDataSet1D<Real>(data);
539 break;
540 case DT_Int64:
541 parray = _numpyDataSet1D<Int64>(data);
542 break;
543 case DT_Int32:
544 parray = _numpyDataSet1D<Int32>(data);
545 break;
546 case DT_Real3:
547 parray = _numpyDataSetReal3D(data);
548 break;
549 case DT_Real2:
550 parray = _numpyDataSetReal2D(data);
551 break;
552 default:
553 warning() << String::format("Export for datatype '{0}' is not supported (var_name={1})", data_type, var->name());
554 }
555
556 m_kdi_chunk->set(namefield, parray);
557 info() << "KDI chunk set " << var->name() << " end";
558 }
559
560 tac("write");
561}
562
563/*---------------------------------------------------------------------------*/
564/*---------------------------------------------------------------------------*/
565
566// https://github.com/BorgwardtLab/GraphKernels/blob/master/src/GKextCPy/eigen.i
567template <typename DataType> PyArrayObject* KdiDataWriter::
568_numpyDataSet1D(IData* data)
569{
570 auto* true_data = dynamic_cast<IArrayDataT<DataType>*>(data);
571 ARCANE_CHECK_POINTER(true_data);
572 info() << "KDI _numpyDataSet1D var/data begin";
573 PyArrayObject* vec_array = _numpyDataSet1D(Span<const DataType>(true_data->view()));
574 info() << "KDI _numpyDataSet1D var/data end";
575 return vec_array;
576}
577
578/*---------------------------------------------------------------------------*/
579/*---------------------------------------------------------------------------*/
580
581// https://github.com/BorgwardtLab/GraphKernels/blob/master/src/GKextCPy/eigen.i
582PyArrayObject* KdiDataWriter::
583_numpyDataSetReal3D(IData* data)
584{
585 info() << "KDI _numpyDataSetReal3D var/data begin";
586 auto* true_data = dynamic_cast<IArrayDataT<Real3>*>(data);
587 ARCANE_CHECK_POINTER(true_data);
588 SmallSpan<const Real3> values(true_data->view());
589 Int32 nb_value = values.size();
590 // TODO: optimiser cela sans passer par un tableau temporaire
591 UniqueArray2<Real> scalar_values;
592 scalar_values.resize(nb_value, 3);
593 for (Int32 i = 0; i < nb_value; ++i) {
594 Real3 v = values[i];
595 scalar_values[i][0] = v.x;
596 scalar_values[i][1] = v.y;
597 scalar_values[i][2] = v.z;
598 }
599
600 PyArrayObject* vec_array = _numpyDataSet2D<Real>(scalar_values);
601 info() << "KDI _numpyDataSetReal3D var/data end";
602 return vec_array;
603}
604
605/*---------------------------------------------------------------------------*/
606/*---------------------------------------------------------------------------*/
607
608// https://github.com/BorgwardtLab/GraphKernels/blob/master/src/GKextCPy/eigen.i
609PyArrayObject* KdiDataWriter::
610_numpyDataSetReal2D(IData* data)
611{
612 info() << "KDI _numpyDataSetReal3D var/data begin";
613 // Converted into an array of 3 components where the last one will be 0.
614 auto* true_data = dynamic_cast<IArrayDataT<Real2>*>(data);
615 ARCANE_CHECK_POINTER(true_data);
616 SmallSpan<const Real2> values(true_data->view());
617 Int32 nb_value = values.size();
618 UniqueArray2<Real> scalar_values;
619 scalar_values.resize(nb_value, 3);
620 for (Int32 i = 0; i < nb_value; ++i) {
621 Real2 v = values[i];
622 scalar_values[i][0] = v.x;
623 scalar_values[i][1] = v.y;
624 scalar_values[i][2] = 0.0;
625 }
626
627 PyArrayObject* vec_array = _numpyDataSet2D<Real>(scalar_values);
628 info() << "KDI _numpyDataSetReal3D var/data end";
629 return vec_array;
630}
631
632/*---------------------------------------------------------------------------*/
633/*---------------------------------------------------------------------------*/
634
635/*---------------------------------------------------------------------------*/
636/*---------------------------------------------------------------------------*/
637
641class KdiPostProcessor
643{
644 public:
645
646 explicit KdiPostProcessor(const ServiceBuildInfo& sbi)
648 {
649 }
650
651 IDataWriter* dataWriter() override { return m_writer.get(); }
652 void notifyBeginWrite() override
653 {
654 auto w = std::make_unique<KdiDataWriter>(mesh(), groups());
655 w->setTimes(times());
657 w->setDirectoryName(dir.file("kdi"));
658 m_writer = std::move(w);
659 }
660 void notifyEndWrite() override
661 {
662 m_writer = nullptr;
663 }
664 void close() override {}
665
666 private:
667
668 std::unique_ptr<IDataWriter> m_writer;
669};
670
671/*---------------------------------------------------------------------------*/
672/*---------------------------------------------------------------------------*/
673
674ARCANE_REGISTER_SERVICE_KDIPOSTPROCESSOR(KdiPostProcessor,
675 KdiPostProcessor);
676
677/*---------------------------------------------------------------------------*/
678/*---------------------------------------------------------------------------*/
679
680} // namespace Arcane
681
682/*---------------------------------------------------------------------------*/
683/*---------------------------------------------------------------------------*/
#define ARCANE_CHECK_POINTER(ptr)
Macro returning the pointer ptr if it is not null or throwing an exception if it is null.
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
#define ENUMERATE_CELL(name, group)
Generic enumerator for a cell group.
#define ENUMERATE_NODE(name, group)
Generic enumerator for a node group.
ArcaneKdiPostProcessorObject(const Arcane::ServiceBuildInfo &sbi)
Constructeur.
Class managing a directory.
Definition Directory.h:36
String file(const String &file_name) const override
Returns the full path of the file file_name in the directory.
Definition Directory.cc:120
Interface of a 1D array data item of type T.
Definition IData.h:300
Interface for writing variable data.
Definition IDataWriter.h:45
Interface of a data item.
Definition IData.h:34
Interface of a variable.
Definition IVariable.h:40
virtual eDataType dataType() const =0
Data type managed by the variable (Real, Integer, ...).
virtual eItemKind itemKind() const =0
Kind of mesh entities on which the variable is based.
virtual Integer dimension() const =0
Dimension of the variable.
virtual String name() const =0
Variable name.
Integer size() const
Number of elements in the group.
Definition ItemGroup.h:93
KDIChunk * m_kdi_chunk
Output Chunk identifier (vtps, ipart) and (vtps, partless).
void write(IVariable *var, IData *data) override
Writes the data data of the variable var.
String m_directory_name
Output directory.
void setMetaData(const String &meta_data) override
Sets the metadata information.
KDIBase * m_kdi_base
KDI identifier of the output.
UniqueArray< Real > m_times
List of times.
std::string m_kdi_full_filename
Name of the current HDF file.
ItemGroupCollection m_groups
List of groups to save.
String m_full_filename
Name of the current HDF file.
void notifyBeginWrite() override
Notifies that an output is going to be performed with the current parameters.
void close() override
Closes the writer. After closing, it can no longer be used.
void notifyEndWrite() override
Notifies that an output has just been performed.
IDataWriter * dataWriter() override
Returns the writer associated with this post-processor.
ItemGroupCollection groups() override
List of groups to save.
ConstArrayView< Real > times() override
List of saved times.
const String & baseDirectoryName() override
Name of the output directory for files.
Structure containing the information to create a service.
View for a 2D array whose size is an 'Int64'.
Definition Span2.h:324
View of an array of elements of type T.
Definition Span.h:635
Unicode character string constructor.
const char * localstr() const
Returns the conversion of the instance into UTF-8 encoding.
Definition String.cc:229
TraceAccessor(ITraceMng *m)
Constructs an accessor via the trace manager m.
TraceMessage info() const
Flow for an information message.
TraceMessage warning() const
Flow for a warning message.
TraceMessage pwarning() const
1D data vector with value semantics (STL style).
Definition Kdi.h:144
Definition Kdi.h:42
ItemGroupT< Cell > CellGroup
Group of cells.
Definition ItemTypes.h:184
ItemGroupT< Node > NodeGroup
Group of nodes.
Definition ItemTypes.h:168
MeshVariableScalarRefT< Node, Real3 > VariableNodeReal3
Coordinate type quantity at node.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Collection< ItemGroup > ItemGroupCollection
Collection of mesh item groups.
std::int64_t Int64
Signed integer type of 64 bits.
eItemKind
Mesh entity type.
@ IK_Node
Node mesh entity.
@ IK_Cell
Cell mesh entity.
unsigned char Byte
Type of a byte.
Definition BaseTypes.h:43
eDataType
Data type.
Definition DataTypes.h:41
@ DT_Int32
32-bit integer data type
Definition DataTypes.h:45
@ DT_Real3
Vector 3 data type.
Definition DataTypes.h:49
@ DT_Int64
64-bit integer data type
Definition DataTypes.h:46
@ DT_Real2
Vector 2 data type.
Definition DataTypes.h:48
@ DT_Real
Real data type.
Definition DataTypes.h:43
@ Cell
The mesh is AMR by cell.
Definition MeshKind.h:53
std::int32_t Int32
Signed integer type of 32 bits.
ConstArrayView< Real > RealConstArrayView
C equivalent of a 1D array of reals.
Definition UtilsTypes.h:488