2
// ************************************************************************
5
// Copyright (2005) Sandia Corporation
7
// Copyright (year first published) Sandia Corporation. Under the terms
8
// of Contract DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
9
// retains certain rights in this software.
11
// This library is free software; you can redistribute it and/or modify
12
// it under the terms of the GNU Lesser General Public License as
13
// published by the Free Software Foundation; either version 2.1 of the
14
// License, or (at your option) any later version.
16
// This library is distributed in the hope that it will be useful, but
17
// WITHOUT ANY WARRANTY; without even the implied warranty of
18
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
// Lesser General Public License for more details.
21
// You should have received a copy of the GNU Lesser General Public
22
// License along with this library; if not, write to the Free Software
23
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
25
// Questions? Contact Kevin Long (krlong@sandia.gov),
26
// Sandia National Laboratories, Livermore, California, USA
28
// ************************************************************************
31
#ifndef SUNDANCE_NLOP_H
32
#define SUNDANCE_NLOP_H
34
#include "SundanceDefs.hpp"
35
#include "SundanceMesh.hpp"
36
#include "SundanceExpr.hpp"
37
#include "SundanceDiscreteFunction.hpp"
38
#include "SundanceObjectWithVerbosity.hpp"
39
#include "TSFNonlinearOperatorBase.hpp"
40
#include "TSFLinearOperatorDecl.hpp"
41
#include "TSFVectorDecl.hpp"
42
#include "TSFVectorType.hpp"
44
namespace SundanceStdFwk
46
using namespace SundanceUtils;
47
using namespace SundanceStdMesh;
48
using namespace SundanceStdMesh::Internal;
49
using namespace SundanceCore;
50
using namespace SundanceCore;
51
using namespace Teuchos;
58
* NLOp encapsulates a discrete nonlinear problem, and can
59
* be passed to a nonlinear solver such as NOX.
62
: public SundanceUtils::ObjectWithClassVerbosity<NLOp>,
63
public TSFExtended::NonlinearOperatorBase<double>
69
/** Construct with a mesh, equation set, bcs, test and unknown funcs,
70
* and a vector type */
71
NLOp(const Mesh& mesh, const Expr& eqn, const Expr& bc,
72
const Expr& test, const Expr& unk, const Expr& u0,
73
const TSFExtended::VectorType<double>& vecType,
74
bool partitionBCs = false);
76
/** Construct with a mesh, equation set, bcs, test and unknown funcs,
77
* parameters, and a vector type */
78
NLOp(const Mesh& mesh, const Expr& eqn, const Expr& bc,
79
const Expr& test, const Expr& unk, const Expr& u0,
80
const Expr& params, const Expr& paramVals,
81
const TSFExtended::VectorType<double>& vecType,
82
bool partitionBCs = false);
86
NLOp(const RefCountPtr<Assembler>& assembler,
89
/** Compute the residual and Jacobian at the current evaluation point */
90
LinearOperator<double> computeJacobianAndFunction(Vector<double>& functionValue) const ;
92
/** Write the Jacobian and residual into the objects provided */
93
void computeJacobianAndFunction(LinearOperator<double>& J,
94
Vector<double>& resid) const ;
96
/** Compute direct sensitivities to parameters */
97
Expr computeSensitivities(const LinearSolver<double>& solver) const ;
100
/** Return the current evaluation point as a Sundance expression */
101
Expr getU0() const {return u0_;}
103
/** Compute the residual at the current eval point */
104
TSFExtended::Vector<double> computeFunctionValue() const ;
106
/** Write the residual into the object provided */
107
void computeFunctionValue(Vector<double>& resid) const ;
109
/** Get an initial guess */
110
TSFExtended::Vector<double> getInitialGuess() const ;
112
/** Create the Jacobian object, but don't fill it in. */
113
LinearOperator<double> allocateJacobian() const ;
115
/** Set an initial guess */
116
void setInitialGuess(const Expr& u0New);
119
/* Handle boilerplate */
120
GET_RCP(TSFExtended::NonlinearOperatorBase<double>);
125
RefCountPtr<Assembler> assembler_;
128
mutable TSFExtended::LinearOperator<double> J_;
140
mutable DiscreteFunction* discreteU0_;