diff --git a/include/IntegrationTools/datastruc/Bin.hh b/include/IntegrationTools/datastruc/Bin.hh index 1600bb4..a0c76c4 100644 --- a/include/IntegrationTools/datastruc/Bin.hh +++ b/include/IntegrationTools/datastruc/Bin.hh @@ -45,7 +45,7 @@ namespace PRISMS _incr = incr; _N = N; _max = std::vector(_min.size()); - for( int i=0; i<_min.size(); i++) + for( unsigned int i=0; i<_min.size(); i++) _max[i] = _min[i] + _incr[i]*_N[i]; _indices = _N; _item.resize(_N); @@ -160,7 +160,7 @@ namespace PRISMS // maximum size of any bin int max_size() { - int max = 0; + unsigned int max = 0; for( int i=0; i<_item.volume(); i++) if( _item(i).size() > max) max = _item(i).size(); @@ -224,4 +224,4 @@ namespace PRISMS } -#endif \ No newline at end of file +#endif diff --git a/include/IntegrationTools/datastruc/PNDArray.hh b/include/IntegrationTools/datastruc/PNDArray.hh index 0600c3e..9efc619 100644 --- a/include/IntegrationTools/datastruc/PNDArray.hh +++ b/include/IntegrationTools/datastruc/PNDArray.hh @@ -110,7 +110,7 @@ namespace PRISMS int linear_index( const IndexContainer &term) const { int lindex = 0; - for( int i=0; i<_unroll.size(); i++) + for( unsigned int i=0; i<_unroll.size(); i++) lindex += term[i]*_unroll[i]; return lindex; } @@ -138,7 +138,7 @@ namespace PRISMS } int vol = 1; - for( int i=0; i class Body { public: - + Mesh mesh; - + std::vector< PField > scalar_field; - + //std::vector< PField, DIM > > vector_field; - + //std::vector< PField, DIM > > tensor_field; - - + + // ---------------------------------------------------------- // Constructors - Body(){}; - + Body(){}; + /// Read from a 2D vtk file /// For now: /// only ASCII files @@ -41,24 +41,24 @@ namespace PRISMS void read_vtk( const std::string &vtkfile) { std::cout << "Begin reading vtk file" << std::endl; - - + + // read in vtk file here std::ifstream infile(vtkfile.c_str()); - + // read mesh info mesh.read_vtk(infile); - + // read point data std::istringstream ss; std::string str, name, type, line; int numcomp; unsigned long int Npoints; - + while(!infile.eof()) { std::getline( infile, line); - + if( line[0] == 'P') { if( line.size() > 9 && line.substr(0,10) == "POINT_DATA") @@ -67,7 +67,7 @@ namespace PRISMS ss.clear(); ss.str(line); ss >> str >> Npoints; - + } } else if( line[0] == 'S') @@ -77,54 +77,107 @@ namespace PRISMS ss.clear(); ss.str(line); ss >> str >> name >> type >> numcomp; - + + // read LOOKUP_TABLE line + std::getline( infile, line); + + // read data + std::cout << "begin reading data" << std::endl; + std::vector data(Npoints); + for( unsigned int i=0; i> data[i]; + } + std::cout << " done" << std::endl; + + + // construct field + std::vector var_name(DIM); + std::vector var_description(DIM); + + if( DIM >= 2) + { + var_name[0] = "x"; + var_description[0] = "x coordinate"; + var_name[1] = "y"; + var_description[1] = "y coordinate"; + + } + if( DIM >= 3) + { + var_name[2] = "z"; + var_description[2] = "z coordinate"; + + } + + + std::cout << "Construct PField '" << name << "'" << std::endl; + scalar_field.push_back( PField( name, var_name, var_description, mesh, data, 0.0) ); + std::cout << " done" << std::endl; + + } + } + // Alternative field descriptor used by ParaView (holds the same information as the "SCALAR" line above) + else if( line[0] == 'F') + { + if( line.size() > 14 && line.substr(0,15) == "FIELD FieldData") + { + ss.clear(); + ss.str(line); + ss >> str >> numcomp; + // read LOOKUP_TABLE line std::getline( infile, line); - + + ss.clear(); + ss.str(line); + ss >> name >> numcomp >> Npoints >> type; + + // read data std::cout << "begin reading data" << std::endl; std::vector data(Npoints); - for( int i=0; i> data[i]; } std::cout << " done" << std::endl; - - + + // construct field std::vector var_name(DIM); std::vector var_description(DIM); - + if( DIM >= 2) { var_name[0] = "x"; var_description[0] = "x coordinate"; var_name[1] = "y"; var_description[1] = "y coordinate"; - + } if( DIM >= 3) { var_name[2] = "z"; var_description[2] = "z coordinate"; - + } - - + + std::cout << "Construct PField '" << name << "'" << std::endl; scalar_field.push_back( PField( name, var_name, var_description, mesh, data, 0.0) ); std::cout << " done" << std::endl; - + } } } - + infile.close(); } - + PField& find_scalar_field(std::string name) { - for( int i=0; i> uli_dummy; cell_node.resize(uli_dummy); - for( int j=0; j> cell_node[j]; } @@ -327,7 +327,7 @@ namespace PRISMS // bin interpolators std::cout << "Bin interpolating functions" << std::endl; - for( int i=0; i<_interp.size(); i++) + for( unsigned int i=0; i<_interp.size(); i++) { _bin.add_range(_interp[i], _interp[i]->min(), _interp[i]->max()); } @@ -344,7 +344,7 @@ namespace PRISMS //std::cout << "ss.str()" << ss.str() << std::endl; ss >> str >> Ncells; - for( int i=0; i> uli_dummy; @@ -519,7 +519,7 @@ namespace PRISMS { //std::cout << "begin add_once()" << std::endl; - for( int i=0; i