Commit e01180a8 authored by Chris Cantwell's avatar Chris Cantwell

Removed deprecated SpatialData class (now use Functions).

parent f5ecbec0
......@@ -530,16 +530,6 @@ namespace Nektar
m_session->LoadParameter("NumQuadPointsError",
m_NumQuadPointsError, 0);
// Read in spatial data
int nq = m_fields[0]->GetNpoints();
m_spatialParameters = MemoryManager<SpatialDomains::SpatialParameters>
::AllocateSharedPtr(m_session, nq);
m_spatialParameters->Read(m_filename);
Array<OneD, NekDouble> x(nq), y(nq), z(nq);
m_fields[0]->GetCoords(x, y, z);
m_spatialParameters->EvaluateParameters(x, y, z);
if (m_session->DefinesFunction("BodyForce"))
{
m_forces = Array<OneD, MultiRegions::ExpListSharedPtr>(v_GetForceDimension());
......
......@@ -41,7 +41,6 @@
#include <LibUtilities/BasicUtils/NekFactory.hpp>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <LibUtilities/BasicUtils/FieldIO.h>
#include <SpatialDomains/SpatialData.h>
#include <MultiRegions/ExpList.h>
#include <SolverUtils/SolverUtilsDeclspec.h>
......@@ -406,7 +405,6 @@ namespace Nektar
SpatialDomains::BoundaryConditionsSharedPtr m_boundaryConditions;
/// Pointer to graph defining mesh.
SpatialDomains::MeshGraphSharedPtr m_graph;
SpatialDomains::SpatialParametersSharedPtr m_spatialParameters;
/// Filename.
std::string m_filename;
/// Name of the session.
......
......@@ -23,7 +23,6 @@ PyrGeom.cpp
QuadGeom.cpp
SegGeom.cpp
PointGeom.cpp
SpatialData.cpp
TetGeom.cpp
#TriFaceComponent.cpp
TriGeom.cpp
......@@ -55,7 +54,6 @@ PyrGeom.h
QuadGeom.h
SegGeom.h
PointGeom.h
SpatialData.h
SpatialDomainsDeclspec.h
TetGeom.h
#TriFaceComponent.h
......
////////////////////////////////////////////////////////////////////////////////
//
// File: SpatialData.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: Storage for spatially-dependent parameters.
//
//
////////////////////////////////////////////////////////////////////////////////
#include <LibUtilities/BasicUtils/VmathArray.hpp>
#include <LibUtilities/BasicUtils/Equation.h>
#include <SpatialDomains/SpatialData.h>
#include <tinyxml/tinyxml.h>
namespace Nektar
{
namespace SpatialDomains
{
/**
* Private default constructor.
*/
/*
SpatialParameters::SpatialParameters():
m_session()
{
}
*/
/**
* Define a set of spatially dependent parameters with \a nq data
* points.
* @param nq Number of data points in the domain.
*/
SpatialParameters::SpatialParameters(const LibUtilities::SessionReaderSharedPtr& pSession, const int nq) :
m_nq(nq),
m_spatialMap(),
m_constMap(),
m_analyticMap(),
m_session(pSession)
{
}
/**
* Define a set of spatially dependent parameters as a deep copy of an
* existing set of parameters.
* @param src Existing set of parameters to copy.
*/
SpatialParameters::SpatialParameters(const SpatialParameters& src) :
m_nq(src.m_nq),
m_spatialMap(),
m_constMap(src.m_constMap),
m_analyticMap(src.m_analyticMap),
m_session(src.m_session)
{
SpatialDataMap::const_iterator x;
for (x = src.m_spatialMap.begin(); x != src.m_spatialMap.end(); ++x)
{
m_spatialMap[x->first] = MemoryManager<SpatialData>
::AllocateSharedPtr(*(x->second));
}
}
/**
* Reads spatially-dependent parameters from an XML file.
* @param infilename XML file.
*/
void SpatialParameters::Read(std::string &infilename)
{
TiXmlDocument doc(infilename);
bool loadOkay = doc.LoadFile();
ASSERTL0(loadOkay, (std::string("Unable to load file: ") +
infilename).c_str());
Read(doc);
}
/**
* Reads spatially-dependent parameters from an XML object.
* @param doc XML document containing spatial data
* definitions.
*/
void SpatialParameters::Read(TiXmlDocument &doc)
{
TiXmlHandle docHandle(&doc);
TiXmlElement* conditions = NULL;
/// Look for all data in CONDITIONS block.
conditions = docHandle.FirstChildElement("NEKTAR")
.FirstChildElement("CONDITIONS").Element();
if (!conditions)
{
return;
}
TiXmlElement *spatialData
= conditions->FirstChildElement("SPATIALDATA");
if (!spatialData)
{
return;
}
// Now read all the different tagged sections
ReadConstantFunctions(spatialData);
ReadAnalyticFunctions(spatialData);
}
/**
* Reads constant-valued spatially-dependent parameters. These are
* defined in the session file with a C tag.
* @param spatialData SpatialData XML element.
*/
void SpatialParameters::ReadConstantFunctions(TiXmlElement *spatialData)
{
TiXmlElement *element = spatialData->FirstChildElement("C");
while (element)
{
std::string variableStr = element->Attribute("NAME");
ASSERTL0(!variableStr.empty(),
"The variable must be specified for the constant "
"spatial data.");
std::string fcnStr = element->Attribute("VALUE");
ASSERTL0(!fcnStr.empty(),
(std::string("Constant for var: ") + variableStr
+ std::string(" must be specified.")).c_str());
m_constMap[variableStr] = atof(fcnStr.c_str());
element = element->NextSiblingElement("C");
}
}
/**
* Reads analytic spatially-dependent function parameters. These are
* defined in the session file with an A tag.
* @param spatialData SpatialData XML element.
*/
void SpatialParameters::ReadAnalyticFunctions(TiXmlElement *spatialData)
{
TiXmlElement *element = spatialData->FirstChildElement("A");
while (element)
{
std::string variableStr = element->Attribute("NAME");
ASSERTL0(!variableStr.empty(),
"The variable must be specified for the analytic "
"spatial data.");
std::string fcnStr = element->Attribute("VALUE");
ASSERTL0(!fcnStr.empty(),
(std::string("Function for var: ") + variableStr
+ std::string(" must be specified.")).c_str());
m_analyticMap[variableStr] = fcnStr;
element = element->NextSiblingElement("A");
}
}
/**
* Evaluates all spatially-dependent parameters at all quadrature,
* points specified by the coordinate arrays. This function must be
* called to populate the list of spatially-dependent data fields.
* @param x x-coordinates of quadrature points.
* @param y y-coordinates of quadrature points.
* @param z z-coordinates of quadrature points.
*/
void SpatialParameters::EvaluateParameters(
const Array<OneD, const NekDouble> x,
const Array<OneD, const NekDouble> y,
const Array<OneD, const NekDouble> z)
{
// First process constant-valued parameters. For this we simply
// fill the spatial data region with the constant.
std::map<std::string, NekDouble>::iterator p;
for (p = m_constMap.begin(); p != m_constMap.end(); p++)
{
SpatialDataSharedPtr fn(MemoryManager<SpatialData>
::AllocateSharedPtr(m_nq));
Vmath::Fill(m_nq, p->second, fn->UpdatePhys(), 1);
m_spatialMap[p->first] = fn;
}
// Now process analytic-valued function parameters. For this we
// evaluate the supplied equation at each quadrature point.
std::map<std::string, std::string>::iterator q;
for (q = m_analyticMap.begin(); q != m_analyticMap.end(); q++)
{
SpatialDataSharedPtr fn(MemoryManager<SpatialData>
::AllocateSharedPtr(m_nq));
LibUtilities::Equation E(m_session, q->second);
E.Evaluate(x, y, z, fn->UpdatePhys());
m_spatialMap[q->first] = fn;
}
}
}
}
////////////////////////////////////////////////////////////////////////////////
//
// File: SpatialData.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: Storage for spatially-dependent parameters.
//
//
////////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_SPATIALDOMAINS_SPATIALDATA_H
#define NEKTAR_SPATIALDOMAINS_SPATIALDATA_H
#include <string>
#include <map>
#include <SpatialDomains/SpatialDomainsDeclspec.h>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
class TiXmlElement;
class TiXmlDocument;
namespace Nektar
{
namespace SpatialDomains
{
/// Defines a domain-wide spatially-varying parameter.
class SpatialData
{
public:
/// Construct new spatially-dependent storage.
SpatialData(int size) :
m_data(size)
{
}
/// Copy existing spatially-dependent storage.
SpatialData(const SpatialData& src) :
m_data(src.m_data)
{
}
/// Returns a const reference to the data.
SPATIAL_DOMAINS_EXPORT inline const Array<OneD, const NekDouble> &GetPhys() const;
/// Returns a non-const reference to the data.
SPATIAL_DOMAINS_EXPORT inline Array<OneD, NekDouble> &UpdatePhys();
private:
/// Default constructor.
SpatialData();
/// Storage for spatially-dependent data.
Array<OneD, NekDouble> m_data;
};
/// Shared pointer to a SpatialData object.
typedef boost::shared_ptr<SpatialData> SpatialDataSharedPtr;
/// Vector of SpatialData pointers.
typedef std::vector< SpatialDataSharedPtr > SpatialDataVector;
/// Iterator for SpatialData vector.
typedef std::vector< SpatialDataSharedPtr >::iterator
SpatialDataVectorIter;
/// Mapping between name and SpatialData.
typedef std::map< std::string, SpatialDataSharedPtr > SpatialDataMap;
/// Constructs a set of spatially-dependent parameters.
class SpatialParameters
{
public:
/// Define a new set of spatially-dependent parameters.
SPATIAL_DOMAINS_EXPORT SpatialParameters(const LibUtilities::SessionReaderSharedPtr& pSession, const int nq);
/// Copies an existing set of spatially-dependent parameters.
SPATIAL_DOMAINS_EXPORT SpatialParameters(const SpatialParameters& src);
/// Reads the set of parameters from an XML file.
SPATIAL_DOMAINS_EXPORT void Read(std::string &infilename);
/// Reads the set of parameters from an XML document object.
SPATIAL_DOMAINS_EXPORT void Read(TiXmlDocument &doc);
/// Evaluate all the parameters at each quadrature point.
SPATIAL_DOMAINS_EXPORT void EvaluateParameters(
const Array<OneD, const NekDouble> x,
const Array<OneD, const NekDouble> y,
const Array<OneD, const NekDouble> z);
/// Determine if a named parameter is defined.
SPATIAL_DOMAINS_EXPORT inline bool Exists(std::string name);
/// Retrieve a single spatially-dependent parameter by name.
SPATIAL_DOMAINS_EXPORT inline SpatialDataSharedPtr& GetData(std::string name);
private:
/// Number of quadrature points in the domain.
int m_nq;
/// List of SpatialData
SpatialDataMap m_spatialMap;
/// List of constant-valued parameter definitions.
std::map<std::string, NekDouble> m_constMap;
/// List of analytic parameter definitions.
std::map<std::string, std::string> m_analyticMap;
/// Shared pointer to the current session
const LibUtilities::SessionReaderSharedPtr& m_session;
/// Default constructor.
// SpatialParameters();
/// Reads constant-valued parameters from XML object.
void ReadConstantFunctions(TiXmlElement *spatialData);
/// Reads analytic parameters from XML object.
void ReadAnalyticFunctions(TiXmlElement *spatialData);
};
/// Shared pointer to a SpatialParameters object.
typedef boost::shared_ptr<SpatialParameters> SpatialParametersSharedPtr;
inline const Array<OneD, const NekDouble> &SpatialData::GetPhys() const
{
return m_data;
}
inline Array<OneD, NekDouble> &SpatialData::UpdatePhys()
{
return m_data;
}
inline bool SpatialParameters::Exists(std::string name)
{
return (m_spatialMap.find(name) != m_spatialMap.end());
}
inline SpatialDataSharedPtr& SpatialParameters::GetData(
std::string name)
{
return m_spatialMap[name];
}
}
}
#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