Commit 0d904797 authored by Douglas Serson's avatar Douglas Serson
Browse files

Move creation of m_exp to a dummy module

parent cf54567c
......@@ -19,6 +19,7 @@ SET(FieldUtilsHeaders
ProcessModules/ProcessBoundaryExtract.h
ProcessModules/ProcessCombineAvg.h
ProcessModules/ProcessConcatenateFld.h
ProcessModules/ProcessCreateExp.h
ProcessModules/ProcessDeform.h
ProcessModules/ProcessDisplacement.h
ProcessModules/ProcessEquiSpacedOutput.h
......@@ -67,6 +68,7 @@ SET(FieldUtilsSources
ProcessModules/ProcessBoundaryExtract.cpp
ProcessModules/ProcessCombineAvg.cpp
ProcessModules/ProcessConcatenateFld.cpp
ProcessModules/ProcessCreateExp.cpp
ProcessModules/ProcessDeform.cpp
ProcessModules/ProcessDisplacement.cpp
ProcessModules/ProcessEquiSpacedOutput.cpp
......
......@@ -95,7 +95,7 @@ void InputFld::Process(po::variables_map &vm)
}
}
int i, j;
int i;
string fldending;
// Determine appropriate field input
if (m_f->m_inputfiles.count("fld") != 0)
......@@ -163,94 +163,6 @@ void InputFld::Process(po::variables_map &vm)
m_f->m_inputfiles[fldending][0], m_f->m_fielddef, m_f->m_data,
m_f->m_fieldMetaDataMap);
}
// if m_exp defined presume we want to load all field into expansions
if (m_f->m_exp.size())
{
int nfields, nstrips;
m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
if (vm.count("useSessionVariables"))
{
nfields = m_f->m_session->GetVariables().size();
}
else
{
nfields = m_f->m_fielddef[0]->m_fields.size();
}
m_f->m_exp.resize(nfields * nstrips);
vector<string> vars = m_f->m_session->GetVariables();
// declare other fields;
for (int s = 0; s < nstrips; ++s) // homogeneous strip varient
{
for (i = 0; i < nfields; ++i)
{
if (i < vars.size())
{
// check to see if field already defined
if (!m_f->m_exp[s * nfields + i])
{
m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir, vars[i]);
}
}
else
{
if (vars.size())
{
m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir, vars[0]);
}
else
{
m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir);
}
}
}
}
// Extract data to coeffs and bwd transform
for (int s = 0; s < nstrips; ++s) // homogeneous strip varient
{
for (j = 0; j < nfields; ++j)
{
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());
}
m_f->m_exp[s * nfields + j]->BwdTrans(
m_f->m_exp[s * nfields + j]->GetCoeffs(),
m_f->m_exp[s * nfields + j]->UpdatePhys());
}
}
// reset output field in case Import loaded elements that are not
// in the expansion (because of range option of partitioning)
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
m_f->m_exp[0]->GetFieldDefinitions();
std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
for (j = 0; j < nfields; ++j)
{
for (i = 0; i < FieldDef.size(); ++i)
{
FieldDef[i]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[j]);
m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
}
}
m_f->m_fielddef = FieldDef;
m_f->m_data = FieldData;
}
}
}
}
......@@ -87,10 +87,7 @@ void InputXml::Process(po::variables_map &vm)
// check for multiple calls to inputXml due to split xml
// files. If so just return
int expsize = m_f->m_exp.size();
m_f->m_comm->AllReduce(expsize, LibUtilities::ReduceMax);
if (expsize != 0)
if (m_f->m_graph)
{
return;
}
......@@ -104,29 +101,6 @@ void InputXml::Process(po::variables_map &vm)
}
}
// check to see if fld file defined so can use in
// expansion defintion if required
string fldending;
bool fldfilegiven = true;
// 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
{
fldfilegiven = false;
}
string xml_ending = "xml";
string xml_gz_ending = "xml.gz";
......@@ -288,130 +262,6 @@ void InputXml::Process(po::variables_map &vm)
timerpart.Start();
}
}
// currently load all field (possibly could read data from
// expansion list but it is re-arranged in expansion)
const SpatialDomains::ExpansionMap &expansions =
m_f->m_graph->GetExpansions();
// if Range has been speficied it is possible to have a
// partition which is empty so ccheck this and return if
// no elements present.
if (!expansions.size())
{
return;
}
m_f->m_exp.resize(1);
// load fielddef header if fld file is defined. This gives
// precedence to Homogeneous definition in fld file
int NumHomogeneousDir = 0;
if (fldfilegiven)
{
// use original expansion to identify which elements are in
// this partition/subrange
Array<OneD, int> ElementGIDs(expansions.size());
SpatialDomains::ExpansionMap::const_iterator expIt;
int i = 0;
for (expIt = expansions.begin(); expIt != expansions.end(); ++expIt)
{
ElementGIDs[i++] = expIt->second->m_geomShPtr->GetGlobalID();
}
m_f->m_fielddef.clear();
m_f->m_data.clear();
m_f->FieldIOForFile(m_f->m_inputfiles[fldending][0])->Import(
m_f->m_inputfiles[fldending][0], m_f->m_fielddef, m_f->m_data,
m_f->m_fieldMetaDataMap, ElementGIDs);
NumHomogeneousDir = m_f->m_fielddef[0]->m_numHomogeneousDir;
//----------------------------------------------
// Set up Expansion information to use mode order from field
m_f->m_graph->SetExpansions(m_f->m_fielddef);
}
else
{
if (m_f->m_session->DefinesSolverInfo("HOMOGENEOUS"))
{
std::string HomoStr = m_f->m_session->GetSolverInfo("HOMOGENEOUS");
if ((HomoStr == "HOMOGENEOUS1D") || (HomoStr == "Homogeneous1D") ||
(HomoStr == "1D") || (HomoStr == "Homo1D"))
{
NumHomogeneousDir = 1;
}
if ((HomoStr == "HOMOGENEOUS2D") || (HomoStr == "Homogeneous2D") ||
(HomoStr == "2D") || (HomoStr == "Homo2D"))
{
NumHomogeneousDir = 2;
}
}
}
// reset expansion defintion to use equispaced points if required.
if (m_requireEquiSpaced || vm.count("output-points"))
{
int nPointsNew = 0;
if (vm.count("output-points"))
{
nPointsNew = vm["output-points"].as<int>();
}
m_f->m_graph->SetExpansionsToEvenlySpacedPoints(nPointsNew);
}
else
{
if (vm.count("output-points"))
{
int nPointsNew = vm["output-points"].as<int>();
m_f->m_graph->SetExpansionsToPointOrder(nPointsNew);
}
}
if (m_f->m_verbose)
{
if (m_f->m_comm->TreatAsRankZero())
{
timerpart.Stop();
NekDouble cpuTime = timerpart.TimePerTest(1);
stringstream ss;
ss << cpuTime << "s";
cout << "\t InputXml setexpansion CPU Time: " << setw(8) << left
<< ss.str() << endl;
timerpart.Start();
}
}
// Override number of planes with value from cmd line
if (NumHomogeneousDir == 1 && vm.count("output-points-hom-z"))
{
int expdim = m_f->m_graph->GetMeshDimension();
m_f->m_fielddef[0]->m_numModes[expdim] =
vm["output-points-hom-z"].as<int>();
}
m_f->m_exp[0] = m_f->SetUpFirstExpList(NumHomogeneousDir, fldfilegiven);
if (m_f->m_verbose)
{
if (m_f->m_comm->TreatAsRankZero())
{
timerpart.Stop();
NekDouble cpuTime = timerpart.TimePerTest(1);
stringstream ss1;
ss1 << cpuTime << "s";
cout << "\t InputXml set first exp CPU Time: " << setw(8) << left
<< ss1.str() << endl;
}
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessCreateExp.cpp
//
// For more information, please see: http://www.nektar.info/
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description: Dummy module to create m_exp.
//
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
using namespace std;
#include "ProcessCreateExp.h"
#include <LibUtilities/BasicUtils/ParseUtils.hpp>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <LibUtilities/BasicUtils/Timer.h>
namespace Nektar
{
namespace FieldUtils
{
ModuleKey ProcessCreateExp::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "createExp"),
ProcessCreateExp::create,
"dummy module used to create m_exp.");
ProcessCreateExp::ProcessCreateExp(FieldSharedPtr f) : ProcessModule(f)
{
}
ProcessCreateExp::~ProcessCreateExp()
{
}
void ProcessCreateExp::Process(po::variables_map &vm)
{
if(m_f->m_graph)
{
int i, j;
Timer timerpart;
if (m_f->m_verbose)
{
if (m_f->m_comm->TreatAsRankZero())
{
cout << "ProcessCreateExp: creating m_exp..." << endl;
timerpart.Start();
}
}
// check to see if fld file defined so can use in
// expansion defintion if required
bool fldfilegiven = (m_f->m_fielddef.size() != 0);
// currently load all field (possibly could read data from
// expansion list but it is re-arranged in expansion)
const SpatialDomains::ExpansionMap &expansions =
m_f->m_graph->GetExpansions();
// if Range has been specified it is possible to have a
// partition which is empty so check this and return if
// no elements present.
if (!expansions.size())
{
return;
}
m_f->m_exp.resize(1);
// load fielddef header if fld file is defined. This gives
// precedence to Homogeneous definition in fld file
int NumHomogeneousDir = 0;
if (fldfilegiven)
{
NumHomogeneousDir = m_f->m_fielddef[0]->m_numHomogeneousDir;
// Set up Expansion information to use mode order from field
m_f->m_graph->SetExpansions(m_f->m_fielddef);
}
else
{
if (m_f->m_session->DefinesSolverInfo("HOMOGENEOUS"))
{
std::string HomoStr =
m_f->m_session->GetSolverInfo("HOMOGENEOUS");
if ((HomoStr == "HOMOGENEOUS1D") ||
(HomoStr == "Homogeneous1D") ||
(HomoStr == "1D") || (HomoStr == "Homo1D"))
{
NumHomogeneousDir = 1;
}
if ((HomoStr == "HOMOGENEOUS2D") ||
(HomoStr == "Homogeneous2D") ||
(HomoStr == "2D") || (HomoStr == "Homo2D"))
{
NumHomogeneousDir = 2;
}
}
}
// reset expansion defintion to use equispaced points if required.
if (m_requireEquiSpaced || vm.count("output-points"))
{
int nPointsNew = 0;
if (vm.count("output-points"))
{
nPointsNew = vm["output-points"].as<int>();
}
m_f->m_graph->SetExpansionsToEvenlySpacedPoints(nPointsNew);
}
else
{
if (vm.count("output-points"))
{
int nPointsNew = vm["output-points"].as<int>();
m_f->m_graph->SetExpansionsToPointOrder(nPointsNew);
}
}
if (m_f->m_verbose)
{
if (m_f->m_comm->TreatAsRankZero())
{
timerpart.Stop();
NekDouble cpuTime = timerpart.TimePerTest(1);
stringstream ss;
ss << cpuTime << "s";
cout << "\t ProcessCreateExp setexpansion CPU Time: "
<< setw(8) << left
<< ss.str() << endl;
timerpart.Start();
}
}
// Override number of planes with value from cmd line
if (NumHomogeneousDir == 1 && vm.count("output-points-hom-z"))
{
int expdim = m_f->m_graph->GetMeshDimension();
m_f->m_fielddef[0]->m_numModes[expdim] =
vm["output-points-hom-z"].as<int>();
}
m_f->m_exp[0] = m_f->SetUpFirstExpList(NumHomogeneousDir, fldfilegiven);
if (m_f->m_verbose)
{
if (m_f->m_comm->TreatAsRankZero())
{
timerpart.Stop();
NekDouble cpuTime = timerpart.TimePerTest(1);
stringstream ss1;
ss1 << cpuTime << "s";
cout << "\t ProcessCreateExp set first exp CPU Time: "
<< setw(8) << left
<< ss1.str() << endl;
}
}
if (fldfilegiven)
{
int nfields, nstrips;
m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
if (vm.count("useSessionVariables"))
{
nfields = m_f->m_session->GetVariables().size();
}
else
{
nfields = m_f->m_fielddef[0]->m_fields.size();
}
m_f->m_exp.resize(nfields * nstrips);
vector<string> vars = m_f->m_session->GetVariables();
// declare other fields;
for (int s = 0; s < nstrips; ++s) // homogeneous strip varient
{
for (i = 0; i < nfields; ++i)
{
if (i < vars.size())
{
// check to see if field already defined
if (!m_f->m_exp[s * nfields + i])
{
m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir, vars[i]);
}
}
else
{
if (vars.size())
{
m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir, vars[0]);
}
else
{
m_f->m_exp[s * nfields + i] = m_f->AppendExpList(
m_f->m_fielddef[0]->m_numHomogeneousDir);
}
}
}
}
// Extract data to coeffs and bwd transform
for (int s = 0; s < nstrips; ++s) // homogeneous strip varient
{
for (j = 0; j < nfields; ++j)
{
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());
}
m_f->m_exp[s * nfields + j]->BwdTrans(
m_f->m_exp[s * nfields + j]->GetCoeffs(),
m_f->m_exp[s * nfields + j]->UpdatePhys());
}
}
// reset output field in case Import loaded elements that are not
// in the expansion (because of range option of partitioning)
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef =
m_f->m_exp[0]->GetFieldDefinitions();
std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
for (j = 0; j < nfields; ++j)
{
for (i = 0; i < FieldDef.size(); ++i)
{
FieldDef[i]->m_fields.push_back(
m_f->m_fielddef[0]->m_fields[j]);
m_f->m_exp[j]->AppendFieldData(FieldDef[i], FieldData[i]);
}
}
m_f->m_fielddef = FieldDef;
m_f->m_data = FieldData;
}
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessCreateExp.h
//
// For more information, please see: http://www.nektar.info/
//
// The MIT License
//
// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
// Department of Aeronautics, Imperial College London (UK), and Scientific
// Computing and Imaging Institute, University of Utah (USA).
//
// License for the specific language governing rights and limitations under
// Permission is hereby granted, free of charge, to any person obtaining a
// copy of this software and associated documentation files (the "Software"),
// to deal in the Software without restriction, including without limitation
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
// and/or sell copies of the Software, and to permit persons to whom the
// Software is furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included