Пример #1
0
void FPairVels::setup()
{
  FPairArbitrary::setup();

  m_pairFactor.setReturnType(Variant::VECTOR);
  m_1stparticleFactor.setReturnType(Variant::VECTOR);
  m_2ndparticleFactor.setReturnType(Variant::VECTOR);

// Setting the colours this force works on
  size_t col1 = M_MANAGER->getColour(m_species.first);
  size_t col2 = M_MANAGER->getColour(m_species.second);
  ColourPair *cp = M_MANAGER->cp(col1, col2);

  if ((col1 == cp->secondColour()) && (col2 == cp->firstColour())) {
    size_t dummy = col1;
    col1 = col2;
    col2 = dummy;
  }
  else if ((col1 == cp->firstColour()) && (col2 == cp->secondColour())) {
//    MSG_DEBUG("FPairVels::setup", "Force colours same order as ColourPair's colours");
  }
  else {
    throw gError("FPairVels::setup", "No ColourPair for these colours. Contact the programmer.");
  }

  if(m_cutoff <= 0)
    throw gError("FPairVels::setup", "Please define a cutoff >0");

  cp->setCutoff(m_cutoff);

}
Пример #2
0
void FPairArbitrary::setup()
{
  FPair::setup();

  ColourPair *m_cp = M_MANAGER->cp(M_MANAGER->getColour(m_species.first), M_MANAGER->getColour(m_species.second));
  
  assert(m_cp);
  
/*  if (m_pairFactor.isNull())
  throw gError("FPairVector::setup", "Please specify a function for 'pairFactor'.");*/
  m_pairFactor.setExpression(m_pairFactorStr);
//   m_pairFactor.setReturnType(Variant::VECTOR);
  m_pairFactor.setColourPair(m_cp);
  m_1stparticleFactor.setExpression(m_1stPExpression);
//   m_1stparticleFactor.setReturnType(Variant::VECTOR);
  m_1stparticleFactor.setColourPair(m_cp);
  m_2ndparticleFactor.setExpression(m_2ndPExpression);
//   m_2ndparticleFactor.setReturnType(Variant::VECTOR);
  m_2ndparticleFactor.setColourPair(m_cp);

  if (m_1stparticleFactor.isNull()) {
    throw gError("FPairArbitrary::setup", "For " + m_properties.className() + ": Please specify a function for 'particleFactor'.");
  }
  if (m_2ndparticleFactor.isNull()) {
    throw gError("FPairArbitrary::setup", "For " + m_properties.className() + ": Please specify a function for 'particleFactor'.");
  }
  if (m_pairFactor.isNull()) {
    throw gError("FPairArbitrary::setup", "For " + m_properties.className() + ": Please specify a function for 'pairFactor'.");
  }
  if(m_symmetry != 1 && m_symmetry != -1) 
    throw gError("FPairArbitrary::setup", "For " + m_properties.className() + ": m_symmetry = \"" + ObjToString(m_symmetry) + 
        "\" not allowed. Allowed values are '-1' and '1'.");  
}
Пример #3
0
void FPairTensor::setup()
{
  FPairArbitraryWF::setup();

  ColourPair *m_cp = M_MANAGER->cp(M_MANAGER->getColour(m_species.first), M_MANAGER->getColour(m_species.second));

  m_pairFactor.setReturnType(Variant::TENSOR);
//   m_pairFactor.setColourPair(m_cp);
  m_1stparticleFactor.setReturnType(Variant::TENSOR);
  m_2ndparticleFactor.setReturnType(Variant::TENSOR);


/*  if (m_pairFactor.isNull()) {
  throw gError("FPairTensor::setup", "Please specify a function for 'pairFactor'.");
}*/

  DataFormat::attribute_t firstAttr =
      Particle::s_tag_format[m_cp->firstColour()].attrByName(m_tensor_name);

  DataFormat::attribute_t secondAttr =
      Particle::s_tag_format[m_cp->secondColour()].attrByName(m_tensor_name);

  if(firstAttr.datatype != DataFormat::TENSOR)
    throw gError("FPairScalar::setup", "the symbol " + m_tensor_name +
        " is registerd as a non-tensor for species " +
            m_cp->manager()->species(m_cp->firstColour()));

  if(secondAttr.datatype != DataFormat::TENSOR)
    throw gError("FPairScalar::setup", "the symbol " + m_tensor_name +
        " is registerd as a non-tensor for species " +
            m_cp->manager()->species(m_cp->secondColour()));

  // FIXME: This is general for each FPairArbitrary except for FPairVels. That's why it's still here  => refine hierarchy or remove FPairVels
  for(size_t i = 0; i < FORCE_HIST_SIZE; ++i)
  {
    m_force_offset[i].first =
        Particle::s_tag_format[m_cp->firstColour()].attrByName(string("force_"
        + m_tensor_name + "_" + ObjToString(i))).offset;
    m_force_offset[i].second =
        Particle::s_tag_format[m_cp->secondColour()].attrByName(string("force_"
        + m_tensor_name + "_" + ObjToString(i))).offset;
  }

// Setting the colours this force works on
  size_t col1 = M_MANAGER->getColour(m_species.first);
  size_t col2 = M_MANAGER->getColour(m_species.second);
  ColourPair *cp = M_MANAGER->cp(col1, col2);

  if ((col1 == cp->secondColour()) && (col2 == cp->firstColour())) {
    size_t dummy = col1;
    col1 = col2;
    col2 = dummy;
  }
  else if ((col1 == cp->firstColour()) && (col2 == cp->secondColour())) {
//    MSG_DEBUG("FPairVels::setup", "Force colours same order as ColourPair's colours");
  }
  else {
    throw gError("FPairTensor::setup", "No ColourPair for these colours. Contact the programmer.");
  }
}
Пример #4
0
void ParticleVels::setup()
{
  // Peculiarities of this class
  if(m_symbolName != "v")
    throw gError("ParticleVels::setup", "Attribute 'symbol' has forbidden value " + m_symbolName + ". ParticleVels must have symbol = \"v\"!");
  
  if(!m_overwrite)
    throw gError("ParticleVels::setup", "Attribute 'overwrite' has forbidden value \"false\". ParticleVels must have overwrite = \"true\"!");
  
  // All the stuff from the parent can be used if we have done what we
  // have done before in ParticleVels::setup()
  ParticleCacheArbitrary::setup();
}
Пример #5
0
// check for consistency of calculator's and triplets' species
void TripletCalculator::checkConsistency() {

  tripletList* trl = M_PHASE->returnTripletList(m_listName);
  
  tripletList::iterator firstTr = trl->begin();
  
  if(M_MANAGER->getColour(m_species[0]) != firstTr->a->c)
    throw gError("TripletCalculator::findStage", "For module " + name() + ": Inconsistency between the attribute species1=\"" + m_species[0] + "\" of this calculator and the first species in the assigned list '" + m_listName + "'. This is currently not allowed.");
  if(M_MANAGER->getColour(m_species[1]) != firstTr->b->c)
    throw gError("TripletCalculator::findStage", "For module " + name() + ": Inconsistency between the attribute species2=\"" + m_species[1] + "\"  of this calculator and the first species in the assigned list '" + m_listName + "'. This is currently not allowed.");
  if(M_MANAGER->getColour(m_species[2]) != firstTr->c->c)
    throw gError("TripletCalculator::findStage", "For module " + name() + ": Inconsistency between the attribute species3=\"" + m_species[2] + "\"  of this calculator and the first species in the assigned list '" + m_listName + "'. This is currently not allowed.");

}   
Пример #6
0
    // Metoda zwraca string dla danego klucza
    static string get( const string& key ) {

        if (contains(key) ) {
            return( property.find( key )->second );
        }
        else {
            gError(key + "-Not found property" );
            return( "xxxxxxxxx" );
        }
    }
Пример #7
0
    // Metoda zwraca double dla danego klucza
    static double getSetting( const string& key ) {

        if (containsSetings(key) ) {
            return( pSettings.find( key )->second );
        }
        else {
            gError(key + "-Not found property" );
            return( 0 );
        }
    }
Пример #8
0
void OutputPDB::setup()
{
  Output::setup();
	
  if(m_posfn == "---") 
    throw gError("OutputPDB::read: 'positionsfn' not properly defined.");
  if (!m_multiple_files) {
    m_pos_s.open(m_posfn.c_str());
  }
}
Пример #9
0
/** Metoda zwraca adres powierchni przechowywanej w pamieci. Powierzchnie sa 
 *  wypelnione wczytanymi obrazkami.
 * @throw const char* : nazwa metody
 */
SDL_Surface* Resource::getSurf( string Name ){
  
  if(  containsSurf(Name) ){
    return pSurfaces.find( Name )->second;
  }
  else{
    gError(Name + ":Not found surfaces" );
    throw(string("Resource::getSurf")); 
  }
  
}
Пример #10
0
void FPairVels::setForceSlots(Integrator* intr, int thread_no) {
  size_t col1 = M_MANAGER->getColour(m_species.first);
  size_t col2 = M_MANAGER->getColour(m_species.second);
  string dof = "vel_pos";
  ColourPair *cp = M_MANAGER->cp(col1, col2);

  if (col1 == intr->colour()) {
    if (dof == intr->dofIntegr()) {
      if (col1 == cp->firstColour()) {
        intr->merge() = true;
        m_offsetToVec[thread_no].first = intr->offsetToVec()[thread_no];
        m_posInVec.first = intr->posInVec();
      }
      else if (col1 == cp->secondColour()) {
        intr->merge() = true;
        m_offsetToVec[thread_no].second = intr->offsetToVec()[thread_no];
        m_posInVec.second = intr->posInVec();
      }
      else {
        throw gError("FPairVels::setForceSlots", "No match for this Force's colours for the ColourPair. Contact the programmer.");
      }
    }
  }
  if (col2 == intr->colour()) {
    if (dof == intr->dofIntegr()) {
      if (col2 == cp->secondColour()) {
        intr->merge() = true;
        m_offsetToVec[thread_no].second = intr->offsetToVec()[thread_no];
        m_posInVec.second = intr->posInVec();
      }
      else if (col2 == cp->firstColour()) {
        intr->merge() = true;
        m_offsetToVec[thread_no].first = intr->offsetToVec()[thread_no];
        m_posInVec.first = intr->posInVec();        
      }
      else {
        throw gError("FPairVels::setForceSlots", "No match for this Force's colours for the ColourPair. Contact the programmer.");
      }
    }
  }
}
Пример #11
0
void ParticleCreatorLSE::createParticles() {
	//Controller* c = M_CONTROLLER;
	MSG_DEBUG(CLASSNAME+("::"+PRETTYFUNC_INFO),"Read matrices");
	M_CONTROLLER->registerForSetupAfterParticleCreation(this);
	if (m_matfile_A == "")
		throw gError("ParticleCreatorLSE::createParticles", "Please define the name of the matrix file A.");
	if (m_matfile_B== "")
		throw gError("ParticleCreatorLSE::createParticles", "Please define the name of the matrix file B.");
	if (m_matfile_C == "")
		throw gError("ParticleCreatorLSE::createParticles", "Please define the name of the matrix file C.");
	if (m_matfile_E == "")
		throw gError("ParticleCreatorLSE::createParticles", "Please define the name of the matrix file E.");
	m_matrixA=new MArray2D(m_matfile_A);
	m_matrixB=new MArray2D(m_matfile_B);
	m_matrixC=new MArray2D(m_matfile_C);
	m_matrixE=new MArray2D(m_matfile_E);
	*m_matrixA = (m_matrixA)->scalarmult(m_mult_matA);
	*m_matrixB = (m_matrixB)->scalarmult(m_mult_matB);
	*m_matrixC = (m_matrixC)->scalarmult(m_mult_matC);
	*m_matrixE = (m_matrixE)->scalarmult(m_mult_matE);
	MSG_DEBUG(CLASSNAME+("::"+PRETTYFUNC_INFO),"Matrix dimensions are: "
			"A(" << (m_matrixA->dim1()) << "," << (m_matrixA->dim2()) << "), "<<
			"E(" << (m_matrixE->dim1()) << "," << (m_matrixE->dim2()) << "), "<<
			"B(" << (m_matrixB->dim1()) << "," << (m_matrixB->dim2()) << "), "<<
			"C(" << (m_matrixC->dim1()) << "," << (m_matrixC->dim2()) << ")."
	);
	MSG_DEBUG(CLASSNAME+("::"+PRETTYFUNC_INFO),"Create superparticle");
	Particle p;
	p.setColour(m_colour);
	size_t offsetA=Particle::s_tag_format[m_colour].attrByName("matrixA").offset;
	size_t offsetE=Particle::s_tag_format[m_colour].attrByName("matrixE").offset;
	size_t offsetx=Particle::s_tag_format[m_colour].attrByName("stateVector").offset;
	size_t offsetv=Particle::s_tag_format[m_colour].attrByName("velocityVector").offset;
	p.tag.array2dDoubleByOffset(offsetA).set(m_matrixA);
	p.tag.array2dDoubleByOffset(offsetE).set(m_matrixE);
	p.tag.array2dDoubleByOffset(offsetx).set(new MArray2D(m_matrixA->dim1(),1,0));
	p.tag.array2dDoubleByOffset(offsetv).set(new MArray2D(m_matrixA->dim1(),1,0));
	M_PHASE->addParticle(p);
	MSG_DEBUG(CLASSNAME+("::"+PRETTYFUNC_INFO),"Done");

}
Пример #12
0
/** Metoda wyszukuje w tablicy asocjacyjnej fontu o podanej
 *  nazwie i zwraca wskaznik do niego
 */
TTF_Font* Resource::getFont(string name) {

    if (containsFont( name ) ) {
        return pFonts.find( name )->second;
    }
    else
    {
        gError(name + ":Not found font" );
        throw("Resource::getFont");
    }

}
Пример #13
0
void LinearRegression::flush()
{
    double sum_x = 0, sum_y = 0, sum_xy = 0, sum_x2 = 0, sum_y2 = 0, sxx, syy, sxy;
    double slope, slope_error, intercept;
    int n = 0;

	/* Initialize our post- and preprocessor functions */
	for (int i = 0; i < SPACE_DIMS; i++) {
		string s = "box" + string(1, 'X'+i);
		m_prefn.constant(s) = m_simulation->phase()->boundary()->boundingBox().size()[i];
		m_postfn.constant(s) = m_simulation->phase()->boundary()->boundingBox().size()[i];
	}

	m_prefn.FromString(m_str_prefn);
	m_postfn.FromString(m_str_postfn);

	/* Apply m_prefn and do the linear regression */
	for (list<data_sp>::iterator i = m_data.begin(); i != m_data.end(); i++) {
        double x, y;

        x = (*i)->doubleByIndex(m_idx_x);
        y = m_prefn.value((*i)->doubleByIndex(m_idx_y));
        
        sum_x += x;
        sum_y += y;
        sum_xy += x*y;
        sum_x2 += x*x;
        sum_y2 += y*y;
        n++;
    }

    if(n < 3) 
       throw gError
         ("LinearRegression::flush", "I need at least 3 values, but have only " 
           + ObjToString(n));
    sxy = sum_xy - sum_x*sum_y/n;
    sxx = sum_x2 - sum_x*sum_x/n;
    syy = sum_y2 - sum_y*sum_y/n;

    slope = sxy/sxx;
    slope_error = sqrt((syy - (slope*slope*sxx)) / (n - 2));
    intercept = sum_y/n - slope*sum_x/n;

    data_sp data = m_output.newData();
    data->doubleByIndex(IDX_SLOPE) = slope;
//    data->doubleByIndex(IDX_SLOPE_ERROR) = slope_error;
    data->doubleByIndex(IDX_INTERCEPT) = intercept;
//    data->doubleByIndex(IDX_INTERCEPT_ERROR) = 0;
    data->doubleByIndex(IDX_VALUE) = m_postfn.value(slope);
    distribute(data);
}
Пример #14
0
void GridMeterScalar::setup()
{
  GridMeter::setup();

  if (m_colour == ALL_COLOURS)
    throw gError("GridMeterScalar::setup", "Please specify a species.");

  m_moment_o = 
    M_GRID_AVERAGER->format().addAttribute
      (m_species + STR_DELIMITER + m_scalar_name + "^" + ObjToString(m_moment),
       DataFormat::VECTOR_DOUBLE).offset;

  m_scalar_o = Particle::s_tag_format[m_colour].attrByName(m_scalar_name).offset;
}
Пример #15
0
/** Pierwszy poziom obslugi zdarzen. Sprawdzane jest jaki klawisz zostal nacisniety, a
 * nastepnie zostaje uruchomiona odpowiednia metoda klasy Game odpowiadajaca za obsluge danego klawisza.
 * Jest to filtrowanie zdarzen na rzecz klasy Game.
 * @return void
 * @param void
 */
void App::processEvent() {


    while ( SDL_PollEvent( &pEvent ) )
    {
        if ( pEvent.type == SDL_QUIT )
        {
            pIsDone = true;
        }
		#ifdef DEBUG
        /** @TODO Po nacisnieciu F1 wyjscie z aplikacji! */
        else if (pEvent.type == SDL_KEYDOWN && pEvent.key.keysym.sym == SDLK_F1 ) {
            gError("Pressed F1 key. App is terminated.");
            throw("App::processEvent");
        }
	#endif
        else if (pEvent.type == SDL_KEYDOWN && pEvent.key.keysym.sym == SDLK_ESCAPE ) {
            gInfo("ESC pressed");
            pGame->pressedEsc();
        }
	    else if (pEvent.type == SDL_KEYDOWN && pEvent.key.keysym.sym == SDLK_SPACE ) {
            pGame->SpaceDown();
        }
        else if (pEvent.type == SDL_KEYUP && pEvent.key.keysym.sym == SDLK_SPACE ) {
            pGame->SpaceUp();
        }
        else if (pEvent.type == SDL_KEYDOWN && pEvent.key.keysym.sym == SDLK_RETURN ) {
            pGame->pressedReturn();
        }
        else if (pEvent.type == SDL_KEYDOWN && pEvent.key.keysym.sym == SDLK_LEFT ) {
            pGame->pressedLeft();
        }
        else if (pEvent.type == SDL_KEYDOWN && pEvent.key.keysym.sym == SDLK_RIGHT ) {
            pGame->pressedRight();
        }
        else if (pEvent.type == SDL_KEYDOWN && pEvent.key.keysym.sym == SDLK_UP ) {
            pGame->pressedUp();
        }
        else if (pEvent.type == SDL_KEYDOWN && pEvent.key.keysym.sym == SDLK_DOWN ) {
            pGame->pressedDown();
        }
        else if ( pEvent.type == SDL_KEYDOWN &&  ( pEvent.key.keysym.sym >= 97 && pEvent.key.keysym.sym >= 122 ) )
        {
            ///@TODO obsluga klawiatury do wpisania highscore

        }
        ///@TODO Reszta zdarzen do dopisania
    }
}
Пример #16
0
void NodeOneChild::read(const xmlNode *xmln)
{
  Node::read(xmln);

  for (const xmlNode *cur_node = xmln->children; cur_node; cur_node = cur_node->next) {
    if (cur_node->type == XML_ELEMENT_NODE) {
      if (m_child)
        throw gError("NodeOneChild::read", "For " + className() + ": Only one child is allowed for this node.");

      m_child = instantiateChild((const char*) cur_node->name);
      if (m_child)
        m_child->read(cur_node);
    }
  }
}
Пример #17
0
_XFX_BEGIN





//
// Resource
//

HRESULT Resource::LoadFile( const String& file )
{
	PROFILE( __FUNCTION__, "General" );

	mFilename = file;
	mPhysicalPath.clear( );
	gMess( "Loading %s from file \"%s\"...", mName.c_str( ), file.c_str( ) );

	unsigned long filesize;
	HRESULT hr;
	if( FAILED( hr = FileSystem::Instance( ).FindFile( file, NULL, &mPhysicalPath ) ) ||
		FAILED( hr = FileSystem::Instance( ).GetFileSize( file, filesize ) ) )
	{
		gError( "Can't open file \"%s\"", file.c_str( ) );
		return hr;
	}

	boost::scoped_array< BYTE > pbuf( new BYTE[ filesize ] );

	FileSystem::Instance( ).ReadFile( file, pbuf.get( ) );

	if( FAILED( hr = LoadMemory( pbuf.get( ), filesize ) ) )
		gError( "Loading %s from file \"%s\" failed!", mName.c_str( ), file.c_str( ) );

	return hr;
}
Пример #18
0
void GridMeterVector::setup()
{
  GridMeter::setup();

  if (m_colour == ALL_COLOURS)
    throw gError("GridMeterVector::setup", "Please specify a species.");

  m_moment_o = 
      M_GRID_AVERAGER->format().addAttribute
      (m_species + STR_DELIMITER + m_name + "^" + ObjToString(m_moment),
       DataFormat::VECTOR_POINT).offset;

  m_offset = Particle::s_tag_format[m_colour].attrByName(m_name).offset;
  MSG_DEBUG("GridMeterVector::setup", "m_offset = " << m_offset << ", m_name = " << m_name);
}
void BondedPairParticleArbitrary::setup()
{
  if(m_expression == "undefined")
    throw gError("BondedPairParticleArbitrary::setup", ": Attribute 'expression' has value \"undefined\"");
       
  ColourPair* cp = M_MANAGER->cp(M_MANAGER->getColour(m_species.first), M_MANAGER->getColour(m_species.second));
  
  m_function.setExpression(m_expression);
  m_function.setColourPair(cp);
  m_1stparticleFactor.setExpression(m_1stPExpression);
  m_1stparticleFactor.setColourPair(cp);
  m_2ndparticleFactor.setExpression(m_2ndPExpression);
  m_2ndparticleFactor.setColourPair(cp);

  BondedPairParticleCalc::setup();
  
}
Пример #20
0
void GridMeterScalarFourierCos::setup()
{
  GridMeterScalar::setup();

//   if(m_dir != 0 && m_dir != 1 && m_dir != 2)
//     throw gError("GridMeterScalarFourierCos::setup", "Attribute 'direction' has a forbidden value \"" + ObjToString(m_dir) + "\"! It must have value \"0\", \"1\" or \"2\" representing one of the cartesian directions.");

//   if(m_lambda == HUGE_VAL)
//     throw gError("GridMeterScalarFourierCos::setup","Please define attribute 'waveLength'!");

  bool abort = true;
  for(size_t i = 0; i < SPACE_DIMS; ++i)
    abort = abort && (m_kVec[i] == HUGE_VAL);

  if(abort)
    throw gError("GridMeterScalarFourierCos::setup","k-vector does not seem to be well defined by attribute 'kVec'.");

//   m_k = 2*M_PI/m_lambda;
    
  m_kVec = 2*M_PI*m_kVec;

}
Пример #21
0
void read_series(istream& df, const string &name)
{
  char ch;
  vec_convert vc;
  series t;
  while (df)
  {
    t.init();
    vc.clear();
    df >> ws;
    if (df.peek() == '*')
    {
      t.hide = true;
      df.ignore();
    }
    if (hide_series)
      t.hide = true;
    df >> ws;
    ch = get_token(df, t.ID);
    if (isspace(ch))
      ch = skip_until(df);
    if (ch != ',')
      continue;
    df >> ws;
    string str;
    ch = get_token(df, str);
    try
    {
      t.f = FindResidual(str);
    }
    catch (gError) 
    {
      cout << NOEQ << t.ID << " - " << str << " -  series ignored" << endl;
      while (ch = df.get(), ch != ';' &&
                            ch != EOF);
      continue;
    }
    parser p(df, name);
    SGML el;
    if (isspace(ch))
      while (df >> ws, ch = df.peek(), ch == '<')
      {
        p.GetSGML(el);
        el.compare("var");
        str = el.FindString("name");
        if (!str.empty())
        {
          t.vs.push_back(str);
          t.vx.push_back(el.FindDouble("value"));
        }
      }
    if (ch != ',')
      ch = skip_until(df);
    if (ch == ',')
      df.ignore();
    else
      continue;
    while (df >> ws, ch = df.peek(), ch == '<')
    {
      vc.push_back(convert());
      vc.back().read(p.GetSGML(el));
    }
    if (ch == ',')
      df.ignore();
    t.read(df, 0, t.f.NameOfX(), t.f.ScaleOfX());
    if (!t)
      continue;
    if (vc.empty())
      ser.push_back(t);
    else
    {
      series t1;
      t1.hide = t.hide;
      t1.ID = t.ID;
      t1.f = t.f;
      t1.vs = t.vs;
      t1.vx = t.vx;
      t1.set(t.Ntot(), vc.size());
      for (size_t i = 0; i < vc.size(); ++i)
      {
        if (vc[i].name().empty())
          throw gError("read_series: no name while converting");
        else
          t1.name(i) = vc[i].name();
      }
      t1.scale() = t.scale();
      t1.NOfX() = SearchString(t1.names(), t1.f.NameOfX());
      for (size_t i = 0; i < vc.size(); ++i)
        vc[i].SetID(t.names());
      for (size_t i = 0; i < t.Ntot(); ++i)
      {
        t1.atr(i) = t.atr(i);
        for (size_t j = 0; j < vc.size(); ++j)
          t1(i, j) = vc[j](t(i));
      }
      t1.set_av();
      ser.push_back(t1);
    }
    ser.back().f.SetInput(ser.back().names());
    ser.back().f.SetOnceInput(ser.back().vs);
  }
}
Пример #22
0
WeightingFunction::WeightingFunction()
{
  throw gError("WeightingFunction::WeightingFunction(default)", "Should not be called. Contact the programmer.");
}
Пример #23
0
void BondedPairParticleCalc::setup()
{
   if(m_symmetry != -1 && m_symmetry != 1)
     throw gError("BondedPairParticleCalc::setup", "For module " + name() + ": Define attribute 'symmetry'! It may only be \"-1\" (antisymmetry) or \"1\" (symmetry). Currently it is " + ObjToString(m_symmetry) + "!");

  if(m_listName == "undefined")
    throw gError("BondedPairParticleCalc::setup", "Attribute 'listName' is undefined!");
       
  if(m_phaseUser != 0 && m_phaseUser != 1 && m_phaseUser != 2)
    throw gError("BondedPairParticleCalc::setup", ": Attribute 'stage' is " + ObjToString(m_phaseUser) + ", which is none of the allowed values \"0\", \"1\", \"2\".");
   
  if(m_species.first == "undefined")
    throw gError("BondedPairParticleCalc::setup", "For module " + name() + ": Attribute 'species1' has value \"undefined\"."); 
  if(m_species.second == "undefined")
    throw gError("BondedPairParticleCalc::setup", "For module " + name() + ": Attribute 'species2' has value \"undefined\"."); 
  
  ColourPair* cp = M_MANAGER->cp(M_MANAGER->getColour(m_species.first), M_MANAGER->getColour(m_species.second)/*m_species*/);
  
  
  // next lines are just necessary for non-bonded pairs, so not here!
  //      cp->setNeedPairs(true);
  //   cp->setCutoff(m_cutoff);
  
  if(m_overwrite)
    {
      try
	{
	  m_slots.first = Particle::s_tag_format[cp->firstColour()].indexOf(m_symbolName, m_datatype);
	  m_slots.first = Particle::s_tag_format[cp->firstColour()].offsetByIndex(m_slots.first);
	}
      catch(gError& err)
	{
	  throw gError("BondedPairParticleCalc::setup", ": search for symbol for species '" + M_MANAGER->species(cp->firstColour()) + " failed, but need one because 'overwrite = \"yes\"'. The message was " + err.message()); 
	}
      try
	{
	  m_slots.second = Particle::s_tag_format[cp->secondColour()].indexOf(m_symbolName, m_datatype);
	  m_slots.second = Particle::s_tag_format[cp->secondColour()].offsetByIndex(m_slots.second);
	}
      catch(gError& err)
	{
	  throw gError("BondedPairParticleCalc::setup", ": search for symbol for species '" + M_MANAGER->species(cp->secondColour()) + " failed, but need one because 'overwrite = \"yes\"'. The message was " + err.message()); 
	}      
    }
  else // m_overwrite = false
    {
      if(Particle::s_tag_format[cp->firstColour()].attrExists(m_symbolName)) 
        throw gError("BondedPairParticleCalc::setup", ": Symbol " + m_symbolName + " is already existing for species '" + M_MANAGER->species(cp->firstColour()) + "'. Second definition is not allowed for overwrite = \"no\"");
      
      if(Particle::s_tag_format[cp->secondColour()].attrExists(m_symbolName))
        throw gError("BondedPairParticleCalc::setup", ": Symbol " + m_symbolName + " is already existing for species '" + M_MANAGER->species(cp->secondColour()) + "'. Second definition is not allowed for overwrite = \"no\"");
      
      // see CONVENTION5 for rule about persistencies
      m_slots.first = Particle::s_tag_format[cp->firstColour()].addAttribute(m_symbolName, m_datatype, /*persist.first*/false, m_symbolName).offset;
      
      if(cp->firstColour() != cp->secondColour())
	{
	  // see CONVENTION5 for rule about persistencies
	  m_slots.second = Particle::s_tag_format[cp->secondColour()].addAttribute(m_symbolName, m_datatype, /*persist.second*/false, m_symbolName).offset;
	}
      else m_slots.second = m_slots.first;
    } // end of else-case where m_overwrite = false
  
  MSG_DEBUG("BondedPairParticleCalc::setup", ": registering " << this->name() << ".");
  
  if(m_phaseUser == 0)    
    cp->registerBondedCalc_0(this);
  else if(m_phaseUser == 1)    
    cp->registerBondedCalc(this);
  else // so it is 2
    {
      ValCalculator* vc = copyMySelf() /*new BondedPairParticleCalc(*this)*/;

      copyMembersTo(vc);
      
      MSG_DEBUG("BondedPairParticleCalc::setup", ": registering copy of " << this->name() << ", CP = (" << cp->firstColour() << ", " << cp->secondColour() << ")");    
      
      cp->registerBondedCalc(vc);
      cp->registerBondedCalc_0(this);
    }

}
Пример #24
0
void GenFSolo::computeForces(int force_index)
{
    throw gError("GenFSolo::computeForces", "Fatal error: do not call GenFSolo::computeForces(int force_index)!!! Needs a Pairdist argument. Please contact the programmer!");
}
Пример #25
0
void BoundaryCouette::setup()
{
  bool_point_t periodic;
  Reflector *inner_refl, *outer_refl;

  MSG_DEBUG("BoundaryCouette::setup", "Creating geometry for rotational Couette flow.");

  BoundaryArbitrary::setup();

  if (!m_periodic)
    throw gError("BoundaryCouette::setup", "Non-periodic Couette flow is not yet supported.");

  periodic.x = periodic.y = false;
  periodic.z = m_periodic;

  /* Create a new container and tell it in which direction
     the boundary is periodic.
  */
	m_container = new WallContainer(m_reflectors[0]);
  m_container->setPeriodicityFront(periodic);
  m_container->setPeriodicityBack(periodic);

  inner_refl = findReflector(m_inner_reflector);
  outer_refl = findReflector(m_outer_reflector);

  /* Create the geometry. Loop over elements of the drums edges.
     In the first loop, the vertices are being created and in the
     second loop the vertices are connected by walls.
   */

  /* Create vertices. Note: The vertices are numbered in the order
     of their creation.
   */
  for (int i = 0; i < m_n_edge_elements; ++i) {
    point_t inner_pos, outer_pos;

    inner_pos.z = outer_pos.z = 0;

    inner_pos.x = m_inner_radius * cos(i*2*M_PI/m_n_edge_elements);
    inner_pos.y = m_inner_radius * sin(i*2*M_PI/m_n_edge_elements);
    outer_pos.x = m_outer_radius * cos(i*2*M_PI/m_n_edge_elements);
    outer_pos.y = m_outer_radius * sin(i*2*M_PI/m_n_edge_elements);

    m_container->addVertex(inner_pos);
    m_container->addVertex(outer_pos);

    inner_pos.z += m_height;
    outer_pos.z += m_height;

    m_container->addVertex(inner_pos);
    m_container->addVertex(outer_pos);
  }

  /* Create walls */
  for (int i = 0; i < m_n_edge_elements; ++i) {
    /* vib = Vertex Inner Bottom */
    int next_i, vib1, vob1, vit1, vot1, vib2, vob2, vit2, vot2;

    next_i = (i+1)%m_n_edge_elements;

    vib1 = i*4;
    vob1 = i*4+1;
    vit1 = i*4+2;
    vot1 = i*4+3;

    vib2 = next_i*4;
    vob2 = next_i*4+1;
    vit2 = next_i*4+2;
    vot2 = next_i*4+3;

    ADDRECT(vib1, vib2, vit2, vit1, inner_refl);
    ADDRECT(vot1, vot2, vob2, vob1, outer_refl);
  }

	m_container->updateBoundingBox();
}
Пример #26
0
void BoundarySTL::setup(Simulation* sim, ManagerCell *mgr)
{
    //    BoundaryWithInlet::setup(sim, mgr);
	
    
    /* Cell subdivision */
	
    region_t *inlet, *r;
    bool_point_t periodic = { { { false, false, false } } };

    /* Do we have to construct an inlet??? */
    if (m_inlet_str != "none") {
        int dir;
        double coord;
        ParticleCreatorInlet *pc = NULL;

        MSG_DEBUG("BoundarySTL::setup", "Adding inlet.");

        for(vector<ParticleCreator*>::iterator pcIter = m_pcList.begin();
            pcIter != m_pcList.end(); ++pcIter)
        {
          if(typeid(**pcIter) == typeid(ParticleCreatorInlet))
          {
            if(pc) 
              throw gError("BoundarySTL::setup", "Please define only one ParticleCreatorInlet");
            pc = (ParticleCreatorInlet*) (*pcIter);
          }
        }
        if(!pc) 
          throw gError("BoundarySTL::setup", "Since 'inlet' is not \"none\", you must define a ParticleCreatorInlet.");
        
//         if (typeid(*pcList[0]) != typeid(ParticleCreatorInlet))
//           throw gError
//             ("BoundarySTL::setup"
//              "Please do only use ParticleCreatorInlet with BoundarySTL if you wish to specify an inlet.");
// 
//         pc = (ParticleCreatorInlet*) pcList[0];
// 
// 
//         MSG_DEBUG("BoundarySTL::setup", "Using particle creator: " << pc->className());

        dir = m_inlet_str[0] - 'x';

        m_inlet_normal.assign(0);
        if (m_inlet_pos_str == "bottom") {
            m_inlet_normal[dir] = 1;
            coord = m_container->boundingBox().corner1[dir];
        } else {
            m_inlet_normal[dir] = -1;
            coord = m_container->boundingBox().corner2[dir];
        }

        
        //        MSG_DEBUG("BoundartSTL::setup", "m_inlet_normal = " << m_inlet_normal);

        /* First, delete all walls that might hinder flow through the inlet. */
        list<Wall*> &walls = m_container->walls();
        for (list<Wall*>::iterator i = walls.begin(); i != walls.end(); ) {
            if (((*i)->normal() - m_inlet_normal).abs() < g_geom_eps) {
                /* Fixme!!! Does only work right now. */
                WallTriangle *wt = (WallTriangle*) (*i);
                bool del = true;

                for (int j = 0; j < 3; j++) {
                    //                    MSG_DEBUG("BoundarySTL::setup", "... = " << wt->corner(j)[dir] - coord);
                    if (abs(wt->corner(j)[dir] - coord) >= g_geom_eps)
                        del = false;
                }

                if (del) {
                    list<Wall*>::iterator d = i;
                    int vs[3];
                    i++;

                    //                    MSG_DEBUG("BoundarySTL::setup", "Deleting wall.");

                    for (int j = 0; j < 3; j++) {
                      vs[j] = m_inlet_base_surface.needVertex(wt->corner(j));
                    }

                    m_container->deleteWall(d);

                    m_inlet_base_surface.addWall
                      (new WallTriangle(&m_inlet_base_surface, NULL, vs[0], vs[1], vs[2]));
                } else
                    i++;
            } else
                i++;
        }

        /* Complicated version, add surfaces */

        MSG_DEBUG("BoundarySTL::setup", "Finding pairs.");
        vector< pair<int, int> > pairs;

        point_t middle_point = { { { 0, 0, 0 } } };
        size_t n_points = 0;
        for (list<Wall*>::iterator i = walls.begin(); i != walls.end(); i++) {
            WallTriangle *w = ((WallTriangle*) (*i));
            vector<int> corners;

            for (int j = 0; j < 3; j++) {
                if (abs(w->corner(j)[dir] - coord) < g_geom_eps)
                    corners.push_back(w->cornerVertex(j));
            }

            //            MSG_DEBUG("BoundarySTL::setup", "corners.size() = " << corners.size());
            if (corners.size() == 2) {
                pair<int, int> p;

                p.first = corners[0];
                p.second = corners[1];

                middle_point += m_container->vertex(p.first);
                middle_point += m_container->vertex(p.second);

                n_points += 2;

                pairs.push_back(p);
            } else if (corners.size() == 3)
                throw gError("BoundarySTL::setup", "FATAL: corners.size() = 3 -> should not happpen.");
        }

        middle_point /= n_points;

        MSG_DEBUG("BoundarySTL::setup", "pairs.size() = " << pairs.size());
        MSG_DEBUG("BoundarySTL::setup", "Creating walls.");
        vector<int> partners;
        partners.resize(m_container->vertices().size()+pairs.size(), -1);
        for (vector< pair<int, int> >::iterator i = pairs.begin(); i != pairs.end(); i++) {
            int a, b;
            point_t n1, n2, mv;

            a = i->first;
            b = i->second;

            if (partners[a] == -1) {
                point_t p = m_container->vertex(a);
                p += -m_inlet_length*m_inlet_normal;
                partners[a] = m_container->addVertex(p);
            }
            if (partners[b] == -1) {
                point_t p = m_container->vertex(b);
                p += -m_inlet_length*m_inlet_normal;
                partners[b] = m_container->addVertex(p);
            }

            n1 = (m_container->vertex(b)-m_container->vertex(a)).cross
              (m_container->vertex(partners[a])-m_container->vertex(b));
            n2 = (m_container->vertex(partners[a])-m_container->vertex(b)).cross
              (m_container->vertex(partners[b])-m_container->vertex(partners[a]));
            mv = middle_point-m_container->vertex(b);

            /* Does the vector n1 point towards the middle? */
            if (n1 * mv > 0) {
              m_container->addWall
                (new WallTriangle(m_container, m_container->reflector(),
                                  a, b, partners[a]));
            } else {
              m_container->addWall
                (new WallTriangle(m_container, m_container->reflector(),
                                  b, a, partners[a]));
            }

            /* Does the vector n2 point towards the middle? */
            if (n2 * mv > 0) {
              m_container->addWall
                (new WallTriangle(m_container, m_container->reflector(),
                                  b, partners[a], partners[b]));
            } else {
              m_container->addWall
                (new WallTriangle(m_container, m_container->reflector(),
                                  b, partners[b], partners[a]));
            }
        }

        /* Now, readd the closing surface */
        MSG_DEBUG("BoundarySTL::setup", "Readding closing surface.");

        for (list<Wall*>::iterator i = m_inlet_base_surface.walls().begin(); i != m_inlet_base_surface.walls().end(); ++i) {
          WallTriangle *wall = (WallTriangle*) *i;
          int v1, v2, v3;

          v1 = m_container->findVertex(wall->corner(0) - m_inlet_length * m_inlet_normal, g_geom_eps);
          v2 = m_container->findVertex(wall->corner(1) - m_inlet_length * m_inlet_normal, g_geom_eps);
          v3 = m_container->findVertex(wall->corner(2) - m_inlet_length * m_inlet_normal, g_geom_eps);

          m_container->addWall
            (new WallTriangle(m_container, m_container->reflector(),
                              v1, v2, v3));
        }

        /* Easy version */
/*        vector<point_t> &vertices = m_container->vertices();
        for (vector<point_t>::iterator i = vertices.begin(); i != vertices.end(); i++) {
            if (abs((*i)[dir] - coord) < g_geom_eps) {
                (*i)[dir] -= m_inlet_normal[dir]*m_inlet_length;
            }
            }*/

        m_container->vertexChanged();
        m_container->updateBoundingBox();
    
        m_proposedSize = m_container->boundingBox().corner2;
        
        // next will also call Boundary::setup => this may lead to addition of a frame
        BoundaryWithInlet::setup(sim, mgr);

        point_t inlet_c1, inlet_c2, r_c1, r_c2;

	Phase* phase = (Phase*) m_parent;

        if (m_inlet_pos_str == "bottom") {
            inlet_c1 = m_container->boundingBox().corner1;
            inlet_c2 = m_container->boundingBox().corner2;
            inlet_c2[dir] = inlet_c1[dir] + m_inlet_length;

            r_c1 = m_container->boundingBox().corner1;
//             r_c1[dir] += m_inlet_length;
            r_c2 = m_container->boundingBox().corner2;
            
            // take the frame into account if existent
            if(m_frontFrame[dir]) inlet_c2[dir] += phase->pairCreator()->interactionCutoff();
//             if(m_frontFrame[dir]) inlet_c2[dir] += sim->maxCutoff;

            r_c1[dir] = inlet_c2[dir];
                        
        } else {
            inlet_c1 = m_container->boundingBox().corner1;
            inlet_c2 = m_container->boundingBox().corner2;
            inlet_c1[dir] = inlet_c2[dir] - m_inlet_length;

            r_c1 = m_container->boundingBox().corner1;
            r_c2 = m_container->boundingBox().corner2;
//             r_c2[dir] -= m_inlet_length;
            
            // take the frame into account if existent
            if(m_endFrame[dir]) inlet_c1[dir] -= phase->pairCreator()->interactionCutoff();
//             if(m_endFrame[dir]) inlet_c1[dir] -= sim->maxCutoff;
            
            r_c2[dir] = inlet_c1[dir];
        }

                
        /* *New style* inlets with constant density */
//        periodic[dir] = true;
        periodic[dir] = false;
        inlet = mgr->cellSubdivide(sim->maxCutoff, inlet_c1, inlet_c2, periodic, 1, pc, 
          dir, (int) m_inlet_normal[dir], P_CREATE);

        pc->setRegion(inlet);

//        mgr->setPeriodicity(periodic);

        periodic[dir] = false;
        r = mgr->cellSubdivide(sim->maxCutoff, r_c1, r_c2, periodic, 0, pc, dir, 
          (int) -m_inlet_normal[dir], P_DELETE);
            
        MSG_DEBUG("BoundarySTL::setup", "r->n_cells = " << r->n_cells <<
                  ", inlet->n_cells = " << inlet->n_cells);

//        ManagerCell::connect
//            ((int) m_inlet_normal[dir]*dir-(m_inlet_normal[dir] < 0 ? 1 : 0), inlet, r, periodic, OUTLET);
        ManagerCell::connect
            ((int) m_inlet_normal[dir]*dir-(m_inlet_normal[dir] < 0 ? 1 : 0), inlet, r, periodic, NEIGHBOR);
    } else {
        m_proposedSize = m_container->boundingBox().corner2;
        
        // next could add a frame
        BoundaryWithInlet::setup(sim, mgr);

        r = mgr->cellSubdivide
          (sim->maxCutoff, m_container->boundingBox().corner1, m_container->boundingBox().corner2, periodic, 0);
    }

    mgr->cellSubdivisionFinished();
    
    mgr->assignContainer(m_container);
    
    int counter = 0;

    MSG_DEBUG("BoundarySTL::setup", "Writing geometry information to '" << m_geometry_filename << "'.");
    m_container->toVTK(m_geometry_filename);
}
Пример #27
0
void FPairVels::computeForces(Particle* part, int force_index)
{
  throw gError("FPairVels::computeForces", "Fatal error: do not call FPairVels::computeForces(Particle* part, int force_index)!!! Needs a Pairdist argument. Please contact the programmer!");
}
Пример #28
0
void FirstHarmonic::push(data_sp data)
{
  if(!negativeFound)
    {  
      data_sp new_data = m_output.newData();
      
      double /*left, right,*/ len, step, pos, mul;
      double value = 0;
      vector<point_t> *vp;
      vector<point_t> *cp;
      
      new_data->doubleByIndex(IDX_TIME) = data->doubleByIndex(m_idx_time);
      cp = data->vectorPointByIndex(m_idx_x).value();      
      vp = data->vectorPointByIndex(m_idx_y).value();

      int grid_size = (*cp).size();
                  
//       left = data->doubleByIndex(m_idx_left);
//       right = data->doubleByIndex(m_idx_right);
//       grid_size = data->intByIndex(m_idx_grid_size);
      
      assert(grid_size > 1);
      step = (*cp)[1].x - (*cp)[0].x;
      // are the cells aligned in x-direction?
      if(step > g_geom_eps)
      {
        // make sure there is not more than one cell in y-direction
        if ((*cp)[1].y - (*cp)[0].y > g_geom_eps) 
          throw gError("FirstHarmonic::push", "multiple cells in more than one direction" 
            " found. This is not allowed with FirstHarmonic");
        len = (*cp)[grid_size - 1].x - (*cp)[0].x + step;
        pos = (*cp)[0].x - step/2;
        mul = 2*M_PI/len;
      }
      else // so it's the y-direction
      {
        step = (*cp)[1].y - (*cp)[0].y;
        assert(step > g_geom_eps);
        len = (*cp)[grid_size - 1].y - (*cp)[0].y + step;
        pos = (*cp)[0].y - step/2;
        mul = 2*M_PI/len;
      
      }
        
      for (int i = 0; i < grid_size; i++) {
        /* Currently, we integrate approximating the profile by step functions.
           The profile should be interpolated linearly, quadratically? */
        value += 0.5*(sin((pos + step/2) * mul) /*+ sin(pos * mul)*/) * (*vp)[i].z;
MSG_DEBUG("FirstHarmonic::push", "pos=" << pos << "\nstep=" << step << "\nmul=" << mul << "\nsin((pos+step)*mul) = sin((" << pos << "+" << step << ")*" << mul << ")=" << sin((pos+step)*mul) << "\nsin(pos*mul)=" << sin(pos*mul) << "\nvalue = " << value << "\nfac=" << 0.5*(sin((pos + step) * mul) + sin(pos * mul)) << "\nvel=" << (*vp)[i].z);	
        pos += step;
      }
      // first check is for abort if noise to large
      // second check avoids logarithms of negative numbers      
      if(value < oldValue && value > 0)
    	{
	      new_data->doubleByIndex(IDX_INTENSITY) = value;
        distribute(new_data);
        oldValue = value;
      }
      else negativeFound = true;
    }
}
Пример #29
0
void TripletCalculator::setup()
{
  M_SIMULATION->controller()->registerForSetupAfterParticleCreation(this);

  if(m_symbolName == "undefined")
    throw gError("TripletCalculator::setup", "Attribute 'symbol' undefined!");

  if(m_listName == "undefined")
    throw gError("TripletCalculator::setup", "Attribute 'listName' undefined!");

  // add attributes


    if(m_species[0] == "undefined")
      throw gError("TripletCalculator::setup", ": Attribute 'species1' has value \"undefined\"!"); 
    if(m_species[1] == "undefined")
      throw gError("TripletCalculator::setup", ": Attribute 'species2' has value \"undefined\"!"); 
    if(m_species[2] == "undefined")
      throw gError("TripletCalculator::setup", ": Attribute 'species3' has value \"undefined\"!"); 

    m_firstColour = M_MANAGER->getColour(m_species[0]);
    m_secondColour = M_MANAGER->getColour(m_species[1]);
    m_thirdColour = M_MANAGER->getColour(m_species[2]);

    if(m_overwrite)
    {

      for(size_t p = 0; p < 3; ++p) {
	try
	  {
	    m_slots[p] = Particle::s_tag_format[M_MANAGER->getColour(m_species[p])].indexOf(m_symbolName, m_datatype);
	    m_slots[p] = Particle::s_tag_format[M_MANAGER->getColour(m_species[p])].offsetByIndex(m_slots[p]);
	  }
	catch(gError& err)
	  {
	    throw gError("TripletCalculator::setup", ": search for symbol for species '" + m_species[p] + " failed. The message was " + err.message()); 
	  }
      } // end for(size_t p = 0

    }
    else // m_overwrite = false
    {
      if(Particle::s_tag_format[M_MANAGER->getColour(m_species[0])].attrExists(m_symbolName)) 
        throw gError("TripletCalculator::setup", ": Symbol " + m_symbolName + " is already existing for species '" + m_species[0] + "'. Second definition is not allowed for overwrite = \"no\"");

      if(Particle::s_tag_format[M_MANAGER->getColour(m_species[1])].attrExists(m_symbolName)) 
        throw gError("TripletCalculator::setup", ": Symbol " + m_symbolName + " is already existing for species '" + m_species[1] + "'. Second definition is not allowed for overwrite = \"no\"");

      if(Particle::s_tag_format[M_MANAGER->getColour(m_species[2])].attrExists(m_symbolName)) 
        throw gError("TripletCalculator::setup", ": Symbol " + m_symbolName + " is already existing for species '" + m_species[2] + "'. Second definition is not allowed for overwrite = \"no\"");


       MSG_DEBUG("TripletCalculator::setup", "adding symbol with name " << m_symbolName);
      
      // see CONVENTION5 for rule about persistencies
      m_slots[0] = Particle::s_tag_format[M_MANAGER->getColour(m_species[0])].addAttribute(m_symbolName, m_datatype, /*persist.first*/false, m_symbolName).offset;
  
      if(m_species[0] != m_species[1])
      {
        // see CONVENTION5 for rule about persistencies
	m_slots[1] = Particle::s_tag_format[M_MANAGER->getColour(m_species[1])].addAttribute(m_symbolName, m_datatype, /*persist.first*/false, m_symbolName).offset;
      }
      else m_slots[1] = m_slots[0];

      if(m_species[2] == m_species[0])
	m_slots[2] = m_slots[0];
      else if(m_species[2] == m_species[1])
	m_slots[2] = m_slots[1];
      else
        // see CONVENTION5 for rule about persistencies
	m_slots[2] = Particle::s_tag_format[M_MANAGER->getColour(m_species[2])].addAttribute(m_symbolName, m_datatype, /*persist.first*/false, m_symbolName).offset;

    } // end of else of if(m_overwrite == false)        
    
    if(m_phaseUser == 0)    
      M_PHASE->registerBondedCalc_0(this);
    else if(m_phaseUser == 1)    
      M_PHASE->registerBondedCalc(this);
    else // so it is 2
    {
      TripletCalculator* vc = copyMySelf();
      assert(((TripletCalculator*) vc)->m_symbolName == m_symbolName);
      assert(vc->stage() == m_stage);
      assert(((TripletCalculator*) vc)->m_slots[0] == m_slots[0]);
      assert(((TripletCalculator*) vc)->m_slots[1] == m_slots[1]);
      assert(((TripletCalculator*) vc)->m_slots[2] == m_slots[2]);
      assert(((TripletCalculator*) vc)->m_parent == m_parent);
      assert(((TripletCalculator*) vc)->m_overwrite == m_overwrite);
      assert(((TripletCalculator*) vc)->m_species[0] == m_species[0]);
      assert(((TripletCalculator*) vc)->m_species[1] == m_species[1]);
      assert(((TripletCalculator*) vc)->m_species[2] == m_species[2]);
        
      MSG_DEBUG("TripletCalculator::setup", ": registering copy.");    
       
      M_PHASE->registerBondedCalc(vc);
      M_PHASE->registerBondedCalc_0(this);
    }
}
Пример #30
0
void BoundaryObstacle::setup()
{
  int v0, v1, v2, v3, v4, v5, v6, v7;

  BoundaryCuboid::setup();

  // consistency check
  double upperObstcl, lowerObstcl;
  for(size_t i = 0; i < SPACE_DIMS; ++i)
    {
      upperObstcl = m_obstacle_center[i] + m_obstacle_size[i]/2;
      lowerObstcl = m_obstacle_center[i] - m_obstacle_size[i]/2;
      /*    MSG_DEBUG("BoundaryObstacle::setup", "upperObstcl=" << upperObstcl << ", lowerObstcl=" << lowerObstcl << ", m_box_size[i]=" << m_box_size[i]);*/
      if(upperObstcl > m_box_size[i] || lowerObstcl < 0)
	throw gError("BoundaryObstacle::setup", "Obstacle exceeds the box in " 
		     + string(1, 'x'+1) + "-direction");
    }
    
  ADDVERTEX(v0, 
	    m_obstacle_center.x - m_obstacle_size.x/2, 
	    m_obstacle_center.y - m_obstacle_size.y/2, 
	    m_obstacle_center.z - m_obstacle_size.z/2);
  ADDVERTEX(v1, 
	    m_obstacle_center.x + m_obstacle_size.x/2, 
	    m_obstacle_center.y - m_obstacle_size.y/2, 
	    m_obstacle_center.z - m_obstacle_size.z/2);
  ADDVERTEX(v2, 
	    m_obstacle_center.x + m_obstacle_size.x/2, 
	    m_obstacle_center.y + m_obstacle_size.y/2, 
	    m_obstacle_center.z - m_obstacle_size.z/2);
  ADDVERTEX(v3, 
	    m_obstacle_center.x - m_obstacle_size.x/2, 
	    m_obstacle_center.y + m_obstacle_size.y/2, 
	    m_obstacle_center.z - m_obstacle_size.z/2);

  ADDVERTEX(v4, 
	    m_obstacle_center.x - m_obstacle_size.x/2, 
	    m_obstacle_center.y - m_obstacle_size.y/2, 
	    m_obstacle_center.z + m_obstacle_size.z/2);
  ADDVERTEX(v5, 
	    m_obstacle_center.x + m_obstacle_size.x/2, 
	    m_obstacle_center.y - m_obstacle_size.y/2, 
	    m_obstacle_center.z + m_obstacle_size.z/2);
  ADDVERTEX(v6, 
	    m_obstacle_center.x + m_obstacle_size.x/2, 
	    m_obstacle_center.y + m_obstacle_size.y/2, 
	    m_obstacle_center.z + m_obstacle_size.z/2);
  ADDVERTEX(v7, 
	    m_obstacle_center.x - m_obstacle_size.x/2, 
	    m_obstacle_center.y + m_obstacle_size.y/2, 
	    m_obstacle_center.z + m_obstacle_size.z/2);

  ADDRECT(v2, v6, v5, v1, m_reflector_str[0]);
  ADDRECT(v4, v7, v3, v0, m_reflector_str[0]);

  ADDRECT(v1, v5, v4, v0, m_reflector_str[1]);
  ADDRECT(v7, v6, v2, v3, m_reflector_str[1]);

  ADDRECT(v3, v2, v1, v0, m_reflector_str[2]);
  ADDRECT(v5, v6, v7, v4, m_reflector_str[2]);

  m_container->updateBoundingBox();
	
  MSG_DEBUG("BoundaryObstacle::read", "box: " << m_container->boundingBox().corner1 << " - " << m_container->boundingBox().corner2);
}