33 scoringManager(mgr),commSize(0),destinationRank(destination),verbose(verbosity)
36 #define DMSG( LVL , MSG ) { if ( verbose > LVL ) { G4cout << MSG << G4endl; } }
40 static const G4int maxelems = 10;
41 os<<
" Name: "<<cnv.
name<<
" with : "<<cnv.
numElems<<
" elements\n";
45 ++i ) os<<
" "<<(cnv.
indexes)[i];
46 if ( cnv.
numElems>maxelems ) os<<
" ...";
52 ++i ) os<<
" "<<(cnv.
values)[i];
53 if ( cnv.
numElems>maxelems ) os<<
" ...";
63 for ( std::map<G4int,G4double*>::const_iterator it =
66 os<<it->first<<
" "<<*(it->second)<<
"\n";
74 DMSG( 2 ,
"Converting G4THitsMap<double> "<<map<<
75 " with name "<<mapName);
77 converted->
name = mapName;
83 std::map<G4int,double*>*
mm = map->
GetMap();
85 for ( std::map<G4int,G4double*>::const_iterator it = mm->begin();
86 it != mm->end() ; ++it ) {
88 (converted->
indexes)[counter] = it->first;
89 (converted->
values)[counter++] = *(it->second);
91 DMSG( 2 ,
"Converted to: "<<*converted );
98 DMSG(2,
"Coverting G4VScoringMesh: "<<mesh);
101 DMSG(2,
"Converting "<<map.size()<<
" score maps");
102 for ( MeshScoreMap::const_iterator it = map.begin() ;
103 it != map.end() ; ++it )
107 DMSG(2,
"Conversion of G4VScoringMesh: "<<mesh<<
" done");
113 for ( std::vector<convMap_t*>::iterator it =
convertedMesh.begin() ;
116 delete[] (*it)->indexes;
117 delete[] (*it)->values;
127 DMSG(0,
"G4MPIScorerMerger::Merge() called");
128 G4int myrank = MPI::COMM_WORLD.Get_rank();
129 commSize = MPI::COMM_WORLD.Get_size();
143 DMSG(0,
"G4MPIScorerMerger::Merge done");
154 DMSG(2,
"Sending "<<numelems<<
" maps");
157 for ( std::vector<convMap_t*>::const_iterator it =
convertedMesh.begin() ;
160 DMSG(2,
"Sending map: "<<elem);
170 DMSG(1,
"Sending of mesh with ID: "<<
meshID<<
" Done.");
175 DMSG(1,
"Receiving of mesh");
182 for (
G4int i = 0 ; i<numElems ; ++i ) {
187 G4int strlen = status.Get_count(MPI::CHAR);
188 char* buf =
new char[strlen];
202 DMSG(2,
"Received one mesh map: "<<*elem);
208 DMSG(1,
"Receiving of mesh done");
213 DMSG(2,
"Merging one mesh");
217 msg<<
"Cannot find mesh with id: "<<
meshID;
221 for ( std::vector<convMap_t*>::const_iterator it =
convertedMesh.begin() ;
230 DMSG(3,
"Received mesh: "<<
hc);
232 DMSG(3,
"Original mesh after accumulation: "
235 DMSG(2,
"Merging one mesh done");
std::vector< convMap_t * > convertedMesh
const G4String & GetWorldName() const
std::ostringstream G4ExceptionDescription
std::map< G4String, G4THitsMap< G4double > * > MeshScoreMap
const G4double hc
[MeV*fm]
void Accumulate(G4THitsMap< G4double > *map)
virtual convMap_t * convertMap(const G4String &mapName, G4THitsMap< double > *map) const
virtual void SendOneMesh()
virtual void ReceiveOneMesh()
virtual size_t GetSize() const
G4MPIScorerMerger(G4ScoringManager *mgr, G4int destination=G4MPImanager::kRANK_MASTER, G4int verbosity=0)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
virtual void MergeOneMesh()
MPI::Intracomm COMM_G4COMMAND_
MeshScoreMap GetScoreMap() const
virtual void convertMesh(const G4VScoringMesh *mesh)
std::map< G4int, T * > * GetMap() const
std::ostream & operator<<(std::ostream &os, const G4MPIScorerMerger::convMap_t &cnv)
static G4String Status(G4StepStatus stps)
size_t GetNumberOfMesh() const
G4VScoringMesh * GetMesh(G4int i) const
G4ScoringManager * scoringManager