Thyra
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
test
nonlinear
models
Thyra_DummyTestModelEvaluator_decl.hpp
1
/*
2
// @HEADER
3
// ***********************************************************************
4
//
5
// Thyra: Interfaces and Support for Abstract Numerical Algorithms
6
// Copyright (2004) Sandia Corporation
7
//
8
// Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
9
// license for use of this work by or on behalf of the U.S. Government.
10
//
11
// Redistribution and use in source and binary forms, with or without
12
// modification, are permitted provided that the following conditions are
13
// met:
14
//
15
// 1. Redistributions of source code must retain the above copyright
16
// notice, this list of conditions and the following disclaimer.
17
//
18
// 2. Redistributions in binary form must reproduce the above copyright
19
// notice, this list of conditions and the following disclaimer in the
20
// documentation and/or other materials provided with the distribution.
21
//
22
// 3. Neither the name of the Corporation nor the names of the
23
// contributors may be used to endorse or promote products derived from
24
// this software without specific prior written permission.
25
//
26
// THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
27
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
28
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
30
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
31
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
32
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
33
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
34
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
35
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
36
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
37
//
38
// Questions? Contact Roscoe A. Bartlett (bartlettra@ornl.gov)
39
//
40
// ***********************************************************************
41
// @HEADER
42
*/
43
44
45
#ifndef DUMMY_TEST_MODEL_EVALUATOR_DECL_HPP
46
#define DUMMY_TEST_MODEL_EVALUATOR_DECL_HPP
47
48
49
#include "Thyra_ModelEvaluatorDefaultBase.hpp"
50
51
52
namespace
Thyra {
53
54
// Mock Extended InArgs and OutArgs Objects. In practice, these
55
// objects will be defined by a solver that needs to extend the
56
// InArgs/OutArgs for specialized data without cluttering the core
57
// model evaluator interface.
58
template
<
class
Scalar>
59
struct
MockExtendedInArgs
60
{
61
Teuchos::RCP<Thyra::VectorBase<Scalar> > a;
62
};
63
64
template
<
class
Scalar>
65
struct
MockExtendedOutArgs
66
{
67
Teuchos::RCP<Thyra::VectorBase<Scalar> > b;
68
};
69
70
71
template
<
class
Scalar>
class
DummyTestModelEvaluator
;
72
73
78
template
<
class
Scalar>
79
RCP<DummyTestModelEvaluator<Scalar>
>
80
dummyTestModelEvaluator(
81
const
Ordinal x_size = 2,
82
const
ArrayView<const Ordinal>
&p_sizes = Teuchos::null,
83
const
ArrayView<const Ordinal>
&g_sizes = Teuchos::null,
84
const
bool
supports_x_dot =
false
,
85
const
bool
supports_x_dot_dot =
false
,
86
const
bool
supports_extended_inargs =
true
,
87
const
bool
supports_extended_outargs =
true
,
88
const
bool
supports_derivatives =
false
89
);
90
91
97
template
<
class
Scalar>
98
class
DummyTestModelEvaluator
:
public
ModelEvaluatorDefaultBase
<Scalar>
99
{
100
public
:
101
104
106
DummyTestModelEvaluator
(
107
const
Ordinal x_size,
108
const
ArrayView<const Ordinal>
&p_sizes,
109
const
ArrayView<const Ordinal>
&g_sizes,
110
const
bool
supports_x_dot =
false
,
111
const
bool
supports_x_dot_dot =
false
,
112
const
bool
supports_extended_inargs =
true
,
113
const
bool
supports_extended_outargs =
true
,
114
const
bool
supports_derivatives =
false
115
);
116
118
121
123
RCP<const VectorSpaceBase<Scalar>
>
get_x_space
()
const
;
125
RCP<const VectorSpaceBase<Scalar>
>
get_p_space
(
int
l)
const
;
127
RCP<const Teuchos::Array<std::string>
>
get_p_names
(
int
l)
const
;
129
RCP<const VectorSpaceBase<Scalar>
>
get_f_space
()
const
;
131
RCP<const VectorSpaceBase<Scalar>
>
get_g_space
(
int
j)
const
;
133
Teuchos::ArrayView<const std::string>
get_g_names
(
int
j)
const
;
135
ModelEvaluatorBase::InArgs<Scalar>
getNominalValues
()
const
;
137
ModelEvaluatorBase::InArgs<Scalar>
getLowerBounds
()
const
;
139
ModelEvaluatorBase::InArgs<Scalar>
getUpperBounds
()
const
;
141
RCP<LinearOpBase<Scalar>
>
create_W_op
()
const
;
143
RCP<PreconditionerBase<Scalar>
>
create_W_prec
()
const
;
145
RCP<const LinearOpWithSolveFactoryBase<Scalar>
>
get_W_factory
()
const
;
147
ModelEvaluatorBase::InArgs<Scalar>
createInArgs
()
const
;
149
void
reportFinalPoint
(
150
const
ModelEvaluatorBase::InArgs<Scalar>
&finalPoint,
151
const
bool
wasSolved
152
);
153
155
156
// For unit testing
157
void
change_p_size_incorrectly(
const
Ordinal new_size);
158
void
change_p_size_correctly(
const
Ordinal new_size);
159
160
private
:
// functions
161
164
166
ModelEvaluatorBase::OutArgs<Scalar>
createOutArgsImpl()
const
;
168
void
evalModelImpl(
169
const
ModelEvaluatorBase::InArgs<Scalar>
&inArgs,
170
const
ModelEvaluatorBase::OutArgs<Scalar>
&outArgs
171
)
const
;
172
174
175
private
:
// data members
176
177
RCP<const VectorSpaceBase<Scalar>
> x_space_;
178
Array<RCP<const VectorSpaceBase<Scalar>
> > p_space_;
179
RCP<const VectorSpaceBase<Scalar>
> f_space_;
180
Array<RCP<const VectorSpaceBase<Scalar>
> > g_space_;
181
Array<std::string>
g_names_;
182
RCP<const LinearOpWithSolveFactoryBase<Scalar>
> W_factory_;
183
ModelEvaluatorBase::InArgs<Scalar>
nominalValues_;
184
RCP<VectorBase<Scalar>
> x0_;
185
ModelEvaluatorBase::InArgs<Scalar>
prototypeInArgs_;
186
ModelEvaluatorBase::OutArgs<Scalar>
prototypeOutArgs_;
187
188
};
189
190
191
}
// namespace Thyra
192
193
194
#endif
// DUMMY_TEST_MODEL_EVALUATOR_DECL_HPP
Teuchos::ArrayView
Teuchos::Array
Teuchos::RCP
Thyra::DummyTestModelEvaluator
Test helper ModelEvaluator.
Definition
Thyra_DummyTestModelEvaluator_decl.hpp:99
Thyra::DummyTestModelEvaluator::get_x_space
RCP< const VectorSpaceBase< Scalar > > get_x_space() const
Definition
Thyra_DummyTestModelEvaluator_def.hpp:169
Thyra::DummyTestModelEvaluator::get_W_factory
RCP< const LinearOpWithSolveFactoryBase< Scalar > > get_W_factory() const
Definition
Thyra_DummyTestModelEvaluator_def.hpp:263
Thyra::DummyTestModelEvaluator::DummyTestModelEvaluator
DummyTestModelEvaluator(const Ordinal x_size, const ArrayView< const Ordinal > &p_sizes, const ArrayView< const Ordinal > &g_sizes, const bool supports_x_dot=false, const bool supports_x_dot_dot=false, const bool supports_extended_inargs=true, const bool supports_extended_outargs=true, const bool supports_derivatives=false)
Definition
Thyra_DummyTestModelEvaluator_def.hpp:86
Thyra::DummyTestModelEvaluator::getUpperBounds
ModelEvaluatorBase::InArgs< Scalar > getUpperBounds() const
Definition
Thyra_DummyTestModelEvaluator_def.hpp:233
Thyra::DummyTestModelEvaluator::create_W_prec
RCP< PreconditionerBase< Scalar > > create_W_prec() const
Definition
Thyra_DummyTestModelEvaluator_def.hpp:251
Thyra::DummyTestModelEvaluator::get_g_space
RCP< const VectorSpaceBase< Scalar > > get_g_space(int j) const
Definition
Thyra_DummyTestModelEvaluator_def.hpp:201
Thyra::DummyTestModelEvaluator::getLowerBounds
ModelEvaluatorBase::InArgs< Scalar > getLowerBounds() const
Definition
Thyra_DummyTestModelEvaluator_def.hpp:225
Thyra::DummyTestModelEvaluator::get_p_names
RCP< const Teuchos::Array< std::string > > get_p_names(int l) const
Definition
Thyra_DummyTestModelEvaluator_def.hpp:185
Thyra::DummyTestModelEvaluator::get_f_space
RCP< const VectorSpaceBase< Scalar > > get_f_space() const
Definition
Thyra_DummyTestModelEvaluator_def.hpp:193
Thyra::DummyTestModelEvaluator::get_g_names
Teuchos::ArrayView< const std::string > get_g_names(int j) const
Definition
Thyra_DummyTestModelEvaluator_def.hpp:209
Thyra::DummyTestModelEvaluator::reportFinalPoint
void reportFinalPoint(const ModelEvaluatorBase::InArgs< Scalar > &finalPoint, const bool wasSolved)
Definition
Thyra_DummyTestModelEvaluator_def.hpp:278
Thyra::DummyTestModelEvaluator::create_W_op
RCP< LinearOpBase< Scalar > > create_W_op() const
Definition
Thyra_DummyTestModelEvaluator_def.hpp:241
Thyra::DummyTestModelEvaluator::getNominalValues
ModelEvaluatorBase::InArgs< Scalar > getNominalValues() const
Definition
Thyra_DummyTestModelEvaluator_def.hpp:217
Thyra::DummyTestModelEvaluator::createInArgs
ModelEvaluatorBase::InArgs< Scalar > createInArgs() const
Definition
Thyra_DummyTestModelEvaluator_def.hpp:271
Thyra::DummyTestModelEvaluator::get_p_space
RCP< const VectorSpaceBase< Scalar > > get_p_space(int l) const
Definition
Thyra_DummyTestModelEvaluator_def.hpp:177
Thyra::ModelEvaluatorBase::InArgs
Concrete aggregate class for all input arguments computable by a ModelEvaluator subclass object.
Definition
Thyra_ModelEvaluatorBase_decl.hpp:159
Thyra::ModelEvaluatorBase::OutArgs
Concrete aggregate class for all output arguments computable by a ModelEvaluator subclass object.
Definition
Thyra_ModelEvaluatorBase_decl.hpp:902
Thyra::ModelEvaluatorDefaultBase::ModelEvaluatorDefaultBase
ModelEvaluatorDefaultBase()
Definition
Thyra_ModelEvaluatorDefaultBase.hpp:1036
Generated by
1.17.0