Skip to content
Snippets Groups Projects
Commit c0ab53bd authored by Ganlin's avatar Ganlin Committed by Mohsen Lahooti
Browse files

Zero an input homo-plane in wavespace

parent f0da9778
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@ v5.5.0
**FieldConvert**
- Fix typo in user-guide and fix but for parallel-in-time FieldConvert (!1645)
- Fixed FieldConvert -m addfld (!1500)
- Add a new FieldConvert module to zero a plane in wavespace (!1632)
- Fix tecplot output for line and plane points (!1497)
**CI**
......
......@@ -433,7 +433,8 @@ possibly also Reynolds stresses) into single file;
project the velocity components from Cartesian coordinate system into the new
coordinate system;
\item \inltt{averagefld}: Compute the averaging of several field files;
\item \inltt{powerspectrum}: Compute power spectrum at given regions from a 3DH1D expansion.
\item \inltt{powerspectrum}: Compute power spectrum at given regions from a 3DH1D expansion;
\item \inltt{zero-homo-plane}: Zero a specfied homogeneous plane in wavespace.
\end{enumerate}
The module list above can be seen by running the command
%
......@@ -1507,6 +1508,23 @@ filter to process data. See \ref{filters:BodyFittedVelocity}.
%
%
\subsection{Zero a homogeneous plane in wavespace: \textit{zero-homo-plane} module}
\label{s:utilities:fieldconvert:sub:zero-homo-plane}
In cases the users would like to visualize the fluctuations in a 3DH1D flow
field, the mean mode is expected to be removed (in the Fourier space). This can
be achieved by running the current module:
\begin{lstlisting}[style=BashInputStyle]
FieldConvert -m zero-homo-plane:planeid=0 mesh.xml session.xml field.fld \
field-zeroMean.fld
\end{lstlisting}
In general, \inltt{planeid} can be any meaningful plane id, which is 0 by
default.
%
%
%
\subsection{Manipulating meshes with FieldConvert}
FieldConvert has support for two modules that can be used in conjunction with
the linear elastic solver, as shown in chapter~\ref{s:elasticity}. To do this,
......
......@@ -64,6 +64,7 @@ SET(FieldUtilsHeaders
ProcessModules/ProcessC0Projection.h
ProcessModules/ProcessQCriterion.h
ProcessModules/ProcessQualityMetric.h
ProcessModules/ProcessZeroHomogeneousPlane.h
)
SET(FieldUtilsSources
......@@ -131,6 +132,7 @@ SET(FieldUtilsSources
ProcessModules/ProcessC0Projection.cpp
ProcessModules/ProcessQCriterion.cpp
ProcessModules/ProcessQualityMetric.cpp
ProcessModules/ProcessZeroHomogeneousPlane.cpp
)
IF (NEKTAR_USE_VTK)
......
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessZeroHomogeneousPlane.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).
//
// 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: Zero the homogeneous plane in wavespace of a 3DH1D field to
// visualise the fluctuation.
//
////////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
using namespace std;
#include <boost/core/ignore_unused.hpp>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include "ProcessZeroHomogeneousPlane.h"
namespace Nektar
{
namespace FieldUtils
{
ModuleKey ProcessZeroHomogeneousPlane::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "zero-homo-plane"),
ProcessZeroHomogeneousPlane::create,
"Extracts a plane from a 3DH1D expansion, requires planeid to be "
"defined.");
ProcessZeroHomogeneousPlane::ProcessZeroHomogeneousPlane(FieldSharedPtr f)
: ProcessModule(f)
{
m_config["planeid"] = ConfigOption(
false, "0",
"plane id in wavespace to be set zero. Default planeid is zero");
}
ProcessZeroHomogeneousPlane::~ProcessZeroHomogeneousPlane()
{
}
void ProcessZeroHomogeneousPlane::v_Process(po::variables_map &vm)
{
m_f->SetUpExp(vm);
if (m_f->m_numHomogeneousDir != 1)
{
NEKERROR(ErrorUtil::efatal,
"ProcessZeroHomogeneousPlane only works for Homogeneous1D.");
}
// Skip in case of empty partition
if (m_f->m_exp[0]->GetNumElmts() == 0)
{
return;
}
int planeid = m_config["planeid"].as<int>();
int nfields = m_f->m_variables.size();
int nstrips;
m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
// Look for correct plane (because of parallel case)
int plane = -1;
for (int i = 0; i < m_f->m_exp[0]->GetZIDs().size(); ++i)
{
if (m_f->m_exp[0]->GetZIDs()[i] == planeid)
{
plane = i;
}
}
if (plane != -1)
{
for (int s = 0; s < nstrips; ++s)
{
for (int i = 0; i < nfields; ++i)
{
int n = s * nfields + i;
// Find the memory location, set zeros
int Ncoeff = m_f->m_exp[n]->GetPlane(plane)->GetNcoeffs();
Vmath::Zero(Ncoeff,
m_f->m_exp[n]->GetPlane(plane)->UpdateCoeffs(), 1);
m_f->m_exp[n]->BwdTrans(m_f->m_exp[n]->GetCoeffs(),
m_f->m_exp[n]->UpdatePhys());
}
}
}
else
{
NEKERROR(ErrorUtil::efatal, "Plane not found.");
}
}
} // namespace FieldUtils
} // namespace Nektar
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessZeroHomogeneousPlane.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).
//
// 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: Zero the homogeneous plane in wavespace of a 3DH1D field to
// visualise the fluctuation.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef FIELDUTILS_PROCESSZEROHOMOGENEOUSPLANE
#define FIELDUTILS_PROCESSZEROHOMOGENEOUSPLANE
#include "../Module.h"
namespace Nektar
{
namespace FieldUtils
{
/**
* @brief This processing module replaces all expansions by a single plane from
* 3DH1D fields, defined by the parameter planeid
*/
class ProcessZeroHomogeneousPlane : public ProcessModule
{
public:
/// Creates an instance of this class
static std::shared_ptr<Module> create(FieldSharedPtr f)
{
return MemoryManager<ProcessZeroHomogeneousPlane>::AllocateSharedPtr(f);
}
static ModuleKey className;
ProcessZeroHomogeneousPlane(FieldSharedPtr f);
virtual ~ProcessZeroHomogeneousPlane();
protected:
/// Write mesh to output file.
virtual void v_Process(po::variables_map &vm) override;
virtual std::string v_GetModuleName() override
{
return "ProcessZeroHomogeneousPlane";
}
virtual std::string v_GetModuleDescription() override
{
return "Zero the homogeneous plane to visualise the oscillations";
}
virtual ModulePriority v_GetModulePriority() override
{
return eModifyExp;
}
};
} // namespace FieldUtils
} // namespace Nektar
#endif
<?xml version="1.0" encoding="utf-8"?>
<NEKTAR>
<EXPANSIONS>
<E COMPOSITE="C[100,101]" NUMMODES="3" 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="SpectralhpDealiasing" VALUE="True" />
<I PROPERTY="SpectralVanishingViscositySpectralHP" VALUE="True" />
<I PROPERTY="SpectralVanishingViscosityHomo1D" VALUE="True" />
<I PROPERTY="HOMOGENEOUS" VALUE="1D" />
<!--<I PROPERTY="UseFFT" VALUE="FFTW" />-->
<I PROPERTY="GlobalSysSoln" VALUE="XxtMultiLevelStaticCond" />
</SOLVERINFO>
<PARAMETERS>
<P> TimeStep = 1.0e-3 </P>
<P> NumSteps = 5e3 </P>
<P> IO_CheckSteps = 1e4 </P>
<P> IO_InfoSteps = 1e3 </P>
<P> IO_CFLSteps = 1e3 </P>
<P> Re = 100.0 </P>
<P> uInf = 1.0 </P>
<P> vInf = 0.0 </P>
<P> wInf = 0.0 </P>
<P> Kinvis = 1.0/Re </P>
<P> LZ = 1.0 </P>
<P> HomModesZ = 4 </P>
<P> SVVDiffCoeff = 0.1 </P>
<P> SVVCutoffRatio = 0.7 </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[3] </B> <!-- bottom -->
<B ID="1"> C[1] </B> <!-- inflow -->
<B ID="2"> C[2] </B> <!-- outflow -->
<B ID="3"> C[4] </B> <!-- top -->
</BOUNDARYREGIONS>
<BOUNDARYCONDITIONS>
<!-- bottom -->
<REGION REF="0">
<P VAR="u" VALUE="[3]" />
<P VAR="v" VALUE="[3]" />
<P VAR="w" VALUE="[3]" />
<P VAR="p" VALUE="[3]" />
</REGION>
<!-- top -->
<REGION REF="3">
<P VAR="u" VALUE="[0]" />
<P VAR="v" VALUE="[0]" />
<P VAR="w" VALUE="[0]" />
<P VAR="p" VALUE="[0]" />
</REGION>
<!-- outflow -->
<REGION REF="1">
<N VAR="u" USERDEFINEDTYPE="HOutflow" VALUE="0" />
<N VAR="v" USERDEFINEDTYPE="HOutflow" VALUE="0" />
<N VAR="w" USERDEFINEDTYPE="HOutflow" VALUE="0" />
<D VAR="p" USERDEFINEDTYPE="HOutflow" VALUE="0" />
</REGION>
<!-- inflow -->
<REGION REF="2">
<D VAR="u" VALUE="uInf" />
<D VAR="v" VALUE="vInf" />
<D VAR="w" VALUE="wInf" />
<N VAR="p" USERDEFINEDTYPE="H" VALUE="0" />
</REGION>
</BOUNDARYCONDITIONS>
<FUNCTION NAME="InitialConditions">
<E VAR="u" VALUE="uInf" />
<E VAR="v" VALUE="vInf" />
<E VAR="w" VALUE="wInf" />
<E VAR="p" VALUE="0" />
</FUNCTION>
</CONDITIONS>
</NEKTAR>
<?xml version="1.0" encoding="utf-8" ?>
<NEKTAR>
<GEOMETRY DIM="2" SPACE="2">
<VERTEX COMPRESSED="B64Z-LittleEndian" BITSIZE="64">eJxjYMAPGKH098X/geC9Pbo8E1b5D3B1zFhNRcizoEo4oKtkxSqP0M8Gpcs8UMTh5rBjtR8hz4FdHC4PAGLNFKcA</VERTEX>
<EDGE COMPRESSED="B64Z-LittleEndian" BITSIZE="64">eJx1j7kNADAIA/P/2X/dVFfEkt1YJ8BACL+i8WQ8G0dFcuBquAmzpwvTN4Tpm2ZuCTO/Td6Re6hfyefvB2HQAMoA</EDGE>
<ELEMENT>
<T COMPRESSED="B64Z-LittleEndian" BITSIZE="64">eJxjYoAAdijNAaU5oTQzlOaC0txo6lmgNBuU5kFTz4pmHi+UZoLSAB5gAHcA</T>
<Q COMPRESSED="B64Z-LittleEndian" BITSIZE="64">eJxjYEAFjFCaCUozo4mzQGlWKM2GJg8AAxgAGAAA</Q>
</ELEMENT>
<COMPOSITE>
<C ID="1"> E[13,3] </C>
<C ID="2"> E[5,12] </C>
<C ID="3"> E[0,4] </C>
<C ID="4"> E[8,11] </C>
<C ID="100"> Q[0-1] </C>
<C ID="101"> T[2-5] </C>
</COMPOSITE>
<DOMAIN> C[100-101] </DOMAIN>
</GEOMETRY>
<Metadata>
<Provenance>
<GitBranch>refs/heads/master</GitBranch>
<GitSHA1>e29c5b6f2f5e7ce6e75f364d485472399668baf7</GitSHA1>
<Hostname>LAPTOP-FIIC1OQ2</Hostname>
<NektarVersion>5.0.0</NektarVersion>
<Timestamp>26-Oct-2023 17:29:22</Timestamp>
</Provenance>
<NekMeshCommandLine>-m peralign:surf1=3:surf2=4:dir=y square_mix.xml square_mix_aligned.xml </NekMeshCommandLine>
</Metadata>
<EXPANSIONS>
<E COMPOSITE="C[100]" NUMMODES="4" TYPE="MODIFIED" FIELDS="u" />
<E COMPOSITE="C[101]" NUMMODES="4" TYPE="MODIFIED" FIELDS="u" />
</EXPANSIONS>
</NEKTAR>
<?xml version="1.0" encoding="utf-8" ?>
<test>
<description>Test the zero-homo-plane FieldConvert module</description>
<executable>FieldConvert</executable>
<parameters>-m zero-homo-plane:planeid=0 square_mix.xml session_zero-homo-plane.xml zero-homo-plane_pre.fld zero-homo-plane_post.fld -f -e</parameters>
<files>
<file description="Session File">square_mix.xml</file>
<file description="Session File">session_zero-homo-plane.xml</file>
<file description="Session File">zero-homo-plane_pre.fld</file>
</files>
<metrics>
<metric type="L2" id="1">
<value variable="x" tolerance="1e-6">1.63299</value>
<value variable="y" tolerance="1e-6">1.63299</value>
<value variable="z" tolerance="1e-6">0.661438</value>
<value variable="u" tolerance="1e-6">0.0</value>
<value variable="v" tolerance="1e-6">0.0</value>
<value variable="w" tolerance="1e-6">0.0</value>
<value variable="p" tolerance="1e-6">0.0</value>
</metric>
<metric type="Linf" id="2">
<value variable="x" tolerance="1e-6">2.0</value>
<value variable="y" tolerance="1e-6">2.0</value>
<value variable="z" tolerance="1e-6">0.75</value>
<value variable="u" tolerance="1e-6">0.0</value>
<value variable="v" tolerance="1e-6">0.0</value>
<value variable="w" tolerance="1e-6">0.0</value>
<value variable="p" tolerance="1e-6">0.0</value>
</metric>
</metrics>
</test>
<?xml version="1.0" encoding="utf-8" ?>
<NEKTAR>
<Metadata>
<Provenance>
<GitBranch>refs/heads/feature/zero_mean_mode</GitBranch>
<GitSHA1>95f7c96a08b3fe457b152280295ffd80ea38900a</GitSHA1>
<Hostname>ae-gl19</Hostname>
<NektarVersion>5.3.0</NektarVersion>
<Timestamp>30-Oct-2023 00:22:16</Timestamp>
</Provenance>
<ChkFileNum>1</ChkFileNum>
<Kinvis>0.01</Kinvis>
<SessionName0>square_mix.opt</SessionName0>
<SessionName1>square_mix.xml</SessionName1>
<SessionName2>session_zero-homo-plane.xml</SessionName2>
<Time>5.0000000000000044</Time>
<TimeStep>0.001</TimeStep>
</Metadata>
<ELEMENTS FIELDS="u,v,w,p" SHAPE="Triangle-HomogenousExp1D" BASIS="Modified_A,Modified_B,Fourier" HOMOGENEOUSLENGTHS="1" HOMOGENEOUSZIDS="0,1,2,3" NUMMODESPERDIR="UNIORDER:3,3,4" ID="2-5" COMPRESSED="B64Z-LittleEndian" BITSIZE="64">eJx7oM4ABB/s9TkhNIhkkJu2t0kOwv9z7H7VhWdGe0G8Fb+XgunBBB5A3Q9zL4hEuPODvZbKg5NHI3sgfL5g2wFxJB4Acz+EB6Xh7oSJQ0BBUuegDf9Ll/8DwXuwexty1+9FSU/p6yD+AaargXElbhCV5rTlwKR62+1FgkyXjzywzdq5TtP44/O9uXcaL2ZPbtzL+P7C8WblJ3vTV8stSb+2fNC6H+ZedHf+S7noaRNwdW/azvbnTFevDVr3w/i43Jn5d4KPR9DNQev+qqtLDe0uPbB9k9KwgHXp072w9CRwRLNcOmrrXli6Gmj3joJRMAoQoP4AqN66v3+DOIj3YP8qri+ztTqm2n6YBxF3Ufw3Izi1aC/rusVRFmIzBl3+hbkf5l6YO3eagGQf7D8Tdty0XmL53n0ce//wZi0cdO0fmPth7oW58/WKf2Dxgi+3rT/+m7R35XQHtvOpOwdt+DOsh9CV5mxqKTOm28LSE1hR7rq9sHQ1oI7FAgDl3Pg3</ELEMENTS>
<ELEMENTS FIELDS="u,v,w,p" SHAPE="Quadrilateral-HomogenousExp1D" BASIS="Modified_A,Modified_A,Fourier" HOMOGENEOUSLENGTHS="1" HOMOGENEOUSZIDS="0,1,2,3" NUMMODESPERDIR="UNIORDER:3,3,4" ID="0-1" COMPRESSED="B64Z-LittleEndian" BITSIZE="64">eJzT52QAgg/2TXIQ+s+x+1UXnhntvXT5PxC8t3+gDhEHkQ256/eCaIbn/WC6K2HDXhfjufWGEy7aMgxTAAsXCO+DvZbKg5NHI3v2IocLjC5I6oSHC0z/ulWvOCcxrRm24bO9SJDp8pEHtrl3Gi9mT27cy/j+wvFm5Sd7q64uNbS79MA2Ks1py4FJ9bZvUhoWsC59ujfgUvyKqTrL955heHS3z6nBNiF16Qe3h6f3ErZpaAJYuMD4/1IuetoEXN0LCxeYeObfCT4eQTfh4QITP9x9qeeY3JRhGz6jYBRQAt4IgsgH+z/MA9VX9/e7KP6bEZxatJdjPYRffwBCV5qzqaXMmA7JV1aTbNnFpyeprpu/9+rhpRPiD+8ftvkLFi47TUC8B/vPhB03rZdYvhcWLq9X/APTK6c7sJ1P3bkXFi4m3TPcNe4s2zt356vte/kfD9v6CwCFWMUV</ELEMENTS>
</NEKTAR>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment