00001
00002
00003
00004
00005
00006
00007 #include "Albany_ScalarResponseFunction.hpp"
00008 #include "Teuchos_TestForException.hpp"
00009 #include "Epetra_LocalMap.h"
00010
00011 Teuchos::RCP<const Epetra_Map>
00012 Albany::ScalarResponseFunction::
00013 responseMap() const
00014 {
00015 int num_responses = this->numResponses();
00016 Teuchos::RCP<const Epetra_LocalMap> response_map =
00017 Teuchos::rcp(new Epetra_LocalMap(num_responses, 0, *comm));
00018 return response_map;
00019 }
00020
00021 Teuchos::RCP<Epetra_Operator>
00022 Albany::ScalarResponseFunction::
00023 createGradientOp() const
00024 {
00025 TEUCHOS_TEST_FOR_EXCEPTION(
00026 true, std::logic_error,
00027 "Error! Albany::ScalarResponseFunction::createGradientOp(): " <<
00028 "Operator form of dg/dx is not supported for scalar responses.");
00029 return Teuchos::null;
00030 }
00031
00032 void
00033 Albany::ScalarResponseFunction::
00034 evaluateDerivative(
00035 const double current_time,
00036 const Epetra_Vector* xdot,
00037 const Epetra_Vector* xdotdot,
00038 const Epetra_Vector& x,
00039 const Teuchos::Array<ParamVec>& p,
00040 ParamVec* deriv_p,
00041 Epetra_Vector* g,
00042 const EpetraExt::ModelEvaluator::Derivative& dg_dx,
00043 const EpetraExt::ModelEvaluator::Derivative& dg_dxdot,
00044 const EpetraExt::ModelEvaluator::Derivative& dg_dxdotdot,
00045 const EpetraExt::ModelEvaluator::Derivative& dg_dp)
00046 {
00047 this->evaluateGradient(
00048 current_time, xdot, xdotdot, x, p, deriv_p, g,
00049 dg_dx.getMultiVector().get(), dg_dxdot.getMultiVector().get(), dg_dxdotdot.getMultiVector().get(),
00050 dg_dp.getMultiVector().get());
00051 }
00052
00053 #ifdef ALBANY_SG_MP
00054 void
00055 Albany::ScalarResponseFunction::
00056 evaluateSGDerivative(
00057 const double current_time,
00058 const Stokhos::EpetraVectorOrthogPoly* sg_xdot,
00059 const Stokhos::EpetraVectorOrthogPoly* sg_xdotdot,
00060 const Stokhos::EpetraVectorOrthogPoly& sg_x,
00061 const Teuchos::Array<ParamVec>& p,
00062 const Teuchos::Array<int>& sg_p_index,
00063 const Teuchos::Array< Teuchos::Array<SGType> >& sg_p_vals,
00064 ParamVec* deriv_p,
00065 Stokhos::EpetraVectorOrthogPoly* sg_g,
00066 const EpetraExt::ModelEvaluator::SGDerivative& sg_dg_dx,
00067 const EpetraExt::ModelEvaluator::SGDerivative& sg_dg_dxdot,
00068 const EpetraExt::ModelEvaluator::SGDerivative& sg_dg_dxdotdot,
00069 const EpetraExt::ModelEvaluator::SGDerivative& sg_dg_dp)
00070 {
00071 this->evaluateSGGradient(
00072 current_time, sg_xdot, sg_xdotdot, sg_x, p, sg_p_index, sg_p_vals, deriv_p,
00073 sg_g, sg_dg_dx.getMultiVector().get(), sg_dg_dxdot.getMultiVector().get(), sg_dg_dxdotdot.getMultiVector().get(),
00074 sg_dg_dp.getMultiVector().get());
00075 }
00076
00077 void
00078 Albany::ScalarResponseFunction::
00079 evaluateMPDerivative(
00080 const double current_time,
00081 const Stokhos::ProductEpetraVector* mp_xdot,
00082 const Stokhos::ProductEpetraVector* mp_xdotdot,
00083 const Stokhos::ProductEpetraVector& mp_x,
00084 const Teuchos::Array<ParamVec>& p,
00085 const Teuchos::Array<int>& mp_p_index,
00086 const Teuchos::Array< Teuchos::Array<MPType> >& mp_p_vals,
00087 ParamVec* deriv_p,
00088 Stokhos::ProductEpetraVector* mp_g,
00089 const EpetraExt::ModelEvaluator::MPDerivative& mp_dg_dx,
00090 const EpetraExt::ModelEvaluator::MPDerivative& mp_dg_dxdot,
00091 const EpetraExt::ModelEvaluator::MPDerivative& mp_dg_dxdotdot,
00092 const EpetraExt::ModelEvaluator::MPDerivative& mp_dg_dp)
00093 {
00094 this->evaluateMPGradient(
00095 current_time, mp_xdot, mp_xdotdot, mp_x, p, mp_p_index, mp_p_vals, deriv_p,
00096 mp_g, mp_dg_dx.getMultiVector().get(), mp_dg_dxdot.getMultiVector().get(), mp_dg_dxdotdot.getMultiVector().get(),
00097 mp_dg_dp.getMultiVector().get());
00098 }
00099 #endif //ALBANY_SG_MP