Beispiel #1
0
void GetParameters(char *fparam, struct RUNPARAMS *param){

  ReadParameters(fparam, param);

  // computing the maxhash
  int val=(POW(2,param->lmax-1)<=512?POW(2,param->lmax-1):512); // limit to 2097152 octs in hash table i.e. 16e6 cells
  param->maxhash=POW(val,3);
  //printf("maxhash=%d\n",param->maxhash);

  // ====================== some checks

  // stencil/streams conformity
#ifdef GPUAXL
  if(param->hstride<(param->nthread*param->nstream)){
    printf(" Stream Thread granulosity too high : nt=%d ns=%d stencil=%d\n",param->hstride,param->nthread,param->nstream);
    abort();
  }
#endif

#ifdef STARS
    param->stars->n		= 0;
#endif

#ifdef SRCINT
  param->srcint*=SRCINT;
#endif

#if defined(UVBKG) || defined(STARS_TO_UVBKG)
  setUVBKG(param, "src/phys_data/uvbkg.dat");
#endif // UVBKG


#ifdef WRAD
  readAtomic(param);
#endif // WRAD

#ifdef SUPERNOVAE
  //read_egy_loss(param);
  //read_mass_loss(param);
#endif // SUPERNOVAE

#if defined(WRADTEST) || defined(SNTEST)
/*
  param->unitary_stars_test->lifetime = 3.673e6;
  param->unitary_stars_test->mass=2e2;
  param->unitary_stars_test->src_pos_x=0.;
  param->unitary_stars_test->src_pos_y=0.;
  param->unitary_stars_test->src_pos_z=0.;
*/

  param->unitary_stars_test->lifetime = 8e6;
  param->unitary_stars_test->mass=2e2;
  param->unitary_stars_test->src_pos_x=0.5;
  param->unitary_stars_test->src_pos_y=0.5;
  param->unitary_stars_test->src_pos_z=0.5;
#endif // defined

}
Beispiel #2
0
Clump *LoaderDFF::loadFromMemory(FileHandle file) {
    auto model = new Clump;

    RWBStream rootStream(file->data, file->length);

    auto rootID = rootStream.getNextChunk();
    if (rootID != CHUNK_CLUMP) {
        throw DFFLoaderException("Invalid root section ID " +
                                 std::to_string(rootID));
    }

    RWBStream modelStream = rootStream.getInnerStream();
    auto rootStructID = modelStream.getNextChunk();
    if (rootStructID != CHUNK_STRUCT) {
        throw DFFLoaderException("Clump missing struct chunk");
    }

    // There is only one value in the struct section.
    auto numAtomics = *(std::uint32_t *)rootStream.getCursor();
    RW_UNUSED(numAtomics);

    GeometryList geometrylist;
    FrameList framelist;

    // Process everything inside the clump stream.
    RWBStream::ChunkID chunkID;
    while ((chunkID = modelStream.getNextChunk())) {
        switch (chunkID) {
            case CHUNK_FRAMELIST:
                framelist = readFrameList(modelStream);
                break;
            case CHUNK_GEOMETRYLIST:
                geometrylist = readGeometryList(modelStream);
                break;
            case CHUNK_ATOMIC: {
                auto atomic = readAtomic(framelist, geometrylist, modelStream);
                RW_CHECK(atomic, "Failed to read atomic");
                if (!atomic) {
                    // Abort reading the rest of the clump
                    return nullptr;
                }
                model->addAtomic(atomic);
            } break;
            default:
                break;
        }
    }

    if (!framelist.empty()) {
        model->setFrame(framelist[0]);
    }

    // Ensure the model has cached metrics
    model->recalculateMetrics();

    return model;
}
Beispiel #3
0
//==============================================================================
size_t Reader::skipAtomic(size_t n)
{
	size_t count=0;

	for(; count<n; count++)
	{
		if(readAtomic() == Character::EndOfFileCharacter) break;
	}

	return count;
}