Commit 4792fc70 authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

Fixes

Fixes for gcc and intel compilers.
gcc-4.1 clean with -Wall -Wextra
intel 11.1 clean with -Wcheck -w1
msvc2010 gives one unrelated warning
parent b73dc746
...@@ -43,6 +43,9 @@ set(HEADER inmost.h ...@@ -43,6 +43,9 @@ set(HEADER inmost.h
add_library(inmost STATIC ${SOURCE} ${HEADER}) add_library(inmost STATIC ${SOURCE} ${HEADER})
option(USE_MPI "Compile with MPI support" ON) option(USE_MPI "Compile with MPI support" ON)
option(USE_MPI_P2P "Use MPI point to point functionality, may be faster with hardware support" ON)
option(USE_MPI_FILE "Use MPI extension to work with files, may save a lot of memory" ON)
option(USE_MPI2 "Use MPI-2 extensions, useful if your MPI library produces warnings to use new functions" ON)
option(USE_OMP "Compile with OpenMP support (experimental)" OFF) option(USE_OMP "Compile with OpenMP support (experimental)" OFF)
option(USE_MESH "Compile mesh capabilities" ON) option(USE_MESH "Compile mesh capabilities" ON)
...@@ -77,13 +80,11 @@ endif() ...@@ -77,13 +80,11 @@ endif()
if(USE_MPI) if(USE_MPI)
find_package(MPI) find_package(MPI)
if(NOT MPI_FOUND) if(NOT MPI_FOUND)
option(USE_MPI "Use Message Passing Interface" OFF) set(USE_MPI OFF)
option(USE_MPI2 "Use MPI-2 functions" OFF)
message("MPI NOT FOUND") message("MPI NOT FOUND")
else() else()
include_directories(${MPI_INCLUDE_PATH}) include_directories(${MPI_INCLUDE_PATH})
option(USE_MPI "Use Message Passing Interface" ON) set(USE_MPI ON)
option(USE_MPI2 "Use MPI-2 functions" ON)
set_target_properties(inmost PROPERTIES COMPILE_FLAGS "${MPI_COMPILE_FLAGS}") set_target_properties(inmost PROPERTIES COMPILE_FLAGS "${MPI_COMPILE_FLAGS}")
message("MPI FOUND") message("MPI FOUND")
endif() endif()
...@@ -95,18 +96,18 @@ if(USE_OMP) ...@@ -95,18 +96,18 @@ if(USE_OMP)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
else() else()
option(USE_OMP "Compile with OpenMP support (experimental)" OFF) set(USE_OMP OFF)
endif() endif()
endif() endif()
if(USE_PARTITIONER_PARMETIS) if(USE_PARTITIONER_PARMETIS)
find_package(ParMETIS) find_package(ParMETIS)
if(NOT PARMETIS_FOUND) if(NOT PARMETIS_FOUND)
option(USE_PARTITIONER_PARMETIS "Use ParMetis partitioner" OFF) set(USE_PARTITIONER_PARMETIS OFF)
message("PARMETIS NOT FOUND") message("PARMETIS NOT FOUND")
else() else()
include_directories(${PARMETIS_INCLUDE_DIR}) include_directories(${PARMETIS_INCLUDE_DIR})
option(USE_PARTITIONER_PARMETIS "Use ParMetis partitioner" ON) set(USE_PARTITIONER_PARMETIS ON)
message("PARMETIS FOUND") message("PARMETIS FOUND")
endif() endif()
endif() endif()
...@@ -115,11 +116,11 @@ endif() ...@@ -115,11 +116,11 @@ endif()
if(USE_PARTITIONER_ZOLTAN) if(USE_PARTITIONER_ZOLTAN)
find_package(ZOLTAN) find_package(ZOLTAN)
if(NOT ZOLTAN_FOUND) if(NOT ZOLTAN_FOUND)
option(USE_PARTITIONER_ZOLTAN "Use Zoltan partitioner" OFF) set(USE_PARTITIONER_ZOLTAN OFF)
message("ZOLTAN NOT FOUND") message("ZOLTAN NOT FOUND")
else() else()
include_directories(${ZOLTAN_INCLUDE_DIRS}) include_directories(${ZOLTAN_INCLUDE_DIRS})
option(USE_PARTITIONER_ZOLTAN "Use Zoltan partitioner" ON) set(USE_PARTITIONER_ZOLTAN ON)
message("ZOLTAN FOUND") message("ZOLTAN FOUND")
endif() endif()
endif() endif()
...@@ -127,11 +128,11 @@ endif() ...@@ -127,11 +128,11 @@ endif()
if(USE_SOLVER_PETSC) if(USE_SOLVER_PETSC)
find_package(PETSc) find_package(PETSc)
if(NOT PETSC_FOUND) if(NOT PETSC_FOUND)
option(USE_SOLVER_PETSC "Use PETSc solver" OFF) set(USE_SOLVER_PETSC OFF)
message("PETSC NOT FOUND") message("PETSC NOT FOUND")
else() else()
include_directories(${PETSC_INCLUDES}) include_directories(${PETSC_INCLUDES})
option(USE_SOLVER_PETSC "Use PETSc solver" ON) set(USE_SOLVER_PETSC ON)
message("PETSC FOUND") message("PETSC FOUND")
add_definitions(${PETSC_DEFINITIONS}) add_definitions(${PETSC_DEFINITIONS})
#message(${PETSC_LIBRARIES}) #message(${PETSC_LIBRARIES})
...@@ -142,16 +143,16 @@ endif() ...@@ -142,16 +143,16 @@ endif()
if(USE_AUTODIFF_OPENCL) if(USE_AUTODIFF_OPENCL)
find_package(OpenCL) find_package(OpenCL)
if(OPENCL_FOUND) if(OPENCL_FOUND)
option(USE_AUTODIFF_OPENCL "Use OpenCL for automatic differentiation" ON) set(USE_AUTODIFF_OPENCL ON)
include_directories(${OPENCL_INCLUDE_DIRS}) include_directories(${OPENCL_INCLUDE_DIRS})
else() else()
option(USE_AUTODIFF_OPENCL "Use OpenCL for automatic differentiation" OFF) set(USE_AUTODIFF_OPENCL OFF)
message("OpenCL not found") message("OpenCL not found")
endif() endif()
endif() endif()
if(USE_AUTODIFF_ASMJIT) if(USE_AUTODIFF_ASMJIT)
Set(ASMJIT_STATIC TRUE) set(ASMJIT_STATIC TRUE)
include("AsmJit/CMakeLists.txt") include("AsmJit/CMakeLists.txt")
include_directories("${ASMJIT_INC_DIR}/asmjit") include_directories("${ASMJIT_INC_DIR}/asmjit")
target_link_libraries(inmost asmjit) target_link_libraries(inmost asmjit)
......
...@@ -76,15 +76,10 @@ mesh + !partitioner + !domain + solvers + +/-nonlinear solvers + autodiff + !sys ...@@ -76,15 +76,10 @@ mesh + !partitioner + !domain + solvers + +/-nonlinear solvers + autodiff + !sys
23) , 23) ,
24) 24)
25) , 25) ,
30) - sort ReorderApply , chunk_array 30) - sort ReorderApply , chunk_array
ReorderApply radix-? ReorderApply radix-?
32) , , Cell, Face, Edge Node 32) , , Cell, Face, Edge Node
35) Bridge* 35) Bridge*
37) container.hpp, 37) container.hpp,
38) GatherBoundaryFaces/GatherInteriorFaces 38) GatherBoundaryFaces/GatherInteriorFaces
39) CastRay , 39) CastRay ,
...@@ -94,7 +89,6 @@ mesh + !partitioner + !domain + solvers + +/-nonlinear solvers + autodiff + !sys ...@@ -94,7 +89,6 @@ mesh + !partitioner + !domain + solvers + +/-nonlinear solvers + autodiff + !sys
45) ? 45) ?
. ( ) . ( )
47) , , ? 47) , , ?
49) - 49) -
...@@ -104,14 +98,15 @@ mesh + !partitioner + !domain + solvers + +/-nonlinear solvers + autodiff + !sys ...@@ -104,14 +98,15 @@ mesh + !partitioner + !domain + solvers + +/-nonlinear solvers + autodiff + !sys
52) , radix big-endian 52) , radix big-endian
53) SortByGlobalID, globalid 53) SortByGlobalID, globalid
54) ( unit tests) 54) ( unit tests)
55) mpi_send/mpi_recv -
7.MSPP: : , , 7.MSPP: () : , ,
8.MSPP: 8.MSPP:
9.MSPP: visual studio 9.MSPP: () visual studio
10.MSPP: ( ) 10.MSPP: ( )
11. 11. ()
12. (, ) 12. (, )
12. MSPP: Mesh 12. () MSPP: Mesh
13. MSPP: Redistribute!!! ExchangeGhost 13. MSPP: Redistribute!!! ExchangeGhost
13. INMOST / MMTK = Mathematical Modelling ToolKit / NSTK 13. INMOST / MMTK = Mathematical Modelling ToolKit / NSTK
......
...@@ -218,10 +218,10 @@ namespace INMOST ...@@ -218,10 +218,10 @@ namespace INMOST
switch (var.op) switch (var.op)
{ {
case AD_COND_TYPE: case AD_COND_TYPE:
lval = (e->GetElementType() & reinterpret_cast<ElementType>(var.left))? 1.0 : -1.0; lval = (e->GetElementType() & (*(ElementType*)&var.left))? 1.0 : -1.0;
return lval; return lval;
case AD_COND_MARK: case AD_COND_MARK:
lval = e->GetMarker(reinterpret_cast<MarkerType>(var.left))? 1.0 : -1.0; lval = e->GetMarker(*(MarkerType *)&var.left)? 1.0 : -1.0;
return lval; return lval;
case AD_COND: case AD_COND:
lval = Evaluate(*var.left, e, user_data); lval = Evaluate(*var.left, e, user_data);
...@@ -329,7 +329,7 @@ namespace INMOST ...@@ -329,7 +329,7 @@ namespace INMOST
{ {
stencil_pairs get_st; stencil_pairs get_st;
reinterpret_cast<stencil_callback>(st.link)(e, get_st, user_data); reinterpret_cast<stencil_callback>(st.link)(e, get_st, user_data);
for (INMOST_DATA_ENUM_TYPE k = 0; k < get_st.size(); ++k) if( get_st[k].first != NULL ) for (INMOST_DATA_ENUM_TYPE k = 0; k < get_st.size(); ++k) if( get_st[k].first != InvalidHandle() )
{ {
lval = DerivativePrecompute(*var.left, Storage(m,get_st[k].first), values, user_data); lval = DerivativePrecompute(*var.left, Storage(m,get_st[k].first), values, user_data);
ret += lval * get_st[k].second; ret += lval * get_st[k].second;
...@@ -454,7 +454,7 @@ namespace INMOST ...@@ -454,7 +454,7 @@ namespace INMOST
{ {
stencil_pairs get_st; stencil_pairs get_st;
reinterpret_cast<stencil_callback>(st.link)(e, get_st, user_data); reinterpret_cast<stencil_callback>(st.link)(e, get_st, user_data);
for (INMOST_DATA_ENUM_TYPE k = static_cast<INMOST_DATA_ENUM_TYPE>(get_st.size()); k > 0; --k) if( get_st[k-1].first != NULL ) for (INMOST_DATA_ENUM_TYPE k = static_cast<INMOST_DATA_ENUM_TYPE>(get_st.size()); k > 0; --k) if( get_st[k-1].first != InvalidHandle() )
DerivativeFill(*var.left, Storage(m,get_st[k - 1].first), entries, values, var.coef * get_st[k - 1].second*multval, user_data); DerivativeFill(*var.left, Storage(m,get_st[k - 1].first), entries, values, var.coef * get_st[k - 1].second*multval, user_data);
} }
return; return;
...@@ -477,8 +477,8 @@ namespace INMOST ...@@ -477,8 +477,8 @@ namespace INMOST
assert(var.op != AD_NONE); assert(var.op != AD_NONE);
switch (var.op) switch (var.op)
{ {
case AD_COND_MARK: return e->GetMarker(reinterpret_cast<MarkerType>(var.left)) ? 1.0 : -1.0; case AD_COND_MARK: return e->GetMarker(*(MarkerType *)&var.left) ? 1.0 : -1.0;
case AD_COND_TYPE: return (e->GetElementType() & reinterpret_cast<ElementType>(var.left)) ? 1.0 : -1.0; case AD_COND_TYPE: return (e->GetElementType() & (*(ElementType *)&var.left)) ? 1.0 : -1.0;
case AD_COND: return Evaluate(*(Evaluate(*var.left, e, user_data) > 0.0 ? var.right->left : var.right->right), e, user_data)*var.coef; case AD_COND: return Evaluate(*(Evaluate(*var.left, e, user_data) > 0.0 ? var.right->left : var.right->right), e, user_data)*var.coef;
case AD_PLUS: return (Evaluate(*var.left, e, user_data) + Evaluate(*var.right, e, user_data))*var.coef; case AD_PLUS: return (Evaluate(*var.left, e, user_data) + Evaluate(*var.right, e, user_data))*var.coef;
case AD_MINUS: return (Evaluate(*var.left, e, user_data) - Evaluate(*var.right, e, user_data))*var.coef; case AD_MINUS: return (Evaluate(*var.left, e, user_data) - Evaluate(*var.right, e, user_data))*var.coef;
...@@ -515,7 +515,7 @@ namespace INMOST ...@@ -515,7 +515,7 @@ namespace INMOST
{ {
stencil_pairs get_st; stencil_pairs get_st;
reinterpret_cast<stencil_callback>(st.link)(e, get_st, user_data); reinterpret_cast<stencil_callback>(st.link)(e, get_st, user_data);
for (INMOST_DATA_ENUM_TYPE k = 0; k < get_st.size(); ++k) if ( get_st[k].first != NULL ) for (INMOST_DATA_ENUM_TYPE k = 0; k < get_st.size(); ++k) if ( get_st[k].first != InvalidHandle() )
ret += var.coef * Evaluate(*var.left, Storage(m,get_st[k].first), user_data) * get_st[k].second; ret += var.coef * Evaluate(*var.left, Storage(m,get_st[k].first), user_data) * get_st[k].second;
} }
return ret; return ret;
......
...@@ -119,21 +119,21 @@ namespace INMOST ...@@ -119,21 +119,21 @@ namespace INMOST
MarkerType hm = m->HideMarker(); MarkerType hm = m->HideMarker();
if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 ) // This cell is 2d face if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 ) // This cell is 2d face
{ {
integer i = -1, k = -1, k1 = -1, k2; enumerator i = ENUMUNDEF, k = ENUMUNDEF, k1 = ENUMUNDEF, k2;
adj_type const & lc = m->LowConn(GetHandle()); adj_type const & lc = m->LowConn(GetHandle());
aret.reserve(lc.size()); aret.reserve(lc.size());
i = m->getNext(lc.data(),static_cast<integer>(lc.size()),i,hm); i = m->getNext(lc.data(),static_cast<enumerator>(lc.size()),i,hm);
HandleType q = lc[i]; //edge 0 HandleType q = lc[i]; //edge 0
adj_type const & qlc = m->LowConn(q); adj_type const & qlc = m->LowConn(q);
k = m->getNext(qlc.data(),static_cast<integer>(qlc.size()),k,hm); k = m->getNext(qlc.data(),static_cast<enumerator>(qlc.size()),k,hm);
aret.push_back(qlc[k]); //node 0 aret.push_back(qlc[k]); //node 0
k = m->getNext(qlc.data(),static_cast<integer>(qlc.size()),k,hm); k = m->getNext(qlc.data(),static_cast<enumerator>(qlc.size()),k,hm);
aret.push_back(qlc[k]); //node 1 aret.push_back(qlc[k]); //node 1
i = m->getNext(lc.data(),static_cast<integer>(lc.size()),i,hm); i = m->getNext(lc.data(),static_cast<enumerator>(lc.size()),i,hm);
HandleType r = lc[i]; //edge 1 HandleType r = lc[i]; //edge 1
adj_type const & rlc = m->LowConn(r); adj_type const & rlc = m->LowConn(r);
k1 = m->getNext(rlc.data(),static_cast<integer>(rlc.size()),k1,hm); k1 = m->getNext(rlc.data(),static_cast<enumerator>(rlc.size()),k1,hm);
k2 = m->getNext(rlc.data(),static_cast<integer>(rlc.size()),k1,hm); k2 = m->getNext(rlc.data(),static_cast<enumerator>(rlc.size()),k1,hm);
if( aret.data()[0] == rlc[k1] || aret.data()[0] == rlc[k2] ) if( aret.data()[0] == rlc[k1] || aret.data()[0] == rlc[k2] )
{ {
HandleType temp = aret.data()[0]; HandleType temp = aret.data()[0];
...@@ -144,9 +144,9 @@ namespace INMOST ...@@ -144,9 +144,9 @@ namespace INMOST
while(it < iend) if( !m->GetMarker(lc[it],hm) ) //loop over edges while(it < iend) if( !m->GetMarker(lc[it],hm) ) //loop over edges
{ {
adj_type const & ilc = m->LowConn(lc[it]); adj_type const & ilc = m->LowConn(lc[it]);
k1 = -1; k1 = ENUMUNDEF;
k1 = m->getNext(ilc.data(),static_cast<integer>(ilc.size()),k1,hm); k1 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
k2 = m->getNext(ilc.data(),static_cast<integer>(ilc.size()),k1,hm); k2 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
if( aret.atback() == ilc[k1] ) if( aret.atback() == ilc[k1] )
aret.push_back(ilc[k2]); aret.push_back(ilc[k2]);
else else
...@@ -242,24 +242,24 @@ namespace INMOST ...@@ -242,24 +242,24 @@ namespace INMOST
MarkerType hm = GetMeshLink()->HideMarker(); MarkerType hm = GetMeshLink()->HideMarker();
if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 ) // This cell is 2d face if( Element::GetGeometricDimension(m->GetGeometricType(GetHandle())) == 2 ) // This cell is 2d face
{ {
integer i = -1, k = -1, k1 = -1, k2; enumerator i = ENUMUNDEF, k = ENUMUNDEF, k1 = ENUMUNDEF, k2;
HandleType last, first; HandleType last, first;
adj_type const & lc = m->LowConn(GetHandle()); adj_type const & lc = m->LowConn(GetHandle());
aret.reserve(lc.size()); aret.reserve(lc.size());
i = m->getNext(lc.data(),static_cast<integer>(lc.size()),i,hm); i = m->getNext(lc.data(),static_cast<enumerator>(lc.size()),i,hm);
HandleType q = lc[i]; //edge 0 HandleType q = lc[i]; //edge 0
adj_type const & qlc = m->LowConn(q); adj_type const & qlc = m->LowConn(q);
k = m->getNext(qlc.data(),static_cast<integer>(qlc.size()),k,hm); k = m->getNext(qlc.data(),static_cast<enumerator>(qlc.size()),k,hm);
if( invert ^ m->GetMarker(qlc[k],mask) ) aret.push_back(qlc[k]); //node 0 if( invert ^ m->GetMarker(qlc[k],mask) ) aret.push_back(qlc[k]); //node 0
first = qlc[k]; first = qlc[k];
k = m->getNext(qlc.data(),static_cast<integer>(qlc.size()),k,hm); k = m->getNext(qlc.data(),static_cast<enumerator>(qlc.size()),k,hm);
if( invert ^ m->GetMarker(qlc[k],mask) ) aret.push_back(qlc[k]); //node 1 if( invert ^ m->GetMarker(qlc[k],mask) ) aret.push_back(qlc[k]); //node 1
last = qlc[k]; last = qlc[k];
i = m->getNext(lc.data(),static_cast<integer>(lc.size()),i,hm); i = m->getNext(lc.data(),static_cast<enumerator>(lc.size()),i,hm);
HandleType r = lc[i]; //edge 1 HandleType r = lc[i]; //edge 1
adj_type const & rlc = m->LowConn(r); adj_type const & rlc = m->LowConn(r);
k1 = m->getNext(rlc.data(),static_cast<integer>(rlc.size()),k1,hm); k1 = m->getNext(rlc.data(),static_cast<enumerator>(rlc.size()),k1,hm);
k2 = m->getNext(rlc.data(),static_cast<integer>(rlc.size()),k1,hm); k2 = m->getNext(rlc.data(),static_cast<enumerator>(rlc.size()),k1,hm);
if( first == rlc[k1] || first == rlc[k2] ) if( first == rlc[k1] || first == rlc[k2] )
{ {
last = first; last = first;
...@@ -274,9 +274,9 @@ namespace INMOST ...@@ -274,9 +274,9 @@ namespace INMOST
while(it != iend) if( !m->GetMarker(lc[it],hm) ) //loop over edges while(it != iend) if( !m->GetMarker(lc[it],hm) ) //loop over edges
{ {
adj_type const & ilc = m->LowConn(lc[it]); adj_type const & ilc = m->LowConn(lc[it]);
k1 = -1; k1 = ENUMUNDEF;
k1 = m->getNext(ilc.data(),static_cast<integer>(ilc.size()),k1,hm); k1 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
k2 = m->getNext(ilc.data(),static_cast<integer>(ilc.size()),k1,hm); k2 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
if( last == ilc[k1] ) if( last == ilc[k1] )
last = ilc[k2]; last = ilc[k2];
else last = ilc[k1]; else last = ilc[k1];
......
...@@ -258,4 +258,4 @@ namespace INMOST ...@@ -258,4 +258,4 @@ namespace INMOST
else std::sort(h,h+n); else std::sort(h,h+n);
} }
} }
#endif #endif
\ No newline at end of file
#pragma once
#ifndef _CONTAINER_HPP #ifndef _CONTAINER_HPP
#define _CONTAINER_HPP #define _CONTAINER_HPP
...@@ -665,7 +665,7 @@ namespace INMOST ...@@ -665,7 +665,7 @@ namespace INMOST
} }
void push_back(const element & e) void push_back(const element & e)
{ {
assert( !fixed && "array size is fixed"); assert( !fixed ); // array size is fixed
#if !defined(USE_OPTIMIZED_ARRAY_ALLOCATION) #if !defined(USE_OPTIMIZED_ARRAY_ALLOCATION)
//unoptimized variant //unoptimized variant
if( (*m_size)+1 > array<element>::growth_formula(*m_size) ) if( (*m_size)+1 > array<element>::growth_formula(*m_size) )
...@@ -684,7 +684,7 @@ namespace INMOST ...@@ -684,7 +684,7 @@ namespace INMOST
} }
void pop_back() void pop_back()
{ {
assert( !fixed && "array size is fixed"); assert( !fixed ); // array size is fixed
assert((*m_arr) != NULL); assert((*m_arr) != NULL);
(*m_arr)[(*m_size)--].~element(); (*m_arr)[(*m_size)--].~element();
if( (*m_size) > 0 ) if( (*m_size) > 0 )
...@@ -734,7 +734,7 @@ namespace INMOST ...@@ -734,7 +734,7 @@ namespace INMOST
__INLINE bool empty() const { if( *m_size ) return false; return true; } __INLINE bool empty() const { if( *m_size ) return false; return true; }
void resize(size_type n, element c = element() ) void resize(size_type n, element c = element() )
{ {
assert( !fixed && "array size is fixed"); assert( !fixed ); // array size is fixed
size_type oldsize = *m_size; size_type oldsize = *m_size;
*m_size = n; *m_size = n;
for(size_type i = *m_size; i < oldsize; i++) (*m_arr)[i].~element(); //delete elements, located over the size for(size_type i = *m_size; i < oldsize; i++) (*m_arr)[i].~element(); //delete elements, located over the size
...@@ -754,7 +754,7 @@ namespace INMOST ...@@ -754,7 +754,7 @@ namespace INMOST
__INLINE size_type size() const {return *m_size;} __INLINE size_type size() const {return *m_size;}
void clear() void clear()
{ {
assert( !fixed && "array size is fixed"); assert( !fixed ); // array size is fixed
for(size_type i = 0; i < *m_size; i++) (*m_arr)[i].~element(); for(size_type i = 0; i < *m_size; i++) (*m_arr)[i].~element();
*m_size = 0; *m_size = 0;
if( *m_arr ) free(*m_arr); if( *m_arr ) free(*m_arr);
...@@ -779,7 +779,7 @@ namespace INMOST ...@@ -779,7 +779,7 @@ namespace INMOST
__INLINE const_reverse_iterator rend() const { return const_reverse_iterator(*m_arr-1); } __INLINE const_reverse_iterator rend() const { return const_reverse_iterator(*m_arr-1); }
iterator erase(iterator pos) iterator erase(iterator pos)
{ {
assert( !fixed && "array size is fixed"); assert( !fixed ); // array size is fixed
ptrdiff_t d = pos-begin(); ptrdiff_t d = pos-begin();
ptrdiff_t s = iterator(*m_arr+(*m_size)-1)-pos; ptrdiff_t s = iterator(*m_arr+(*m_size)-1)-pos;
(*pos).~element(); (*pos).~element();
...@@ -806,7 +806,7 @@ namespace INMOST ...@@ -806,7 +806,7 @@ namespace INMOST
} }
iterator erase(iterator b, iterator e) iterator erase(iterator b, iterator e)
{ {
assert( !fixed && "array size is fixed"); assert( !fixed ); // array size is fixed
ptrdiff_t d = b-begin(); ptrdiff_t d = b-begin();
ptrdiff_t s = end()-e; ptrdiff_t s = end()-e;
ptrdiff_t n = e-b; ptrdiff_t n = e-b;
...@@ -829,7 +829,7 @@ namespace INMOST ...@@ -829,7 +829,7 @@ namespace INMOST
} }
iterator insert(iterator pos, const element & x) iterator insert(iterator pos, const element & x)
{ {
assert( !fixed && "array size is fixed"); assert( !fixed ); // array size is fixed
if( static_cast<void *>(pos) == NULL ) if( static_cast<void *>(pos) == NULL )
{ {
assert((*m_arr) == NULL); assert((*m_arr) == NULL);
...@@ -859,7 +859,7 @@ namespace INMOST ...@@ -859,7 +859,7 @@ namespace INMOST
} }
void insert(iterator pos, size_type n, const element & x) void insert(iterator pos, size_type n, const element & x)
{ {
assert( !fixed && "array size is fixed"); assert( !fixed ); // array size is fixed
if( n > 0 ) if( n > 0 )
{ {
if( static_cast<void *>(pos) == NULL) if( static_cast<void *>(pos) == NULL)
...@@ -883,7 +883,7 @@ namespace INMOST ...@@ -883,7 +883,7 @@ namespace INMOST
template <class InputIterator> template <class InputIterator>
void insert(iterator pos, InputIterator first, InputIterator last) void insert(iterator pos, InputIterator first, InputIterator last)
{ {
assert( !fixed && "array size is fixed"); assert( !fixed ); // array size is fixed
ptrdiff_t n = static_cast<ptrdiff_t>(std::distance(first,last)); ptrdiff_t n = static_cast<ptrdiff_t>(std::distance(first,last));
if( n > 0 ) if( n > 0 )
{ {
...@@ -926,7 +926,7 @@ namespace INMOST ...@@ -926,7 +926,7 @@ namespace INMOST
for(iterator it = m_first; it != m_last; it++) (*it).~element(); for(iterator it = m_first; it != m_last; it++) (*it).~element();
if( n-q != 0 ) if( n-q != 0 )
{ {
assert( !fixed && "array size is fixed"); assert( !fixed ); // array size is fixed
size_type gf = array<element>::growth_formula((*m_size)+static_cast<size_type>(n-q)); size_type gf = array<element>::growth_formula((*m_size)+static_cast<size_type>(n-q));
if( gf != array<element>::growth_formula(*m_size) ) if( gf != array<element>::growth_formula(*m_size) )
*m_arr = static_cast<element *>(realloc(*m_arr,sizeof(element)*gf)); *m_arr = static_cast<element *>(realloc(*m_arr,sizeof(element)*gf));
......
This diff is collapsed.
...@@ -5,12 +5,10 @@ namespace INMOST ...@@ -5,12 +5,10 @@ namespace INMOST
template<typename StorageType> template<typename StorageType>
void ElementArray<StorageType>::Unite(const HandleType * h, INMOST_DATA_ENUM_TYPE num) void ElementArray<StorageType>::Unite(const HandleType * h, INMOST_DATA_ENUM_TYPE num)
{ {
assert(GetMeshLink() == other.GetMeshLink());
if( empty() ) container.insert(container.end(),h,h+num); if( empty() ) container.insert(container.end(),h,h+num);
else else
{ {
Mesh * m = GetMeshLink(); Mesh * m = GetMeshLink();
size_type s = size();
MarkerType mrk = m->CreateMarker(); MarkerType mrk = m->CreateMarker();
SetMarker(mrk); SetMarker(mrk);
for(INMOST_DATA_ENUM_TYPE it = 0; it < num; it++) for(INMOST_DATA_ENUM_TYPE it = 0; it < num; it++)
...@@ -27,7 +25,6 @@ namespace INMOST ...@@ -27,7 +25,6 @@ namespace INMOST
template<typename StorageType> template<typename StorageType>
void ElementArray<StorageType>::Subtract(const HandleType * h, INMOST_DATA_ENUM_TYPE num) void ElementArray<StorageType>::Subtract(const HandleType * h, INMOST_DATA_ENUM_TYPE num)
{ {
assert(GetMeshLink() == other.GetMeshLink());
if( !empty() ) if( !empty() )
{ {
Mesh * mesh = GetMeshLink(); Mesh * mesh = GetMeshLink();
...@@ -96,4 +93,4 @@ namespace INMOST ...@@ -96,4 +93,4 @@ namespace INMOST
template class ElementArray<Cell>; template class ElementArray<Cell>;
template class ElementArray<Storage>; template class ElementArray<Storage>;
} }
#endif #endif
\ No newline at end of file