16#include <Comm_Group_MPI.h>
17#include <communications.h>
18#include <unordered_set>
19#include <Ecrire_CGNS.h>
45void Ecrire_CGNS::init_proc_maitre_local_comm()
47 assert(is_comm_group_mode());
53 envoyer_broadcast(proc_maitre_local_comm_, 0);
58void Ecrire_CGNS::cgns_open_grid_base_link_file()
63 if (is_linked_files_comm_group_mode())
65 fn = (Nom(baseFile_name_)).nom_me(proc_maitre_local_comm_).getString() +
".grid.cgns";
67 cgns_helper_.cgns_open_file<TYPE_RUN_CGNS::PAR>(fn, fileId_,
false);
68 Cerr <<
"**** Multiple parallel CGNS files " << baseFile_name_ <<
"_XXXX.grid.cgns opened !" << finl;
72 fn = baseFile_name_ +
".grid.cgns";
76 cgns_helper_.cgns_open_file<TYPE_RUN_CGNS::PAR>(fn, fileId_);
78 cgns_helper_.cgns_open_file<TYPE_RUN_CGNS::SEQ>(fn, fileId_);
81 grid_file_opened_ =
true;
84void Ecrire_CGNS::cgns_close_grid_or_solution_link_file(
const double t,
const TYPE_LINK_CGNS type,
bool is_cerr)
90 if (type == TYPE_LINK_CGNS::GRID)
92 if (is_linked_files_comm_group_mode())
93 fn = baseFile_name_ +
"_XXXX.grid.cgns";
95 fn = baseFile_name_ +
".grid.cgns";
97 else if (type == TYPE_LINK_CGNS::SOLUTION)
99 if (is_linked_files_comm_group_mode())
100 fn = baseFile_name_ +
"_XXXX_" +
".solution." + cgns_helper_.convert_double_to_string(t) +
".cgns";
102 fn = baseFile_name_ +
".solution." + cgns_helper_.convert_double_to_string(t) +
".cgns";
104 else if (type == TYPE_LINK_CGNS::FINAL_LINK)
105 fn = baseFile_name_ +
".cgns";
107 Process::exit(
"Error in Ecrire_CGNS::cgns_close_grid_or_solution_link_file !!! \n");
111 if (is_linked_files_comm_group_mode())
113 cgns_helper_.cgns_close_file<TYPE_RUN_CGNS::PAR>(fn , fileId_,
false);
114 Cerr <<
"**** Multiple parallel CGNS files " << fn <<
" closed !" << finl;
117 cgns_helper_.cgns_close_file<TYPE_RUN_CGNS::PAR>(fn, fileId_, is_cerr);
120 cgns_helper_.cgns_close_file<TYPE_RUN_CGNS::SEQ>(fn, fileId_, is_cerr);
122 if (type == TYPE_LINK_CGNS::GRID)
123 grid_file_opened_ =
false;
125 if (type == TYPE_LINK_CGNS::SOLUTION)
126 solution_file_opened_ =
false;
129void Ecrire_CGNS::cgns_fill_info_grid_link_file(
const char* basename,
const CGNS_TYPE& cgns_type_elem,
const int icelldim,
const int nb_som,
const int nb_elem,
const bool is_polyedre)
131 cellDim_.push_back(icelldim);
132 baseZone_name_.push_back(std::string(basename));
133 sizeId_.push_back( { nb_som, nb_elem } );
135 if (cgns_type_elem == CGNS_ENUMV(NGON_n))
138 connectname_.push_back( {
"NGON_n",
"NFACE_n" });
140 connectname_.push_back({
"NGON_n" });
143 connectname_.push_back({
"Elem" });
146void Ecrire_CGNS::cgns_init_solution_link_file(
const std::string& LOC,
const Nom& nom_dom)
148 assert (LOC ==
"ELEM" || LOC ==
"SOM");
149 Cerr <<
"### Building a new CGNS base with a linked zone to host the field located at : " << LOC <<
" !" << finl;
150 doms_written_.push_back(nom_dom);
151 baseId_.push_back(-123);
152 zoneId_.push_back(-123);
155void Ecrire_CGNS::gather_local_sizeId_for_comm_group()
158 if (!vec_proc_maitre_local_comm_.empty())
return;
160 unique_vec_proc_maitre_local_comm_.clear();
161 sizeId_som_local_comm_.clear();
162 sizeId_elem_local_comm_.clear();
165 MPI_Allgather(&proc_maitre_local_comm_, 1, MPI_ENTIER, vec_proc_maitre_local_comm_.data(), 1, MPI_ENTIER, Comm_Group_MPI::get_trio_u_world());
167 std::unordered_set<int> seen;
169 for (
int val : vec_proc_maitre_local_comm_)
170 if (seen.insert(val).second)
171 unique_vec_proc_maitre_local_comm_.push_back(val);
173 std::vector<std::vector<cgsize_t>> sizeId_som_local_comm_tmp, sizeId_elem_local_comm_tmp;
174 sizeId_som_local_comm_tmp.reserve(sizeId_.size());
175 sizeId_elem_local_comm_tmp.reserve(sizeId_.size());
177 MPI_Datatype CGNS_MPI_SIZE;
178 MPI_Type_match_size(MPI_TYPECLASS_INTEGER,
sizeof(cgsize_t), &CGNS_MPI_SIZE);
180 for (
int i = 0; i < static_cast<int>(sizeId_.size()); i++)
182 assert(sizeId_[i].size() == 2);
184 sizeId_som_local_comm_tmp.emplace_back(
Process::nproc(),
static_cast<cgsize_t
>(-123));
185 sizeId_elem_local_comm_tmp.emplace_back(
Process::nproc(),
static_cast<cgsize_t
>(-123));
187 MPI_Allgather(&sizeId_[i][0], 1, CGNS_MPI_SIZE, sizeId_som_local_comm_tmp[i].data(), 1, CGNS_MPI_SIZE, Comm_Group_MPI::get_trio_u_world());
188 MPI_Allgather(&sizeId_[i][1], 1, CGNS_MPI_SIZE, sizeId_elem_local_comm_tmp[i].data(), 1, CGNS_MPI_SIZE, Comm_Group_MPI::get_trio_u_world());
191 const int nb_grps =
static_cast<int>(unique_vec_proc_maitre_local_comm_.size());
192 sizeId_som_local_comm_.reserve(sizeId_.size());
193 sizeId_elem_local_comm_.reserve(sizeId_.size());
195 for (
int i = 0; i < static_cast<int>(sizeId_.size()); i++)
197 sizeId_som_local_comm_.emplace_back(nb_grps,
static_cast<cgsize_t
>(-123));
198 sizeId_elem_local_comm_.emplace_back(nb_grps,
static_cast<cgsize_t
>(-123));
200 for (
int j = 0; j < nb_grps; j++)
202 int proc_grp = unique_vec_proc_maitre_local_comm_[j];
203 sizeId_som_local_comm_[i][j] = sizeId_som_local_comm_tmp[i][proc_grp];
204 sizeId_elem_local_comm_[i][j] = sizeId_elem_local_comm_tmp[i][proc_grp];
212void Ecrire_CGNS::add_new_linked_base(
const std::string& LOC,
const Nom& nom_dom)
214 assert (LOC ==
"ELEM" || LOC ==
"SOM");
215 Cerr <<
"### Building a new CGNS base with a linked zone to host the field located at : " << LOC <<
" !" << finl;
217 doms_written_.push_back(nom_dom);
218 baseId_.push_back(-123);
220 const Nom nom_dom_mod = TRUST_2_CGNS::modify_domaine_name_for_link(nom_dom, LOC);
221 const int ind_base = TRUST_2_CGNS::get_index_nom_vector(doms_written_, nom_dom_mod);
224 Cerr <<
"Error Ecrire_CGNS::add_new_linked_base : cg_base_write !" << finl, TRUST_CGNS_ERROR();
229 TRUST_2_CGNS& TRUST2CGNS = T2CGNS_[ind_base];
230 const std::vector<int>& global_nb_elem = TRUST2CGNS.get_global_nb_elem(),
231 &global_nb_som = TRUST2CGNS.get_global_nb_som(),
232 &proc_non_zero_elem = TRUST2CGNS.get_proc_non_zero_elem();
234 const int nb_zones_to_write = TRUST2CGNS.nb_procs_writing();
235 const bool all_write = TRUST2CGNS.all_procs_write();
236 std::string zonename, zonename_link;
238 for (
int i = 0; i != nb_zones_to_write; i++)
240 const int indZ = all_write ? i : proc_non_zero_elem[i];
241 const int ne_loc = global_nb_elem[indZ], ns_loc = global_nb_som[indZ];
244 zoneId_.push_back(-123);
245 const cgsize_t isize[3] = { ns_loc , ne_loc , 0 };
250 cgns_helper_.cgns_write_zone_and_classic_links(
true , fileId_, baseId_.back(), zonename, isize, zoneId_.back(), indZ + 1,
251 "" , nom_dom_mod.
getString(), zonename_link, connectname_[ind_base],
252 "Ecrire_CGNS::add_new_linked_base");
255 zoneId_par_.push_back(zoneId_);
259 zoneId_.push_back(-123);
260 const cgsize_t isize[3] = { sizeId_[ind_base][0] , sizeId_[ind_base][1] , 0 };
262 cgns_helper_.cgns_write_zone_and_classic_links(
true , fileId_, baseId_.back(), nom_dom.
getString(), isize, zoneId_.back(), 1,
263 "" , baseZone_name_[ind_base], baseZone_name_[ind_base], connectname_[ind_base],
264 "Ecrire_CGNS::add_new_linked_base");
270void Ecrire_CGNS::cgns_open_solution_link_file(
const double t)
274 const bool enter_group_comm = is_linked_files_comm_group_mode();
277 if (enter_group_comm)
278 fn = (Nom(baseFile_name_)).nom_me(proc_maitre_local_comm_).getString() +
".solution." + cgns_helper_.convert_double_to_string(t) +
".cgns";
280 fn = baseFile_name_ +
".solution." + cgns_helper_.convert_double_to_string(t) +
".cgns";
286 cgns_helper_.cgns_open_file<TYPE_RUN_CGNS::PAR>(fn, fileId_, enter_group_comm ? false :
true);
288 if (enter_group_comm)
289 Cerr <<
"**** Multiple parallel CGNS files " << baseFile_name_ <<
"_XXXX.solution." + cgns_helper_.convert_double_to_string(t) +
".cgns opened !" << finl;
292 cgns_helper_.cgns_open_file<TYPE_RUN_CGNS::SEQ>(fn, fileId_,
true);
294 solution_file_opened_ =
true;
300 for (
auto &itr : fld_loc_map_)
302 const std::string& LOC = itr.first;
303 const Nom& nom_dom = itr.second;
305 int index_glob = -123, ind_base = -123;
306 TRUST_2_CGNS::init_glob_base_domain_idx(doms_written_, nom_dom,
true , LOC, index_glob, ind_base);
309 Cerr <<
"Error Ecrire_CGNS::cgns_open_solution_link_file : cg_base_write !" << finl, TRUST_CGNS_ERROR();
315 const cgsize_t isize[3] = { sizeId_[ind_base][0] , sizeId_[ind_base][1] , 0 };
317 std::string linkfile = baseFile_name_ +
".grid.cgns";
319 if (enter_group_comm)
320 linkfile = (Nom(baseFile_name_)).nom_me(proc_maitre_local_comm_).getString() +
".grid.cgns";
322 TRUST_2_CGNS::remove_slash_linkfile(linkfile);
324 cgns_helper_.cgns_write_zone_and_classic_links(
true , fileId_, baseId_[index_glob], nom_dom.
getString(), isize, zoneId_[index_glob], 1,
325 linkfile, baseZone_name_[ind_base], baseZone_name_[ind_base], connectname_[ind_base],
326 "Ecrire_CGNS::cgns_open_solution_link_file");
330void Ecrire_CGNS::cgns_write_final_link_file_for_single_file_comm_group()
333 if (vec_proc_maitre_local_comm_.empty())
334 gather_local_sizeId_for_comm_group();
337 std::string fn = baseFile_name_ +
".cgns";
339 cgns_helper_.cgns_open_file<TYPE_RUN_CGNS::PAR>(fn, fileId_link,
true);
341 const int nb_grps =
static_cast<int>(unique_vec_proc_maitre_local_comm_.size());
342 std::vector<int> zoneId_tmp;
343 std::vector<int> baseId_tmp(baseId_);
345 for (
auto &itr : doms_written_)
347 bool has_field =
false;
348 std::string LOC =
"rien";
349 TRUST_2_CGNS::init_has_field_and_loc_iters(itr, fld_loc_map_, has_field, LOC);
351 int index_glob = -123, ind_base = -123;
352 TRUST_2_CGNS::init_glob_base_domain_idx(doms_written_, itr, has_field, LOC, index_glob, ind_base);
354 if (cg_base_write(fileId_link, itr.getChar(), cellDim_[ind_base],
Objet_U::dimension, &baseId_tmp[index_glob]) != CG_OK)
355 Cerr <<
"Error Ecrire_CGNS::cgns_write_final_link_file_comm_group : cg_base_write !" << finl, TRUST_CGNS_ERROR();
357 int zone_goto_idx = 1;
361 for (
int gid = 0; gid < nb_grps; gid++)
363 int proc_grp = unique_vec_proc_maitre_local_comm_[gid];
364 std::string zone_name = Nom(
"Zone").nom_me(proc_grp).getString();
366 std::string file_group_id = Nom(baseFile_name_).nom_me(proc_grp).getString();
367 TRUST_2_CGNS::remove_slash_linkfile(file_group_id);
369 const cgsize_t isize[3] = { sizeId_som_local_comm_[ind_base][gid], sizeId_elem_local_comm_[ind_base][gid], 0 };
371 if ((isize[0] == 0 && isize[1] == 0))
continue;
373 zoneId_tmp.push_back(-123);
377 cgns_helper_.cgns_write_zone_and_deformable_links(
true , has_field, fileId_link, baseId_tmp[index_glob],
378 zone_name, isize, zoneId_tmp.back(), zone_goto_idx,
379 file_group_id, baseZone_name_[ind_base], baseZone_name_[ind_base],
380 connectname_[ind_base], itr, LOC, time_post_,
381 "Ecrire_CGNS::cgns_write_final_link_file_comm_group");
385 cgns_helper_.cgns_write_zone_and_classic_links(
true , fileId_link, baseId_tmp[index_glob], zone_name,
386 isize, zoneId_tmp.back(), zone_goto_idx,
387 file_group_id +
".cgns" , baseZone_name_[ind_base],
388 baseZone_name_[ind_base], connectname_[ind_base],
389 "Ecrire_CGNS::cgns_write_final_link_file_for_single_file_comm_group");
392 cgns_helper_.cgns_write_solution_classic_links(file_group_id, itr.getString(), itr.getString(), LOC, time_post_,
393 "Ecrire_CGNS::cgns_write_final_link_file_comm_group");
401 cgns_helper_.cgns_write_iters_deformable<TYPE_ECRITURE_CGNS::SEQ>(
true, has_field,
static_cast<int>(zoneId_tmp.size()) ,
402 fileId_link, baseId_tmp[index_glob], ind_base,
403 zoneId_tmp, LOC, solname_som_, solname_elem_,
404 solname_faces_, grid_name_, time_post_);
406 cgns_helper_.cgns_write_iters<TYPE_ECRITURE_CGNS::SEQ>(has_field,
static_cast<int>(zoneId_tmp.size()) ,
407 fileId_link, baseId_tmp[index_glob], ind_base,
408 zoneId_tmp, LOC, solname_som_, solname_elem_,
409 solname_faces_, time_post_);
411 cgns_helper_.cgns_close_file<TYPE_RUN_CGNS::PAR>(fn, fileId_link,
true);
415void Ecrire_CGNS::cgns_write_final_link_file_comm_group()
418 if (vec_proc_maitre_local_comm_.empty())
419 gather_local_sizeId_for_comm_group();
424 std::string fn = baseFile_name_ +
".cgns";
426 cgns_helper_.cgns_open_file<TYPE_RUN_CGNS::SEQ>(fn, fileId_,
true);
428 const int nb_grps =
static_cast<int>(unique_vec_proc_maitre_local_comm_.size());
429 std::vector<int> zoneId_tmp;
431 for (
auto &itr : doms_written_)
433 bool has_field =
false;
434 std::string LOC =
"rien";
435 TRUST_2_CGNS::init_has_field_and_loc_iters(itr, fld_loc_map_, has_field, LOC);
437 int index_glob = -123, ind_base = -123;
438 TRUST_2_CGNS::init_glob_base_domain_idx(doms_written_, itr, has_field, LOC, index_glob, ind_base);
440 if (cg_base_write(fileId_, itr.getChar(), cellDim_[ind_base],
Objet_U::dimension, &baseId_[index_glob]) != CG_OK)
441 Cerr <<
"Error Ecrire_CGNS::cgns_write_final_link_file_comm_group : cg_base_write !" << finl, TRUST_CGNS_ERROR();
443 int zone_goto_idx = 1;
447 for (
int gid = 0; gid < nb_grps; gid++)
449 int proc_grp = unique_vec_proc_maitre_local_comm_[gid];
450 std::string zone_name = Nom(
"Zone").nom_me(proc_grp).getString();
452 std::string file_group_id = Nom(baseFile_name_).nom_me(proc_grp).getString();
453 TRUST_2_CGNS::remove_slash_linkfile(file_group_id);
455 const cgsize_t isize[3] = { sizeId_som_local_comm_[ind_base][gid], sizeId_elem_local_comm_[ind_base][gid], 0 };
457 if ((isize[0] == 0 && isize[1] == 0))
continue;
459 zoneId_tmp.push_back(-123);
463 cgns_helper_.cgns_write_zone_and_deformable_links(
true , has_field, fileId_, baseId_[index_glob],
464 zone_name, isize, zoneId_tmp.back(), zone_goto_idx,
465 file_group_id, baseZone_name_[ind_base], baseZone_name_[ind_base],
466 connectname_[ind_base], itr, LOC, time_post_,
467 "Ecrire_CGNS::cgns_write_final_link_file_comm_group");
471 cgns_helper_.cgns_write_zone_and_classic_links(
true , fileId_, baseId_[index_glob], zone_name,
472 isize, zoneId_tmp.back(), zone_goto_idx,
473 file_group_id +
".grid.cgns" , baseZone_name_[ind_base],
474 baseZone_name_[ind_base], connectname_[ind_base],
475 "Ecrire_CGNS::cgns_write_final_link_file_comm_group");
478 cgns_helper_.cgns_write_solution_classic_links(file_group_id, itr.getString(), itr.getString(), LOC, time_post_,
479 "Ecrire_CGNS::cgns_write_final_link_file_comm_group");
487 cgns_helper_.cgns_write_iters_deformable<TYPE_ECRITURE_CGNS::SEQ>(
true, has_field,
static_cast<int>(zoneId_tmp.size()) ,
488 fileId_, baseId_[index_glob], ind_base,
489 zoneId_tmp, LOC, solname_som_, solname_elem_,
490 solname_faces_, grid_name_, time_post_);
492 cgns_helper_.cgns_write_iters<TYPE_ECRITURE_CGNS::SEQ>(has_field,
static_cast<int>(zoneId_tmp.size()) ,
493 fileId_, baseId_[index_glob], ind_base,
494 zoneId_tmp, LOC, solname_som_, solname_elem_,
495 solname_faces_, time_post_);
497 cgns_helper_.cgns_close_file<TYPE_RUN_CGNS::SEQ>(fn, fileId_,
true);
502void Ecrire_CGNS::cgns_write_final_link_file()
504 if (is_linked_files_comm_group_mode())
506 cgns_write_final_link_file_comm_group();
513 std::string fn = baseFile_name_ +
".cgns";
515 cgns_helper_.cgns_open_file<TYPE_RUN_CGNS::SEQ>(fn, fileId_,
true);
517 std::string base_link_file = baseFile_name_;
518 TRUST_2_CGNS::remove_slash_linkfile(base_link_file);
520 for (
auto &itr : doms_written_)
522 bool has_field =
false;
523 std::string LOC =
"rien";
524 TRUST_2_CGNS::init_has_field_and_loc_iters(itr, fld_loc_map_, has_field, LOC);
526 int index_glob = -123, ind_base = -123;
527 TRUST_2_CGNS::init_glob_base_domain_idx(doms_written_, itr, has_field, LOC, index_glob, ind_base);
529 if (cg_base_write(fileId_, itr.getChar(), cellDim_[ind_base],
Objet_U::dimension, &baseId_[index_glob]) != CG_OK)
530 Cerr <<
"Error Ecrire_CGNS::cgns_open_solution_link_file : cg_base_write !" << finl, TRUST_CGNS_ERROR();
532 const cgsize_t isize[3] = { sizeId_[ind_base][0] , sizeId_[ind_base][1] , 0 };
536 cgns_helper_.cgns_write_zone_and_deformable_links(
true , has_field, fileId_, baseId_[index_glob],
537 itr.getString(), isize, zoneId_[index_glob], 1,
538 base_link_file, baseZone_name_[ind_base], baseZone_name_[ind_base],
539 connectname_[ind_base], itr, LOC, time_post_,
540 "Ecrire_CGNS::cgns_open_solution_link_file");
542 cgns_helper_.cgns_write_iters_deformable<TYPE_ECRITURE_CGNS::SEQ>(
true , has_field, 1 , fileId_,
543 baseId_[index_glob], index_glob ,
544 zoneId_, LOC, solname_som_, solname_elem_,
545 solname_faces_, grid_name_, time_post_);
549 cgns_helper_.cgns_write_zone_and_classic_links(
true , fileId_, baseId_[index_glob],
550 itr.getString(), isize, zoneId_[index_glob], 1,
551 base_link_file +
".grid.cgns" , baseZone_name_[ind_base],
552 baseZone_name_[ind_base], connectname_[ind_base],
553 "Ecrire_CGNS::cgns_write_final_link_file");
556 cgns_helper_.cgns_write_solution_classic_links(base_link_file, itr.getString(), itr.getString(), LOC, time_post_,
557 "Ecrire_CGNS::cgns_write_final_link_file");
559 cgns_helper_.cgns_write_iters<TYPE_ECRITURE_CGNS::SEQ>(has_field, 1, fileId_, baseId_[index_glob], index_glob ,
560 zoneId_, LOC, solname_som_, solname_elem_, solname_faces_, time_post_);
565 cgns_close_grid_or_solution_link_file(-123. , TYPE_LINK_CGNS::FINAL_LINK,
true);
569void Ecrire_CGNS::link_multi_loc_support_pb_deformable()
573 link_multi_loc_support_lagrangian();
580 const bool enter_group_comm = is_linked_files_comm_group_mode();
582 for (
auto &itr : fld_loc_map_)
584 const std::string& LOC = itr.first;
585 const Nom& nom_dom = itr.second;
587 int index_glob = -123, ind_base = -123;
588 TRUST_2_CGNS::init_glob_base_domain_idx(doms_written_, nom_dom,
true , LOC, index_glob, ind_base);
591 Cerr <<
"Error Ecrire_CGNS::link_multi_loc_support_pb_deformable : cg_base_write !" << finl, TRUST_CGNS_ERROR();
593 const cgsize_t isize[3] = { sizeId_[ind_base][0], sizeId_[ind_base][1], 0 };
596 cgns_helper_.cgns_write_zone_and_classic_links(
true , fileId_, baseId_[index_glob], nom_dom.
getString(), isize, zoneId_[index_glob], 1,
597 "" , baseZone_name_[ind_base], baseZone_name_[ind_base], connectname_[ind_base],
598 "Ecrire_CGNS::link_multi_loc_support_pb_deformable",
false );
601 std::string linkfile;
602 if (!first_time_post_)
603 linkfile = (enter_group_comm ? Nom(baseFile_name_).nom_me(proc_maitre_local_comm_).getString() : baseFile_name_) +
604 ".solution." + cgns_helper_.convert_double_to_string(time_post_[0]) +
".cgns";
606 TRUST_2_CGNS::remove_slash_linkfile(linkfile);
608 cgns_helper_.cgns_write_connectivity_deformable_links(fileId_, baseId_[index_glob], zoneId_[index_glob], linkfile, baseZone_name_[ind_base], baseZone_name_[ind_base],
609 connectname_[ind_base],
"Ecrire_CGNS::link_multi_loc_support_pb_deformable");
614 if (first_time_post_)
return;
616 for (
auto &itr : fld_loc_map_)
618 const std::string& LOC = itr.first;
619 const Nom& nom_dom = itr.second;
621 int index_glob = -123, ind_base = -123;
622 TRUST_2_CGNS::init_glob_base_domain_idx(doms_written_, nom_dom,
true , LOC, index_glob, ind_base);
624 std::string linkpath =
"/" + baseZone_name_[ind_base] +
"/" + baseZone_name_[ind_base] +
"/" + grid_name_loc_ +
"/";
626 if (cg_goto(fileId_, baseId_[index_glob],
"Zone_t", 1,
"end") != CG_OK)
627 Cerr <<
"Error Ecrire_CGNS::link_multi_loc_support_pb_deformable : cg_goto !" << finl, TRUST_CGNS_ERROR();
629 if (cg_link_write(grid_name_loc_.c_str(),
"" , linkpath.c_str()) != CG_OK)
630 Cerr <<
"Error Ecrire_CGNS::link_multi_loc_support_pb_deformable : cg_link_write !" << finl, TRUST_CGNS_ERROR();
634 multi_loc_deformable_support_linked_ =
true;
638void Ecrire_CGNS::link_multi_loc_support_lagrangian()
640 for (
auto &itr : fld_loc_map_)
642 const std::string& LOC = itr.first;
643 const Nom& nom_dom = itr.second;
645 int index_glob = -123, ind_base = -123;
646 TRUST_2_CGNS::init_glob_base_domain_idx(doms_written_, nom_dom,
true , LOC, index_glob, ind_base);
647 assert (ind_base == 0);
650 Cerr <<
"Error Ecrire_CGNS::link_multi_loc_support_lagrangian : cg_base_write !" << finl, TRUST_CGNS_ERROR();
652 const int nb_current_post =
static_cast<int> (time_post_.size());
653 const cgsize_t isize[3] = { sizeId_[nb_current_post - 1][0], sizeId_[nb_current_post - 1][1], 0 };
655 cgns_helper_.cgns_write_zone_and_classic_links(
true , fileId_, baseId_[index_glob], nom_dom.
getString(), isize, zoneId_[index_glob], 1,
656 "" , baseZone_name_[ind_base], baseZone_name_[ind_base], connectname_[ind_base],
657 "Ecrire_CGNS::link_multi_loc_support_lagrangian");
659 multi_loc_deformable_support_linked_ =
true;
662void Ecrire_CGNS::cgns_write_final_link_file_lagrangian()
666 const int nsteps =
static_cast<int>(time_post_.size());
667 const cgsize_t nuse =
static_cast<cgsize_t
>(nsteps);
669 if (nsteps == 0)
return;
671 std::string fn = baseFile_name_ +
".cgns";
673 cgns_helper_.cgns_open_file<TYPE_RUN_CGNS::SEQ>(fn, fileId_,
true);
675 for (
auto &itr : fld_loc_map_)
677 const std::string& LOC = itr.first;
678 const Nom& nom_dom = itr.second;
680 int index_glob = -123, ind_base = -123;
681 TRUST_2_CGNS::init_glob_base_domain_idx(doms_written_, nom_dom,
true , LOC, index_glob, ind_base);
684 Cerr <<
"Error Ecrire_CGNS::cgns_write_final_link_file_lagrangian : cg_base_write !" << finl, TRUST_CGNS_ERROR();
686 if (cg_biter_write(fileId_, baseId_[index_glob],
"TimeIterValues", nsteps) != CG_OK)
687 Cerr <<
"Error Ecrire_CGNS::cgns_write_final_link_file_lagrangian : cg_biter_write !" << finl, TRUST_CGNS_ERROR();
689 if (cg_goto(fileId_, baseId_[index_glob],
"BaseIterativeData_t", 1,
"end") != CG_OK)
690 Cerr <<
"Error Ecrire_CGNS::cgns_write_final_link_file_lagrangian : cg_goto BaseIterativeData_t !" << finl, TRUST_CGNS_ERROR();
693 if (cg_array_write(
"TimeValues", CGNS_DOUBLE_TYPE, 1, &nuse, time_post_.data()) != CG_OK)
694 Cerr <<
"Error Ecrire_CGNS::cgns_write_final_link_file_lagrangian : cg_array_write TimeValues !" << finl, TRUST_CGNS_ERROR();
696 if (cg_simulation_type_write(fileId_, baseId_[index_glob], CGNS_ENUMV(TimeAccurate)) != CG_OK)
697 Cerr <<
"Error Ecrire_CGNS::cgns_write_final_link_file_lagrangian : cg_simulation_type_write !" << finl, TRUST_CGNS_ERROR();
700 std::vector<int> number_of_zones(nsteps, 1);
701 if (cg_array_write(
"NumberOfZones", CGNS_ENUMV(Integer), 1, &nuse, number_of_zones.data()) != CG_OK)
702 Cerr <<
"Error Ecrire_CGNS::cgns_write_final_link_file_lagrangian : cg_array_write NumberOfZones !" << finl, TRUST_CGNS_ERROR();
704 cgsize_t zpdims[3] = { CGNS_STR_SIZE, 1, nuse };
705 std::string zone_ptrs;
706 zone_ptrs.reserve(
static_cast<size_t>(CGNS_STR_SIZE) * nsteps);
708 bool first_zone =
true;
709 for (
int i = 0; i < nsteps; i++)
715 zname += std::to_string(i);
719 zname.resize(CGNS_STR_SIZE,
' ');
723 if (cg_array_write(
"ZonePointers", CGNS_ENUMV(Character), 3, zpdims, zone_ptrs.c_str()) != CG_OK)
724 Cerr <<
"Error Ecrire_CGNS::cgns_write_final_link_file_lagrangian : cg_array_write ZonePointers !" << finl, TRUST_CGNS_ERROR();
726 for (
int i = 0; i < nsteps; i++)
728 cgsize_t isize[3] = { sizeId_[i][0] , sizeId_[i][1] , 0 };
734 zn += std::to_string(i);
737 if (cg_zone_write(fileId_, baseId_[index_glob], zn.c_str(), isize, CGNS_ENUMV(Unstructured), &zoneId_[index_glob]) != CG_OK)
738 Cerr <<
"Error Ecrire_CGNS::cgns_write_final_link_file_lagrangian : cg_zone_write !" << finl, TRUST_CGNS_ERROR();
740 std::string linkfile = baseFile_name_ +
".solution." + cgns_helper_.convert_double_to_string(time_post_[i]) +
".cgns";
741 TRUST_2_CGNS::remove_slash_linkfile(linkfile);
742 std::string linkpath =
"/" + baseZone_name_[ind_base] +
"/" + baseZone_name_[ind_base] +
"/GridCoordinates/";
744 if (cg_goto(fileId_, baseId_[index_glob],
"Zone_t", zoneId_[index_glob],
"end") != CG_OK)
745 Cerr <<
"Error Ecrire_CGNS::cgns_write_final_link_file_lagrangian : cg_goto Zone_t !" << finl, TRUST_CGNS_ERROR();
747 if (cg_link_write(
"GridCoordinates", linkfile.c_str(), linkpath.c_str()) != CG_OK)
748 Cerr <<
"Error Ecrire_CGNS::cgns_write_final_link_file_lagrangian : cg_link_write GridCoordinates !" << finl, TRUST_CGNS_ERROR();
750 for (
auto& itr_conn : connectname_[ind_base])
752 linkpath =
"/" + baseZone_name_[ind_base] +
"/" + baseZone_name_[ind_base] +
"/" + itr_conn +
"/";
753 if (cg_link_write(itr_conn.c_str(), linkfile.c_str(), linkpath.c_str()) != CG_OK)
754 Cerr <<
"Error Ecrire_CGNS::cgns_write_final_link_file_lagrangian : cg_link_write connectivity !" << finl, TRUST_CGNS_ERROR();
757 std::string solname =
"FlowSolution_itr_" + std::to_string(i);
758 linkpath =
"/" + nom_dom.
getString() +
"/" + nom_dom.
getString() +
"/" + solname +
"/";
759 if (cg_link_write(solname.c_str(), linkfile.c_str(), linkpath.c_str()) != CG_OK)
760 Cerr <<
"Error Ecrire_CGNS::cgns_write_final_link_file_lagrangian : cg_link_write FlowSolution !" << finl, TRUST_CGNS_ERROR();
764 cgns_close_grid_or_solution_link_file(-123., TYPE_LINK_CGNS::FINAL_LINK,
true);
int rank() const
Renvoie le rang du processeur local dans le groupe *this.
class Nom Une chaine de caractere pour nommer les objets de TRUST
const char * getChar() const
Nom nom_me(int, const char *prefix=0, int without_padding=0) const
Insere _prefix000n (n=me() ou nproc()) dans un nom de fichier (par ex:toto.
const std::string & getString() const
static bool PARALLEL_OVER_ZONE
static int enter_group(const Comm_Group &group)
Si le processeur local appartient au groupe, le groupe courant pour ce processeur devient "group" et ...
static const Comm_Group & get_user_defined_group()
Renvoie une reference au groupe sur defini par l'utilisateur.
static const Comm_Group & groupe_TRUST()
Renvoie une reference au groupe de tous les processeurs TRUST.
static void exit_group()
Retourne dans le groupe ou l'on etait avant le dernier enter_group() reussi (dont le resultat a ete 1...
static bool is_parallel()
static int nproc()
renvoie le nombre de processeurs dans le groupe courant Voir Comm_Group::nproc() et PE_Groups::curren...
static int me()
renvoie mon rang dans le groupe de communication courant.
static void exit(int exit_code=-1)
Routine de sortie de TRUST dans une region Kokkos.