本文整理汇总了C++中Topology::CommonSetup方法的典型用法代码示例。如果您正苦于以下问题:C++ Topology::CommonSetup方法的具体用法?C++ Topology::CommonSetup怎么用?C++ Topology::CommonSetup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Topology
的用法示例。
在下文中一共展示了Topology::CommonSetup方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadTopology
// ParmFile::ReadTopology()
int ParmFile::ReadTopology(Topology& Top, FileName const& fnameIn,
ArgList const& argListIn, int debugIn)
{
if (fnameIn.empty()) {
mprinterr("Error: No input topology name given.\n");
return 1;
}
if (!File::Exists( fnameIn )) {
mprinterr("Error: Topology '%s' does not exist.\n", fnameIn.full());
return 1;
}
parmName_ = fnameIn;
ArgList argIn = argListIn;
ParmFormatType pfType;
ParmIO* parmio = 0;
Top.SetDebug( debugIn );
// Only force bond search when 'bondsearch' is specified.
bool bondsearch = false;
if (argIn.Contains("bondsearch")) {
Top.SetOffset( argIn.getKeyDouble("bondsearch", -1.0) );
bondsearch = true;
}
// 'as' keyword specifies a format
std::string as_arg = argIn.GetStringKey("as");
if (!as_arg.empty()) {
pfType = (ParmFormatType)FileTypes::GetFormatFromString( PF_KeyArray, as_arg, UNKNOWN_PARM );
if (pfType == UNKNOWN_PARM) {
mprinterr("Error: Topology format '%s' not recognized.\n", as_arg.c_str());
return 1;
}
parmio = (ParmIO*)FileTypes::AllocIO( PF_AllocArray, pfType, false );
} else
parmio = DetectFormat( parmName_, pfType );
if (parmio == 0) {
mprinterr("Error: Could not determine format of topology '%s'\n", parmName_.full());
return 1;
}
mprintf("\tReading '%s' as %s\n", parmName_.full(),
FileTypes::FormatDescription(PF_AllocArray, pfType) );
parmio->SetDebug( debugIn );
if (parmio->processReadArgs(argIn)) return 1;
int err = parmio->ReadParm( parmName_.Full(), Top);
// Perform setup common to all parm files.
if (err == 0)
err = Top.CommonSetup(bondsearch || parmio->NeedsBondSearch());
else
mprinterr("Error reading topology file '%s'\n", parmName_.full());
delete parmio;
if (err > 0) return 1;
return 0;
}
示例2: Analyze
//.........这里部分代码省略.........
for (std::vector<DataSet_1D*>::iterator ds = histdata_.begin();
ds != histdata_.end(); ++ds, ++dim, ++bOff)
{
double dval = (*ds)->Dval( n );
// Check if data is out of bounds for this dimension.
if (dval > dim->Max() || dval < dim->Min()) {
index = -1L;
break;
}
// Calculate index for this particular dimension (idx)
long int idx = (long int)((dval - dim->Min()) / dim->Step());
if (debug_>1) mprintf(" [%s:%f (%li)],", dim->label(), dval, idx);
// Calculate overall index in Bins, offset has already been calcd.
index += (idx * (*bOff));
}
// If index was successfully calculated, populate bin
if (index > -1L && index < (long int)Bins_.size()) {
if (debug_ > 1) mprintf(" |index=%li",index);
if (calcAMD_)
Bins_[index] += exp( amddata_->Dval(n) );
else
Bins_[index]++;
} else {
mprintf("\tWarning: Frame %zu Coordinates out of bounds (%li)\n", n+1, index);
}
if (debug_>1) mprintf("}\n");
}
// Calc free energy if requested
if (calcFreeE_) CalcFreeE();
// Normalize if requested
if (normalize_ != NO_NORM) Normalize();
if (nativeOut_) {
// Use Histogram built-in output
PrintBins();
} else {
// Using DataFileList framework, set-up labels etc.
if (N_dimensions_ == 1) {
DataSet_double& dds = static_cast<DataSet_double&>( *hist_ );
// Since Allocate1D only reserves data, use assignment op.
dds = Bins_;
hist_->SetDim(Dimension::X, dimensions_[0]);
} else if (N_dimensions_ == 2) {
DataSet_MatrixDbl& mds = static_cast<DataSet_MatrixDbl&>( *hist_ );
mds.Allocate2D( dimensions_[0].Bins(), dimensions_[1].Bins() );
std::copy( Bins_.begin(), Bins_.end(), mds.begin() );
hist_->SetDim(Dimension::X, dimensions_[0]);
hist_->SetDim(Dimension::Y, dimensions_[1]);
outfile_->ProcessArgs("noxcol usemap nolabels");
} else if (N_dimensions_ == 3) {
DataSet_GridFlt& gds = static_cast<DataSet_GridFlt&>( *hist_ );
//gds.Allocate3D( dimensions_[0].Bins(), dimensions_[1].Bins(), dimensions_[2].Bins() );
gds.Allocate_N_O_D( dimensions_[0].Bins(), dimensions_[1].Bins(), dimensions_[2].Bins(),
Vec3(dimensions_[0].Min(), dimensions_[1].Min(), dimensions_[2].Min()),
Vec3(dimensions_[0].Step(), dimensions_[1].Step(), dimensions_[2].Step())
);
//std::copy( Bins_.begin(), Bins_.end(), gds.begin() );
// FIXME: Copy will not work since in grids data is ordered with Z
// changing fastest. Should the ordering in grid be changed?
size_t idx = 0;
for (size_t z = 0; z < gds.NZ(); z++)
for (size_t y = 0; y < gds.NY(); y++)
for (size_t x = 0; x < gds.NX(); x++)
gds.SetElement( x, y, z, (float)Bins_[idx++] );
hist_->SetDim(Dimension::X, dimensions_[0]);
hist_->SetDim(Dimension::Y, dimensions_[1]);
hist_->SetDim(Dimension::Z, dimensions_[2]);
outfile_->ProcessArgs("noxcol usemap nolabels");
// Create pseudo-topology/trajectory
if (!traj3dName_.empty()) {
Topology pseudo;
pseudo.AddTopAtom(Atom("H3D", 0), Residue("H3D", 1, ' ', ' '));
pseudo.CommonSetup();
if (!parmoutName_.empty()) {
ParmFile pfile;
if (pfile.WriteTopology( pseudo, parmoutName_, ParmFile::UNKNOWN_PARM, 0 ))
mprinterr("Error: Could not write pseudo topology to '%s'\n", parmoutName_.c_str());
}
Trajout_Single out;
if (out.PrepareTrajWrite(traj3dName_, ArgList(), &pseudo, CoordinateInfo(),
Ndata, traj3dFmt_) == 0)
{
Frame outFrame(1);
for (size_t i = 0; i < Ndata; ++i) {
outFrame.ClearAtoms();
outFrame.AddVec3( Vec3(histdata_[0]->Dval(i),
histdata_[1]->Dval(i),
histdata_[2]->Dval(i)) );
out.WriteSingle(i, outFrame);
}
out.EndTraj();
} else
mprinterr("Error: Could not set up '%s' for write.\n", traj3dName_.c_str());
}
}
}
return Analysis::OK;
}