aboutsummaryrefslogtreecommitdiff
path: root/Carpet
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2006-03-04 17:55:00 +0000
committerErik Schnetter <schnetter@cct.lsu.edu>2006-03-04 17:55:00 +0000
commitbfd9487d8ac6ff53e23de54818c5b76bf50869b8 (patch)
tree4b2dd03aed31f13a0b1e48a5eae37a0b400c3857 /Carpet
parent85e45f4c2513bf9224672926c1667e731a5a8564 (diff)
Carpet: Export some functions to inquire about models
Export functions that convert between model names and ids, and between the processors on which a model runs and the model id. darcs-hash:20060304175543-dae7b-65b8d083983262d05f5950d2af71e5684a90203d.gz
Diffstat (limited to 'Carpet')
-rw-r--r--Carpet/Carpet/src/CarpetStartup.cc2
-rw-r--r--Carpet/Carpet/src/MultiModel.cc55
-rw-r--r--Carpet/Carpet/src/functions.hh22
3 files changed, 70 insertions, 9 deletions
diff --git a/Carpet/Carpet/src/CarpetStartup.cc b/Carpet/Carpet/src/CarpetStartup.cc
index 17b4d9a0e..114495f6a 100644
--- a/Carpet/Carpet/src/CarpetStartup.cc
+++ b/Carpet/Carpet/src/CarpetStartup.cc
@@ -19,7 +19,7 @@ namespace Carpet {
DECLARE_CCTK_PARAMETERS;
comm_universe = MPI_COMM_WORLD;
- SplitWorld (comm_universe, model, comm_world, true);
+ SplitUniverse (comm_universe, model, comm_world, true);
dist::pseudoinit (comm_world);
return 0;
diff --git a/Carpet/Carpet/src/MultiModel.cc b/Carpet/Carpet/src/MultiModel.cc
index 3ab87e323..492e953ea 100644
--- a/Carpet/Carpet/src/MultiModel.cc
+++ b/Carpet/Carpet/src/MultiModel.cc
@@ -9,6 +9,8 @@
#include "cctk.h"
+#include "functions.hh"
+
namespace Carpet
@@ -18,9 +20,50 @@ namespace Carpet
+ vector <string> models; // Model id to model name
+ std::map <string, int> model_map; // Model name to model id
+ vector <int> model_ids; // Processor to model id
+ vector <vector <int> > model_procs; // Model id to processors
+
+
+
+ vector <string> Models () { return models; }
+ std::map <string, int> ModelMap () { return model_map; }
+ vector <int> ModelIds () { return model_ids; }
+ vector <vector <int> > ModelProcs () { return model_procs; }
+
+ string Models (int const id)
+ {
+ return models.at (id);
+ }
+
+ int ModelMap (string const name)
+ {
+ if (model_map.find (name) != model_map.end())
+ {
+ return model_map[name];
+ }
+ else
+ {
+ return -1;
+ }
+ }
+
+ int ModelId (int const proc)
+ {
+ return model_ids.at (proc);
+ }
+
+ vector <int> ModelProcs (int const proc)
+ {
+ return model_procs.at (proc);
+ }
+
+
+
void
- SplitWorld (MPI_Comm const world, string const model, MPI_Comm & comm,
- bool const verbose)
+ SplitUniverse (MPI_Comm const world, string const model, MPI_Comm & comm,
+ bool const verbose)
{
// Get the total number of processors
int num_procs;
@@ -56,7 +99,7 @@ namespace Carpet
world);
// Convert model name buffer with C strings to C++ strings
- vector <string> models (num_procs);
+ models.resize (num_procs);
for (int n = 0; n < num_procs; ++ n)
{
models.at(n)
@@ -65,8 +108,8 @@ namespace Carpet
// Map model strings to small integers
int num_models = 0;
- vector <int> model_ids (num_procs);
- std::map <string, int> model_map;
+ model_ids.resize (num_procs);
+ model_map.clear ();
for (int n = 0; n < num_procs; ++ n)
{
if (model_map.find (models.at(n)) != model_map.end())
@@ -88,7 +131,7 @@ namespace Carpet
++ num_model_procs.at (model_ids.at(n));
}
- vector <vector <int> > model_procs (num_models);
+ model_procs.resize (num_models);
for (int m = 0; m < num_models; ++ m)
{
model_procs.at(m).reserve (num_model_procs.at(m));
diff --git a/Carpet/Carpet/src/functions.hh b/Carpet/Carpet/src/functions.hh
index 2d8866fe2..fbd24115e 100644
--- a/Carpet/Carpet/src/functions.hh
+++ b/Carpet/Carpet/src/functions.hh
@@ -1,6 +1,8 @@
#ifndef FUNCTIONS_HH
#define FUNCTIONS_HH
+#include <map>
+#include <string>
#include <vector>
#include <mpi.h>
@@ -43,8 +45,24 @@ namespace Carpet {
// Multi-Model
void
- SplitWorld (MPI_Comm const world, string const model, MPI_Comm & comm,
- bool verbose);
+ SplitUniverse (MPI_Comm const world, string const model, MPI_Comm & comm,
+ bool verbose);
+
+ // Model id to model name
+ vector <string> Models ();
+ string Model (int id);
+
+ // Model name to model id
+ std::map <string, int> ModelMap ();
+ int ModelMap (string name);
+
+ // Processor to model id
+ vector <int> ModelIds ();
+ int ModelId (int proc);
+
+ // Model id to processors
+ vector <vector <int> > ModelProcs ();
+ vector <int> ModelProcs (int proc);
extern "C" {
CCTK_POINTER_TO_CONST