Commit ba470db6 authored by Chris Cantwell's avatar Chris Cantwell

Merge branch 'feature/ProcessRemoveField' into 'master'

FieldConvert module to remove fields from .fld files

See merge request !978
parents 870850d8 6619da9c
Pipeline #470 passed with stage
in 0 seconds
......@@ -109,6 +109,7 @@ v5.0.0
- Add module for evaluating the mean of variables on the domain (!894)
- Add module for counting the total number of DOF (!948)
- Fixed wss module for compressible flows (!958)
- Add module for removing fields from .fld files (!978)
**IncNavierStokesSolver**
- Replace steady-state check based on difference of norms by check based on
......
......@@ -181,6 +181,7 @@ possibly also Reynolds stresses) into single file;
\item \inltt{pointdatatofld}: Given discrete data at quadrature points
project them onto an expansion basis and output fld file;
\item \inltt{printfldnorms}: Print L2 and LInf norms to stdout;
\item \inltt{removefield}: Removes one or more fields from .fld files;
\item \inltt{scalargrad}: Computes scalar gradient field;
\item \inltt{scaleinputfld}: Rescale input field by a constant factor;
\item \inltt{shear}: Computes time-averaged shear stress metrics: TAWSS, OSI, transWSS, TAAFI, TACFI, WSSG;
......@@ -927,6 +928,19 @@ then printed to the stdout.
%
%
\subsection{Removes one or more fields from .fld files: \textit{removefield} module}
This module allows to remove one or more fields from a .fld file:
\begin{lstlisting}[style=BashInputStyle]
FieldConvert -m removefield:fieldname="u,v,p" test.xml test.fld test-removed.fld
\end{lstlisting}
where the file \inltt{test-removed.fld} can be processed in a similar
way as described in section \ref{s:utilities:fieldconvert:sub:convert}
to visualise the result either in Tecplot, Paraview or VisIt. The lighter resulting
file speeds up the postprocessing of large files when not all fields are required.
%
%
%
\subsection{Computes the scalar gradient: \textit{scalargrad} module}
The scalar gradient of a field is computed by running:
\begin{lstlisting}[style=BashInputStyle]
......
......@@ -44,6 +44,7 @@ SET(FieldUtilsHeaders
ProcessModules/ProcessMeanMode.h
ProcessModules/ProcessPointDataToFld.h
ProcessModules/ProcessPrintFldNorms.h
ProcessModules/ProcessRemoveField.h
ProcessModules/ProcessScaleInFld.h
ProcessModules/ProcessStreamFunction.h
ProcessModules/ProcessSurfDistance.h
......@@ -101,6 +102,7 @@ SET(FieldUtilsSources
ProcessModules/ProcessMeanMode.cpp
ProcessModules/ProcessPointDataToFld.cpp
ProcessModules/ProcessPrintFldNorms.cpp
ProcessModules/ProcessRemoveField.cpp
ProcessModules/ProcessScaleInFld.cpp
ProcessModules/ProcessVorticity.cpp
ProcessModules/ProcessScalGrad.cpp
......
///////////////////////////////////////////////////////////////////////////////
//
// File: ProcessRemoveField.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: Remove a variable
//
///////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
using namespace std;
#include "ProcessRemoveField.h"
#include <LibUtilities/BasicUtils/ParseUtils.h>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
namespace Nektar
{
namespace FieldUtils
{
ModuleKey ProcessRemoveField::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "removefield"), ProcessRemoveField::create,
"Remove one of the existing fields");
ProcessRemoveField::ProcessRemoveField(FieldSharedPtr f) : ProcessModule(f)
{
m_config["fieldname"] =
ConfigOption(false, "NotSet", "Name for field to be removed, required");
}
ProcessRemoveField::~ProcessRemoveField(void)
{
}
void ProcessRemoveField::Process(po::variables_map &vm)
{
// Obtain field names to be removed
string fieldNames = m_config["fieldname"].as<string>();
vector<string> fieldName;
ASSERTL0(fieldNames != "NotSet", "A fieldname is required");
ASSERTL0(ParseUtils::GenerateVector(fieldNames, fieldName),
"Failed to interpret fields string");
// Remove fields specified
for (int i = 0; i < fieldName.size(); ++i)
{
// check if field exists
auto it = std::find(m_f->m_variables.begin(), m_f->m_variables.end(),
fieldName[i]);
ASSERTL0(it != m_f->m_variables.end(), "Field does not exist");
int fieldID = std::distance(m_f->m_variables.begin(), it);
m_f->m_variables.erase(it);
m_f->m_exp.erase(m_f->m_exp.begin() + fieldID);
cout << "Field " << fieldName[i] << " has been erased" << endl;
}
}
} // namespace FieldUtils
} // namespace Nektar
///////////////////////////////////////////////////////////////////////////////
//
// File: ProcessRemoveField.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: Remove a variable
//
////////////////////////////////////////////////////////////////////////////////
#ifndef FIELDUTILS_PROCESSREMOVEFIELD
#define FIELDUTILS_PROCESSREMOVEFIELD
#include "../Module.h"
namespace Nektar
{
namespace FieldUtils
{
/**
* @brief This processing module adds a new field from a string definition
*/
class ProcessRemoveField : public ProcessModule
{
public:
/// Creates an instance of this class
static std::shared_ptr<Module> create(FieldSharedPtr f)
{
return MemoryManager<ProcessRemoveField>::AllocateSharedPtr(f);
}
static ModuleKey className;
ProcessRemoveField(FieldSharedPtr f);
virtual ~ProcessRemoveField();
virtual void Process(po::variables_map &vm);
virtual std::string GetModuleName()
{
return "ProcessRemoveField";
}
virtual std::string GetModuleDescription()
{
return "Removes specific fields from .fld";
}
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