Debian Codegraph @

packages/nox/test/epetra/LOCA_TestProblems/NormConstraint.H

raw
1 // @HEADER
2 // *****************************************************************************
3 // LOCA: Library of Continuation Algorithms Package
4 //
5 // Copyright 2001-2005 NTESS and the LOCA contributors.
6 // SPDX-License-Identifier: BSD-3-Clause
7 // *****************************************************************************
8 // @HEADER
9
10 #ifndef NORMCONSTRAINT_H
11 #define NORMCONSTRAINT_H
12
13 #include "LOCA.H"
14
15 //! A simple constraint equation based on the solution norm
16 /*!
17 * This class implements the LOCA::MultiContinuation::ConstraintInterfaceMVDX
18 * constraint interface for a simple norm constraint:
19 * \f[
20 * g(x,p) = \frac{1}{2 N} \|x\|^2 - \gamma
21 * \f]
22 * where \f$x\f$ is the solution vector and \gamma is the constraint
23 * parameter.
24 */
25 class NormConstraint :
26 public LOCA::MultiContinuation::ConstraintInterfaceMVDX {
27
28 public:
29
30 //! Constructor
31 NormConstraint(int N, const LOCA::ParameterVector& pVec,
32 NOX::Abstract::Vector& cloneVec);
33
34 //! Copy constructor
35 NormConstraint(const NormConstraint& source,
36 NOX::CopyType type = NOX::DeepCopy);
37
38 //! Destructor
39 virtual ~NormConstraint();
40
41 /*!
42 * @name Implementation of LOCA::MultiContinuation::ConstraintInterfaceMVDX
43 * virtual methods
44 */
45 //@{
46
47 //! Copy
48 virtual void
49 copy(const LOCA::MultiContinuation::ConstraintInterface& source);
50
51 //! Cloning function
52 virtual
53 Teuchos::RCP<LOCA::MultiContinuation::ConstraintInterface>
54 clone(NOX::CopyType type = NOX::DeepCopy) const;
55
56 //! Return number of constraints
57 virtual int numConstraints() const;
58
59 //! Set the solution vector to y.
60 virtual void setX(const NOX::Abstract::Vector& y);
61
62 //! Sets parameter indexed by paramID
63 virtual void setParam(int paramID, double val);
64
65 //! Sets parameters indexed by paramIDs
66 virtual void setParams(const std::vector<int>& paramIDs,
67 const NOX::Abstract::MultiVector::DenseMatrix& vals);
68
69 //! Compute continuation constraint equations
70 virtual NOX::Abstract::Group::ReturnType
71 computeConstraints();
72
73 //! Compute derivative of constraints w.r.t. solution vector x
74 virtual NOX::Abstract::Group::ReturnType
75 computeDX();
76
77 //! Compute derivative of constraints w.r.t. supplied parameters.
78 /*!
79 * The first column of \c dgdp should be filled with the constraint
80 * residuals \f$g\f$ if \c isValidG is \c false. If \c isValidG is
81 * \c true, then the \c dgdp contains \f$g\f$ on input.
82 */
83 virtual NOX::Abstract::Group::ReturnType
84 computeDP(const std::vector<int>& paramIDs,
85 NOX::Abstract::MultiVector::DenseMatrix& dgdp,
86 bool isValidG);
87
88 //! Return \c true if constraint residuals are valid
89 virtual bool isConstraints() const;
90
91 //! Return \c true if derivative of constraint w.r.t. x is valid
92 virtual bool isDX() const;
93
94 //! Return constraint residuals
95 virtual const NOX::Abstract::MultiVector::DenseMatrix&
96 getConstraints() const;
97
98 //! Return solution component of constraint derivatives
99 virtual const NOX::Abstract::MultiVector*
100 getDX() const;
101
102 /*!
103 * \brief Return \c true if solution component of constraint
104 * derivatives is zero
105 */
106 virtual bool isDXZero() const;
107
108 //@}
109
110 /*!
111 * \brief Set the flag determinging whether isDXZero()
112 * returns true or false. This is for testing bordered solvers when B
113 * is zero.
114 */
115 void setIsZeroDX(bool flag);
116
117 private:
118
119 //! Prohibit generation and use of operator=()
120 NormConstraint& operator=(const NormConstraint& source);
121
122 protected:
123
124 //! Dimension of discretization
125 int n;
126
127 //! Constraint values
128 NOX::Abstract::MultiVector::DenseMatrix constraints;
129
130 //! Flag indicating whether constraints are valid
131 bool isValidConstraints;
132
133 //! Parameter vector
134 LOCA::ParameterVector p;
135
136 //! Solution vector
137 Teuchos::RCP<NOX::Abstract::MultiVector> x;
138
139 //! Flag indicating whether dgdx is zero
140 bool isZeroDgDx;
141
142 };
143
144 #endif