当前位置: 首页>>代码示例>>C++>>正文


C++ ConfigurationPtr类代码示例

本文整理汇总了C++中ConfigurationPtr的典型用法代码示例。如果您正苦于以下问题:C++ ConfigurationPtr类的具体用法?C++ ConfigurationPtr怎么用?C++ ConfigurationPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了ConfigurationPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: c

bool SAXConfigurationHandler::startElement ( const QString & namespaceURI, 
        const QString & localName, const QString & qName, 
        const QXmlAttributes & atts ) {
    int idx = qName.find ( ':' );
    QString prefix = "";
    if ( idx > 0 ) {
        prefix = qName.left ( idx );
    }
    ConfigurationPtr c(new DefaultConfiguration( localName, 
            getLocationString(), namespaceURI, prefix ));

    // if processing the toplevel item simply push it, otherwise link it
    // with the parent
    if( d->configuration.isNull() ) {
        d->configuration = c;
    } else {
        ConfigurationPtr parent = d->elements.top();
        parent->addChild( c );
    }

    // process attributes
    for( int i = 0; i < atts.length(); i ++ ) {
        c->setAttribute( atts.localName( i ), atts.value( i ) );
    }

    // push currently built configuration to the stack
    d->elements.push( c );

    return true;
}
开发者ID:acassis,项目名称:lintouch,代码行数:30,代码来源:SAXConfigurationHandler.cpp

示例2: debug

void	InstrumentTest::testInstrument() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testInstrument() begin");
	ConfigurationPtr	config = Configuration::get(dbfilename);
	Database	database = config->database();

	// create an instrument
	Instrument	instrument(database, "BLUBB");

	// add a few components
	InstrumentComponentPtr	camera = InstrumentComponentPtr(
		new InstrumentComponentDirect(DeviceName::Camera,
			DeviceName("camera:simulator/camera"), 7, "localhost"));
	instrument.add(camera);
	InstrumentComponentPtr	ccd = InstrumentComponentPtr(
		new InstrumentComponentDerived(DeviceName::Ccd,
			instrument, DeviceName::Camera, 5));
	instrument.add(ccd);

	// check instrument
	CPPUNIT_ASSERT(instrument.name() == "BLUBB");

	// has method
	debug(LOG_DEBUG, DEBUG_LOG, 0, "test 'has' method");
	CPPUNIT_ASSERT(instrument.has(DeviceName::Camera));
	CPPUNIT_ASSERT(instrument.has(DeviceName::Ccd));

	// component_type method
	debug(LOG_DEBUG, DEBUG_LOG, 0, "test 'component_type' method");
	CPPUNIT_ASSERT(instrument.component_type(DeviceName::Camera)
		== InstrumentComponent::direct);
	CPPUNIT_ASSERT(instrument.component_type(DeviceName::Ccd)
		== InstrumentComponent::derived);

	// devicename method
	debug(LOG_DEBUG, DEBUG_LOG, 0, "test 'devicename' method");
	CPPUNIT_ASSERT(instrument.devicename(DeviceName::Camera)
		== DeviceName("camera:simulator/camera"));
	debug(LOG_DEBUG, DEBUG_LOG, 0, "ccd device: %s",
		instrument.devicename(DeviceName::Ccd).toString().c_str());
	CPPUNIT_ASSERT(instrument.devicename(DeviceName::Ccd)
		== DeviceName("camera:simulator/camera"));

	// name method
	debug(LOG_DEBUG, DEBUG_LOG, 0, "test 'name' method");
	debug(LOG_DEBUG, DEBUG_LOG, 0, "name(camera) = %s",
		instrument.name(DeviceName::Camera).c_str());
	CPPUNIT_ASSERT(instrument.name(DeviceName::Camera)
		== DeviceName("camera:simulator/camera").toString());

	debug(LOG_DEBUG, DEBUG_LOG, 0, "name(ccd) = %s",
		instrument.name(DeviceName::Ccd).c_str());
	CPPUNIT_ASSERT(instrument.name(DeviceName::Ccd) == "camera");

	// unit method
	debug(LOG_DEBUG, DEBUG_LOG, 0, "test 'unit' method");
	CPPUNIT_ASSERT(instrument.unit(DeviceName::Camera) == 7);
	CPPUNIT_ASSERT(instrument.unit(DeviceName::Ccd) == 5);
	
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testInstrument() end");
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:60,代码来源:InstrumentTest.cpp

示例3:

	BulkPipe::BulkPipe(DevicePtr device, ConfigurationPtr conf, InterfacePtr interface, EndpointPtr in, EndpointPtr out, EndpointPtr interrupt, ITokenPtr claimToken):
		_device(device), _conf(conf), _interface(interface), _in(in), _out(out), _interrupt(interrupt), _claimToken(claimToken)
	{
		int currentConfigurationIndex = _device->GetConfiguration();
		if (conf->GetIndex() != currentConfigurationIndex)
			_device->SetConfiguration(conf->GetIndex());
	}
开发者ID:Ilya87,项目名称:android-file-transfer-linux,代码行数:7,代码来源:BulkPipe.cpp

示例4: debug

void	ConfigurationTest::testConfiguration() {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testConfiguration() begin");
	ConfigurationPtr	configuration
		= Configuration::get("configtest.db");
	configuration->set("global", ".", "name1", "value1");
	configuration->set("global", ".", "name2", "value2");
	debug(LOG_DEBUG, DEBUG_LOG, 0, "testConfiguration() end");
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:8,代码来源:ConfigurationTest.cpp

示例5: checkException

    //_______________________________________________________
    bool ExceptionListWidget::checkException( ConfigurationPtr exception )
    {

        while( exception->exceptionPattern().isEmpty() || !QRegExp( exception->exceptionPattern() ).isValid() )
        {

            KMessageBox::error( this, i18n("Regular Expression syntax is incorrect") );
            QPointer<ExceptionDialog> dialog( new ExceptionDialog( this ) );
            dialog->setException( exception );
            if( dialog->exec() == QDialog::Rejected )
            {
                delete dialog;
                return false;
            }

            dialog->save();
            delete dialog;
        }

        return true;
    }
开发者ID:KDE,项目名称:oxygen-transparent,代码行数:22,代码来源:oxygenexceptionlistwidget.cpp

示例6: SaveConfiguration

void MainWindow::SaveConfiguration()
{
    try {
        int selected = ui->cbConfiguration->currentIndex();
        if(selected <= 0) throw std::runtime_error("You cannot save over the default configuration.");
        m_server.SaveConfiguration(m_configuration,m_configList[selected - 1]);

        // reload configurations for each device
        Server::DeviceList devices;
        m_server.GetDeviceList(&devices);
        for(Server::DeviceList::iterator device = devices.begin(); device != devices.end(); ++device)
        {
            ConfigurationPtr config = (*device)->GetConfiguration();
            if(config && config->GetName() == m_configList[selected - 1]) {
                (*device)->SetConfiguration(m_server.LoadConfiguration(m_configList[selected - 1]));
            }
        }

        QMessageBox::information(this,"","Configuration saved.");
    } catch(const std::runtime_error& e) {
        QMessageBox::critical(this,"Error creating configuration.",e.what());
    }
}
开发者ID:duckinator,项目名称:wifipad,代码行数:23,代码来源:MainWindow.cpp

示例7: throw

/**
 * \brief Get a list of interface association Descriptors from the device
 */
std::list<USBDescriptorPtr>	Device::interfaceAssociationDescriptors(
					bool videoonly) throw(USBError) {
	std::list<USBDescriptorPtr>	iadescriptors;

	// see whether there is any additional data that could contain
	// an interface association descriptor
	ConfigurationPtr	config = activeConfig();
	if (config->extra().size() == 0) {
		debug(LOG_DEBUG, DEBUG_LOG, 0, "no data for descriptors");
		return iadescriptors;
	}

	// try to parse additional descriptors
	DescriptorFactory	f(*this);
	std::vector<USBDescriptorPtr>	list = f.descriptors(config->extra());
	debug(LOG_DEBUG, DEBUG_LOG, 0, "found %d additional descriptors",
		list.size());

	// no check whether they are InterfaceAssociationDescriptors
	std::vector<USBDescriptorPtr>::const_iterator	i;
	for (i = list.begin(); i != list.end(); i++) {
		USBDescriptorPtr	dp = *i;
		if (isPtr<InterfaceAssociationDescriptor>(dp)) {
			InterfaceAssociationDescriptor	*iad
				= getPtr<InterfaceAssociationDescriptor>(dp);
			bool	isvideo = iad->isVideoInterfaceCollection();
			debug(LOG_DEBUG, DEBUG_LOG, 0, "isvideo = %s",
				(isvideo) ? "YES" : "NO");
			if ((!videoonly) || (isvideo)) {
				iadescriptors.push_back(dp);
			}
		}
	}

	// return all the interface association descriptors we have found
	return iadescriptors;
}
开发者ID:felipebetancur,项目名称:AstroPhotography-2,代码行数:40,代码来源:USBDevice.cpp

示例8: testSerializeToFile

    void testSerializeToFile () {
        DefaultConfigurationBuilder builder;
        DefaultConfigurationSerializer serializer;
        ConfigurationPtr cg;
        ConfigurationPtr cb;
        QString cge, cbe;
        int cgl, cgc, cbl, cbc;

        //construct good configuration
        cg = builder.buildFromFile( 
                srcdir + "/tests/test_config.xml", 
                cge, cgl, cgc, false );
        CPPUNIT_ASSERT_MESSAGE( 
                QString("%1 at line %2 column %3")
                .arg( cge ).arg( cgl ).arg( cgc ).latin1(), 
                cg );

        CPPUNIT_ASSERT ( 
                cg->setAttribute ( "escaped", "<>&\"'" ) != false );

        CPPUNIT_ASSERT ( serializer.serializeToFile (
                    builddir + "/serialized_config.xml", cg ) );

        //reconstruct good configuration from new file
        cb = builder.buildFromFile( 
                builddir + "/serialized_config.xml", cbe, cbl, cbc );
        CPPUNIT_ASSERT_MESSAGE( 
                QString("%1 at line %2 column %3")
                .arg( cbe ).arg( cbl ).arg( cbc ).latin1(), 
                cb );

        CPPUNIT_ASSERT ( cb->getAttribute ( "escaped" ) == "<>&\"'" );

        // compare both configs
        CPPUNIT_ASSERT ( cg->getName () == cb->getName () );
        // TODO: compare structure
    }
开发者ID:acassis,项目名称:lintouch,代码行数:37,代码来源:TestDefaultConfigurationSerializer.cpp

示例9: FaceContactErrorCalculator

 FaceContactErrorCalculator(ConfigurationPtr config, const Face& faceA, const Face& faceB) :
   m_config(config), m_faceA(faceA), m_faceB(faceB), m_nDof(m_config->GetDOF()) {}
开发者ID:Hongxiao321321,项目名称:trajopt-1,代码行数:2,代码来源:pushing.cpp

示例10: characters

bool SAXConfigurationHandler::characters ( const QString & ch ) {
    //qDebug( "got characters: `%s'", ch.latin1() );
    ConfigurationPtr c = d->elements.top();
    c->setValue( c->getValue() + ch );
    return true;
}
开发者ID:acassis,项目名称:lintouch,代码行数:6,代码来源:SAXConfigurationHandler.cpp

示例11: main

/**
 * \brief Main function for the snowfocus program
 */
int	main(int argc, char *argv[]) {
	snowstar::CommunicatorSingleton	cs(argc, argv);

	std::string	instrumentname;
	int	steps = 10;
	double	exposuretime = 1.0;
	double	temperature = std::numeric_limits<double>::quiet_NaN();
	std::string	binning;
	std::string	frame;
	std::string	filtername;
	astro::focusing::Focusing::method_type	method
		= astro::focusing::Focusing::FWHM;

	int	c;
	int	longindex;
	while (EOF != (c = getopt_long(argc, argv, "b:c:de:f:hi:m:r:t:",
		longopts, &longindex)))
		switch (c) {
		case 'b':
			binning = optarg;
			break;
		case 'c':
			astro::config::Configuration::set_default(optarg);
			break;
		case 'd':
			debuglevel = LOG_DEBUG;
			break;
		case 'e':
			exposuretime = std::stod(optarg);
			break;
		case 'f':
			filtername = optarg;
			break;
		case 'h':
			usage(argv[0]);
			return EXIT_SUCCESS;
		case 'i':
			instrumentname = optarg;
			break;
		case 'm':
			method = astro::focusing::Focusing::string2method(optarg);
			break;
		case 'r':
			frame = optarg;
			break;
		case 's':
			steps = std::stoi(optarg);
			break;
		case 't':
			temperature = std::stod(optarg);
			break;
		}

	// the next argument is the command
	if (argc <= optind) {
		throw std::runtime_error("not enough arguments");
	}
	std::string	command = argv[optind++];
	debug(LOG_DEBUG, DEBUG_LOG, 0, "command: %s", command.c_str()); 
	if (command == "help") {
		usage(argv[0]);
		return EXIT_SUCCESS;
	}


	// get the configuration
	ConfigurationPtr	config = Configuration::get();

	// check whether we have an instrument
	if (0 == instrumentname.size()) {
		throw std::runtime_error("instrument name not set");
	}
	RemoteInstrument	instrument(config->database(),
						instrumentname);
	// get the device names
	CcdPrx	ccdprx = instrument.ccd_proxy();
	std::string	ccdname = ccdprx->getName();
	FocuserPrx	focuserprx = instrument.focuser_proxy();
	std::string	focusername = focuserprx->getName();
	debug(LOG_DEBUG, DEBUG_LOG, 0, "ccd: %s focuser: %s", ccdname.c_str(),
		focusername.c_str());

	// first get a connection to the server
	Ice::CommunicatorPtr	ic = CommunicatorSingleton::get();
	astro::ServerName	servername
		= instrument.servername(astro::DeviceName::Ccd);
	Ice::ObjectPrx	base = ic->stringToProxy(
				servername.connect("FocusingFactory"));
	FocusingFactoryPrx	focusingfactory
		= FocusingFactoryPrx::checkedCast(base);

	// get the focusing interface
	FocusingPrx	focusing = focusingfactory->get(ccdname, focusername);
	debug(LOG_DEBUG, DEBUG_LOG, 0, "got a focusing proxy");

	// creating a callback
	Ice::ObjectPtr	callback = new FocusCallbackI();
//.........这里部分代码省略.........
开发者ID:felipebetancur,项目名称:AstroPhotography-2,代码行数:101,代码来源:snowfocus.cpp

示例12: throw

/**
 * \brief Construct a camera from a USB Device
 *
 * The constructor undertakes an extensive analysis of the descriptors
 * to find the video control and video streaming interfaces of the video
 * function of the device. It also makes sure no kernel driver is attached
 * to the device. It does not, however, claim any of the interfaces, this
 * is done when the device is really used.
 * \param _device	an USB device to open as a UVC camera
 * \param force		force opening as camera even if the
 *			interface associaten descriptor does not
 *			declare itself as a video interface association
 *                      descriptor (handles the TIS camera)
 * XXX apparently the force parameter is never used, so the question should be
 *     asked whether we can remove it.
 */
UVCCamera::UVCCamera(Device& _device, bool /* force */) throw(USBError)
	: device(_device) {
	debug(LOG_DEBUG, DEBUG_LOG, 0, "create a UVC camera object");

	// make sure the camera is open, this most probably will not have
	// any effect
	device.open();

	// scan the active configuration for one that has an Interface
	// association descriptor
	ConfigurationPtr config = device.activeConfig();
	if (config->extra().size() == 0) {
		debug(LOG_ERR, DEBUG_LOG, 0, "no extra descriptors");
		throw USBError("no InterfaceAssociationDescriptor");
	}

	// get the list of interface association descriptors
	std::list<USBDescriptorPtr>	iadlist
		= device.interfaceAssociationDescriptors(true);
	if (0 == iadlist.size()) {
		throw USBError("no Video Interface Association found");
	}
	iadptr = *iadlist.begin();
	debug(LOG_DEBUG, DEBUG_LOG, 0, "Video Interface Association found");

	// get the control interface, and the list of interface descriptors
	// for the control interface, and claim it
	uint8_t	ci = controlInterfaceNumber();
	videocontrol = (*config)[ci];
	debug(LOG_DEBUG, DEBUG_LOG, 0, "Control interface number: %d", ci);
	videocontrol->detachKernelDriver();

	// we also need to know all the video control descriptors appended
	// to this InterfaceDescriptor. The VideoControlDescriptorFactory
	// does that.
	debug(LOG_DEBUG, DEBUG_LOG, 0, "parse the video control descriptors");
	InterfaceDescriptorPtr	controlinterface = (*videocontrol)[0];
	VideoControlDescriptorFactory	vcdf(device);
	videocontroldescriptors = vcdf.descriptors(controlinterface->extra());
	std::cout << videocontroldescriptors[0];
	
	// now claim get the various interface descriptors, i.e. the
	// alternate settings for an interface
	int	interfacecount = iad().bInterfaceCount();
	debug(LOG_DEBUG, DEBUG_LOG, 0, "interfaces in association: %d",
		interfacecount);

	// now parse the video streaming interfaces
	debug(LOG_DEBUG, DEBUG_LOG, 0, "parse streaming interface descriptors");
	VideoStreamingDescriptorFactory	vsf(device);
	for (int vsif = controlInterfaceNumber() + 1;
		vsif < controlInterfaceNumber() + iad().bInterfaceCount();
		vsif++) {
		debug(LOG_DEBUG, DEBUG_LOG, 0,
			"analyzing video streaming interface %d", vsif);
		InterfacePtr	interface = (*config)[vsif];
		// only alternate setting 0 contains the formats
		InterfaceDescriptorPtr	id = (*interface)[0];
		std::string	extra = id->extra();
		debug(LOG_DEBUG, DEBUG_LOG, 0, "extra descriptors: %d bytes",
			extra.size());
		USBDescriptorPtr	vsd = vsf.descriptor(extra);
		debug(LOG_DEBUG, DEBUG_LOG, 0, "parse complete");
		videostreaming.push_back(vsd);
	}
	debug(LOG_DEBUG, DEBUG_LOG, 0, "UVCCamera constructed");
}
开发者ID:AndreasFMueller,项目名称:AstroPhotography,代码行数:83,代码来源:UVCCamera.cpp

示例13: getSystemRef

    void ConfigsParticleDecomp::gather() {
      System& system = getSystemRef();
      esutil::Error err(system.comm);
      
      int nprocs = system.comm->size();
      int myrank = system.comm->rank();
      
      int localN = system.storage->getNRealParticles();
      
      int curNumP = 0;
      boost::mpi::all_reduce(*system.comm, localN, curNumP, std::plus<int>());
      if(myrank==0){
        // check whether the number of particles is the same during the gathering
        if( curNumP != num_of_part ){
          stringstream msg;
          msg<<"   ConfigsParticleDecomp gathers the configurations of the same system\n"
                " with the same number of particles. If you need to store the systems\n"
                " with different number of particles you should use something else."
                " E.g `Configurations`";
          err.setException( msg.str() );
        }
      }

      ConfigurationPtr config = make_shared<Configuration> ();
      for (int rank_i=0; rank_i<nprocs; rank_i++) {
        map< size_t, Real3D > conf;
        if (rank_i == myrank) {
          CellList realCells = system.storage->getRealCells();
          for(CellListIterator cit(realCells); !cit.isDone(); ++cit) {
            int id = cit->id();
            Real3D property = Real3D(0,0,0);
            if(key=="position")
              property = cit->position();
            else if(key=="velocity")
              property = cit->velocity();
            else if(key=="unfolded"){
              Real3D& pos = cit->position();
              Int3D& img = cit->image();
              Real3D Li = system.bc->getBoxL();
              for (int i = 0; i < 3; ++i) property[i] = pos[i] + img[i] * Li[i];
            }
            else{
              stringstream msg;
              msg<<"Error. Key "<<key<<" is unknown. Use position, unfolded or"
                      " velocity.";
              err.setException( msg.str() );
            }
            
            conf[id] = property;
          }
    	}

        boost::mpi::broadcast(*system.comm, conf, rank_i);

        for (map<size_t,Real3D>::iterator itr=conf.begin(); itr != conf.end(); ++itr) {
          size_t id = itr->first;
          Real3D p = itr->second;
          if(idToCpu[id]==myrank) config->set(id, p[0], p[1], p[2]);
        }
      }

      pushConfig(config);
    }
开发者ID:pgemuende,项目名称:espressopp,代码行数:63,代码来源:ConfigsParticleDecomp.cpp

示例14: getSystemRef

    void Configurations::gather() {

      System& system = getSystemRef();
  
      // determine number of local particles and total particles

      int myN = system.storage->getNRealParticles();
      int maxN;   // maximal number of particles one processor has
      int totalN; // totlal number of particles all processors have

      boost::mpi::all_reduce(*system.comm, myN, maxN, boost::mpi::maximum<int>());
      boost::mpi::all_reduce(*system.comm, myN, totalN, std::plus<int>());

      LOG4ESPP_INFO(logger, "#Partices: me = " << myN << ", max = " << maxN
                            << ", totalN = " << totalN);

      int*  ids         = new int [maxN];  // buffer for gather
      Real3D* coordinates;
      Real3D* velocities;
      Real3D* forces;
      real* radii;

      if (gatherPos)    coordinates = new Real3D [maxN];  // buffer for gather
      if (gatherVel)    velocities  = new Real3D [maxN];  // buffer for gather
      if (gatherForce)  forces      = new Real3D [maxN];  // buffer for gather
      if (gatherRadius) radii       = new real [maxN];  // buffer for gather

      // fill the buffer with my values

      CellList realCells = system.storage->getRealCells();

      int i = 0; 
      for(CellListIterator cit(realCells); !cit.isDone(); ++cit) {
        ids[i] = cit->id();
        if (gatherPos) {
          Real3D pos = cit->position();
          Int3D img = cit->image();
          if (folded)
        	system.bc->foldPosition(pos, img);
          else
        	system.bc->unfoldPosition(pos, img);
          coordinates[i] = pos;
        }
        if (gatherVel)    velocities[i]  = cit->velocity();
        if (gatherForce)  forces[i]      = cit->force();
        if (gatherRadius) radii[i]       = cit->radius();
        i++;
      }

      if (i != myN) {
        LOG4ESPP_ERROR(logger, "mismatch for number of local particles");
      }

      // each proc sends its data to master process

      if (system.comm->rank() == 0) {

         ConfigurationPtr config = make_shared<Configuration> (); //totalN

         // root process collects data from all processors and sets it

         int nproc = system.comm->size();

         for (int iproc = 0; iproc < nproc; iproc++) {
           int nother;
           if (iproc) {
              int nIds, nVals;   // number of received values
              int tmp;
              boost::mpi::request req;
              boost::mpi::status  stat;
              LOG4ESPP_DEBUG(logger, "receive tags from " << iproc);
              req = system.comm->irecv<int>(iproc, DEFAULT_TAG, ids, maxN);
              system.comm->send(iproc, DEFAULT_TAG, 0);
              stat = req.wait();
              nIds = *stat.count<int>();
              if (gatherPos) {
                req = system.comm->irecv<Real3D>(iproc, DEFAULT_TAG, coordinates, maxN);
                system.comm->send(iproc, DEFAULT_TAG, 0);
                stat = req.wait();
                nVals = *stat.count<Real3D>();
                if (nVals != nIds) {
                  LOG4ESPP_ERROR(logger, "serious error collecting data, got " <<
                                nIds << " ids, but " << nVals << " coordinates");
                }
              }
              if (gatherVel) {
                req = system.comm->irecv<Real3D>(iproc, DEFAULT_TAG, velocities, maxN);
                system.comm->send(iproc, DEFAULT_TAG, 0);
                stat = req.wait();
                nVals = *stat.count<Real3D>();
                if (nVals != nIds) {
                  LOG4ESPP_ERROR(logger, "serious error collecting data, got " <<
                                nIds << " ids, but " << nVals << " velocities");
                }
              }
              if (gatherForce) {
                req = system.comm->irecv<Real3D>(iproc, DEFAULT_TAG, forces, maxN);
                system.comm->send(iproc, DEFAULT_TAG, 0);
                stat = req.wait();
                nVals = *stat.count<Real3D>();
//.........这里部分代码省略.........
开发者ID:Clemson-MSE,项目名称:espressopp,代码行数:101,代码来源:Configurations.cpp

示例15: getSystemRef

        python::list StaticStructF::computeArraySingleChain(int nqx, int nqy, int nqz,
                real bin_factor, int chainlength) const {
            //fist the system coords are saved at each CPU
            System& system = getSystemRef();
            esutil::Error err(system.comm);
            Real3D Li = system.bc->getBoxL(); //Box size (Lx, Ly, Lz)

            int nprocs = system.comm->size(); // number of CPUs
            int myrank = system.comm->rank(); // current CPU's number

            int num_part = 0;
            ConfigurationPtr config = make_shared<Configuration > ();
            // loop over all CPU-numbers - to give all CPUs all particle coords
            for (int rank_i = 0; rank_i < nprocs; rank_i++) {
                map< size_t, Real3D > conf;
                if (rank_i == myrank) {
                    CellList realCells = system.storage->getRealCells();
                    for (CellListIterator cit(realCells); !cit.isDone(); ++cit) {
                        int id = cit->id();
                        conf[id] = cit->position();
                    }
                }
                boost::mpi::broadcast(*system.comm, conf, rank_i);

                // for simplicity we will number the particles from 0
                for (map<size_t, Real3D>::iterator itr = conf.begin(); itr != conf.end(); ++itr) {
                    size_t id = itr->first;
                    Real3D p = itr->second;
                    config->set(id, p[0], p[1], p[2]);
                    //config->set(num_part, p[0], p[1], p[2]);
                    num_part++;
                }
            }
            cout << "particles are given to each CPU!\n";
            // now all CPUs have all particle coords and num_part is the total number
            // of particles   

            // use all CPUs
            // TODO it could be a problem if   n_nodes > num_part

            // here starts calculation of the static structure factor

            //step size for qx, qy, qz
            real dqs[3];
            dqs[0] = 2. * M_PIl / Li[0];
            dqs[1] = 2. * M_PIl / Li[1];
            dqs[2] = 2. * M_PIl / Li[2];

            Real3D q;

            //calculations for binning
            real bin_size = bin_factor * min(dqs[0], (dqs[1], dqs[2]));
            real q_sqr_max = nqx * nqx * dqs[0] * dqs[0]
                    + nqy * nqy * dqs[1] * dqs[1]
                    + nqz * nqz * dqs[2] * dqs[2];
            real q_max = sqrt(q_sqr_max);
            int num_bins = (int) ceil(q_max / bin_size);
            vector<real> sq_bin;
            vector<real> q_bin;
            vector<int> count_bin;
            sq_bin.resize(num_bins);
            q_bin.resize(num_bins);
            count_bin.resize(num_bins);

            if (myrank == 0) {
                cout << nprocs << " CPUs\n\n"
                        << "bin size \t" << bin_size << "\n"
                        << "q_max    \t" << q_max << "\n";
            }

            real n_reci = 1. / num_part;
            real chainlength_reci = 1. / chainlength;
            real scos_local = 0; //will store cos-sum on each CPU
            real ssin_local = 0; //will store sin-sum on each CPU   
            //will store the summation of the the single chain structure factor
            real singleChain_localSum = 0;
            Real3D coordP;
            python::list pyli;

            //calculations for parallelizing (over chains)
            int num_chains;
            if (num_part % chainlength == 0)
                num_chains = num_part / chainlength;
            else {
                cout << "ERROR: chainlenght does not match total number of "
                        << "particles. num_part % chainlenght is unequal 0. \n"
                        << "Calculation of SingleChain_StaticStructF aborted\n";
                return pyli;
            }
            int cpp = (int) ceil((double) num_chains / nprocs); //chains per proc
            cout << "chains per proc\t" << cpp << "\n";


            //loop over different q values
            //starting from zero because combinations with negative components 
            //will give the same result in S(q). so S(q) is the same for
            //the 8 vectors q=(x,y,z),(-x,y,z), (x,-y,z),(x,y,-z),(-x,-y,z),...
            for (int hx = -nqx; hx <= nqx; hx++) {
                for (int hy = -nqy; hy <= nqy; hy++) {
                    for (int hz = 0; hz <= nqz; hz++) {
//.........这里部分代码省略.........
开发者ID:Clemson-MSE,项目名称:espressopp,代码行数:101,代码来源:StaticStructF.cpp


注:本文中的ConfigurationPtr类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。