Separate work item for blob analysis and regular macroscale analysis

This commit is contained in:
James E McClure 2016-02-29 11:14:22 -05:00
parent fa0ad77b21
commit 489c878148
2 changed files with 23 additions and 13 deletions

View File

@ -16,7 +16,7 @@
#include "lbpm_color_simulator.h"
//#define WRITE_SURFACES
//#define WRE_SURFACES
/*
* Simulator for two-phase flow in porous media
@ -156,8 +156,9 @@ int main(int argc, char **argv)
//solid_isovalue = 0.0;
int RESTART_INTERVAL=20000;
int ANALYSIS_INTERVAL=1000;
int ANALYSIS_INTERVAL=1000;
bool ANALYZE_BLOB_STATES=false;
if (rank==0){
//.............................................................
// READ SIMULATION PARMAETERS FROM INPUT FILE
@ -190,7 +191,7 @@ int main(int argc, char **argv)
// Line 7: time-stepping criteria
input >> timestepMax; // max no. of timesteps
input >> RESTART_INTERVAL; // restart interval
input >> tol; // error tolerance
input >> tol; // error tolerance
//.............................................................
//.......................................................................
@ -868,10 +869,16 @@ int main(int argc, char **argv)
timestep++;
// Run the analysis, blob identification, and write restart files
if (ANALYZE_BLOB_STATES == true){
run_analysis(timestep,RESTART_INTERVAL,rank_info,*Averages,last_ids,last_index,last_id_map,
Nx,Ny,Nz,pBC,beta,err,Phi,Pressure,Velocity,ID,f_even,f_odd,Den,
LocalRestartFile,meshData,fillData,tpool,work_ids);
}
else{
ComputeMacroscaleAverages(timestep,ANALYSIS_INTERVAL,RESTART_INTERVAL,rank_info,*Averages,
Nx,Ny,Nz,pBC,beta,err,Phi,Pressure,Velocity,ID,f_even,f_odd,Den,
LocalRestartFile,meshData,fillData,tpool,work_ids);
}
// Save the timers
if ( timestep%50==0 )
PROFILE_SAVE("lbpm_color_simulator",1);

View File

@ -5,7 +5,7 @@
#include "IO/MeshDatabase.h"
//#define ANALYSIS_INTERVAL 6
#define ANALYSIS_INTERVAL 1000
#define ANALYSIS_INTERVAL_DEFAULT 1000
#define BLOBID_INTERVAL 250
enum AnalysisType{ AnalyzeNone=0, IdentifyBlobs=0x01, CopyPhaseIndicator=0x02,
@ -229,7 +229,11 @@ public:
Averages.ColorToSignedDistance(beta,Averages.Phase_tminus,Averages.Phase_tminus);
Averages.ColorToSignedDistance(beta,Averages.Phase_tplus,Averages.Phase_tplus);
Averages.UpdateMeshValues();
Averages.ComputeLocal();
Averages.Reduce();
Averages.PrintAll(timestep);
Averages.Initialize();
Averages.ComponentAverages();
Averages.SortBlobs();
Averages.PrintComponents(timestep);
@ -238,7 +242,7 @@ public:
ThreadPool::WorkItem::d_state = 2; // Change state to finished
}
private:
AnalysisWorkItem();
BlobAnalysisWorkItem();
AnalysisType type;
int timestep;
TwoPhase& Averages;
@ -262,7 +266,7 @@ void run_analysis( int timestep, int restart_interval,
// Determin the analysis we want to perform
AnalysisType type = AnalyzeNone;
if ( timestep%ANALYSIS_INTERVAL + 5 == ANALYSIS_INTERVAL ) {
if ( timestep%ANALYSIS_INTERVAL_DEFAULT + 5 == ANALYSIS_INTERVAL_DEFAULT ) {
// Copy the phase indicator field for the earlier timestep
type = static_cast<AnalysisType>( type | CopyPhaseIndicator );
}
@ -279,12 +283,12 @@ void run_analysis( int timestep, int restart_interval,
}
#endif
if ( timestep%ANALYSIS_INTERVAL == 0 ) {
if ( timestep%ANALYSIS_INTERVAL_DEFAULT == 0 ) {
// Copy the averages to the CPU (and identify blobs)
type = static_cast<AnalysisType>( type | CopySimState );
type = static_cast<AnalysisType>( type | IdentifyBlobs );
}
if ( timestep%ANALYSIS_INTERVAL == 5 ) {
if ( timestep%ANALYSIS_INTERVAL_DEFAULT == 5 ) {
// Run the analysis
type = static_cast<AnalysisType>( type | ComputeAverages );
}
@ -373,7 +377,7 @@ void run_analysis( int timestep, int restart_interval,
// Spawn threads to do the analysis work
if ( (type&ComputeAverages) != 0 ) {
ThreadPool::WorkItem *work = new AnalysisWorkItem(
ThreadPool::WorkItem *work = new BlobAnalysisWorkItem(
type,timestep,Averages,last_index,last_id_map,beta);
work->add_dependency(wait.blobID);
work->add_dependency(wait.analysis);
@ -417,7 +421,6 @@ void run_analysis( int timestep, int restart_interval,
// Function to start the analysis
void ComputeMacroscaleAverages( int timestep, int analysis_interval, int restart_interval,
const RankInfoStruct& rank_info, TwoPhase& Averages,
BlobIDstruct& last_ids, BlobIDstruct& last_index, BlobIDList& last_id_map,
int Nx, int Ny, int Nz, bool pBC, double beta, double err,
const double *Phi, double *Pressure, const double *Velocity,
const char *ID, const double *f_even, const double *f_odd, const double *Den,
@ -509,7 +512,7 @@ void ComputeMacroscaleAverages( int timestep, int analysis_interval, int restart
// Spawn threads to do the analysis work
if ( (type&ComputeAverages) != 0 ) {
ThreadPool::WorkItem *work = new AnalysisWorkItem(
type,timestep,Averages,last_index,last_id_map,beta);
type,timestep,Averages,beta);
work->add_dependency(wait.analysis);
work->add_dependency(wait.vis); // Make sure we are done using analysis before modifying
wait.analysis = tpool.add_work(work);