Hello everybody,
As I said in a precedent post, there is a bug in the reassignment of ids: when converting the QJson input file to the Parscale container base class the ids are not assigned correctly. The problem is input.cpp, specifically in the function readQJsonArray. the classic qjson object reorders ids with a classic C++ pattern, that is, alphabetically. So when using the for cycle, the ++i increment is done through this pattern. conversely the particleid integer follows an incremental path, because is a pure integer of c++. This results in an ids reassignment in the parscale container. Understand that my solution is not elegant, I am not an informatic expert, but be as it may, it works.
Hoping I don't annoy you with these posts on ParScale, also i beg your pardon for the varables name
Riccardo
here I post the new readQjsonarray function reworked.
void Input::readQJsonArray(const QJsonObject &myParticles, ContainerBase &container) const
{
//Iterate through the data for each particle
int particleId = 0;
QJsonObject::const_iterator i, h;
QString tot;
double * ptr = (double*) container.begin_slow_dirty(); //ptr to scalar per-particle data
double ***ptr3 = (double***) container.begin_slow_dirty(); //ptr to vectorial per-particle data
int toto, ind;
for (i = myParticles.begin(); i != myParticles.end(); ++i)
{
if(particleId>=container.size())
error().throw_error_one(FLERR,"particleId>=container.size(). You have specified too many particles in the JSON file.\n");
h = myParticles.begin();
tot = h.key();
toto = tot.toInt();
ind = toto - 1;
for (h = myParticles.begin(); h != myParticles.end(); ++h)
{
tot = h.key();
toto = tot.toInt();
ind = toto - 1;
if (ind == particleId)
break;
}
QJsonArray data = (*h).toArray();
QJsonValue value, value1;
//std::cout << "data.size=" << data.size() << std::endl;
if(data.size()=container.lenVecUsed(). You have specified too few data in the JSON file.\n");
for(int j = 0; j < data.size(); j++)
{
if(j>=container.lenVecUsed())
error().throw_error_one(FLERR,"j>=container.lenVecUsed(). You have specified too many data in the JSON file.\n");
value = data[j];
//std::cout << "particule =" << particleId << "--------------------------data[" << j << "]=" << value.toDouble() << std::endl;
//std::cout << "toto=" << toto << " PARTICLEid= " << particleId << " index " << ind << std::endl;
if(container.lenVecUsed()>1)
ptr3[particleId][0][j] = value.toDouble();//
else
ptr[particleId] = value.toDouble();
}
particleId++;
h = myParticles.begin();
}
if(particleId < container.size())
error().throw_error_one(FLERR,"particleId < container.size(). You have specified too few data in the input.");
}
sradl1981 | Tue, 06/23/2015 - 11:52
Id reassignment
thank you,
this bug will be removed in the next public release (expected June 2015)
cheers
Stefan