Commit e21ed20e authored by Blake Nelson's avatar Blake Nelson

*** empty log message ***


git-svn-id: https://gforge.sci.utah.edu/svn/nektar/trunk@476 305cdda6-5ce1-45b3-a98d-dfc68c8b3305
parent 6edae495
......@@ -36,6 +36,8 @@
#ifndef NEKTARUNIVCONSTS_HPP
#define NEKTARUNIVCONSTS_HPP
#include <LibUtilities/BasicConst/NektarUnivTypeDefs.hpp>
namespace Nektar
{
// Null defintion of NekDoubleSharedArray
......@@ -48,6 +50,9 @@ namespace Nektar
/***
$Log: NektarUnivConsts.hpp,v $
Revision 1.2 2007/03/21 20:56:42 sherwin
Update to change BasisSharedVector to boost::shared_array<BasisSharedPtr> and removed tthe Vector definitions in GetCoords and PhysDeriv
Revision 1.1 2007/03/20 11:56:25 sherwin
.
......
......@@ -191,15 +191,6 @@ namespace Nektar
{
}
// SharedArray(const SharedArray<T>& rhs) :
// px(new T[rhs.m_size]),
// pn(px, deleter()),
// m_offset(rhs.m_offset),
// m_size(rhs.m_size)
// {
// std::copy(rhs.px, rhs.px + rhs.m_size, px);
// }
SharedArray<T>& operator=(SharedArray<T>& rhs)
{
if( this != &rhs )
......@@ -213,19 +204,6 @@ namespace Nektar
return *this;
}
// void Assign(const SharedArray<T>& rhs)
// {
// if( this != &rhs )
// {
// px = new T[rhs.m_size];
// pn = boost::detail::shared_count(px, deleter());
// m_offset = rhs.m_offset;
// m_size = rhs.m_size;
// std::copy(rhs.px, rhs.px + rhs.m_size, px);
// }
// }
void reset()
{
this_type().swap(*this);
......@@ -319,6 +297,15 @@ namespace Nektar
std::swap(m_size, other.m_size);
}
typedef T* iterator;
typedef const T* const_iterator;
iterator begin() { return px + m_offset; }
iterator end() { return px + m_size; }
const_iterator begin() const { return px + m_offset; }
const_iterator end() const { return px + m_size; }
private:
//SharedArray<T>& operator=(const SharedArray<T>& rhs);
......
///////////////////////////////////////////////////////////////////////////////
//
// File SharedArrayUtil.hpp
//
// For more information, please see: http://www.nektar.info
//
// The MIT License
//
// Copyright (c) 2006 Scientific Computing and Imaging Institute,
// University of Utah (USA) and Department of Aeronautics, Imperial
// College London (UK).
//
// 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:
//
///////////////////////////////////////////////////////////////////////////////
#ifndef NEKTAR_LIB_UTILITIES_BASIC_UTILS_SHARED_ARRAY_UTIL_HPP
#define NEKTAR_LIB_UTILITIES_BASIC_UTILS_SHARED_ARRAY_UTIL_HPP
#include <LibUtilities/Memory/NekMemoryManager.hpp>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <algorithm>
namespace Nektar
{
template<typename DataType>
SharedArray<DataType> Copy(const SharedArray<DataType>& a)
{
SharedArray<DataType> c = MemoryManager::AllocateSharedArray<DataType>(a.GetSize());
std::copy(a.begin(), a.end(), c.begin());
return c;
}
}
#endif //NEKTAR_LIB_UTILITIES_BASIC_UTILS_SHARED_ARRAY_UTIL_HPP
......@@ -81,6 +81,7 @@ SET(LibUtilityHeaders
./BasicUtils/Blas.hpp
./BasicUtils/TransF77.hpp
./BasicUtils/SharedArray.hpp
./BasicUtils/SharedArrayUtil.hpp
./Memory/ThreadSpecificPool.hpp
./Memory/NekMemoryManager.hpp
)
......
......@@ -36,6 +36,7 @@
#include <StdRegions/StdExpansion.h>
#include <LibUtilities/BasicUtils/SharedArrayUtil.hpp>
namespace Nektar
{
......@@ -108,7 +109,7 @@ namespace Nektar
StdExpansion::StdExpansion(const StdExpansion &T)
{
m_base = SharedArray<LibUtilities::BasisSharedPtr>(T.m_base);
m_base = Copy(T.m_base);
// NOTE: Copy Constructor produces a deep copy
// allocate memory for coeffs
......@@ -294,6 +295,9 @@ namespace Nektar
/**
* $Log: StdExpansion.cpp,v $
* Revision 1.28 2007/03/29 19:35:08 bnelson
* Replaced boost::shared_array with SharedArray
*
* Revision 1.27 2007/03/25 15:48:22 sherwin
* UPdate LocalRegions to take new NekDouble and shared_array formats. Added new Demos
*
......
......@@ -34,10 +34,11 @@
///////////////////////////////////////////////////////////////////////////////
#include <UnitTests/StdRegions/testStdSegExp.h>
#include <LibUtilities/BasicConst/NektarUnivConsts.hpp>
#include <StdRegions/StdSegExp.h>
#include "StdRegions/StdRegions.hpp"
#include "LibUtilities/Foundations/Foundations.hpp"
#include <StdRegions/StdRegions.hpp>
#include <LibUtilities/Foundations/Foundations.hpp>
#include <boost/test/auto_unit_test.hpp>
#include <boost/test/test_case_template.hpp>
......@@ -606,6 +607,9 @@ namespace Nektar
/**
$Log: testStdSegExp.cpp,v $
Revision 1.8 2007/03/29 19:45:46 bnelson
*** empty log message ***
Revision 1.7 2007/03/26 11:17:03 pvos
made testStdRegions back working
......
......@@ -144,83 +144,83 @@ namespace Nektar
void testConstruction()
{
{
CountedObject<double>::ClearCounters();
SharedArray<CountedObject<double> > non_const_array =
MemoryManager::AllocateSharedArray<CountedObject<double> >(10);
const SharedArray<CountedObject<double> > const_array =
MemoryManager::AllocateSharedArray<CountedObject<double> >(10);
BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 0);
{
SharedArray<CountedObject<double> > a1(non_const_array);
BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 0);
}
BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 0);
{
SharedArray<CountedObject<double> > a2(const_array);
BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 0);
}
// 10 should be destroyed from the copy of the const_array.
BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 10);
{
const SharedArray<CountedObject<double> > a1(non_const_array);
BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 10);
}
BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 10);
{
const SharedArray<CountedObject<double> > a2(const_array);
BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 10);
}
// TODO - Ideally we could detect that a const object is being
// created and avoid the copy.
BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 20);
}
//{
// CountedObject<double>::ClearCounters();
// SharedArray<CountedObject<double> > non_const_array =
// MemoryManager::AllocateSharedArray<CountedObject<double> >(10);
// const SharedArray<CountedObject<double> > const_array =
// MemoryManager::AllocateSharedArray<CountedObject<double> >(10);
// BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 0);
// {
// SharedArray<CountedObject<double> > a1(non_const_array);
// BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 0);
// }
// BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 0);
// {
// //SharedArray<CountedObject<double> > a2(const_array);
// //BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 0);
// }
// // 10 should be destroyed from the copy of the const_array.
// BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 10);
// {
// const SharedArray<CountedObject<double> > a1(non_const_array);
// BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 10);
// }
// BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 10);
// {
// //const SharedArray<CountedObject<double> > a2(const_array);
// //BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 10);
// }
// // TODO - Ideally we could detect that a const object is being
// // created and avoid the copy.
// BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 20);
//}
}
void testAssignment()
{
{
CountedObject<double>::ClearCounters();
SharedArray<CountedObject<double> > non_const_array =
MemoryManager::AllocateSharedArray<CountedObject<double> >(10);
const SharedArray<CountedObject<double> > const_array =
MemoryManager::AllocateSharedArray<CountedObject<double> >(10);
{
SharedArray<CountedObject<double> > a1;
a1 = non_const_array;
//a1 = const_array;
}
BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 0);
{
SharedArray<CountedObject<double> > a2;
a2.Assign(const_array);
}
BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 10);
{
const SharedArray<CountedObject<double> > a2;
//a2 = SharedArray<CountedObject<double> >(non_const_array);
}
BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 10);
{
const SharedArray<CountedObject<double> > a3;
//a3 = SharedArray<CountedObject<double> >(const_array);
}
BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 10);
}
BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 30);
}
// {
// CountedObject<double>::ClearCounters();
// SharedArray<CountedObject<double> > non_const_array =
// MemoryManager::AllocateSharedArray<CountedObject<double> >(10);
// const SharedArray<CountedObject<double> > const_array =
// MemoryManager::AllocateSharedArray<CountedObject<double> >(10);
// {
// SharedArray<CountedObject<double> > a1;
// a1 = non_const_array;
// //a1 = const_array;
// }
// BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 0);
// {
// SharedArray<CountedObject<double> > a2;
// a2.Assign(const_array);
// }
// BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 10);
// {
// const SharedArray<CountedObject<double> > a2;
// //a2 = SharedArray<CountedObject<double> >(non_const_array);
// }
// BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 10);
// {
// const SharedArray<CountedObject<double> > a3;
// //a3 = SharedArray<CountedObject<double> >(const_array);
// }
// BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 10);
// }
// BOOST_CHECK_EQUAL(CountedObject<double>::numberDestroyed, 30);
//}
}
}
......
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