TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Partitionneur_Fichier_Decoupage.cpp
1/****************************************************************************
2* Copyright (c) 2026, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15#include <Partitionneur_Fichier_Decoupage.h>
16#include <EFichier.h>
17#include <Domaine.h>
18#include <Param.h>
19
20Implemente_instanciable(Partitionneur_Fichier_Decoupage,"Partitionneur_Fichier_Decoupage",Partitionneur_base);
21// XD partitionneur_fichier_decoupage partitionneur_deriv fichier_decoupage INHERITS_BRACE This algorithm reads an array
22// XD_CONT of integer values on the disc, one value for each mesh element. Each value is interpreted as the target part
23// XD_CONT number n>=0 for this element. The number of parts created is the highest value in the array plus one. Empty
24// XD_CONT parts can be created if some values are not present in the array. NL2 The file format is ASCII, and contains
25// XD_CONT space, tab or carriage-return separated integer values. The first value is the number nb_elem of elements in
26// XD_CONT the domain, followed by nb_elem integer values (positive or zero). NL2 This algorithm has been designed to
27// XD_CONT work together with the \'ecrire_decoupage\' option. You can generate a partition with any other algorithm,
28// XD_CONT write it to disc, modify it, and read it again to generate the .Zone files. NL2 Contrary to other
29// XD_CONT partitioning algorithms, no correction is applied by default to the partition (eg. element 0 on processor 0
30// XD_CONT and corrections for periodic boundaries). If \'corriger_partition\' is specified, these corrections are
31// XD_CONT applied.
32
33
35{
36 Cerr << "Partitionneur_Metis::printOn invalid\n" << finl;
37 exit();
38 return os;
39}
40
41/*! @brief Reads the partitioner parameters from disk.
42 *
43 * Expected format:
44 * { fichier FILENAME }
45 * FILENAME is the name of an existing file in ArrOfInt ASCII format.
46 *
47 */
49{
50 param.ajouter("fichier",&filename_,Param::REQUIRED); // XD attr fichier chaine fichier REQ File name
51 param.ajouter_flag("corriger_partition",&corriger_partition_); // XD attr corriger_partition rien corriger_partition OPT not_set
52}
53
55{
56 ref_domaine_ = domaine;
57}
58
60{
61 filename_ = filename;
62}
63
64/*! @brief Reads the content of "filename_" and stores the result in elem_part.
65 *
66 */
67void Partitionneur_Fichier_Decoupage::construire_partition(IntVect& elem_part, int& nb_parts_tot) const
68{
69 if (!ref_domaine_)
70 {
71 Cerr << "Error in Partitionneur_Fichier_Decoupage::construire_partition\n";
72 Cerr << " The domain has not been associated" << finl;
73 exit();
74 }
75 if (filename_ == "")
76 {
77 Cerr << "Error in Partitionneur_Fichier_Decoupage::construire_partition\n";
78 Cerr << " The file name has not been initialized" << finl;
79 exit();
80 }
81
82 Cerr << "Reading of splitting file : " << filename_ << finl;
83 EFichier file;
84 file.ouvrir(filename_);
85 if (!file.good())
86 {
87 Cerr << "Error in Partitionneur_Fichier_Decoupage::construire_partition\n";
88 Cerr << " Failed to open file " << filename_ << finl;
89 exit();
90 }
91 file >> elem_part;
92 file >> nb_parts_tot;
93 file.close();
94 const int sz = elem_part.size_array();
95 const int nelem = ref_domaine_->nb_elem();
96 if (nelem != sz)
97 {
98 Cerr << "Error in Partitionneur_Fichier_Decoupage::construire_partition\n";
99 Cerr << " The file contains an array of " << sz << " values.\n";
100 Cerr << " The area contains " << nelem << " elements" << finl;
101 exit();
102 }
104 {
105 Cerr << " Correction of the partition." << finl;
106 if (ref_domaine_->bords_perio().size() > 0)
107 corriger_bords_avec_liste(ref_domaine_.valeur(),
108 0,
109 elem_part);
110 corriger_elem0_sur_proc0(elem_part);
111 }
112}
File for reading. This class is to the C++ ifstream class what the Entree class is to the.
Definition EFichier.h:29
virtual int ouvrir(const char *name, IOS_OPEN_MODE mode=ios::in)
virtual void set_param(Param &) const
Definition Objet_U.h:130
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
Definition Objet_U.cpp:278
Helper class to factorize the readOn method of Objet_U classes.
Definition Param.h:112
void ajouter_flag(const char *keyword, const bool *value)
Register a boolean flag whose mere presence switches it to true.
Definition Param.cpp:474
void ajouter(const char *keyword, const int *value, Param::Nature nat=Param::OPTIONAL)
Register an integer parameter.
Definition Param.cpp:364
@ REQUIRED
Definition Param.h:115
Partition of a domain from a disk file containing, for each element, the processor number to which th...
void associer_domaine(const Domaine &domaine) override
void construire_partition(IntVect &elem_part, int &nb_parts_tot) const override
Reads the content of "filename_" and stores the result in elem_part.
static void corriger_bords_avec_liste(const Domaine_t &dom, const int_t my_offset, BigIntVect_ &elem_part)
static void corriger_elem0_sur_proc0(BigIntVect_ &elem_part)
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Definition Process.cpp:466
Base class for output streams.
Definition Sortie.h:52
_SIZE_ size_array() const