Commit 59da512e authored by Douglas Serson's avatar Douglas Serson
Browse files

Modify InterpPointDataToFld to make frompts an option instead of an input file

parent b9fe2594
......@@ -104,7 +104,6 @@ struct Field
LibUtilities::CommSharedPtr m_comm;
LibUtilities::SessionReaderSharedPtr m_session;
SpatialDomains::MeshGraphSharedPtr m_graph;
LibUtilities::PtsIOSharedPtr m_ptsIO;
map<string, vector<string> > m_inputfiles;
bool m_writeBndFld;
......
......@@ -79,19 +79,20 @@ void InputPts::Process(po::variables_map &vm)
{
string inFile = (m_f->m_inputfiles["pts"][0]).c_str();
LibUtilities::PtsIOSharedPtr ptsIO;
if (m_f->m_session)
{
m_f->m_ptsIO = MemoryManager<LibUtilities::PtsIO>::AllocateSharedPtr(
ptsIO = MemoryManager<LibUtilities::PtsIO>::AllocateSharedPtr(
m_f->m_session->GetComm());
}
else // serial communicator
{
LibUtilities::CommSharedPtr c =
LibUtilities::GetCommFactory().CreateInstance("Serial", 0, 0);
m_f->m_ptsIO = MemoryManager<LibUtilities::PtsIO>::AllocateSharedPtr(c);
ptsIO = MemoryManager<LibUtilities::PtsIO>::AllocateSharedPtr(c);
}
m_f->m_ptsIO->Import(inFile, m_f->m_fieldPts);
ptsIO->Import(inFile, m_f->m_fieldPts);
// save field names
for (int j = 0; j < m_f->m_fieldPts->GetNFields(); ++j)
......
......@@ -59,9 +59,9 @@ ProcessInterpField::ProcessInterpField(FieldSharedPtr f) : ProcessModule(f)
{
m_config["fromxml"] = ConfigOption(
false, "NotSet", "Xml file form which to interpolate field");
false, "NotSet", "Xml file from which to interpolate field");
m_config["fromfld"] = ConfigOption(
false, "NotSet", "Fld file form which to interpolate field");
false, "NotSet", "Fld file from which to interpolate field");
m_config["clamptolowervalue"] =
ConfigOption(false, "-10000000", "Lower bound for interpolation value");
......@@ -245,6 +245,8 @@ void ProcessInterpField::Process(po::variables_map &vm)
m_f->m_exp[i]->FwdTrans_IterPerExp(
m_f->m_exp[i]->GetPhys(), m_f->m_exp[i]->UpdateCoeffs());
}
// save field names
m_f->m_variables = m_fromField->m_fielddef[0]->m_fields;
}
void ProcessInterpField::PrintProgressbar(const int position,
......
......@@ -60,6 +60,8 @@ ModuleKey ProcessInterpPointDataToFld::className =
ProcessInterpPointDataToFld::ProcessInterpPointDataToFld(FieldSharedPtr f)
: ProcessModule(f)
{
m_config["frompts"] = ConfigOption(
false, "NotSet", "Pts file from which to interpolate field");
m_config["interpcoord"] =
ConfigOption(false, "-1", "coordinate id to use for interpolation");
......@@ -73,18 +75,26 @@ void ProcessInterpPointDataToFld::Process(po::variables_map &vm)
{
int i, j;
// Check for command line point specification if no .pts file specified
ASSERTL0(m_f->m_fieldPts != LibUtilities::NullPtsField,
"No input points found");
// Load pts file
ASSERTL0( m_config["frompts"].as<string>().compare("NotSet") != 0,
"ProcessInterpPointDataToFld requires frompts parameter");
string inFile = m_config["frompts"].as<string>().c_str();
LibUtilities::PtsIOSharedPtr ptsIO =
MemoryManager<LibUtilities::PtsIO>::AllocateSharedPtr(m_f->m_comm);
ptsIO->Import(inFile, m_f->m_fieldPts);
int nFields = m_f->m_fieldPts->GetNFields();
ASSERTL0(nFields > 0, "No field values provided in input");
// assume one field is already defined from input file.
// Define new expansions.
ASSERTL0(NumHomogeneousDir == 0,
"ProcessInterpPointDataToFld does not support homogeneous expansion");
ASSERTL0(m_f->m_exp.size() == 1,
"ProcessInterpPointDataToFld requires xml input without fld.");
m_f->m_exp.resize(nFields);
for (i = 1; i < nFields; ++i)
{
m_f->m_exp[i] = m_f->AppendExpList(0);
m_f->m_exp[i] = m_f->AppendExpList(NumHomogeneousDir);
}
int totpoints = m_f->m_exp[0]->GetTotPoints();
......@@ -103,13 +113,13 @@ void ProcessInterpPointDataToFld::Process(po::variables_map &vm)
Interpolator interp(eNoMethod, coord_id);
if (m_f->m_comm->GetRank() == 0)
if (m_f->m_verbose && m_f->m_comm->TreatAsRankZero())
{
interp.SetProgressCallback(
&ProcessInterpPointDataToFld::PrintProgressbar, this);
}
interp.Interpolate(m_f->m_fieldPts, outPts);
if (m_f->m_comm->GetRank() == 0)
if (m_f->m_verbose && m_f->m_comm->TreatAsRankZero())
{
cout << endl;
}
......@@ -128,6 +138,15 @@ void ProcessInterpPointDataToFld::Process(po::variables_map &vm)
m_f->m_exp[i]->FwdTrans_IterPerExp(m_f->m_exp[i]->GetPhys(),
m_f->m_exp[i]->UpdateCoeffs());
}
// save field names
for (int j = 0; j < m_f->m_fieldPts->GetNFields(); ++j)
{
m_f->m_variables.push_back(m_f->m_fieldPts->GetFieldName(j));
}
// Remove m_fieldPts to avoid confusion
m_f->m_fieldPts = LibUtilities::NullPtsField;
}
}
}
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