fix sumreduce
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#include "IO/MeshDatabase.h"
|
||||
#include "IO/IOHelpers.h"
|
||||
#include "IO/silo.h"
|
||||
#include "common/MPI_Helpers.h"
|
||||
#include "common/MPI.h"
|
||||
#include "common/Utilities.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
@@ -36,7 +36,7 @@ void IO::initialize( const std::string& path, const std::string& format, bool ap
|
||||
global_IO_format = Format::SILO;
|
||||
else
|
||||
ERROR("Unknown format");
|
||||
int rank = comm_rank(MPI_COMM_WORLD);
|
||||
int rank = Utilities::MPI(MPI_COMM_WORLD).getRank();
|
||||
if ( !append && rank==0 ) {
|
||||
mkdir(path.c_str(),S_IRWXU|S_IRGRP);
|
||||
std::string filename;
|
||||
@@ -55,7 +55,7 @@ void IO::initialize( const std::string& path, const std::string& format, bool ap
|
||||
// Write the mesh data in the original format
|
||||
static std::vector<IO::MeshDatabase> writeMeshesOrigFormat( const std::vector<IO::MeshDataStruct>& meshData, const std::string& path )
|
||||
{
|
||||
int rank = MPI_WORLD_RANK();
|
||||
int rank = Utilities::MPI(MPI_COMM_WORLD).getRank();
|
||||
std::vector<IO::MeshDatabase> meshes_written;
|
||||
for (size_t i=0; i<meshData.size(); i++) {
|
||||
char domainname[100], filename[100], fullpath[200];
|
||||
@@ -120,7 +120,7 @@ static std::vector<IO::MeshDatabase> writeMeshesOrigFormat( const std::vector<IO
|
||||
// Create the database entry for the mesh data
|
||||
static IO::MeshDatabase getDatabase( const std::string& filename, const IO::MeshDataStruct& mesh, int format )
|
||||
{
|
||||
int rank = MPI_WORLD_RANK();
|
||||
int rank = Utilities::MPI(MPI_COMM_WORLD).getRank();
|
||||
char domainname[100];
|
||||
sprintf(domainname,"%s_%05i",mesh.meshName.c_str(),rank);
|
||||
// Create the MeshDatabase
|
||||
@@ -161,7 +161,7 @@ static IO::MeshDatabase write_domain( FILE *fid, const std::string& filename,
|
||||
const IO::MeshDataStruct& mesh, int format )
|
||||
{
|
||||
const int level = 0;
|
||||
int rank = MPI_WORLD_RANK();
|
||||
int rank = Utilities::MPI(MPI_COMM_WORLD).getRank();
|
||||
// Create the MeshDatabase
|
||||
IO::MeshDatabase database = getDatabase( filename, mesh, format );
|
||||
// Write the mesh
|
||||
@@ -399,7 +399,7 @@ void writeSiloSummary( const std::vector<IO::MeshDatabase>& meshes_written, cons
|
||||
static std::vector<IO::MeshDatabase> writeMeshesNewFormat(
|
||||
const std::vector<IO::MeshDataStruct>& meshData, const std::string& path, int format )
|
||||
{
|
||||
int rank = MPI_WORLD_RANK();
|
||||
int rank = Utilities::MPI(MPI_COMM_WORLD).getRank();
|
||||
std::vector<IO::MeshDatabase> meshes_written;
|
||||
char filename[100], fullpath[200];
|
||||
sprintf(filename,"%05i",rank);
|
||||
@@ -419,7 +419,7 @@ static std::vector<IO::MeshDatabase> writeMeshesSilo(
|
||||
const std::vector<IO::MeshDataStruct>& meshData, const std::string& path, int format )
|
||||
{
|
||||
#ifdef USE_SILO
|
||||
int rank = MPI_WORLD_RANK();
|
||||
int rank = Utilities::MPI(MPI_COMM_WORLD).getRank();
|
||||
std::vector<IO::MeshDatabase> meshes_written;
|
||||
char filename[100], fullpath[200];
|
||||
sprintf(filename,"%05i.silo",rank);
|
||||
@@ -441,12 +441,12 @@ static std::vector<IO::MeshDatabase> writeMeshesSilo(
|
||||
/****************************************************
|
||||
* Write the mesh data *
|
||||
****************************************************/
|
||||
void IO::writeData( const std::string& subdir, const std::vector<IO::MeshDataStruct>& meshData, MPI_Comm comm )
|
||||
void IO::writeData( const std::string& subdir, const std::vector<IO::MeshDataStruct>& meshData, const Utilities::MPI& comm )
|
||||
{
|
||||
if ( global_IO_path.empty() )
|
||||
IO::initialize( );
|
||||
PROFILE_START("writeData");
|
||||
int rank = comm_rank(comm);
|
||||
int rank = Utilities::MPI(MPI_COMM_WORLD).getRank();
|
||||
// Check the meshData before writing
|
||||
for ( const auto& data : meshData ) {
|
||||
if ( !data.check() )
|
||||
@@ -457,7 +457,7 @@ void IO::writeData( const std::string& subdir, const std::vector<IO::MeshDataStr
|
||||
if ( rank == 0 ) {
|
||||
mkdir(path.c_str(),S_IRWXU|S_IRGRP);
|
||||
}
|
||||
MPI_Barrier(comm);
|
||||
comm.barrier();
|
||||
// Write the mesh files
|
||||
std::vector<IO::MeshDatabase> meshes_written;
|
||||
if ( global_IO_format == Format::OLD ) {
|
||||
|
||||
@@ -34,7 +34,7 @@ void initialize( const std::string& path="", const std::string& format="silo", b
|
||||
* @param[in] meshData The data to write
|
||||
* @param[in] comm The comm to use for writing (usually MPI_COMM_WORLD or a dup thereof)
|
||||
*/
|
||||
void writeData( const std::string& subdir, const std::vector<IO::MeshDataStruct>& meshData, MPI_Comm comm );
|
||||
void writeData( const std::string& subdir, const std::vector<IO::MeshDataStruct>& meshData, const Utilities::MPI& comm );
|
||||
|
||||
|
||||
/*!
|
||||
@@ -44,7 +44,7 @@ void writeData( const std::string& subdir, const std::vector<IO::MeshDataStruct>
|
||||
* @param[in] meshData The data to write
|
||||
* @param[in] comm The comm to use for writing (usually MPI_COMM_WORLD or a dup thereof)
|
||||
*/
|
||||
inline void writeData( int timestep, const std::vector<IO::MeshDataStruct>& meshData, MPI_Comm comm )
|
||||
inline void writeData( int timestep, const std::vector<IO::MeshDataStruct>& meshData, const Utilities::MPI& comm )
|
||||
{
|
||||
char subdir[100];
|
||||
sprintf(subdir,"vis%03i",timestep);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#include "analysis/ElectroChemistry.h"
|
||||
|
||||
ElectroChemistryAnalyzer::ElectroChemistryAnalyzer(std::shared_ptr <Domain> dm):
|
||||
Dm(dm),
|
||||
fillData(dm->Comm,dm->rank_info,{dm->Nx-2,dm->Ny-2,dm->Nz-2},{1,1,1},0,1)
|
||||
Dm(dm)
|
||||
{
|
||||
|
||||
Nx=dm->Nx; Ny=dm->Ny; Nz=dm->Nz;
|
||||
@@ -130,7 +129,10 @@ void ElectroChemistryAnalyzer::Basic(ScaLBL_IonModel &Ion, ScaLBL_Poisson &Poiss
|
||||
void ElectroChemistryAnalyzer::WriteVis( ScaLBL_IonModel &Ion, ScaLBL_Poisson &Poisson, ScaLBL_StokesModel &Stokes, std::shared_ptr<Database> input_db, int timestep){
|
||||
|
||||
auto vis_db = input_db->getDatabase( "Visualization" );
|
||||
char VisName[40];
|
||||
char VisName[40];
|
||||
|
||||
std::vector<IO::MeshDataStruct> visData;
|
||||
fillHalo<double> fillData(Dm->Comm,Dm->rank_info,{Dm->Nx-2,Dm->Ny-2,Dm->Nz-2},{1,1,1},0,1);
|
||||
|
||||
IO::initialize("","silo","false");
|
||||
// Create the MeshDataStruct
|
||||
@@ -216,7 +218,7 @@ void ElectroChemistryAnalyzer::WriteVis( ScaLBL_IonModel &Ion, ScaLBL_Poisson &P
|
||||
}
|
||||
|
||||
if (vis_db->getWithDefault<bool>( "write_silo", true ))
|
||||
IO::writeData( timestep, visData, Dm->Comm.comm );
|
||||
IO::writeData( timestep, visData, Dm->Comm );
|
||||
|
||||
/* if (vis_db->getWithDefault<bool>( "save_8bit_raw", true )){
|
||||
char CurrentIDFilename[40];
|
||||
|
||||
@@ -7,12 +7,12 @@
|
||||
|
||||
#include <vector>
|
||||
#include "common/Domain.h"
|
||||
#include "common/Utilities.h"
|
||||
#include "common/MPI_Helpers.h"
|
||||
#include "common/Communication.h"
|
||||
#include "analysis/analysis.h"
|
||||
#include "analysis/distance.h"
|
||||
#include "analysis/Minkowski.h"
|
||||
#include "common/Utilities.h"
|
||||
#include "common/MPI_Helpers.h"
|
||||
#include "IO/MeshDatabase.h"
|
||||
#include "IO/Reader.h"
|
||||
#include "IO/Writer.h"
|
||||
@@ -49,8 +49,6 @@ public:
|
||||
void WriteVis( ScaLBL_IonModel &Ion, ScaLBL_Poisson &Poisson, ScaLBL_StokesModel &Stokes, std::shared_ptr<Database> input_db, int timestep);
|
||||
|
||||
private:
|
||||
std::vector<IO::MeshDataStruct> visData;
|
||||
fillHalo<double> fillData;
|
||||
FILE *TIMELOG;
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -229,25 +229,25 @@ void SubPhase::Basic(){
|
||||
}
|
||||
}
|
||||
}
|
||||
gwb.V=sumReduce( Dm->Comm, wb.V);
|
||||
gnb.V=sumReduce( Dm->Comm, nb.V);
|
||||
gwb.M=sumReduce( Dm->Comm, wb.M);
|
||||
gnb.M=sumReduce( Dm->Comm, nb.M);
|
||||
gwb.Px=sumReduce( Dm->Comm, wb.Px);
|
||||
gwb.Py=sumReduce( Dm->Comm, wb.Py);
|
||||
gwb.Pz=sumReduce( Dm->Comm, wb.Pz);
|
||||
gnb.Px=sumReduce( Dm->Comm, nb.Px);
|
||||
gnb.Py=sumReduce( Dm->Comm, nb.Py);
|
||||
gnb.Pz=sumReduce( Dm->Comm, nb.Pz);
|
||||
gwb.V=Dm->Comm.sumReduce( wb.V);
|
||||
gnb.V=Dm->Comm.sumReduce( nb.V);
|
||||
gwb.M=Dm->Comm.sumReduce( wb.M);
|
||||
gnb.M=Dm->Comm.sumReduce( nb.M);
|
||||
gwb.Px=Dm->Comm.sumReduce( wb.Px);
|
||||
gwb.Py=Dm->Comm.sumReduce( wb.Py);
|
||||
gwb.Pz=Dm->Comm.sumReduce( wb.Pz);
|
||||
gnb.Px=Dm->Comm.sumReduce( nb.Px);
|
||||
gnb.Py=Dm->Comm.sumReduce( nb.Py);
|
||||
gnb.Pz=Dm->Comm.sumReduce( nb.Pz);
|
||||
|
||||
count_w=sumReduce( Dm->Comm, count_w);
|
||||
count_n=sumReduce( Dm->Comm, count_n);
|
||||
count_w=Dm->Comm.sumReduce( count_w);
|
||||
count_n=Dm->Comm.sumReduce( count_n);
|
||||
if (count_w > 0.0)
|
||||
gwb.p=sumReduce( Dm->Comm, wb.p) / count_w;
|
||||
gwb.p=Dm->Comm.sumReduce( wb.p) / count_w;
|
||||
else
|
||||
gwb.p = 0.0;
|
||||
if (count_n > 0.0)
|
||||
gnb.p=sumReduce( Dm->Comm, nb.p) / count_n;
|
||||
gnb.p=Dm->Comm.sumReduce( nb.p) / count_n;
|
||||
else
|
||||
gnb.p = 0.0;
|
||||
|
||||
@@ -445,14 +445,14 @@ void SubPhase::Full(){
|
||||
nd.X -= nc.X;
|
||||
|
||||
// compute global entities
|
||||
gnc.V=sumReduce( Dm->Comm, nc.V);
|
||||
gnc.A=sumReduce( Dm->Comm, nc.A);
|
||||
gnc.H=sumReduce( Dm->Comm, nc.H);
|
||||
gnc.X=sumReduce( Dm->Comm, nc.X);
|
||||
gnd.V=sumReduce( Dm->Comm, nd.V);
|
||||
gnd.A=sumReduce( Dm->Comm, nd.A);
|
||||
gnd.H=sumReduce( Dm->Comm, nd.H);
|
||||
gnd.X=sumReduce( Dm->Comm, nd.X);
|
||||
gnc.V=Dm->Comm.sumReduce( nc.V);
|
||||
gnc.A=Dm->Comm.sumReduce( nc.A);
|
||||
gnc.H=Dm->Comm.sumReduce( nc.H);
|
||||
gnc.X=Dm->Comm.sumReduce( nc.X);
|
||||
gnd.V=Dm->Comm.sumReduce( nd.V);
|
||||
gnd.A=Dm->Comm.sumReduce( nd.A);
|
||||
gnd.H=Dm->Comm.sumReduce( nd.H);
|
||||
gnd.X=Dm->Comm.sumReduce( nd.X);
|
||||
gnd.Nc = nd.Nc;
|
||||
// wetting
|
||||
for (k=0; k<Nz; k++){
|
||||
@@ -492,14 +492,14 @@ void SubPhase::Full(){
|
||||
wd.H -= wc.H;
|
||||
wd.X -= wc.X;
|
||||
// compute global entities
|
||||
gwc.V=sumReduce( Dm->Comm, wc.V);
|
||||
gwc.A=sumReduce( Dm->Comm, wc.A);
|
||||
gwc.H=sumReduce( Dm->Comm, wc.H);
|
||||
gwc.X=sumReduce( Dm->Comm, wc.X);
|
||||
gwd.V=sumReduce( Dm->Comm, wd.V);
|
||||
gwd.A=sumReduce( Dm->Comm, wd.A);
|
||||
gwd.H=sumReduce( Dm->Comm, wd.H);
|
||||
gwd.X=sumReduce( Dm->Comm, wd.X);
|
||||
gwc.V=Dm->Comm.sumReduce( wc.V);
|
||||
gwc.A=Dm->Comm.sumReduce( wc.A);
|
||||
gwc.H=Dm->Comm.sumReduce( wc.H);
|
||||
gwc.X=Dm->Comm.sumReduce( wc.X);
|
||||
gwd.V=Dm->Comm.sumReduce( wd.V);
|
||||
gwd.A=Dm->Comm.sumReduce( wd.A);
|
||||
gwd.H=Dm->Comm.sumReduce( wd.H);
|
||||
gwd.X=Dm->Comm.sumReduce( wd.X);
|
||||
gwd.Nc = wd.Nc;
|
||||
|
||||
/* Set up geometric analysis of interface region */
|
||||
@@ -527,20 +527,20 @@ void SubPhase::Full(){
|
||||
iwn.A = morph_i->A();
|
||||
iwn.H = morph_i->H();
|
||||
iwn.X = morph_i->X();
|
||||
giwn.V=sumReduce( Dm->Comm, iwn.V);
|
||||
giwn.A=sumReduce( Dm->Comm, iwn.A);
|
||||
giwn.H=sumReduce( Dm->Comm, iwn.H);
|
||||
giwn.X=sumReduce( Dm->Comm, iwn.X);
|
||||
giwn.V=Dm->Comm.sumReduce( iwn.V);
|
||||
giwn.A=Dm->Comm.sumReduce( iwn.A);
|
||||
giwn.H=Dm->Comm.sumReduce( iwn.H);
|
||||
giwn.X=Dm->Comm.sumReduce( iwn.X);
|
||||
// measure only the connected part
|
||||
iwnc.Nc = morph_i->MeasureConnectedPathway();
|
||||
iwnc.V = morph_i->V();
|
||||
iwnc.A = morph_i->A();
|
||||
iwnc.H = morph_i->H();
|
||||
iwnc.X = morph_i->X();
|
||||
giwnc.V=sumReduce( Dm->Comm, iwnc.V);
|
||||
giwnc.A=sumReduce( Dm->Comm, iwnc.A);
|
||||
giwnc.H=sumReduce( Dm->Comm, iwnc.H);
|
||||
giwnc.X=sumReduce( Dm->Comm, iwnc.X);
|
||||
giwnc.V=Dm->Comm.sumReduce( iwnc.V);
|
||||
giwnc.A=Dm->Comm.sumReduce( iwnc.A);
|
||||
giwnc.H=Dm->Comm.sumReduce( iwnc.H);
|
||||
giwnc.X=Dm->Comm.sumReduce( iwnc.X);
|
||||
giwnc.Nc = iwnc.Nc;
|
||||
|
||||
double vol_nc_bulk = 0.0;
|
||||
@@ -631,46 +631,46 @@ void SubPhase::Full(){
|
||||
}
|
||||
}
|
||||
|
||||
gnd.M=sumReduce( Dm->Comm, nd.M);
|
||||
gnd.Px=sumReduce( Dm->Comm, nd.Px);
|
||||
gnd.Py=sumReduce( Dm->Comm, nd.Py);
|
||||
gnd.Pz=sumReduce( Dm->Comm, nd.Pz);
|
||||
gnd.K=sumReduce( Dm->Comm, nd.K);
|
||||
gnd.M=Dm->Comm.sumReduce( nd.M);
|
||||
gnd.Px=Dm->Comm.sumReduce( nd.Px);
|
||||
gnd.Py=Dm->Comm.sumReduce( nd.Py);
|
||||
gnd.Pz=Dm->Comm.sumReduce( nd.Pz);
|
||||
gnd.K=Dm->Comm.sumReduce( nd.K);
|
||||
|
||||
gwd.M=sumReduce( Dm->Comm, wd.M);
|
||||
gwd.Px=sumReduce( Dm->Comm, wd.Px);
|
||||
gwd.Py=sumReduce( Dm->Comm, wd.Py);
|
||||
gwd.Pz=sumReduce( Dm->Comm, wd.Pz);
|
||||
gwd.K=sumReduce( Dm->Comm, wd.K);
|
||||
gwd.M=Dm->Comm.sumReduce( wd.M);
|
||||
gwd.Px=Dm->Comm.sumReduce( wd.Px);
|
||||
gwd.Py=Dm->Comm.sumReduce( wd.Py);
|
||||
gwd.Pz=Dm->Comm.sumReduce( wd.Pz);
|
||||
gwd.K=Dm->Comm.sumReduce( wd.K);
|
||||
|
||||
gnc.M=sumReduce( Dm->Comm, nc.M);
|
||||
gnc.Px=sumReduce( Dm->Comm, nc.Px);
|
||||
gnc.Py=sumReduce( Dm->Comm, nc.Py);
|
||||
gnc.Pz=sumReduce( Dm->Comm, nc.Pz);
|
||||
gnc.K=sumReduce( Dm->Comm, nc.K);
|
||||
gnc.M=Dm->Comm.sumReduce( nc.M);
|
||||
gnc.Px=Dm->Comm.sumReduce( nc.Px);
|
||||
gnc.Py=Dm->Comm.sumReduce( nc.Py);
|
||||
gnc.Pz=Dm->Comm.sumReduce( nc.Pz);
|
||||
gnc.K=Dm->Comm.sumReduce( nc.K);
|
||||
|
||||
gwc.M=sumReduce( Dm->Comm, wc.M);
|
||||
gwc.Px=sumReduce( Dm->Comm, wc.Px);
|
||||
gwc.Py=sumReduce( Dm->Comm, wc.Py);
|
||||
gwc.Pz=sumReduce( Dm->Comm, wc.Pz);
|
||||
gwc.K=sumReduce( Dm->Comm, wc.K);
|
||||
gwc.M=Dm->Comm.sumReduce( wc.M);
|
||||
gwc.Px=Dm->Comm.sumReduce( wc.Px);
|
||||
gwc.Py=Dm->Comm.sumReduce( wc.Py);
|
||||
gwc.Pz=Dm->Comm.sumReduce( wc.Pz);
|
||||
gwc.K=Dm->Comm.sumReduce( wc.K);
|
||||
|
||||
giwn.Mn=sumReduce( Dm->Comm, iwn.Mn);
|
||||
giwn.Pnx=sumReduce( Dm->Comm, iwn.Pnx);
|
||||
giwn.Pny=sumReduce( Dm->Comm, iwn.Pny);
|
||||
giwn.Pnz=sumReduce( Dm->Comm, iwn.Pnz);
|
||||
giwn.Kn=sumReduce( Dm->Comm, iwn.Kn);
|
||||
giwn.Mw=sumReduce( Dm->Comm, iwn.Mw);
|
||||
giwn.Pwx=sumReduce( Dm->Comm, iwn.Pwx);
|
||||
giwn.Pwy=sumReduce( Dm->Comm, iwn.Pwy);
|
||||
giwn.Pwz=sumReduce( Dm->Comm, iwn.Pwz);
|
||||
giwn.Kw=sumReduce( Dm->Comm, iwn.Kw);
|
||||
giwn.Mn=Dm->Comm.sumReduce( iwn.Mn);
|
||||
giwn.Pnx=Dm->Comm.sumReduce( iwn.Pnx);
|
||||
giwn.Pny=Dm->Comm.sumReduce( iwn.Pny);
|
||||
giwn.Pnz=Dm->Comm.sumReduce( iwn.Pnz);
|
||||
giwn.Kn=Dm->Comm.sumReduce( iwn.Kn);
|
||||
giwn.Mw=Dm->Comm.sumReduce( iwn.Mw);
|
||||
giwn.Pwx=Dm->Comm.sumReduce( iwn.Pwx);
|
||||
giwn.Pwy=Dm->Comm.sumReduce( iwn.Pwy);
|
||||
giwn.Pwz=Dm->Comm.sumReduce( iwn.Pwz);
|
||||
giwn.Kw=Dm->Comm.sumReduce( iwn.Kw);
|
||||
|
||||
// pressure averaging
|
||||
gnc.p=sumReduce( Dm->Comm, nc.p);
|
||||
gnd.p=sumReduce( Dm->Comm, nd.p);
|
||||
gwc.p=sumReduce( Dm->Comm, wc.p);
|
||||
gwd.p=sumReduce( Dm->Comm, wd.p);
|
||||
gnc.p=Dm->Comm.sumReduce( nc.p);
|
||||
gnd.p=Dm->Comm.sumReduce( nd.p);
|
||||
gwc.p=Dm->Comm.sumReduce( wc.p);
|
||||
gwd.p=Dm->Comm.sumReduce( wd.p);
|
||||
|
||||
if (vol_wc_bulk > 0.0)
|
||||
wc.p = wc.p /vol_wc_bulk;
|
||||
@@ -681,10 +681,10 @@ void SubPhase::Full(){
|
||||
if (vol_nd_bulk > 0.0)
|
||||
nd.p = nd.p /vol_nd_bulk;
|
||||
|
||||
vol_wc_bulk=sumReduce( Dm->Comm, vol_wc_bulk);
|
||||
vol_wd_bulk=sumReduce( Dm->Comm, vol_wd_bulk);
|
||||
vol_nc_bulk=sumReduce( Dm->Comm, vol_nc_bulk);
|
||||
vol_nd_bulk=sumReduce( Dm->Comm, vol_nd_bulk);
|
||||
vol_wc_bulk=Dm->Comm.sumReduce( vol_wc_bulk);
|
||||
vol_wd_bulk=Dm->Comm.sumReduce( vol_wd_bulk);
|
||||
vol_nc_bulk=Dm->Comm.sumReduce( vol_nc_bulk);
|
||||
vol_nd_bulk=Dm->Comm.sumReduce( vol_nd_bulk);
|
||||
|
||||
if (vol_wc_bulk > 0.0)
|
||||
gwc.p = gwc.p /vol_wc_bulk;
|
||||
|
||||
Reference in New Issue
Block a user