Commit 3008cf01 authored by Douglas Serson's avatar Douglas Serson
Browse files

Allow using nprocs without procid in FieldConvert

parent d8ba38be
......@@ -717,6 +717,17 @@ struct Field
return tmp;
}
FIELD_UTILS_EXPORT void ClearField()
{
m_session = LibUtilities::SessionReaderSharedPtr();
m_graph = SpatialDomains::MeshGraphSharedPtr();
m_fieldPts = LibUtilities::NullPtsField;
m_exp.clear();
m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
m_data = std::vector<std::vector<NekDouble> > ();
m_variables.clear();
}
private:
/// Map to store FieldIO instances. Key is the reader type, value is the
/// FieldIO object.
......
......@@ -249,7 +249,7 @@ bool OutputFileBase::WriteFile(std::string &filename, po::variables_map &vm)
// Get path to file. If procid was defined, get the full name
// to avoid checking files from other partitions
fs::path outFile;
if(vm.count("procid"))
if(vm.count("nprocs"))
{
outFile = GetFullOutName(filename, vm);
}
......
......@@ -55,6 +55,7 @@ ModuleKey OutputInfo::m_className =
OutputInfo::OutputInfo(FieldSharedPtr f) : OutputModule(f)
{
m_config["nprocs"] = ConfigOption(false, "1", "number of partitions");
}
OutputInfo::~OutputInfo()
......@@ -68,10 +69,9 @@ void OutputInfo::Process(po::variables_map &vm)
int i;
// partition mesh
ASSERTL0(vm.count("nprocs") > 0,
"--nprocs nust be specified with info output");
int nprocs = vm["nprocs"].as<int>();
ASSERTL0(m_config["nprocs"].as<string>().compare("NotSet") != 0,
"Need to specify nprocs for info output");
int nprocs = m_config["nprocs"].as<int>();
LibUtilities::CommSharedPtr vComm = boost::shared_ptr<FieldConvertComm>(
new FieldConvertComm(0, NULL, nprocs, 0));
......
......@@ -179,11 +179,6 @@ void FilterFieldConvert::v_Initialise(
m_fieldMetaData["InitialTime"] = boost::lexical_cast<std::string>(time);
// Fill some parameters of m_f
m_f->m_session = m_session;
m_f->m_graph = pFields[0]->GetGraph();
m_f->m_comm = m_f->m_session->GetComm();
// Load restart file if necessary
if (m_restartFile != "")
{
......@@ -363,7 +358,7 @@ void FilterFieldConvert::OutputField(
}
// Empty m_f to save memory
ClearFields();
m_f->ClearField();
if (dump != -1) // not final dump so rescale
{
......@@ -483,6 +478,10 @@ void FilterFieldConvert::CreateModules( vector<string> &modcmds)
void FilterFieldConvert::CreateFields(
const Array<OneD, const MultiRegions::ExpListSharedPtr> &pFields)
{
// Fill some parameters of m_f
m_f->m_session = m_session;
m_f->m_graph = pFields[0]->GetGraph();
m_f->m_comm = m_f->m_session->GetComm();
m_f->m_fieldMetaDataMap = m_fieldMetaData;
m_f->m_fieldPts = LibUtilities::NullPtsField;
// Create m_f->m_exp
......@@ -521,14 +520,6 @@ void FilterFieldConvert::CreateFields(
m_f->m_variables= m_variables;
}
void FilterFieldConvert::ClearFields()
{
m_f->m_fieldPts = LibUtilities::NullPtsField;
m_f->m_exp.clear();
m_f->m_fielddef = std::vector<LibUtilities::FieldDefinitionsSharedPtr>();
m_f->m_data = std::vector<std::vector<NekDouble> > ();
}
// This function checks validity conditions for the list of modules provided
void FilterFieldConvert::CheckModules(vector<ModuleSharedPtr> &modules)
{
......
......@@ -110,8 +110,6 @@ protected:
void CreateFields(
const Array<OneD, const MultiRegions::ExpListSharedPtr> &pFields);
void ClearFields();
void CheckModules(vector<ModuleSharedPtr> &modules);
unsigned int m_numSamples;
......
......@@ -209,16 +209,22 @@ int main(int argc, char* argv[])
* name of the module to load.
*/
FieldSharedPtr f = boost::shared_ptr<Field>(new Field());
int nParts = 1;
if (LibUtilities::GetCommFactory().ModuleExists("ParallelMPI"))
{
if(vm.count("procid"))
if(vm.count("nprocs"))
{
int nprocs, rank;
ASSERTL0(vm.count("nprocs"),
"Must specify --nprocs when using --procid option");
nprocs = vm["nprocs"].as<int>();
rank = vm["procid"].as<int>();
if(vm.count("procid"))
{
rank = vm["procid"].as<int>();
}
else
{
nParts = nprocs;
rank = 0;
}
f->m_comm = boost::shared_ptr<FieldConvertComm>(
new FieldConvertComm(argc, argv, nprocs,rank));
......@@ -415,15 +421,30 @@ int main(int argc, char* argv[])
PrintExecutionSequence(modules);
}
// Run field process.
for (int n = 0; n < SIZE_ModulePriority; ++n)
// Loop on partitions when using nprocs without procid
for(int p = 0; p < nParts; ++p)
{
ModulePriority priority = static_cast<ModulePriority>(n);
for (int i = 0; i < modules.size(); ++i)
if(verbose && nParts > 1)
{
if(modules[i]->GetModulePriority() == priority)
cout << endl << "Processing partition: " << p << endl;
}
if (p > 0)
{
int rank = p;
f->ClearField();
f->m_comm = boost::shared_ptr<FieldConvertComm>(
new FieldConvertComm(argc, argv, nParts,rank));
}
// Run field process.
for (int n = 0; n < SIZE_ModulePriority; ++n)
{
ModulePriority priority = static_cast<ModulePriority>(n);
for (int i = 0; i < modules.size(); ++i)
{
RunModule(modules[i], vm, verbose);
if(modules[i]->GetModulePriority() == priority)
{
RunModule(modules[i], vm, verbose);
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment