Commit 7a167518 authored by Dave Moxey's avatar Dave Moxey

Merge branch 'feature/FieldConvertHomogeneousPlane' into 'master'

Feature/field convert homogeneous plane

This MR creates a module to FieldConvert that extracts one of the planes of a 3DH1D expansion (with the option of getting it in wavespace). This way we can easily obtain slices along the z-direction.

The meanmode module is also modified to use this new module, avoiding duplicate code.

See merge request !542
parents a68e45c2 b4bdf2b3
......@@ -31,6 +31,7 @@ v4.3.0
- Small fixes in interpolation routine (!515)
- Add support for surface extraction in 3DH1D case (!521)
- Add support for isocontour extraction for 3DH1D (!525)
- Add module to extract one of the planes of 3DH1D (!542)
- Add module to enable mean mode of 3DH1D to be extracted (!530)
- Fix bug in C^0 projection (!541))
- Add command line option to set number of homogeneous planes (!540)
......
......@@ -99,6 +99,7 @@ Specifically, FieldConvert has these additional functionalities
\item \inltt{concatenate}: Concatenate a \nekpp binary output (.chk or .fld) field file into single file;
\item \inltt{equispacedoutput}: Write data as equi-spaced output using simplices to represent the data for connecting points;
\item \inltt{extract}: Extract a boundary field;
\item \inltt{homplane}: Extract a plane from 3DH1D expansions;
\item \inltt{interpfield}: Interpolates one field to another, requires fromxml, fromfld to be defined;
\item \inltt{interppointdatatofld}: Interpolates given discrete data using a finite difference approximation to a fld file given an xml file;
\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;
......@@ -253,6 +254,27 @@ way as described in section \ref{s:utilities:fieldconvert:sub:convert}
to visualise either in Tecplot or in Paraview the result.
%
%
\subsection{Extract a plane from 3DH1D expansion: \textit{homplane} module}
To obtain a 2D expansion containing one of the planes of a
3DH1D field file, use the command:
\begin{lstlisting}[style=BashInputStyle]
FieldConvert -m homplane:planeid=value file.xml file.fld file-plane.fld
\end{lstlisting}
If the option \inltt{wavespace} is used, the Fourier coefficients
corresponding to \inltt{planeid} are obtained. The command in this case is:
\begin{lstlisting}[style=BashInputStyle]
FieldConvert -m homplane:wavespace:planeid=value file.xml \
file.fld file-plane.fld
\end{lstlisting}
The output file \inltt{file-plane.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{Interpolate one field to another: \textit{interpfield} module}
......@@ -445,7 +467,7 @@ to visualise it either in Tecplot or in Paraview the result.
%
%
\subsection{Extract mean mode of 3Dh1D expansion: \textit{meanmode} module}
\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:
......
......@@ -17,6 +17,7 @@ SET(FieldConvertHeaders
ProcessModules/ProcessDisplacement.h
ProcessModules/ProcessEquiSpacedOutput.h
ProcessModules/ProcessGrad.h
ProcessModules/ProcessHomogeneousPlane.h
ProcessModules/ProcessInterpField.h
ProcessModules/ProcessInterpPoints.h
ProcessModules/ProcessInterpPointDataToFld.h
......@@ -54,6 +55,7 @@ SET(FieldConvertSources
ProcessModules/ProcessDisplacement.cpp
ProcessModules/ProcessEquiSpacedOutput.cpp
ProcessModules/ProcessGrad.cpp
ProcessModules/ProcessHomogeneousPlane.cpp
ProcessModules/ProcessInterpField.cpp
ProcessModules/ProcessInterpPoints.cpp
ProcessModules/ProcessInterpPointDataToFld.cpp
......@@ -85,6 +87,7 @@ ADD_NEKTAR_TEST(bfs_vort)
ADD_NEKTAR_TEST(bfs_vort_rng)
# ADD_NEKTAR_TEST(chan3D_pts)
ADD_NEKTAR_TEST(chan3DH1D_meanmode)
ADD_NEKTAR_TEST(chan3DH1D_plane)
ADD_NEKTAR_TEST(cube_prismhex)
# windows produces slightly differently formatted files which results in
......
////////////////////////////////////////////////////////////////////////////////
//
// File: ProcessHomogeneousPlane.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 a single plane of a 3DH1D field.
//
////////////////////////////////////////////////////////////////////////////////
#include <string>
#include <iostream>
using namespace std;
#include "ProcessHomogeneousPlane.h"
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <LibUtilities/BasicUtils/ParseUtils.hpp>
namespace Nektar
{
namespace Utilities
{
ModuleKey ProcessHomogeneousPlane::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "homplane"),
ProcessHomogeneousPlane::create,
"Extracts a plane from a 3DH1D expansion, requires planeid to be "
"defined.");
ProcessHomogeneousPlane::ProcessHomogeneousPlane(FieldSharedPtr f)
: ProcessModule(f)
{
m_config["planeid"] = ConfigOption(false, "NotSet", "plane id to extract");
m_config["wavespace"] =
ConfigOption(true, "NotSet", "Extract plane in Fourier space");
}
ProcessHomogeneousPlane::~ProcessHomogeneousPlane()
{
}
void ProcessHomogeneousPlane::Process(po::variables_map &vm)
{
if (m_f->m_verbose)
{
cout << "ProcessHomogeneousPlane: Extracting plane..." << endl;
}
if ((m_f->m_fielddef[0]->m_numHomogeneousDir) != 1)
{
ASSERTL0(false,
"ProcessHomogeneousPlane only works for Homogeneous1D.");
}
ASSERTL0(m_config["planeid"].m_beenSet,
"Missing parameter planeid for ProcessHomogeneousPlane");
int planeid = m_config["planeid"].as<int>();
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(planeid);
if (m_config["wavespace"].m_beenSet)
{
m_f->m_exp[n]->BwdTrans(m_f->m_exp[n]->GetCoeffs(),
m_f->m_exp[n]->UpdatePhys());
}
else
{
m_f->m_exp[n]->FwdTrans(m_f->m_exp[n]->GetPhys(),
m_f->m_exp[n]->UpdateCoeffs());
}
}
}
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: ProcessHomogeneousPlane.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 a single plane of a 3DH1D field.
//
////////////////////////////////////////////////////////////////////////////////
#ifndef UTILITIES_PREPROCESSING_FIELDCONVERT_PROCESSHOMOGENEOUSPLANE
#define UTILITIES_PREPROCESSING_FIELDCONVERT_PROCESSHOMOGENEOUSPLANE
#include "../Module.h"
namespace Nektar
{
namespace Utilities
{
/**
* @brief This processing module replaces all expansions by a single plane from
* 3DH1D fields, defined by the parameter planeid
*/
class ProcessHomogeneousPlane : public ProcessModule
{
public:
/// Creates an instance of this class
static boost::shared_ptr<Module> create(FieldSharedPtr f)
{
return MemoryManager<ProcessHomogeneousPlane>::AllocateSharedPtr(f);
}
static ModuleKey className;
ProcessHomogeneousPlane(FieldSharedPtr f);
virtual ~ProcessHomogeneousPlane();
/// Write mesh to output file.
virtual void Process(po::variables_map &vm);
};
}
}
#endif
......@@ -50,9 +50,10 @@ namespace Utilities
ModuleKey ProcessMeanMode::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "meanmode"),
ProcessMeanMode::create, "Extract mean mode from 3DH1D.");
ProcessMeanMode::create,
"Extract mean mode from 3DH1D.");
ProcessMeanMode::ProcessMeanMode(FieldSharedPtr f) : ProcessModule(f)
ProcessMeanMode::ProcessMeanMode(FieldSharedPtr f) : ProcessHomogeneousPlane(f)
{
}
......@@ -67,52 +68,16 @@ void ProcessMeanMode::Process(po::variables_map &vm)
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;
// Set parameters for mean mode
RegisterConfig("planeid", "0");
RegisterConfig("wavespace", "1");
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;
ProcessHomogeneousPlane::Process(vm);
}
}
}
......@@ -37,31 +37,32 @@
#define UTILITIES_PREPROCESSING_FIELDCONVERT_PROCESSMEANMODE
#include "../Module.h"
#include "ProcessHomogeneousPlane.h"
namespace Nektar
{
namespace Utilities
{
/**
* @brief This processing module replaces all expansions by the mean mode
* from 3DH1D fields
* @brief This processing module replaces all expansions by the mean mode from
* 3DH1D fields
*/
class ProcessMeanMode : public ProcessModule
class ProcessMeanMode : public ProcessHomogeneousPlane
{
public:
/// Creates an instance of this class
static boost::shared_ptr<Module> create(FieldSharedPtr f) {
return MemoryManager<ProcessMeanMode>::AllocateSharedPtr(f);
}
static ModuleKey className;
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();
ProcessMeanMode(FieldSharedPtr f);
virtual ~ProcessMeanMode();
/// Write mesh to output file.
virtual void Process(po::variables_map &vm);
/// Write mesh to output file.
virtual void Process(po::variables_map &vm);
};
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<test>
<description> Process 3DH1D plane output </description>
<executable>FieldConvert</executable>
<parameters> -m homplane:planeid=4 -e chan3DH1D.xml chan3DH1D.fld chan3DH1D_plane.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