-
Notifications
You must be signed in to change notification settings - Fork 90
/
Copy pathAlbany_StatelessObserverImpl.cpp
68 lines (58 loc) · 2.52 KB
/
Albany_StatelessObserverImpl.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//*****************************************************************//
// Albany 3.0: Copyright 2016 Sandia Corporation //
// This Software is released under the BSD license detailed //
// in the file "license.txt" in the top-level Albany directory //
//*****************************************************************//
#include "Albany_StatelessObserverImpl.hpp"
#include "Albany_AbstractDiscretization.hpp"
#include "Teuchos_TimeMonitor.hpp"
#include <string>
namespace Albany {
StatelessObserverImpl::
StatelessObserverImpl (const Teuchos::RCP<Application> &app)
: app_(app),
solOutTime_(Teuchos::TimeMonitor::getNewTimer("Albany: Observe Solution"))
{
force_write_solution_ = app->getForceWriteSolution();
}
RealType StatelessObserverImpl::
getTimeParamValueOrDefault (RealType defaultValue) const {
const std::string label("Time");
bool const
use_time_param = (app_->getParamLib()->isParameter(label) == true) &&
(app_->getSolutionMethod() != Transient);
double const
this_time = use_time_param == true ?
app_->getParamLib()->getRealValue<PHAL::AlbanyTraits::Residual>(label) :
defaultValue;
return this_time;
}
void StatelessObserverImpl::
observeSolution (double stamp,
const Teuchos::RCP<const Thyra_Vector>& x,
const Teuchos::RCP<const Thyra_Vector>& x_dot,
const Teuchos::RCP<const Thyra_Vector>& x_dotdot,
const Teuchos::RCP<const Thyra_MultiVector>& dxdp)
{
Teuchos::TimeMonitor timer(*solOutTime_);
auto overlapped_x = app_->getAdaptSolMgr()->updateAndReturnOverlapSolution(*x);
Teuchos::RCP<Thyra_MultiVector> overlapped_dxdp;
if (dxdp != Teuchos::null) {
overlapped_dxdp = app_->getAdaptSolMgr()->updateAndReturnOverlapSolutionDxDp(*dxdp);
}
if (x_dot != Teuchos::null) {
auto overlapped_x_dot = app_->getAdaptSolMgr()->updateAndReturnOverlapSolutionDot(*x_dot);
if (x_dotdot != Teuchos::null) {
auto overlapped_x_dotdot = app_->getAdaptSolMgr()->updateAndReturnOverlapSolutionDotDot(*x_dotdot);
app_->getDiscretization()->writeSolution(
*overlapped_x, overlapped_dxdp, *overlapped_x_dot, *overlapped_x_dotdot,
stamp, true, force_write_solution_);
} else {
app_->getDiscretization()->writeSolution(
*overlapped_x, overlapped_dxdp, *overlapped_x_dot, stamp, true, force_write_solution_);
}
} else {
app_->getDiscretization()->writeSolution(*overlapped_x, overlapped_dxdp, stamp, true, force_write_solution_);
}
}
} // namespace Albany