Commit 55116c47 authored by Dave Moxey's avatar Dave Moxey

Merge branch 'feature/FieldConvert-MeanMode' into 'master'

Create mean mode module for FieldConvert

This MR creates a module for FieldConvert which extracts the mean mode (plane zero) from a Homogeneous1D expansion.

See merge request !530
parents 373aa860 42486af5
......@@ -104,6 +104,7 @@ Specifically, FieldConvert has these additional functionalities
\item \inltt{interppoints}: Interpolates a set of points to another, requires fromfld and fromxml to be defined, a line or plane of points can be defined;
\item \inltt{isocontour}: Extract an isocontour of ``fieldid'' variable and at value ``fieldvalue''. Optionally ``fieldstr'' can be specified for a string defiition or ``smooth'' for smoothing;
\item \inltt{jacobianenergy}: Shows high frequency energy of Jacobian;
\item \inltt{meanmode}: Extract mean mode (plane zero) of 3DH1D expansions;
\item \inltt{printfldnorms}: Print L2 and LInf norms to stdout;
\item \inltt{scalargrad}: Computes scalar gradient field;
\item \inltt{scaleinputfld}: Rescale input field by a constant factor;
......@@ -444,6 +445,22 @@ to visualise it either in Tecplot or in Paraview the result.
%
%
\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
3DH1D field file, use the command:
\begin{lstlisting}[style=BashInputStyle]
FieldConvert -m meanmode file.xml file.fld file-mean.fld
\end{lstlisting}
The output file \inltt{file-mean.fld} can be processed in a similar
way as described in section \ref{s:utilities:fieldconvert:sub:convert}
to visualise it either in Tecplot or in Paraview.
%
%
%
\subsection{Print L2 and LInf norms: \textit{printfldnorms} module}
\begin{lstlisting}[style=BashInputStyle]
......
......@@ -22,6 +22,7 @@ SET(FieldConvertHeaders
ProcessModules/ProcessInterpPointDataToFld.h
ProcessModules/ProcessIsoContour.h
ProcessModules/ProcessJacobianEnergy.h
ProcessModules/ProcessMeanMode.h
ProcessModules/ProcessPrintFldNorms.h
ProcessModules/ProcessScaleInFld.h
ProcessModules/ProcessSurfDistance.h
......@@ -57,6 +58,7 @@ SET(FieldConvertSources
ProcessModules/ProcessInterpPointDataToFld.cpp
ProcessModules/ProcessIsoContour.cpp
ProcessModules/ProcessJacobianEnergy.cpp
ProcessModules/ProcessMeanMode.cpp
ProcessModules/ProcessPrintFldNorms.cpp
ProcessModules/ProcessScaleInFld.cpp
ProcessModules/ProcessVorticity.cpp
......@@ -80,6 +82,7 @@ ADD_NEKTAR_TEST(chan3D_vort)
ADD_NEKTAR_TEST(bfs_vort)
ADD_NEKTAR_TEST(bfs_vort_rng)
# ADD_NEKTAR_TEST(chan3D_pts)
ADD_NEKTAR_TEST(chan3DH1D_meanmode)
# windows produces slightly differently formatted files which results in
# different hashes
......
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessMeanMode.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: Extract mean mode of 3DH1D field.
//
////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <iostream>
using namespace std;
#include "ProcessMeanMode.h"
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <LibUtilities/BasicUtils/ParseUtils.hpp>
namespace Nektar
{
namespace Utilities
{
ModuleKey ProcessMeanMode::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "meanmode"),
ProcessMeanMode::create, "Extract mean mode from 3DH1D.");
ProcessMeanMode::ProcessMeanMode(FieldSharedPtr f) : ProcessModule(f)
{
}
ProcessMeanMode::~ProcessMeanMode()
{
}
void ProcessMeanMode::Process(po::variables_map &vm)
{
if (m_f->m_verbose)
{
cout << "ProcessMeanMode: Extracting mean mode..." << endl;
}
if ((m_f->m_fielddef[0]->m_numHomogeneousDir) != 1)
{
ASSERTL0(false, "ProcessMeanMode only works for Homogeneous1D.");
}
if (m_f->m_fielddef[0]->m_homogeneousZIDs[0] != 0)
{
ASSERTL0(false, "ProcessMeanMode: mean mode not found.");
}
int nfields = m_f->m_fielddef[0]->m_fields.size();
int nstrips;
m_f->m_session->LoadParameter("Strip_Z",nstrips,1);
for(int s = 0; s < nstrips; ++s)
{
for (int i = 0; i < nfields; ++i)
{
int n = s*nfields + i;
m_f->m_exp[n] = m_f->m_exp[n]->GetPlane(0);
m_f->m_exp[n]->BwdTrans(m_f->m_exp[n]->GetCoeffs(),
m_f->m_exp[n]->UpdatePhys());
}
}
std::vector<LibUtilities::FieldDefinitionsSharedPtr> FieldDef
= m_f->m_exp[0]->GetFieldDefinitions();
std::vector<std::vector<NekDouble> > FieldData(FieldDef.size());
for(int s = 0; s < nstrips; ++s)
{
for (int j = 0; j < nfields; ++j)
{
for (int i = 0; i < FieldDef.size()/nstrips; ++i)
{
int n = s * FieldDef.size()/nstrips + i;
FieldDef[n]->m_fields.push_back(m_f->m_fielddef[0]->m_fields[j]);
m_f->m_exp[s*nfields+j]->AppendFieldData(FieldDef[n], FieldData[n]);
}
}
}
m_f->m_fielddef = FieldDef;
m_f->m_data = FieldData;
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessMeanMode.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: Extract mean mode of 3DH1D field.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef UTILITIES_PREPROCESSING_FIELDCONVERT_PROCESSMEANMODE
#define UTILITIES_PREPROCESSING_FIELDCONVERT_PROCESSMEANMODE
#include "../Module.h"
namespace Nektar
{
namespace Utilities
{
/**
* @brief This processing module replaces all expansions by the mean mode
* from 3DH1D fields
*/
class ProcessMeanMode : public ProcessModule
{
public:
/// Creates an instance of this class
static boost::shared_ptr<Module> create(FieldSharedPtr f) {
return MemoryManager<ProcessMeanMode>::AllocateSharedPtr(f);
}
static ModuleKey className;
ProcessMeanMode(FieldSharedPtr f);
virtual ~ProcessMeanMode();
/// Write mesh to output file.
virtual void Process(po::variables_map &vm);
};
}
}
#endif
This diff is collapsed.
<?xml version="1.0" encoding="utf-8"?>
<NEKTAR>
<EXPANSIONS>
<E COMPOSITE="C[0]" NUMMODES="4" FIELDS="u,v,w,p" TYPE="MODIFIED" />
</EXPANSIONS>
<CONDITIONS>
<SOLVERINFO>
<I PROPERTY="SolverType" VALUE="VelocityCorrectionScheme"/>
<I PROPERTY="EQTYPE" VALUE="UnsteadyNavierStokes"/>
<I PROPERTY="AdvectionForm" VALUE="Convective"/>
<I PROPERTY="Projection" VALUE="Galerkin"/>
<I PROPERTY="TimeIntegrationMethod" VALUE="IMEXOrder2"/>
<I PROPERTY="HOMOGENEOUS" VALUE="1D"/>
</SOLVERINFO>
<PARAMETERS>
<P> TimeStep = 0.001 </P>
<P> NumSteps = 1000 </P>
<P> IO_CheckSteps = 1000 </P>
<P> IO_InfoSteps = 1000 </P>
<P> Kinvis = 1 </P>
<P> HomModesZ = 8 </P>
<P> LZ = 1.0 </P>
</PARAMETERS>
<VARIABLES>
<V ID="0"> u </V>
<V ID="1"> v </V>
<V ID="2"> w </V>
<V ID="3"> p </V>
</VARIABLES>
<BOUNDARYREGIONS>
<B ID="0"> C[1] </B>
<B ID="1"> C[2] </B>
<B ID="2"> C[3] </B>
</BOUNDARYREGIONS>
<BOUNDARYCONDITIONS>
<REGION REF="0">
<D VAR="u" VALUE="0" />
<D VAR="v" VALUE="0" />
<D VAR="w" VALUE="0" />
<N VAR="p" USERDEFINEDTYPE="H" VALUE="0" /> // High Order Pressure BC
</REGION>
<REGION REF="1">
<D VAR="u" VALUE="y*(1-y)" />
<D VAR="v" VALUE="0" />
<D VAR="w" VALUE="0" />
<N VAR="p" USERDEFINEDTYPE="H" VALUE="0" /> // High Order Pressure BC
</REGION>
<REGION REF="2">
<N VAR="u" VALUE="0" />
<N VAR="v" VALUE="0" />
<N VAR="w" VALUE="0" />
<D VAR="p" VALUE="0" />
</REGION>
</BOUNDARYCONDITIONS>
<FUNCTION NAME="InitialConditions">
<E VAR="u" VALUE="0" />
<E VAR="v" VALUE="0" />
<E VAR="w" VALUE="0" />
<E VAR="p" VALUE="0" />
</FUNCTION>
<FUNCTION NAME="ExactSolution">
<E VAR="u" VALUE="y*(1-y)" />
<E VAR="v" VALUE="0" />
<E VAR="w" VALUE="0" />
<E VAR="p" VALUE="-2*Kinvis*(x-1)" />
</FUNCTION>
</CONDITIONS>
<GEOMETRY DIM="2" SPACE="2">
<VERTEX>
<!-- Always must have four values per entry. -->
<V ID="0"> 0.0 0.0 0.0 </V>
<V ID="1"> 0.5 0.0 0.0 </V>
<V ID="2"> 1.0 0.0 0.0 </V>
<V ID="3"> 0.0 0.5 0.0 </V>
<V ID="4"> 0.5 0.5 0.0 </V>
<V ID="5"> 1.0 0.5 0.0 </V>
<V ID="6"> 0.0 1.0 0.0 </V>
<V ID="7"> 0.5 1.0 0.0 </V>
<V ID="8"> 1.0 1.0 0.0 </V>
</VERTEX>
<EDGE>
<E ID="0"> 0 1 </E>
<E ID="1"> 1 2 </E>
<E ID="2"> 0 3 </E>
<E ID="3"> 1 4 </E>
<E ID="4"> 2 5 </E>
<E ID="5"> 3 4 </E>
<E ID="6"> 4 5 </E>
<E ID="7"> 3 6 </E>
<E ID="8"> 4 7 </E>
<E ID="9"> 5 8 </E>
<E ID="10"> 6 7 </E>
<E ID="11"> 7 8 </E>
</EDGE>
<!-- Q - quads, T - triangles, S - segments, E - tet, P - pyramid, R - prism, H - hex -->
<!-- Only certain element types are appropriate for the given dimension (dim on mesh) -->
<!-- Can also use faces to define 3-D elements. Specify with F[1] for face 1, for example. -->
<ELEMENT>
<Q ID="0"> 0 3 5 2 </Q>
<Q ID="1"> 1 4 6 3 </Q>
<Q ID="2"> 5 8 10 7 </Q>
<Q ID="3"> 6 9 11 8 </Q>
</ELEMENT>
<COMPOSITE>
<C ID="0"> Q[0-3] </C>
<C ID="1"> E[0,1,10,11] </C> // Walls
<C ID="2"> E[2,7] </C> // Inflow
<C ID="3"> E[4,9] </C> // Outflow
</COMPOSITE>
<DOMAIN> C[0] </DOMAIN>
</GEOMETRY>
</NEKTAR>
<?xml version="1.0" encoding="utf-8"?>
<test>
<description> Process 3DH1D meanmode output </description>
<executable>FieldConvert</executable>
<parameters> -m meanmode -e chan3DH1D.xml chan3DH1D.fld chan3DH1D_mean.fld</parameters>
<files>
<file description="Session File">chan3DH1D.xml</file>
<file description="Session File">chan3DH1D.fld</file>
</files>
<metrics>
<metric type="L2" id="1">
<value variable="u" tolerance="1e-6">0.182574</value>
<value variable="v" tolerance="1e-6">0</value>
<value variable="w" tolerance="1e-6">0</value>
<value variable="p" tolerance="1e-6">1.1547</value>
</metric>
</metrics>
</test>
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