Commit 776d16ce authored by Chris Cantwell's avatar Chris Cantwell

Merge branch 'feature/AvgFilterMultiOutput' of /opt/gitlab/repositories/nektar

parents e9f4ab02 130f6ce2
......@@ -761,7 +761,7 @@
SpatialDomains::Composite c = it->second->begin()->second;
vector<unsigned int> tmpOrder;
// From the composite, we now construct the allVerts, allEdges
// and allCoord map so that they can be transferred across
// processors. We also populate the locFaces set to store a
......
......@@ -115,8 +115,8 @@ namespace Nektar
void Preconditioner::v_DoPreconditionerWithNonVertOutput(
const Array<OneD, NekDouble> &pInput,
Array<OneD, NekDouble> &pOutput,
const Array<OneD, NekDouble> &pNonVertOutput)
const Array<OneD, NekDouble> &pNonVertOutput,
Array<OneD, NekDouble>& pVertForce)
{
NEKERROR(ErrorUtil::efatal, "Method does not exist");
}
......
......@@ -80,7 +80,9 @@ namespace Nektar
inline void DoPreconditionerWithNonVertOutput(
const Array<OneD, NekDouble>& pInput,
Array<OneD, NekDouble>& pOutput,
const Array<OneD, NekDouble>& pNonVertOutput);
const Array<OneD, NekDouble>& pNonVertOutput,
Array<OneD, NekDouble>& pVertForce = NullNekDouble1DArray);
inline void DoTransformToLowEnergy(
Array<OneD, NekDouble>& pInOut,
......@@ -152,7 +154,9 @@ namespace Nektar
virtual void v_DoPreconditionerWithNonVertOutput(
const Array<OneD, NekDouble>& pInput,
Array<OneD, NekDouble>& pOutput,
const Array<OneD, NekDouble>& pNonVertOutput);
const Array<OneD, NekDouble>& pNonVertOutput,
Array<OneD, NekDouble>& pVertForce);
virtual void v_DoTransformToLowEnergy(
Array<OneD, NekDouble>& pInOut,
......@@ -214,9 +218,11 @@ namespace Nektar
inline void Preconditioner::DoPreconditionerWithNonVertOutput(
const Array<OneD, NekDouble>& pInput,
Array<OneD, NekDouble>& pOutput,
const Array<OneD, NekDouble>& pNonVertOutput)
const Array<OneD, NekDouble>& pNonVertOutput,
Array<OneD, NekDouble>& pVertForce)
{
v_DoPreconditionerWithNonVertOutput(pInput,pOutput,pNonVertOutput);
v_DoPreconditionerWithNonVertOutput(pInput,pOutput,pNonVertOutput,
pVertForce);
}
/**
......
......@@ -115,7 +115,8 @@ namespace Nektar
const Array<OneD, NekDouble>& pInput,
Array<OneD, NekDouble>& pOutput)
{
v_DoPreconditionerWithNonVertOutput(pInput,pOutput,NullNekDouble1DArray);
v_DoPreconditionerWithNonVertOutput(pInput,pOutput,NullNekDouble1DArray,
NullNekDouble1DArray);
}
/**
......@@ -124,8 +125,9 @@ namespace Nektar
void PreconditionerLinear::v_DoPreconditionerWithNonVertOutput(
const Array<OneD, NekDouble>& pInput,
Array<OneD, NekDouble>& pOutput,
const Array<OneD, NekDouble>& pNonVertOutput)
{
const Array<OneD, NekDouble>& pNonVertOutput,
Array<OneD, NekDouble>& pVertForce)
{
GlobalSysSolnType solvertype=m_locToGloMap->GetGlobalSysSolnType();
switch(solvertype)
{
......@@ -172,17 +174,34 @@ namespace Nektar
//any other value
Vmath::Vcopy(pInput.num_elements(),pInput,1,pOutput,1);
}
// Scatter back soln from linear solve
for(i = 0; i < nloc; ++i)
if(pVertForce != NullNekDouble1DArray)
{
val = LocToGloBnd[i];
if(val >= nDirFull)
Vmath::Zero(pVertForce.num_elements(),pVertForce,1);
// Scatter back soln from linear solve
for(i = 0; i < nloc; ++i)
{
pOutput[val-nDirFull] = Out[LocToGlo[i]];
val = LocToGloBnd[i];
if(val >= nDirFull)
{
pOutput[val-nDirFull] = Out[LocToGlo[i]];
// copy vertex forcing into this vector
pVertForce[val-nDirFull] = In[LocToGlo[i]];
}
}
}
else
{
// Scatter back soln from linear solve
for(i = 0; i < nloc; ++i)
{
val = LocToGloBnd[i];
if(val >= nDirFull)
{
pOutput[val-nDirFull] = Out[LocToGlo[i]];
}
}
}
}
break;
default:
......
......@@ -72,8 +72,7 @@ namespace Nektar
MULTI_REGIONS_EXPORT
virtual ~PreconditionerLinear() {}
protected:
GlobalLinSysSharedPtr m_vertLinsys;
boost::shared_ptr<AssemblyMap> m_vertLocToGloMap;
......@@ -86,7 +85,8 @@ namespace Nektar
virtual void v_DoPreconditionerWithNonVertOutput(
const Array<OneD, NekDouble>& pInput,
Array<OneD, NekDouble>& pOutput,
const Array<OneD, NekDouble>& pNonVertOutput);
const Array<OneD, NekDouble>& pNonVertOutput,
Array<OneD, NekDouble>& pVertForce);
virtual void v_DoPreconditioner(
const Array<OneD, NekDouble>& pInput,
......
......@@ -136,10 +136,8 @@ namespace Nektar
//Apply linear space preconditioner
m_linSpacePrecon->DoPreconditionerWithNonVertOutput(InputLinear, OutputLinear, tmp);
//m_linSpacePrecon->DoPreconditioner(InputLinear, OutputLinear);
m_lowEnergyPrecon->DoMultiplybyInverseTransposedTransformationMatrix(OutputLinear,pOutput);
//m_lowEnergyPrecon->DoTransformToLowEnergy(OutputLinear,pOutput);
Vmath::Vadd(nGlobal,pOutput,1,OutputLowEnergy,1,pOutput,1);
}
......
......@@ -48,8 +48,7 @@ namespace Nektar
{
if (pParams.find("OutputFile") == pParams.end())
{
string outname = m_session->GetSessionName() + "_avg.fld";
m_outputFile = outname;
m_outputFile = m_session->GetSessionName();
}
else
{
......@@ -57,12 +56,28 @@ namespace Nektar
"Missing parameter 'OutputFile'.");
m_outputFile = pParams.find("OutputFile")->second;
}
ASSERTL0(pParams.find("OutputFrequency") != pParams.end(),
"Missing parameter 'OutputFrequency'.");
m_outputFrequency = atoi(pParams.find("OutputFrequency")->second.c_str());
m_numAverages = 0;
m_index = 0;
if(pParams.find("SampleFrequency") == pParams.end())
{
m_sampleFrequency = 1;
}
else
{
m_sampleFrequency = atoi(pParams.find("SampleFrequency")->second.c_str());
}
if(pParams.find("OutputFrequency") == pParams.end())
{
m_outputFrequency = m_session->GetParameter("NumSteps");
}
else
{
m_outputFrequency = atoi(pParams.find("OutputFrequency")->second.c_str());
}
m_numAverages = 0;
m_index = 0;
m_outputIndex = 0;
m_fld = MemoryManager<LibUtilities::FieldIO>::AllocateSharedPtr(pSession->GetComm());
}
......@@ -84,7 +99,7 @@ namespace Nektar
void FilterAverageFields::v_Update(const Array<OneD, const MultiRegions::ExpListSharedPtr> &pFields, const NekDouble &time)
{
m_index++;
if (m_index % m_outputFrequency > 0)
if (m_index % m_sampleFrequency > 0)
{
return;
}
......@@ -98,9 +113,20 @@ namespace Nektar
m_numAverages += 1;
// update FinalTime here since this is when last field will be added.
m_avgFieldMetaData["FinalTime"] = boost::lexical_cast<std::string>(time);
if (m_index % m_outputFrequency == 0)
{
OutputAvgField(pFields,++m_outputIndex);
}
}
void FilterAverageFields::v_Finalise(const Array<OneD, const MultiRegions::ExpListSharedPtr> &pFields, const NekDouble &time)
{
OutputAvgField(pFields);
}
void FilterAverageFields::OutputAvgField(const Array<OneD, const MultiRegions::ExpListSharedPtr> &pFields, int dump)
{
for(int n = 0; n < m_avgFields.num_elements(); ++n)
{
......@@ -111,14 +137,12 @@ namespace Nektar
= pFields[0]->GetFieldDefinitions();
std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
Array<OneD, NekDouble> fieldcoeffs;
int ncoeffs = pFields[0]->GetNcoeffs();
// copy Data into FieldData and set variable
for(int j = 0; j < pFields.num_elements(); ++j)
{
{
// check to see if field is same order a zeroth field
if(m_avgFields[j].num_elements() == ncoeffs)
{
......@@ -129,7 +153,7 @@ namespace Nektar
fieldcoeffs = Array<OneD,NekDouble>(ncoeffs);
pFields[0]->ExtractCoeffsToCoeffs(pFields[j],m_avgFields[j],fieldcoeffs);
}
for(int i = 0; i < FieldDef.size(); ++i)
{
// Could do a search here to find correct variable
......@@ -139,7 +163,27 @@ namespace Nektar
}
m_avgFieldMetaData["NumberOfFieldDumps"] = boost::lexical_cast<std::string>(m_numAverages);
m_fld->Write(m_outputFile,FieldDef,FieldData,m_avgFieldMetaData);
std::stringstream outname;
if(dump == -1) // final dump
{
outname << m_outputFile << "_avg.fld";
}
else
{
outname << m_outputFile<< "_" << dump << "_avg.fld";
}
m_fld->Write(outname.str(),FieldDef,FieldData,m_avgFieldMetaData);
if(dump != -1) // not final dump so rescale cummulative average
{
for(int n = 0; n < m_avgFields.num_elements(); ++n)
{
Vmath::Smul(m_avgFields[n].num_elements(), (NekDouble) m_numAverages,
m_avgFields[n],1,m_avgFields[n],1);
}
}
}
bool FilterAverageFields::v_IsTimeDependent()
......
......@@ -68,11 +68,15 @@ namespace Nektar
virtual void v_Update(const Array<OneD, const MultiRegions::ExpListSharedPtr> &pFields, const NekDouble &time);
virtual void v_Finalise(const Array<OneD, const MultiRegions::ExpListSharedPtr> &pFields, const NekDouble &time);
virtual bool v_IsTimeDependent();
void OutputAvgField(const Array<OneD, const MultiRegions::ExpListSharedPtr> &pFields, int dump = -1);
private:
unsigned int m_numAverages;
unsigned int m_outputFrequency;
unsigned int m_sampleFrequency;
unsigned int m_index;
unsigned int m_outputIndex;
std::string m_outputFile;
LibUtilities::FieldIOSharedPtr m_fld;
LibUtilities::FieldMetaDataMap m_avgFieldMetaData;
......
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