Skip to content

Commit 3f4653e

Browse files
committed
boundary update
Modified the implementation of dirichlet constraints to support more general multigrid processing
1 parent fb6151d commit 3f4653e

File tree

5 files changed

+96
-128
lines changed

5 files changed

+96
-128
lines changed

Src/MultiGridOctreeData.IsoSurface.inl

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ Real Octree< Real >::GetIsoValue( ConstPointer( Real ) solution , const std::vec
247247
for( int d=maxDepth ; d>=_minDepth ; d-- )
248248
{
249249
std::vector< typename TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) );
250-
for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( d );
250+
for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( d );
251251
#pragma omp parallel for num_threads( threads ) reduction( + : isoValue , weightSum )
252252
for( int i=_sNodes.nodeCount[d] ; i<_sNodes.nodeCount[d+1] ; i++ )
253253
{
@@ -279,8 +279,7 @@ Real Octree< Real >::GetIsoValue( ConstPointer( Real ) solution , const std::vec
279279
if( w!=0 ) isoValue += value * w , weightSum += w;
280280
}
281281
}
282-
if( _boundaryType==-1 ) return isoValue/weightSum - Real(0.5);
283-
else return isoValue/weightSum;
282+
return isoValue / weightSum;
284283
}
285284

286285
template< class Real >
@@ -296,7 +295,7 @@ void Octree< Real >::SetSliceIsoCorners( ConstPointer( Real ) solution , ConstPo
296295
{
297296
typename Octree< Real >::template SliceValues< Vertex >& sValues = slabValues[depth].sliceValues( slice );
298297
std::vector< typename TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) );
299-
for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
298+
for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
300299
#pragma omp parallel for num_threads( threads )
301300
for( int i=_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slice-z] ; i<_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slice-z+1] ; i++ )
302301
{
@@ -364,7 +363,7 @@ void Octree< Real >::SetSliceIsoVertices( ConstPointer( Real ) kernelDensityWeig
364363
{
365364
typename Octree< Real >::template SliceValues< Vertex >& sValues = slabValues[depth].sliceValues( slice );
366365
std::vector< typename TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) );
367-
for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
366+
for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
368367
#pragma omp parallel for num_threads( threads )
369368
for( int i=_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slice-z] ; i<_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slice-z+1] ; i++ )
370369
{
@@ -456,7 +455,7 @@ void Octree< Real >::SetXSliceIsoVertices( ConstPointer( Real ) kernelDensityWei
456455
typename Octree< Real >::template XSliceValues< Vertex >& xValues = slabValues[depth].xSliceValues( slab );
457456

458457
std::vector< typename TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) );
459-
for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
458+
for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
460459
#pragma omp parallel for num_threads( threads )
461460
for( int i=_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slab] ; i<_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slab+1] ; i++ )
462461
{
@@ -661,7 +660,7 @@ void Octree< Real >::SetSliceIsoEdges( int depth , int slice , int z , std::vect
661660
{
662661
typename Octree< Real >::template SliceValues< Vertex >& sValues = slabValues[depth].sliceValues( slice );
663662
std::vector< typename TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) );
664-
for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
663+
for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
665664
#pragma omp parallel for num_threads( threads )
666665
for( int i=_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slice-z] ; i<_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slice-z+1] ; i++ )
667666
{
@@ -721,7 +720,7 @@ void Octree< Real >::SetXSliceIsoEdges( int depth , int slab , std::vector< Slab
721720
typename Octree< Real >::template XSliceValues< Vertex >& xValues = slabValues[depth].xSliceValues( slab );
722721

723722
std::vector< typename TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) );
724-
for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
723+
for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
725724
#pragma omp parallel for num_threads( threads )
726725
for( int i=_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slab] ; i<_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][slab+1] ; i++ )
727726
{
@@ -797,7 +796,7 @@ void Octree< Real >::SetIsoSurface( int depth , int offset , const SliceValues<
797796
std::vector< std::pair< int , Vertex > > polygon;
798797
std::vector< typename TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) );
799798
std::vector< std::vector< IsoEdge > > edgess( std::max< int >( 1 , threads ) );
800-
for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
799+
for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
801800
#pragma omp parallel for num_threads( threads )
802801
for( int i=_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][offset] ; i<_sNodes.nodeCount[depth]+_sNodes.sliceOffsets[depth][offset+1] ; i++ )
803802
{
@@ -834,7 +833,7 @@ void Octree< Real >::SetIsoSurface( int depth , int offset , const SliceValues<
834833
if( iter!=sValues.faceEdgeMap.end() )
835834
{
836835
const std::vector< IsoEdge >& _edges = iter->second;
837-
for( int j=0 ; j<_edges.size() ; j++ ) edges.push_back( IsoEdge( _edges[j][flip] , _edges[j][1-flip] ) );
836+
for( size_t j=0 ; j<_edges.size() ; j++ ) edges.push_back( IsoEdge( _edges[j][flip] , _edges[j][1-flip] ) );
838837
}
839838
else fprintf( stderr , "[ERROR] Invalid faces: %d %d %d\n" , i , d , o ) , exit( 0 );
840839
}
@@ -854,7 +853,7 @@ void Octree< Real >::SetIsoSurface( int depth , int offset , const SliceValues<
854853
if( iter!=xValues.faceEdgeMap.end() )
855854
{
856855
const std::vector< IsoEdge >& _edges = iter->second;
857-
for( int j=0 ; j<_edges.size() ; j++ ) edges.push_back( IsoEdge( _edges[j][flip] , _edges[j][1-flip] ) );
856+
for( size_t j=0 ; j<_edges.size() ; j++ ) edges.push_back( IsoEdge( _edges[j][flip] , _edges[j][1-flip] ) );
858857
}
859858
else fprintf( stderr , "[ERROR] Invalid faces: %d %d %d\n" , i , d , o ) , exit( 0 );
860859
}
@@ -871,7 +870,7 @@ void Octree< Real >::SetIsoSurface( int depth , int offset , const SliceValues<
871870
while( current!=start )
872871
{
873872
int idx;
874-
for( idx=0 ; idx<edges.size() ; idx++ ) if( edges[idx][0]==current ) break;
873+
for( idx=0 ; idx<(int)edges.size() ; idx++ ) if( edges[idx][0]==current ) break;
875874
if( idx==edges.size() )
876875
{
877876
typename hash_map< long long , long long >::const_iterator iter;
@@ -890,10 +889,10 @@ void Octree< Real >::SetIsoSurface( int depth , int offset , const SliceValues<
890889
loops.back().push_back( start );
891890
}
892891
// Add the loops to the mesh
893-
for( int j=0 ; j<loops.size() ; j++ )
892+
for( size_t j=0 ; j<loops.size() ; j++ )
894893
{
895894
std::vector< std::pair< int , Vertex > > polygon( loops[j].size() );
896-
for( int k=0 ; k<loops[j].size() ; k++ )
895+
for( size_t k=0 ; k<loops[j].size() ; k++ )
897896
{
898897
long long key = loops[j][k];
899898
typename hash_map< long long , std::pair< int , Vertex > >::const_iterator iter;

Src/MultiGridOctreeData.SortedTreeNodes.inl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void SortedTreeNodes::setSliceTableData( SliceTableData& sData , int depth , int
151151
sData._cMap.resize( sData.nodeCount * Square::CORNERS , 0 ) , sData._eMap.resize( sData.nodeCount * Square::EDGES , 0 ) , sData._fMap.resize( sData.nodeCount * Square::FACES , 0 );
152152
sData.cTable.resize( sData.nodeCount ) , sData.eTable.resize( sData.nodeCount ) , sData.fTable.resize( sData.nodeCount );
153153
std::vector< TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) );
154-
for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
154+
for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
155155
#pragma omp parallel for num_threads( threads )
156156
for( int i=span.first ; i<span.second ; i++ )
157157
{
@@ -246,9 +246,9 @@ void SortedTreeNodes::setSliceTableData( SliceTableData& sData , int depth , int
246246
}
247247
int cCount = 0 , eCount = 0 , fCount = 0;
248248

249-
for( int i=0 ; i<sData._cMap.size() ; i++ ) if( sData._cMap[i] ) sData._cMap[i] = cCount++;
250-
for( int i=0 ; i<sData._eMap.size() ; i++ ) if( sData._eMap[i] ) sData._eMap[i] = eCount++;
251-
for( int i=0 ; i<sData._fMap.size() ; i++ ) if( sData._fMap[i] ) sData._fMap[i] = fCount++;
249+
for( size_t i=0 ; i<sData._cMap.size() ; i++ ) if( sData._cMap[i] ) sData._cMap[i] = cCount++;
250+
for( size_t i=0 ; i<sData._eMap.size() ; i++ ) if( sData._eMap[i] ) sData._eMap[i] = eCount++;
251+
for( size_t i=0 ; i<sData._fMap.size() ; i++ ) if( sData._fMap[i] ) sData._fMap[i] = fCount++;
252252
#pragma omp parallel for num_threads( threads )
253253
for( int i=0 ; i<sData.nodeCount ; i++ )
254254
{
@@ -272,7 +272,7 @@ void SortedTreeNodes::setXSliceTableData( XSliceTableData& sData , int depth , i
272272
sData._eMap.resize( sData.nodeCount * Square::CORNERS , 0 ) , sData._fMap.resize( sData.nodeCount * Square::EDGES , 0 );
273273
sData.eTable.resize( sData.nodeCount ) , sData.fTable.resize( sData.nodeCount );
274274
std::vector< TreeOctNode::ConstNeighborKey3 > neighborKeys( std::max< int >( 1 , threads ) );
275-
for( int i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
275+
for( size_t i=0 ; i<neighborKeys.size() ; i++ ) neighborKeys[i].set( depth );
276276
#pragma omp parallel for num_threads( threads )
277277
for( int i=span.first ; i<span.second ; i++ )
278278
{
@@ -335,8 +335,8 @@ void SortedTreeNodes::setXSliceTableData( XSliceTableData& sData , int depth , i
335335
}
336336
int eCount = 0 , fCount = 0;
337337

338-
for( int i=0 ; i<sData._eMap.size() ; i++ ) if( sData._eMap[i] ) sData._eMap[i] = eCount++;
339-
for( int i=0 ; i<sData._fMap.size() ; i++ ) if( sData._fMap[i] ) sData._fMap[i] = fCount++;
338+
for( size_t i=0 ; i<sData._eMap.size() ; i++ ) if( sData._eMap[i] ) sData._eMap[i] = eCount++;
339+
for( size_t i=0 ; i<sData._fMap.size() ; i++ ) if( sData._fMap[i] ) sData._fMap[i] = fCount++;
340340
#pragma omp parallel for num_threads( threads )
341341
for( int i=0 ; i<sData.nodeCount ; i++ )
342342
{

Src/MultiGridOctreeData.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ DAMAGE.
3030
#define MULTI_GRID_OCTREE_DATA_INCLUDED
3131

3232
#define NEW_CODE 1
33-
#define NEW_NEW_CODE 1
3433

3534
//#define MAX_MEMORY_GB 15
3635
#define MAX_MEMORY_GB 0
@@ -71,8 +70,6 @@ DAMAGE.
7170
#define FORCE_NEUMANN_FIELD 1 // This flag forces the normal component across the boundary of the integration domain to be zero.
7271
// This should be enabled if GRADIENT_DOMAIN_SOLUTION is not, so that CG doesn't run into trouble.
7372

74-
#define ROBERTO_TOLDO_FIX 1
75-
7673
#if !FORCE_NEUMANN_FIELD
7774
#pragma message( "[WARNING] Not zeroing out normal component on boundary" )
7875
#endif // !FORCE_NEUMANN_FIELD
@@ -216,16 +213,16 @@ class Octree
216213
struct PointData
217214
{
218215
Point3D< Real > position;
219-
Real weightedCoarserValue;
216+
Real weightedCoarserDValue;
220217
Real weight;
221-
PointData( Point3D< Real > p=Point3D< Real >() , Real w=0 ) { position = p , weight = w , weightedCoarserValue = Real(0); }
218+
PointData( Point3D< Real > p=Point3D< Real >() , Real w=0 ) { position = p , weight = w , weightedCoarserDValue = Real(0); }
222219
};
223220
template< class Data >
224221
struct SparseNodeData
225222
{
226223
std::vector< int > indices;
227224
std::vector< Data > data;
228-
int index( const TreeOctNode* node ) const { return node->nodeData.nodeIndex>=indices.size() ? -1 : indices[ node->nodeData.nodeIndex ]; }
225+
int index( const TreeOctNode* node ) const { return node->nodeData.nodeIndex>=(int)indices.size() ? -1 : indices[ node->nodeData.nodeIndex ]; }
229226
};
230227
protected:
231228
SortedTreeNodes _sNodes;
@@ -293,8 +290,8 @@ class Octree
293290
void SetPointValuesFromCoarser( SparseNodeData< PointData >& pointInfo , int depth , const SortedTreeNodes& sNodes , ConstPointer( Real ) coarseCoefficients );
294291
// Evalutes the solution @(depth) at the points @(depth-1) and updates the met constraints @(depth-1)
295292
void SetPointConstraintsFromFiner ( const SparseNodeData< PointData >& pointInfo , int depth , const SortedTreeNodes& sNodes , ConstPointer( Real ) finerCoefficients , Pointer( Real ) metConstraints ) const;
296-
Real _WeightedCoarserFunctionValue( const PointData& pointData , const typename TreeOctNode::NeighborKey3& neighborKey3 , const TreeOctNode* node , ConstPointer( Real ) coarseCoefficients ) const;
297-
Real _WeightedFinerFunctionValue ( const PointData& pointData , const typename TreeOctNode::NeighborKey3& neighborKey3 , const TreeOctNode* node , ConstPointer( Real ) finerCoefficients ) const;
293+
Real _CoarserFunctionValue( const PointData& pointData , const typename TreeOctNode::NeighborKey3& neighborKey3 , const TreeOctNode* node , ConstPointer( Real ) coarseCoefficients ) const;
294+
Real _FinerFunctionValue ( const PointData& pointData , const typename TreeOctNode::NeighborKey3& neighborKey3 , const TreeOctNode* node , ConstPointer( Real ) finerCoefficients ) const;
298295

299296
// Down samples constraints @(depth) to constraints @(depth-1)
300297
template< class C > void DownSample( int depth , const SortedTreeNodes& sNodes , ConstPointer( C ) fineConstraints , Pointer( C ) coarseConstraints ) const;

0 commit comments

Comments
 (0)