OpenRadioss 2025.1.11
OpenRadioss project
Loading...
Searching...
No Matches
c_domain_decomposition_rbody.cpp
Go to the documentation of this file.
1//Copyright> OpenRadioss
2//Copyright> Copyright (C) 1986-2025 Altair Engineering Inc.
3//Copyright>
4//Copyright> This program is free software: you can redistribute it and/or modify
5//Copyright> it under the terms of the GNU Affero General Public License as published by
6//Copyright> the Free Software Foundation, either version 3 of the License, or
7//Copyright> (at your option) any later version.
8//Copyright>
9//Copyright> This program is distributed in the hope that it will be useful,
10//Copyright> but WITHOUT ANY WARRANTY; without even the implied warranty of
11//Copyright> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12//Copyright> GNU Affero General Public License for more details.
13//Copyright>
14//Copyright> You should have received a copy of the GNU Affero General Public License
15//Copyright> along with this program. If not, see <https://www.gnu.org/licenses/>.
16//Copyright>
17//Copyright>
18//Copyright> Commercial Alternative: Altair Radioss Software
19//Copyright>
20//Copyright> As an alternative to this open-source version, Altair also offers Altair Radioss
21//Copyright> software under a commercial license. Contact Altair to discuss further if the
22//Copyright> commercial version may interest you: https://www.altair.com/radioss/.
23#include <iostream>
24#include <vector>
25#include <map>
26
27#define _FCALL
28
29
30// global vector of hash table
31std::vector<std::vector<int>> rbody;
32
33
34/* ***************************************************************
35c_prevent_decomposition_rbody : create a list of element
36input : * rbodysize : size of the list (type = integer)
37 * elements : list of element (type = integer)
38*************************************************************** */
39extern "C" {
40 void c_prevent_decomposition_rbody_(int * rbodysize, int * elements )
41 {
42 const int cs = (*rbodysize);
43 rbody.emplace_back(elements, elements+cs);
44 }
45
46/* ***************************************************************
47c_enforce_constraints_rbody : stick a list of element on a given processor
48 2 strategies : * stick all the elements of the rigid body on the processor P
49 with the lowest total number of element
50 * stick all the elements of the rigid body on the processor P
51 with the lowest total number of rigid body
52
53input : * cep : connectivity processor / element (type = integer)
54 * nspmd : number of MPI processor (type = integer)
55 * nrby : number of rigid body (type = integer)
56*************************************************************** */
57 void c_enforce_constraints_rbody_(int * cep, int * nspmd, int * nrby )
58 {
59
60
61 int const number_proc = *nspmd ;
62
63 std::vector<int> compteur(*nspmd,0);
64 std::vector<int> compteur_2(*nspmd,0);
65
66 for(const auto & c : rbody)
67 {
68
69 for(int i=0 ; i<number_proc ; i++)
70 {
71 compteur_2[i] = 0 ;
72 }
73
74 for(const auto & v : c)
75 {
76 compteur_2[ cep[v-1]-1 ] += 1 ;
77 }
78
79 int id_proc, number_element,number_rby ;
80 id_proc = -1 ;
81 number_element= -1 ;
82 number_rby= *nrby + 1 ;
83// ----------------------------------------------------
84// stick all the elements of the rigid body on the processor P
85// with the lowest total number of element
86
87/* for(int i=0 ; i<number_proc ; i++){
88 if(number_element<compteur_2[i]){
89 id_proc = i+1 ;
90 number_element=compteur_2[i] ;
91 }
92 }
93// ----------------------------------------------------
94*/
95// ----------------------------------------------------
96// stick all the elements of the rigid body on the processor P
97// with the lowest total number of rigid body
98 // find id_proc : the processor ID with the lowest number of /RBODY
99 for(int i=0 ; i<number_proc ; i++){
100 if(compteur_2[i]>0 && compteur[i]<number_rby){
101 id_proc = i+1 ;
102 number_rby = compteur[i] ;
103 }
104 }
105 // stick the element v-1 to id_proc
106 int domain = id_proc;
107 compteur[domain-1] = compteur[domain-1] + 1 ;
108 for(const auto & v : c)
109 {
110 cep[v-1] = domain;
111 }
112// ----------------------------------------------------
113 }
114 rbody.clear();
115 }
116
117
118 // Fortran 2 C porting
119 void _FCALL C_PREVENT_DECOMPOSITION_RBODY(int * rbodysize, int * elements)
120 {
121 c_prevent_decomposition_rbody_(rbodysize,elements);
122 }
123 void c_prvent_decomposition_rbody__(int * rbodysize, int * elements)
124 {
125 c_prevent_decomposition_rbody_(rbodysize,elements);
126 }
127 void c_prevent_decomposition_rbody(int * rbodysize,int * elements)
128 {
129 c_prevent_decomposition_rbody_(rbodysize,elements);
130 }
131
132 void _FCALL C_ENFORCE_CONSTRAINTS_RBODY(int * cep, int * nspmd, int * nrby)
133 {
135 }
136 void c_enforce_constraints_rbody__(int * cep , int * nspmd, int * nrby )
137 {
139 }
140 void c_enforce_constraints_rbody(int * cep, int * nspmd, int * nrby)
141 {
143 }
144
145}
void c_prvent_decomposition_rbody__(int *rbodysize, int *elements)
std::vector< std::vector< int > > rbody
void c_enforce_constraints_rbody(int *cep, int *nspmd, int *nrby)
void c_prevent_decomposition_rbody(int *rbodysize, int *elements)
void _FCALL C_ENFORCE_CONSTRAINTS_RBODY(int *cep, int *nspmd, int *nrby)
void _FCALL C_PREVENT_DECOMPOSITION_RBODY(int *rbodysize, int *elements)
void c_enforce_constraints_rbody__(int *cep, int *nspmd, int *nrby)
void c_enforce_constraints_rbody_(int *cep, int *nspmd, int *nrby)
void c_prevent_decomposition_rbody_(int *rbodysize, int *elements)
#define _FCALL
static int nspmd
Definition rad2rad_c.c:126