Merge branch 'master' of github.com:JamesEMcClure/LBPM-WIA
This commit is contained in:
@@ -35,6 +35,9 @@ ADD_LBPM_TEST_PARALLEL( TestMassConservationD3Q7 1 )
|
||||
ADD_LBPM_TEST_1_2_4( testCommunication )
|
||||
ADD_LBPM_TEST_1_2_4( testUtilities )
|
||||
ADD_LBPM_TEST( TestWriter )
|
||||
IF ( USE_NETCDF )
|
||||
ADD_LBPM_PROVISIONAL_TEST( TestNetcdf )
|
||||
ENDIF()
|
||||
|
||||
# Sample test that will run with 1, 2, and 4 processors, failing with 4 or more procs
|
||||
ADD_LBPM_TEST_1_2_4( hello_world )
|
||||
|
||||
57
tests/TestNetcdf.cpp
Normal file
57
tests/TestNetcdf.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
// Sequential blob analysis
|
||||
// Reads parallel simulation data and performs connectivity analysis
|
||||
// and averaging on a blob-by-blob basis
|
||||
// James E. McClure 2014
|
||||
|
||||
#include "IO/netcdf.h"
|
||||
|
||||
#include "ProfilerApp.h"
|
||||
|
||||
|
||||
void load( const std::string filename )
|
||||
{
|
||||
int fid = netcdf::open( filename );
|
||||
|
||||
std::vector<std::string> vars = netcdf::getVarNames( fid );
|
||||
for (size_t i=0; i<vars.size(); i++) {
|
||||
printf("Reading variable %s\n",vars[i].c_str());
|
||||
netcdf::VariableType type = netcdf::getVarType( fid, vars[i] );
|
||||
if ( type == netcdf::STRING )
|
||||
Array<std::string> tmp = netcdf::getVar<std::string>( fid, vars[i] );
|
||||
else if ( type == netcdf::SHORT )
|
||||
Array<short> tmp = netcdf::getVar<short>( fid, vars[i] );
|
||||
else
|
||||
Array<double> tmp = netcdf::getVar<double>( fid, vars[i] );
|
||||
}
|
||||
|
||||
std::vector<std::string> attr = netcdf::getAttNames( fid );
|
||||
for (size_t i=0; i<attr.size(); i++) {
|
||||
printf("Reading attribute %s\n",attr[i].c_str());
|
||||
netcdf::VariableType type = netcdf::getAttType( fid, attr[i] );
|
||||
if ( type == netcdf::STRING )
|
||||
Array<std::string> tmp = netcdf::getAtt<std::string>( fid, attr[i] );
|
||||
else
|
||||
Array<double> tmp = netcdf::getAtt<double>( fid, attr[i] );
|
||||
}
|
||||
netcdf::close( fid );
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
PROFILE_START("Main");
|
||||
|
||||
std::vector<std::string> filenames;
|
||||
|
||||
if ( argc==0 ) {
|
||||
printf("At least one filename must be specified\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
for (int i=1; i<argc; i++)
|
||||
load( argv[i] );
|
||||
|
||||
PROFILE_SAVE("TestNetcdf");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,14 @@ int main(int argc, char **argv)
|
||||
MPI_Comm comm = MPI_COMM_WORLD;
|
||||
MPI_Comm_rank(comm,&rank);
|
||||
MPI_Comm_size(comm,&nprocs);
|
||||
|
||||
|
||||
|
||||
int SOLID=atoi(argv[1]);
|
||||
int NWP=atoi(argv[2]);
|
||||
if (rank==0){
|
||||
printf("Solid Label %i \n",SOLID);
|
||||
printf("NWP Label %i \n",NWP);
|
||||
}
|
||||
//.......................................................................
|
||||
// Reading the domain information file
|
||||
//.......................................................................
|
||||
@@ -183,14 +190,18 @@ int main(int argc, char **argv)
|
||||
int count = 0;
|
||||
N=nx*ny*nz;
|
||||
|
||||
if (rank==0) printf("WARNING: assumed that INPUT: WP(1),NWP(2) OUTPUT will be NWP(1),WP(2) (lbpm_segmented_decomp) \n");
|
||||
//if (rank==0) printf("WARNING: assumed that INPUT: WP(1),NWP(2) OUTPUT will be NWP(1),WP(2) (lbpm_segmented_decomp) \n");
|
||||
// Really need a better way to do this -- this is to flip convention for a particular data set
|
||||
for (k=0;k<nz;k++){
|
||||
for (j=0;j<ny;j++){
|
||||
for (i=0;i<nx;i++){
|
||||
n = k*nx*ny+j*nx+i;
|
||||
if (Dm.id[n] == 1) Dm.id[n]=2;
|
||||
else if (Dm.id[n] == 2) Dm.id[n]=1;
|
||||
n = k*nx*ny+j*nx+i;
|
||||
if (Dm.id[n]==char(SOLID)) Dm.id[n] = 0;
|
||||
else if (Dm.id[n]==char(NWP)) Dm.id[n] = 1;
|
||||
else Dm.id[n] = 2;
|
||||
|
||||
// if (Dm.id[n] == 1) Dm.id[n]=2;
|
||||
//else if (Dm.id[n] == 2) Dm.id[n]=1;
|
||||
// Initialize the solid phase
|
||||
// if (Dm.id[n] == 0) id[n] = 0;
|
||||
// else id[n] = 1;
|
||||
@@ -198,6 +209,27 @@ int main(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
count = 0;
|
||||
int total = 0;
|
||||
int countGlobal = 0;
|
||||
int totalGlobal = 0;
|
||||
for (int k=1; k<Nz-1; k++){
|
||||
for (int j=1; j<Ny-1; j++){
|
||||
for (int i=1; i<Nx-1; i++){
|
||||
n=k*Nx*Ny+j*Nx+i;
|
||||
total++;
|
||||
if (Dm.id[n] == 0){
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
MPI_Allreduce(&count,&countGlobal,1,MPI_INT,MPI_SUM,comm);
|
||||
MPI_Allreduce(&total,&totalGlobal,1,MPI_INT,MPI_SUM,comm);
|
||||
float porosity = float(totalGlobal-countGlobal)/totalGlobal;
|
||||
if (rank==0) printf("Porosity=%f\n",porosity);
|
||||
|
||||
|
||||
char LocalRankFilename[40];
|
||||
|
||||
sprintf(LocalRankFilename,"ID.%05i",rank);
|
||||
|
||||
Reference in New Issue
Block a user