本文整理汇总了C++中Teuchos::getParametersFromXmlString方法的典型用法代码示例。如果您正苦于以下问题:C++ Teuchos::getParametersFromXmlString方法的具体用法?C++ Teuchos::getParametersFromXmlString怎么用?C++ Teuchos::getParametersFromXmlString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Teuchos
的用法示例。
在下文中一共展示了Teuchos::getParametersFromXmlString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sinCosModel
TEUCHOS_UNIT_TEST( Rythmos_DefaultIntegrator, failRampingTimestep )
{
const RCP<SinCosModel> model = sinCosModel(true);
const RCP<TimeStepNonlinearSolver<double> > nonlinearSolver =
timeStepNonlinearSolver<double>();
const RCP<BackwardEulerStepper<double> > beStepper =
backwardEulerStepper<double>(model, nonlinearSolver);
const RCP<MockStepperDecorator<double> > stepper =
createMockStepperDecorator<double>(beStepper);
stepper->setFailOnStepId(3);
stepper->setInitialCondition(model->getNominalValues());
const RCP<DefaultIntegrator<double> > integrator =
defaultIntegrator<double>();
integrator->setIntegrationControlStrategy(
rampingIntegrationControlStrategy<double>(
getParametersFromXmlString(
"<ParameterList name=\"Ramping\">"
" <Parameter name=\"Initial dt\" type=\"double\" value=\"0.2\"/>"
"</ParameterList>"
) ) );
RCP<MockIntegrationObserver<double> > observer =
createMockIntegrationObserver<double>();
{
std::list<std::string> call_stack;
call_stack.push_back(observer->nameResetIntegrationObserver_);
call_stack.push_back(observer->nameObserveStartTimeIntegration_);
call_stack.push_back(observer->nameObserveStartTimeStep_);
call_stack.push_back(observer->nameObserveCompletedTimeStep_);
call_stack.push_back(observer->nameObserveStartTimeStep_);
call_stack.push_back(observer->nameObserveCompletedTimeStep_);
call_stack.push_back(observer->nameObserveStartTimeStep_);
call_stack.push_back(observer->nameObserveCompletedTimeStep_);
call_stack.push_back(observer->nameObserveStartTimeStep_);
call_stack.push_back(observer->nameObserveFailedTimeStep_);
call_stack.push_back(observer->nameObserveStartTimeStep_);
call_stack.push_back(observer->nameObserveCompletedTimeStep_);
call_stack.push_back(observer->nameObserveStartTimeStep_);
call_stack.push_back(observer->nameObserveCompletedTimeStep_);
call_stack.push_back(observer->nameObserveEndTimeIntegration_);
observer->setCallStack(call_stack);
integrator->setIntegrationObserver(observer);
}
const double finalTime = 1.0;
integrator->setStepper(stepper, finalTime);
integrator->setVerbLevel(Teuchos::VERB_EXTREME);
integrator->setOStream(Teuchos::rcpFromRef(out));
const RCP<const Thyra::VectorBase<double> > x_final =
get_fwd_x<double>(*integrator, finalTime);
}
示例2: TEUCHOS_UNIT_TEST
TEUCHOS_UNIT_TEST( BasicDiscreteAdjointStepperTester, rawNonlinearAdjoint )
{
using Teuchos::outArg;
using Teuchos::describe;
using Teuchos::getParametersFromXmlString;
typedef Thyra::ModelEvaluatorBase MEB;
//
out << "\nA) Create the nonlinear ME ...\n";
//
RCP<VanderPolModel> stateModel = vanderPolModel(
getParametersFromXmlString(
"<ParameterList>"
" <Parameter name=\"Implicit model formulation\" type=\"bool\" value=\"1\"/>"
"</ParameterList>"
)
);
//
out << "\nB) Create the nonlinear solver ...\n";
//
RCP<TimeStepNonlinearSolver<double> > nlSolver = timeStepNonlinearSolver<double>(
getParametersFromXmlString(
"<ParameterList>"
" <Parameter name=\"Default Tol\" type=\"double\" value=\"1.0e-10\"/>"
" <Parameter name=\"Default Max Iters\" type=\"int\" value=\"20\"/>"
"</ParameterList>"
)
);
//
out << "\nC) Create the integrator for the forward state problem ...\n";
//
RCP<IntegratorBuilder<double> > ib = integratorBuilder<double>(
Teuchos::getParametersFromXmlString(
"<ParameterList>"
" <ParameterList name=\"Stepper Settings\">"
" <ParameterList name=\"Stepper Selection\">"
" <Parameter name=\"Stepper Type\" type=\"string\" value=\"Backward Euler\"/>"
" </ParameterList>"
" </ParameterList>"
" <ParameterList name=\"Integration Control Strategy Selection\">"
" <Parameter name=\"Integration Control Strategy Type\" type=\"string\""
" value=\"Simple Integration Control Strategy\"/>"
" <ParameterList name=\"Simple Integration Control Strategy\">"
" <Parameter name=\"Take Variable Steps\" type=\"bool\" value=\"false\"/>"
" <Parameter name=\"Fixed dt\" type=\"double\" value=\"0.5\"/>" // Gives 2 time steps!
" </ParameterList>"
" </ParameterList>"
" <ParameterList name=\"Interpolation Buffer Settings\">"
" <ParameterList name=\"Trailing Interpolation Buffer Selection\">"
" <Parameter name=\"Interpolation Buffer Type\" type=\"string\" value=\"Interpolation Buffer\"/>"
" </ParameterList>"
" </ParameterList>"
"</ParameterList>"
)
);
MEB::InArgs<double> ic = stateModel->getNominalValues();
RCP<IntegratorBase<double> > integrator = ib->create(stateModel, ic, nlSolver);
//integrator->setVerbLevel(Teuchos::VERB_EXTREME);
// ToDo: Set the trailing IB to pick up the entire state solution!
//
out << "\nD) Solve the basic forward problem ...\n";
//
const TimeRange<double> fwdTimeRange = integrator->getFwdTimeRange();
const double t_final = fwdTimeRange.upper();
RCP<const Thyra::VectorBase<double> > x_final, x_dot_final;
get_fwd_x_and_x_dot( *integrator, t_final, outArg(x_final), outArg(x_dot_final) );
out << "\nt_final = " << t_final << "\n";
out << "\nx_final: " << *x_final;
out << "\nx_dot_final: " << *x_dot_final;
//
out << "\nE) Create the basic adjoint model (no distributed response) ...\n";
//
RCP<AdjointModelEvaluator<double> > adjModel =
adjointModelEvaluator<double>(
stateModel, fwdTimeRange
);
adjModel->setFwdStateSolutionBuffer(integrator);
//
out << "\nF) Create a stepper and integrator for the adjoint ...\n";
//
RCP<Thyra::LinearNonlinearSolver<double> > adjTimeStepSolver =
Thyra::linearNonlinearSolver<double>();
RCP<Rythmos::StepperBase<double> > adjStepper =
integrator->getStepper()->cloneStepperAlgorithm();
//.........这里部分代码省略.........