Commit 96cada2b authored by Kilian Lackhove's avatar Kilian Lackhove

Merge branch 'feature/FC-avgValue' into 'master'

New FC module for evaluating average value

See merge request !894
parents 5b1c3e2a 94bb5193
......@@ -69,6 +69,7 @@ v5.0.0
- Allow using xml file without expansion tag in FieldConvert (!849)
- Add Lambda 2 vortex detection criteria (!882)
- Add module for calculating new field from existing ones (!889)
- Add module for evaluating the mean of variables on the domain (!894)
**IncNavierStokesSolver**
- Replace steady-state check based on difference of norms by check based on
......
......@@ -175,6 +175,7 @@ possibly also Reynolds stresses) into single file;
\item \inltt{isocontour}: Extract an isocontour of ``fieldid'' variable and at value ``fieldvalue''. Optionally ``fieldstr'' can be specified for a string definition or ``smooth'' for smoothing;
\item \inltt{jacobianenergy}: Shows high frequency energy of Jacobian;
\item \inltt{qualitymetric}: Evaluate a quality metric of the underlying mesh to show mesh quality;
\item \inltt{mean}: Evaluate the mean of variables on the domain;
\item \inltt{meanmode}: Extract mean mode (plane zero) of 3DH1D expansions;
\item \inltt{pointdatatofld}: Given discrete data at quadrature points
project them onto an expansion basis and output fld file;
......@@ -806,7 +807,20 @@ Two quality metrics are implemented that produce scalar fields $Q$:
%
%
%
\subsection{Evaluate the mean of variables on the domain: \textit{mean} module}
To evaluate the mean of variables on the domain one can use the
\inltt{mean} module of FieldConvert
%
\begin{lstlisting}[style=BashInputStyle]
FieldConvert -m mean file1.xml file2.fld out.stdout
\end{lstlisting}
%
This module does not create an output file which is reinforced by the
out.stdout option. The integral and mean for each field variable are
then printed to the stdout.
%
%
%
\subsection{Extract mean mode of 3DH1D expansion: \textit{meanmode} module}
To obtain a 2D expansion containing the mean mode (plane zero in Fourier space) of a
......
......@@ -39,6 +39,7 @@ SET(FieldUtilsHeaders
ProcessModules/ProcessL2Criterion.h
ProcessModules/ProcessMapping.h
ProcessModules/ProcessNumModes.h
ProcessModules/ProcessMean.h
ProcessModules/ProcessMeanMode.h
ProcessModules/ProcessPointDataToFld.h
ProcessModules/ProcessPrintFldNorms.h
......@@ -94,6 +95,7 @@ SET(FieldUtilsSources
ProcessModules/ProcessL2Criterion.cpp
ProcessModules/ProcessMapping.cpp
ProcessModules/ProcessNumModes.cpp
ProcessModules/ProcessMean.cpp
ProcessModules/ProcessMeanMode.cpp
ProcessModules/ProcessPointDataToFld.cpp
ProcessModules/ProcessPrintFldNorms.cpp
......
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessMean.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: Compute the mean of each field.
//
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
using namespace std;
#include "ProcessMean.h"
#include <LibUtilities/BasicUtils/SharedArray.hpp>
namespace Nektar
{
namespace FieldUtils
{
ModuleKey ProcessMean::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "mean"), ProcessMean::create,
"compute the mean of each field over the domain.");
ProcessMean::ProcessMean(FieldSharedPtr f) : ProcessModule(f)
{
}
ProcessMean::~ProcessMean()
{
}
void ProcessMean::Process(po::variables_map &vm)
{
int nfields = m_f->m_variables.size();
int spacedim = m_f->m_graph->GetMeshDimension() + m_f->m_numHomogeneousDir;
int npoints = m_f->m_exp[0]->GetNpoints();
// Calculate volume (or area)
Array<OneD, NekDouble> ones(npoints, 1.0);
NekDouble scale = m_f->m_exp[0]->Integral(ones);
// Output volume
string name[3] = {"length", "area", "volume"};
cout << "Domain " << name[spacedim - 1] << " : " << scale << endl;
// Calculate integral and mean of each field
for (int i = 0; i < nfields; ++i)
{
NekDouble integral = m_f->m_exp[0]->Integral(m_f->m_exp[i]->GetPhys());
if (m_f->m_comm->GetRank() == 0)
{
cout << "Integral (variable " << m_f->m_variables[i]
<< ") : " << integral << endl;
cout << "Mean (variable " << m_f->m_variables[i]
<< ") : " << integral / scale << endl;
}
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessMean.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
// 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: Compute the mean of each field.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef FIELDUTILS_PROCESSMEAN
#define FIELDUTILS_PROCESSMEAN
#include "../Module.h"
namespace Nektar
{
namespace FieldUtils
{
/**
* @brief This processing module computes the mean of each field.
*
*/
class ProcessMean : public ProcessModule
{
public:
/// Creates an instance of this class
static std::shared_ptr<Module> create(FieldSharedPtr f)
{
return MemoryManager<ProcessMean>::AllocateSharedPtr(f);
}
static ModuleKey className;
ProcessMean(FieldSharedPtr f);
virtual ~ProcessMean();
/// Write mesh to output file.
virtual void Process(po::variables_map &vm);
virtual std::string GetModuleName()
{
return "ProcessMean";
}
virtual std::string GetModuleDescription()
{
return "Evaluating mean";
}
virtual ModulePriority GetModulePriority()
{
return eModifyExp;
}
};
}
}
#endif
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