Minor changes to PoissonSolver

This commit is contained in:
Mark Berrill 2021-05-17 12:26:29 -04:00
parent a2b22e5e47
commit 3cdfb7caf6
2 changed files with 30 additions and 26 deletions

View File

@ -5,19 +5,35 @@
#include "analysis/distance.h"
#include "common/ReadMicroCT.h"
ScaLBL_Poisson::ScaLBL_Poisson(int RANK, int NP, const Utilities::MPI& COMM):
rank(RANK), nprocs(NP),timestep(0),timestepMax(0),tau(0),k2_inv(0),tolerance(0),h(0),
epsilon0(0),epsilon0_LB(0),epsilonR(0),epsilon_LB(0),Vin(0),Vout(0),Nx(0),Ny(0),Nz(0),N(0),Np(0),analysis_interval(0),
chargeDen_dummy(0),WriteLog(0),nprocx(0),nprocy(0),nprocz(0),
BoundaryConditionInlet(0),BoundaryConditionOutlet(0),BoundaryConditionSolid(0),Lx(0),Ly(0),Lz(0),
Vin0(0),freqIn(0),t0_In(0),Vin_Type(0),Vout0(0),freqOut(0),t0_Out(0),Vout_Type(0),
TestPeriodic(0),TestPeriodicTime(0),TestPeriodicTimeConv(0),TestPeriodicSaveInterval(0),
comm(COMM)
static inline bool fileExists( const std::string &filename )
{
std::ifstream ifile( filename.c_str() );
return ifile.good();
}
ScaLBL_Poisson::~ScaLBL_Poisson(){
ScaLBL_Poisson::ScaLBL_Poisson(int RANK, int NP, const Utilities::MPI& COMM):
rank(RANK), TIMELOG(nullptr), nprocs(NP),timestep(0),timestepMax(0),tau(0),k2_inv(0),tolerance(0),h(0),
epsilon0(0),epsilon0_LB(0),epsilonR(0),epsilon_LB(0),Vin(0),Vout(0),Nx(0),Ny(0),Nz(0),N(0),Np(0),analysis_interval(0),
chargeDen_dummy(0),WriteLog(0),nprocx(0),nprocy(0),nprocz(0),
BoundaryConditionInlet(0),BoundaryConditionOutlet(0),BoundaryConditionSolid(0),Lx(0),Ly(0),Lz(0),
Vin0(0),freqIn(0),t0_In(0),Vin_Type(0),Vout0(0),freqOut(0),t0_Out(0),Vout_Type(0),
TestPeriodic(0),TestPeriodicTime(0),TestPeriodicTimeConv(0),TestPeriodicSaveInterval(0),
comm(COMM)
{
if ( rank == 0 ) {
bool WriteHeader = !fileExists( "PoissonSolver_Convergence.csv" );
TIMELOG = fopen("PoissonSolver_Convergence.csv","a+");
if (WriteHeader)
fprintf(TIMELOG,"Timestep Error\n");
}
}
ScaLBL_Poisson::~ScaLBL_Poisson()
{
if ( TIMELOG )
fclose( TIMELOG );
}
void ScaLBL_Poisson::ReadParams(string filename){
@ -596,24 +612,10 @@ void ScaLBL_Poisson::Run(double *ChargeDensity, int timestep_from_Study){
}
static inline bool fileExists( const std::string &filename )
{
std::ifstream ifile( filename.c_str() );
return ifile.good();
}
void ScaLBL_Poisson::getConvergenceLog(int timestep,double error){
if ( rank == 0 ) {
bool WriteHeader = !fileExists( "PoissonSolver_Convergence.csv" );
auto fid = fopen("PoissonSolver_Convergence.csv","a+");
if (WriteHeader)
fprintf(fid,"Timestep Error\n");
fprintf(fid,"%i %.5g\n",timestep,error);
fflush(fid);
fclose( fid );
fprintf(TIMELOG,"%i %.5g\n",timestep,error);
fflush(TIMELOG);
}
}

View File

@ -89,6 +89,8 @@ public:
private:
Utilities::MPI comm;
FILE *TIMELOG;
// filenames
char LocalRankString[8];
char LocalRankFilename[40];