Commit d18ef8d8 authored by Chris Cantwell's avatar Chris Cantwell

Merge branch 'feature/FieldConvertCleanUp' into 'master'

Feature/field convert clean up

This MR includes a number of new features and fixes for the FieldConvert utility. It also deprecates a number of standalone utilities.

See merge request !475
parents 6c3be247 23954a9a
This diff is collapsed.
......@@ -2,12 +2,4 @@
\input{meshconvert}
\input{fieldconvert}
\input{fldtovtk}
\input{fldtotecplot}
\input{xmltovtk}
\input{probefld}
\input{fieldconvert}
\ No newline at end of file
......@@ -875,6 +875,10 @@ namespace Nektar
}
}
/** \brief Get the normals along specficied face
* Get the face normals interplated to a points0 x points 0
* type distribution
**/
void PrismExp::v_ComputeFaceNormal(const int face)
{
const SpatialDomains::GeomFactorsSharedPtr &geomFactors =
......
......@@ -197,7 +197,7 @@ namespace Nektar
}
}
/**
/**
*
*/
ExpansionType ExpList::GetExpType(void)
......@@ -560,7 +560,7 @@ namespace Nektar
* array of size \f$N_{\mathrm{eof}}\f$.
*/
void ExpList::v_FwdTrans_IterPerExp(const Array<OneD, const NekDouble> &inarray,
Array<OneD, NekDouble> &outarray)
Array<OneD, NekDouble> &outarray)
{
Array<OneD,NekDouble> f(m_ncoeffs);
......@@ -1187,7 +1187,7 @@ namespace Nektar
* \f$Q_{\mathrm{tot}}\f$.
*/
void ExpList::v_BwdTrans_IterPerExp(const Array<OneD, const NekDouble> &inarray,
Array<OneD, NekDouble> &outarray)
Array<OneD, NekDouble> &outarray)
{
Array<OneD, NekDouble> tmp;
for (int i = 0; i < m_collections.size(); ++i)
......@@ -1235,7 +1235,7 @@ namespace Nektar
NekDouble tol,
bool returnNearestElmt)
{
NekDouble resid;
NekDouble nearpt = 1e6;
if (GetNumElmts() == 0)
{
......@@ -1255,7 +1255,7 @@ namespace Nektar
{
if ((*m_exp)[i]->GetGeom()->ContainsPoint(gloCoords,
locCoords,
tol, resid))
tol, nearpt))
{
w.SetX(gloCoords[0]);
w.SetY(gloCoords[1]);
......@@ -1291,7 +1291,7 @@ namespace Nektar
// retrieve local coordinate of point
(*m_exp)[min_id]->GetGeom()->GetLocCoords(gloCoords,
locCoords);
locCoords);
return min_id;
}
else
......@@ -1304,56 +1304,64 @@ namespace Nektar
{
static int start = 0;
int min_id = 0;
NekDouble resid_min = 1e6;
NekDouble nearpt_min = 1e6;
Array<OneD, NekDouble> savLocCoords(locCoords.num_elements());
// restart search from last found value
for (int i = start; i < (*m_exp).size(); ++i)
{
if ((*m_exp)[i]->GetGeom()->ContainsPoint(gloCoords, locCoords,
tol, resid))
if ((*m_exp)[i]->GetGeom()->ContainsPoint(gloCoords,
locCoords,
tol, nearpt))
{
start = i;
return i;
}
else
{
if(resid < resid_min)
if(nearpt < nearpt_min)
{
min_id = i;
resid_min = resid;
Vmath::Vcopy(locCoords.num_elements(),savLocCoords,1,locCoords,1);
nearpt_min = nearpt;
Vmath::Vcopy(locCoords.num_elements(),locCoords,1,savLocCoords,1);
}
}
}
for (int i = 0; i < start; ++i)
{
if ((*m_exp)[i]->GetGeom()->ContainsPoint(gloCoords, locCoords,
tol, resid))
if ((*m_exp)[i]->GetGeom()->ContainsPoint(gloCoords,
locCoords,
tol, nearpt))
{
start = i;
return i;
}
else
{
if(resid < resid_min)
if(nearpt < nearpt_min)
{
min_id = i;
resid_min = resid;
Vmath::Vcopy(locCoords.num_elements(),savLocCoords,1,locCoords,1);
nearpt_min = nearpt;
Vmath::Vcopy(locCoords.num_elements(),
locCoords,1,savLocCoords,1);
}
}
}
std::string msg = "Failed to find point in element to tolerance of "
+ boost::lexical_cast<std::string>(resid)
+ " using nearest point found";
WARNINGL0(true,msg.c_str());
std::string msg = "Failed to find point within element to tolerance of "
+ boost::lexical_cast<std::string>(tol)
+ " using local point ("
+ boost::lexical_cast<std::string>(locCoords[0]) +","
+ boost::lexical_cast<std::string>(locCoords[1]) +","
+ boost::lexical_cast<std::string>(locCoords[1])
+ ") in element: "
+ boost::lexical_cast<std::string>(min_id);
WARNINGL1(false,msg.c_str());
if(returnNearestElmt)
{
Vmath::Vcopy(locCoords.num_elements(),locCoords,1,savLocCoords,1);
Vmath::Vcopy(locCoords.num_elements(),savLocCoords,1,locCoords,1);
return min_id;
}
else
......@@ -1817,7 +1825,6 @@ namespace Nektar
ASSERTL0(false,
"This method is not defined or valid for this class type");
LibUtilities::TranspositionSharedPtr trans;
return trans;
}
......@@ -1834,7 +1841,6 @@ namespace Nektar
ASSERTL0(false,
"This method is not defined or valid for this class type");
Array<OneD, unsigned int> NoModes(1);
return NoModes;
}
......@@ -1843,7 +1849,6 @@ namespace Nektar
ASSERTL0(false,
"This method is not defined or valid for this class type");
Array<OneD, unsigned int> NoModes(1);
return NoModes;
}
......@@ -1936,6 +1941,7 @@ namespace Nektar
void ExpList::GeneralGetFieldDefinitions(std::vector<LibUtilities::FieldDefinitionsSharedPtr> &fielddef,
int NumHomoDir,
int NumHomoStrip,
Array<OneD, LibUtilities::BasisSharedPtr> &HomoBasis,
std::vector<NekDouble> &HomoLen,
std::vector<unsigned int> &HomoZIDs,
......@@ -2025,8 +2031,16 @@ namespace Nektar
if(elementIDs.size() > 0)
{
LibUtilities::FieldDefinitionsSharedPtr fdef = MemoryManager<LibUtilities::FieldDefinitions>::AllocateSharedPtr(shape, elementIDs, basis, UniOrder, numModes,fields, NumHomoDir, HomoLen, HomoZIDs, HomoYIDs);
fielddef.push_back(fdef);
for(int i = 0; i < NumHomoStrip; ++i)
{
LibUtilities::FieldDefinitionsSharedPtr fdef =
MemoryManager<LibUtilities::FieldDefinitions>::
AllocateSharedPtr(shape, elementIDs, basis,
UniOrder, numModes,fields,
NumHomoDir, HomoLen, HomoZIDs,
HomoYIDs);
fielddef.push_back(fdef);
}
}
}
}
......@@ -2395,7 +2409,6 @@ namespace Nektar
"This method is not defined or valid for this class type");
}
void ExpList::v_GetBCValues(Array<OneD, NekDouble> &BndVals,
const Array<OneD, NekDouble> &TotField,
int BndID)
......
......@@ -64,13 +64,13 @@ namespace Nektar
class GlobalMatrix;
enum Direction
{
eX,
eY,
eZ,
eS,
eN
};
{
eX,
eY,
eZ,
eS,
eN
};
enum ExpansionType
{
......@@ -81,21 +81,21 @@ namespace Nektar
e3DH2D,
e3D,
eNoType
};
};
MultiRegions::Direction const DirCartesianMap[] =
{
eX,
eY,
eZ
};
{
eX,
eY,
eZ
};
/// A map between global matrix keys and their associated block
/// matrices.
typedef map<GlobalMatrixKey,DNekScalBlkMatSharedPtr> BlockMatrixMap;
/// A shared pointer to a BlockMatrixMap.
typedef boost::shared_ptr<BlockMatrixMap> BlockMatrixMapShPtr;
/// Base class for all multi-elemental spectral/hp expansions.
class ExpList: public boost::enable_shared_from_this<ExpList>
......@@ -134,7 +134,7 @@ namespace Nektar
/// Returns the type of the expansion
MULTI_REGIONS_EXPORT void SetExpType(ExpansionType Type);
/// Evaulates the maximum number of modes in the elemental basis
/// order over all elements
inline int EvalBasisNumModesMax(void) const;
......@@ -160,12 +160,12 @@ namespace Nektar
/// Returns the total number of qudature points scaled by
/// the factor scale on each 1D direction
inline int Get1DScaledTotPoints(const NekDouble scale) const;
/// Sets the wave space to the one of the possible configuration
/// true or false
inline void SetWaveSpace(const bool wavespace);
///Set Modified Basis for the stability analysis
inline void SetModifiedBasis(const bool modbasis);
......@@ -321,8 +321,8 @@ namespace Nektar
Array<OneD, NekDouble> &coord_0,
Array<OneD, NekDouble> &coord_1 = NullNekDouble1DArray,
Array<OneD, NekDouble> &coord_2 = NullNekDouble1DArray);
// Homogeneous transforms
// Homogeneous transforms
inline void HomogeneousFwdTrans(
const Array<OneD, const NekDouble> &inarray,
Array<OneD, NekDouble> &outarray,
......@@ -342,7 +342,7 @@ namespace Nektar
const Array<OneD, NekDouble> &inarray2,
Array<OneD, NekDouble> &outarray,
CoeffState coeffstate = eLocal);
inline void GetBCValues(
Array<OneD, NekDouble> &BndVals,
const Array<OneD, NekDouble> &TotField,
......@@ -353,7 +353,7 @@ namespace Nektar
Array<OneD, const NekDouble> &V2,
Array<OneD, NekDouble> &outarray,
int BndID);
/// Apply geometry information to each expansion.
MULTI_REGIONS_EXPORT void ApplyGeomInfo();
......@@ -397,7 +397,7 @@ namespace Nektar
}
void WriteVtkPieceHeader(std::ofstream &outfile, int expansion,
int istrip)
int istrip = 0)
{
v_WriteVtkPieceHeader(outfile, expansion, istrip);
}
......@@ -627,8 +627,8 @@ namespace Nektar
inline void PhysDeriv(
Direction edir,
const Array<OneD, const NekDouble> &inarray,
Array<OneD, NekDouble> &out_d);
Array<OneD, NekDouble> &out_d);
/// This function discretely evaluates the derivative of a function
/// \f$f(\boldsymbol{x})\f$ on the domain consisting of all
/// elements of the expansion.
......@@ -738,6 +738,7 @@ namespace Nektar
MULTI_REGIONS_EXPORT void GeneralGetFieldDefinitions(
std::vector<LibUtilities::FieldDefinitionsSharedPtr> &fielddef,
int NumHomoDir = 0,
int NumHomoStrip = 1,
Array<OneD, LibUtilities::BasisSharedPtr> &HomoBasis =
LibUtilities::NullBasisSharedPtr1DArray,
std::vector<NekDouble> &HomoLen =
......@@ -821,15 +822,15 @@ namespace Nektar
const boost::shared_ptr<ExpList> &fromExpList,
const Array<OneD, const NekDouble> &fromCoeffs,
Array<OneD, NekDouble> &toCoeffs);
//Extract data in fielddata into the m_coeffs_list for the 3D stability analysis (base flow is 2D)
MULTI_REGIONS_EXPORT void ExtractDataToCoeffs(
LibUtilities::FieldDefinitionsSharedPtr &fielddef,
std::vector<NekDouble> &fielddata,
std::string &field,
Array<OneD, NekDouble> &coeffs);
/// Returns a shared pointer to the current object.
boost::shared_ptr<ExpList> GetSharedThisPtr()
......@@ -975,7 +976,7 @@ namespace Nektar
NekOptimize::GlobalOptParamSharedPtr m_globalOptParam;
BlockMatrixMapShPtr m_blockMat;
//@todo should this be in ExpList or ExpListHomogeneous1D.cpp
// it's a bool which determine if the expansion is in the wave space (coefficient space)
// or not
......@@ -1050,7 +1051,7 @@ namespace Nektar
Array<OneD, NekDouble> &Upwind);
virtual boost::shared_ptr<ExpList> &v_GetTrace();
virtual boost::shared_ptr<AssemblyMapDG> &v_GetTraceMap();
virtual const Array<OneD, const int> &v_GetTraceBndMap();
......@@ -1134,11 +1135,11 @@ namespace Nektar
const Array<OneD,const NekDouble> &inarray,
Array<OneD, NekDouble> &outarray,
CoeffState coeffstate);
virtual void v_BwdTrans_IterPerExp(
const Array<OneD,const NekDouble> &inarray,
Array<OneD,NekDouble> &outarray);
virtual void v_FwdTrans(
const Array<OneD,const NekDouble> &inarray,
Array<OneD, NekDouble> &outarray,
......@@ -1154,11 +1155,11 @@ namespace Nektar
const Array<OneD, const NekDouble> &inarray,
Array<OneD, NekDouble> &outarray,
CoeffState coeffstate);
virtual void v_IProductWRTBase_IterPerExp(
const Array<OneD,const NekDouble> &inarray,
Array<OneD, NekDouble> &outarray);
virtual void v_GeneralMatrixOp(
const GlobalMatrixKey &gkey,
const Array<OneD,const NekDouble> &inarray,
......@@ -1169,7 +1170,7 @@ namespace Nektar
Array<OneD, NekDouble> &coord_0,
Array<OneD, NekDouble> &coord_1,
Array<OneD, NekDouble> &coord_2 = NullNekDouble1DArray);
virtual void v_PhysDeriv(
const Array<OneD, const NekDouble> &inarray,
Array<OneD, NekDouble> &out_d0,
......@@ -1451,7 +1452,7 @@ namespace Nektar
{
m_WaveSpace = wavespace;
}
/**
*
*/
......@@ -1520,7 +1521,7 @@ namespace Nektar
v_IProductWRTBase(inarray,outarray, coeffstate);
}
/**
/**
*
*/
inline void ExpList::IProductWRTBase_IterPerExp(
......@@ -1540,8 +1541,8 @@ namespace Nektar
{
v_FwdTrans(inarray,outarray,coeffstate);
}
/**
/**
*
*/
inline void ExpList::FwdTrans_IterPerExp (
......@@ -1569,8 +1570,8 @@ namespace Nektar
{
v_BwdTrans(inarray,outarray,coeffstate);
}
/**
/**
*
*/
inline void ExpList::BwdTrans_IterPerExp (
......@@ -1644,7 +1645,7 @@ namespace Nektar
{
v_GetCoords(coord_0,coord_1,coord_2);
}
/**
*
*/
......@@ -1655,7 +1656,7 @@ namespace Nektar
{
v_PhysDeriv(inarray,out_d0,out_d1,out_d2);
}
/**
*
*/
......@@ -1673,8 +1674,8 @@ namespace Nektar
Array<OneD, NekDouble> &out_d)
{
v_PhysDeriv(edir, inarray,out_d);
}
}
/**
*
*/
......@@ -1687,7 +1688,7 @@ namespace Nektar
{
v_HomogeneousFwdTrans(inarray,outarray,coeffstate,Shuff,UnShuff);
}
/**
*
*/
......@@ -1700,7 +1701,7 @@ namespace Nektar
{
v_HomogeneousBwdTrans(inarray,outarray,coeffstate,Shuff,UnShuff);
}
/**
*
*/
......@@ -1712,7 +1713,7 @@ namespace Nektar
{
v_DealiasedProd(inarray1,inarray2,outarray,coeffstate);
}
/**
*
*/
......@@ -1723,7 +1724,7 @@ namespace Nektar
{
v_GetBCValues(BndVals,TotField,BndID);
}
/**
*
*/
......@@ -1735,7 +1736,7 @@ namespace Nektar
{
v_NormVectorIProductWRTBase(V1,V2,outarray,BndID);
}
/**
* @param eid The index of the element to be checked.
* @return The dimension of the coordinates of the specific element.
......
......@@ -1168,9 +1168,10 @@ namespace Nektar
}
void ExpList2D::v_WriteVtkPieceHeader(
std::ostream &outfile,
int expansion)
{
std::ostream &outfile,
int expansion,
int istrip)
{
int i,j;
int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
int nquad1 = (*m_exp)[expansion]->GetNumPoints(1);
......
......@@ -138,7 +138,7 @@ namespace Nektar
virtual void v_ReadGlobalOptimizationParameters();
virtual void v_WriteVtkPieceHeader(
std::ostream &outfile, int expansion);
std::ostream &outfile, int expansion, int istrip);
virtual void v_PhysInterp1DScaled(
const NekDouble scale,
......
......@@ -468,7 +468,7 @@ namespace Nektar
::AllocateSharedPtr(m_session,three,NumShape);
}
void ExpList3D::v_WriteVtkPieceHeader(std::ostream &outfile, int expansion)
void ExpList3D::v_WriteVtkPieceHeader(std::ostream &outfile, int expansion, int istrip)
{
int i,j,k;
int nquad0 = (*m_exp)[expansion]->GetNumPoints(0);
......
......@@ -98,7 +98,7 @@ namespace Nektar
virtual void v_ReadGlobalOptimizationParameters();
virtual void v_WriteVtkPieceHeader(std::ostream &outfile, int expansion);
virtual void v_WriteVtkPieceHeader(std::ostream &outfile, int expansion, int istrip);
virtual void v_PhysInterp1DScaled(const NekDouble scale, const Array<OneD, NekDouble> &inarray, Array<OneD, NekDouble> &outarray);
......
......@@ -413,7 +413,8 @@ namespace Nektar
GetCoords(expansion,coords[0],coords[1],coords[2]);
NekDouble DistStrip;
m_session->LoadParameter("DistStrip", DistStrip);
m_session->LoadParameter("DistStrip", DistStrip, 0);
// Reset the z-coords for homostrips
for(int i = 0; i < ntot; i++)
{
coords[2][i] += istrip*DistStrip;
......@@ -515,7 +516,7 @@ namespace Nektar
return sqrt(err);
}
Array<OneD, const NekDouble> ExpList3DHomogeneous1D::v_HomogeneousEnergy(void)
{
Array<OneD, NekDouble> energy(m_planes.num_elements()/2);
......
......@@ -612,7 +612,10 @@ namespace Nektar
PlanesIDs.push_back(m_transposition->GetPlaneID(i));
}
m_planes[0]->GeneralGetFieldDefinitions(returnval, 1, HomoBasis, HomoLen, PlanesIDs);
int NumHomoStrip;
m_session->LoadParameter("Strip_Z",NumHomoStrip,1);
m_planes[0]->GeneralGetFieldDefinitions(returnval, 1, NumHomoStrip, HomoBasis, HomoLen, PlanesIDs);
return returnval;
}
......@@ -632,8 +635,11 @@ namespace Nektar
PlanesIDs.push_back(m_transposition->GetPlaneID(i));
}
int NumHomoStrip;
m_session->LoadParameter("Strip_Z",NumHomoStrip,1);
// enforce NumHomoDir == 1 by direct call
m_planes[0]->GeneralGetFieldDefinitions(fielddef,1, HomoBasis,HomoLen,PlanesIDs);
m_planes[0]->GeneralGetFieldDefinitions(fielddef, 1, NumHomoStrip, HomoBasis,HomoLen,PlanesIDs);
}
......
......@@ -589,7 +589,7 @@ namespace Nektar
HomoLen[0] = m_lhom_y;
HomoLen[1] = m_lhom_z;
m_lines[0]->GeneralGetFieldDefinitions(returnval, 2, HomoBasis, HomoLen);
m_lines[0]->GeneralGetFieldDefinitions(returnval, 2, 1, HomoBasis, HomoLen);
return returnval;