Commit 94bb5193 authored by Douglas Serson's avatar Douglas Serson

Merge branch 'master' into feature/FC-avgValue

parents a8d10c62 627e37fc
......@@ -67,6 +67,7 @@ v5.0.0
- Enable output to multiple files (!844)
- 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**
......
......@@ -157,6 +157,7 @@ Specifically, FieldConvert has these additional functionalities
\item \inltt{QCriterion}: Computes the Q-Criterion for a given output file;
\item \inltt{L2Criterion}: Computes the Lambda 2 Criterion for a given output file;
\item \inltt{addcompositeid}: Adds the composite ID of an element as an additional field;
\item \inltt{addfieldfromstring}: Adds a new field from an expression involving the existing fields;
\item \inltt{addFld}: Sum two .fld files;
\item \inltt{combineAvg}: Combine two \nekpp binary output (.chk or .fld) field file containing averages of fields (and
possibly also Reynolds stresses) into single file;
......@@ -282,7 +283,28 @@ variable that contains the composite ID. To assist in boundary identification,
the input file \inlsh{mesh.xml} should be a surface XML file that can be
obtained through the \nm \inltt{extract} module (see section
\ref{s:utilities:nekmesh:extract}).
%
%
%
\subsection{Add new field: \textit{addfieldfromstring} module}
To create a new field using an expression involving the existing fields, one can
use the \inltt{addfieldfromstring} module of FieldConvert
%
\begin{lstlisting}[style=BashInputStyle]
FieldConvert -m addfieldfromstring:fieldstr="x+y+u":fieldname="result" \
file1.xml file2.fld file3.fld
\end{lstlisting}
%
In this case \inltt{fieldstr} is a required parameter describing a function of
the coordinates and the existing variables, and \inltt{fieldname} is an optional
parameter defining the name of the new field (the default is newfield).
\inltt{file3.fld} is the output containing both the original and the new fields,
and 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.
%
%
%
\subsection{Sum two .fld files: \textit{addFld} module}
To sum two .fld files one can use the \inltt{addFld} module of FieldConvert
%
......
......@@ -17,6 +17,7 @@ SET(FieldUtilsHeaders
OutputModules/OutputPts.h
OutputModules/OutputXml.h
ProcessModules/ProcessAddCompositeID.h
ProcessModules/ProcessAddFieldFromString.h
ProcessModules/ProcessAddFld.h
ProcessModules/ProcessBoundaryExtract.h
ProcessModules/ProcessCombineAvg.h
......@@ -72,6 +73,7 @@ SET(FieldUtilsSources
OutputModules/OutputPts.cpp
OutputModules/OutputXml.cpp
ProcessModules/ProcessAddCompositeID.cpp
ProcessModules/ProcessAddFieldFromString.cpp
ProcessModules/ProcessAddFld.cpp
ProcessModules/ProcessBoundaryExtract.cpp
ProcessModules/ProcessCombineAvg.cpp
......
///////////////////////////////////////////////////////////////////////////////
//
// File: ProcessAddFieldFromString.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: Add a new field from a string based on existing variable
//
///////////////////////////////////////////////////////////////////////////////
#include <iostream>
#include <string>
using namespace std;
#include "ProcessAddFieldFromString.h"
#include <LibUtilities/BasicUtils/ParseUtils.h>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
namespace Nektar
{
namespace FieldUtils
{
ModuleKey ProcessAddFieldFromString::className =
GetModuleFactory().RegisterCreatorFunction(
ModuleKey(eProcessModule, "addfieldfromstring"),
ProcessAddFieldFromString::create,
"Create a new field from the existing fields as specified by a string"
" using a required argument of the form fieldstr=\"x + y + u\" ");
ProcessAddFieldFromString::ProcessAddFieldFromString(FieldSharedPtr f)
: ProcessModule(f)
{
m_config["fieldstr"] = ConfigOption(
false, "NotSet", "string of new field to be added (required)");
m_config["fieldname"] =
ConfigOption(false, "newfield",
"name for new field, default is newfield (optional)");
}
ProcessAddFieldFromString::~ProcessAddFieldFromString(void)
{
}
void ProcessAddFieldFromString::Process(po::variables_map &vm)
{
// Check if required parameter fieldstr was provided
ASSERTL0(m_config["fieldstr"].m_beenSet, "fieldstr must be specified");
// Get number of fields (before adding new entry)
int nfields = m_f->m_variables.size();
// Set up new field name
string fieldName = m_config["fieldname"].as<string>();
m_f->m_variables.push_back(fieldName);
// Skip in case of empty partition
if (m_f->m_exp[0]->GetNumElmts() == 0)
{
return;
}
// Check if using strips
int nstrips;
m_f->m_session->LoadParameter("Strip_Z", nstrips, 1);
ASSERTL0(nstrips == 1,
"Routine is currently only setup for non-strip files");
// Create new expansion
m_f->m_exp.resize(nfields + 1);
m_f->m_exp[nfields] = m_f->AppendExpList(m_f->m_numHomogeneousDir);
// Variables for storing names and values for evaluating the function
string varstr;
vector<Array<OneD, const NekDouble>> interpfields;
// Add the coordinate values
varstr += "x y z";
int npoints = m_f->m_exp[0]->GetTotPoints();
Array<OneD, NekDouble> x(npoints, 0.0);
Array<OneD, NekDouble> y(npoints, 0.0);
Array<OneD, NekDouble> z(npoints, 0.0);
m_f->m_exp[0]->GetCoords(x, y, z);
interpfields.push_back(x);
interpfields.push_back(y);
interpfields.push_back(z);
// Add the field values
for (int i = 0; i < nfields; ++i)
{
varstr += " " + m_f->m_variables[i];
interpfields.push_back(m_f->m_exp[i]->GetPhys());
}
// Create new function
LibUtilities::AnalyticExpressionEvaluator strEval;
int exprId = -1;
string fieldstr = m_config["fieldstr"].as<string>();
exprId = strEval.DefineFunction(varstr.c_str(), fieldstr);
// Evaluate function
strEval.Evaluate(exprId, interpfields, m_f->m_exp[nfields]->UpdatePhys());
// Update coeffs
m_f->m_exp[nfields]->FwdTrans_IterPerExp(
m_f->m_exp[nfields]->GetPhys(), m_f->m_exp[nfields]->UpdateCoeffs());
}
}
}
///////////////////////////////////////////////////////////////////////////////
//
// File: ProcessAddFieldFromString.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: Generate new field from string based on existing fields
//
////////////////////////////////////////////////////////////////////////////////
#ifndef FIELDUTILS_PROCESSADDNEWFIELDFROMSTR
#define FIELDUTILS_PROCESSADDNEWFIELDFROMSTR
#include "../Module.h"
namespace Nektar
{
namespace FieldUtils
{
/**
* @brief This processing module adds a new field from a string definition
*/
class ProcessAddFieldFromString : public ProcessModule
{
public:
/// Creates an instance of this class
static std::shared_ptr<Module> create(FieldSharedPtr f)
{
return MemoryManager<ProcessAddFieldFromString>::AllocateSharedPtr(f);
}
static ModuleKey className;
ProcessAddFieldFromString(FieldSharedPtr f);
virtual ~ProcessAddFieldFromString();
virtual void Process(po::variables_map &vm);
virtual std::string GetModuleName()
{
return "ProcessAddFieldFromString";
}
virtual std::string GetModuleDescription()
{
return "Calculating new field";
}
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