Commit 46a7c636 authored by simone's avatar simone
Browse files

using nDimensions as variable and NDIM has template constant.

parent 7912d1c3
......@@ -151,7 +151,7 @@ class PhysVectUnknown
public VectorType
{
static const UInt _S_nbcomp = nDimensions;
static const UInt _S_nbcomp;
public:
typedef VectorType super;
......@@ -402,6 +402,11 @@ public:
};
template <typename VectorType>
const UInt PhysVectUnknown <VectorType>::_S_nbcomp (nDimensions);
///////////////////////////////////////////////////////////
inline VectorBlock
operator+( VectorBlock const &ex_v1, VectorBlock
......
......@@ -26,7 +26,7 @@ AM_CPPFLAGS = -I$(top_srcdir)
lib_LTLIBRARIES = liblifecore.la
liblifecore_la_SOURCES = about.cpp lifeversion.cpp\
liblifecore_la_SOURCES = about.cpp life.cpp lifeversion.cpp\
dataString.cpp debug.cpp \
switch.cpp util_string.cpp typeInfo.cpp\
SmartAssert.cpp displayer.cpp
......
/* -*- mode: c++ -*-
This file is part of the LifeV library
Author(s): Simone Deparis <simone.deparis@epfl.ch>
Date: 2009-12-09
Copyright (C) 2009 EPFL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/**
\file life.cpp
\author Simone Deparis <simone.deparis@epfl.ch>
\date 2009-12-09
*/
#include <life/lifecore/life.hpp>
namespace LifeV
{
const UInt nDimensions(NDIM);
} //end namespace LifeV
......@@ -243,15 +243,13 @@ const BCName nullBCName; // The empty string!
#define THREEDIM 1
#if defined(TWODIM)
extern const UInt nDimensions;
# define NDIM 2
const UInt nDimensions = 2;
#if defined(TWODIM)
#define NDIM 2
#elif defined(THREEDIM)
#define NDIM 3
const UInt nDimensions = 3;
#else
#error You MUST compile with either -DTWODIM of -DTHREEDIM set, sorry.
......
......@@ -388,7 +388,7 @@ private:
return result;
}
private:
bool M_components[nDimensions];
bool M_components[NDIM];
bool M_normal;
bool M_tangential;
bool M_directional;
......
......@@ -61,10 +61,12 @@ public:
//! returns a pointer to a Real[3] containing the coordinates
/*
Real * coor()
{
return const_cast<Real*>( _coor.data() );
};
*/
Real const * coor() const
{
return _coor.data();
......@@ -112,7 +114,7 @@ public:
}
//!Another way to access coordinate data and modify them!
boost::array<Real,nDimensions>& coordinate ( void )
boost::array<Real,NDIM>& coordinate ( void )
{
return _coor;
}
......@@ -135,7 +137,7 @@ public:
std::ostream & showMe( bool verbose = false, std::ostream & c = std::cout ) const;
private:
boost::array<Real,nDimensions> _coor;
boost::array<Real,NDIM> _coor;
};
}
#endif
......@@ -54,25 +54,31 @@ public:
static const UInt numLocalVertices = GEOSHAPE::numVertices; // for comp only
//! The ith point (starting from 1)
/* It returns the reference to an point object (possibly derived from
Geo0D)*/
PointType & point( ID const i );
PointType)*/
PointType const & point ( ID const i ) const;
//! The ith point (starting from the end)
/* It returns the reference to an point object (possibly derived from
Geo0D). It starts from the last point, yet it follows the rule: vertices
PointType). It starts from the last point, yet it follows the rule: vertices
first. It may be used to access the points of a Geometry Element in a
reverse way (i.e. with the opposite GeoElement orientation)*/
PointType & reversepoint( ID const i );
PointType const & reversepoint ( ID const i ) const;
//!Inserts a point. Uses point references
void setPoint( ID const i, Geo0D const & p ); //put point
void setPoint( ID const i, PointType const & p ); //put point
//!Inserts a point Uses point references (bounds check)
bool setPointBD( ID const i, Geo0D const & p ); //with forced bound check
bool setPointBD( ID const i, PointType const & p ); //with forced bound check
//!Inserts a point. Uses pointers
void setPoint( ID const i, Geo0D const * p ); //put point
void setPoint( ID const i, PointType const * p ); //put point
//!Inserts a point. Uses pointers (bounds check)
bool setPointBD( ID const i, Geo0D const * p ); //with forced bound check
bool setPointBD( ID const i, PointType const * p ); //with forced bound check
//! If marker flag of point p is unset, is stes it to that of the argument, otherwise
//! is sets it to the stronger flag between the stored one
//! and the one provided by the argument.
/*! Be aware: This method is going to do a const_cast to _points to
change the flag.
*/
EntityFlag setStrongerMarkerAtPoint( const ID& pt, EntityFlag const & p );
std::ostream & showMe( bool verbose = false, std::ostream & c = std::cout ) const;
......@@ -93,7 +99,7 @@ public:
void exchangePoints( const ID otn[ GEOSHAPE::numPoints ] );
private:
Geo0D * _points[ GEOSHAPE::numPoints ];
PointType const* _points[ GEOSHAPE::numPoints ];
};
......@@ -160,28 +166,12 @@ GeoND<GEOSHAPE, POINTTYPE>::operator=( GeoND<GEOSHAPE, POINTTYPE> const & G )
}
template <typename GEOSHAPE, typename POINTTYPE>
INLINE
POINTTYPE & GeoND<GEOSHAPE, POINTTYPE>::point( ID const i )
{
ASSERT_BD( ( i > 0 && i <= GeoND<GEOSHAPE, POINTTYPE>::numLocalPoints ) ) ;
return *( static_cast<POINTTYPE *>( _points[ i - 1 ] ) ); // indexing from 1
}
template <typename GEOSHAPE, typename POINTTYPE>
INLINE
POINTTYPE const & GeoND<GEOSHAPE, POINTTYPE>::point( ID const i ) const
{
ASSERT_BD( ( i > 0 && i <= GeoND<GEOSHAPE, POINTTYPE>::numLocalPoints ) );
return *( static_cast<POINTTYPE *>( _points[ i - 1 ] ) );
}
template <typename GEOSHAPE, typename POINTTYPE>
INLINE
POINTTYPE & GeoND<GEOSHAPE, POINTTYPE>::reversepoint( ID const i )
{
ASSERT_BD( ( i > 0 && i <= GeoND<GEOSHAPE, POINTTYPE>::numLocalPoints ) ) ;
return *( static_cast<POINTTYPE *>( _points[ reversePoint<GEOSHAPE>::operate( i ) - 1 ] ) ); // indexing from 1
return *( static_cast<POINTTYPE const*>( _points[ i - 1 ] ) );
}
template <typename GEOSHAPE, typename POINTTYPE>
......@@ -189,21 +179,21 @@ INLINE
POINTTYPE const & GeoND<GEOSHAPE, POINTTYPE>::reversepoint( ID const i ) const
{
ASSERT_BD( ( i > 0 && i <= GeoND<GEOSHAPE, POINTTYPE>::numLocalPoints ) );
return *( static_cast<POINTTYPE *>( _points[ reversePoint<GEOSHAPE>::operate( i ) - 1 ] ) );
return *( static_cast<POINTTYPE const*>( _points[ reversePoint<GEOSHAPE>::operate( i ) - 1 ] ) );
}
template <typename GEOSHAPE, typename POINTTYPE>
INLINE
void GeoND<GEOSHAPE, POINTTYPE>::setPoint( ID const i, Geo0D const & p )
void GeoND<GEOSHAPE, POINTTYPE>::setPoint( ID const i, PointType const & p )
{
ASSERT_BD( ( i > 0 && i <= GeoND<GEOSHAPE, POINTTYPE>::numLocalPoints ) ) ;
_points[ i - 1 ] = const_cast<Geo0D *>( &p );
_points[ i - 1 ] = ( &p );
}
template <typename GEOSHAPE, typename POINTTYPE>
bool GeoND<GEOSHAPE, POINTTYPE>::setPointBD( ID const i, Geo0D const & p )
bool GeoND<GEOSHAPE, POINTTYPE>::setPointBD( ID const i, PointType const & p )
{
ASSERT_BD0( ( i > 0 && i <= GeoND<GEOSHAPE, POINTTYPE>::numLocalPoints ) ) ;
......@@ -212,21 +202,21 @@ bool GeoND<GEOSHAPE, POINTTYPE>::setPointBD( ID const i, Geo0D const & p )
if ( i <= 0 || i > GeoND<GEOSHAPE, POINTTYPE>::numLocalVertices )
return false;
_points[ i -1 ] = const_cast<Geo0D *>( &p );
_points[ i -1 ] = ( &p );
return true;
}
template <typename GEOSHAPE, typename POINTTYPE>
INLINE
void GeoND<GEOSHAPE, POINTTYPE>::setPoint( ID const i, Geo0D const * p )
void GeoND<GEOSHAPE, POINTTYPE>::setPoint( ID const i, PointType const * p )
{
ASSERT_BD( ( i > 0 && i <= GeoND<GEOSHAPE, POINTTYPE>::numLocalPoints ) ) ;
_points[ i - 1 ] = const_cast<Geo0D *>( p );
_points[ i - 1 ] = ( p );
}
template <typename GEOSHAPE, typename POINTTYPE>
bool GeoND<GEOSHAPE, POINTTYPE>::setPointBD( ID const i, Geo0D const * p )
bool GeoND<GEOSHAPE, POINTTYPE>::setPointBD( ID const i, PointType const * p )
{
ASSERT_BD0( ( i > 0 && i <= GeoND<GEOSHAPE, POINTTYPE>::numLocalPoints ) ) ;
......@@ -235,10 +225,16 @@ bool GeoND<GEOSHAPE, POINTTYPE>::setPointBD( ID const i, Geo0D const * p )
if ( i <= 0 || i > GeoND<GEOSHAPE, POINTTYPE>::numLocalVertices )
return false;
_points[ i -1 ] = const_cast<Geo0D *>( p );
_points[ i -1 ] = ( p );
return true;
}
template <typename GEOSHAPE, typename POINTTYPE>
EntityFlag GeoND<GEOSHAPE, POINTTYPE>::setStrongerMarkerAtPoint( const ID& i, EntityFlag const & p )
{
return (const_cast<POINTTYPE *> ( _points[i -1]) ) -> setStrongerMarker(p);
}
template <typename GEOSHAPE, typename POINTTYPE>
std::ostream & GeoND<GEOSHAPE, POINTTYPE>::
......@@ -265,7 +261,7 @@ showMe( bool verbose, std::ostream & out ) const
template <typename GEOSHAPE, typename POINTTYPE>
void GeoND<GEOSHAPE, POINTTYPE>::swapPoints( const ID & pt1, const ID & pt2 )
{
Geo0D * tmp( _points[ pt1 - 1 ] );
PointType const* tmp( _points[ pt1 - 1 ] );
_points[ pt1 - 1 ] = _points[ pt2 - 1 ];
_points[ pt2 - 1 ] = tmp;
}
......@@ -273,7 +269,7 @@ void GeoND<GEOSHAPE, POINTTYPE>::swapPoints( const ID & pt1, const ID & pt2 )
template <typename GEOSHAPE, typename POINTTYPE>
void GeoND<GEOSHAPE, POINTTYPE>::exchangePoints( const ID otn[ GEOSHAPE::numPoints ] )
{
Geo0D * tmp[ GEOSHAPE::numPoints ];
PointType const* tmp[ GEOSHAPE::numPoints ];
for ( unsigned int i = 0;i < GEOSHAPE::numPoints;++i )
{
tmp[ i ] = _points[ i ];
......
Supports Markdown
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