本文整理汇总了C++中StringT::Suffix方法的典型用法代码示例。如果您正苦于以下问题:C++ StringT::Suffix方法的具体用法?C++ StringT::Suffix怎么用?C++ StringT::Suffix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringT
的用法示例。
在下文中一共展示了StringT::Suffix方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: atoi
/* construct extracting dimensions from the name */
MatrixParameterT::MatrixParameterT(const StringT& name_NxM, char variable):
ParameterInterfaceT(name_NxM),
fVariable(variable),
fCopySymmetric(false)
{
const char caller[] = "MatrixParameterT::MatrixParameterT";
const char msg[] = "could not extract %s dimensions from \"%s\" in \"%s\"";
/* resolve suffix */
StringT suffix;
suffix.Suffix(name_NxM, '_');
if (suffix.StringLength() < 4)
ExceptionT::GeneralFail(caller, msg, "matrix", suffix.Pointer(), name_NxM.Pointer());
/* resolve column dimensions */
StringT num;
num.Suffix(suffix, 'x');
if (num.StringLength() < 2 || !isdigit(num[1]))
ExceptionT::GeneralFail(caller, msg, "col", num.Pointer(), name_NxM.Pointer());
int col = -1;
col = atoi(num.Pointer(1));
if (col < 0)
ExceptionT::GeneralFail(caller, msg, "col", num.Pointer(), name_NxM.Pointer());
/* resolve row dimensions */
suffix.Root('x');
if (suffix.StringLength() < 2 || !isdigit(suffix[1]))
ExceptionT::GeneralFail(caller, msg, "row", suffix.Pointer(), name_NxM.Pointer());
int row = -1;
row = atoi(suffix.Pointer(1));
if (row < 0)
ExceptionT::GeneralFail(caller, msg, "row", suffix.Pointer(), name_NxM.Pointer());
/* initialize */
fMatrix.Dimension(row, col);
fMatrix = 0.0;
}
示例2: Open
bool TextInputT::Open (const StringT& filename)
{
/* create file root */
StringT suffix;
suffix.Suffix (filename.Pointer());
if (strncmp (suffix.Pointer(), ".geo", 4) == 0 ||
strncmp (suffix.Pointer(), ".run", 4) == 0 ||
strncmp (suffix.Pointer(), ".in", 3) == 0)
fFileRoot.Root (filename);
fFilePath.FilePath(fFileRoot);
/* scan geometry file */
ifstreamT geo;
if (!OpenFile (geo, ".geo")) {
cout << "\n TextInputT::Open: error opening geometry file: " << geo.filename() << endl;
return false;
}
if (!ScanGeometryFile (geo)) {
cout << "\n TextInputT::Open: error scanning geometry file: " << geo.filename() << endl;
return false;
}
/* scan results file */
ifstreamT run;
if (!OpenFile (run, ".run")) {
cout << "\n TextInputT::Open: error opening results file: " << run.filename() << endl;
return false;
}
if (!ScanResultsFile (run)) {
cout << "\n TextInputT::Open: error scanning results file: " << run.filename() << endl;
return false;
}
/* must be OK */
return true;
}
示例3: TakeParameterList
/* accept parameter list */
void ThermomechanicalCouplingManagerT::TakeParameterList(const ParameterListT& list)
{
const char caller[] = "ThermomechanicalCouplingManagerT::TakeParameterList";
/* inherited */
// MultiManagerT::TakeParameterList(list);
/* inherited - don't call direct base class method */
ParameterInterfaceT::TakeParameterList(list);
/* path to parameters file */
StringT path;
path.FilePath(fInputFile);
TaskT task = kRun;
/* parse/validate continuum input */
StringT continuum_input = list.GetParameter("continuum_input");
continuum_input.ToNativePathName();
continuum_input.Prepend(path);
ParameterListT continuum_params;
ParseInput(continuum_input, continuum_params, true, true, true, fArgv);
/* construct continuum solver */
if (fCoarseComm->Size() != 1)
ExceptionT::GeneralFail(caller, "parallel execution error");
if (Size() > 1) /* change file name so output files are unique */ {
StringT suffix;
suffix.Suffix(continuum_input);
continuum_input.Root();
continuum_input.Append(".p", Rank());
continuum_input.Append(suffix);
}
StringT continuum_output_file;
continuum_output_file.Root(continuum_input);
continuum_output_file.Append(".out");
fCoarseOut.open(continuum_output_file);
fCoarse = TB_DYNAMIC_CAST(FEManagerT_bridging*, FEManagerT::New(continuum_params.Name(), continuum_input, fCoarseOut, *fCoarseComm, fArgv, task));
if (!fCoarse) ExceptionT::GeneralFail(caller, "could not construct continuum solver");
fCoarse->TakeParameterList(continuum_params);
/* parse/validate atomistic input */
StringT atom_input = list.GetParameter("atom_input");
atom_input.ToNativePathName();
atom_input.Prepend(path);
ParameterListT atom_params;
ParseInput(atom_input, atom_params, true, true, true, fArgv);
/* construct atomistic solver */
if (Size() != fFineComm->Size())
ExceptionT::GeneralFail(caller, "parallel execution error");
StringT atom_output_file;
atom_output_file.Root(atom_input);
if (Size() > 1) atom_output_file.Append(".p", Rank());
atom_output_file.Append(".out");
fFineOut.open(atom_output_file);
fFine = TB_DYNAMIC_CAST(FEManagerT_bridging*, FEManagerT::New(atom_params.Name(), atom_input, fFineOut, *fFineComm, fArgv, task));
if (!fFine) ExceptionT::GeneralFail(caller, "could not construct atomistic solver");
fFine->TakeParameterList(atom_params);
/* check consistency between time managers */
TimeManagerT* atom_time = fFine->TimeManager();
TimeManagerT* continuum_time = fCoarse->TimeManager();
/* use parameters from coarse scale solver */
fTimeManager = fCoarse->TimeManager();
fOutputFormat = fCoarse->OutputFormat();
/* don't compute initial conditions */
fFine->SetComputeInitialCondition(false);
fCoarse->SetComputeInitialCondition(false);
/* resolve bridging fields */
const StringT& bridging_field = list.GetParameter("bridging_field");
fFineField = fFine->NodeManager()->Field(bridging_field);
if (!fFineField) ExceptionT::GeneralFail(caller, "could not resolve fine scale \"%s\" field", bridging_field.Pointer());
fCoarseField = fCoarse->NodeManager()->Field(bridging_field);
if (!fFineField) ExceptionT::GeneralFail(caller, "could not resolve coarse scale \"%s\" field", bridging_field.Pointer());
/* resolve integrator types */
// if (fFineField->Integrator().ImplicitExplicit() != fCoarseField->Integrator().ImplicitExplicit())
// ExceptionT::GeneralFail(caller, "time integrator mismatch");
fImpExp = fFineField->Integrator().ImplicitExplicit();
/* collect the ghost atom ID list */
ArrayT<StringT> ghost_atom_ID;
const ParameterListT* ghosts = list.List("ghost_atom_ID_list");
if (ghosts) StringListT::Extract(*ghosts, ghost_atom_ID);
/* configure projection/interpolation */
NodeManagerT& fine_node_manager = *(fFine->NodeManager());
int group = 0;
int order1 = 0;
bool make_inactive = true;
bool node_to_node = false;
fFine->InitGhostNodes(fFineField->FieldName(), ghost_atom_ID, fCoarse->ProjectImagePoints());
fCoarse->InitInterpolation(fFineField->FieldName(), fFine->GhostNodes(), fine_node_manager.InitialCoordinates());
fCoarse->InitProjection(fFineField->FieldName(), *(fFine->CommManager()), fFine->NonGhostNodes(), fine_node_manager, make_inactive, node_to_node);
/* send coarse/fine output through the fFine output */
//.........这里部分代码省略.........