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
add_library(inmost STATIC ${SOURCE} ${HEADER})
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_MESH "Compile mesh capabilities" ON)
......@@ -77,13 +80,11 @@ endif()
if(USE_MPI)
find_package(MPI)
if(NOT MPI_FOUND)
option(USE_MPI "Use Message Passing Interface" OFF)
option(USE_MPI2 "Use MPI-2 functions" OFF)
set(USE_MPI OFF)
message("MPI NOT FOUND")
else()
include_directories(${MPI_INCLUDE_PATH})
option(USE_MPI "Use Message Passing Interface" ON)
option(USE_MPI2 "Use MPI-2 functions" ON)
set(USE_MPI ON)
set_target_properties(inmost PROPERTIES COMPILE_FLAGS "${MPI_COMPILE_FLAGS}")
message("MPI FOUND")
endif()
......@@ -95,18 +96,18 @@ if(USE_OMP)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
else()
option(USE_OMP "Compile with OpenMP support (experimental)" OFF)
set(USE_OMP OFF)
endif()
endif()
if(USE_PARTITIONER_PARMETIS)
find_package(ParMETIS)
if(NOT PARMETIS_FOUND)
option(USE_PARTITIONER_PARMETIS "Use ParMetis partitioner" OFF)
set(USE_PARTITIONER_PARMETIS OFF)
message("PARMETIS NOT FOUND")
else()
include_directories(${PARMETIS_INCLUDE_DIR})
option(USE_PARTITIONER_PARMETIS "Use ParMetis partitioner" ON)
set(USE_PARTITIONER_PARMETIS ON)
message("PARMETIS FOUND")
endif()
endif()
......@@ -115,11 +116,11 @@ endif()
if(USE_PARTITIONER_ZOLTAN)
find_package(ZOLTAN)
if(NOT ZOLTAN_FOUND)
option(USE_PARTITIONER_ZOLTAN "Use Zoltan partitioner" OFF)
set(USE_PARTITIONER_ZOLTAN OFF)
message("ZOLTAN NOT FOUND")
else()
include_directories(${ZOLTAN_INCLUDE_DIRS})
option(USE_PARTITIONER_ZOLTAN "Use Zoltan partitioner" ON)
set(USE_PARTITIONER_ZOLTAN ON)
message("ZOLTAN FOUND")
endif()
endif()
......@@ -127,11 +128,11 @@ endif()
if(USE_SOLVER_PETSC)
find_package(PETSc)
if(NOT PETSC_FOUND)
option(USE_SOLVER_PETSC "Use PETSc solver" OFF)
set(USE_SOLVER_PETSC OFF)
message("PETSC NOT FOUND")
else()
include_directories(${PETSC_INCLUDES})
option(USE_SOLVER_PETSC "Use PETSc solver" ON)
set(USE_SOLVER_PETSC ON)
message("PETSC FOUND")
add_definitions(${PETSC_DEFINITIONS})
#message(${PETSC_LIBRARIES})
......@@ -142,16 +143,16 @@ endif()
if(USE_AUTODIFF_OPENCL)
find_package(OpenCL)
if(OPENCL_FOUND)
option(USE_AUTODIFF_OPENCL "Use OpenCL for automatic differentiation" ON)
set(USE_AUTODIFF_OPENCL ON)
include_directories(${OPENCL_INCLUDE_DIRS})
else()
option(USE_AUTODIFF_OPENCL "Use OpenCL for automatic differentiation" OFF)
set(USE_AUTODIFF_OPENCL OFF)
message("OpenCL not found")
endif()
endif()
if(USE_AUTODIFF_ASMJIT)
Set(ASMJIT_STATIC TRUE)
set(ASMJIT_STATIC TRUE)
include("AsmJit/CMakeLists.txt")
include_directories("${ASMJIT_INC_DIR}/asmjit")
target_link_libraries(inmost asmjit)
......
......@@ -76,15 +76,10 @@ mesh + !partitioner + !domain + solvers + +/-nonlinear solvers + autodiff + !sys
23) ,
24)
25) ,
30) - sort ReorderApply , chunk_array
ReorderApply radix-?
32) , , Cell, Face, Edge Node
35) Bridge*
37) container.hpp,
38) GatherBoundaryFaces/GatherInteriorFaces
39) CastRay ,
......@@ -94,7 +89,6 @@ mesh + !partitioner + !domain + solvers + +/-nonlinear solvers + autodiff + !sys
45) ?
. ( )
47) , , ?
49) -
......@@ -104,14 +98,15 @@ mesh + !partitioner + !domain + solvers + +/-nonlinear solvers + autodiff + !sys
52) , radix big-endian
53) SortByGlobalID, globalid
54) ( unit tests)
55) mpi_send/mpi_recv -
7.MSPP: : , ,
7.MSPP: () : , ,
8.MSPP:
9.MSPP: visual studio
9.MSPP: () visual studio
10.MSPP: ( )
11.
11. ()
12. (, )
12. MSPP: Mesh
12. () MSPP: Mesh
13. MSPP: Redistribute!!! ExchangeGhost
13. INMOST / MMTK = Mathematical Modelling ToolKit / NSTK
......
......@@ -218,10 +218,10 @@ namespace INMOST
switch (var.op)
{
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;
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;
case AD_COND:
lval = Evaluate(*var.left, e, user_data);
......@@ -329,7 +329,7 @@ namespace INMOST
{
stencil_pairs get_st;
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);
ret += lval * get_st[k].second;
......@@ -454,7 +454,7 @@ namespace INMOST
{
stencil_pairs get_st;
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);
}
return;
......@@ -477,8 +477,8 @@ namespace INMOST
assert(var.op != AD_NONE);
switch (var.op)
{
case AD_COND_MARK: return e->GetMarker(reinterpret_cast<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_MARK: return e->GetMarker(*(MarkerType *)&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_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;
......@@ -515,7 +515,7 @@ namespace INMOST
{
stencil_pairs get_st;
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;
}
return ret;
......
......@@ -119,21 +119,21 @@ namespace INMOST
MarkerType hm = m->HideMarker();
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());
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
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
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
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
adj_type const & rlc = m->LowConn(r);
k1 = m->getNext(rlc.data(),static_cast<integer>(rlc.size()),k1,hm);
k2 = 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<enumerator>(rlc.size()),k1,hm);
if( aret.data()[0] == rlc[k1] || aret.data()[0] == rlc[k2] )
{
HandleType temp = aret.data()[0];
......@@ -144,9 +144,9 @@ namespace INMOST
while(it < iend) if( !m->GetMarker(lc[it],hm) ) //loop over edges
{
adj_type const & ilc = m->LowConn(lc[it]);
k1 = -1;
k1 = m->getNext(ilc.data(),static_cast<integer>(ilc.size()),k1,hm);
k2 = m->getNext(ilc.data(),static_cast<integer>(ilc.size()),k1,hm);
k1 = ENUMUNDEF;
k1 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
k2 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
if( aret.atback() == ilc[k1] )
aret.push_back(ilc[k2]);
else
......@@ -242,24 +242,24 @@ namespace INMOST
MarkerType hm = GetMeshLink()->HideMarker();
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;
adj_type const & lc = m->LowConn(GetHandle());
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
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
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
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
adj_type const & rlc = m->LowConn(r);
k1 = m->getNext(rlc.data(),static_cast<integer>(rlc.size()),k1,hm);
k2 = 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<enumerator>(rlc.size()),k1,hm);
if( first == rlc[k1] || first == rlc[k2] )
{
last = first;
......@@ -274,9 +274,9 @@ namespace INMOST
while(it != iend) if( !m->GetMarker(lc[it],hm) ) //loop over edges
{
adj_type const & ilc = m->LowConn(lc[it]);
k1 = -1;
k1 = m->getNext(ilc.data(),static_cast<integer>(ilc.size()),k1,hm);
k2 = m->getNext(ilc.data(),static_cast<integer>(ilc.size()),k1,hm);
k1 = ENUMUNDEF;
k1 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
k2 = m->getNext(ilc.data(),static_cast<enumerator>(ilc.size()),k1,hm);
if( last == ilc[k1] )
last = ilc[k2];
else last = ilc[k1];
......
......@@ -258,4 +258,4 @@ namespace INMOST
else std::sort(h,h+n);
}
}
#endif
\ No newline at end of file
#endif
#pragma once
#ifndef _CONTAINER_HPP
#define _CONTAINER_HPP
......@@ -665,7 +665,7 @@ namespace INMOST
}
void push_back(const element & e)
{
assert( !fixed && "array size is fixed");
assert( !fixed ); // array size is fixed
#if !defined(USE_OPTIMIZED_ARRAY_ALLOCATION)
//unoptimized variant
if( (*m_size)+1 > array<element>::growth_formula(*m_size) )
......@@ -684,7 +684,7 @@ namespace INMOST
}
void pop_back()
{
assert( !fixed && "array size is fixed");
assert( !fixed ); // array size is fixed
assert((*m_arr) != NULL);
(*m_arr)[(*m_size)--].~element();
if( (*m_size) > 0 )
......@@ -734,7 +734,7 @@ namespace INMOST
__INLINE bool empty() const { if( *m_size ) return false; return true; }
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;
*m_size = n;
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
__INLINE size_type size() const {return *m_size;}
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();
*m_size = 0;
if( *m_arr ) free(*m_arr);
......@@ -779,7 +779,7 @@ namespace INMOST
__INLINE const_reverse_iterator rend() const { return const_reverse_iterator(*m_arr-1); }
iterator erase(iterator pos)
{
assert( !fixed && "array size is fixed");
assert( !fixed ); // array size is fixed
ptrdiff_t d = pos-begin();
ptrdiff_t s = iterator(*m_arr+(*m_size)-1)-pos;
(*pos).~element();
......@@ -806,7 +806,7 @@ namespace INMOST
}
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 s = end()-e;
ptrdiff_t n = e-b;
......@@ -829,7 +829,7 @@ namespace INMOST
}
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 )
{
assert((*m_arr) == NULL);
......@@ -859,7 +859,7 @@ namespace INMOST
}
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( static_cast<void *>(pos) == NULL)
......@@ -883,7 +883,7 @@ namespace INMOST
template <class InputIterator>
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));
if( n > 0 )
{
......@@ -926,7 +926,7 @@ namespace INMOST
for(iterator it = m_first; it != m_last; it++) (*it).~element();
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));
if( gf != array<element>::growth_formula(*m_size) )
*m_arr = static_cast<element *>(realloc(*m_arr,sizeof(element)*gf));
......
#include "dlg.h"
#include <string>
#include <fstream>
#include <iomanip>
#include <time.h>
#if defined(_WIN32)
#include <direct.h>
#else
#include <unistd.h>
#endif
#include <dirent.h> //for win32 - download from http://softagalleria.net/download/dirent/?C=M;O=D
const bool nmpfa_special = false;
using namespace INMOST;
INMOST_DATA_ENUM_TYPE wnum = 0;
void get_well_func(Storage * current_element, Automatizator::stencil_pairs & out_stencil,void * user_data)
{
out_stencil.push_back(Automatizator::stencil_pair(((wells *)user_data)->GetWellElements(wnum),1.0));
}
void add_row(Solver::Row & Ar, Solver::Row & r, Storage::real mult)
{
for(Solver::Row::iterator it = r.Begin(); it != r.End(); ++it) if( fabs(it->second) > 0.0 )
{
Ar[it->first] += mult*it->second;
}
}
const int name_width = 26;
const int type_width = 14;
const int elems_width = 10;
const int sparse_width = 10;
const int length_width = 10;
void PrintTag(Tag t)
{
std::cout << std::setw(name_width) << t.GetTagName() << std::setw(type_width) << DataTypeName(t.GetDataType());
int num = 0;
char elems[7] = "NEFCSM";
std::string print = "";
for(ElementType etype = NODE; etype <= MESH; etype = etype << 1)
{
if( t.isDefined(etype) )
{
print = print + elems[ElementNum(etype)];
num++;
}
}
std::cout << std::setw(elems_width) << print;
print = "";
for(ElementType etype = NODE; etype <= MESH; etype = etype << 1)
{
if( t.isSparse(etype) )
{
print = print + elems[ElementNum(etype)];
num++;
}
}
std::cout << std::setw(sparse_width) << print;
if( t.GetSize() == ENUMUNDEF )
std::cout << std::setw(length_width) << "VAR" << std::endl;
else
std::cout << std::setw(length_width) << t.GetSize() << std::endl;
}
void PrintTags(Mesh * m, ElementType etypes = MESH|ESET|CELL|FACE|EDGE|NODE)
{
std::cout << std::setw(name_width) << "Name" << std::setw(type_width) << "Type" << std::setw(elems_width) << "Element" << std::setw(sparse_width) << "Sparse" << std::setw(length_width) << "Length" << std::endl;
for(Mesh::iteratorTag t = m->BeginTag(); t != m->EndTag(); ++t )
{
bool print = false;
for(ElementType etype = NODE; etype <= MESH; etype = etype << 1) if( (etype&etypes) && t->isDefined(etype) ) {print = true; break;}
if( print ) PrintTag(*t);
}
}
void PrintRealTags(Mesh * m, ElementType etypes = MESH|ESET|CELL|FACE|EDGE|NODE)
{
std::cout << std::setw(name_width) << "Name" << std::setw(type_width) << "Type" << std::setw(elems_width) << "Element" << std::setw(sparse_width) << "Sparse" << std::setw(length_width) << "Length" << std::endl;
for(Mesh::iteratorTag t = m->BeginTag(); t != m->EndTag(); ++t ) if( t->GetDataType() == DATA_REAL )
{
bool print = false;
for(ElementType etype = NODE; etype <= MESH; etype = etype << 1) if( (etype&etypes) && t->isDefined(etype) ) {print = true; break;}
if( print ) PrintTag(*t);
}
}
void PrintNumericTags(Mesh * m, ElementType etypes = MESH|ESET|CELL|FACE|EDGE|NODE)
{
std::cout << std::setw(name_width) << "Name" << std::setw(type_width) << "Type" << std::setw(elems_width) << "Element" << std::setw(sparse_width) << "Sparse" << std::setw(length_width) << "Length" << std::endl;
for(Mesh::iteratorTag t = m->BeginTag(); t != m->EndTag(); ++t ) if( t->GetDataType() != DATA_REFERENCE )
{
bool print = false;
for(ElementType etype = NODE; etype <= MESH; etype = etype << 1) if( (etype&etypes) && t->isDefined(etype) ) {print = true; break;}
if( print ) PrintTag(*t);
}
}
std::string stolower(const std::string & input)
{
std::string ret(input);
for(size_t k = 0; k < ret.size(); k++) ret[k] = tolower(ret[k]);
return ret;
}
bool question_yesno()
{
while(true)
{
std::string ans;
std::cin >> ans;
std::string lans = stolower(ans);
if( lans == "yes" || lans == "y" )
return true;
else if ( lans == "no" || lans == "n")
return false;
else
{
std::cout << "I don't understand " << ans << "." << std::endl;
std::cout << "Please enter \"yes\" or \"no\" again." << std::endl;
}
}
}
int question_keyword(const std::string keywords[], const int N)
{
while(true)
{
std::string ans;
std::cin >> ans;
std::string lans = stolower(ans);
for(int k = 0; k < N; k++)
{
std::string lkeyword = stolower(keywords[k]);
if( lans == lkeyword )
return k;
}
std::cout << "I don't understand " << ans << "." << std::endl;
std::cout << "Please enter one of:" << std::endl;
for(int k = 0; k < N; k++)
std::cout << keywords[k] << ", ";
std::cout << std::endl;
}
}
void _list_directory(const char *dirname)
{
DIR *dir;
struct dirent *ent;
dir = opendir (dirname);
if (dir != NULL)
{
const size_t maxw = 24, maxl = 86;
size_t line = 0, width, recs;
while ((ent = readdir (dir)) != NULL)
{
width = strlen(ent->d_name);
switch (ent->d_type)
{
case DT_DIR: width+=2; break;
default: width = 0;
}
recs = ceil(width/(maxw*1.0));
if( line+recs*maxw > maxl )
{
std::cout << std::endl;
line = 0;
}
line += recs*maxw;
switch (ent->d_type)
{
case DT_DIR: std::cout << std::setw(maxw*recs) << (std::string(ent->d_name)+"/"); break;
}
}
rewinddir(dir);
std::string formats[6]= {".vtk",".pvtk",".msh",".grid",".grdecl",".pmf"};
while ((ent = readdir (dir)) != NULL)
{
std::string fname(ent->d_name);
for(size_t k = 0; k < fname.size(); k++) fname[k] = tolower(fname[k]);
bool print = false;
for(size_t k = 0; k < 6; k++)
{
if( fname.find(formats[k]) != std::string::npos )
{
print = true;
break;
}
}
if( !print ) continue;
width = strlen(ent->d_name);
switch (ent->d_type)
{
case DT_DIR: width = 0; break;
case DT_REG: width++; break;
case DT_LNK: width+=2; break;
default: width+=2;
}
recs = ceil(width/(maxw*1.0));
if( line+recs*maxw > maxl )
{
std::cout << std::endl;
line = 0;
}
line += recs*maxw;
switch (ent->d_type)
{
case DT_DIR: break;
case DT_REG: std::cout << std::setw(recs*maxw) << ent->d_name; break;