Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up observer interfaces #1087

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 22 additions & 19 deletions src/Albany_ObserverImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@ ObserverImpl (const Teuchos::RCP<Application> &app)

void ObserverImpl::
observeSolution(double stamp,
const Thyra_Vector& nonOverlappedSolution,
const Teuchos::Ptr<const Thyra_MultiVector>& nonOverlappedSolution_dxdp,
const Teuchos::Ptr<const Thyra_Vector>& nonOverlappedSolutionDot,
const Teuchos::Ptr<const Thyra_Vector>& nonOverlappedSolutionDotDot)
const Thyra_Vector& x,
const Teuchos::Ptr<const Thyra_MultiVector>& dxdp,
const Teuchos::Ptr<const Thyra_Vector>& x_dot,
const Teuchos::Ptr<const Thyra_Vector>& x_dotdot)
{
app_->evaluateStateFieldManager (stamp,
nonOverlappedSolution,
nonOverlappedSolutionDot,
nonOverlappedSolutionDotDot,
nonOverlappedSolution_dxdp);
app_->evaluateStateFieldManager (stamp, x, x_dot, x_dotdot, dxdp);

//! update distributed parameters in the mesh
auto distParamLib = app_->getDistributedParameterLibrary();
Expand All @@ -44,21 +40,28 @@ observeSolution(double stamp,
}

StatelessObserverImpl::observeSolution (stamp,
nonOverlappedSolution,
nonOverlappedSolution_dxdp,
nonOverlappedSolutionDot,
nonOverlappedSolutionDotDot);
Teuchos::rcpFromRef(x),
Teuchos::rcpFromPtr(x_dot),
Teuchos::rcpFromPtr(x_dotdot),
Teuchos::rcpFromPtr(dxdp));
}

void ObserverImpl::
observeSolution(double stamp,
const Thyra_MultiVector& nonOverlappedSolution,
const Teuchos::Ptr<const Thyra_MultiVector>& nonOverlappedSolution_dxdp)
const Thyra_MultiVector& x,
const Teuchos::Ptr<const Thyra_MultiVector>& dxdp)
{
app_->evaluateStateFieldManager(stamp, nonOverlappedSolution,
nonOverlappedSolution_dxdp);
StatelessObserverImpl::observeSolution(stamp, nonOverlappedSolution,
nonOverlappedSolution_dxdp);
app_->evaluateStateFieldManager(stamp, x, dxdp);
Teuchos::Ptr<const Thyra_Vector> x_dot,x_dotdot;

int x_ncols = x.domain()->dim();
if (x_ncols==1) {
x_dot = x.col(1).ptr();
} else if (x_ncols==2) {
x_dot = x.col(1).ptr();
x_dotdot = x.col(2).ptr();
}
observeSolution (stamp, *x.col(0), dxdp, x_dot, x_dotdot);
}

void ObserverImpl::
Expand Down
23 changes: 12 additions & 11 deletions src/Albany_ObserverImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,26 @@

namespace Albany {

class ObserverImpl : public StatelessObserverImpl, public Piro::ROL_ObserverBase<ST> {
class ObserverImpl : public StatelessObserverImpl,
public Piro::ROL_ObserverBase<ST>
{
public:
explicit ObserverImpl(const Teuchos::RCP<Application>& app);

// Bring in scope the version we don't override
using StatelessObserverImpl::observeSolution;

void observeSolution(
double stamp, const Thyra_Vector& nonOverlappedSolution,
const Teuchos::Ptr<const Thyra_MultiVector>& nonOverlappedSolution_dxdp,
const Teuchos::Ptr<const Thyra_Vector>& nonOverlappedSolutionDot,
const Teuchos::Ptr<const Thyra_Vector>& nonOverlappedSolutionDotDot) override;
// Override from ROL_ObserverBase
void observeSolution (double stamp, const Thyra_Vector& x,
const Teuchos::Ptr<const Thyra_MultiVector>& x_dxdp,
const Teuchos::Ptr<const Thyra_Vector>& x_dot,
const Teuchos::Ptr<const Thyra_Vector>& x_dotdot) override;

void observeSolution(
double stamp, const Thyra_MultiVector& nonOverlappedSolution,
const Teuchos::Ptr<const Thyra_MultiVector>& nonOverlappedSolution_dxdp) override;
void observeSolution (double stamp,
const Thyra_MultiVector& x,
const Teuchos::Ptr<const Thyra_MultiVector>& dxdp) override;

void parameterChanged(
const std::string& param) override;
void parameterChanged (const std::string& param) override;

void parametersChanged() override;

Expand Down
Loading