Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions include/IntegrationTools/datastruc/Bin.hh
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace PRISMS
_incr = incr;
_N = N;
_max = std::vector<double>(_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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -224,4 +224,4 @@ namespace PRISMS
}


#endif
#endif
6 changes: 3 additions & 3 deletions include/IntegrationTools/datastruc/PNDArray.hh
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -138,7 +138,7 @@ namespace PRISMS
}

int vol = 1;
for( int i=0; i<dim.size(); i++)
for( unsigned int i=0; i<dim.size(); i++)
{
vol *= dim[i];
}
Expand All @@ -157,4 +157,4 @@ namespace PRISMS
}


#endif
#endif
115 changes: 84 additions & 31 deletions include/IntegrationTools/pfield/Body.hh
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,27 @@

namespace PRISMS
{

/// A class for a Body: a combination of Mesh and Field(s))
///
template< class Coordinate, int DIM>
class Body
{
public:

Mesh<Coordinate, DIM> mesh;

std::vector< PField<Coordinate, double, DIM> > scalar_field;

//std::vector< PField<Coordinate, std::vector<double>, DIM > > vector_field;

//std::vector< PField<Coordinate, Tensor<double>, DIM > > tensor_field;


// ----------------------------------------------------------
// Constructors
Body(){};
Body(){};

/// Read from a 2D vtk file
/// For now:
/// only ASCII files
Expand All @@ -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")
Expand All @@ -67,7 +67,7 @@ namespace PRISMS
ss.clear();
ss.str(line);
ss >> str >> Npoints;

}
}
else if( line[0] == 'S')
Expand All @@ -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<double> data(Npoints);
for( unsigned int i=0; i<Npoints; i++)
{
infile >> data[i];
}
std::cout << " done" << std::endl;


// construct field
std::vector<std::string> var_name(DIM);
std::vector<std::string> 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<Coordinate, double, DIM>( 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<double> data(Npoints);
for( int i=0; i<Npoints; i++)
for( unsigned int i=0; i<Npoints; i++)
{
infile >> data[i];
}
std::cout << " done" << std::endl;


// construct field
std::vector<std::string> var_name(DIM);
std::vector<std::string> 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<Coordinate, double, DIM>( name, var_name, var_description, mesh, data, 0.0) );
std::cout << " done" << std::endl;

}
}
}

infile.close();
}

PField<Coordinate, double, DIM>& find_scalar_field(std::string name)
{
for( int i=0; i<scalar_field.size(); i++)
for( unsigned int i=0; i<scalar_field.size(); i++)
{
if( scalar_field[i].name() == name)
return scalar_field[i];
Expand All @@ -135,4 +188,4 @@ namespace PRISMS
}


#endif
#endif
20 changes: 10 additions & 10 deletions include/IntegrationTools/pfield/Mesh.hh
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,12 @@ namespace PRISMS

~Mesh()
{
for( int i=0; i<_interp.size(); i++)
for( unsigned int i=0; i<_interp.size(); i++)
{
delete _interp[i];
}

for( int i=0; i<_bfunc.size(); i++)
for( unsigned int i=0; i<_bfunc.size(); i++)
{
delete _bfunc[i];
}
Expand Down Expand Up @@ -197,7 +197,7 @@ namespace PRISMS
std::cout << "Read POINTS: " << Npoints << std::endl;
_node.reserve(Npoints);
std::cout << " reserve OK" << std::endl;
for( int i=0; i<Npoints; i++)
for( unsigned int i=0; i<Npoints; i++)
{
if( DIM == 2)
{
Expand All @@ -224,7 +224,7 @@ namespace PRISMS
std::cout << "Determine Body size" << std::endl;
for( int j=0; j<DIM; j++)
{
for( int i=1; i<hist[j].size(); i++)
for( unsigned int i=1; i<hist[j].size(); i++)
{
/*if( hist[j][i] != hist[j][i-1])
{
Expand Down Expand Up @@ -299,12 +299,12 @@ namespace PRISMS
bfunc_ptr = _bfunc.back();

std::cout << "Read CELLS: " << Ncells << std::endl;
for( int i=0; i<Ncells; i++)
for( unsigned int i=0; i<Ncells; i++)
{
infile >> uli_dummy;

cell_node.resize(uli_dummy);
for( int j=0; j<uli_dummy; j++)
for( unsigned int j=0; j<uli_dummy; j++)
{
infile >> cell_node[j];
}
Expand All @@ -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());
}
Expand All @@ -344,7 +344,7 @@ namespace PRISMS
//std::cout << "ss.str()" << ss.str() << std::endl;
ss >> str >> Ncells;

for( int i=0; i<Ncells; i++)
for( unsigned int i=0; i<Ncells; i++)
{
infile >> uli_dummy;

Expand Down Expand Up @@ -519,7 +519,7 @@ namespace PRISMS
{
//std::cout << "begin add_once()" << std::endl;

for( int i=0; i<list.size(); i++)
for( unsigned int i=0; i<list.size(); i++)
{
if( list[i] == val)
{
Expand All @@ -539,4 +539,4 @@ namespace PRISMS
}


#endif
#endif