LOCA::TurningPoint::MinimallyAugmented::Constraint::
Constraint(
    const Teuchos::RCP<LOCA::GlobalData>& global_data,
    const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
    const Teuchos::RCP<Teuchos::ParameterList>& tpParams,
    const Teuchos::RCP<LOCA::TurningPoint::MinimallyAugmented::AbstractGroup>& g,
    int bif_param) :
  globalData(global_data),
  parsedParams(topParams),
  turningPointParams(tpParams),
  grpPtr(g),
  a_vector(grpPtr->getX().createMultiVector(1, NOX::ShapeCopy)),
  b_vector(a_vector->clone(NOX::ShapeCopy)),
  w_vector(a_vector->clone(NOX::ShapeCopy)),
  v_vector(a_vector->clone(NOX::ShapeCopy)),
  Jv_vector(a_vector->clone(NOX::ShapeCopy)),
  Jtw_vector(a_vector->clone(NOX::ShapeCopy)),
  sigma_x(a_vector->clone(NOX::ShapeCopy)),
  constraints(1, 1),
  borderedSolver(),
  dn(static_cast<double>(a_vector->length())),
  sigma_scale(1.0),
  isSymmetric(false),
  isValidConstraints(false),
  isValidDX(false),
  bifParamID(1),
  updateVectorsEveryContinuationStep(true),
  updateVectorsEveryIteration(false),
  nullVecScaling(NVS_OrderN),
  multiplyMass(false),
  tdGrp(Teuchos::rcp_dynamic_cast<LOCA::TimeDependent::AbstractGroup>(grpPtr)),
  tmp_mass(grpPtr->getX().clone(NOX::ShapeCopy))
{
  // Instantiate bordered solvers
  borderedSolver = 
    globalData->locaFactory->createBorderedSolverStrategy(parsedParams,
							  turningPointParams);

  // Get symmetric flag
  isSymmetric = turningPointParams->get("Symmetric Jacobian", false);

  bifParamID[0] = bif_param;

  // Options
  updateVectorsEveryContinuationStep = 
    turningPointParams->get("Update Null Vectors Every Continuation Step", 
			    true);
  updateVectorsEveryIteration = 
    turningPointParams->get("Update Null Vectors Every Nonlinear Iteration", 
			    false);
  std::string nullVecScalingMethod = 
    turningPointParams->get("Null Vector Scaling", "Order N");
  if (nullVecScalingMethod == "None")
    nullVecScaling = NVS_None;
  else if (nullVecScalingMethod == "Order 1")
    nullVecScaling = NVS_OrderOne;
  else if (nullVecScalingMethod == "Order N")
    nullVecScaling = NVS_OrderN;
  else
    globalData->locaErrorCheck->throwError(
       "LOCA::TurningPoint::MinimallyAugmented::Constraint::Constraint()",
       std::string("Unknown null vector scaling method:  ") + nullVecScalingMethod);
  multiplyMass = 
    turningPointParams->get("Multiply Null Vectors by Mass Matrix", false);
  if (multiplyMass && tdGrp == Teuchos::null) {
    globalData->locaErrorCheck->throwError(
       "LOCA::TurningPoint::MinimallyAugmented::Constraint::Constraint()",
       "Group must be derived from LOCA::TimeDependent::AbstractGroup to multiply null vectors by mass matrix");
  }

  // Compute/get initial "a" & "b" vectors
  getInitialVectors((*a_vector)[0], (*b_vector)[0]);
}
コード例 #2
0
LOCA::Hopf::MinimallyAugmented::ExtendedGroup::
ExtendedGroup(
       const Teuchos::RCP<LOCA::GlobalData>& global_data,
       const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
       const Teuchos::RCP<Teuchos::ParameterList>& hpfParams,
       const Teuchos::RCP<LOCA::Hopf::MinimallyAugmented::AbstractGroup>& g)
  : globalData(global_data),
    parsedParams(topParams),
    hopfParams(hpfParams),
    grpPtr(g),
    bordered_grp(),
    constraintsPtr(),
    xMultiVec(globalData, g->getX(), 1, 2, NOX::DeepCopy),
    fMultiVec(globalData, g->getX(), 3, 2, NOX::ShapeCopy),
    newtonMultiVec(globalData, g->getX(), 1, 2, NOX::ShapeCopy),
    gradientMultiVec(globalData, g->getX(), 1, 2, NOX::ShapeCopy),
    xVec(),
    fVec(),
    ffMultiVec(),
    dfdpMultiVec(),
    fBifMultiVec(),
    newtonVec(),
    gradientVec(),
    jacOp(),
    borderedSolver(),
    index_f(1),
    index_dfdp(2),
    bifParamID(-1),
    isValidF(false),
    isValidJacobian(false),
    isValidNewton(false),
    isValidGradient(false),
    isBordered(false)
{
  const char *func = "LOCA::Hopf::MinimallyAugmented::ExtendedGroup()";

  // Set up multi-vector views
  setupViews(); 

  // Get bifurcation parameter name
  if (!hopfParams->isParameter("Bifurcation Parameter")) {
    globalData->locaErrorCheck->throwError(func,
				 "\"Bifurcation Parameter\" name is not set!");
  }
  string bifParamName = hopfParams->get("Bifurcation Parameter", "None");
  const ParameterVector& p = grpPtr->getParams();
  bifParamID = p.getIndex(bifParamName);

  // Get Hopf frequency
  if (!hopfParams->isParameter("Initial Frequency")) {
    globalData->locaErrorCheck->throwError(func,
					 "\"Initial Frequency\" is not set!");
  }
  double omega = 
    hopfParams->get("Initial Frequency", 1.0);

  // Get symmetric flag
  bool isSymmetric = hopfParams->get("Symmetric Jacobian", false);

  // Compute/get initial "a" & "b" vectors
  Teuchos::RCP<NOX::Abstract::Vector> aVecPtr_real;
  Teuchos::RCP<NOX::Abstract::Vector> aVecPtr_imag;
  Teuchos::RCP<NOX::Abstract::Vector> bVecPtr_real;
  Teuchos::RCP<NOX::Abstract::Vector> bVecPtr_imag;
  getInitialVectors(aVecPtr_real, aVecPtr_imag, bVecPtr_real, bVecPtr_imag,
		    isSymmetric);

  // Create constraint equation
  constraintsPtr = 
    Teuchos::rcp(new LOCA::Hopf::MinimallyAugmented::Constraint(
							   globalData,
							   parsedParams,
							   hopfParams,
							   grpPtr,
							   isSymmetric,
							   *aVecPtr_real,
							   *aVecPtr_imag,
							   bVecPtr_real.get(),
							   bVecPtr_imag.get(),
							   bifParamID,
							   omega));

  // Set parameters in solution vector
  xVec->getScalar(0) = grpPtr->getParam(bifParamID);
  xVec->getScalar(1) = omega;

  // Set parameters and solution vector in constraints
  constraintsPtr->setParam(bifParamID, xVec->getScalar(0));
  constraintsPtr->setX(*(xVec->getXVec()));

  // Instantiate bordered solver
  borderedSolver = 
    globalData->locaFactory->createBorderedSolverStrategy(parsedParams,
							  hopfParams);

  // Determine if underlying group is bordered
  bordered_grp = 
    Teuchos::rcp_dynamic_cast<LOCA::BorderedSystem::AbstractGroup>(grpPtr);
  isBordered = (bordered_grp != Teuchos::null);

  // Create Jacobian operator for bordered solver
  jacOp = Teuchos::rcp(new LOCA::BorderedSolver::JacobianOperator(grpPtr));
}