Commit a6a28feb authored by Kilian Lackhove's avatar Kilian Lackhove
Browse files

moved Interpolator to SolverUtils and added ExpListSharedPtr support

parent 6020da66
......@@ -13,7 +13,6 @@ SET(BasicUtilsHeaders
./BasicUtils/Equation.h
./BasicUtils/FieldIO.h
./BasicUtils/FileSystem.h
./BasicUtils/Interpolator.h
./BasicUtils/ErrorUtil.hpp
./BasicUtils/MeshPartition.h
./BasicUtils/MeshPartitionMetis.h
......@@ -43,7 +42,6 @@ SET(BasicUtilsSources
./BasicUtils/Equation.cpp
./BasicUtils/FieldIO.cpp
./BasicUtils/FileSystem.cpp
./BasicUtils/Interpolator.cpp
./BasicUtils/MeshPartition.cpp
./BasicUtils/MeshPartitionMetis.cpp
./BasicUtils/PtsField.cpp
......
......@@ -29,6 +29,7 @@ SET(SOLVER_UTILS_SOURCES
Filters/FilterModalEnergy.cpp
Filters/FilterThresholdMax.cpp
Filters/FilterThresholdMin.cpp
Interpolator.cpp
RiemannSolvers/RiemannSolver.cpp
RiemannSolvers/UpwindSolver.cpp
RiemannSolvers/UpwindLDGSolver.cpp
......@@ -72,6 +73,7 @@ SET(SOLVER_UTILS_HEADERS
Filters/FilterModalEnergy.h
Filters/FilterThresholdMax.h
Filters/FilterThresholdMin.h
Interpolator.h
RiemannSolvers/RiemannSolver.h
RiemannSolvers/UpwindSolver.h
RiemannSolvers/UpwindLDGSolver.h
......
......@@ -898,12 +898,12 @@ namespace Nektar
// check if we already computed this funcKey combination
std::string interpKey = m_session->GetFunctionFilename(pFunctionName, pFieldName, domain);
map<std::string, LibUtilities::Interpolator >::iterator it
map<std::string, Interpolator >::iterator it
= m_interpolators.find(interpKey);
if (it == m_interpolators.end())
{
m_interpolators[interpKey] = LibUtilities::Interpolator(
Nektar::LibUtilities::eShepard);
m_interpolators[interpKey] = SolverUtils::Interpolator(
Nektar::SolverUtils::eShepard);
}
m_interpolators[interpKey].Interpolate(ptsField, outPts);
......
......@@ -42,11 +42,11 @@
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <LibUtilities/BasicUtils/FileSystem.h>
#include <LibUtilities/BasicUtils/FieldIO.h>
#include <LibUtilities/BasicUtils/Interpolator.h>
#include <LibUtilities/BasicUtils/Progressbar.hpp>
#include <LibUtilities/BasicUtils/PtsField.h>
#include <LibUtilities/BasicUtils/PtsIO.h>
#include <MultiRegions/ExpList.h>
#include <SolverUtils/Interpolator.h>
#include <SolverUtils/SolverUtilsDeclspec.h>
#include <SolverUtils/Core/Misc.h>
......@@ -419,7 +419,7 @@ namespace Nektar
/// Field input/output
LibUtilities::FieldIOSharedPtr m_fld;
/// Map of the interpolation weights for a specific filename.
map<std::string, LibUtilities::Interpolator > m_interpolators;
map<std::string, Interpolator > m_interpolators;
/// Array holding all dependent variables.
Array<OneD, MultiRegions::ExpListSharedPtr> m_fields;
/// Base fields.
......
......@@ -34,11 +34,11 @@
//
////////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/BasicUtils/Interpolator.h>
#include <SolverUtils/Interpolator.h>
namespace Nektar
{
namespace LibUtilities
namespace SolverUtils
{
/**
......@@ -51,8 +51,8 @@ namespace LibUtilities
* The most suitable algorithm is chosen automatically.
*/
void Interpolator::CalcWeights(
const PtsFieldSharedPtr inField,
PtsFieldSharedPtr &outField)
const LibUtilities::PtsFieldSharedPtr inField,
LibUtilities::PtsFieldSharedPtr &outField)
{
ASSERTL0(inField->GetNFields() == outField->GetNFields(), "number of fields does not match");
ASSERTL0(inField->GetDim() <= m_dim, "too many dimesions in inField");
......@@ -225,8 +225,8 @@ void Interpolator::CalcWeights(
* @SetWeights.
*/
void Interpolator::Interpolate(
const PtsFieldSharedPtr inField,
PtsFieldSharedPtr &outField)
const LibUtilities::PtsFieldSharedPtr inField,
LibUtilities::PtsFieldSharedPtr &outField)
{
ASSERTL0(inField->GetNFields() == outField->GetNFields(), "number of fields does not match");
ASSERTL0(inField->GetDim() <= m_dim, "too many dimesions in inField");
......@@ -264,6 +264,65 @@ void Interpolator::Interpolate(
}
void Interpolator::Interpolate(const vector< MultiRegions::ExpListSharedPtr > inField, LibUtilities::PtsFieldSharedPtr &outField)
{
ASSERTL0(inField.size() == outField->GetNFields(), "number of fields does not match");
ASSERTL0(inField[0]->GetCoordim(0) <= m_dim, "too many dimesions in inField");
ASSERTL0(outField->GetDim() <= m_dim, "too many dimesions in outField");
// m_inField = inField;
m_outField = outField;
int nInDim = inField[0]->GetCoordim(0);
int nOutPts = m_outField->GetNpoints();
int lastProg = 0;
m_weights = Array<OneD, Array<OneD, float> >(nOutPts);
m_neighInds = Array<OneD, Array<OneD, unsigned int> >(nOutPts);
for (int i = 0; i < nOutPts; ++i)
{
Array<OneD, NekDouble> Lcoords(nInDim, 0.0);
Array<OneD, NekDouble> coords(nInDim, 0.0);
for (int j = 0; j < m_outField->GetDim(); ++j)
{
coords[j] = m_outField->GetPointVal(j,i);
}
// Obtain Element and LocalCoordinate to interpolate
int elmtid = inField[0]->GetExpIndex(coords, Lcoords, 1e-3);
if(elmtid >= 0)
{
int offset = inField[0]->GetPhys_Offset(inField[0]->
GetOffset_Elmt_Id(elmtid));
for (int f = 0; f < inField.size(); ++f)
{
NekDouble value = inField[f]->GetExp(elmtid)->
StdPhysEvaluate(Lcoords, inField[f]->GetPhys() +offset);
if ((boost::math::isnan)(value))
{
ASSERTL0(false, "new value is not a number");
}
else
{
m_outField->SetPointVal(f, i, value);
}
}
}
int progress = int(100 * i / nOutPts);
if (m_progressCallback && progress > lastProg)
{
m_progressCallback(i, nOutPts);
lastProg = progress;
}
}
}
int Interpolator::GetDim() const
{
return m_dim;
......@@ -287,13 +346,13 @@ InterpMethod Interpolator::GetInterpMethod() const
}
PtsFieldSharedPtr Interpolator::GetInField() const
LibUtilities::PtsFieldSharedPtr Interpolator::GetInField() const
{
return m_inField;
}
PtsFieldSharedPtr Interpolator::GetOutField() const
LibUtilities::PtsFieldSharedPtr Interpolator::GetOutField() const
{
return m_outField;
}
......
......@@ -34,8 +34,8 @@
//
///////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_LIB_UTILITIES_BASIC_UTILS_INTERPOLATOR_H
#define NEKTAR_LIB_UTILITIES_BASIC_UTILS_INTERPOLATOR_H
#ifndef NEKTAR_SOLVERUTILS_INTERPOLATOR_H
#define NEKTAR_SOLVERUTILS_INTERPOLATOR_H
#include <vector>
......@@ -47,6 +47,8 @@
#include <boost/geometry/geometries/box.hpp>
#include <boost/geometry/index/rtree.hpp>
#include <MultiRegions/ExpList.h>
#include <LibUtilities/BasicUtils/ErrorUtil.hpp>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <LibUtilities/BasicUtils/VmathArray.hpp>
......@@ -59,7 +61,7 @@ using namespace std;
namespace Nektar
{
namespace LibUtilities
namespace SolverUtils
{
enum InterpMethod{
......@@ -85,11 +87,15 @@ class Interpolator
};
LIB_UTILITIES_EXPORT void CalcWeights(
const PtsFieldSharedPtr inField,
PtsFieldSharedPtr &outField);
const LibUtilities::PtsFieldSharedPtr inField,
LibUtilities::PtsFieldSharedPtr &outField);
LIB_UTILITIES_EXPORT void Interpolate(
const LibUtilities::PtsFieldSharedPtr inField,
LibUtilities::PtsFieldSharedPtr &outField);
LIB_UTILITIES_EXPORT void Interpolate(
const PtsFieldSharedPtr inField,
const vector<MultiRegions::ExpListSharedPtr> inField,
PtsFieldSharedPtr &outField);
LIB_UTILITIES_EXPORT int GetDim() const;
......@@ -100,9 +106,9 @@ class Interpolator
LIB_UTILITIES_EXPORT InterpMethod GetInterpMethod() const;
LIB_UTILITIES_EXPORT PtsFieldSharedPtr GetInField() const;
LIB_UTILITIES_EXPORT LibUtilities::PtsFieldSharedPtr GetInField() const;
LIB_UTILITIES_EXPORT PtsFieldSharedPtr GetOutField() const;
LIB_UTILITIES_EXPORT LibUtilities::PtsFieldSharedPtr GetOutField() const;
template<typename FuncPointerT, typename ObjectPointerT>
......@@ -148,8 +154,8 @@ class Interpolator
typedef std::pair<BPoint, unsigned int> PtsPointPair;
typedef bgi::rtree< PtsPointPair, bgi::rstar<16> > PtsRtree;
PtsFieldSharedPtr m_inField;
PtsFieldSharedPtr m_outField;
LibUtilities::PtsFieldSharedPtr m_inField;
LibUtilities::PtsFieldSharedPtr m_outField;
/// Interpolation Method
InterpMethod m_method;
......
......@@ -86,15 +86,15 @@ ADD_NEKTAR_TEST(chan3DH1D_meanmode)
# windows produces slightly differently formatted files which results in
# different hashes
#IF(WIN32)
# IF(WIN32)
# ADD_NEKTAR_TEST(chan3D_probe_win)
# ADD_NEKTAR_TEST(chan3D_equispacedoutput_win)
# ADD_NEKTAR_TEST(chan3D_isocontour_win)
#ELSE(WIN32)
# ELSE(WIN32)
# ADD_NEKTAR_TEST(chan3D_probe)
# ADD_NEKTAR_TEST(chan3D_equispacedoutput)
# ADD_NEKTAR_TEST(chan3D_isocontour)
#ENDIF(WIN32)
# ENDIF(WIN32)
IF (NEKTAR_USE_MPI)
......
......@@ -40,7 +40,7 @@ using namespace std;
#include "ProcessInterpPointDataToFld.h"
#include <LibUtilities/BasicUtils/Interpolator.h>
#include <SolverUtils/Interpolator.h>
#include <LibUtilities/BasicUtils/PtsField.h>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <LibUtilities/BasicUtils/ParseUtils.hpp>
......@@ -113,7 +113,7 @@ void ProcessInterpPointDataToFld::Process(po::variables_map &vm)
cout << "Interpolating: ";
}
LibUtilities::Interpolator Interp(Nektar::LibUtilities::eNoMethod, coord_id);
SolverUtils::Interpolator Interp(SolverUtils::eNoMethod, coord_id);
Interp.Interpolate(m_f->m_fieldPts, outPts);
cout << " done" << endl;
......
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