Commit 1fab2f80 authored by Douglas Serson's avatar Douglas Serson
Browse files

Allow for multiple fld inputs

parent 999563f4
......@@ -85,32 +85,12 @@ InputFld::~InputFld()
void InputFld::Process(po::variables_map &vm)
{
int i;
string fldending;
// Determine appropriate field input
if (m_f->m_inputfiles.count("fld") != 0)
{
fldending = "fld";
}
else if (m_f->m_inputfiles.count("chk") != 0)
{
fldending = "chk";
}
else if (m_f->m_inputfiles.count("rst") != 0)
{
fldending = "rst";
}
else if (m_f->m_inputfiles.count("bse") != 0)
{
fldending = "bse";
}
else
{
ASSERTL0(false, "no input file found");
}
string fileName = m_config["infile"].as<string>();
LibUtilities::FieldIOSharedPtr fld =
m_f->FieldIOForFile(m_f->m_inputfiles[fldending][0]);
m_f->FieldIOForFile(fileName);
int oldSize = m_f->m_fielddef.size();
if(m_f->m_graph)
{
// currently load all field (possibly could read data from
......@@ -138,18 +118,30 @@ void InputFld::Process(po::variables_map &vm)
}
fld->Import(
m_f->m_inputfiles[fldending][0], m_f->m_fielddef, m_f->m_data,
fileName, m_f->m_fielddef, m_f->m_data,
m_f->m_fieldMetaDataMap, ElementGIDs);
}
else // load all data.
{
fld->Import(
m_f->m_inputfiles[fldending][0], m_f->m_fielddef, m_f->m_data,
fileName, m_f->m_fielddef, m_f->m_data,
m_f->m_fieldMetaDataMap);
}
// save field names
m_f->m_variables = m_f->m_fielddef[0]->m_fields;
for(i = 0; i < m_f->m_fielddef[oldSize]->m_fields.size(); ++i)
{
// check for multiple fld files
vector<string>::iterator it =
find (m_f->m_variables.begin(),
m_f->m_variables.end(),
m_f->m_fielddef[oldSize]->m_fields[i]);
if(it == m_f->m_variables.end())
{
m_f->m_variables.push_back(m_f->m_fielddef[oldSize]->m_fields[i]);
}
}
}
}
}
......@@ -105,8 +105,7 @@ InputNek5000::~InputNek5000()
*/
void InputNek5000::Process(po::variables_map &vm)
{
string fldending = "fld5000";
ifstream file(m_f->m_inputfiles[fldending][0].c_str(), ios::binary);
ifstream file(m_config["infile"].as<string>().c_str(), ios::binary);
// Header: 132 bytes for binary.
vector<char> data(132);
......
......@@ -60,9 +60,6 @@ ProcessAddFld::ProcessAddFld(FieldSharedPtr f) : ProcessModule(f)
m_config["fromfld"] =
ConfigOption(false, "NotSet", "Fld file form which to add field");
ASSERTL0(m_config["fromfld"].as<string>().compare("NotSet") != 0,
"Need to specify fromfld=file.fld ");
if(f->m_inputfiles.count("xml"))
{
m_priority = eModifyExp;
......@@ -82,8 +79,12 @@ void ProcessAddFld::Process(po::variables_map &vm)
string scalestr = m_config["scale"].as<string>();
NekDouble scale = boost::lexical_cast<NekDouble>(scalestr);
ASSERTL0(m_config["fromfld"].as<string>().compare("NotSet") != 0,
"Need to specify fromfld=file.fld ");
string fromfld = m_config["fromfld"].as<string>();
FieldSharedPtr fromField = boost::shared_ptr<Field>(new Field());
vector<LibUtilities::FieldDefinitionsSharedPtr> fromFieldDef;
vector<vector<double> > fromFieldData;
if (m_f->m_graph)
{
......@@ -108,29 +109,29 @@ void ProcessAddFld::Process(po::variables_map &vm)
ElementGIDs[i++] = expIt->second->m_geomShPtr->GetGlobalID();
}
m_f->FieldIOForFile(fromfld)->Import(
fromfld, fromField->m_fielddef, fromField->m_data,
fromfld, fromFieldDef, fromFieldData,
LibUtilities::NullFieldMetaDataMap, ElementGIDs);
}
else
{
m_f->FieldIOForFile(fromfld)->Import(
fromfld, fromField->m_fielddef, fromField->m_data,
fromfld, fromFieldDef, fromFieldData,
LibUtilities::NullFieldMetaDataMap);
}
bool samelength = true;
if (fromField->m_data.size() != m_f->m_data.size())
if (fromFieldData.size() != m_f->m_data.size())
{
samelength = false;
}
// scale input field
for (int i = 0; i < fromField->m_data.size(); ++i)
for (int i = 0; i < fromFieldData.size(); ++i)
{
int datalen = fromField->m_data[i].size();
int datalen = fromFieldData[i].size();
Vmath::Smul(datalen, scale, &(fromField->m_data[i][0]), 1,
&(fromField->m_data[i][0]), 1);
Vmath::Smul(datalen, scale, &(fromFieldData[i][0]), 1,
&(fromFieldData[i][0]), 1);
if (samelength)
{
......@@ -151,7 +152,7 @@ void ProcessAddFld::Process(po::variables_map &vm)
int datalen = m_f->m_data[i].size();
Vmath::Vadd(datalen, &(m_f->m_data[i][0]), 1,
&(fromField->m_data[i][0]), 1, &(m_f->m_data[i][0]), 1);
&(fromFieldData[i][0]), 1, &(m_f->m_data[i][0]), 1);
}
}
......@@ -174,26 +175,26 @@ void ProcessAddFld::Process(po::variables_map &vm)
// since expansion is set up according to m_f search for same
// variable in new field
int nfield;
for (nfield = 0; nfield < fromField->m_fielddef[0]->m_fields.size();
for (nfield = 0; nfield < fromFieldDef[0]->m_fields.size();
++nfield)
{
if (fromField->m_fielddef[0]->m_fields[nfield] ==
if (fromFieldDef[0]->m_fields[nfield] ==
m_f->m_variables[j])
{
break;
}
}
ASSERTL0(nfield != fromField->m_fielddef[0]->m_fields.size(),
ASSERTL0(nfield != fromFieldDef[0]->m_fields.size(),
"Could not find field " + m_f->m_variables[j] +
" in from field");
// load new field
for (int i = 0; i < fromField->m_data.size(); ++i)
for (int i = 0; i < fromFieldData.size(); ++i)
{
m_f->m_exp[j]->ExtractDataToCoeffs(
fromField->m_fielddef[i], fromField->m_data[i],
fromField->m_fielddef[i]->m_fields[nfield],
fromFieldDef[i], fromFieldData[i],
fromFieldDef[i]->m_fields[nfield],
m_f->m_exp[j]->UpdateCoeffs());
}
......
......@@ -94,13 +94,12 @@ void ProcessBoundaryExtract::Process(po::variables_map &vm)
numBndExp = max(numBndExp, breg_it->first);
}
// assuming all boundary regions are consecutive number if
// regions is one more tham maximum id
// regions is one more than maximum id
numBndExp++;
// not all partitions in parallel touch all boundaries so
// find maximum number of boundaries
m_f->m_session->GetComm()->AllReduce(numBndExp,
LibUtilities::ReduceMax);
m_f->m_comm->AllReduce(numBndExp, LibUtilities::ReduceMax);
// THis presumes boundary regions are numbered consecutively
for (int i = 0; i < numBndExp; ++i)
......
......@@ -51,31 +51,11 @@ ModuleKey ProcessConcatenateFld::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "concatenate"),
ProcessConcatenateFld::create,
"Concatenate field file into single file");
"Concatenate field file into single file (deprecated)");
ProcessConcatenateFld::ProcessConcatenateFld(FieldSharedPtr f)
: ProcessModule(f)
{
// check for correct input files
if ((f->m_inputfiles.count("xml") == 0) &&
(f->m_inputfiles.count("xml.gz") == 0))
{
cout << "An xml or xml.gz input file must be specified for the "
"concatenate module"
<< endl;
exit(3);
}
if ((f->m_inputfiles.count("fld") == 0) &&
(f->m_inputfiles.count("chk") == 0) &&
(f->m_inputfiles.count("rst") == 0))
{
cout << "A fld or chk or rst input file must be specified for the "
"concatenate module"
<< endl;
exit(3);
}
}
ProcessConcatenateFld::~ProcessConcatenateFld()
......@@ -84,24 +64,11 @@ ProcessConcatenateFld::~ProcessConcatenateFld()
void ProcessConcatenateFld::Process(po::variables_map &vm)
{
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
m_f->m_exp[0]->GetFieldDefinitions();
std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
// Copy Data into FieldData and set variable
for (int j = 0; j < m_f->m_exp.size(); ++j)
if(m_f->m_comm->TreatAsRankZero())
{
for (int i = 0; i < FieldDef.size(); ++i)
{
// Could do a search here to find correct variable
FieldDef[i]->m_fields.push_back(m_f->m_fielddef[0]->m_fields[j]);
m_f->m_exp[0]->AppendFieldData(FieldDef[i], FieldData[i],
m_f->m_exp[j]->UpdateCoeffs());
}
cout << "Concatenate module is not needed. Instead, use " << endl
<< "\tFieldConvert file1.fld file2.fld file-conc.fld" << endl;
}
m_f->m_fielddef = FieldDef;
m_f->m_data = FieldData;
}
}
}
......@@ -242,11 +242,21 @@ void ProcessCreateExp::Process(po::variables_map &vm)
{
for (i = 0; i < m_f->m_data.size() / nstrips; ++i)
{
m_f->m_exp[s * nfields + j]->ExtractDataToCoeffs(
m_f->m_fielddef[i * nstrips + s],
m_f->m_data[i * nstrips + s],
m_f->m_fielddef[i * nstrips + s]->m_fields[j],
m_f->m_exp[s * nfields + j]->UpdateCoeffs());
int n = i * nstrips + s;
// In case of multiple flds, we might not have a
// variable in this m_data[n] -> skip in this case
vector<string>::iterator it =
find (m_f->m_fielddef[n]->m_fields.begin(),
m_f->m_fielddef[n]->m_fields.end(),
m_f->m_variables[j]);
if(it !=m_f->m_fielddef[n]->m_fields.end())
{
m_f->m_exp[s * nfields + j]->ExtractDataToCoeffs(
m_f->m_fielddef[n],
m_f->m_data[n],
m_f->m_variables[j],
m_f->m_exp[s * nfields + j]->UpdateCoeffs());
}
}
m_f->m_exp[s * nfields + j]->BwdTrans(
m_f->m_exp[s * nfields + j]->GetCoeffs(),
......
......@@ -55,7 +55,7 @@ ModuleKey ProcessInterpPoints::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "interppoints"),
ProcessInterpPoints::create,
"Interpolates a set of points to another, requires fromfld and "
"Interpolates a field to a set of points. Requires fromfld and "
"fromxml to be defined, a line, plane or block of points can be "
"defined");
......
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