TrioCFD 1.9.9_beta
TrioCFD documentation
Loading...
Searching...
No Matches
Solv_tools.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
16#include <Solv_tools.h>
17#include <Objet_U.h>
18
19void Solv_tools::construit_renum(const DoubleVect& b)
20{
21 // Initialize the items_to_keep_ array if not already done
23
24 // Compute important value:
29 //Journal()<<"nb_rows_=" << nb_rows_ << " nb_rows_tot_=" << nb_rows_tot_ << " decalage_local_global_=" << decalage_local_global_ << finl;
30
31 /**********************/
32 /* Build renum_ array */
33 /**********************/
34 //if (MatricePetsc_==nullptr)
35 {
36 const MD_Vector& md = b.get_md_vector();
37 renum_.reset();
38 renum_.resize(0, b.line_size());
39 MD_Vector_tools::creer_tableau_distribue(md, renum_, RESIZE_OPTIONS::NOCOPY_NOINIT);
40 }
41 int cpt=0;
42 int size=items_to_keep_.size_array();
43 renum_ = INT_MAX; //to crash if the MD_Vector is inconsistent
44 ArrOfTID& renum_array = renum_; // array viewed as linear
45 for(int i=0; i<size; i++)
46 if(items_to_keep_[i])
47 {
48 renum_array[i]=cpt+decalage_local_global_;
49 cpt++;
50 }
51
52 renum_.echange_espace_virtuel();
53 // Build index_
54 index_.resize(size);
55 int index = 0;
56 // ToDo OpenMP: factorize with ix since index_=ix-decalage_local_global_
57 for (int i=0; i<size; i++)
58 {
59 if (items_to_keep_[i])
60 {
61 index_[i] = index;
62 index++;
63 }
64 else
65 index_[i] = -1;
66 }
67 // Build ix
68 size=b.size_array();
69 auto colonne_globale=decalage_local_global_;
70 ix.resize(size);
71 for (int i=0; i<size; i++)
72 if (items_to_keep_[i])
73 {
74 ix[i] = colonne_globale;
75 colonne_globale++;
76 }
77 else
78 ix[i] = -1;
79}
80
int get_sequential_items_flags(ArrOfBit &flags, int line_size=1) const
static void creer_tableau_distribue(const MD_Vector &, Array_base &, RESIZE_OPTIONS opt=RESIZE_OPTIONS::COPY_INIT)
Transforms v into a parallel array having the structure md.
: This class is an OWN_PTR but the pointed object is shared among multiple
Definition MD_Vector.h:48
static trustIdType mppartial_sum(trustIdType i)
Computes the partial sum of x over processors 0 to me()-1 (returns 0 on processor 0).
Definition Process.cpp:403
static double mp_sum(double)
Computes the sum of x over all processors in the current group.
Definition Process.cpp:145
ArrOfBit items_to_keep_
Definition Solv_tools.h:31
int secmem_sz_
Definition Solv_tools.h:37
int nb_items_to_keep_
Definition Solv_tools.h:33
ArrOfTID ix
Definition Solv_tools.h:32
trustIdType nb_rows_tot_
Definition Solv_tools.h:35
TIDTab renum_
Definition Solv_tools.h:29
IntTab index_
Definition Solv_tools.h:30
trustIdType decalage_local_global_
Definition Solv_tools.h:36
void construit_renum(const DoubleVect &)
_SIZE_ size_array() const
_SIZE_ size_totale() const
Definition TRUSTVect.tpp:61
int line_size() const
Definition TRUSTVect.tpp:67
virtual const MD_Vector & get_md_vector() const
Definition TRUSTVect.h:123