00001
00002
00003
00004
00005
00006
00007 #ifndef ALBANY_SOLUTION_RESPONSE_FUNCTION_HPP
00008 #define ALBANY_SOLUTION_RESPONSE_FUNCTION_HPP
00009
00010 #include "Albany_DistributedResponseFunction.hpp"
00011 #include "Albany_Application.hpp"
00012
00013 #include "Teuchos_ParameterList.hpp"
00014 #include "Teuchos_Array.hpp"
00015
00016 #include "Epetra_Map.h"
00017 #include "Epetra_Import.h"
00018 #include "Epetra_CrsGraph.h"
00019
00020 namespace Albany {
00021
00025 class SolutionResponseFunction : public DistributedResponseFunction {
00026 public:
00027
00029 SolutionResponseFunction(
00030 const Teuchos::RCP<Albany::Application>& application,
00031 Teuchos::ParameterList& responseParams);
00032
00034 virtual ~SolutionResponseFunction();
00035
00037 virtual void setup();
00038
00040 virtual Teuchos::RCP<const Epetra_Map> responseMap() const;
00041
00043 virtual Teuchos::RCP<Epetra_Operator> createGradientOp() const;
00044
00046
00047
00049 virtual void evaluateResponse(
00050 const double current_time,
00051 const Epetra_Vector* xdot,
00052 const Epetra_Vector* xdotdot,
00053 const Epetra_Vector& x,
00054 const Teuchos::Array<ParamVec>& p,
00055 Epetra_Vector& g);
00056
00058 virtual void evaluateTangent(
00059 const double alpha,
00060 const double beta,
00061 const double omega,
00062 const double current_time,
00063 bool sum_derivs,
00064 const Epetra_Vector* xdot,
00065 const Epetra_Vector* xdotdot,
00066 const Epetra_Vector& x,
00067 const Teuchos::Array<ParamVec>& p,
00068 ParamVec* deriv_p,
00069 const Epetra_MultiVector* Vxdot,
00070 const Epetra_MultiVector* Vxdotdot,
00071 const Epetra_MultiVector* Vx,
00072 const Epetra_MultiVector* Vp,
00073 Epetra_Vector* g,
00074 Epetra_MultiVector* gx,
00075 Epetra_MultiVector* gp);
00076
00078 virtual void evaluateGradient(
00079 const double current_time,
00080 const Epetra_Vector* xdot,
00081 const Epetra_Vector* xdotdot,
00082 const Epetra_Vector& x,
00083 const Teuchos::Array<ParamVec>& p,
00084 ParamVec* deriv_p,
00085 Epetra_Vector* g,
00086 Epetra_Operator* dg_dx,
00087 Epetra_Operator* dg_dxdot,
00088 Epetra_Operator* dg_dxdotdot,
00089 Epetra_MultiVector* dg_dp);
00090
00092
00094
00095
00096 #ifdef ALBANY_SG_MP
00097
00098 virtual void init_sg(
00099 const Teuchos::RCP<const Stokhos::OrthogPolyBasis<int,double> >& basis,
00100 const Teuchos::RCP<const Stokhos::Quadrature<int,double> >& quad,
00101 const Teuchos::RCP<Stokhos::OrthogPolyExpansion<int,double> >& expansion,
00102 const Teuchos::RCP<const EpetraExt::MultiComm>& multiComm);
00103
00105 virtual void evaluateSGResponse(
00106 const double curr_time,
00107 const Stokhos::EpetraVectorOrthogPoly* sg_xdot,
00108 const Stokhos::EpetraVectorOrthogPoly* sg_xdotdot,
00109 const Stokhos::EpetraVectorOrthogPoly& sg_x,
00110 const Teuchos::Array<ParamVec>& p,
00111 const Teuchos::Array<int>& sg_p_index,
00112 const Teuchos::Array< Teuchos::Array<SGType> >& sg_p_vals,
00113 Stokhos::EpetraVectorOrthogPoly& sg_g);
00114
00116 virtual void evaluateSGTangent(
00117 const double alpha,
00118 const double beta,
00119 const double omega,
00120 const double current_time,
00121 bool sum_derivs,
00122 const Stokhos::EpetraVectorOrthogPoly* sg_xdot,
00123 const Stokhos::EpetraVectorOrthogPoly* sg_xdotdot,
00124 const Stokhos::EpetraVectorOrthogPoly& sg_x,
00125 const Teuchos::Array<ParamVec>& p,
00126 const Teuchos::Array<int>& sg_p_index,
00127 const Teuchos::Array< Teuchos::Array<SGType> >& sg_p_vals,
00128 ParamVec* deriv_p,
00129 const Epetra_MultiVector* Vx,
00130 const Epetra_MultiVector* Vxdot,
00131 const Epetra_MultiVector* Vxdotdot,
00132 const Epetra_MultiVector* Vp,
00133 Stokhos::EpetraVectorOrthogPoly* sg_g,
00134 Stokhos::EpetraMultiVectorOrthogPoly* sg_JV,
00135 Stokhos::EpetraMultiVectorOrthogPoly* sg_gp);
00136
00138 virtual void evaluateSGGradient(
00139 const double current_time,
00140 const Stokhos::EpetraVectorOrthogPoly* sg_xdot,
00141 const Stokhos::EpetraVectorOrthogPoly* sg_xdotdot,
00142 const Stokhos::EpetraVectorOrthogPoly& sg_x,
00143 const Teuchos::Array<ParamVec>& p,
00144 const Teuchos::Array<int>& sg_p_index,
00145 const Teuchos::Array< Teuchos::Array<SGType> >& sg_p_vals,
00146 ParamVec* deriv_p,
00147 Stokhos::EpetraVectorOrthogPoly* sg_g,
00148 Stokhos::EpetraOperatorOrthogPoly* sg_dg_dx,
00149 Stokhos::EpetraOperatorOrthogPoly* sg_dg_dxdot,
00150 Stokhos::EpetraOperatorOrthogPoly* sg_dg_dxdotdot,
00151 Stokhos::EpetraMultiVectorOrthogPoly* sg_dg_dp);
00152 #endif //ALBANY_SG_MP
00153
00155
00157
00158
00159 #ifdef ALBANY_SG_MP
00160
00161 virtual void evaluateMPResponse(
00162 const double curr_time,
00163 const Stokhos::ProductEpetraVector* mp_xdot,
00164 const Stokhos::ProductEpetraVector* mp_xdotdot,
00165 const Stokhos::ProductEpetraVector& mp_x,
00166 const Teuchos::Array<ParamVec>& p,
00167 const Teuchos::Array<int>& mp_p_index,
00168 const Teuchos::Array< Teuchos::Array<MPType> >& mp_p_vals,
00169 Stokhos::ProductEpetraVector& mp_g);
00170
00172 virtual void evaluateMPTangent(
00173 const double alpha,
00174 const double beta,
00175 const double omega,
00176 const double current_time,
00177 bool sum_derivs,
00178 const Stokhos::ProductEpetraVector* mp_xdot,
00179 const Stokhos::ProductEpetraVector* mp_xdotdot,
00180 const Stokhos::ProductEpetraVector& mp_x,
00181 const Teuchos::Array<ParamVec>& p,
00182 const Teuchos::Array<int>& mp_p_index,
00183 const Teuchos::Array< Teuchos::Array<MPType> >& mp_p_vals,
00184 ParamVec* deriv_p,
00185 const Epetra_MultiVector* Vx,
00186 const Epetra_MultiVector* Vxdot,
00187 const Epetra_MultiVector* Vxdotdot,
00188 const Epetra_MultiVector* Vp,
00189 Stokhos::ProductEpetraVector* mp_g,
00190 Stokhos::ProductEpetraMultiVector* mp_JV,
00191 Stokhos::ProductEpetraMultiVector* mp_gp);
00192
00194 virtual void evaluateMPGradient(
00195 const double current_time,
00196 const Stokhos::ProductEpetraVector* mp_xdot,
00197 const Stokhos::ProductEpetraVector* mp_xdotdot,
00198 const Stokhos::ProductEpetraVector& mp_x,
00199 const Teuchos::Array<ParamVec>& p,
00200 const Teuchos::Array<int>& mp_p_index,
00201 const Teuchos::Array< Teuchos::Array<MPType> >& mp_p_vals,
00202 ParamVec* deriv_p,
00203 Stokhos::ProductEpetraVector* mp_g,
00204 Stokhos::ProductEpetraOperator* mp_dg_dx,
00205 Stokhos::ProductEpetraOperator* mp_dg_dxdot,
00206 Stokhos::ProductEpetraOperator* mp_dg_dxdotdot,
00207 Stokhos::ProductEpetraMultiVector* mp_dg_dp);
00208 #endif //ALBANY_SG_MP
00209
00211
00212 private:
00213
00215 SolutionResponseFunction(const SolutionResponseFunction&);
00216
00218 SolutionResponseFunction& operator=(const SolutionResponseFunction&);
00219
00220 protected:
00221
00222 Teuchos::RCP<Epetra_Map>
00223 buildCulledMap(const Epetra_Map& x_map,
00224 const Teuchos::Array<int>& keepDOF) const;
00225
00226 void cullSolution(const Epetra_MultiVector& x,
00227 Epetra_MultiVector& x_culled) const;
00228
00229 protected:
00230
00232 Teuchos::RCP<Albany::Application> application;
00233
00235 Teuchos::Array<int> keepDOF;
00236
00238 Teuchos::RCP<const Epetra_Map> culled_map;
00239
00241 Teuchos::RCP<Epetra_Import> importer;
00242
00244 Teuchos::RCP<Epetra_CrsGraph> gradient_graph;
00245
00246 };
00247
00248 }
00249
00250 #endif // ALBANY_SOLUTION_RESPONSE_FUNCTION_HPP