aboutsummaryrefslogtreecommitdiff
path: root/Carpet/Carpet/src/Restrict.cc
diff options
context:
space:
mode:
authorThomas Radke <tradke@aei.mpg.de>2005-08-15 15:00:00 +0000
committerThomas Radke <tradke@aei.mpg.de>2005-08-15 15:00:00 +0000
commitb3405326ebf651b20b4c44423df62ef23a1bf8f2 (patch)
tree3f28fb7697589ff69ab3ac283cd0064dba340522 /Carpet/Carpet/src/Restrict.cc
parent8493c61f465169c3d52b53b5023680a0d33f898c (diff)
Carpet*: generalise the comm_state class for collective buffer communications
CarpetLib's comm_state class (actually, it's still just a struct) has been extended to handle collective buffer communications for all possible C datatypes at the same time. This makes it unnecessary for the higher-level communication routines to loop over each individual datatype separately. darcs-hash:20050815150023-776a0-dddc1aca7ccaebae872f9f451b2c3595cd951fed.gz
Diffstat (limited to 'Carpet/Carpet/src/Restrict.cc')
-rw-r--r--Carpet/Carpet/src/Restrict.cc40
1 files changed, 11 insertions, 29 deletions
diff --git a/Carpet/Carpet/src/Restrict.cc b/Carpet/Carpet/src/Restrict.cc
index 42d4d8720..e26fb9416 100644
--- a/Carpet/Carpet/src/Restrict.cc
+++ b/Carpet/Carpet/src/Restrict.cc
@@ -16,8 +16,8 @@ namespace Carpet {
using namespace std;
- // restricts a set of groups which all have the same vartype
- static void RestrictGroups (const cGH* cgh, group_set& groups);
+ // restricts a set of groups
+ static void RestrictGroups (const cGH* cgh, const vector<int>& groups);
void Restrict (const cGH* cgh)
@@ -38,52 +38,34 @@ namespace Carpet {
return;
}
- // sort all grid functions into sets of the same vartype
- vector<group_set> groups;
+ // remove all groups with are non-GFs, empty, or have no storage assigned
+ vector<int> groups;
for (int group = 0; group < CCTK_NumGroups(); ++group) {
if (CCTK_GroupTypeI(group) == CCTK_GF
&& CCTK_NumVarsInGroupI(group) > 0
&& CCTK_QueryGroupStorageI(cgh, group)) {
-
- group_set newset;
- const int firstvar = CCTK_FirstVarIndexI (group);
- newset.vartype = CCTK_VarTypeI (firstvar);
- assert (newset.vartype >= 0);
- int c;
- for (c = 0; c < groups.size(); c++) {
- if (newset.vartype == groups[c].vartype) {
- break;
- }
- }
- if (c == groups.size()) {
- groups.push_back (newset);
- }
- groups[c].members.push_back (group);
+ groups.push_back (group);
}
}
// Restrict
- for (int c = 0; c < groups.size(); c++) {
- RestrictGroups (cgh, groups[c]);
- }
+ RestrictGroups (cgh, groups);
// Synchronise
- for (int c = 0; c < groups.size(); c++) {
- SyncGroups (cgh, groups[c]);
- }
+ SyncGroups (cgh, groups);
}
// restricts a set of groups which all have the same vartype
- static void RestrictGroups (const cGH* cgh, group_set& groups) {
+ static void RestrictGroups (const cGH* cgh, const vector<int>& groups) {
DECLARE_CCTK_PARAMETERS;
const int tl = 0;
- for (comm_state state(groups.vartype); ! state.done(); state.step()) {
- for (int c = 0; c < groups.members.size(); ++c) {
- const int group = groups.members[c];
+ for (comm_state state; ! state.done(); state.step()) {
+ for (int c = 0; c < groups.size(); ++c) {
+ const int group = groups[c];
for (int m=0; m<(int)arrdata.at(group).size(); ++m) {
// use background time here (which may not be modified