other warnings and cleanups

This commit is contained in:
alemuntoni 2020-04-26 12:27:21 +02:00
parent f583d13191
commit 9f19e890ac
8 changed files with 46 additions and 30 deletions

View File

@ -30,6 +30,7 @@ DAMAGE.
#define ALLOCATOR_INCLUDED
#include <vector>
#include <iostream>
class AllocatorState
{
@ -148,7 +149,7 @@ public:
if( elements>blockSize ) fprintf( stderr , "[ERROR] Allocator: elements bigger than block-size: %d>%d\n" , elements , blockSize ) , exit( 0 );
if( remains<elements )
{
if( index==memory.size()-1 )
if( index==(int)memory.size()-1 )
{
mem = new T[blockSize];
if( !mem ) fprintf( stderr , "[ERROR] Failed to allocate memory\n" ) , exit(0);

View File

@ -119,8 +119,8 @@ template< class C > const C* GetPointer( const C& c ){ return &c; }
template< class C > C* GetPointer( std::vector< C >& v ){ return &v[0]; }
template< class C > const C* GetPointer( const std::vector< C >& v ){ return &v[0]; }
template< class C > C* GetPointer( C* c , int sz ) { return c; }
template< class C > const C* GetPointer( const C* c , int sz ) { return c; }
template< class C > C* GetPointer( C* c , int ) { return c; }
template< class C > const C* GetPointer( const C* c , int ) { return c; }
#endif // ARRAY_DEBUG
#endif // ARRAY_INCLUDED

View File

@ -57,7 +57,7 @@ void Octree< Real >::_Evaluator< FEMDegree , BType >::set( LocalDepth depth )
}
//// The face stencil
for( int f=0 ; f<Cube::FACES ; f++ )
for( unsigned int f=0 ; f<Cube::FACES ; f++ )
{
int dir , off;
Cube::FactorFaceIndex( f , dir , off );
@ -94,7 +94,7 @@ void Octree< Real >::_Evaluator< FEMDegree , BType >::set( LocalDepth depth )
}
//// The edge stencil
for( int e=0 ; e<Cube::EDGES ; e++ )
for( unsigned int e=0 ; e<Cube::EDGES ; e++ )
{
int orientation , i1 , i2;
Cube::FactorEdgeIndex( e , orientation , i1 , i2 );
@ -131,7 +131,7 @@ void Octree< Real >::_Evaluator< FEMDegree , BType >::set( LocalDepth depth )
}
//// The corner stencil
for( int c=0 ; c<Cube::CORNERS ; c++ )
for( unsigned int c=0 ; c<Cube::CORNERS ; c++ )
{
int cx , cy ,cz;
Cube::FactorCornerIndex( c , cx , cy , cz );
@ -170,7 +170,7 @@ void Octree< Real >::_Evaluator< FEMDegree , BType >::set( LocalDepth depth )
}
//// The face stencil
for( int f=0 ; f<Cube::FACES ; f++ )
for( unsigned int f=0 ; f<Cube::FACES ; f++ )
{
int dir , off;
Cube::FactorFaceIndex( f , dir , off );
@ -207,7 +207,7 @@ void Octree< Real >::_Evaluator< FEMDegree , BType >::set( LocalDepth depth )
}
//// The edge stencil
for( int e=0 ; e<Cube::EDGES ; e++ )
for( unsigned int e=0 ; e<Cube::EDGES ; e++ )
{
int orientation , i1 , i2;
Cube::FactorEdgeIndex( e , orientation , i1 , i2 );
@ -244,7 +244,7 @@ void Octree< Real >::_Evaluator< FEMDegree , BType >::set( LocalDepth depth )
}
//// The corner stencil
for( int c=0 ; c<Cube::CORNERS ; c++ )
for( unsigned int c=0 ; c<Cube::CORNERS ; c++ )
{
int cx , cy ,cz;
Cube::FactorCornerIndex( c , cx , cy , cz );
@ -269,7 +269,7 @@ V Octree< Real >::_getValue( const ConstPointSupportKey< FEMDegree >& neighborKe
{
static const int SupportSize = BSplineSupportSizes< FEMDegree >::SupportSize;
static const int LeftSupportRadius = -BSplineSupportSizes< FEMDegree >::SupportStart;
static const int RightSupportRadius = BSplineSupportSizes< FEMDegree >::SupportEnd;
//static const int RightSupportRadius = BSplineSupportSizes< FEMDegree >::SupportEnd;
static const int LeftPointSupportRadius = BSplineSupportSizes< FEMDegree >::SupportEnd;
static const int RightPointSupportRadius = - BSplineSupportSizes< FEMDegree >::SupportStart;

View File

@ -26,6 +26,8 @@ ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF S
DAMAGE.
*/
#include "MultiGridOctreeData.h"
#include "Octree.h"
#include "MyTime.h"
#include "MemoryUsage.h"
@ -762,11 +764,11 @@ void Octree< Real >::_setIsoSurface( LocalDepth depth , int offset , const _Slic
if( inBounds && !IsActiveNode( leaf->children ) )
{
edges.clear();
unsigned char mcIndex = ( bValues.mcIndices[ i - bValues.sliceData.nodeOffset ] ) | ( fValues.mcIndices[ i - fValues.sliceData.nodeOffset ]<<4 );
//unsigned char mcIndex = ( bValues.mcIndices[ i - bValues.sliceData.nodeOffset ] ) | ( fValues.mcIndices[ i - fValues.sliceData.nodeOffset ]<<4 );
// [WARNING] Just because the node looks empty doesn't mean it doesn't get eges from finer neighbors
{
// Gather the edges from the faces (with the correct orientation)
for( int f=0 ; f<Cube::FACES ; f++ )
for( unsigned int f=0 ; f<Cube::FACES ; f++ )
{
int d , o;
Cube::FactorFaceIndex( f , d , o );
@ -825,8 +827,9 @@ void Octree< Real >::_setIsoSurface( LocalDepth depth , int offset , const _Slic
long long start = edge[0] , current = edge[1];
while( current!=start )
{
int idx;
for( idx=0 ; idx<(int)edges.size() ; idx++ ) if( edges[idx][0]==current ) break;
unsigned int idx;
for( idx=0 ; idx<edges.size() ; idx++ )
if( edges[idx][0]==current ) break;
if( idx==edges.size() )
{
typename std::unordered_map< long long, long long >::const_iterator iter;

View File

@ -545,7 +545,7 @@ void Octree< Real >::_upSample( LocalDepth highDepth , DenseNodeData< C , FEMDeg
static const int DownSampleSize = BSplineSupportSizes< FEMDegree >::DownSample0Size > BSplineSupportSizes< FEMDegree >::DownSample1Size ? BSplineSupportSizes< FEMDegree >::DownSample0Size : BSplineSupportSizes< FEMDegree >::DownSample1Size;
Stencil< double , DownSampleSize > downSampleStencils[ Cube::CORNERS ];
int lowCenter = ( 1<<lowDepth )>>1;
for( int c=0 ; c<Cube::CORNERS ; c++ )
for( unsigned int c=0 ; c<Cube::CORNERS ; c++ )
{
int cx , cy , cz;
Cube::FactorCornerIndex( c , cx , cy , cz );
@ -943,14 +943,14 @@ void Octree< Real >::_updateCumulativeInterpolationConstraintsFromFiner( const I
static const int LeftPointSupportRadius = BSplineSupportSizes< FEMDegree >::SupportEnd;
static const int RightPointSupportRadius = -BSplineSupportSizes< FEMDegree >::SupportStart;
static const int LeftSupportRadius = -BSplineSupportSizes< FEMDegree >::SupportStart;
static const int RightSupportRadius = BSplineSupportSizes< FEMDegree >::SupportEnd;
//static const int RightSupportRadius = BSplineSupportSizes< FEMDegree >::SupportEnd;
// Note: We can't iterate over the finer point nodes as the point weights might be
// scaled incorrectly, due to the adaptive exponent. So instead, we will iterate
// over the coarser nodes and evaluate the finer solution at the associated points.
LocalDepth lowDepth = highDepth-1;
if( lowDepth<0 ) return;
size_t start = _sNodesBegin(lowDepth) , end = _sNodesEnd(lowDepth);
//size_t start = _sNodesBegin(lowDepth) , end = _sNodesEnd(lowDepth);
std::vector< PointSupportKey< FEMDegree > > neighborKeys( std::max< int >( 1 , threads ) );
for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( _localToGlobal( lowDepth ) );
#pragma omp parallel for num_threads( threads )
@ -1293,7 +1293,7 @@ int Octree< Real >::_getSliceMatrixAndUpdateConstraints( const FEMSystemFunctor&
}
}
#if !defined( _WIN32 ) && !defined( _WIN64 )
#pragma message( "[WARNING] I'm not sure how expensive this system call is on non-Windows system. (You may want to comment this out.)" )
//#pragma message( "[WARNING] I'm not sure how expensive this system call is on non-Windows system. (You may want to comment this out.)" )
#endif // !_WIN32 && !_WIN64
memoryUsage();
return 1;
@ -1638,7 +1638,7 @@ void Octree< Real >::_updateConstraintsFromCoarser( const FEMSystemFunctor& F ,
// Given the solution @( depth ) add to the met constraints @( depth-1 )
template< class Real >
template< int FEMDegree , BoundaryType BType , class FEMSystemFunctor >
void Octree< Real >::_updateCumulativeIntegralConstraintsFromFiner( const FEMSystemFunctor& F , const BSplineData< FEMDegree , BType >& bsData , LocalDepth highDepth , const DenseNodeData< Real , FEMDegree >& fineSolution , DenseNodeData< Real , FEMDegree >& coarseConstraints ) const
void Octree< Real >::_updateCumulativeIntegralConstraintsFromFiner( const FEMSystemFunctor& F , const BSplineData< FEMDegree , BType >& , LocalDepth highDepth , const DenseNodeData< Real , FEMDegree >& fineSolution , DenseNodeData< Real , FEMDegree >& coarseConstraints ) const
{
typename BSplineIntegrationData< FEMDegree , BType , FEMDegree , BType >::FunctionIntegrator::template ChildIntegrator< DERIVATIVES( FEMDegree ) , DERIVATIVES( FEMDegree ) > childIntegrator;
BSplineIntegrationData< FEMDegree , BType , FEMDegree , BType >::SetChildIntegrator( childIntegrator , highDepth-1 );
@ -1651,8 +1651,8 @@ void Octree< Real >::_updateCumulativeIntegralConstraintsFromFiner( const FEMSys
// Get the stencil describing the Laplacian relating coefficients @(depth) with coefficients @(depth-1)
Stencil< double , OverlapSize > stencils[2][2][2];
SystemCoefficients< FEMDegree , BType , FEMDegree , BType >::SetCentralSystemStencils( F , childIntegrator , stencils );
size_t start = _sNodesBegin( highDepth) , end = _sNodesEnd(highDepth) , range = end-start;
int lStart = _sNodesBegin(highDepth-1);
size_t start = _sNodesBegin( highDepth) , end = _sNodesEnd(highDepth) ;
//int lStart = _sNodesBegin(highDepth-1);
// Iterate over the nodes @( depth )
std::vector< SupportKey > neighborKeys( std::max< int >( 1 , threads ) );
@ -1926,7 +1926,7 @@ void Octree< Real >::_addFEMConstraints( const FEMConstraintFunctor& F , const C
// Compute the contribution from all coarser depths
for( LocalDepth d=1 ; d<=maxDepth ; d++ )
{
size_t start = _sNodesBegin( d ) , end = _sNodesEnd( d );
//size_t start = _sNodesBegin( d ) , end = _sNodesEnd( d );
Stencil< _D , CFEMOverlapSize > stencils[2][2][2];
typename SystemCoefficients< CDegree , CBType , FEMDegree , FEMBType >::ChildIntegrator childIntegrator;
BSplineIntegrationData< CDegree , CBType , FEMDegree , FEMBType >::SetChildIntegrator( childIntegrator , d-1 );

View File

@ -692,7 +692,7 @@ public:
const Point3D< Real >& normal = *n;
if( normal[0]!=0 || normal[1]!=0 || normal[2]!=0 ) return true;
}
if( node->children ) for( int c=0 ; c<Cube::CORNERS ; c++ ) if( (*this)( node->children + c ) ) return true;
if( node->children ) for( unsigned int c=0 ; c<Cube::CORNERS ; c++ ) if( (*this)( node->children + c ) ) return true;
return false;
}
};

View File

@ -187,18 +187,30 @@ template< class Real >
struct _PointDataAccumulator_< Real , false >
{
#if POINT_DATA_RES
static inline void _AddToPointData_( PointData< Real , false >& pData , Point3D< Real > position , Real value , Point3D< Real > gradient , Point3D< Real > center , Real width , Real weight ){ pData.addPoint( SinglePointData< Real , false >( position , value , weight ) , center , width ); }
static inline void _AddToPointData_( PointData< Real , false >& pData , Point3D< Real > position , Real value , Point3D< Real > , Point3D< Real > center , Real width , Real weight )
{
pData.addPoint( SinglePointData< Real , false >( position , value , weight ) , center , width );
}
#else // !POINT_DATA_RES
static inline void _AddToPointData_( PointData< Real , false >& pData , Point3D< Real > position , Real value , Point3D< Real > gradient , Real weight ){ pData.position += position , pData.value += value , pData.weight += weight; }
static inline void _AddToPointData_( PointData< Real , false >& pData , Point3D< Real > position , Real value , Point3D< Real > , Real weight )
{
pData.position += position , pData.value += value , pData.weight += weight;
}
#endif // POINT_DATA_RES
};
template< class Real >
struct _PointDataAccumulator_< Real , true >
{
#if POINT_DATA_RES
static inline void _AddToPointData_( PointData< Real , true >& pData , Point3D< Real > position , Real value , Point3D< Real > gradient , Point3D< Real > center , Real width , Real weight ){ pData.addPoint( SinglePointData< Real , true >( position , value , gradient , weight ) , center , width ); }
static inline void _AddToPointData_( PointData< Real , true >& pData , Point3D< Real > position , Real value , Point3D< Real > gradient , Point3D< Real > center , Real width , Real weight )
{
pData.addPoint( SinglePointData< Real , true >( position , value , gradient , weight ) , center , width );
}
#else // !POINT_DATA_RES
static inline void _AddToPointData_( PointData< Real , true >& pData , Point3D< Real > position , Real value , Point3D< Real > gradient , Real weight ){ pData.position += position , pData.value += value , pData.gradient += gradient , pData.weight += weight; }
static inline void _AddToPointData_( PointData< Real , true >& pData , Point3D< Real > position , Real value , Point3D< Real > gradient , Real weight )
{
pData.position += position , pData.value += value , pData.gradient += gradient , pData.weight += weight;
}
#endif // POINT_DATA_RES
};
@ -294,7 +306,7 @@ typename Octree< Real >::template DensityEstimator< DensityDegree >* Octree< Rea
#ifdef FAST_SET_UP
std::vector< int > sampleMap( NodeCount() , -1 );
#pragma omp parallel for num_threads( threads )
for( unsigned int i=0 ; i<samples.size() ; i++ )
for( int i=0 ; i<(int)samples.size() ; i++ )
if( samples[i].sample.weight>0 )
sampleMap[ samples[i].node->nodeData.nodeIndex ] = i;
std::function< ProjectiveData< OrientedPoint3D< Real > , Real > ( TreeOctNode* ) > SetDensity = [&] ( TreeOctNode* node )
@ -328,7 +340,7 @@ typename Octree< Real >::template DensityEstimator< DensityDegree >* Octree< Rea
};
SetDensity( _spaceRoot );
#else // !FAST_SET_UP
for( unsigned int i=0 ; i<samples.size() ; i++ )
for( int i=0 ; i<(int)samples.size() ; i++ )
{
const TreeOctNode* node = samples[i].node;
const ProjectiveData< OrientedPoint3D< Real > , Real >& sample = samples[i].sample;

View File

@ -458,7 +458,7 @@ int _Execute(
double valueSum = 0 , weightSum = 0;
typename Octree< Real >::template MultiThreadedEvaluator< Degree , BType > evaluator( &tree , solution , pp.ThreadsVal );
#pragma omp parallel for num_threads( pp.ThreadsVal ) reduction( + : valueSum , weightSum )
for( unsigned int j=0 ; j<samples->size() ; j++ ) {
for( int j=0 ; j<(int)samples->size() ; j++ ) {
ProjectiveData< OrientedPoint3D< Real > , Real >& sample = (*samples)[j].sample;
Real w = sample.weight;
if( w>0 ) weightSum += w , valueSum += evaluator.value( sample.data.p / sample.weight , omp_get_thread_num() , (*samples)[j].node ) * w;