TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
MD_Vector_base.h
1/****************************************************************************
2* Copyright (c) 2025, 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
16#ifndef MD_Vector_base_included
17#define MD_Vector_base_included
18
19#include <TRUSTArray.h>
20#include <ArrOfBit.h>
21
24class MD_Vector;
25class MD_Vector_seq;
27class MD_Vector_std;
28
29/*! @brief Base class for distributed vectors parallel descriptors.
30 *
31 * See also the MD_Vector class (which is a kind of DERIV() of this class), and see derived classes
32 * MD_Vector_std, MD_Vector_composite and MD_Vector_seq.
33 */
34class MD_Vector_base : public Objet_U
35{
36 Declare_base(MD_Vector_base);
37
38public:
39
40 virtual int get_nb_items_reels() const { return nb_items_reels_; }
41 virtual int get_nb_items_tot() const { return nb_items_tot_; }
42 virtual trustIdType nb_items_seq_tot() const { return nb_items_seq_tot_; }
43 virtual int nb_items_seq_local() const { return nb_items_seq_local_; }
44
45 virtual const ArrOfInt& get_blocs_items_to_compute() const = 0;
46 virtual const ArrOfInt& get_items_to_compute() const = 0;
47 virtual const ArrOfInt& get_blocs_items_to_sum() const = 0;
48 virtual const ArrOfInt& get_items_to_sum() const = 0;
49
50 int get_sequential_items_flags(ArrOfBit& flags, int line_size=1) const;
51 int get_sequential_items_flags(ArrOfInt& flags, int line_size=1) const;
52
53 virtual bool validate(trustIdType sz_array, int line_size) const;
54
55 virtual void initialize_comm(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, DoubleVect&) const = 0;
56 virtual void prepare_send_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, DoubleVect&) const = 0;
57 virtual void process_recv_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, DoubleVect&) const = 0;
58
59 virtual void initialize_comm(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, FloatVect&) const = 0;
60 virtual void prepare_send_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, FloatVect&) const = 0;
61 virtual void process_recv_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, FloatVect&) const = 0;
62
63 virtual void initialize_comm(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, IntVect&) const = 0;
64 virtual void prepare_send_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, IntVect&) const = 0;
65 virtual void process_recv_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, IntVect&) const = 0;
66
67#if INT_is_64_ == 2
68 virtual void initialize_comm(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, TIDVect&) const = 0;
69 virtual void prepare_send_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, TIDVect&) const = 0;
70 virtual void process_recv_data(const Echange_EV_Options& opt, Schema_Comm_Vecteurs&, TIDVect&) const = 0;
71#endif
72
73 // Used in MD_Vector_tools:
74 virtual void fill_md_vect_renum(const IntVect& renum, MD_Vector& md_vect) const = 0;
75
76 // Tool method:
77 static void append_item_to_blocs(ArrOfInt& blocs, int item);
78
79 /*! Whether algorithms in TRUSTVect_tools should use the blocks stored in members MD_Vector_mono::blocs_items_to_*
80 */
81 virtual bool use_blocks() const = 0;
82
83protected:
84 // Actual implementation of the sequential flags retrieval - overriden in MD_Vector_seq:
85 virtual int get_seq_flags_impl(ArrOfBit& flags, int line_size) const;
86
87 // Tool methods:
88 static void append_blocs(ArrOfInt& dest, const ArrOfInt& src, int offset=0, int multiplier=1);
89 static void append_items(ArrOfInt& dest, const ArrOfInt& src, int offset=0, int multiplier=1);
90
91 // Total number of items (real+virtual), used to determine the size of arrays to create
92 int nb_items_tot_ = -1;
93 // Number of "real" items (the dimension(0) property of the array, or size() for the vector)
94 // In principle real items are all those belonging to real elements; they are grouped at
95 // the beginning of the array at indices 0 <= i < nb_items_reels_.
96 // If this number is -1, there is no separation between real and virtual items
97 // (case of P1Bulle multi-localisation arrays for which real and virtual items are mixed)
99
100 // Total number (across all procs) of sequential items (equal to mp_sum(nb_items_seq_local_)) - may exceed 32 bits.
101 trustIdType nb_items_seq_tot_ = -1;
102 // Number of sequential items on this processor (equal to the number of items in the blocks of blocs_items_to_sum_)
104
105private:
106 // This class may modify ref_count_:
107 friend class MD_Vector;
108
109};
110
111#endif
Base class for distributed vectors parallel descriptors.
virtual void process_recv_data(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, DoubleVect &) const =0
virtual const ArrOfInt & get_blocs_items_to_sum() const =0
int get_sequential_items_flags(ArrOfBit &flags, int line_size=1) const
virtual const ArrOfInt & get_items_to_sum() const =0
friend class MD_Vector
static void append_blocs(ArrOfInt &dest, const ArrOfInt &src, int offset=0, int multiplier=1)
trustIdType nb_items_seq_tot_
virtual void initialize_comm(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, IntVect &) const =0
virtual int get_seq_flags_impl(ArrOfBit &flags, int line_size) const
virtual void prepare_send_data(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, DoubleVect &) const =0
virtual void prepare_send_data(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, FloatVect &) const =0
virtual bool use_blocks() const =0
virtual int nb_items_seq_local() const
virtual void initialize_comm(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, DoubleVect &) const =0
static void append_items(ArrOfInt &dest, const ArrOfInt &src, int offset=0, int multiplier=1)
virtual bool validate(trustIdType sz_array, int line_size) const
virtual void initialize_comm(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, FloatVect &) const =0
virtual void prepare_send_data(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, IntVect &) const =0
virtual int get_nb_items_tot() const
virtual void process_recv_data(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, FloatVect &) const =0
virtual void process_recv_data(const Echange_EV_Options &opt, Schema_Comm_Vecteurs &, IntVect &) const =0
virtual trustIdType nb_items_seq_tot() const
virtual int get_nb_items_reels() const
static void append_item_to_blocs(ArrOfInt &blocs, int item)
Helper method to append an item to a "blocs"-type array containing series of blocks.
virtual void fill_md_vect_renum(const IntVect &renum, MD_Vector &md_vect) const =0
virtual const ArrOfInt & get_items_to_compute() const =0
virtual const ArrOfInt & get_blocs_items_to_compute() const =0
Metadata for a distributed composite vector.
Dummy parallel descriptor used for sequential computations.
This is the simplest descriptor, used for arrays of values at vertices, elements, faces,...
: This class is an OWN_PTR but the pointed object is shared among multiple
Definition MD_Vector.h:48
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
Definition Objet_U.cpp:54