本文整理汇总了C++中Particles::parameters方法的典型用法代码示例。如果您正苦于以下问题:C++ Particles::parameters方法的具体用法?C++ Particles::parameters怎么用?C++ Particles::parameters使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Particles
的用法示例。
在下文中一共展示了Particles::parameters方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
PARTICLES_FIXTURE()
{
testParticles.nParticles(test_nParticles);
testParticles.initializeMatrices();
mat & data = testParticles.data();
mat & r = testParticles.r();
auto & parameters = testParticles.parameters();
parameters["v_x"] = 0;
parameters["v_y"] = 1;
parameters["volume"] = 2;
vec v_x, v_y, volume;
mat _r;
_r << 0.313150 << 0.932484 << 0.731905 << 0.650592 << 0.109496 << 0.532164 << 0.685139 << 0.678746 << 0.384222 << 0.947418 << 0.294880 << arma::endr
<< 0.597834 << 0.519061 << 0.547958 << 0.343276 << 0.449608 << 0.704623 << 0.468903 << 0.390759 << 0.581632 << 0.401296 << 0.368566 << arma::endr;
v_x << 0.165347 << 0.001397 << 0.212907 << 0.529744 << 0.195344 << 0.504753 << 0.236449 << 0.546610 << 0.681405 << 0.665064 << 0.110014;
v_y << 0.265347 << 0.101397 << 0.112907 << 0.329744 << 0.695344 << 0.0504753 << 0.536449 << 0.346610 << 0.168145 << 0.166564 << 0.111014;
volume << 8.76566e-06 << 8.22899e-06 << 8.0501e-06 << 8.31843e-06 << 7.78176e-06 << 6.44008e-06 << 7.33453e-06 << 8.0501e-06 << 8.31843e-06 << 7.0662e-06 << 8.13954e-06 << arma::endr;
r = _r.t();
data.col(parameters["v_x"]) = v_x;
data.col(parameters["v_y"]) = v_y;
data.col(parameters["volume"]) = volume;
unordered_map<int, int> & pIds = testParticles.pIds();
for(int i=0; i<test_nParticles;i++)
{
pIds[i] = i;
}
}
示例2: loadBinaryBody
void LoadParticles::loadBinaryBody(Particles &particles, FILE *rawData,
unordered_map<string, int> parameters) {
particles.maxParticles(m_nParticles);
particles.nParticles(m_nParticles);
particles.totParticles(m_nParticles);
// Storing only non-basic parameters in the parameters
int counter = 0;
vector<pair<int, int>> data_config_mapping;
for (auto param : parameters) {
bool found = false;
for (string basic_parameter : basicParameters) {
if (param.first == basic_parameter) {
found = true;
}
}
if (!found) {
particles.parameters()[param.first] = counter;
data_config_mapping.push_back(pair<int, int>(counter, param.second));
counter++;
}
}
//--------------------------------------------------------------------------
bool idIsset = false;
int idPos = 0;
if (parameters.count("id") > 0) {
idIsset = true;
idPos = parameters["id"];
}
vector<pair<int, int>> position_config;
int dim = 0;
if (parameters.count("x") > 0) {
dim++;
position_config.push_back(pair<int, int>(0, parameters["x"]));
}
if (parameters.count("y") > 0) {
dim++;
position_config.push_back(pair<int, int>(1, parameters["y"]));
}
if (parameters.count("z") > 0) {
dim++;
position_config.push_back(pair<int, int>(2, parameters["z"]));
}
particles.dim(dim);
//--------------------------------------------------------------------------
// Creating the data matrix
particles.initializeMatrices();
int nColumns = m_nColumns;
ivec &idToCol = particles.getIdToCol_v();
arma::ivec &colToId = particles.colToId();
arma::mat &r = particles.r();
arma::mat &data = particles.data();
// Reading all the data from file
for (unsigned int i = 0; i < particles.nParticles(); i++) {
double line[nColumns];
fread(&line[0], nColumns * sizeof(double), 1, rawData);
// Collecting the data
if (idIsset) {
idToCol[int(line[idPos])] = i;
colToId[i] = int(line[idPos]);
} else {
idToCol[i] = i;
colToId[i] = i;
}
for (pair<int, int> pc : position_config) {
r(i, pc.first) = line[pc.second];
}
for (pair<int, int> dfc : data_config_mapping) {
data(i, dfc.first) = line[dfc.second];
}
}
}
示例3: loadBody
void LoadParticles::loadBody(Particles &particles, std::fstream &rawData,
unordered_map<string, int> parameters) {
particles.maxParticles(m_nParticles);
particles.nParticles(m_nParticles);
particles.totParticles(m_nParticles);
string line;
//--------------------------------------------------------------------------
// Storing only non-basic parameters in the parameters
int counter = 0;
vector<pair<int, int>> data_config_mapping;
for (auto param : parameters) {
bool found = false;
for (string basic_parameter : basicParameters) {
if (param.first == basic_parameter) {
found = true;
}
}
if (!found) {
particles.parameters()[param.first] = counter;
data_config_mapping.push_back(pair<int, int>(counter, param.second));
counter++;
}
}
//--------------------------------------------------------------------------
bool idIsset = false;
int idPos = 0;
if (parameters.count("id") > 0) {
idIsset = true;
idPos = parameters["id"];
}
vector<pair<int, int>> position_config;
int dim = 0;
if (parameters.count("x") > 0) {
dim++;
position_config.push_back(pair<int, int>(0, parameters["x"]));
}
if (parameters.count("y") > 0) {
dim++;
position_config.push_back(pair<int, int>(1, parameters["y"]));
}
if (parameters.count("z") > 0) {
dim++;
position_config.push_back(pair<int, int>(2, parameters["z"]));
}
particles.dim(dim);
//--------------------------------------------------------------------------
// Creating the data matrix
particles.initializeMatrices();
ivec &idToCol = particles.getIdToCol_v();
arma::ivec &colToId = particles.colToId();
arma::mat &r = particles.r();
arma::mat &data = particles.data();
// Reading all the data from file
for (unsigned int i = 0; i < particles.nParticles(); i++) {
vector<string> lineSplit;
getline(rawData, line);
boost::trim_if(line, boost::is_any_of("\t "));
boost::split(lineSplit, line, boost::is_any_of("\t "),
boost::token_compress_on);
// Collecting the data
if (idIsset) {
idToCol[stoi(lineSplit[idPos])] = i;
colToId[i] = stoi(lineSplit[idPos]);
} else {
idToCol[i] = i;
colToId[i] = i;
}
for (pair<int, int> pc : position_config) {
r(i, pc.first) = stod(lineSplit[pc.second]);
}
for (pair<int, int> dfc : data_config_mapping) {
data(i, dfc.first) = stod(lineSplit[dfc.second]);
}
}
}