NOX::Abstract::Group::ReturnType LOCA::TurningPoint::MooreSpence::PhippsBordering::solveTranspose( Teuchos::ParameterList& params, const LOCA::TurningPoint::MooreSpence::ExtendedMultiVector& input, LOCA::TurningPoint::MooreSpence::ExtendedMultiVector& result) const { std::string callingFunction = "LOCA::TurningPoint::MooreSpence::PhippsBordering::solveTranspose()"; NOX::Abstract::Group::ReturnType status; // Get components of input Teuchos::RCP<const NOX::Abstract::MultiVector> input_x = input.getXMultiVec(); Teuchos::RCP<const NOX::Abstract::MultiVector> input_null = input.getNullMultiVec(); Teuchos::RCP<const NOX::Abstract::MultiVector::DenseMatrix> input_param = input.getScalars(); // Get components of result Teuchos::RCP<NOX::Abstract::MultiVector> result_x = result.getXMultiVec(); Teuchos::RCP<NOX::Abstract::MultiVector> result_null = result.getNullMultiVec(); Teuchos::RCP<NOX::Abstract::MultiVector::DenseMatrix> result_param = result.getScalars(); int m = input.numVectors(); std::vector<int> index_input(m); for (int i=0; i<m; i++) index_input[i] = i; // Create new multivectors with m+2 columns // First m columns store input_x, input_null, result_x, result_null // respectively, next column stores 0, -phi, J^-T tmp , -J^-T phi // respectively, last column is for solving (Jv)_x^T u Teuchos::RCP<NOX::Abstract::MultiVector> cont_input_x = input_x->clone(m+2); Teuchos::RCP<NOX::Abstract::MultiVector> cont_input_null = input_null->clone(m+2); Teuchos::RCP<NOX::Abstract::MultiVector> cont_result_x = result_x->clone(m+2); Teuchos::RCP<NOX::Abstract::MultiVector> cont_result_null = result_null->clone(m+2); // Set first m columns to input_x cont_input_x->setBlock(*input_x, index_input); // Set last two columns to 0 (*cont_input_x)[m].init(0); (*cont_input_x)[m+1].init(0); // Set first m columns to input_null cont_input_null->setBlock(*input_null, index_input); // Set next column to -phi Teuchos::RCP<NOX::Abstract::Vector> phi = tpGroup->getLengthVector(); (*cont_input_null)[m].update(-1.0, *phi, 0.0); // Set last column to 0 (*cont_input_null)[m].init(0); // Initialize result multivectors to 0 cont_result_x->init(0.0); cont_result_null->init(0.0); // Solve status = solveTransposeContiguous(params, *cont_input_x, *cont_input_null, *input_param, *cont_result_x, *cont_result_null, *result_param); // Create views of first m columns for result_x, result_null Teuchos::RCP<NOX::Abstract::MultiVector> cont_result_x_view = cont_result_x->subView(index_input); Teuchos::RCP<NOX::Abstract::MultiVector> cont_result_null_view = cont_result_null->subView(index_input); // Copy first m columns back into result_x, result_null *result_x = *cont_result_x_view; *result_null = *cont_result_null_view; return status; }
NOX::Abstract::Group::ReturnType LOCA::TurningPoint::MooreSpence::PhippsBordering::solve( Teuchos::ParameterList& params, const LOCA::TurningPoint::MooreSpence::ExtendedMultiVector& input, LOCA::TurningPoint::MooreSpence::ExtendedMultiVector& result) const { string callingFunction = "LOCA::TurningPoint::MooreSpence::PhippsBordering::solve()"; NOX::Abstract::Group::ReturnType status; // Get components of input Teuchos::RCP<const NOX::Abstract::MultiVector> input_x = input.getXMultiVec(); Teuchos::RCP<const NOX::Abstract::MultiVector> input_null = input.getNullMultiVec(); Teuchos::RCP<const NOX::Abstract::MultiVector::DenseMatrix> input_param = input.getScalars(); // Get components of result Teuchos::RCP<NOX::Abstract::MultiVector> result_x = result.getXMultiVec(); Teuchos::RCP<NOX::Abstract::MultiVector> result_null = result.getNullMultiVec(); Teuchos::RCP<NOX::Abstract::MultiVector::DenseMatrix> result_param = result.getScalars(); int m = input.numVectors(); vector<int> index_input(m); for (int i=0; i<m; i++) index_input[i] = i; // Create new multivectors with m+2 columns // First m columns store input_x, input_null, result_x, result_null // respectively, next column stores dfdp, dJndp, J^-1 dfdp, J^-1 dJndp // respectively. Last column is for solving (Jv)_x v Teuchos::RCP<NOX::Abstract::MultiVector> cont_input_x = input_x->clone(m+2); Teuchos::RCP<NOX::Abstract::MultiVector> cont_input_null = input_null->clone(m+2); Teuchos::RCP<NOX::Abstract::MultiVector> cont_result_x = result_x->clone(m+2); Teuchos::RCP<NOX::Abstract::MultiVector> cont_result_null = result_null->clone(m+2); // Set first m columns to input_x cont_input_x->setBlock(*input_x, index_input); // Set column m+1 to dfdp (*cont_input_x)[m] = (*dfdp)[0]; // Initialize column m+2 to 0 (*cont_input_x)[m+1].init(0.0); // Set first m columns to input_null cont_input_null->setBlock(*input_null, index_input); // Set column m+1 to dJndp (*cont_input_null)[m] = (*dJndp)[0]; // Initialize column m+2 to 0 (*cont_input_null)[m+1].init(0.0); // Initialize result multivectors to 0 cont_result_x->init(0.0); cont_result_null->init(0.0); // Solve status = solveContiguous(params, *cont_input_x, *cont_input_null, *input_param, *cont_result_x, *cont_result_null, *result_param); // Create views of first m columns for result_x, result_null Teuchos::RCP<NOX::Abstract::MultiVector> cont_result_x_view = cont_result_x->subView(index_input); Teuchos::RCP<NOX::Abstract::MultiVector> cont_result_null_view = cont_result_null->subView(index_input); // Copy first m columns back into result_x, result_null *result_x = *cont_result_x_view; *result_null = *cont_result_null_view; return status; }