Fixing bug in PoissonSolver
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
# Set some CMake properties
|
# Set some CMake properties
|
||||||
CMAKE_MINIMUM_REQUIRED( VERSION 3.9 )
|
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("====================")
|
MESSAGE("====================")
|
||||||
|
|||||||
@@ -57,6 +57,6 @@ inline std::vector<std::string> splitList( const char *line, const char token )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}; // namespace IO
|
} // namespace IO
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ typedef int DBfile;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace IO::silo {
|
namespace IO {
|
||||||
|
namespace silo {
|
||||||
|
|
||||||
|
|
||||||
enum FileMode { READ, WRITE, CREATE };
|
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 );
|
const std::vector<std::string> &subVarNames, const std::vector<int> &subVarTypes );
|
||||||
|
|
||||||
|
|
||||||
}; // namespace IO::silo
|
} // namespace silo
|
||||||
|
} // namespace IO
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "IO/silo.hpp"
|
#include "IO/silo.hpp"
|
||||||
|
|||||||
@@ -13,7 +13,8 @@
|
|||||||
#include <silo.h>
|
#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
|
#endif
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.18.3)
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.18.3)
|
||||||
CMAKE_POLICY( SET CMP0057 NEW )
|
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(CheckCCompilerFlag)
|
||||||
INCLUDE(CheckCSourceCompiles)
|
INCLUDE(CheckCSourceCompiles)
|
||||||
|
|||||||
@@ -218,20 +218,19 @@ void ScaLBL_Poisson::ReadInput(){
|
|||||||
|
|
||||||
void ScaLBL_Poisson::AssignSolidBoundary(double *poisson_solid)
|
void ScaLBL_Poisson::AssignSolidBoundary(double *poisson_solid)
|
||||||
{
|
{
|
||||||
size_t NLABELS=0;
|
|
||||||
signed char VALUE=0;
|
signed char VALUE=0;
|
||||||
double AFFINITY=0.f;
|
double AFFINITY=0.f;
|
||||||
|
|
||||||
auto LabelList = electric_db->getVector<int>( "SolidLabels" );
|
auto LabelList = electric_db->getVector<int>( "SolidLabels" );
|
||||||
auto AffinityList = electric_db->getVector<double>( "SolidValues" );
|
auto AffinityList = electric_db->getVector<double>( "SolidValues" );
|
||||||
|
|
||||||
NLABELS=LabelList.size();
|
size_t NLABELS = LabelList.size();
|
||||||
if (NLABELS != AffinityList.size()){
|
if (NLABELS != AffinityList.size()){
|
||||||
ERROR("Error: LB-Poisson Solver: SolidLabels and SolidValues must be the same length! \n");
|
ERROR("Error: LB-Poisson Solver: SolidLabels and SolidValues must be the same length! \n");
|
||||||
}
|
}
|
||||||
|
|
||||||
double label_count[NLABELS];
|
std::vector<double> label_count( NLABELS, 0.0 );
|
||||||
double label_count_global[NLABELS];
|
std::vector<double> label_count_global( NLABELS, 0.0 );
|
||||||
// Assign the labels
|
// Assign the labels
|
||||||
|
|
||||||
for (size_t idx=0; idx<NLABELS; idx++) label_count[idx]=0;
|
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)
|
if (WriteHeader)
|
||||||
{
|
fprintf(fid,"Timestep Error\n");
|
||||||
fprintf(TIMELOG,"Timestep Error\n");
|
|
||||||
fprintf(TIMELOG,"%i %.5g\n",timestep,error);
|
fprintf(fid,"%i %.5g\n",timestep,error);
|
||||||
fflush(TIMELOG);
|
fflush(fid);
|
||||||
}
|
fclose( fid );
|
||||||
else {
|
|
||||||
fprintf(TIMELOG,"%i %.5g\n",timestep,error);
|
|
||||||
fflush(TIMELOG);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -94,7 +94,6 @@ private:
|
|||||||
char LocalRankFilename[40];
|
char LocalRankFilename[40];
|
||||||
char LocalRestartFile[40];
|
char LocalRestartFile[40];
|
||||||
char OutputFilename[200];
|
char OutputFilename[200];
|
||||||
FILE *TIMELOG;
|
|
||||||
|
|
||||||
//int rank,nprocs;
|
//int rank,nprocs;
|
||||||
void LoadParams(std::shared_ptr<Database> db0);
|
void LoadParams(std::shared_ptr<Database> db0);
|
||||||
|
|||||||
Reference in New Issue
Block a user