Fixing bug in PoissonSolver

This commit is contained in:
Mark Berrill
2021-05-17 12:00:40 -04:00
parent 8f8d23632a
commit a2b22e5e47
7 changed files with 36 additions and 30 deletions

View File

@@ -1,6 +1,8 @@
# Set some CMake properties
CMAKE_MINIMUM_REQUIRED( VERSION 3.9 )
CMAKE_POLICY( SET CMP0115 OLD )
if( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20.0")
CMAKE_POLICY( SET CMP0115 OLD )
endif()
MESSAGE("====================")

View File

@@ -57,6 +57,6 @@ inline std::vector<std::string> splitList( const char *line, const char token )
}
}; // namespace IO
} // namespace IO
#endif

View File

@@ -18,7 +18,8 @@ typedef int DBfile;
#endif
namespace IO::silo {
namespace IO {
namespace silo {
enum FileMode { READ, WRITE, CREATE };
@@ -256,7 +257,9 @@ void writeMultiVar( DBfile *fid, const std::string &varname,
const std::vector<std::string> &subVarNames, const std::vector<int> &subVarTypes );
}; // namespace IO::silo
} // namespace silo
} // namespace IO
#endif
#include "IO/silo.hpp"

View File

@@ -13,7 +13,8 @@
#include <silo.h>
namespace IO::silo {
namespace IO {
namespace silo {
/****************************************************
@@ -413,7 +414,8 @@ Array<TYPE> readTriMeshVariable( DBfile *fid, const std::string &varname )
}
}; // namespace IO::silo
} // namespace silo
} // namespace IO
#endif

View File

@@ -1,6 +1,8 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.18.3)
CMAKE_POLICY( SET CMP0057 NEW )
CMAKE_POLICY( SET CMP0115 OLD )
if( ${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.20.0")
CMAKE_POLICY( SET CMP0115 OLD )
endif()
INCLUDE(CheckCCompilerFlag)
INCLUDE(CheckCSourceCompiles)

View File

@@ -218,20 +218,19 @@ void ScaLBL_Poisson::ReadInput(){
void ScaLBL_Poisson::AssignSolidBoundary(double *poisson_solid)
{
size_t NLABELS=0;
signed char VALUE=0;
double AFFINITY=0.f;
auto LabelList = electric_db->getVector<int>( "SolidLabels" );
auto AffinityList = electric_db->getVector<double>( "SolidValues" );
NLABELS=LabelList.size();
size_t NLABELS = LabelList.size();
if (NLABELS != AffinityList.size()){
ERROR("Error: LB-Poisson Solver: SolidLabels and SolidValues must be the same length! \n");
}
double label_count[NLABELS];
double label_count_global[NLABELS];
std::vector<double> label_count( NLABELS, 0.0 );
std::vector<double> label_count_global( NLABELS, 0.0 );
// Assign the labels
for (size_t idx=0; idx<NLABELS; idx++) label_count[idx]=0;
@@ -596,26 +595,25 @@ void ScaLBL_Poisson::Run(double *ChargeDensity, int timestep_from_Study){
}
void ScaLBL_Poisson::getConvergenceLog(int timestep,double error){
if (rank==0){
bool WriteHeader=false;
TIMELOG = fopen("PoissonSolver_Convergence.csv","r");
if (TIMELOG != NULL)
fclose(TIMELOG);
else
WriteHeader=true;
TIMELOG = fopen("PoissonSolver_Convergence.csv","a+");
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(TIMELOG,"Timestep Error\n");
fprintf(TIMELOG,"%i %.5g\n",timestep,error);
fflush(TIMELOG);
}
else {
fprintf(TIMELOG,"%i %.5g\n",timestep,error);
fflush(TIMELOG);
}
fprintf(fid,"Timestep Error\n");
fprintf(fid,"%i %.5g\n",timestep,error);
fflush(fid);
fclose( fid );
}
}

View File

@@ -94,7 +94,6 @@ private:
char LocalRankFilename[40];
char LocalRestartFile[40];
char OutputFilename[200];
FILE *TIMELOG;
//int rank,nprocs;
void LoadParams(std::shared_ptr<Database> db0);