Commit d4e6c59a authored by Chris Cantwell's avatar Chris Cantwell

Merge branch 'master' into fix/evs-root-only

parents dcee729b ff04c296
......@@ -49,12 +49,12 @@ v5.0.0
WeightPartitions was used in parallel (!923)
- Removed instance count from beginning of Array storage to improve memory
alignment (!921)
- Fix naming issue of duplicate Unit tests (!924)
- Fix naming issue of duplicate Unit tests (!924)
- Fix warnings about missing virtual destructors in abstract classes (!932)
- Fix ability to have periodic boundary conditions that are aligned by a
- Fix ability to have periodic boundary conditions that are aligned by a
rotation rather than just a translation (!933)
- Added a coupling interface to exchange data between solvers at run time
and a DummySolver to test the implementations (!853, !931)
and a DummySolver to test the implementations (!853, !931 !973)
- Fix compilation issue with newer Boost versions and clang (!940)
- If only `NEKTAR_BUILD_LIBRARY` is enabled, only libraries up to and including
`MultiRegions` will be built by default (!945)
......@@ -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
......@@ -125,6 +126,8 @@ v5.0.0
seg, quad and hex elements (!771, !862)
- Fix compressible solver with NUMMODES=1 (!868)
- Introduce equations of state to account for real gas effects (!880)
- Modified pressure outlet BCs to allow for the reference static pressure to be
set from the VALUE fields (!981)
**AcousticSolver:**
- Added two new boundary conditions to the APE system: RiemannInvariantBC
......@@ -137,6 +140,9 @@ v5.0.0
**APESolver:**
- APESolver was replaced with AcousticSolver (!918)
**PulseWaveSolver**
- Added two new boundary conditions: AInflow and UInflow
**Documentation**:
- Added the developer-guide repository as a submodule (!751)
......@@ -156,7 +162,8 @@ v4.4.2
- Fix deadlock in DiffusionLDG (!885)
- Fix uninitialised coefficients in DirectFull solver (!898)
- Updated PETSc to 3.7.7 (!916)
- Fix typcase to an integer which set Lz < 1 to zero when postprocess hdf5 output (!9922)
- Fix typecast to an integer which set Lz < 1 to zero when postprocess hdf5 output (!922)
- Fix program options errors on Windows in debug mode (!986)
- Fix potential clobbered output of ModArnoldi EVs when run in parallel (!983)
**IncNavierStokesSolver**
......
Subproject commit aa951501d39dbccce498c2a47c752d143cc2d019
Subproject commit 7c88d86e78a8908720b971d71ce8b5aafdd5eb92
......@@ -159,7 +159,7 @@ First we need to define the variables under the section \inltt{VARIABLES}.
</VARIABLES>
\end{lstlisting}
The composites that we want to apply out boundary conditions then need to be defined in the \inltt{BOUNDARYREIONS}, for example if we had three composites (C[1], C[4] and C[8]) that correspond to three vertices of the computational mesh we would define:
The composites that we want to apply out boundary conditions then need to be defined in the \inltt{BOUNDARYREGIONS}, for example if we had three composites (C[1], C[4] and C[8]) that correspond to three vertices of the computational mesh we would define:
\begin{lstlisting}[style=XmlStyle]
<BOUNDARYREGIONS>
<B ID="0"> C[1] </B>
......@@ -172,7 +172,8 @@ Finally we can specify the boundary conditions on the regions specified under \i
The Pulse Wave Solver comes with a number of boundary conditions that are unique to this solver. Boundary conditions must be provided for both the area and velocity at the inlets and outlets of the domain. Examples of the different boundary conditions will be provided in the following.
\paragraph{Inlet boundary condition:~} Typically at the inlet of the domain a flow profile (\inltt{Q-inflow}) is specified through a \inltt{USERDEFINEDTYPE} boundary conditioning . An example inlet condition for the parent artery of the previously bifurcation example is
\paragraph{Inlet boundary condition:~} The inlet condition may be specified algebraically in four different ways: as an area variation (\inltt{A-inflow}); a velocity profile (\inltt{U-inflow}); a volume flux (\inltt{Q-inflow}); or by prescribing the forward characteristic (\inltt{TimeDependent}). When prescribing a volume flux, it must be specified in the input file via the area, as illustrated below. Note that $u = 1.0$.
\begin{lstlisting}[style=XmlStyle]
<REGION REF="0">
<D VAR="A" USERDEFINEDTYPE="Q-inflow" VALUE="(7.112e-4)*(sin(7.854*t)
......
......@@ -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]
......
......@@ -2,7 +2,7 @@
<test>
<description>Test for time integration schemes</description>
<executable>TimeIntegrationDemo</executable>
<parameters>--Npoints 100 --Ntimesteps 100 --NTimeIntegrationMethod 7</parameters>
<parameters>--points 100 --timesteps 100 --method 7</parameters>
<metrics>
<metric type="L2" id="1">
<value tolerance="1e-12">0.10135</value>
......
......@@ -2,7 +2,7 @@
<test>
<description>Test for time integration schemes</description>
<executable>TimeIntegrationDemo</executable>
<parameters>--Npoints 100 --Ntimesteps 100 --NTimeIntegrationMethod 4</parameters>
<parameters>--points 100 --timesteps 100 --method 4</parameters>
<metrics>
<metric type="L2" id="1">
<value tolerance="1e-12">0.0616905</value>
......
......@@ -2,7 +2,7 @@
<test>
<description>Test for time integration schemes</description>
<executable>TimeIntegrationDemo</executable>
<parameters>--Npoints 100 --Ntimesteps 100 --NTimeIntegrationMethod 5</parameters>
<parameters>--points 100 --timesteps 100 --method 5</parameters>
<metrics>
<metric type="L2" id="1">
<value tolerance="1e-12">0.061634</value>
......
......@@ -2,7 +2,7 @@
<test>
<description>Test for time integration schemes</description>
<executable>TimeIntegrationDemo</executable>
<parameters>--Npoints 100 --Ntimesteps 100 --NTimeIntegrationMethod 6</parameters>
<parameters>--points 100 --timesteps 100 --method 6</parameters>
<metrics>
<metric type="L2" id="1">
<value tolerance="1e-12">0.315262</value>
......
......@@ -2,7 +2,7 @@
<test>
<description>Test for time integration schemes</description>
<executable>TimeIntegrationDemo</executable>
<parameters>--Npoints 100 --Ntimesteps 100 --NTimeIntegrationMethod 1</parameters>
<parameters>--points 100 --timesteps 100 --method 1</parameters>
<metrics>
<metric type="L2" id="1">
<value tolerance="1e-12">0.224678</value>
......
......@@ -2,7 +2,7 @@
<test>
<description>Test for time integration schemes</description>
<executable>TimeIntegrationDemo</executable>
<parameters>--Npoints 100 --Ntimesteps 100 --NTimeIntegrationMethod 2</parameters>
<parameters>--points 100 --timesteps 100 --method 2</parameters>
<metrics>
<metric type="L2" id="1">
<value tolerance="1e-12">0.0798986</value>
......
......@@ -2,7 +2,7 @@
<test>
<description>Test for time integration schemes</description>
<executable>TimeIntegrationDemo</executable>
<parameters>--Npoints 100 --Ntimesteps 100 --NTimeIntegrationMethod 3</parameters>
<parameters>--points 100 --timesteps 100 --method 3</parameters>
<metrics>
<metric type="L2" id="1">
<value tolerance="1e-12">0.0610636</value>
......
......@@ -2,7 +2,7 @@
<test>
<description>Test for time integration schemes</description>
<executable>TimeIntegrationDemo</executable>
<parameters>--Npoints 100 --Ntimesteps 100 --NTimeIntegrationMethod 8</parameters>
<parameters>--points 100 --timesteps 100 --method 8</parameters>
<metrics>
<metric type="L2" id="1">
<value tolerance="1e-12">0.134315</value>
......
......@@ -29,7 +29,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
// Description:
// Description: Example of using time-integration schemes.
//
///////////////////////////////////////////////////////////////////////////////
......@@ -181,20 +181,25 @@ int main(int argc, char *argv[])
{
po::options_description desc("Available options");
desc.add_options()
("help, h", "Produce this help message.")
("Npoints, np", po::value<int>(),
"the number of grid points to be used.")
("Ntimesteps, nt", po::value<int>(),
"the number of timesteps to be used.")
("NTimeIntegrationMethod, nm", po::value<int>(),
"TimeIntegrationMethod is a number in the range [1,5]."
"and defines the time-integration method to be used, i.e"
"- 1: 1st order multi-step IMEX scheme (Euler Backwards/Euler Forwards)"
"- 2: 2nd order multi-step IMEX scheme"
"- 3: 3rd order multi-step IMEX scheme"
"- 4: 2nd order multi-stage DIRK IMEX scheme"
"- 5: 3nd order multi-stage DIRK IMEX scheme"
"- 6: 2nd order IMEX Gear (Extrapolated Gear/SBDF-2)");
("help,h", "Produce this help message.")
("points,p", po::value<int>(),
"Number of grid points to be used.")
("timesteps,t", po::value<int>(),
"Number of timesteps to be used.")
("method,m", po::value<int>(),
"TimeIntegrationMethod is a number in the range [1,8].\n"
"It defines the time-integration method to be used:\n"
"- 1: 1st order multi-step IMEX scheme\n"
" (Euler Backwards/Euler Forwards)\n"
"- 2: 2nd order multi-step IMEX scheme\n"
"- 3: 3rd order multi-step IMEX scheme\n"
"- 4: 2nd order multi-stage DIRK IMEX scheme\n"
"- 5: 3nd order multi-stage DIRK IMEX scheme\n"
"- 6: 2nd order IMEX Gear (Extrapolated Gear/SBDF-2)\n"
"- 7: 2nd order Crank-Nicolson/Adams-Bashforth (CNAB)\n"
"- 8: 2nd order Modified Crank-Nicolson/Adams-Bashforth\n"
" (MCNAB)"
);
po::variables_map vm;
try
{
......@@ -209,29 +214,17 @@ int main(int argc, char *argv[])
return 1;
}
if (!vm.count("Npoints") || !vm.count("Ntimesteps") || !vm.count("NTimeIntegrationMethod"))
if (!vm.count("points") || !vm.count("timesteps") || !vm.count("method")
|| vm.count("help"))
{
cerr << "Usage: Project1D --Npoints nPoints --Ntimesteps nTimesteps --TimeIntegrationMethod nMethod" << endl;
cerr << "Where - Npoints is the number of grid points to be used" << endl;
cerr << " for the finite difference discretisation" << endl;
cerr << " - Ntimesteps is the number of timesteps to be used" << endl;
cerr << " for the time-integration method" << endl;
cerr << " - TimeIntegrationMethod is a number in the range [1,8]" << endl;
cerr << " and defines the time-integration method to be used, i.e." << endl;
cerr << " - 1: 1st order multi-step IMEX scheme (Euler Backwards/Euler Forwards)" << endl;
cerr << " - 2: 2nd order multi-step IMEX scheme" << endl;
cerr << " - 3: 3rd order multi-step IMEX scheme" << endl;
cerr << " - 4: 2nd order multi-stage DIRK IMEX scheme" << endl;
cerr << " - 5: 3nd order multi-stage DIRK IMEX scheme" << endl;
cerr << " - 6: 2nd order IMEX Gear (Extrapolated Gear/SBDF-2)" << endl;
cerr << " - 7: 2nd order Crank-Nicolson/Adams-Bashforth (CNAB)" << endl;
cerr << " - 8: 2nd order Modified Crank-Nicolson/Adams-Bashforth (MCNAB)" << endl;
cout << "Please specify points, timesteps and method." << endl << endl;
cout << desc;
return 1;
}
int nPoints = vm["Npoints"].as<int>();
int nTimesteps = vm["Ntimesteps"].as<int>();
int nMethod = vm["NTimeIntegrationMethod"].as<int>();
int nPoints = vm["points"].as<int>();
int nTimesteps = vm["timesteps"].as<int>();
int nMethod = vm["method"].as<int>();
// Open a file for writing the solution
ofstream outfile;
......@@ -340,16 +333,8 @@ int main(int argc, char *argv[])
break;
default :
{
cerr << "The third argument defines the time-integration method to be used" << endl;
cerr << "and should be a number in the range [1,6], i.e." << endl;
cerr << " - 1: 1st order multi-step IMEX scheme (Euler Backwards/Euler Forwards)" << endl;
cerr << " - 2: 2nd order multi-step IMEX scheme" << endl;
cerr << " - 3: 3rd order multi-step IMEX scheme" << endl;
cerr << " - 4: 2nd order multi-stage DIRK IMEX scheme" << endl;
cerr << " - 5: 3rd order multi-stage DIRK IMEX scheme" << endl;
cerr << " - 6: 2nd order IMEX Gear (Extrapolated Gear/SBDF-2)" << endl;
cerr << " - 7: 2nd order Crank-Nicolson/Adams-Bashforth (CNAB)" << endl;
cerr << " - 8: 2nd order Modified Crank-Nicolson/Adams-Bashforth (MCNAB)" << endl;
cout << "Invalid method." << endl << endl;
cout << desc;
exit(1);
}
}
......
......@@ -6,27 +6,27 @@ import gc
import sys
def main():
session_name = ["memory-test-python-to-c-address.py", "newsquare_2x2.xml"]
session_name = ["memory-test-python-to-c-address.py", "newsquare_2x2.xml"]
session = SessionReader.CreateInstance(session_name)
graph = MeshGraph.Read(session)
exp = ExpList2D(session, graph)
session = SessionReader.CreateInstance(session_name)
graph = MeshGraph.Read(session)
exp = ExpList2D(session, graph)
coords = exp.GetCoords()
coords = coords[0]
coords = exp.GetCoords()
coords = coords[0]
coords_data_address = str(hex(coords.ctypes.data)).rstrip('L')
coords_data_address = str(hex(coords.ctypes.data)).rstrip('L')
print "The memory address of data is: {}\n".format(coords_data_address)
print( "The memory address of data is: {}\n".format(coords_data_address))
exp.SetPhysArray(coords)
phys_data_address = exp.GetPhysAddress()
print "The memory address of array data is: {}\n".format(phys_data_address)
exp.SetPhysArray(coords)
phys_data_address = exp.GetPhysAddress()
print( "The memory address of array data is: {}\n".format(phys_data_address))
if coords_data_address == phys_data_address:
print("Test successful!")
else:
print("Test unsuccessful")
if coords_data_address == phys_data_address:
print("Test successful!")
else:
print("Test unsuccessful")
if __name__ == '__main__':
main()
......@@ -7,51 +7,51 @@ import sys
import numpy as np
def get_refcount(coords_address):
gc.collect()
return ctypes.c_long.from_address(coords_address).value
gc.collect()
return ctypes.c_long.from_address(coords_address).value
def main():
session_name = ["memory-test-python-to-c-address.py", "newsquare_2x2.xml"]
expected_test_outcome = [1, 2, 1, -9.187094450483263e-15]
actual_test_outcome = []
session = SessionReader.CreateInstance(session_name)
graph = MeshGraph.Read(session)
exp = ExpList2D(session, graph)
print("Loaded session: %s" % session.GetSessionName())
print("Loaded MeshGraph of dimension: %d\n" % graph.GetMeshDimension())
print("Retrieving coordinates...")
coords = exp.GetCoords()
coords_subs = coords[1]
coords = coords[0]
coords_address = id(coords)
print("Retrieved coordinates.")
print("Reference count for expansion coordinates: %d\n" % get_refcount(coords_address))
actual_test_outcome.append(get_refcount(coords_address))
print("Setting PhysArray (exp.SetPhysArray())...")
exp.SetPhysArray(coords)
print("exp.SetPhysArray() completed.")
print("Reference count for expansion coordinates: %d\n" % get_refcount(coords_address))
actual_test_outcome.append(get_refcount(coords_address))
print("Substituting the coordinates in m_phys...")
exp.SetPhysArray(coords_subs)
print("Substitution completed.")
print("Reference count for expansion coordinates: %d\n" % get_refcount(coords_address))
actual_test_outcome.append(get_refcount(coords_address))
print("Attempting to access the coordinates in Python...")
print("The sum of coordinates array entires is: %r" % sum(coords))
actual_test_outcome.append(sum(coords))
if np.allclose(actual_test_outcome, expected_test_outcome):
print("Test successful!")
else:
print("Test unsuccessful")
session_name = ["memory-test-python-to-c-address.py", "newsquare_2x2.xml"]
expected_test_outcome = [1, 2, 1, -9.187094450483263e-15]
actual_test_outcome = []
session = SessionReader.CreateInstance(session_name)
graph = MeshGraph.Read(session)
exp = ExpList2D(session, graph)
print("Loaded session: %s" % session.GetSessionName())
print("Loaded MeshGraph of dimension: %d\n" % graph.GetMeshDimension())
print("Retrieving coordinates...")
coords = exp.GetCoords()
coords_subs = coords[1]
coords = coords[0]
coords_address = id(coords)
print("Retrieved coordinates.")
print("Reference count for expansion coordinates: %d\n" % get_refcount(coords_address))
actual_test_outcome.append(get_refcount(coords_address))
print("Setting PhysArray (exp.SetPhysArray())...")
exp.SetPhysArray(coords)
print("exp.SetPhysArray() completed.")
print("Reference count for expansion coordinates: %d\n" % get_refcount(coords_address))
actual_test_outcome.append(get_refcount(coords_address))
print("Substituting the coordinates in m_phys...")
exp.SetPhysArray(coords_subs)
print("Substitution completed.")
print("Reference count for expansion coordinates: %d\n" % get_refcount(coords_address))
actual_test_outcome.append(get_refcount(coords_address))
print("Attempting to access the coordinates in Python...")
print("The sum of coordinates array entires is: %r" % sum(coords))
actual_test_outcome.append(sum(coords))
if np.allclose(actual_test_outcome, expected_test_outcome):
print("Test successful!")
else:
print("Test unsuccessful")
if __name__ == '__main__':
main()
......@@ -7,54 +7,54 @@ import sys
import numpy as np
def get_refcount(coords_address):
gc.collect()
return ctypes.c_long.from_address(coords_address).value
gc.collect()
return ctypes.c_long.from_address(coords_address).value
def main():
session_name = ["NekPy_ReferenceTest_PythonDeleteFirst.py", "newsquare_2x2.xml"]
expected_test_outcome = [1, 2, 1, 3.469446951953614e-17]
actual_test_outcome = []
session = SessionReader.CreateInstance(session_name)
graph = MeshGraph.Read(session)
exp = ExpList2D(session, graph)
print("Loaded session: %s" % session.GetSessionName())
print("Loaded MeshGraph of dimension: %d\n" % graph.GetMeshDimension())
print("Retrieving coordinates...")
coords = exp.GetCoords()
coords = coords[0]
coords_address = id(coords)
print("Retrieved coordinates.")
print("Reference count for expansion coordinates: %d\n" % get_refcount(coords_address))
actual_test_outcome.append(get_refcount(coords_address))
print("Setting PhysArray (exp.SetPhysArray())...")
exp.SetPhysArray(coords)
print("exp.SetPhysArray() completed.")
print("Reference count for expansion coordinates: %d\n" % get_refcount(coords_address))
actual_test_outcome.append(get_refcount(coords_address))
print("Deleting coordinates in Python...")
del coords
print("Coordinates deleted in Python.")
print("Reference count for expansion coordinates: %d\n" % get_refcount(coords_address))
actual_test_outcome.append(get_refcount(coords_address))
# Ensure we are in PhysState to avoid ASSERT inside ExpList.
exp.SetPhysState(True)
print("Attempting to calculate the integral...")
print("Integral calculated to be: %r" % exp.PhysIntegral())
actual_test_outcome.append(exp.PhysIntegral())
if np.allclose(actual_test_outcome, expected_test_outcome):
print("Test successful!")
else:
print("Test unsuccessful")
session_name = ["NekPy_ReferenceTest_PythonDeleteFirst.py", "newsquare_2x2.xml"]
expected_test_outcome = [1, 2, 1, 3.469446951953614e-17]
actual_test_outcome = []
session = SessionReader.CreateInstance(session_name)
graph = MeshGraph.Read(session)
exp = ExpList2D(session, graph)
print("Loaded session: %s" % session.GetSessionName())
print("Loaded MeshGraph of dimension: %d\n" % graph.GetMeshDimension())
print("Retrieving coordinates...")
coords = exp.GetCoords()
coords = coords[0]
coords_address = id(coords)
print("Retrieved coordinates.")
print("Reference count for expansion coordinates: %d\n" % get_refcount(coords_address))
actual_test_outcome.append(get_refcount(coords_address))
print("Setting PhysArray (exp.SetPhysArray())...")
exp.SetPhysArray(coords)
print("exp.SetPhysArray() completed.")
print("Reference count for expansion coordinates: %d\n" % get_refcount(coords_address))
actual_test_outcome.append(get_refcount(coords_address))
print("Deleting coordinates in Python...")
del coords
print("Coordinates deleted in Python.")
print("Reference count for expansion coordinates: %d\n" % get_refcount(coords_address))
actual_test_outcome.append(get_refcount(coords_address))
# Ensure we are in PhysState to avoid ASSERT inside ExpList.
exp.SetPhysState(True)
print("Attempting to calculate the integral...")
print("Integral calculated to be: %r" % exp.PhysIntegral())
actual_test_outcome.append(exp.PhysIntegral())
if np.allclose(actual_test_outcome, expected_test_outcome):
print("Test successful!")
else:
print("Test unsuccessful")
if __name__ == '__main__':
main()
......@@ -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
......
......@@ -259,10 +259,11 @@ void InputSemtex::Process(po::variables_map &vm)
swap_endian(tmp);
}
double* x = &tmp[0];
for (int k = 0; k < nelmt; ++k)
{
std::copy(&tmp[k * elmtSize], &tmp[(k+1) * elmtSize],
data + k * offset + elSizeJ);
std::copy(x, x + elmtSize, data + k * offset + elSizeJ);
x += elmtSize;
}
}
......
///////////////////////////////////////////////////////////////////////////////
//
// 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
//
////////////////////////////////////////////////////////////////////////////////