Working on lbpm_uCT

This commit is contained in:
Mark Berrill
2016-05-25 14:00:28 -04:00
parent 1b36f74bdf
commit b11d2c447e
27 changed files with 658 additions and 681 deletions

View File

@@ -176,7 +176,7 @@ std::shared_ptr<IO::Variable> IO::getVariable( const std::string& path, const st
var->name = variable;
var->data.resize(N);
if ( precision=="double" ) {
memcpy(var->data.get(),data,bytes);
memcpy(var->data.data(),data,bytes);
} else {
ERROR("Format not implimented");
}

View File

@@ -120,7 +120,7 @@ static IO::MeshDatabase write_domain( FILE *fid, const std::string& filename,
int dim = mesh.vars[i]->dim;
int type = static_cast<int>(mesh.vars[i]->type);
size_t N = mesh.vars[i]->data.length();
const double* data = N==0 ? NULL:mesh.vars[i]->data.get();
const double* data = N==0 ? NULL:mesh.vars[i]->data.data();
if ( type == static_cast<int>(IO::NullVariable) ) {
ERROR("Variable type not set");
}

View File

@@ -32,6 +32,44 @@ inline std::vector<TYPE> reverse( const std::vector<TYPE>& x )
y[i] = x[x.size()-i-1];
return y;
}
// Function to reverse an array
template<class TYPE1, class TYPE2>
inline std::vector<TYPE2> convert( const std::vector<TYPE1>& x )
{
std::vector<TYPE2> y(x.size());
for (size_t i=0; i<x.size(); i++)
y[i] = static_cast<TYPE2>(x[i]);
return y;
}
/****************************************************
* Convert the VariableType to a string *
****************************************************/
std::string VariableTypeName( VariableType type )
{
if ( type == BYTE )
return "BYTE";
else if ( type == SHORT )
return "SHORT";
else if ( type == USHORT )
return "USHORT";
else if ( type == INT )
return "INT";
else if ( type == UINT )
return "UINT";
else if ( type == INT64 )
return "INT64";
else if ( type == UINT64 )
return "UINT64";
else if ( type == FLOAT )
return "FLOAT";
else if ( type == DOUBLE )
return "DOUBLE";
else if ( type == STRING )
return "STRING";
return "Unknown";
}
/****************************************************
@@ -170,70 +208,70 @@ Array<unsigned short> getVar<unsigned short>( int fid, const std::string& var )
{
PROFILE_START("getVar<unsigned short>");
Array<unsigned short> x( reverse(getVarDim(fid,var)) );
int err = nc_get_var_ushort( fid, getVarID(fid,var), x.get() );
int err = nc_get_var_ushort( fid, getVarID(fid,var), x.data() );
CHECK_NC_ERR( err );
PROFILE_STOP("getVar<unsigned short>");
return x;
return x.reverseDim();
}
template<>
Array<short> getVar<short>( int fid, const std::string& var )
{
PROFILE_START("getVar<short>");
Array<short> x( reverse(getVarDim(fid,var)) );
int err = nc_get_var_short( fid, getVarID(fid,var), x.get() );
int err = nc_get_var_short( fid, getVarID(fid,var), x.data() );
CHECK_NC_ERR( err );
PROFILE_STOP("getVar<short>");
return x;
return x.reverseDim();
}
template<>
Array<unsigned int> getVar<unsigned int>( int fid, const std::string& var )
{
PROFILE_START("getVar<unsigned int>");
Array<unsigned int> x( reverse(getVarDim(fid,var)) );
int err = nc_get_var_uint( fid, getVarID(fid,var), x.get() );
int err = nc_get_var_uint( fid, getVarID(fid,var), x.data() );
CHECK_NC_ERR( err );
PROFILE_STOP("getVar<unsigned int>");
return x;
return x.reverseDim();
}
template<>
Array<int> getVar<int>( int fid, const std::string& var )
{
PROFILE_START("getVar<int>");
Array<int> x( reverse(getVarDim(fid,var)) );
int err = nc_get_var_int( fid, getVarID(fid,var), x.get() );
int err = nc_get_var_int( fid, getVarID(fid,var), x.data() );
CHECK_NC_ERR( err );
PROFILE_STOP("getVar<int>");
return x;
return x.reverseDim();
}
template<>
Array<float> getVar<float>( int fid, const std::string& var )
{
PROFILE_START("getVar<float>");
Array<float> x( reverse(getVarDim(fid,var)) );
int err = nc_get_var_float( fid, getVarID(fid,var), x.get() );
int err = nc_get_var_float( fid, getVarID(fid,var), x.data() );
CHECK_NC_ERR( err );
PROFILE_STOP("getVar<float>");
return x;
return x.reverseDim();
}
template<>
Array<double> getVar<double>( int fid, const std::string& var )
{
PROFILE_START("getVar<double>");
Array<double> x( reverse(getVarDim(fid,var)) );
int err = nc_get_var_double( fid, getVarID(fid,var), x.get() );
int err = nc_get_var_double( fid, getVarID(fid,var), x.data() );
CHECK_NC_ERR( err );
PROFILE_STOP("getVar<double>");
return x;
return x.reverseDim();
}
template<>
Array<char> getVar<char>( int fid, const std::string& var )
{
PROFILE_START("getVar<char>");
Array<char> x( reverse(getVarDim(fid,var)) );
int err = nc_get_var_text( fid, getVarID(fid,var), x.get() );
int err = nc_get_var_text( fid, getVarID(fid,var), x.data() );
CHECK_NC_ERR( err );
PROFILE_STOP("getVar<char>");
return x;
return x.reverseDim();
}
template<>
Array<std::string> getVar<std::string>( int fid, const std::string& var )
@@ -251,6 +289,31 @@ Array<std::string> getVar<std::string>( int fid, const std::string& var )
PROFILE_STOP("getVar<std::string>");
return text;
}
static inline void get_stride_args( const std::vector<int>& start,
const std::vector<int>& count, const std::vector<int>& stride,
size_t *startp, size_t *countp, ptrdiff_t *stridep )
{
for (size_t i=0; i<start.size(); i++)
startp[i] = start[i];
for (size_t i=0; i<count.size(); i++)
countp[i] = count[i];
for (size_t i=0; i<stride.size(); i++)
stridep[i] = stride[i];
}
template<>
Array<short> getVar<short>( int fid, const std::string& var, const std::vector<int>& start,
const std::vector<int>& count, const std::vector<int>& stride )
{
PROFILE_START("getVar<short> (strided)");
Array<short> x( reverse(convert<int,size_t>(count)) );
size_t startp[10], countp[10];
ptrdiff_t stridep[10];
get_stride_args( start, count, stride, startp, countp, stridep );
int err = nc_get_vars_short( fid, getVarID(fid,var), startp, countp, stridep, x.data() );
CHECK_NC_ERR( err );
PROFILE_STOP("getVar<short> (strided)");
return x.reverseDim();
}
/****************************************************
@@ -261,7 +324,7 @@ Array<double> getAtt<double>( int fid, const std::string& att )
{
PROFILE_START("getAtt<double>");
Array<double> x( getAttDim(fid,att) );
int err = nc_get_att_double( fid, NC_GLOBAL, att.c_str(), x.get() );
int err = nc_get_att_double( fid, NC_GLOBAL, att.c_str(), x.data() );
CHECK_NC_ERR( err );
PROFILE_STOP("getAtt<double>");
return x;

View File

@@ -13,6 +13,9 @@ namespace netcdf {
//! Enum to hold variable type
enum VariableType { BYTE, SHORT, USHORT, INT, UINT, INT64, UINT64, FLOAT, DOUBLE, STRING };
//! Convert the VariableType to a string
std::string VariableTypeName( VariableType type );
/*!
* @brief Open netcdf file
@@ -84,6 +87,20 @@ template<class TYPE>
Array<TYPE> getVar( int fid, const std::string& var );
/*!
* @brief Read a strided variable
* @detailed This function reads a strided variable with the given name from the file
* @param fid Handle to the open file
* @param var Variable to read
* @param start Starting corner for the read
* @param count Number of elements to read
* @param stride Stride size for the read
*/
template<class TYPE>
Array<TYPE> getVar( int fid, const std::string& var, const std::vector<int>& start,
const std::vector<int>& count, const std::vector<int>& stride );
/*!
* @brief Read an attribute
* @detailed This function reads an attribute with the given name from the file

View File

@@ -52,8 +52,8 @@ int ComputeBlob( const Array<bool>& isPhase, BlobIDArray& LocalBlobID, bool peri
int last = start_id-1;
std::vector<int> neighbor_ids;
neighbor_ids.reserve(N_neighbors);
const bool *isPhasePtr = isPhase.get();
BlobIDType *LocalBlobIDPtr = LocalBlobID.get();
const bool *isPhasePtr = isPhase.data();
BlobIDType *LocalBlobIDPtr = LocalBlobID.data();
for (int z=0; z<Nz; z++) {
for (int y=0; y<Ny; y++) {
for (int x=0; x<Nx; x++) {
@@ -143,7 +143,7 @@ int ComputeLocalBlobIDs( const DoubleArray& Phase, const DoubleArray& SignDist,
// Compute the local blob ids
size_t N = Nx*Ny*Nz;
Array<bool> isPhase(Nx,Ny,Nz);
memset(isPhase.get(),0,Nx*Ny*Nz*sizeof(bool));
memset(isPhase.data(),0,Nx*Ny*Nz*sizeof(bool));
for (size_t i=0; i<N; i++) {
if ( SignDist(i) <= vS) {
// Solid phase
@@ -765,7 +765,7 @@ void getNewIDs( ID_map_struct& map, BlobIDType& id_max, std::vector<BlobIDType>&
void renumberIDs( const std::vector<BlobIDType>& new_ids, BlobIDArray& IDs )
{
size_t N = IDs.length();
BlobIDType* ids = IDs.get();
BlobIDType* ids = IDs.data();
for (size_t i=0; i<N; i++) {
BlobIDType id = ids[i];
if ( id>=0 )

View File

@@ -1,20 +0,0 @@
#include "Array.h"
#include <stdint.h>
/********************************************************
* std::swap *
********************************************************/
namespace std
{
template<> void swap( Array<bool>& v1, Array<bool>& v2 ) { v1.swap(v2); }
template<> void swap( Array<char>& v1, Array<char>& v2 ) { v1.swap(v2); }
template<> void swap( Array<int>& v1, Array<int>& v2 ) { v1.swap(v2); }
template<> void swap( Array<unsigned int>& v1, Array<unsigned int>& v2 ) { v1.swap(v2); }
template<> void swap( Array<int64_t>& v1, Array<int64_t>& v2 ) { v1.swap(v2); }
template<> void swap( Array<uint64_t>& v1, Array<uint64_t>& v2 ) { v1.swap(v2); }
template<> void swap( Array<float>& v1, Array<float>& v2 ) { v1.swap(v2); }
template<> void swap( Array<double>& v1, Array<double>& v2 ) { v1.swap(v2); }
}

View File

@@ -986,7 +986,7 @@ Array<TYPE> Array<TYPE>::coarsen( const Array<TYPE>& filter ) const
for (size_t k2=0; k2<Nh[2]; k2++) {
for (size_t j2=0; j2<Nh[1]; j2++) {
for (size_t i2=0; i2<Nh[0]; i2++) {
tmp += this->operator()(i1*Nh[0]+i2,j1*Nh[1]+j2,k1*Nh[2]+k2);
tmp += filter(i2,j2,k2) * this->operator()(i1*Nh[0]+i2,j1*Nh[1]+j2,k1*Nh[2]+k2);
}
}
}

View File

@@ -436,7 +436,7 @@ int main(int argc, char **argv)
*/
FILE *PHASE = fopen("Phase.dat","wb");
fwrite(Phase.get(),8,Nx*Ny*Nz,PHASE);
fwrite(Phase.data(),8,Nx*Ny*Nz,PHASE);
fclose(PHASE);
// Compute the porosity
@@ -998,12 +998,12 @@ int main(int argc, char **argv)
FILE *BLOBS;
BLOBS = fopen("Blobs.dat","wb");
fwrite(LocalBlobID.get(),4,Nx*Ny*Nz,BLOBS);
fwrite(LocalBlobID.data(),4,Nx*Ny*Nz,BLOBS);
fclose(BLOBS);
FILE *DISTANCE;
DISTANCE = fopen("SignDist.dat","wb");
fwrite(SignDist.get(),8,Nx*Ny*Nz,DISTANCE);
fwrite(SignDist.data(),8,Nx*Ny*Nz,DISTANCE);
fclose(DISTANCE);
}

View File

@@ -141,8 +141,8 @@ void readRankData( int proc, int nx, int ny, int nz, DoubleArray& Phase, DoubleA
char file1[40], file2[40];
sprintf(file1,"SignDist.%05d",proc);
sprintf(file2,"Phase.%05d",proc);
ReadBinaryFile(file1, Phase.get(), nx*ny*nz);
ReadBinaryFile(file2, SignDist.get(), nx*ny*nz);
ReadBinaryFile(file1, Phase.data(), nx*ny*nz);
ReadBinaryFile(file2, SignDist.data(), nx*ny*nz);
}
@@ -316,7 +316,7 @@ int main(int argc, char **argv)
FILE *BLOBS = fopen("Blobs.dat","wb");
fwrite(GlobalBlobID.get(),4,Nx*Ny*Nz,BLOBS);
fwrite(GlobalBlobID.data(),4,Nx*Ny*Nz,BLOBS);
fclose(BLOBS);
MPI_Finalize();
return 0;

View File

@@ -39,8 +39,8 @@ void readRankData( int proc, int nx, int ny, int nz, DoubleArray& Phase, DoubleA
char file1[40], file2[40];
sprintf(file1,"SignDist.%05d",proc);
sprintf(file2,"Phase.%05d",proc);
ReadBinaryFile(file1, Phase.get(), nx*ny*nz);
ReadBinaryFile(file2, SignDist.get(), nx*ny*nz);
ReadBinaryFile(file1, Phase.data(), nx*ny*nz);
ReadBinaryFile(file2, SignDist.data(), nx*ny*nz);
}
@@ -117,13 +117,13 @@ int main(int argc, char **argv)
char LocalRankFilename[100];
sprintf(LocalRankFilename,"BlobLabel.%05i",rank);
FILE *BLOBLOCAL = fopen(LocalRankFilename,"wb");
fwrite(GlobalBlobID.get(),4,GlobalBlobID.length(),BLOBLOCAL);
fwrite(GlobalBlobID.data(),4,GlobalBlobID.length(),BLOBLOCAL);
fclose(BLOBLOCAL);
printf("Wrote BlobLabel.%05i \n",rank);
/*FILE *BLOBS = fopen("Blobs.dat","wb");
fwrite(GlobalBlobID.get(),4,Nx*Ny*Nz,BLOBS);
fwrite(GlobalBlobID.data(),4,Nx*Ny*Nz,BLOBS);
fclose(BLOBS);*/
#ifdef PROFILE
PROFILE_STOP("main");

View File

@@ -266,11 +266,11 @@ int main(int argc, char **argv)
fclose(OUTFILE);
OUTFILE = fopen("Phase.dat","wb");
fwrite(Phase.get(),8,Nx*Ny*Nz,OUTFILE);
fwrite(Phase.data(),8,Nx*Ny*Nz,OUTFILE);
fclose(OUTFILE);
/* OUTFILE = fopen("SignDist.dat","wb");
fwrite(SignDist.get(),8,Nx*Ny*Nz,OUTFILE);
fwrite(SignDist.data(),8,Nx*Ny*Nz,OUTFILE);
fclose(OUTFILE);
*/

View File

@@ -20,8 +20,8 @@ void readRankData( int proc, int nx, int ny, int nz, DoubleArray& Phase, DoubleA
char file1[40], file2[40];
sprintf(file1,"SignDist.%05d",proc);
sprintf(file2,"Phase.%05d",proc);
ReadBinaryFile(file1, Phase.get(), nx*ny*nz);
ReadBinaryFile(file2, SignDist.get(), nx*ny*nz);
ReadBinaryFile(file1, Phase.data(), nx*ny*nz);
ReadBinaryFile(file2, SignDist.data(), nx*ny*nz);
}
inline void WriteBlobs(TwoPhase Averages){
printf("Writing the blob list \n");
@@ -262,7 +262,7 @@ int main(int argc, char **argv)
//...........................................................................
MPI_Barrier(comm);
//.......................................................................
SignedDistance(Averages.Phase.get(),nspheres,cx,cy,cz,rad,Lx,Ly,Lz,Nx,Ny,Nz,
SignedDistance(Averages.Phase.data(),nspheres,cx,cy,cz,rad,Lx,Ly,Lz,Nx,Ny,Nz,
Dm.iproc,Dm.jproc,Dm.kproc,Dm.nprocx,Dm.nprocy,Dm.nprocz);
//.......................................................................
// Assign the phase ID field based on the signed distance

View File

@@ -1198,8 +1198,8 @@ int main(int argc, char **argv)
//...........................................................................
InitD3Q19(ID, f_even, f_odd, Nx, Ny, Nz);
//......................................................................
// InitDenColorDistance(ID, Copy, Phi, SDs.get(), das, dbs, beta, xIntPos, Nx, Ny, Nz, S);
InitDenColorDistance(ID, Den, Phi, SDs.get(), das, dbs, beta, xIntPos, Nx, Ny, Nz);
// InitDenColorDistance(ID, Copy, Phi, SDs.data(), das, dbs, beta, xIntPos, Nx, Ny, Nz, S);
InitDenColorDistance(ID, Den, Phi, SDs.data(), das, dbs, beta, xIntPos, Nx, Ny, Nz);
InitD3Q7(ID, A_even, A_odd, &Den[0], Nx, Ny, Nz);
InitD3Q7(ID, B_even, B_odd, &Den[N], Nx, Ny, Nz);
//......................................................................
@@ -1212,7 +1212,7 @@ int main(int argc, char **argv)
sprintf(LocalRankFilename,"%s%s","ID.",LocalRankString);
WriteLocalSolidID(LocalRankFilename, id, N);
sprintf(LocalRankFilename,"%s%s","SDs.",LocalRankString);
WriteLocalSolidDistance(LocalRankFilename, SDs.get(), N);
WriteLocalSolidDistance(LocalRankFilename, SDs.data(), N);
//.......................................................................
if (Restart == true){
if (rank==0) printf("Reading restart file! \n");
@@ -1345,7 +1345,7 @@ int main(int argc, char **argv)
//...........................................................................
// Copy the phase indicator field for the earlier timestep
DeviceBarrier();
CopyToHost(Phase_tplus.get(),Phi,N*sizeof(double));
CopyToHost(Phase_tplus.data(),Phi,N*sizeof(double));
//...........................................................................
//...........................................................................
// Copy the data for for the analysis timestep
@@ -1354,8 +1354,8 @@ int main(int argc, char **argv)
//...........................................................................
DeviceBarrier();
ComputePressureD3Q19(ID,f_even,f_odd,Pressure,Nx,Ny,Nz);
CopyToHost(Phase.get(),Phi,N*sizeof(double));
CopyToHost(Press.get(),Pressure,N*sizeof(double));
CopyToHost(Phase.data(),Phi,N*sizeof(double));
CopyToHost(Press.data(),Pressure,N*sizeof(double));
MPI_Barrier(comm);
//...........................................................................
@@ -1774,14 +1774,14 @@ int main(int argc, char **argv)
// Copy the phase indicator field for the later timestep
DeviceBarrier();
ComputePressureD3Q19(ID,f_even,f_odd,Pressure,Nx,Ny,Nz);
CopyToHost(Phase_tminus.get(),Phi,N*sizeof(double));
CopyToHost(Phase_tplus.get(),Phi,N*sizeof(double));
CopyToHost(Phase.get(),Phi,N*sizeof(double));
CopyToHost(Press.get(),Pressure,N*sizeof(double));
CopyToHost(Phase_tminus.data(),Phi,N*sizeof(double));
CopyToHost(Phase_tplus.data(),Phi,N*sizeof(double));
CopyToHost(Phase.data(),Phi,N*sizeof(double));
CopyToHost(Press.data(),Pressure,N*sizeof(double));
double temp=0.5/beta;
for (n=0; n<N; n++){
double value = Phase.get()[n];
double value = Phase.data()[n];
SDn(n) = temp*log((1.0+value)/(1.0-value));
}
@@ -2218,12 +2218,12 @@ int main(int argc, char **argv)
//************************************************************************/
sprintf(LocalRankFilename,"%s%s","Phase.",LocalRankString);
// printf("Local File Name = %s \n",LocalRankFilename);
// CopyToHost(Phase.get(),Phi,N*sizeof(double));
// CopyToHost(Phase.data(),Phi,N*sizeof(double));
FILE *PHASE;
PHASE = fopen(LocalRankFilename,"wb");
fwrite(Press.get(),8,N,PHASE);
// fwrite(MeanCurvature.get(),8,N,PHASE);
fwrite(Press.data(),8,N,PHASE);
// fwrite(MeanCurvature.data(),8,N,PHASE);
fclose(PHASE);
/* double *DensityValues;

View File

@@ -79,7 +79,7 @@ int main(int argc, char **argv)
DoubleArray CubeValues(2,2,2);
// Compute the signed distance function
SignedDistance(Phase.get(),nspheres,cx,cy,cz,rad,Lx,Ly,Lz,Nx,Ny,Nz,0,0,0,1,1,1);
SignedDistance(Phase.data(),nspheres,cx,cy,cz,rad,Lx,Ly,Lz,Nx,Ny,Nz,0,0,0,1,1,1);
for (k=0; k<Nz; k++){
for (j=0; j<Ny; j++){
@@ -89,7 +89,7 @@ int main(int argc, char **argv)
}
}
}
SignedDistance(SignDist.get(),0,cx,cy,cz,rad,Lx,Ly,Lz,Nx,Ny,Nz,0,0,0,1,1,1);
SignedDistance(SignDist.data(),0,cx,cy,cz,rad,Lx,Ly,Lz,Nx,Ny,Nz,0,0,0,1,1,1);
pmmc_MeshCurvature(Phase, MeanCurvature, GaussCurvature, Nx, Ny, Nz);

View File

@@ -106,7 +106,7 @@ int main(int argc, char **argv)
if (rank==0){
FILE *PHASE = fopen("Phase.00000","wb");
fwrite(Averages.MeanCurvature.get(),8,Nx*Ny*Nz,PHASE);
fwrite(Averages.MeanCurvature.data(),8,Nx*Ny*Nz,PHASE);
fclose(PHASE);
}
// ****************************************************

View File

@@ -121,16 +121,16 @@ int main(int argc, char **argv)
if (rank == 0) cout << "Reading in domain from signed distance function..." << endl;
//.......................................................................
sprintf(LocalRankFilename,"%s%s","SignDist.",LocalRankString);
ReadBinaryFile(LocalRankFilename, Averages.SDs.get(), N);
ReadBinaryFile(LocalRankFilename, Averages.SDs.data(), N);
MPI_Barrier(comm);
// sprintf(LocalRankFilename,"%s%s","Pressure.",LocalRankString);
//ReadBinaryFile(LocalRankFilename, Averages.Press.get(), N);
//ReadBinaryFile(LocalRankFilename, Averages.Press.data(), N);
//MPI_Barrier(comm);
if (rank == 0) cout << "Domain set." << endl;
//.......................................................................
sprintf(LocalRankFilename,"%s%s","Label_NWP.",LocalRankString);
ReadBlobFile(LocalRankFilename, Averages.Label_NWP.get(), N);
ReadBlobFile(LocalRankFilename, Averages.Label_NWP.data(), N);
MPI_Barrier(comm);
if (rank == 0) cout << "Label_NWP set." << endl;
@@ -227,7 +227,7 @@ int main(int argc, char **argv)
}
// BlobContainer Blobs;
DoubleArray RecvBuffer(dimx);
// MPI_Allreduce(&Averages.ComponentAverages_NWP.get(),&Blobs.get(),1,MPI_DOUBLE,MPI_SUM,Dm.Comm);
// MPI_Allreduce(&Averages.ComponentAverages_NWP.data(),&Blobs.data(),1,MPI_DOUBLE,MPI_SUM,Dm.Comm);
MPI_Barrier(comm);
if (rank==0) printf("All ranks passed gate \n");

View File

@@ -198,7 +198,7 @@ int main(int argc, char **argv)
sprintf(LocalRankFilename,"SignDist.%05i",rank);
FILE *DIST = fopen(LocalRankFilename,"wb");
fwrite(Averages.SDs.get(),8,Averages.SDs.length(),DIST);
fwrite(Averages.SDs.data(),8,Averages.SDs.length(),DIST);
fclose(DIST);
sprintf(LocalRankFilename,"ID.%05i",rank);

View File

@@ -372,7 +372,7 @@ int main(int argc, char **argv)
// sprintf(LocalRankFilename,"%s%s","ID.",LocalRankString);
// WriteLocalSolidID(LocalRankFilename, id, N);
sprintf(LocalRankFilename,"%s%s","SignDist.",LocalRankString);
ReadBinaryFile(LocalRankFilename, Averages->SDs.get(), N);
ReadBinaryFile(LocalRankFilename, Averages->SDs.data(), N);
MPI_Barrier(comm);
if (rank == 0) cout << "Domain set." << endl;
@@ -553,7 +553,7 @@ int main(int argc, char **argv)
//...........................................................................
// Copy signed distance for device initialization
CopyToDevice(dvcSignDist, Averages->SDs.get(), dist_mem_size);
CopyToDevice(dvcSignDist, Averages->SDs.data(), dist_mem_size);
//...........................................................................
int logcount = 0; // number of surface write-outs
@@ -686,7 +686,7 @@ int main(int argc, char **argv)
//...........................................................................
// Copy the phase indicator field for the earlier timestep
DeviceBarrier();
CopyToHost(Averages->Phase_tplus.get(),Phi,N*sizeof(double));
CopyToHost(Averages->Phase_tplus.data(),Phi,N*sizeof(double));
//...........................................................................
//...........................................................................
// Copy the data for for the analysis timestep
@@ -695,11 +695,11 @@ int main(int argc, char **argv)
//...........................................................................
DeviceBarrier();
ComputePressureD3Q19(ID,f_even,f_odd,Pressure,Nx,Ny,Nz);
CopyToHost(Averages->Phase.get(),Phi,N*sizeof(double));
CopyToHost(Averages->Press.get(),Pressure,N*sizeof(double));
CopyToHost(Averages->Vel_x.get(),&Velocity[0],N*sizeof(double));
CopyToHost(Averages->Vel_y.get(),&Velocity[N],N*sizeof(double));
CopyToHost(Averages->Vel_z.get(),&Velocity[2*N],N*sizeof(double));
CopyToHost(Averages->Phase.data(),Phi,N*sizeof(double));
CopyToHost(Averages->Press.data(),Pressure,N*sizeof(double));
CopyToHost(Averages->Vel_x.data(),&Velocity[0],N*sizeof(double));
CopyToHost(Averages->Vel_y.data(),&Velocity[N],N*sizeof(double));
CopyToHost(Averages->Vel_z.data(),&Velocity[2*N],N*sizeof(double));
//...........................................................................
if (rank==0) printf("********************************************************\n");
@@ -934,7 +934,7 @@ int main(int argc, char **argv)
int NumberComponents_NWP = ComputeGlobalPhaseComponent(Mask.Nx-2,Mask.Ny-2,Mask.Nz-2,Mask.rank_info,Averages->PhaseID,1,Averages->Label_NWP);
printf("Number of non-wetting phase components: %i \n ",NumberComponents_NWP);
DeviceBarrier();
CopyToHost(Averages->Phase.get(),Phi,N*sizeof(double));
CopyToHost(Averages->Phase.data(),Phi,N*sizeof(double));
*/
/* Averages->WriteSurfaces(0);
@@ -942,17 +942,17 @@ int main(int argc, char **argv)
sprintf(LocalRankFilename,"%s%s","Phase.",LocalRankString);
FILE *PHASE;
PHASE = fopen(LocalRankFilename,"wb");
fwrite(Averages->SDn.get(),8,N,PHASE);
fwrite(Averages->SDn.data(),8,N,PHASE);
fclose(PHASE);
*/
/* sprintf(LocalRankFilename,"%s%s","Pressure.",LocalRankString);
FILE *PRESS;
PRESS = fopen(LocalRankFilename,"wb");
fwrite(Averages->Press.get(),8,N,PRESS);
fwrite(Averages->Press.data(),8,N,PRESS);
fclose(PRESS);
CopyToHost(Averages->Phase.get(),Phi,N*sizeof(double));
CopyToHost(Averages->Phase.data(),Phi,N*sizeof(double));
double * Grad;
Grad = new double [3*N];
CopyToHost(Grad,ColorGrad,3*N*sizeof(double));

View File

@@ -12,6 +12,13 @@ enum AnalysisType{ AnalyzeNone=0, IdentifyBlobs=0x01, CopyPhaseIndicator=0x02,
CopySimState=0x04, ComputeAverages=0x08, CreateRestart=0x10, WriteVis=0x20 };
template<class TYPE>
void DeleteArray( const TYPE *p )
{
delete [] p;
}
// Structure used to store ids
struct AnalysisWaitIdStruct {
ThreadPool::thread_id_t blobID;
@@ -279,14 +286,14 @@ void run_analysis( int timestep, int restart_interval,
(type&CopySimState)!=0 || (type&IdentifyBlobs)!=0 )
{
phase = std::shared_ptr<DoubleArray>(new DoubleArray(Nx,Ny,Nz));
CopyToHost(phase->get(),Phi,N*sizeof(double));
CopyToHost(phase->data(),Phi,N*sizeof(double));
}
if ( (type&CopyPhaseIndicator)!=0 ) {
memcpy(Averages.Phase_tplus.get(),phase->get(),N*sizeof(double));
memcpy(Averages.Phase_tplus.data(),phase->data(),N*sizeof(double));
//Averages.ColorToSignedDistance(beta,Averages.Phase,Averages.Phase_tplus);
}
if ( (type&ComputeAverages)!=0 ) {
memcpy(Averages.Phase_tminus.get(),phase->get(),N*sizeof(double));
memcpy(Averages.Phase_tminus.data(),phase->data(),N*sizeof(double));
//Averages.ColorToSignedDistance(beta,Averages.Phase,Averages.Phase_tminus);
}
if ( (type&CopySimState) != 0 ) {
@@ -301,11 +308,11 @@ void run_analysis( int timestep, int restart_interval,
tpool.wait(wait.vis); // Make sure we are done using analysis before modifying
PROFILE_STOP("Copy-Wait",1);
PROFILE_START("Copy-State",1);
memcpy(Averages.Phase.get(),phase->get(),N*sizeof(double));
CopyToHost(Averages.Press.get(),Pressure,N*sizeof(double));
CopyToHost(Averages.Vel_x.get(),&Velocity[0],N*sizeof(double));
CopyToHost(Averages.Vel_y.get(),&Velocity[N],N*sizeof(double));
CopyToHost(Averages.Vel_z.get(),&Velocity[2*N],N*sizeof(double));
memcpy(Averages.Phase.data(),phase->data(),N*sizeof(double));
CopyToHost(Averages.Press.data(),Pressure,N*sizeof(double));
CopyToHost(Averages.Vel_x.data(),&Velocity[0],N*sizeof(double));
CopyToHost(Averages.Vel_y.data(),&Velocity[N],N*sizeof(double));
CopyToHost(Averages.Vel_z.data(),&Velocity[2*N],N*sizeof(double));
PROFILE_STOP("Copy-State",1);
}
std::shared_ptr<double> cDen, cDistEven, cDistOdd;

View File

@@ -294,7 +294,7 @@ int main(int argc, char **argv)
if (nprocx > 1 && rank==0) printf("Disc packs are 2D -- are you sure you want nprocx > 1? \n");
//.......................................................................
SignedDistanceDiscPack(SignDist.get(),ndiscs,cx,cy,rad,Lx,Ly,Lz,Nx,Ny,Nz,
SignedDistanceDiscPack(SignDist.data(),ndiscs,cx,cy,rad,Lx,Ly,Lz,Nx,Ny,Nz,
iproc,jproc,kproc,nprocx,nprocy,nprocz);
//.......................................................................
// Assign walls in the signed distance functions (x,y boundaries)
@@ -375,7 +375,7 @@ int main(int argc, char **argv)
//.......................................................................
sprintf(LocalRankString,"%05d",rank);
sprintf(LocalRankFilename,"%s%s","SignDist.",LocalRankString);
WriteLocalSolidDistance(LocalRankFilename, SignDist.get(), N);
WriteLocalSolidDistance(LocalRankFilename, SignDist.data(), N);
//......................................................................
// ****************************************************

View File

@@ -133,7 +133,7 @@ int main(int argc, char **argv)
sprintf(LocalRankFilename,"SignDist.%05i",rank);
FILE *DIST = fopen(LocalRankFilename,"rb");
size_t ReadSignDist;
ReadSignDist=fread(SignDist.get(),8,N,DIST);
ReadSignDist=fread(SignDist.data(),8,N,DIST);
if (ReadSignDist != size_t(N)) printf("lbpm_morphdrain_pp: Error reading signed distance function (rank=%i)\n",rank);
fclose(DIST);

View File

@@ -282,7 +282,7 @@ int main(int argc, char **argv)
// sprintf(LocalRankFilename,"%s%s","ID.",LocalRankString);
// WriteLocalSolidID(LocalRankFilename, id, N);
sprintf(LocalRankFilename,"%s%s","SignDist.",LocalRankString);
ReadBinaryFile(LocalRankFilename, Averages.SDs.get(), N);
ReadBinaryFile(LocalRankFilename, Averages.SDs.data(), N);
MPI_Barrier(comm);
if (rank == 0) cout << "Domain set." << endl;
@@ -402,7 +402,7 @@ int main(int argc, char **argv)
//...........................................................................
// Copy signed distance for device initialization
CopyToDevice(dvcSignDist, Averages.SDs.get(), dist_mem_size);
CopyToDevice(dvcSignDist, Averages.SDs.data(), dist_mem_size);
//...........................................................................
int logcount = 0; // number of surface write-outs
@@ -509,10 +509,10 @@ int main(int argc, char **argv)
DeviceBarrier();
ComputePressureD3Q19(ID,f_even,f_odd,Pressure,Nx,Ny,Nz);
ComputeVelocityD3Q19(ID,f_even,f_odd,Velocity,Nx,Ny,Nz);
CopyToHost(Averages.Press.get(),Pressure,N*sizeof(double));
CopyToHost(Averages.Vel_x.get(),&Velocity[0],N*sizeof(double));
CopyToHost(Averages.Vel_y.get(),&Velocity[N],N*sizeof(double));
CopyToHost(Averages.Vel_z.get(),&Velocity[2*N],N*sizeof(double));
CopyToHost(Averages.Press.data(),Pressure,N*sizeof(double));
CopyToHost(Averages.Vel_x.data(),&Velocity[0],N*sizeof(double));
CopyToHost(Averages.Vel_y.data(),&Velocity[N],N*sizeof(double));
CopyToHost(Averages.Vel_z.data(),&Velocity[2*N],N*sizeof(double));
// Way more work than necessary -- this is just to get the solid interfacial area!!
Averages.Initialize();

View File

@@ -148,7 +148,7 @@ int main(int argc, char **argv)
sprintf(LocalRankFilename,"SignDist.%05i",rank);
FILE *DIST = fopen(LocalRankFilename,"rb");
size_t ReadSignDist;
ReadSignDist=fread(SignDist.get(),8,N,DIST);
ReadSignDist=fread(SignDist.data(),8,N,DIST);
if (ReadSignDist != size_t(N)) printf("lbpm_random_pp: Error reading signed distance function (rank=%i)\n",rank);
fclose(DIST);

View File

@@ -332,7 +332,7 @@ int main(int argc, char **argv)
sprintf(LocalRankFilename,"SignDist.%05i",rank);
FILE *DIST = fopen(LocalRankFilename,"wb");
fwrite(Averages.SDs.get(),8,Averages.SDs.length(),DIST);
fwrite(Averages.SDs.data(),8,Averages.SDs.length(),DIST);
fclose(DIST);
/* // Solve for the position of the non-wetting phase

View File

@@ -185,7 +185,7 @@ int main(int argc, char **argv)
MPI_Bcast(&D,1,MPI_DOUBLE,0,comm);
//.......................................................................
SignedDistance(SignDist.get(),nspheres,cx,cy,cz,rad,Lx,Ly,Lz,Nx,Ny,Nz,
SignedDistance(SignDist.data(),nspheres,cx,cy,cz,rad,Lx,Ly,Lz,Nx,Ny,Nz,
iproc,jproc,kproc,nprocx,nprocy,nprocz);
//.......................................................................
// Assign the phase ID field based on the signed distance
@@ -242,7 +242,7 @@ int main(int argc, char **argv)
//.......................................................................
sprintf(LocalRankString,"%05d",rank);
sprintf(LocalRankFilename,"%s%s","SignDist.",LocalRankString);
WriteLocalSolidDistance(LocalRankFilename, SignDist.get(), N);
WriteLocalSolidDistance(LocalRankFilename, SignDist.data(), N);
//......................................................................
// ****************************************************

View File

@@ -198,7 +198,7 @@ int main(int argc, char **argv)
sprintf(LocalRankFilename,"SignDist.%05i",rank);
FILE *DIST = fopen(LocalRankFilename,"wb");
fwrite(Averages.SDs.get(),8,Averages.SDs.length(),DIST);
fwrite(Averages.SDs.data(),8,Averages.SDs.length(),DIST);
fclose(DIST);
sprintf(LocalRankFilename,"ID.%05i",rank);

File diff suppressed because it is too large Load Diff