diff --git a/packages/nox/test/tpetra/CMakeLists.txt b/packages/nox/test/tpetra/CMakeLists.txt index c611a0924f15..1634654740ad 100644 --- a/packages/nox/test/tpetra/CMakeLists.txt +++ b/packages/nox/test/tpetra/CMakeLists.txt @@ -43,6 +43,11 @@ IF(NOX_ENABLE_ABSTRACT_IMPLEMENTATION_THYRA AND SOURCES ${UNIT_TEST_DRIVER} ME_Tpetra_Heq.hpp ME_Tpetra_Heq_def.hpp Tpetra_Heq.cpp ) + TRIBITS_ADD_EXECUTABLE_AND_TEST( + Tpetra_Laplace2D + SOURCES ${UNIT_TEST_DRIVER} Tpetra_Laplace2D.cpp + ) + IF(NOX_ENABLE_LOCA) TRIBITS_ADD_EXECUTABLE_AND_TEST( @@ -67,6 +72,4 @@ IF(NOX_ENABLE_ABSTRACT_IMPLEMENTATION_THYRA AND ENDIF() -ENDIF() - -ADD_SUBDIRECTORY(NOX_Operators) \ No newline at end of file +ENDIF() \ No newline at end of file diff --git a/packages/nox/test/tpetra/NOX_Operators/CMakeLists.txt b/packages/nox/test/tpetra/NOX_Operators/CMakeLists.txt deleted file mode 100644 index 71f7e57029c7..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -ADD_SUBDIRECTORY(src) - -TRIBITS_ADD_EXECUTABLE_AND_TEST( - NOX_Operators_Tpetra - SOURCES - NOX_Tpetra_Interface_Jacobian.hpp # this file epetra equivalent was in src-epetra. move tpetra one to src-tpetra ? - NOX_Tpetra_Interface_Preconditioner.hpp # this file epetra equivalent was in src-epetra. move tpetra one to src-tpetra ? - NOX_Tpetra_Interface_Required.hpp # this file epetra equivalent was in src-epetra. move tpetra one to src-tpetra ? - Laplace2D_Tpetra.hpp - Laplace2D_Tpetra.cpp - test.cpp - # TESTONLYLIBS noxtestutils - COMM serial mpi - NUM_MPI_PROCS 1 - # PASS_REGULAR_EXPRESSION "Test passed!" - ) - diff --git a/packages/nox/test/tpetra/NOX_Operators/Laplace2D_Tpetra.cpp b/packages/nox/test/tpetra/NOX_Operators/Laplace2D_Tpetra.cpp deleted file mode 100644 index 24a18afbbedc..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/Laplace2D_Tpetra.cpp +++ /dev/null @@ -1,244 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#include "Laplace2D_Tpetra.hpp" - -// this is required to know the number of lower, upper, left and right -// node for each node of the Cartesian grid (composed by nx \timex ny -// elements) - -void -Laplace2D::get_myNeighbours( const int i, const int nx, const int ny, - int & left, int & right, - int & lower, int & upper) -{ - - int ix, iy; - ix = i%nx; - iy = (i - ix)/nx; - - if( ix == 0 ) - left = -1; - else - left = i-1; - if( ix == nx-1 ) - right = -1; - else - right = i+1; - if( iy == 0 ) - lower = -1; - else - lower = i-nx; - if( iy == ny-1 ) - upper = -1; - else - upper = i+nx; - - return; - -} - -// This function creates a CrsMatrix, whose elements corresponds -// to the discretization of a Laplacian over a Cartesian grid, -// with nx grid point along the x-axis and and ny grid points -// along the y-axis. For the sake of simplicity, I suppose that -// all the nodes in the matrix are internal nodes (Dirichlet -// boundary nodes are supposed to have been already condensated) - -TCrsMatrix * -Laplace2D::CreateLaplacian( const int nx, const int ny, const Teuchos::RCP >& comm) -{ - - int numGlobalElements = nx * ny; - - // create a map - TMap * map = new TMap(numElemsGlobal, 0, comm) - // local number of rows - int numMyElements = map->getLocalNumElements(); - // get update list - int * globalElements = map->getGlobalNumElements(); - - double hx = 1.0/(nx-1); - double hy = 1.0/(ny-1); - double off_left = -1.0/(hx*hx); - double off_right = -1.0/(hx*hx); - double off_lower = -1.0/(hy*hy); - double off_upper = -1.0/(hy*hy); - double diag = 2.0/(hx*hx) + 2.0/(hy*hy); - - int left, right, lower, upper; - - // a bit overestimated the nonzero per row - - TCrsMatrix * A = new TCrsMatrix(Copy,*Map,5); - - // Add rows one-at-a-time - - double * values = new double[4]; - int * indices = new int[4]; - - for( int i = 0; i < NumMyElements; ++i ) - { - int numEntries=0; - get_myNeighbours( globalElements[i], nx, ny, left, right, lower, upper ); - if( left != -1 ) - { - indices[numEntries] = left; - values[numEntries] = off_left; - ++numEntries; - } - if( right != -1 ) - { - indices[numEntries] = right; - values[numEntries] = off_right; - ++numEntries; - } - if( lower != -1 ) - { - indices[numEntries] = lower; - values[numEntries] = off_lower; - ++numEntries; - } - if( upper != -1 ) - { - indices[numEntries] = upper; - values[numEntries] = off_upper; - ++numEntries; - } - // put the off-diagonal entries - A->insertGlobalValues(MyGlobalElements[i], numEntries, values, indices); - // Put in the diagonal entry - A->insertGlobalValues(MyGlobalElements[i], 1, &diag, MyGlobalElements+i); - } - - // put matrix in local ordering - A->fillComplete(); - - delete [] indices; - delete [] values; - delete map; - - return A; - -} /* createJacobian */ - -// ========================================================================== -// This class contians the main definition of the nonlinear problem at -// hand. A method is provided to compute F(x) for a given x, and another -// method to update the entries of the Jacobian matrix, for a given x. -// As the Jacobian matrix J can be written as -// J = L + diag(lambda*exp(x[i])), -// where L corresponds to the discretization of a Laplacian, and diag -// is a diagonal matrix with lambda*exp(x[i]). Basically, to update -// the jacobian we simply update the diagonal entries. Similarly, to compute -// F(x), we reset J to be equal to L, then we multiply it by the -// (distributed) vector x, then we add the diagonal contribution -// ========================================================================== - -// constructor. Requires the number of nodes along the x-axis -// and y-axis, the value of lambda, and the communicator -// (to define a Map, which is a linear map in this case) -PDEProblem::PDEProblem(const int nx, const int ny, const double lambda, - const Teuchos::RCP >& comm) : - nx_(nx), ny_(ny), lambda_(lambda) -{ - hx_ = 1.0/(nx_-1); - hy_ = 1.0/(ny_-1); - matrix_ = Laplace2D::CreateLaplacian(nx_,ny_,comm); -} - -// destructor -PDEProblem::~PDEProblem() -{ - delete matrix_; -} - -// compute F(x) -void PDEProblem::ComputeF( const TVector & x, TVector & f ) -{ - // reset diagonal entries - double diag = 2.0/(hx_*hx_) + 2.0/(hy_*hy_); - - int numMyElements = matrix_->Map().numMyElements(); - // get update list - int * myGlobalElements = matrix_->Map().myGlobalElements(); - - for( int i = 0; i < numMyElements; ++i ) - { - // Put in the diagonal entry - matrix_->replaceGlobalValues(myGlobalElements[i], 1, &diag, myGlobalElements+i); - } - // matrix-vector product (intra-processes communication occurs in this call) - matrix_->multiply( false, x, f ); - - // add diagonal contributions - for( int i = 0; i < numMyElements; ++i ) - { - // Put in the diagonal entry - f[i] += lambda_*exp(x[i]); - } -} - -// update the Jacobian matrix for a given x -void PDEProblem::updateJacobian( const TVector & x ) -{ - double diag = 2.0/(hx_*hx_) + 2.0/(hy_*hy_); - - int numMyElements = matrix_->map().numMyElements(); - // get update list - int * myGlobalElements = matrix_->Map().myGlobalElements(); - - for( int i = 0; i < numMyElements; ++i ) - { - // Put in the diagonal entry - double newdiag = diag + lambda_*exp(x[i]); - matrix_->replaceGlobalValues(myGlobalElements[i], 1, &newdiag, myGlobalElements+i); - } - -} - - diff --git a/packages/nox/test/tpetra/NOX_Operators/Laplace2D_Tpetra.hpp b/packages/nox/test/tpetra/NOX_Operators/Laplace2D_Tpetra.hpp deleted file mode 100644 index d61b31eafe28..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/Laplace2D_Tpetra.hpp +++ /dev/null @@ -1,195 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -// NOX Test Lacplace 2D Problem -// ---------------------------- -// Simple nonlinear PDE problem. -// This file provides the problem -// -// -\Delta u + \lambda e^u = 0 in \Omega = (0,1) \times (0,1) -// u = 0 on \partial \Omega -// -// for use as a driver for various nox-tpetra tests - -// Tpetra support -#include "NOX_TpetraTypedefs.hpp" -#include "NOX_Tpetra_Interface_Jacobian.hpp" -#include "NOX_Tpetra_Interface_Preconditioner.hpp" -#include "NOX_Tpetra_Interface_Required.hpp" - -namespace Laplace2D { - -// this is required to know the number of lower, upper, left and right -// node for each node of the Cartesian grid (composed by nx \timex ny -// elements) - -void -get_myNeighbours( const int i, const int nx, const int ny, - int & left, int & right, - int & lower, int & upper); - - -// This function creates a CrsMatrix, whose elements corresponds -// to the discretization of a Laplacian over a Cartesian grid, -// with nx grid point along the x-axis and and ny grid points -// along the y-axis. For the sake of simplicity, I suppose that -// all the nodes in the matrix are internal nodes (Dirichlet -// boundary nodes are supposed to have been already condensated) - -TCsrMatrix * -CreateLaplacian( const int nx, const int ny, const Teuchos::RCP >& comm); - -// ========================================================================== -// This class contians the main definition of the nonlinear problem at -// hand. A method is provided to compute F(x) for a given x, and another -// method to update the entries of the Jacobian matrix, for a given x. -// As the Jacobian matrix J can be written as -// J = L + diag(lambda*exp(x[i])), -// where L corresponds to the discretization of a Laplacian, and diag -// is a diagonal matrix with lambda*exp(x[i]). Basically, to update -// the jacobian we simply update the diagonal entries. Similarly, to compute -// F(x), we reset J to be equal to L, then we multiply it by the -// (distributed) vector x, then we add the diagonal contribution -// ========================================================================== - -} // namespace Laplace2D - - -class PDEProblem -{ - -public: - - // constructor. Requires the number of nodes along the x-axis - // and y-axis, the value of lambda, and the communicator - // (to define a Map, which is a linear map in this case) - PDEProblem(const int nx, const int ny, const double lambda, - const Teuchos::RCP >& comm); - - // destructor - ~PDEProblem(); - - // compute F(x) - void computeF(const TVector & x, TVector & f); - - // update the Jacobian matrix for a given x - void updateJacobian(const TVector & x); - - // returns a pointer to the internally stored matrix - TCsrMatrix * getMatrix() - { - return matrix_; - } - -private: - - int nx_, ny_; - double hx_, hy_; - TCsrMatrix * matrix_; - double lambda_; - -}; /* class PDEProblem */ - -// ========================================================================== -// This is the main NOX class for this example. Here we define -// the interface between the nonlinear problem at hand, and NOX. -// The constructor accepts a PDEProblem object. Using a pointer -// to this object, we can update the Jacobian and compute F(x), -// using the definition of our problem. This interface is bit -// crude: For instance, no PrecMatrix nor Preconditioner is specified. -// ========================================================================== - -class SimpleProblemInterface : public NOX::Tpetra::Interface::Required , // TODO: no tpetra alternaative create it - public NOX::Tpetra::Interface::Jacobian , // TODO: no tpetra alternaative create it - public NOX::Tpetra::Interface::Preconditioner // TODO: no tpetra alternaative create it -{ - -public: - - //! Constructor - SimpleProblemInterface( PDEProblem * Problem ) : - Problem_(Problem) {}; - - //! Destructor - ~SimpleProblemInterface() - { - }; - - bool computeF(const TVector & x, TVector & f, - NOX::Tpetra::Interface::Required::FillType F ) - { - problem_->computeF(x,f); - return true; - }; - - bool computeJacobian(const TVector & x, TOperator & Jac) - { - - problem_->updateJacobian(x); - return true; - } - - bool computePreconditioner(const TVector & x, TOperator & Op, Teuchos::ParameterList *) - { - - problem_->updateJacobian(x); - return true; - } - - bool computePrecMatrix(const TVector & x, TRowMatrix & M) - { - std::cout << "*ERR* SimpleProblem::preconditionVector()\n"; - std::cout << "*ERR* don't use explicit preconditioning" << std::endl; - throw 1; - } - -private: - - PDEProblem * problem_; - -}; /* class SimpleProblemInterface */ - diff --git a/packages/nox/test/tpetra/NOX_Operators/src/CMakeLists.txt b/packages/nox/test/tpetra/NOX_Operators/src/CMakeLists.txt deleted file mode 100644 index fea9a51bf6e9..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -APPEND_GLOB(HEADERS ${DIR}/*.hpp) -APPEND_GLOB(SOURCES ${DIR}/*.cpp) \ No newline at end of file diff --git a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_FiniteDifference.cpp b/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_FiniteDifference.cpp deleted file mode 100644 index 274a97b4b26e..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_FiniteDifference.cpp +++ /dev/null @@ -1,631 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#include "NOX_Tpetra_FiniteDifference.hpp" - -#include "NOX_Abstract_Group.H" -#include "NOX_Tpetra_Vector.H" -#include "Teuchos_ParameterList.hpp" -#include "NOX_Utils.H" - -using namespace NOX; -using namespace NOX::Tpetra; - -FiniteDifference::FiniteDifference( - Teuchos::ParameterList& printingParams, - const Teuchos::RCP& i, - const NOX::Tpetra::Vector& x, - double beta_, - double alpha_) : - utils(printingParams), - interface(i), - x_perturb(x.getTpetraVector()), - fo(x.getTpetraVector()), - fp(x.getTpetraVector()), - Jc(x.getTpetraVector()), - alpha(alpha_), - beta(beta_), - betaType(Scalar), - diffType(Forward), - label("NOX::FiniteDifference Jacobian"), - useGroupForComputeF(false) -{ - // Create the finite difference Jacobian matrix - jacobian = createGraphAndJacobian(*i, x.getTpetraVector()); -} - -FiniteDifference:: -FiniteDifference( - Teuchos::ParameterList& printingParams, - const Teuchos::RCP& i, - const NOX::Tpetra::Vector& x, - const Teuchos::RCP& beta_, - double alpha_) : - utils(printingParams), - interface(i), - x_perturb(x.getTpetraVector()), - fo(x.getTpetraVector()), - fp(x.getTpetraVector()), - Jc(x.getTpetraVector()), - alpha(alpha_), - beta(0), - betaVector(beta_), - betaType(Vector), - diffType(Forward), - label("NOX::FiniteDifference Jacobian"), - useGroupForComputeF(false) -{ - // Create the finite difference Jacobian matrix - jacobian = createGraphAndJacobian(*i, x.getTpetraVector()); -} - -FiniteDifference::FiniteDifference( - Teuchos::ParameterList& printingParams, - const Teuchos::RCP& i, - const NOX::Tpetra::Vector& x, - const Teuchos::RCP& userGraph, - double beta_, - double alpha_) : - utils(printingParams), - graph(userGraph), - interface(i), - x_perturb(x.getTpetraVector()), - fo(x.getTpetraVector()), - fp(x.getTpetraVector()), - Jc(x.getTpetraVector()), - alpha(alpha_), - beta(beta_), - betaType(Scalar), - diffType(Forward), - label("NOX::FiniteDifference Jacobian"), - useGroupForComputeF(false) -{ - // Create the finite difference Jacobian matrix directly using a - // user supplied graph. - jacobian = Teuchos::rcp(new TCrsMatrix(Copy, *graph)); - jacobian->FillComplete(); -} - -FiniteDifference::FiniteDifference( - Teuchos::ParameterList& printingParams, - const Teuchos::RCP& i, - const NOX::Tpetra::Vector& x, - const Teuchos::RCP& userGraph, - const Teuchos::RCP& beta_, - double alpha_) : - utils(printingParams), - graph(userGraph), - interface(i), - x_perturb(x.getTpetraVector()), - fo(x.getTpetraVector()), - fp(x.getTpetraVector()), - Jc(x.getTpetraVector()), - alpha(alpha_), - beta(0), - betaVector(beta_), - betaType(Vector), - diffType(Forward), - label("NOX::FiniteDifference Jacobian"), - useGroupForComputeF(false) -{ - // Create the finite difference Jacobian matrix directly using a - // user supplied graph. - jacobian = Teuchos::rcp(new TCrsMatrix(Copy, *graph)); - jacobian->FillComplete(); -} - -FiniteDifference::~FiniteDifference() -{ - -} - -const char* FiniteDifference::Label () const -{ - return label.c_str(); -} - -int FiniteDifference::SetUseTranspose(bool use_transpose) -{ - return jacobian->SetUseTranspose(use_transpose); -} - -int FiniteDifference::Apply(const TMultiVector& X, TMultiVector& Y) const -{ - return jacobian->Apply(X, Y); -} - -int FiniteDifference::ApplyInverse(const TMultiVector& X, TMultiVector& Y) const -{ - return jacobian->ApplyInverse(X, Y); -} - -bool FiniteDifference::UseTranspose() const -{ - return jacobian->UseTranspose(); -} - -bool FiniteDifference::HasNormInf() const -{ - return jacobian->HasNormInf(); -} - -const TMap& FiniteDifference::OperatorDomainMap() const -{ - return jacobian->OperatorDomainMap(); -} - -const TMap& FiniteDifference::OperatorRangeMap() const -{ - return jacobian->OperatorRangeMap(); -} - -bool FiniteDifference::Filled() const -{ - return jacobian->Filled(); -} - -int FiniteDifference::NumMyRowEntries(int MyRow, int & NumEntries) const -{ - return jacobian->NumMyRowEntries(MyRow, NumEntries); -} - -int FiniteDifference::MaxNumEntries() const -{ - return jacobian->MaxNumEntries(); -} - -int FiniteDifference::ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const -{ - return jacobian->ExtractMyRowCopy(MyRow, Length, NumEntries, Values, Indices); -} - -int FiniteDifference::ExtractDiagonalCopy(TVector & Diagonal) const -{ - return jacobian->ExtractDiagonalCopy(Diagonal); -} - -int FiniteDifference::Multiply(bool TransA, const TMultiVector& X, TMultiVector& Y) const -{ - return jacobian->Multiply(TransA, X, Y); -} - -int FiniteDifference::Solve(bool Upper, bool Trans, bool UnitDiagonal, const TMultiVector& X, TMultiVector& Y) const -{ - return jacobian->Solve(Upper, Trans, UnitDiagonal, X, Y); -} - -int FiniteDifference::InvRowSums(TVector& x) const -{ - return jacobian->InvRowSums(x); -} - -int FiniteDifference::LeftScale(const TVector& x) -{ - return jacobian->LeftScale(x); -} - -int FiniteDifference::InvColSums(TVector& x) const -{ - return jacobian->InvColSums(x); -} - -int FiniteDifference::RightScale(const TVector& x) -{ - return jacobian->RightScale(x); -} - -double FiniteDifference::NormInf() const -{ - return jacobian->NormInf(); -} - -double FiniteDifference::NormOne() const -{ - return jacobian->NormOne(); -} - -#ifndef TPETRA_NO_32BIT_GLOBAL_INDICES -int FiniteDifference::NumGlobalNonzeros() const -{ - return jacobian->NumGlobalNonzeros(); -} - -int FiniteDifference::NumGlobalRows() const -{ - return jacobian->NumGlobalRows(); -} - -int FiniteDifference::NumGlobalCols() const -{ - return jacobian->NumGlobalCols(); -} - -int FiniteDifference::NumGlobalDiagonals() const -{ - return jacobian->NumGlobalDiagonals(); -} -#endif - -long long FiniteDifference::NumGlobalNonzeros64() const -{ - return jacobian->NumGlobalNonzeros64(); -} - -long long FiniteDifference::NumGlobalRows64() const -{ - return jacobian->NumGlobalRows64(); -} - -long long FiniteDifference::NumGlobalCols64() const -{ - return jacobian->NumGlobalCols64(); -} - -long long FiniteDifference::NumGlobalDiagonals64() const -{ - return jacobian->NumGlobalDiagonals64(); -} - -int FiniteDifference::NumMyNonzeros() const -{ - return jacobian->NumMyNonzeros(); -} - -int FiniteDifference::NumMyRows() const -{ - return jacobian->NumMyRows(); -} - -int FiniteDifference::NumMyCols() const -{ - return jacobian->NumMyCols(); -} - -int FiniteDifference::NumMyDiagonals() const -{ - return jacobian->NumMyDiagonals(); -} - -bool FiniteDifference::LowerTriangular() const -{ - return jacobian->LowerTriangular(); -} - -bool FiniteDifference::UpperTriangular() const -{ - return jacobian->UpperTriangular(); -} - -const Epetra_Comm& FiniteDifference::Comm() const -{ - return jacobian->Comm(); -} - -const TMap& FiniteDifference::RowMatrixRowMap() const -{ - return jacobian->RowMatrixRowMap(); -} - -const TMap& FiniteDifference::RowMatrixColMap() const -{ - return jacobian->RowMatrixColMap(); -} - -const TImport* FiniteDifference::RowMatrixImporter() const -{ - return jacobian->RowMatrixImporter(); -} - -const TBlockMap& FiniteDifference::Map() const -{ - return jacobian->Map(); -} - -bool FiniteDifference::computeJacobian(const TVector& x) -{ - return( computeJacobian(x, *this)); -} - -bool FiniteDifference::computeJacobian(const TVector& x, TOperator& Jac) -{ - // First check to make sure Jac is a NOX::Tpetra::FiniteDifference object - FiniteDifference* testMatrix = dynamic_cast(&Jac); - if (testMatrix == 0) { - utils.out() << "ERROR: NOX::Tpetra::FiniteDifference::computeJacobian() - " - << "Jacobian to evaluate is not a FiniteDifference object!" - << std::endl; - throw std::runtime_error("NOX Error"); - } - - const TBlockMap& map = fo.Map(); - - // We need the TCrsMatrix inside the FiniteDifference object - // for the correct insertion commands. - TCrsMatrix& jac = *testMatrix->jacobian; - - // Zero out Jacobian - jac.PutScalar(0.0); - - // Create an extra perturbed residual vector pointer if needed - if ( diffType == Centered ) - if ( Teuchos::is_null(fmPtr) ) - fmPtr = Teuchos::rcp(new TVector(x)); - - double scaleFactor = 1.0; - if ( diffType == Backward ) - scaleFactor = -1.0; - - double eta = 0.0; // Value to perturb the solution vector - -#ifndef TPETRA_NO_32BIT_GLOBAL_INDICES - int min = map.MinAllGID(); // Minimum Global ID value - int max = map.MaxAllGID(); // Maximum Global ID value - int myMin = map.MinMyGID(); // Minimum Local ID value - int myMax = map.MaxMyGID(); // Maximum Local ID value -#else - long long min = map.MinAllGID64(); // Minimum Global ID value - long long max = map.MaxAllGID64(); // Maximum Global ID value - long long myMin = map.MinMyGID64(); // Minimum Local ID value - long long myMax = map.MaxMyGID64(); // Maximum Local ID value -#endif - - // Compute the RHS at the initial solution - computeF(x, fo, NOX::Tpetra::Interface::Required::FD_Res); - - x_perturb = x; - - // loop over each global unknown -#ifndef TPETRA_NO_32BIT_GLOBAL_INDICES -int k; -#else - long long k; -#endif - for (k = min; k < max+1; k++) { - - // Perturb the solution vector via local IDs only if it is owned by - // this processor - int proc = 0; - if (map.MyGID(k)) { - - if (betaType == Scalar) - eta = alpha*x[map.LID(k)] + beta; - else - eta = alpha*x[map.LID(k)] + (*betaVector)[map.LID(k)]; - - x_perturb[map.LID(k)] += scaleFactor * eta; - proc = map.Comm().MyPID(); - } - - // Find what proc eta is on - int broadcastProc = 0; - map.Comm().SumAll(&proc ,&broadcastProc , 1); - // Send the perturbation variable, eta, to all processors - map.Comm().Broadcast(&eta, 1, broadcastProc); - - // Compute the perturbed RHS - computeF(x_perturb,fp, NOX::Tpetra::Interface::Required::FD_Res); - - if ( diffType == Centered ) { - if (map.MyGID(k)) - x_perturb[map.LID(k)] -= 2.0 * eta; - computeF(x_perturb,*fmPtr, NOX::Tpetra::Interface::Required::FD_Res); - } - - // Compute the column k of the Jacobian - if ( diffType != Centered ) { - Jc.Update(1.0, fp, -1.0, fo, 0.0); - Jc.Scale( 1.0/(scaleFactor * eta) ); - } - else { - Jc.Update(1.0, fp, -1.0, *fmPtr, 0.0); - Jc.Scale( 1.0/(2.0 * eta) ); - } - - // Insert nonzero column entries into the jacobian -#ifndef TPETRA_NO_32BIT_GLOBAL_INDICES - int j; -#else - long long j; -#endif - for (j = myMin; j < myMax+1; j++) { - if (!map.MyGID(j)) - continue; - if (Jc[map.LID(j)] != 0.0) { - jac.ReplaceGlobalValues(j,1,&Jc[map.LID(j)],&k); - } - } - - // Unperturb the solution vector - x_perturb = x; - - } - - jac.FillComplete(); - - return true; -} - -bool FiniteDifference::computePreconditioner(const TVector& x, - Epetra_Operator& /* Prec */, - Teuchos::ParameterList* /* precParams */) -{ - return computeJacobian(x, *this); -} - -Teuchos::RCP FiniteDifference:: -createGraphAndJacobian(Interface::Required& /* i */, const TVector& x) -{ - - const TBlockMap& map = fo.Map(); - - double eta = 0.0; // Value to perturb the solution vector - -#ifndef TPETRA_NO_32BIT_GLOBAL_INDICES - int min = map.MinAllGID(); // Minimum Global ID value - int max = map.MaxAllGID(); // Maximum Global ID value - int myMin = map.MinMyGID(); // Minimum Local ID value - int myMax = map.MaxMyGID(); // Maximum Local ID value -#else - long long min = map.MinAllGID64(); // Minimum Global ID value - long long max = map.MaxAllGID64(); // Maximum Global ID value - long long myMin = map.MinMyGID64(); // Minimum Local ID value - long long myMax = map.MaxMyGID64(); // Maximum Local ID value -#endif - - // Create the graph - graph = Teuchos::rcp(new TCrsGraph(Copy,map,10)); - - // Compute the RHS at the initial solution - computeF(x, fo, NOX::Tpetra::Interface::Required::FD_Res); - - // loop over each global unknown -#ifndef TPETRA_NO_32BIT_GLOBAL_INDICES - int k; -#else - long long k; -#endif - for (k = min; k < max+1; k++) { - - // Perturb the solution vector via local IDs only if it is owned by - // this processor - if (map.MyGID(k)) { - - if (betaType == Scalar) - eta = alpha*x[map.LID(k)] + beta; - else - eta = alpha*x[map.LID(k)] + (*betaVector)[map.LID(k)]; - - x_perturb[map.LID(k)] += eta; - } - - // Compute the perturbed RHS - computeF(x_perturb, fp, NOX::Tpetra::Interface::Required::FD_Res); - - // Compute the column k of the Jacobian - Jc.Update(1.0, fp, -1.0, fo, 0.0); - //Jc.Scale(1.0/eta); - - // Insert column entries into the graph -#ifndef TPETRA_NO_32BIT_GLOBAL_INDICES - int j; -#else - long long j; -#endif - for (j = myMin; j < myMax+1; j++) { - // Allow for the possibility that rows j from myMin to myMax are not necessarily contigous - if (!map.MyGID(j)) - continue; - if (Jc[map.LID(j)] != 0.0) { - graph->InsertGlobalIndices(j,1,&k); - } - } - - // Unperturb the solution vector - x_perturb = x; - - } - - graph->FillComplete(); - jacobian = Teuchos::rcp(new TCrsMatrix(Copy, *graph)); - jacobian->FillComplete(); - - return jacobian; - -} - -void FiniteDifference::setDifferenceMethod(DifferenceType diffType_) -{ - diffType = diffType_; -} - -TCrsMatrix& FiniteDifference::getUnderlyingMatrix() const -{ - return *jacobian; -} - -void FiniteDifference::Print(std::ostream& strm) const -{ - jacobian->Print(strm); -} - -void FiniteDifference::setGroupForComputeF(NOX::Abstract::Group& group) -{ - useGroupForComputeF = true; - groupPtr = group.clone(); - return; -} - - -bool FiniteDifference::computeF(const TVector& input, - TVector& result, - NOX::Tpetra::Interface::Required::FillType) -{ - bool ok = false; - - if (!useGroupForComputeF) - ok = interface->computeF(input, result, - NOX::Tpetra::Interface::Required::FD_Res); - else { - - // Get rid of const for NOX::Tpetra:Vector Ctor. - TVector& nonconstInput = const_cast(input); - - Teuchos::RCP tmpEpetraInputVec = - //Teuchos::rcp(&nonconstInput, false); - Teuchos::rcp(new TVector(nonconstInput)); - NOX::Tpetra::Vector noxX(tmpEpetraInputVec, - NOX::Tpetra::Vector::CreateCopy); - groupPtr->setX(noxX); - groupPtr->computeF(); - result = dynamic_cast - (groupPtr->getF()).getTpetraVector(); - ok = true; - - } - - return ok; -} diff --git a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_FiniteDifference.hpp b/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_FiniteDifference.hpp deleted file mode 100644 index d69c7b0edbe3..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_FiniteDifference.hpp +++ /dev/null @@ -1,363 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#ifndef NOX_TPETRA_FINITEDIFFERENCE_H -#define NOX_TPETRA_FINITEDIFFERENCE_H - -#include "NOX_Tpetra_Interface_Jacobian.H" // base class -#include "NOX_Tpetra_Interface_Preconditioner.H" // base class - -#include "NOX_Epetra_Interface_Required.H" // for enum FillType -#include "NOX_Common.H" // for -#include "Teuchos_RCP.hpp" -#include "TVector.h" - -// Forward Declarations; -class TMap; -class TImport; -class TVector; -class TCrsGraph; -class TCrsMatrix; - -namespace NOX { - namespace Abstract { - class Group; - } - namespace Tpetra { - class Vector; - } -} - -namespace NOX { - -namespace Tpetra { - - /*! \brief Concrete implementation for creating an TRowMatrix Jacobian via finite differencing of the residual. - -The Jacobian entries are calculated via 1st order finite differencing. -This requires \f$ N + 1 \f$ calls to computeF() where \f$ N \f$ is the -number of unknowns in the problem. - - \f[ J_{ij} = \frac{\partial F_i}{\partial x_j} = \frac{F_i(x+\delta\mathbf{e}_j) - F_i(x)}{\delta} \f] - -where \f$ J\f$ is the Jacobian, \f$ F\f$ is the function evaluation, -\f$ x\f$ is the solution vector, and \f$\delta\f$ is a small -perturbation to the \f$ x_j\f$ entry. - -The perturbation, \f$ \delta \f$, is calculated based on one of the -following equations: - -\f[ \delta = \alpha * | x_j | + \beta \f] -\f[ \delta = \alpha * | x_j | + \beta_j \f] - -where \f$ \alpha \f$ is a scalar value (defaults to 1.0e-4) and \f$ -\beta \f$ can be either a scalar or a vector (defaults to a scalar -value of 1.0e-6). The choice is defined by the type of constructor -used. All parameters are supplied in the constructor. In addition to -the forward difference derivative approximation, backward or centered -differences can be used via the setDifferenceMethod function. Note -that centered difference provides second order spatial accuracy but at -the cost of twice as many function evaluations. - - Since this inherits from the TRowMatrix class, it can be used as the preconditioning matrix for AztecOO preconditioners. This method is very inefficient when computing the Jacobian and is not recommended for large-scale systems but only for debugging purposes. - */ -class FiniteDifference : public TRowMatrix, - public NOX::Tpetra::Interface::Jacobian, - public NOX::Tpetra::Interface::Preconditioner { - - public: - - //! Define types for use of the perturbation parameter \f$ \delta\f$. - enum DifferenceType {Forward, Backward, Centered}; - - //! Constructor with scalar beta. - FiniteDifference(Teuchos::ParameterList& printingParams, - const Teuchos::RCP& i, - const NOX::Tpetra::Vector& initialGuess, - double beta = 1.0e-6, - double alpha = 1.0e-4); - - //! Constructor with vector beta. - FiniteDifference(Teuchos::ParameterList& printingParams, - const Teuchos::RCP& i, - const NOX::Tpetra::Vector& initialGuess, - const Teuchos::RCP& beta, - double alpha = 1.0e-4); - - //! Constructor that takes a pre-constructed TCrsGraph so it does not have to determine the non-zero entries in the matrix. - FiniteDifference(Teuchos::ParameterList& printingParams, - const Teuchos::RCP& i, - const NOX::Tpetra::Vector& initialGuess, - const Teuchos::RCP& g, - double beta = 1.0e-6, - double alpha = 1.0e-4); - - //! Constructor with output control that takes a pre-constructed TCrsGraph so it does not have to determine the non-zero entries in the matrix. - FiniteDifference(Teuchos::ParameterList& printingParams, - const Teuchos::RCP& i, - const NOX::Tpetra::Vector& initialGuess, - const Teuchos::RCP& g, - const Teuchos::RCP& beta, - double alpha = 1.0e-4); - - //! Pure virtual destructor - virtual ~FiniteDifference(); - - //! Returns a character std::string describing the name of the operator - virtual const char* Label () const; - - //! If set true, the transpose of this operator will be applied - virtual int SetUseTranspose(bool UseTranspose); - - //! Return the result on an Epetra_Operator applied to an TMultiVector X in Y. - virtual int Apply(const TMultiVector& X, TMultiVector& Y) const; - - //! Return the result on an Epetra_Operator inverse applied to an TMultiVector X in Y. - virtual int ApplyInverse(const TMultiVector& X, TMultiVector& Y) const; - - //! Returns the current use transpose setting - virtual bool UseTranspose() const; - - //! Returns true if the this object can provide an approximate Inf-norm, false otherwise. - virtual bool HasNormInf() const; - - //!Returns the TBlockMap object associated with the domain of this matrix operator. - virtual const TMap & OperatorDomainMap() const; - - //!Returns the TBlockMap object associated with the range of this matrix operator. - virtual const TMap & OperatorRangeMap() const; - - //! See TRowMatrix documentation. - virtual bool Filled() const; - - //! See TRowMatrix documentation. - virtual int NumMyRowEntries(int MyRow, int & NumEntries) const; - - //! See TRowMatrix documentation. - virtual int MaxNumEntries() const; - - //! See TRowMatrix documentation. - virtual int ExtractMyRowCopy(int MyRow, int Length, int & NumEntries, double *Values, int * Indices) const; - - //! See TRowMatrix documentation. - virtual int ExtractDiagonalCopy(TVector & Diagonal) const; - - //! See TRowMatrix documentation. - virtual int Multiply(bool TransA, const TMultiVector& X, TMultiVector& Y) const; - - //! See TRowMatrix documentation. - virtual int Solve(bool Upper, bool Trans, bool UnitDiagonal, const TMultiVector& X, TMultiVector& Y) const; - - //! See TRowMatrix documentation. - virtual int InvRowSums(TVector& x) const; - - //! See TRowMatrix documentation. - virtual int LeftScale(const TVector& x); - - //! See TRowMatrix documentation. - virtual int InvColSums(TVector& x) const; - - //! See TRowMatrix documentation. - virtual int RightScale(const TVector& x); - - //! See TRowMatrix documentation. - virtual double NormInf() const; - - //! See TRowMatrix documentation. - virtual double NormOne() const; - - //! See TRowMatrix documentation. -#ifndef TPETRA_NO_32BIT_GLOBAL_INDICES - virtual int NumGlobalNonzeros() const; -#endif - virtual long long NumGlobalNonzeros64() const; - - //! See TRowMatrix documentation. -#ifndef TPETRA_NO_32BIT_GLOBAL_INDICES - virtual int NumGlobalRows() const; -#endif - virtual long long NumGlobalRows64() const; - - //! See TRowMatrix documentation. -#ifndef TPETRA_NO_32BIT_GLOBAL_INDICES - virtual int NumGlobalCols() const; -#endif - virtual long long NumGlobalCols64() const; - - //! See TRowMatrix documentation. -#ifndef TPETRA_NO_32BIT_GLOBAL_INDICES - virtual int NumGlobalDiagonals() const; -#endif - virtual long long NumGlobalDiagonals64() const; - - //! See TRowMatrix documentation. - virtual int NumMyNonzeros() const; - - //! See TRowMatrix documentation. - virtual int NumMyRows() const; - - //! See TRowMatrix documentation. - virtual int NumMyCols() const; - - //! See TRowMatrix documentation. - virtual int NumMyDiagonals() const; - - //! See TRowMatrix documentation. - virtual bool LowerTriangular() const; - - //! See TRowMatrix documentation. - virtual bool UpperTriangular() const; - - //! See TRowMatrix documentation. - virtual const Teuchos::RCP>& comm() const; - - //! See TRowMatrix documentation. - virtual const TMap & RowMatrixRowMap() const; - - //! See TRowMatrix documentation. - virtual const TMap & RowMatrixColMap() const; - - //! See TRowMatrix documentation. - virtual const TImport * RowMatrixImporter() const; - - //! See Epetra_SrcDistObj documentation. - virtual const TBlockMap& Map() const; - - //! Compute Jacobian given the specified input vector, x. Returns true if computation was successful. - virtual bool computeJacobian(const TVector& x, TOperator& Jac); - - //! Compute Jacobian given the specified input vector, x. Returns true if computation was successful. - virtual bool computeJacobian(const TVector& x); - - //! Compute an TRowMatrix to be used by Aztec preconditioners given the specified input vector, x. Returns true if computation was successful. - virtual bool computePreconditioner(const TVector& x, - TOperator& Prec, - Teuchos::ParameterList* precParams = 0); - - //! Set the type of perturbation method used (default is Forward) - virtual void setDifferenceMethod( DifferenceType type ); - - //! An accessor method for the underlying TCrsMatrix - virtual TCrsMatrix& getUnderlyingMatrix() const; - - //! Output the underlying matrix - virtual void Print(std::ostream&) const; - - //! Register a NOX::Abstract::Group derived object and use the computeF() method of that group for the perturbation instead of the NOX::Tpetra::Interface::Required::computeF() method. This is required for LOCA to get the operators correct during homotopy. - void setGroupForComputeF(NOX::Abstract::Group& group); - -protected: - - //! Constructs an TCrsGraph and TRowMatrix for the Jacobian. This is only called if the user does not supply an TCrsGraph. - Teuchos::RCP - createGraphAndJacobian(Interface::Required& i, const TVector& x); - - bool computeF(const TVector& input, TVector& result, - NOX::Tpetra::Interface::Required::FillType); - -protected: - - //! Printing Utilities object - const NOX::Utils utils; - - //! Pointer to the Jacobian graph. - Teuchos::RCP graph; - - //! Pointer to the Jacobian. - Teuchos::RCP jacobian; - - //! User provided interface function. - Teuchos::RCP interface; - - //! Perturbed solution vector - a work array that needs to be mutable. - mutable TVector x_perturb; - - //! Function evaluation at currentX - a work array that needs to be mutable. - mutable TVector fo; - - //! Function evaluation at perturbX - a work array that needs to be mutable. - mutable TVector fp; - - //! Optional pointer to function evaluation at -perturbX - needed only for centered finite differencing - Teuchos::RCP fmPtr; - - //! Column vector of the jacobian - a work array that needs to be mutable. - mutable TVector Jc; - - //! Constant for the perturbation calculation. - double alpha; - - //! Constant for the perturbation calculation. - double beta; - - //! Vector for the perturbation calculation. - Teuchos::RCP betaVector; - - //! Define types for the \f$ \beta \f$ parameter during the - //! computation of the perturbation parameter \f$ \delta\f$. - enum BetaType {Scalar, Vector}; - - //! Flag that sets whether \f$ \beta \f$ is a scalar or a vector. - BetaType betaType; - - //! Define types for use of the perturbation parameter \f$ \delta\f$. - DifferenceType diffType; - - //! label for the TRowMatrix - std::string label; - - //! Flag to enables the use of a group instead of the interface for the computeF() calls in the directional difference calculation. - bool useGroupForComputeF; - - //! Pointer to the group for possible use in computeF() calls. - Teuchos::RCP groupPtr; - -}; -} // namespace Tpetra -} // namespace NOX - -#endif /* NOX_TPETRA_FINITEDIFFERENCE_H */ diff --git a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Interface_Jacobian.hpp b/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Interface_Jacobian.hpp deleted file mode 100644 index a01f35b36804..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Interface_Jacobian.hpp +++ /dev/null @@ -1,90 +0,0 @@ -// $Id$ -// $Source$ - -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#ifndef NOX_TPETRA_INTERFACE_JACOBIAN_H -#define NOX_TPETRA_INTERFACE_JACOBIAN_H - -#include "NOX_Common.H" - -// Forward declarations -class TVector; -class TOperator; - -namespace NOX { -namespace Tpetra { -namespace Interface { - - /*! \brief Used by NOX::Tpetra to provide a link to the - external code for Jacobian fills. - - This is only required if the user wishes to supply their own Jacobian - operator. - */ -class Jacobian { - -public: - - //! Constructor. - Jacobian() {}; - - //! Destructor. - virtual ~Jacobian() {}; - - /*! Compute Jacobian given the specified input vector x. Returns - true if computation was successful. - */ - virtual bool computeJacobian(const Tpetra_Vector& x, Tpetra_Operator& Jac) = 0; - -}; -} // namespace Interface -} // namespace Tpetra -} // namespace NOX - -#endif diff --git a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Interface_Preconditioner.hpp b/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Interface_Preconditioner.hpp deleted file mode 100644 index 0ff845112279..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Interface_Preconditioner.hpp +++ /dev/null @@ -1,93 +0,0 @@ -// $Id$ -// $Source$ - -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#ifndef NOX_TPETRA_INTERFACE_PRECONDITIONER_H -#define NOX_TPETRA_INTERFACE_PRECONDITIONER_H - -#include "NOX_Common.H" - -// Forward declarations -class Tpetra_Vector; -class Tpetra_Operator; -namespace Teuchos { - class ParameterList; -} - -namespace NOX { -namespace Tpetra { -namespace Interface { - - /*! \brief Used by NOX::Tpetra to provide a link to the - external code for Precondtioner fills. - - This is only required if the user wishes to supply their own - preconditioner operator. - */ -class Preconditioner { - -public: - - //! Constructor - Preconditioner() {}; - - //! Destructor - virtual ~Preconditioner() {}; - - //! Computes a user defined preconditioner. - virtual bool computePreconditioner(const Tpetra_Vector& x, - Tpetra_Operator& M, - Teuchos::ParameterList* precParams = 0) = 0; - -}; -} // namespace Interface -} // namespace Tpetra -} // namespace NOX - -#endif diff --git a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Interface_Required.hpp b/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Interface_Required.hpp deleted file mode 100644 index e6d175275a6d..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Interface_Required.hpp +++ /dev/null @@ -1,122 +0,0 @@ -// $Id$ -// $Source$ - -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#ifndef NOX_TPETRA_INTERFACE_REQUIRED_H -#define NOX_TPETRA_INTERFACE_REQUIRED_H - -#include "NOX_Common.H" - -// Forward declarations -class Tpetra_Vector; - -namespace NOX { -namespace Tpetra { - - /*! - \brief Provides a set of interfaces for users to provide information about the nonlinear problem to NOX. - - Contains interfaces for the user to supply (1) the evaluation of the nonlinear equations, (2) the Jacobian, and (3) any preconditioning if required. - */ -namespace Interface { - - /*! - \brief Supplies NOX with the set nonlinear equations. - - This is the minimum required information to solve a nonlinear - problem using the NOX::Tpetra objects for the linear algebra - implementation. Used by NOX::Tpetra::Group to provide a link - to the external code for residual fills. - */ -class Required { - -public: - - //! Type of fill that a computeF() method is used for. - /*! computeF() can be called for a variety of reasons: - - - To evaluate the function residuals. - - To be used in an approximation to the Jacobian (finite difference or directional derivative). - - To be used in an approximation to the preconditioner. - - This flag tells computeF() what the evaluation is used for. This allows the user to change the fill process to eliminate costly terms. For example, sometimes, terms in the function are very expensive and can be ignored in a Jacobian calculation. The user can query this flag and determine not to recompute such terms if the computeF() is used in a Jacobian calculation. - */ - enum FillType { - //! The exact residual (F) is being calculated. - Residual, - //! The Jacobian matrix is being estimated. - Jac, - //! The preconditioner matrix is being estimated. - Prec, - //! The fill context is from a FD approximation (includes FDC) - FD_Res, - //! The fill context is from a MF approximation - MF_Res, - //! The fill context is from a MF computeJacobian() approximation - MF_Jac, - //! A user defined estimation is being performed. - User - }; - - //! Constructor - Required() {}; - - //! Destructor - virtual ~Required() {}; - - //! Compute the function, F, given the specified input vector x. Returns true if computation was successful. - virtual bool computeF(const Tpetra_Vector& x, Tpetra_Vector& F, - const FillType fillFlag) = 0; - -}; -} // namespace Interface -} // namespace Tpetra -} // namespace NOX - -#endif diff --git a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Scaling.cpp b/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Scaling.cpp deleted file mode 100644 index 95450aa473c6..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Scaling.cpp +++ /dev/null @@ -1,259 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#include "NOX_Tpetra_Scaling.hpp" - -// #include "Epetra_Vector.h" -// #include "Epetra_Operator.h" -// #include "TRowMatrix.h" -// #include "TLinearProblem.h" - -#include "NOX_Utils.H" - -NOX::Tpetra::Scaling::Scaling() -{ - -} - -NOX::Tpetra::Scaling::~Scaling() -{ - -} - -void NOX::Tpetra::Scaling::addUserScaling(ScaleType type, const Teuchos::RCP& D) -{ - if ( Teuchos::is_null(tmpVectorPtr) ) - tmpVectorPtr = Teuchos::rcp(new TVector(*D)); - - scaleType.push_back(type); - sourceType.push_back(UserDefined); - scaleVector.push_back(D); -} - -void NOX::Tpetra::Scaling::addRowSumScaling(ScaleType type, const Teuchos::RCP& D) -{ - if ( Teuchos::is_null(tmpVectorPtr) ) - tmpVectorPtr = Teuchos::rcp(new TVector(*D)); - - scaleType.push_back(type); - sourceType.push_back(RowSum); - scaleVector.push_back(D); -} - -void NOX::Tpetra::Scaling::addColSumScaling(ScaleType type, const Teuchos::RCP& D) -{ - if ( Teuchos::is_null(tmpVectorPtr) ) - tmpVectorPtr = Teuchos::rcp(new TVector(*D)); - - scaleType.push_back(type); - sourceType.push_back(ColSum); - scaleVector.push_back(D); -} - -void NOX::Tpetra::Scaling::computeScaling(const TLinearProblem& problem) -{ - - TVector* diagonal = 0; - for (unsigned int i = 0; i < scaleVector.size(); i ++) { - - if (sourceType[i] == RowSum) { - - diagonal = scaleVector[i].get(); - - // Make sure the Jacobian is an TRowMatrix, otherwise we can't - // perform a row sum scale! - const TRowMatrix* test = 0; - test = dynamic_cast(problem.GetOperator()); - if (test == 0) { - std::cout << "ERROR: NOX::Tpetra::Scaling::scaleLinearSystem() - " - << "For \"Row Sum\" scaling, the Matrix must be an " - << "TRowMatrix derived object!" << std::endl; - throw std::runtime_error("NOX Error"); - } - - test->InvRowSums(*diagonal); - diagonal->Reciprocal(*diagonal); - - } - - else if (sourceType[i] == ColSum) { - - diagonal = scaleVector[i].get(); - - // Make sure the Jacobian is an TRowMatrix, otherwise we can't - // perform a row sum scale! - const TRowMatrix* test = 0; - test = dynamic_cast(problem.GetOperator()); - if (test == 0) { - std::cout << "ERROR: NOX::Tpetra::Scaling::scaleLinearSystem() - " - << "For \"Column Sum\" scaling, the Matrix must be an " - << "TRowMatrix derived object!" << std::endl; - throw std::runtime_error("NOX Error"); - } - - test->InvColSums(*diagonal); - diagonal->Reciprocal(*diagonal); - - } - - } - -} - -void NOX::Tpetra::Scaling::scaleLinearSystem(TLinearProblem& problem) -{ - TVector* diagonal = 0; - for (unsigned int i = 0; i < scaleVector.size(); i ++) { - - diagonal = scaleVector[i].get(); - - if (scaleType[i] == Left) { - - tmpVectorPtr->Reciprocal(*diagonal); - problem.LeftScale(*tmpVectorPtr); - - } - else if (scaleType[i] == Right) { - - tmpVectorPtr->Reciprocal(*diagonal); - problem.RightScale(*tmpVectorPtr); - } - - } -} - -void NOX::Tpetra::Scaling::unscaleLinearSystem(TLinearProblem& problem) -{ - TVector* diagonal = 0; - for (unsigned int i = 0; i < scaleVector.size(); i ++) { - - diagonal = scaleVector[i].get(); - - if (scaleType[i] == Left) { - problem.LeftScale(*diagonal); - } - else if (scaleType[i] == Right) { - problem.RightScale(*diagonal); - - } - } -} - -void NOX::Tpetra::Scaling::applyRightScaling(const TVector& input, - TVector& result) -{ - if (scaleVector.size() == 0) { - result = input; - } - else { - TVector* diagonal = 0; - for (unsigned int i = 0; i < scaleVector.size(); i ++) { - - if (scaleType[i] == Right) { - diagonal = scaleVector[i].get(); - - tmpVectorPtr->Reciprocal(*diagonal); - - result.Multiply(1.0, input, *tmpVectorPtr, 0.0); - } - } - } -} - -void NOX::Tpetra::Scaling::applyLeftScaling(const TVector& input, - TVector& result) -{ - if (scaleVector.size() == 0) { - result = input; - } - else { - TVector* diagonal = 0; - for (unsigned int i = 0; i < scaleVector.size(); i ++) { - - if (scaleType[i] == Left) { - diagonal = scaleVector[i].get(); - - tmpVectorPtr->Reciprocal(*diagonal); - - result.Multiply(1.0, input, *tmpVectorPtr, 0.0); - } - } - } -} - -void NOX::Tpetra::Scaling::print(std::ostream& os) -{ - - os << "\n LINEAR SOLVER SCALING:" << std::endl; - - for (unsigned int i = 0; i < scaleVector.size(); i ++) { - - std::string source = " "; - if (sourceType[i] == UserDefined) - source = "User Defined Vector"; - else if (sourceType[i] == RowSum) - source = "Row Sum"; - else if (sourceType[i] == ColSum) - source = "Col Sum"; - - if (scaleType[i] == Left) { - os << " " << (i+1) << ". Left Scaled with " << source << std::endl; - - } - else if (scaleType[i] == Right) - os << " " << (i+1) << ". Right Scaled with " << source << std::endl; - } - - return; -} - -std::ostream& -NOX::Tpetra::operator<<(std::ostream& os, NOX::Tpetra::Scaling& scalingObject) -{ - scalingObject.print(os); - return os; -} diff --git a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Scaling.hpp b/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Scaling.hpp deleted file mode 100644 index 421414025121..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Scaling.hpp +++ /dev/null @@ -1,141 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#ifndef NOX_EPETRA_SCALING_H -#define NOX_EPETRA_SCALING_H - -#include "NOX_Common.H" // for -#include "NOX_Abstract_Vector.H" // -#include "Teuchos_RCP.hpp" -#include -#include - -// Forward Declarations -class TVector; -class TRowMatrix; -class TLinearProblem; -namespace NOX { - class Utils; -} - -namespace NOX { - -namespace Tpetra { - - /*! \brief Object to control scaling of vectors and linear systems. - - Currently this assumes a diagonal scaling only! Once epetra can - do matrix-matrix multiplies we will expand this class. - - */ -class Scaling { - -public: - - //! Describes where the scaling vector comes from. - enum SourceType {None, RowSum, ColSum, UserDefined}; - - //! Describes the type of scaling to apply. - enum ScaleType {Left, Right}; - - //! Constructor. - Scaling(); - - //! Virtual destructor - virtual ~Scaling(); - - //! Add a user supplied diagonal scale vector to the scaling object. - virtual void addUserScaling(ScaleType type, const Teuchos::RCP& D); - - //! Add "Row Sum" scaling to the scaling object. The supplied vector is used to store the current row sum vector. - virtual void addRowSumScaling(ScaleType type, const Teuchos::RCP& D); - - //! Add "Col Sum" scaling to the scaling object. The supplied vector is used to store the current column sum vector. - virtual void addColSumScaling(ScaleType type, const Teuchos::RCP& D); - - //! Computes Row Sum scaling diagonal vectors. Only needs to be called if a row or column sum scaling has been requested. - virtual void computeScaling(const TLinearProblem& problem); - - //! Scales the linear system. - virtual void scaleLinearSystem(TLinearProblem& problem); - - //! Remove the scaling from the linear system. - virtual void unscaleLinearSystem(TLinearProblem& problem); - - //! Applies any RIGHT scaling vectors to an input vector. - virtual void applyRightScaling(const Epetra_Vector& input, - Epetra_Vector& result); - - //! Applies any LEFT scaling vectors to an input vector. - virtual void applyLeftScaling(const Epetra_Vector& input, - Epetra_Vector& result); - - //! Printing - virtual void print(std::ostream& os); - -private: - - //! Scaling type - std::vector scaleType; - - //! Source type - std::vector sourceType; - - //! Scaling vector pointer - std::vector< Teuchos::RCP > scaleVector; - - //! Temporary vector - Teuchos::RCP tmpVectorPtr; - -}; - - std::ostream& operator<<(std::ostream& os, NOX::Tpetra::Scaling& scalingObject); - -} // namespace Epetra -} // namespace NOX - -#endif /* NOX_EPETRA_SCALING_H */ diff --git a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Vector.cpp b/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Vector.cpp deleted file mode 100644 index e0e59d85500e..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Vector.cpp +++ /dev/null @@ -1,360 +0,0 @@ -// $Id$ -// $Source$ - -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#include "NOX_Tpetra_Vector.hpp" -#include "NOX_Tpetra_MultiVector.hpp" -#include "TVector.h" -#include "NOX_Tpetra_VectorSpace_L2.H" - -NOX::Tpetra::Vector:: -Vector(const Teuchos::RCP& source, - NOX::Tpetra::Vector::MemoryType memoryType, - NOX::CopyType type, - Teuchos::RCP vs) -{ - if (Teuchos::is_null(vs)) - vectorSpace = Teuchos::rcp(new NOX::Tpetra::VectorSpaceL2); - else - vectorSpace = vs; - - if (memoryType == NOX::Tpetra::Vector::CreateView) - tpetraVec = source; - else { - - switch (type) { - - case DeepCopy: // default behavior - - tpetraVec = Teuchos::rcp(new TVector(*source)); - break; - - case ShapeCopy: - - tpetraVec = Teuchos::rcp(new TVector(source->Map())); - break; - } - - } -} - -NOX::Tpetra::Vector::Vector(const TVector& source, NOX::CopyType type, - Teuchos::RCP vs) -{ - if (Teuchos::is_null(vs)) - vectorSpace = Teuchos::rcp(new NOX::Tpetra::VectorSpaceL2); - else - vectorSpace = vs; - - switch (type) { - - case DeepCopy: // default behavior - - tpetraVec = Teuchos::rcp(new TVector(source)); - break; - - case ShapeCopy: - - tpetraVec = Teuchos::rcp(new TVector(source.Map())); - break; - - } -} - -NOX::Tpetra::Vector::Vector(const NOX::Tpetra::Vector& source, - NOX::CopyType type) -{ - vectorSpace = source.vectorSpace; - - switch (type) { - - case DeepCopy: // default behavior - - tpetraVec = Teuchos::rcp(new TVector(source.getTpetraVector())); - break; - - case ShapeCopy: - - epetraVec = - Teuchos::rcp(new TVector(source.getTpetraVector().Map())); - break; - - } -} - -NOX::Tpetra::Vector::~Vector() -{ - -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector::operator=(const TVector& source) -{ - tpetraVec->Scale(1.0, source); - return *this; -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector::operator=(const NOX::Abstract::Vector& source) -{ - return operator=(dynamic_cast(source)); -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector::operator=(const NOX::Tpetra::Vector& source) -{ - tpetraVec->Scale(1.0, source.getTpetraVector()); - return *this; -} - -TVector& NOX::Tpetra::Vector::getTpetraVector() -{ - return *tpetraVec; -} - -const TVector& NOX::Tpetra::Vector::getTpetraVector() const -{ - return *tpetraVec; -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector::init(double value) -{ - tpetraVec->PutScalar(value); - return *this; -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector::random(bool useSeed, int seed) -{ - if (useSeed) - tpetraVec->SetSeed(seed); - tpetraVec->Random(); - return *this; -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector::abs(const NOX::Abstract::Vector& base) -{ - return abs(dynamic_cast(base)); -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector::abs(const NOX::Tpetra::Vector& base) -{ - tpetraVec->Abs(base.getTpetraVector()); - return *this; -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector::reciprocal(const NOX::Abstract::Vector& base) -{ - return reciprocal(dynamic_cast(base)); -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector::reciprocal(const NOX::Tpetra::Vector& base) -{ - tpetraVec->Reciprocal(base.getTpetraVector()); - return *this; -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector::scale(double alpha) -{ - tpetraVec->Scale(alpha); - return *this; -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector:: -update(double alpha, const NOX::Abstract::Vector& a, double gamma) -{ - return update(alpha, dynamic_cast(a), gamma); -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector:: -update(double alpha, const NOX::Tpetra::Vector& a, double gamma) -{ - tpetraVec->Update(alpha, a.getTpetraVector(), gamma); - return *this; -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector:: -update(double alpha, const NOX::Abstract::Vector& a, - double beta, const NOX::Abstract::Vector& b, - double gamma) -{ - return update(alpha, dynamic_cast(a), - beta, dynamic_cast(b), gamma); -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector:: -update(double alpha, const NOX::Tpetra::Vector& a, - double beta, const NOX::Tpetra::Vector& b, - double gamma) -{ - tpetraVec->Update(alpha, a.getTpetraVector(), beta, b.getTpetraVector(), gamma); - return *this; -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector::scale(const NOX::Abstract::Vector& a) -{ - return scale(dynamic_cast(a)); -} - -NOX::Abstract::Vector& NOX::Tpetra::Vector::scale(const NOX::Tpetra::Vector& a) -{ - tpetraVec->multiply(1.0, *tpetraVec, a.getTpetraVector(), 0.0); - return *this; -} - -Teuchos::RCP NOX::Tpetra::Vector:: -clone(CopyType type) const -{ - Teuchos::RCP newVec = - Teuchos::rcp(new NOX::Tpetra::Vector(*tpetraVec, type, vectorSpace)); - return newVec; -} - -Teuchos::RCP -NOX::Tpetra::Vector::createMultiVector( - const NOX::Abstract::Vector* const* vecs, - int numVecs, NOX::CopyType type) const -{ - if (numVecs < 0) { - std::cerr << "NOX::Tpetra::Vector::createMultiVector: Error! Multivector" - << " must have positive number of columns!" << std::endl; - throw std::runtime_error("NOX Error"); - } - - double** v = new double*[numVecs+1]; - const TBlockMap& map = tpetraVec->Map(); - const TVector* vecPtr; - - tpetraVec->ExtractView(&(v[0])); - for (int i=0; i(*vecs[i]); - vecPtr = &(noxEpetraVecPtr.getTpetraVector()); - vecPtr->ExtractView(&(v[i+1])); - } - - TMultiVector tpetra_mv(View, map, v, numVecs+1); - - Teuchos::RCP mv = - Teuchos::rcp(new NOX::Tpetra::MultiVector(tpetra_mv, type)); - - delete [] v; - - return mv; -} - -Teuchos::RCP -NOX::Tpetra::Vector::createMultiVector(int numVecs, NOX::CopyType type) const -{ - if (numVecs <= 0) { - std::cerr << "NOX::Tpetra::Vector::createMultiVector: Error! Multivector" - << " must have positive number of columns!" << std::endl; - throw std::runtime_error("NOX Error"); - } - - const TBlockMap& map = tpetraVec->Map(); - TMultiVector *tpetra_mv; - - if (type == NOX::ShapeCopy) - tpetra_mv = new TMultiVector(map, numVecs, true); - else { - tpetra_mv = new TMultiVector(map, numVecs, false); - TVector* v; - for (int i=0; i mv = - Teuchos::rcp(new NOX::Tpetra::MultiVector(*tpetra_mv, type)); - - delete tpetra_mv; - - return mv; -} - -double NOX::Tpetra::Vector::norm(NOX::Abstract::Vector::NormType type) const -{ - return vectorSpace->norm(*tpetraVec, type); -} - -double NOX::Tpetra::Vector::norm(const NOX::Abstract::Vector& weights) const -{ - return norm(dynamic_cast(weights)); -} - -double NOX::Tpetra::Vector::norm(const NOX::Tpetra::Vector& /* weights */) const -{ - std::cerr << "NOX::Tpetra::Vector - Weighted norm not supported" << std::endl; - throw std::runtime_error("NOX-Epetra Error"); -} - -double NOX::Tpetra::Vector::innerProduct(const NOX::Abstract::Vector& y) const -{ - return innerProduct(dynamic_cast(y)); -} - -double NOX::Tpetra::Vector::innerProduct(const NOX::Tpetra::Vector& y) const -{ - return vectorSpace->innerProduct(*tpetraVec, y.getTpetraVector()); -} - -NOX::size_type NOX::Tpetra::Vector::length() const -{ - return tpetraVec->GlobalLength64(); -} - -void NOX::Tpetra::Vector::print(std::ostream& stream) const -{ - tpetraVec->Print(stream); - return; -} - -Teuchos::RCP -NOX::Tpetra::Vector::getVectorSpace() const -{ - return vectorSpace; -} diff --git a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Vector.hpp b/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Vector.hpp deleted file mode 100644 index e8b47b4bf7aa..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_Vector.hpp +++ /dev/null @@ -1,250 +0,0 @@ -// $Id$ -// $Source$ - -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#ifndef NOX_TPETRA_VECTOR_H -#define NOX_TPETRA_VECTOR_H - -#include "NOX_Abstract_Vector.H" // base class -#include "Teuchos_RCP.hpp" // class data element -#include "NOX_Tpetra_VectorSpace.hpp" // class data element - -// Forward declarations -class TVector; -namespace NOX { - namespace Tpetra { - class VectorSpace; - } -} - -namespace NOX { - -//! %NOX %Tpetra support. -namespace Tpetra { - -//! Implementation of NOX::Abstract::Vector for %Tpetra vectors. -class Vector : public virtual NOX::Abstract::Vector { - - public: - - //! Type of memory management to use when constructing the vector. - enum MemoryType { - //! Keeps a pointer to and uses the actual TVector passed in. - CreateView, - //! Allocates a new underlying TVector object. - CreateCopy - }; - - /*! \brief Constructor that creates a COPY or VIEW of the TVector. - - NOTE: This ctor should just always create a view. It should be - implicit from the fact that a RCP object is being passed - in that a persisting relationship is present. However, since this - could cause confusion, the default is to make a copy and if a user - wants a view, they must pass in an explicit flag. - - A VIEW of a vector uses the same underlying memory. - WARNING: A View can be dangerous since multiple objects can access - the same memory locations. - */ - Vector(const Teuchos::RCP& source, - NOX::Tpetra::Vector::MemoryType memoryType = - NOX::Tpetra::Vector::CreateCopy, - NOX::CopyType type = NOX::DeepCopy, - Teuchos::RCP vs = - Teuchos::null); - - //! Construct by copying map and/or elements of an TVector. - /*! Allocates an entirely new vector. Does NOT allow for a view. */ - Vector(const TVector& source, - NOX::CopyType type = NOX::DeepCopy, - Teuchos::RCP vs = - Teuchos::null); - - //! Copy constructor. - Vector(const NOX::Tpetra::Vector& source, - NOX::CopyType type = NOX::DeepCopy); - - //! Destruct Vector. - ~Vector(); - - //@{ \name Access to underlying Petra vector. - - //! Get reference to underlying Tpetra vector. - virtual TVector& getTpetraVector(); - - //! Get const reference to underlying Tpetra vector. - virtual const TVector& getTpetraVector() const; - - //@} - - //@{ \name Initialization methods. - - // derived - virtual NOX::Abstract::Vector& init(double gamma); - - // derived - virtual NOX::Abstract::Vector& random(bool useSeed = false, int seed = 1); - - //! Copies source vector into "this". - /*! NOTE: this will NOT copy the underlying vector space into the - new vector. */ - virtual NOX::Abstract::Vector& operator=(const TVector& y); - - // derived - virtual NOX::Abstract::Vector& operator=(const NOX::Tpetra::Vector& y); - virtual NOX::Abstract::Vector& operator=(const NOX::Abstract::Vector& y); - - // derived - virtual NOX::Abstract::Vector& abs(const NOX::Tpetra::Vector& y); - virtual NOX::Abstract::Vector& abs(const NOX::Abstract::Vector& y); - - // derived - virtual NOX::Abstract::Vector& reciprocal(const NOX::Tpetra::Vector& y); - virtual NOX::Abstract::Vector& reciprocal(const NOX::Abstract::Vector& y); - - //@} - - //@{ \name Update methods. - - // derived - virtual NOX::Abstract::Vector& scale(double gamma); - - // derived - virtual NOX::Abstract::Vector& scale(const NOX::Tpetra::Vector& a); - virtual NOX::Abstract::Vector& scale(const NOX::Abstract::Vector& a); - - // derived - virtual NOX::Abstract::Vector& update(double alpha, const NOX::Tpetra::Vector& a, - double gamma = 0.0); - virtual NOX::Abstract::Vector& update(double alpha, const NOX::Abstract::Vector& a, - double gamma = 0.0); - - // derived - virtual NOX::Abstract::Vector& update(double alpha, const NOX::Tpetra::Vector& a, - double beta, const NOX::Tpetra::Vector& b, - double gamma = 0.0); - virtual NOX::Abstract::Vector& update(double alpha, const NOX::Abstract::Vector& a, - double beta, const NOX::Abstract::Vector& b, - double gamma = 0.0); - - - //@} - - //@{ \name Creating new Vectors. - - // derived - virtual Teuchos::RCP - clone(CopyType type = DeepCopy) const; - - /*! - * \brief Create a MultiVector with \c numVecs+1 columns out of an array of - * Vectors. The vector stored under \c this will be the first column with - * the remaining \c numVecs columns given by \c vecs. - * - * The implementation here creates a NOX::Tpetra::MultiVector with - * either Shape or Deep copies of the supplied vectors. - */ - virtual Teuchos::RCP - createMultiVector(const NOX::Abstract::Vector* const* vecs, - int numVecs, NOX::CopyType type = NOX::DeepCopy) const; - - /*! - * \brief Create a MultiVector with \c numVecs columns. - * - * The implementation here creates a NOX::Tpetra::MultiVector with - * either Shape or Deep copies of the supplied vector. - */ - virtual Teuchos::RCP - createMultiVector(int numVecs, NOX::CopyType type = NOX::DeepCopy) const; - - //@} - - //@{ \name Norms. - - // derived - virtual double norm(NOX::Abstract::Vector::NormType type = TwoNorm) const; - - // derived - virtual double norm(const NOX::Tpetra::Vector& weights) const; - virtual double norm(const NOX::Abstract::Vector& weights) const; - - //@} - - //@{ \name Inner products - - // derived - virtual double innerProduct(const NOX::Tpetra::Vector& y) const; - virtual double innerProduct(const NOX::Abstract::Vector& y) const; - - //@} - - // derived - virtual NOX::size_type length() const; - - // derived - virtual void print(std::ostream& stream) const; - - //! Returns the NOX::Tpetra::VectorSpace associated with this vector. - virtual Teuchos::RCP - getVectorSpace() const; - - protected: - - //! Pointer to petra vector owned by this object - Teuchos::RCP tpetraVec; - - //! Pointer to the vector space. - Teuchos::RCP vectorSpace; - -}; -} // namespace Tpetra -} // namespace NOX - -#endif diff --git a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace.hpp b/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace.hpp deleted file mode 100644 index 2f7e6df64efa..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace.hpp +++ /dev/null @@ -1,94 +0,0 @@ -// $Id$ -// $Source$ - -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#ifndef NOX_TPETRA_VECTORSPACE_H -#define NOX_TPETRA_VECTORSPACE_H - -#include "NOX_Abstract_Vector.H" // For NormType - -// Forward declaration -class TVector; - -namespace NOX { - -namespace Tpetra { - - /*! \brief Pure virtual base class for the vector space used by NOX::Tpetra::Vectors. - - This class allows users to override the inner product and norm - used by the NOX::Tpetra::Vector class. The most frequent use of - this class is for introducing a weighted norm throughout NOX. - - */ - class VectorSpace { - - public: - - //! Constructor - VectorSpace() {}; - - //! Destructor - virtual ~VectorSpace() {}; - - //! Computes the inner product: . - virtual double innerProduct(const TVector& a, - const TVector& b) const = 0; - - //! Computes the norm. - /*! For an L2 norm, the computation is: sqrt( ). */ - virtual double norm(const TVector& a, - NOX::Abstract::Vector::NormType = - NOX::Abstract::Vector::TwoNorm) const = 0; - - }; -} // namespace Tpetra -} // namespace NOX - -#endif diff --git a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace_L2.cpp b/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace_L2.cpp deleted file mode 100644 index 10d3218fee77..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace_L2.cpp +++ /dev/null @@ -1,89 +0,0 @@ -// $Id$ -// $Source$ - -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#include "NOX_Tpetra_VectorSpace_L2.H" -#include "Tpetra_Vector.h" - -NOX::Tpetra::VectorSpaceL2::VectorSpaceL2() -{ - -} - -NOX::Tpetra::VectorSpaceL2::~VectorSpaceL2() -{ - -} - -double NOX::Tpetra::VectorSpaceL2:: -innerProduct(const TVector& a, const TVector& b) const -{ - double dot; - a.dot(b, &dot); - return dot; -} - -double NOX::TVector::VectorSpaceL2:: -norm(const TVector& a, NOX::Abstract::Vector::NormType type) const -{ - double n; - switch (type) { - case NOX::Abstract::Vector::MaxNorm: - a.NormInf(&n); - break; - case NOX::Abstract::Vector::OneNorm: - a.Norm1(&n); - break; - case NOX::Abstract::Vector::TwoNorm: - default: - a.norm2(&n); - break; - } - return n; -} diff --git a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace_L2.hpp b/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace_L2.hpp deleted file mode 100644 index f45dcd7f40fc..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace_L2.hpp +++ /dev/null @@ -1,88 +0,0 @@ -// $Id$ -// $Source$ - -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#ifndef NOX_TPETRA_VECTORSPACE_L2_H -#define NOX_TPETRA_VECTORSPACE_L2_H - -#include "NOX_Tpetra_VectorSpace.hpp" // base class - -namespace NOX { - -namespace Tpetra { - - /*! \brief Concrete class for an L2 vector space. - - This class allows users to override the inner product and norm - used by the NOX::Tpetra::Vector class. The most frequent use of - this class is for introducing a weighted norm throughout NOX. - - */ - class VectorSpaceL2 : public NOX::Tpetra::VectorSpace { - - public: - - //! Constructor - VectorSpaceL2(); - - //! Destructor - virtual ~VectorSpaceL2(); - - virtual double innerProduct(const TVector& a, - const TVector& b) const; - - virtual double norm(const TVector& a, - NOX::Abstract::Vector::NormType = - NOX::Abstract::Vector::TwoNorm) const; - -}; -} // namespace Epetra -} // namespace NOX - -#endif diff --git a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace_ScaledL2.cpp b/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace_ScaledL2.cpp deleted file mode 100644 index 26191f77be45..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace_ScaledL2.cpp +++ /dev/null @@ -1,121 +0,0 @@ -// $Id$ -// $Source$ - -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#include "NOX_Tpetra_VectorSpace_ScaledL2.H" -#include "Tpetra_Vector.h" - -NOX::Tpetra::VectorSpaceScaledL2:: -VectorSpaceScaledL2(const Teuchos::RCP& s, - NOX::Tpetra::Scaling::ScaleType st) : - scalingPtr(s), - scaleType(st) -{ - -} - -NOX::Tpetra::VectorSpaceScaledL2::~VectorSpaceScaledL2() -{ - -} - -double NOX::Tpetra::VectorSpaceScaledL2:: -innerProduct(const TVector& a, const TVector& b) const -{ - if ( Teuchos::is_null(tmpVectorPtr) ) - tmpVectorPtr = Teuchos::rcp(new TVector(a)); - - *tmpVectorPtr = a; - - if (scaleType == NOX::Tpetra::Scaling::Left) { - // Do twice on a instead of once on a and once on b. - scalingPtr->applyLeftScaling(*tmpVectorPtr, *tmpVectorPtr); - scalingPtr->applyLeftScaling(*tmpVectorPtr, *tmpVectorPtr); - } - else { - // Do twice on a instead of once on a and once on b. - scalingPtr->applyRightScaling(*tmpVectorPtr, *tmpVectorPtr); - scalingPtr->applyRightScaling(*tmpVectorPtr, *tmpVectorPtr); - } - - double dot; - tmpVectorPtr->Dot(b, &dot); - return dot; -} - -double NOX::Tpetra::VectorSpaceScaledL2:: -norm(const TVector& a, NOX::Abstract::Vector::NormType type) const -{ - if ( Teuchos::is_null(tmpVectorPtr) ) - tmpVectorPtr = Teuchos::rcp(new TVector(a)); - - *tmpVectorPtr = a; - - if (scaleType == NOX::Tpetra::Scaling::Left) { - scalingPtr->applyLeftScaling(*tmpVectorPtr, *tmpVectorPtr); - } - else { - scalingPtr->applyRightScaling(*tmpVectorPtr, *tmpVectorPtr); - } - - double value; - switch (type) { - case NOX::Abstract::Vector::MaxNorm: - tmpVectorPtr->NormInf(&value); - break; - case NOX::Abstract::Vector::OneNorm: - tmpVectorPtr->Norm1(&value); - break; - case NOX::Abstract::Vector::TwoNorm: - default: - tmpVectorPtr->Norm2(&value); - break; - } - return value; -} diff --git a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace_ScaledL2.hpp b/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace_ScaledL2.hpp deleted file mode 100644 index 3e02752d7e76..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/NOX_Tpetra_VectorSpace_ScaledL2.hpp +++ /dev/null @@ -1,116 +0,0 @@ -// $Id$ -// $Source$ - -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -#ifndef NOX_TPETRA_VECTORSPACE_SCALEDL2_H -#define NOX_TPETRA_VECTORSPACE_SCALEDL2_H - -#include "NOX_Tpetra_VectorSpace.H" // base class -#include "Teuchos_RCP.hpp" -#include "NOX_Tpetra_Scaling.H" - -// Forward declarations -class TVector; - -namespace NOX { - -namespace Epetra { - - /*! \brief Concrete class for a weighted L2 vector space. - - This class allows users to override the inner product and norm - used by the NOX::Tpetra::Vector class. The most frequent use of - this class is for introducing a weighted norm throughout NOX. - - */ - class VectorSpaceScaledL2 : public NOX::Tpetra::VectorSpace { - - public: - - //! Constructor - VectorSpaceScaledL2(const Teuchos::RCP& s, - NOX::Tpetra::Scaling::ScaleType st = - NOX::Tpetra::Scaling::Left); - - //! Destructor - virtual ~VectorSpaceScaledL2(); - - //! Computes a scaled inner product. - /*! Computes a scaled inner product: \f$ \f$ where - \f$D\f$ is the set of scaling vectors associated with either - left of right scaling. - */ - virtual double innerProduct(const TVector& a, - const TVector& b) const; - - //! Computes the scaled norm. - /*! Computes the scaled norm using \f$ Da \f$ where \f$D\f$ is the - set of scaling vectors associated with either left of right - scaling. - */ - virtual double norm(const TVector& a, - NOX::Abstract::Vector::NormType = - NOX::Abstract::Vector::TwoNorm) const; - - protected: - - //! Scaling vector used in the inner product - Teuchos::RCP scalingPtr; - - //! Scaling type to apply to vector space - NOX::Tpetra::Scaling::ScaleType scaleType; - - //! Temporary vector used in scaling computations - mutable Teuchos::RCP tmpVectorPtr; - - }; -} // namespace Epetra -} // namespace NOX - -#endif diff --git a/packages/nox/test/tpetra/NOX_Operators/src/README.md b/packages/nox/test/tpetra/NOX_Operators/src/README.md deleted file mode 100644 index 96018605c1f7..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/src/README.md +++ /dev/null @@ -1 +0,0 @@ -Sources files migrated from src-epetra that could be moved at the end to src-tpetra diff --git a/packages/nox/test/tpetra/NOX_Operators/test.cpp b/packages/nox/test/tpetra/NOX_Operators/test.cpp deleted file mode 100644 index 9bf7624391af..000000000000 --- a/packages/nox/test/tpetra/NOX_Operators/test.cpp +++ /dev/null @@ -1,223 +0,0 @@ -//@HEADER -// ************************************************************************ -// -// NOX: An Object-Oriented Nonlinear Solver Package -// Copyright (2002) Sandia Corporation -// -// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive -// license for use of this work by or on behalf of the U.S. Government. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the Corporation nor the names of the -// contributors may be used to endorse or promote products derived from -// this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY -// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE -// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// -// Questions? Contact Roger Pawlowski (rppawlo@sandia.gov) or -// Eric Phipps (etphipp@sandia.gov), Sandia National Laboratories. -// ************************************************************************ -// CVS Information -// $Source$ -// $Author$ -// $Date$ -// $Revision$ -// ************************************************************************ -//@HEADER - -// NOX headers -#include "NOX.H" // Required headers -// #include "NOX_Epetra.H" // Epetra Interface headers -// #include "NOX_TestCompare.H" // Test Suite headers -// #include "NOX_Epetra_DebugTools.H" - -// // Trilinos headers -// #ifdef HAVE_MPI -// #include "Epetra_MpiComm.h" -// #else -// #include "Epetra_SerialComm.h" -// #endif -// #include "TMap.h" -// #include "TVector.h" -// #include "TRowMatrix.h" -// #include "TCrsMatrix.h" -// #include "TMap.h" -// #include "TLinearProblem.h" -// #include "AztecOO.h" -// #include "Teuchos_StandardCatchMacros.hpp" - -#include "Laplace2D_Tpetra.hpp" -#include "Teuchos_Comm.hpp" -#include "Teuchos_RCP.hpp" - -int main(int argc, char *argv[]) -{ - Teuchos::RCP > comm = Tpetra::getDefaultComm(); - - bool verbose = false; - bool success = false; - try { - if (argc > 1) - if (argv[1][0]=='-' && argv[1][1]=='v') - verbose = true; - - // Get the process ID and the total number of processors - int MyPID = Comm.MyPID(); -#ifdef HAVE_MPI - int NumProc = Comm.NumProc(); -#endif - - // define the parameters of the nonlinear PDE problem - int nx = 5; - int ny = 6; - double lambda = 1.0; - - PDEProblem Problem(nx,ny,lambda,&Comm); - - // starting solution, here a zero vector - TVector InitialGuess(Problem.GetMatrix()->Map()); - InitialGuess.PutScalar(0.0); - - // random vector upon which to apply each operator being tested - TVector directionVec(Problem.GetMatrix()->Map()); - directionVec.Random(); - - // Set up the problem interface - Teuchos::RCP interface = - Teuchos::rcp(new SimpleProblemInterface(&Problem) ); - - // Set up theolver options parameter list - Teuchos::RCP noxParamsPtr = Teuchos::rcp(new Teuchos::ParameterList); - Teuchos::ParameterList & noxParams = *(noxParamsPtr.get()); - - // Set the nonlinear solver method - noxParams.set("Nonlinear Solver", "Line Search Based"); - - // Set up the printing utilities - // Only print output if the "-v" flag is set on the command line - Teuchos::ParameterList& printParams = noxParams.sublist("Printing"); - printParams.set("MyPID", MyPID); - printParams.set("Output Precision", 5); - printParams.set("Output Processor", 0); - if( verbose ) - printParams.set("Output Information", - NOX::Utils::OuterIteration + - NOX::Utils::OuterIterationStatusTest + - NOX::Utils::InnerIteration + - NOX::Utils::Parameters + - NOX::Utils::Details + - NOX::Utils::Warning + - NOX::Utils::TestDetails); - else - printParams.set("Output Information", NOX::Utils::Error + - NOX::Utils::TestDetails); - - NOX::Utils printing(printParams); - - - // Identify the test problem - if (printing.isPrintType(NOX::Utils::TestDetails)) - printing.out() << "Starting epetra/NOX_Operators/NOX_Operators.exe" << std::endl; - - // Identify processor information -#ifdef HAVE_MPI - if (printing.isPrintType(NOX::Utils::TestDetails)) { - printing.out() << "Parallel Run" << std::endl; - printing.out() << "Number of processors = " << NumProc << std::endl; - printing.out() << "Print Process = " << MyPID << std::endl; - } - Comm.Barrier(); - if (printing.isPrintType(NOX::Utils::TestDetails)) - printing.out() << "Process " << MyPID << " is alive!" << std::endl; - Comm.Barrier(); -#else - if (printing.isPrintType(NOX::Utils::TestDetails)) - printing.out() << "Serial Run" << std::endl; -#endif - - int status = 0; - - Teuchos::RCP iReq = interface; - - // Need a NOX::Tpetra::Vector for constructor - TVector noxInitGuess(InitialGuess, NOX::DeepCopy); - - // Analytic matrix - Teuchos::RCP A = Teuchos::rcp( Problem.GetMatrix(), false ); - - TVector A_resultVec(Problem.GetMatrix()->Map()); - interface->computeJacobian( InitialGuess, *A ); - A->Apply( directionVec, A_resultVec ); - - // FD operator - Teuchos::RCP graph = Teuchos::rcp( const_cast(&A->graph()), false ); - Teuchos::RCP FD = Teuchos::rcp( - new NOX::Tpetra::FiniteDifference(printParams, iReq, noxInitGuess, graph) ); - - TVector FD_resultVec(Problem.GetMatrix()->Map()); - FD->computeJacobian(InitialGuess, *FD); - FD->Apply( directionVec, FD_resultVec ); - - // Matrix-Free operator - Teuchos::RCP MF = Teuchos::rcp( - new NOX::Tpetra::MatrixFree(printParams, iReq, noxInitGuess) ); - - TVector MF_resultVec(Problem.GetMatrix()->Map()); - MF->computeJacobian(InitialGuess, *MF); - MF->Apply( directionVec, MF_resultVec ); - - // Need NOX::Tpetra::Vectors for tests - NOX::Tpetra::Vector noxAvec ( A_resultVec , NOX::DeepCopy ); - NOX::Tpetra::Vector noxFDvec( FD_resultVec, NOX::DeepCopy ); - NOX::Tpetra::Vector noxMFvec( MF_resultVec, NOX::DeepCopy ); - - // Create a TestCompare class - NOX::Tpetra::TestCompare tester( printing.out(), printing); - double abstol = 1.e-4; - double reltol = 1.e-4 ; - //NOX::TestCompare::CompareType aComp = NOX::TestCompare::Absolute; - - status += tester.testVector( noxFDvec, noxAvec, reltol, abstol, - "Finite-Difference Operator Apply Test" ); - status += tester.testVector( noxMFvec, noxAvec, reltol, abstol, - "Matrix-Free Operator Apply Test" ); - - success = status==0; - - // Summarize test results - if(success) - printing.out() << "Test passed!" << std::endl; - else - printing.out() << "Test failed!" << std::endl; - } - TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success); - -#ifdef HAVE_MPI - MPI_Finalize(); -#endif - - return ( success ? EXIT_SUCCESS : EXIT_FAILURE ); -} -/* - end of file test.C -*/ diff --git a/packages/nox/test/tpetra/Tpetra_Laplace2D.cpp b/packages/nox/test/tpetra/Tpetra_Laplace2D.cpp new file mode 100644 index 000000000000..acd8db85ad11 --- /dev/null +++ b/packages/nox/test/tpetra/Tpetra_Laplace2D.cpp @@ -0,0 +1,322 @@ +#include "Teuchos_UnitTestHarness.hpp" +#include "Teuchos_ScalarTraits.hpp" +#include "Teuchos_ParameterList.hpp" + +#include "Teuchos_Comm.hpp" +#include "Teuchos_RCP.hpp" +#include "Tpetra_Laplace2D.hpp" + +// Laplace2D implementation +void Laplace2D::getMyNeighbours(const int i, const int nx, const int ny, + int &left, int &right, + int &lower, int &upper) +{ + int ix, iy; + ix = i % nx; + iy = (i - ix) / nx; + + if (ix == 0) + left = -1; + else + left = i - 1; + if (ix == nx - 1) + right = -1; + else + right = i + 1; + if (iy == 0) + lower = -1; + else + lower = i - nx; + if (iy == ny - 1) + upper = -1; + else + upper = i + nx; + + return; +} + +CRSM * Laplace2D::createLaplacian(const int nx, const int ny, const Teuchos::RCP>& comm) +{ + int numGlobalElements = nx * ny; + int numLocalElements = 5; // TD: added + // create a map + Teuchos::RCP map = Teuchos::rcp(new const Map(numGlobalElements, 5, 0, comm)); + // local number of rows + numLocalElements = map->getLocalNumElements(); + // get update list + Tpetra::global_size_t globalElements = map->getGlobalNumElements(); + + double hx = 1.0 / (nx - 1); + double hy = 1.0 / (ny - 1); + double off_left = -1.0 / (hx * hx); + double off_right = -1.0 / (hx * hx); + double off_lower = -1.0 / (hy * hy); + double off_upper = -1.0 / (hy * hy); + double diag = 2.0 / (hx * hx) + 2.0 / (hy * hy); + + int left, right, lower, upper; + + // a bit overestimated the nonzero per row + + Teuchos::RCP A = Teuchos::rcp(new CRSM(map, 5)); + // Add rows one-at-a-time + + double *values = new double[4]; + int *indices = new int[4]; + + for (int i = 0; i < numMyElements; ++i) + { + int numEntries = 0; + getMyNeighbours(globalElements[i], nx, ny, left, right, lower, upper); + if (left != -1) + { + indices[numEntries] = left; + values[numEntries] = off_left; + ++numEntries; + } + if (right != -1) + { + indices[numEntries] = right; + values[numEntries] = off_right; + ++numEntries; + } + if (lower != -1) + { + indices[numEntries] = lower; + values[numEntries] = off_lower; + ++numEntries; + } + if (upper != -1) + { + indices[numEntries] = upper; + values[numEntries] = off_upper; + ++numEntries; + } + // put the off-diagonal entries + a->insertGlobalValues(myGlobalElements[i], numEntries, values, indices); + // Put in the diagonal entry + a->insertGlobalValues(myGlobalElements[i], 1, &diag, myGlobalElements + i); + } + + // put matrix in local ordering + a->fillComplete(); + + delete[] indices; + delete[] values; + delete map; + + return a; + +} /* createJacobian */ + +// ========================================================================== +// This class contians the main definition of the nonlinear problem at +// hand. A method is provided to compute F(x) for a given x, and another +// method to update the entries of the Jacobian matrix, for a given x. +// As the Jacobian matrix J can be written as +// J = L + diag(lambda*exp(x[i])), +// where L corresponds to the discretization of a Laplacian, and diag +// is a diagonal matrix with lambda*exp(x[i]). Basically, to update +// the jacobian we simply update the diagonal entries. Similarly, to compute +// F(x), we reset J to be equal to L, then we multiply it by the +// (distributed) vector x, then we add the diagonal contribution +// ========================================================================== + +// constructor. Requires the number of nodes along the x-axis +// and y-axis, the value of lambda, and the communicator +// (to define a Map, which is a linear map in this case) +PDEProblem::PDEProblem(const int nx, const int ny, const double lambda, + const Teuchos::RCP> &comm) : + nx_(nx), ny_(ny), lambda_(lambda) +{ + hx_ = 1.0/(nx_-1); + hy_ = 1.0/(ny_-1); + matrix_ = Laplace2D::createLaplacian(nx_,ny_,comm); +} + +// destructor +PDEProblem::~PDEProblem() +{ + delete matrix_; +} + +// compute F(x) +void PDEProblem::computeF( const TV & x, TV & f ) +{ + // reset diagonal entries + double diag = 2.0/(hx_*hx_) + 2.0/(hy_*hy_); + + int numMyElements = matrix_->getMap()->getLocalNumElements(); + // get update list + int * myGlobalElements = matrix_->getMap()->getLocalElementList(); + + for( int i = 0; i < numMyElements; ++i ) + { + // Put in the diagonal entry + matrix_->replaceGlobalValues(myGlobalElements[i], 1, &diag, myGlobalElements+i); + } + // matrix-vector product (intra-processes communication occurs in this call) + matrix_->multiply( false, x, f ); + + // add diagonal contributions + for( int i = 0; i < numMyElements; ++i ) + { + // Put in the diagonal entry + f[i] += lambda_*exp(x[i]); + } +} + +// update the Jacobian matrix for a given x +void PDEProblem::updateJacobian( const TV & x ) +{ + double diag = 2.0/(hx_*hx_) + 2.0/(hy_*hy_); + + int numMyElements = matrix_->getMap().numMyElements(); + // get update list + int * myGlobalElements = matrix_->getMap().myGlobalElements(); + + for( int i = 0; i < NumMyElements; ++i ) + { + // Put in the diagonal entry + double newdiag = diag + lambda_*exp(x[i]); + matrix_->replaceGlobalValues(myGlobalElements[i], 1, &newdiag, myGlobalElements+i); + } +} + +TEUCHOS_UNIT_TEST(Tpetra_Laplace2D, Laplace2D) +{ + try { + bool verbose = Teuchos::UnitTestRepository::verboseUnitTests(); + + // Get the process ID and the total number of processors + int myPID = comm.getRank(); +#ifdef HAVE_MPI + int numProc = comm.getSize(); +#endif + + // define the parameters of the nonlinear PDE problem + int nx = 5; + int ny = 6; + double lambda = 1.0; + + PDEProblem problem(nx,ny,lambda,&comm); + + // starting solution, here a zero vector + TV initialGuess(problem.getMatrix()->getMap()); + initialGuess.putScalar(0.0); + + // random vector upon which to apply each operator being tested + TV directionVec(problem.getMatrix()->getMap()); + directionVec.random(); + + // Set up the problem interface + Teuchos::RCP interface = + Teuchos::rcp(new SimpleProblemInterface(&problem) ); + + // Set up theolver options parameter list + Teuchos::RCP noxParamsPtr = Teuchos::rcp(new Teuchos::ParameterList); + Teuchos::ParameterList & noxParams = *(noxParamsPtr.get()); + + // Set the nonlinear solver method + noxParams.set("Nonlinear Solver", "Line Search Based"); + + // Set up the printing utilities + // Only print output if the "-v" flag is set on the command line + Teuchos::ParameterList& printParams = noxParams.sublist("Printing"); + printParams.set("MyPID", myPID); + printParams.set("Output Precision", 5); + printParams.set("Output Processor", 0); + if( verbose ) + printParams.set("Output Information", + NOX::Utils::OuterIteration + + NOX::Utils::OuterIterationStatusTest + + NOX::Utils::InnerIteration + + NOX::Utils::Parameters + + NOX::Utils::Details + + NOX::Utils::Warning + + NOX::Utils::TestDetails); + else + printParams.set("Output Information", NOX::Utils::Error + + NOX::Utils::TestDetails); + + NOX::Utils printing(printParams); + + // Identify the test problem + if (printing.isPrintType(NOX::Utils::TestDetails)) + printing.out() << "Starting epetra/NOX_Operators/NOX_Operators.exe" << std::endl; + + // Identify processor information +#ifdef HAVE_MPI + if (printing.isPrintType(NOX::Utils::TestDetails)) { + printing.out() << "Parallel Run" << std::endl; + printing.out() << "Number of processors = " << numProc << std::endl; + printing.out() << "Print Process = " << myPID << std::endl; + } + comm.barrier(); + if (printing.isPrintType(NOX::Utils::TestDetails)) + printing.out() << "Process " << myPID << " is alive!" << std::endl; + comm.barrier(); +#else + if (printing.isPrintType(NOX::Utils::TestDetails)) + printing.out() << "Serial Run" << std::endl; +#endif + + int status = 0; + + Teuchos::RCP iReq = interface; + + // Need a NOX::Epetra::Vector for constructor + NOX::Epetra::Vector noxInitGuess(initialGuess, NOX::DeepCopy); + + // Analytic matrix + Teuchos::RCP A = Teuchos::rcp( problem.getMatrix(), false ); + + TV A_resultVec(problem.getMatrix()->getMap()); + interface->computeJacobian( initialGuess, *A ); + A->Apply( directionVec, A_resultVec ); + + // FD operator + Teuchos::RCP graph = Teuchos::rcp( const_cast(&A->getGraph()), false ); + Teuchos::RCP FD = Teuchos::rcp( + new NOX::Epetra::FiniteDifference(printParams, iReq, noxInitGuess, graph) ); + + TV FD_resultVec(problem.getMatrix()->getMap()); + FD->computeJacobian(initialGuess, *FD); + FD->Apply( directionVec, FD_resultVec ); + + // Matrix-Free operator + Teuchos::RCP MF = Teuchos::rcp( + new NOX::Epetra::MatrixFree(printParams, iReq, noxInitGuess) ); + + TV MF_resultVec(problem.getMatrix()->getMap()); + MF->computeJacobian(initialGuess, *MF); + MF->apply( directionVec, MF_resultVec ); + + // Need NOX::Epetra::Vectors for tests + NOX::Epetra::Vector noxAvec ( A_resultVec , NOX::DeepCopy ); + NOX::Epetra::Vector noxFDvec( FD_resultVec, NOX::DeepCopy ); + NOX::Epetra::Vector noxMFvec( MF_resultVec, NOX::DeepCopy ); + + // Create a TestCompare class + NOX::Epetra::TestCompare tester( printing.out(), printing); + double abstol = 1.e-4; + double reltol = 1.e-4 ; + //NOX::TestCompare::CompareType aComp = NOX::TestCompare::Absolute; + + status += tester.testVector( noxFDvec, noxAvec, reltol, abstol, + "Finite-Difference Operator Apply Test" ); + status += tester.testVector( noxMFvec, noxAvec, reltol, abstol, + "Matrix-Free Operator Apply Test" ); + + success = status==0; + + // Summarize test results + if(success) + printing.out() << "Test passed!" << std::endl; + else + printing.out() << "Test failed!" << std::endl; + } + TEUCHOS_STANDARD_CATCH_STATEMENTS(verbose, std::cerr, success); + + return -1; +} diff --git a/packages/nox/test/tpetra/Tpetra_Laplace2D.hpp b/packages/nox/test/tpetra/Tpetra_Laplace2D.hpp new file mode 100644 index 000000000000..3d6c21ae1003 --- /dev/null +++ b/packages/nox/test/tpetra/Tpetra_Laplace2D.hpp @@ -0,0 +1,249 @@ +#include "Tpetra_ConfigDefs.hpp" +#include "Tpetra_Map_fwd.hpp" +#include "Tpetra_MultiVector.hpp" // fwd doesn't have default enabled template types +#include "Tpetra_Vector_fwd.hpp" +#include "Tpetra_Export_fwd.hpp" +#include "Tpetra_Import_fwd.hpp" +#include "Tpetra_RowGraph_fwd.hpp" +#include "Tpetra_RowMatrix_fwd.hpp" +#include "Tpetra_CrsGraph_fwd.hpp" +#include "Tpetra_CrsMatrix_fwd.hpp" +#include "Tpetra_Operator_fwd.hpp" + +// Typedefs and constants + +typedef Tpetra::MultiVector<>::scalar_type Scalar; +typedef Tpetra::MultiVector<>::local_ordinal_type LO; +typedef Tpetra::MultiVector<>::global_ordinal_type GO; +typedef Tpetra::MultiVector<>::node_type Node; + +typedef Tpetra::Map Map; +typedef Tpetra::Vector TV; +typedef Tpetra::CrsMatrix CRSM; +typedef Tpetra::RowMatrix TRM; +typedef Tpetra::Operator TO; +typedef Tpetra::CrsGraph< LO, GO, Node> CSRG; + +// Interfaces + +namespace NOX +{ + namespace Tpetra + { + namespace Interface + { + + /*! \brief Used by NOX::Tpetra to provide a link to the + external code for Jacobian fills. + + This is only required if the user wishes to supply their own Jacobian + operator. + */ + class Jacobian + { + + public: + //! Constructor. + Jacobian(){}; + + //! Destructor. + virtual ~Jacobian(){}; + + /*! Compute Jacobian given the specified input vector x. Returns + true if computation was successful. + */ + virtual bool computeJacobian(const TV &x, TO &Jac) = 0; + }; + + /*! \brief Used by NOX::Tpetra to provide a link to the + external code for Precondtioner fills. + + This is only required if the user wishes to supply their own + preconditioner operator. + */ + class Preconditioner + { + + public: + //! Constructor + Preconditioner(){}; + + //! Destructor + virtual ~Preconditioner(){}; + + //! Computes a user defined preconditioner. + virtual bool computePreconditioner(const TV &x, + TO &M, + Teuchos::ParameterList *precParams = 0) = 0; + }; + + /*! + \brief Supplies NOX with the set nonlinear equations. + + This is the minimum required information to solve a nonlinear + problem using the NOX::Tpetra objects for the linear algebra + implementation. Used by NOX::Tpetra::Group to provide a link + to the external code for residual fills. + */ + class Required + { + + public: + //! Type of fill that a computeF() method is used for. + /*! computeF() can be called for a variety of reasons: + + - To evaluate the function residuals. + - To be used in an approximation to the Jacobian (finite difference or directional derivative). + - To be used in an approximation to the preconditioner. + + This flag tells computeF() what the evaluation is used for. This allows the user to change the fill process to eliminate costly terms. For example, sometimes, terms in the function are very expensive and can be ignored in a Jacobian calculation. The user can query this flag and determine not to recompute such terms if the computeF() is used in a Jacobian calculation. + */ + enum FillType + { + //! The exact residual (F) is being calculated. + Residual, + //! The Jacobian matrix is being estimated. + Jac, + //! The preconditioner matrix is being estimated. + Prec, + //! The fill context is from a FD approximation (includes FDC) + FD_Res, + //! The fill context is from a MF approximation + MF_Res, + //! The fill context is from a MF computeJacobian() approximation + MF_Jac, + //! A user defined estimation is being performed. + User + }; + + //! Constructor + Required(){}; + + //! Destructor + virtual ~Required(){}; + + //! Compute the function, F, given the specified input vector x. Returns true if computation was successful. + virtual bool computeF(const TV &x, TV &F, + const FillType fillFlag) = 0; + }; + } // namespace Interface + } // namespace Tpetra +} // namespace NOX + +namespace Laplace2D +{ + // this is required to know the number of lower, upper, left and right + // node for each node of the Cartesian grid (composed by nx \timex ny + // elements) + + void getMyNeighbours(const int i, const int nx, const int ny, + int &left, int &right, + int &lower, int &upper); + + // This function creates a CrsMatrix, whose elements corresponds + // to the discretization of a Laplacian over a Cartesian grid, + // with nx grid point along the x-axis and and ny grid points + // along the y-axis. For the sake of simplicity, I suppose that + // all the nodes in the matrix are internal nodes (Dirichlet + // boundary nodes are supposed to have been already condensated) + + CRSM * createLaplacian(const int nx, const int ny, const Teuchos::RCP>& comm); + + // ========================================================================== + // This class contians the main definition of the nonlinear problem at + // hand. A method is provided to compute F(x) for a given x, and another + // method to update the entries of the Jacobian matrix, for a given x. + // As the Jacobian matrix J can be written as + // J = L + diag(lambda*exp(x[i])), + // where L corresponds to the discretization of a Laplacian, and diag + // is a diagonal matrix with lambda*exp(x[i]). Basically, to update + // the jacobian we simply update the diagonal entries. Similarly, to compute + // F(x), we reset J to be equal to L, then we multiply it by the + // (distributed) vector x, then we add the diagonal contribution + // ========================================================================== + +} // namespace Laplace2D + +class PDEProblem +{ + +public: + // constructor. Requires the number of nodes along the x-axis + // and y-axis, the value of lambda, and the communicator + // (to define a Map, which is a linear map in this case) + PDEProblem(const int nx, const int ny, const double lambda, + const Teuchos::RCP> &comm); + + // destructor + ~PDEProblem(); + + // compute F(x) + void computeF(const TV &x, TV &f); + + // update the Jacobian matrix for a given x + void updateJacobian(const TV &x); + + // returns a pointer to the internally stored matrix + CRSM *getMatrix() + { + return matrix_; + } + +private: + int nx_, ny_; + double hx_, hy_; + CRSM *matrix_; + double lambda_; + +}; /* class PDEProblem */ + +// ========================================================================== +// This is the main NOX class for this example. Here we define +// the interface between the nonlinear problem at hand, and NOX. +// The constructor accepts a PDEProblem object. Using a pointer +// to this object, we can update the Jacobian and compute F(x), +// using the definition of our problem. This interface is bit +// crude: For instance, no PrecMatrix nor Preconditioner is specified. +// ========================================================================== + +class SimpleProblemInterface : public NOX::Tpetra::Interface::Required, + public NOX::Tpetra::Interface::Jacobian, + public NOX::Tpetra::Interface::Preconditioner +{ + +public: + //! Constructor + SimpleProblemInterface(PDEProblem *problem) : problem_(problem){}; + + //! Destructor + ~SimpleProblemInterface(){}; + + bool computeF(const TV &x, TV &f, + NOX::Tpetra::Interface::Required::FillType F) + { + problem_->computeF(x, f); + return true; + }; + + bool computeJacobian(const TV &x, TV &Jac) + { + problem_->updateJacobian(x); + return true; + } + + bool computePreconditioner(const TV &x, TO &Op, Teuchos::ParameterList *) + { + problem_->updateJacobian(x); + return true; + } + + bool computePrecMatrix(const TV &x, TRM &M) + { + std::cout << "*ERR* SimpleProblem::preconditionVector()\n"; + std::cout << "*ERR* don't use explicit preconditioning" << std::endl; + throw 1; + } + +private: + PDEProblem *problem_; +}; /* class SimpleProblemInterface */