Commit e794db7e authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

[BUGFIX] split PeriodicIntersect into h and cpp

parent 2c007046
......@@ -546,7 +546,7 @@ void SetupBlockForest::getBlocks( std::vector< SetupBlock* >& blocks, const uint
void SetupBlockForest::mapPointToPeriodicDomain( real_t & px, real_t & py, real_t & pz ) const
{
boost::array< bool, 3 > periodic;
std::array< bool, 3 > periodic;
periodic[0] = periodic_[0];
periodic[1] = periodic_[1];
periodic[2] = periodic_[2];
......
......@@ -167,6 +167,7 @@ public:
inline void extend( const value_type e );
inline void extend( const vector_type & e );
inline void setCenter( const vector_type & center );
inline void translate( const vector_type & translation );
inline void scale( const value_type factor );
......
......@@ -491,7 +491,6 @@ template< typename T >
typename GenericAABB< T >::value_type GenericAABB< T >::volume() const
{
WALBERLA_ASSERT( checkInvariant() );
return ( maxCorner_[0] - minCorner_[0] ) * ( maxCorner_[1] - minCorner_[1] ) * ( maxCorner_[2] - minCorner_[2] );
}
......@@ -1563,6 +1562,21 @@ void GenericAABB< T >::extend( const vector_type & e )
/**
* \brief Sets center of this GenericAABB
*
* AABB gets translated such that its center matches the given center.
*
* \param new center location
*/
template< typename T >
void GenericAABB< T >::setCenter( const vector_type & center )
{
translate(center - this->center());
}
/**
* \brief Translates this GenericAABB
*
......
......@@ -46,7 +46,7 @@ namespace domain_decomposition {
//**********************************************************************************************************************
void BlockStorage::mapToPeriodicDomain( real_t & x, real_t & y, real_t & z ) const
{
boost::array< bool, 3 > periodic;
std::array< bool, 3 > periodic;
periodic[0] = periodic_[0];
periodic[1] = periodic_[1];
periodic[2] = periodic_[2];
......@@ -62,7 +62,7 @@ void BlockStorage::mapToPeriodicDomain( real_t & x, real_t & y, real_t & z ) con
//**********************************************************************************************************************
bool BlockStorage::periodicIntersect( const math::AABB & box1, const math::AABB & box2 ) const
{
boost::array< bool, 3 > periodic;
std::array< bool, 3 > periodic;
periodic[0] = periodic_[0];
periodic[1] = periodic_[1];
periodic[2] = periodic_[2];
......@@ -73,12 +73,12 @@ bool BlockStorage::periodicIntersect( const math::AABB & box1, const math::AABB
//**********************************************************************************************************************
/*!
* For documentation, see documentation of free function
* 'bool periodicIntersect( const boost::array< bool, 3 > & periodic, const math::AABB & domain, const math::AABB & box1, const math::AABB & box2 )'
* 'bool periodicIntersect( const std::array< bool, 3 > & periodic, const math::AABB & domain, const math::AABB & box1, const math::AABB & box2 )'
*/
//**********************************************************************************************************************
bool BlockStorage::periodicIntersect( const math::AABB & box1, const math::AABB & box2, const real_t dx ) const
{
boost::array< bool, 3 > periodic;
std::array< bool, 3 > periodic;
periodic[0] = periodic_[0];
periodic[1] = periodic_[1];
periodic[2] = periodic_[2];
......
......@@ -29,7 +29,7 @@ namespace domain_decomposition {
void mapPointToPeriodicDomain( const boost::array< bool, 3 > & periodic, const AABB & domain, real_t & x, real_t & y, real_t & z )
void mapPointToPeriodicDomain( const std::array< bool, 3 > & periodic, const AABB & domain, real_t & x, real_t & y, real_t & z )
{
if( periodic[0] )
{
......
......@@ -25,7 +25,7 @@
#include "core/math/AABB.h"
#include "core/math/Vector3.h"
#include <boost/array.hpp>
#include <array>
......@@ -42,12 +42,12 @@ namespace domain_decomposition {
* The min points of the domain are included in the simulation space, the max points are excluded!
*/
//**********************************************************************************************************************
void mapPointToPeriodicDomain( const boost::array< bool, 3 > & periodic, const AABB & domain, real_t & x, real_t & y, real_t & z );
void mapPointToPeriodicDomain( const std::array< bool, 3 > & periodic, const AABB & domain, real_t & x, real_t & y, real_t & z );
/// see documetation of 'void mapPointToPeriodicDomain( const boost::array< bool, 3 > & periodic, const AABB & domain, real_t & x, real_t & y, real_t & z )'
inline void mapPointToPeriodicDomain( const boost::array< bool, 3 > & periodic, const AABB & domain, Vector3< real_t > & p )
inline void mapPointToPeriodicDomain( const std::array< bool, 3 > & periodic, const AABB & domain, Vector3< real_t > & p )
{
mapPointToPeriodicDomain( periodic, domain, p[0], p[1], p[2] );
}
......@@ -55,7 +55,7 @@ inline void mapPointToPeriodicDomain( const boost::array< bool, 3 > & periodic,
/// see documetation of 'void mapPointToPeriodicDomain( const boost::array< bool, 3 > & periodic, const AABB & domain, real_t & x, real_t & y, real_t & z )'
inline Vector3< real_t > mapPointToPeriodicDomain( const boost::array< bool, 3 > & periodic, const AABB & domain, const Vector3< real_t > & p )
inline Vector3< real_t > mapPointToPeriodicDomain( const std::array< bool, 3 > & periodic, const AABB & domain, const Vector3< real_t > & p )
{
Vector3< real_t > point( p );
mapPointToPeriodicDomain( periodic, domain, point[0], point[1], point[2] );
......
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla 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 General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file PeriodicIntersect.cpp
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#include "PeriodicIntersect.h"
#include "MapPointToPeriodicDomain.h"
namespace walberla {
namespace domain_decomposition {
bool periodicIntersect( const std::array< bool, 3 > & periodic, const math::AABB & domain, const math::AABB & box1, const math::AABB & box2 )
{
auto min1 = box1.minCorner();
auto min2 = box2.minCorner();
auto max1 = box1.maxCorner();
auto max2 = box2.maxCorner();
mapPointToPeriodicDomain(periodic, domain, min1);
mapPointToPeriodicDomain(periodic, domain, min2);
mapPointToPeriodicDomain(periodic, domain, max1);
mapPointToPeriodicDomain(periodic, domain, max2);
bool flag = false;
if (max1[0] > max2[0])
{
if ( (max1[0]-max2[0]) < box1.xSize() ) flag = true;
} else
{
if ( (max2[0]-max1[0]) < box2.xSize() ) flag = true;
}
if (min1[0] > min2[0])
{
if ( (min1[0]-min2[0]) < box2.xSize() ) flag = true;
} else
{
if ( (min2[0]-min1[0]) < box1.xSize() ) flag = true;
}
if (!flag) return false;
flag = false;
if (max1[1] > max2[1])
{
if ( (max1[1]-max2[1]) < box1.ySize() ) flag = true;
} else
{
if ( (max2[1]-max1[1]) < box2.ySize() ) flag = true;
}
if (min1[1] > min2[1])
{
if ( (min1[1]-min2[1]) < box2.ySize() ) flag = true;
} else
{
if ( (min2[1]-min1[1]) < box1.ySize() ) flag = true;
}
if (!flag) return false;
flag = false;
if (max1[2] > max2[2])
{
if ( (max1[2]-max2[2]) < box1.zSize() ) flag = true;
} else
{
if ( (max2[2]-max1[2]) < box2.zSize() ) flag = true;
}
if (min1[2] > min2[2])
{
if ( (min1[2]-min2[2]) < box2.zSize() ) flag = true;
} else
{
if ( (min2[2]-min1[2]) < box1.zSize() ) flag = true;
}
return flag;
}
bool periodicIntersect( const std::array< bool, 3 > & periodic, const math::AABB & domain, const math::AABB& box1, const math::AABB & box2, const real_t dx )
{
return periodicIntersect(periodic, domain, box1.getExtended( dx ), box2);
}
} // namespace domain_decomposition
} // namespace walberla
......@@ -14,97 +14,23 @@
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file PeriodicIntersect.h
//! \ingroup domain_decomposition
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
#pragma once
#include "MapPointToPeriodicDomain.h"
#include "core/DataTypes.h"
#include "core/math/AABB.h"
#include "core/math/Vector3.h"
#include <boost/array.hpp>
#include <array>
namespace walberla {
namespace domain_decomposition {
bool periodicIntersect( const boost::array< bool, 3 > & periodic, const math::AABB & domain, const math::AABB & box1, const math::AABB & box2 )
{
auto min1 = box1.minCorner();
auto min2 = box2.minCorner();
auto max1 = box1.maxCorner();
auto max2 = box2.maxCorner();
mapPointToPeriodicDomain(periodic, domain, min1);
mapPointToPeriodicDomain(periodic, domain, min2);
mapPointToPeriodicDomain(periodic, domain, max1);
mapPointToPeriodicDomain(periodic, domain, max2);
bool flag = false;
if (max1[0] > max2[0])
{
if ( (max1[0]-max2[0]) < box1.xSize() ) flag = true;
} else
{
if ( (max2[0]-max1[0]) < box2.xSize() ) flag = true;
}
if (min1[0] > min2[0])
{
if ( (min1[0]-min2[0]) < box2.xSize() ) flag = true;
} else
{
if ( (min2[0]-min1[0]) < box1.xSize() ) flag = true;
}
if (!flag) return false;
flag = false;
if (max1[1] > max2[1])
{
if ( (max1[1]-max2[1]) < box1.ySize() ) flag = true;
} else
{
if ( (max2[1]-max1[1]) < box2.ySize() ) flag = true;
}
if (min1[1] > min2[1])
{
if ( (min1[1]-min2[1]) < box2.ySize() ) flag = true;
} else
{
if ( (min2[1]-min1[1]) < box1.ySize() ) flag = true;
}
if (!flag) return false;
flag = false;
if (max1[2] > max2[2])
{
if ( (max1[2]-max2[2]) < box1.zSize() ) flag = true;
} else
{
if ( (max2[2]-max1[2]) < box2.zSize() ) flag = true;
}
if (min1[2] > min2[2])
{
if ( (min1[2]-min2[2]) < box2.zSize() ) flag = true;
} else
{
if ( (min2[2]-min1[2]) < box1.zSize() ) flag = true;
}
return flag;
}
bool periodicIntersect( const boost::array< bool, 3 > & periodic, const math::AABB & domain, const math::AABB& box1, const math::AABB & box2, const real_t dx )
{
return periodicIntersect(periodic, domain, box1.getExtended( dx ), box2);
}
bool periodicIntersect( const std::array< bool, 3 > & periodic, const math::AABB & domain, const math::AABB & box1, const math::AABB & box2 );
bool periodicIntersect( const std::array< bool, 3 > & periodic, const math::AABB & domain, const math::AABB& box1, const math::AABB & box2, const real_t dx );
} // namespace domain_decomposition
} // namespace walberla
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