Пример #1
0
void
LOCA::Homotopy::DeflatedGroup::
fillC(NOX::Abstract::MultiVector::DenseMatrix& C) const
{
  string callingFunction = 
    "LOCA::Homotopy::DeflatedGroup::fillC";

  Teuchos::RCP<const NOX::Abstract::MultiVector::DenseMatrix> my_C = 
    minusOne;

  // If the underlying system isn't bordered, we're done
  if (!isBordered) {
    C.assign(*my_C);
    return;
  }

  Teuchos::RCP<const NOX::Abstract::MultiVector> my_B = 
    totalDistMultiVec;

  Teuchos::RCP<const NOX::Abstract::MultiVector> my_A = 
    underlyingF;
  
  // Create views for underlying group
  int w = bordered_grp->getBorderedWidth();
  NOX::Abstract::MultiVector::DenseMatrix underlyingC(Teuchos::View, C,
						      w, w, 0, 0);

  // Combine blocks in underlying group
  bordered_grp->fillC(underlyingC);

  // Create views for my blocks
  NOX::Abstract::MultiVector::DenseMatrix my_A_p(Teuchos::View, C,
						 w, 1, 0, w);
  NOX::Abstract::MultiVector::DenseMatrix my_B_p(Teuchos::View, C,
						 1, w, w, 0);
  NOX::Abstract::MultiVector::DenseMatrix my_CC(Teuchos::View, C,
						1, 1, w, w);

  // Extract solution component from my_A and store in my_A_p
  bordered_grp->extractParameterComponent(false, *my_A, my_A_p);

  // Extract solution component from my_B and store in my_B_p
  bordered_grp->extractParameterComponent(true, *my_B, my_B_p);

  // Copy in my_C
  my_CC.assign(*my_C);
}
Пример #2
0
void
LOCA::Hopf::MinimallyAugmented::ExtendedGroup::
fillC(NOX::Abstract::MultiVector::DenseMatrix& C) const
{
  string callingFunction = 
    "LOCA::Hopf::MinimallyAugmented::ExtendedGroup::fillC";

  Teuchos::RCP<const NOX::Abstract::MultiVector::DenseMatrix> my_C = 
    dfdpMultiVec->getScalars();

  // If the underlying system isn't bordered, we're done
  if (!isBordered) {
    C.assign(*my_C);
    return;
  }

  Teuchos::RCP<const NOX::Abstract::MultiVector> my_B = 
    Teuchos::rcp(constraintsPtr->getDX(),false);

  Teuchos::RCP<const NOX::Abstract::MultiVector> my_A = 
    dfdpMultiVec->getXMultiVec();
  
  // Create views for underlying group
  int w = bordered_grp->getBorderedWidth();
  NOX::Abstract::MultiVector::DenseMatrix underlyingC(Teuchos::View, C,
						      w, w, 0, 0);

  // Combine blocks in underlying group
  bordered_grp->fillC(underlyingC);

  // Create views for my blocks
  NOX::Abstract::MultiVector::DenseMatrix my_A_p(Teuchos::View, C,
						 w, 2, 0, w);
  NOX::Abstract::MultiVector::DenseMatrix my_B_p(Teuchos::View, C,
						 2, w, w, 0);
  NOX::Abstract::MultiVector::DenseMatrix my_CC(Teuchos::View, C,
						2, 2, w, w);

  // Extract solution component from my_A and store in my_A_p
  bordered_grp->extractParameterComponent(false, *my_A, my_A_p);

  // Extract solution component from my_B and store in my_B_p
  bordered_grp->extractParameterComponent(true, *my_B, my_B_p);

  // Copy in my_C
  my_CC.assign(*my_C);
}
Пример #3
0
void
LOCA::BorderedSolver::Nested::setMatrixBlocks(
         const Teuchos::RCP<const LOCA::BorderedSolver::AbstractOperator>& oper,
	 const Teuchos::RCP<const NOX::Abstract::MultiVector>& blockA,
	 const Teuchos::RCP<const LOCA::MultiContinuation::ConstraintInterface>& blockB,
	 const Teuchos::RCP<const NOX::Abstract::MultiVector::DenseMatrix>& blockC)
{
  string callingFunction = 
    "LOCA::BorderedSolver::Nested::setMatrixBlocks()";

  // Cast oper to a bordered operator
  Teuchos::RCP<const LOCA::BorderedSolver::JacobianOperator> op = 
    Teuchos::rcp_dynamic_cast<const LOCA::BorderedSolver::JacobianOperator>(oper);
  if (op == Teuchos::null) 
    globalData->locaErrorCheck->throwError(
      callingFunction,
      string("Operaror must be of type LOCA::BorderedSolver::JacobianOperator")
      + string(" in order to use nested bordered solver strategy."));

  // Get bordered group
  grp = Teuchos::rcp_dynamic_cast<const LOCA::BorderedSystem::AbstractGroup>(op->getGroup());
  if (grp == Teuchos::null) 
    globalData->locaErrorCheck->throwError(
      callingFunction,
      string("Group must be of type LOCA::BorderedSystem::AbstractGroup")
      + string(" in order to use nested bordered solver strategy."));

  Teuchos::RCP<const LOCA::MultiContinuation::ConstraintInterfaceMVDX> con_mvdx = Teuchos::rcp_dynamic_cast<const LOCA::MultiContinuation::ConstraintInterfaceMVDX>(blockB);
  if (con_mvdx == Teuchos::null)
    globalData->locaErrorCheck->throwError(
		 callingFunction,
		 "Constraints object must be of type ConstraintInterfaceMVDX");

  bool isZeroA = (blockA.get() == NULL);
  bool isZeroB = con_mvdx->isDXZero();
  bool isZeroC = (blockC.get() == NULL);
  Teuchos::RCP<const NOX::Abstract::MultiVector> blockB_dx;
  if (!isZeroB)
    blockB_dx = Teuchos::rcp(con_mvdx->getDX(), false);

  // ensure blocks B and C are not both zero
  if (isZeroB && isZeroC) 
    globalData->locaErrorCheck->throwError(
				        callingFunction,
				        "Blocks B and C cannot both be zero");

  // ensure blocks A and C are not both zero
  if (isZeroA && isZeroC) 
    globalData->locaErrorCheck->throwError(
				         callingFunction,
				         "Blocks A and C cannot both be zero");

  // Get unbordered group
  unbordered_grp = grp->getUnborderedGroup();

  // get number of outer constraints
  if (isZeroB)
    numConstraints = blockC->numRows();
  else
    numConstraints = blockB_dx->numVectors();

  // Get total bordered width
  underlyingWidth = grp->getBorderedWidth();
  myWidth = underlyingWidth + numConstraints;
  
  // combine blocks
  bool isCombinedAZero = grp->isCombinedAZero();
  bool isCombinedBZero = grp->isCombinedBZero();
  bool isCombinedCZero = grp->isCombinedCZero();
  Teuchos::RCP<NOX::Abstract::MultiVector> A;
  Teuchos::RCP<NOX::Abstract::MultiVector> B;
  Teuchos::RCP<NOX::Abstract::MultiVector::DenseMatrix> C;
  
  if (!isCombinedAZero || !isZeroA) {
    A = unbordered_grp->getX().createMultiVector(myWidth);
    A->init(0.0);
  }
  if (!isCombinedBZero || !isZeroB) {
    B = unbordered_grp->getX().createMultiVector(myWidth);
    B->init(0.0);
    
  }
  if (!isCombinedCZero || !isZeroC) {
    C = Teuchos::rcp(new NOX::Abstract::MultiVector::DenseMatrix(myWidth,
								 myWidth));
    C->putScalar(0.0);
  }

  std::vector<int> idx1(underlyingWidth);
  for (int i=0; i<underlyingWidth; i++)
    idx1[i] = i;
  if (!isCombinedAZero) {
    Teuchos::RCP<NOX::Abstract::MultiVector> underlyingA = 
      A->subView(idx1);
    grp->fillA(*underlyingA);
  }
  if (!isCombinedBZero) {
    Teuchos::RCP<NOX::Abstract::MultiVector> underlyingB = 
      B->subView(idx1);
    grp->fillB(*underlyingB);
  }
  if (!isCombinedCZero) {
    NOX::Abstract::MultiVector::DenseMatrix underlyingC(Teuchos::View, 
							*C, 
							underlyingWidth, 
							underlyingWidth, 
							0, 0);
    grp->fillC(underlyingC);
  }

  std::vector<int> idx2(numConstraints);
  for (int i=0; i<numConstraints; i++)
    idx2[i] = underlyingWidth+i;
  if (!isZeroA) {
    Teuchos::RCP<NOX::Abstract::MultiVector> my_A_x = A->subView(idx2);
    NOX::Abstract::MultiVector::DenseMatrix my_A_p(Teuchos::View, *C,
						   underlyingWidth, 
						   numConstraints, 0, 
						   underlyingWidth);
    grp->extractSolutionComponent(*blockA, *my_A_x);
    grp->extractParameterComponent(false, *blockA, my_A_p);
  }

  if (!isZeroB) {
    Teuchos::RCP<NOX::Abstract::MultiVector> my_B_x = B->subView(idx2);
    NOX::Abstract::MultiVector::DenseMatrix my_B_p(Teuchos::View, *C,
						   numConstraints, 
						   underlyingWidth, 
						   underlyingWidth, 0);
    grp->extractSolutionComponent(*blockB_dx, *my_B_x);
    grp->extractParameterComponent(true, *blockB_dx, my_B_p);
  }

  if (!isZeroC) {
    NOX::Abstract::MultiVector::DenseMatrix my_CC(Teuchos::View, *C,
						  numConstraints, 
						  numConstraints, 
						  underlyingWidth, 
						  underlyingWidth);
    my_CC.assign(*blockC);
  }

  // Create unbordered operator
  Teuchos::RCP<LOCA::BorderedSolver::AbstractOperator> unbordered_op = 
    Teuchos::rcp(new LOCA::BorderedSolver::JacobianOperator(unbordered_grp));
    
  // set blocks in solver
  solver->setMatrixBlocksMultiVecConstraint(unbordered_op, A, B, C);
}
void
LOCA::MultiContinuation::ConstrainedGroup::fillC(
	                     NOX::Abstract::MultiVector::DenseMatrix& C) const
{
  std::string callingFunction = 
    "LOCA::MultiContinuation::ConstrainedGroup::fillC";

  Teuchos::RCP<const NOX::Abstract::MultiVector::DenseMatrix> my_C = 
    dfdpMultiVec->getScalars();

  // If the underlying system isn't bordered, we're done
  if (!isBordered) {
    C.assign(*my_C);
    return;
  }

  bool isZeroB = constraintsPtr->isDXZero();
  Teuchos::RCP<const NOX::Abstract::MultiVector> my_B;

  if (!isZeroB) {
    Teuchos::RCP<const LOCA::MultiContinuation::ConstraintInterfaceMVDX> constraints_mvdx = Teuchos::rcp_dynamic_cast<const LOCA::MultiContinuation::ConstraintInterfaceMVDX>(constraintsPtr);
    if (constraints_mvdx == Teuchos::null)
      globalData->locaErrorCheck->throwError(
				callingFunction,
				std::string("Constraints object must be of type") +
				std::string("ConstraintInterfaceMVDX"));

    my_B = Teuchos::rcp(constraints_mvdx->getDX(),false);
  }

  Teuchos::RCP<const NOX::Abstract::MultiVector> my_A = 
    dfdpMultiVec->getXMultiVec();
  
  // Create views for underlying group
  int w = bordered_grp->getBorderedWidth();
  NOX::Abstract::MultiVector::DenseMatrix underlyingC(Teuchos::View, C,
						      w, w, 0, 0);

  // Combine blocks in underlying group
  bordered_grp->fillC(underlyingC);

  // Create views for my blocks
  NOX::Abstract::MultiVector::DenseMatrix my_A_p(Teuchos::View, C,
						 w, numParams, 0, w);
  NOX::Abstract::MultiVector::DenseMatrix my_B_p(Teuchos::View, C,
						 numParams, w, w, 0);
  NOX::Abstract::MultiVector::DenseMatrix my_CC(Teuchos::View, C,
						numParams, numParams, w, w);

  // Extract solution component from my_A and store in my_A_p
  bordered_grp->extractParameterComponent(false, *my_A, my_A_p);

  // Extract solution component from my_B and store in my_B_p
  if (isZeroB)
    my_B_p.putScalar(0.0);
  else
    bordered_grp->extractParameterComponent(true, *my_B, my_B_p);

  // Copy in my_C
  my_CC.assign(*my_C);
}