FEApp_SolutionAverageResponseFunction.cpp

Go to the documentation of this file.
00001 // $Id$ 
00002 // $Source$ 
00003 // @HEADER
00004 // ***********************************************************************
00005 // 
00006 //                           Sacado Package
00007 //                 Copyright (2006) Sandia Corporation
00008 // 
00009 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
00010 // the U.S. Government retains certain rights in this software.
00011 // 
00012 // This library is free software; you can redistribute it and/or modify
00013 // it under the terms of the GNU Lesser General Public License as
00014 // published by the Free Software Foundation; either version 2.1 of the
00015 // License, or (at your option) any later version.
00016 //  
00017 // This library is distributed in the hope that it will be useful, but
00018 // WITHOUT ANY WARRANTY; without even the implied warranty of
00019 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020 // Lesser General Public License for more details.
00021 //  
00022 // You should have received a copy of the GNU Lesser General Public
00023 // License along with this library; if not, write to the Free Software
00024 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00025 // USA
00026 // Questions? Contact David M. Gay (dmgay@sandia.gov) or Eric T. Phipps
00027 // (etphipp@sandia.gov).
00028 // 
00029 // ***********************************************************************
00030 // @HEADER
00031 
00032 #include "FEApp_SolutionAverageResponseFunction.hpp"
00033 
00034 FEApp::SolutionAverageResponseFunction::
00035 SolutionAverageResponseFunction()
00036 {
00037 }
00038 
00039 FEApp::SolutionAverageResponseFunction::
00040 ~SolutionAverageResponseFunction()
00041 {
00042 }
00043 
00044 unsigned int
00045 FEApp::SolutionAverageResponseFunction::
00046 numResponses() const 
00047 {
00048   return 1;
00049 }
00050 
00051 void
00052 FEApp::SolutionAverageResponseFunction::
00053 evaluateResponses(const Epetra_Vector* xdot,
00054       const Epetra_Vector& x,
00055       const Teuchos::Array< Teuchos::RCP<ParamVec> >& p,
00056       Epetra_Vector& g)
00057 {
00058   x.MeanValue(&g[0]);
00059 }
00060 
00061 void
00062 FEApp::SolutionAverageResponseFunction::
00063 evaluateTangents(
00064      const Epetra_Vector* xdot,
00065      const Epetra_Vector& x,
00066      const Teuchos::Array< Teuchos::RCP<ParamVec> >& p,
00067      const Teuchos::Array< Teuchos::RCP<ParamVec> >& deriv_p,
00068      const Teuchos::Array< Teuchos::RCP<Epetra_MultiVector> >& dxdot_dp,
00069      const Teuchos::Array< Teuchos::RCP<Epetra_MultiVector> >& dx_dp,
00070      Epetra_Vector* g,
00071      const Teuchos::Array< Teuchos::RCP<Epetra_MultiVector> >& gt)
00072 {
00073   // Evaluate response g
00074   if (g != NULL)
00075     x.MeanValue(&(*g)[0]);
00076 
00077   // Evaluate tangent of g = dg/dx*dx/dp + dg/dxdot*dxdot/dp + dg/dp
00078   for (unsigned int j=0; j<gt.size(); j++)
00079     if (gt[j] != Teuchos::null)
00080       for (int i=0; i<dx_dp[i]->NumVectors(); i++)
00081   (*dx_dp[j])(i)->MeanValue(&(*gt[j])[i][0]);
00082 }
00083 
00084 void
00085 FEApp::SolutionAverageResponseFunction::
00086 evaluateGradients(
00087     const Epetra_Vector* xdot,
00088     const Epetra_Vector& x,
00089     const Teuchos::Array< Teuchos::RCP<ParamVec> >& p,
00090     const Teuchos::Array< Teuchos::RCP<ParamVec> >& deriv_p,
00091     Epetra_Vector* g,
00092     Epetra_MultiVector* dg_dx,
00093     Epetra_MultiVector* dg_dxdot,
00094     const Teuchos::Array< Teuchos::RCP<Epetra_MultiVector> >& dg_dp)
00095 {
00096 
00097   // Evaluate response g
00098   if (g != NULL)
00099     x.MeanValue(&(*g)[0]);
00100 
00101   // Evaluate dg/dx
00102   if (dg_dx != NULL)
00103     dg_dx->PutScalar(1.0 / x.GlobalLength());
00104 
00105   // Evaluate dg/dxdot
00106   if (dg_dxdot != NULL)
00107     dg_dxdot->PutScalar(0.0);
00108 
00109   // Evaluate dg/dp
00110   for (unsigned int j=0; j<dg_dp.size(); j++)
00111     if (dg_dp[j] != Teuchos::null)
00112       dg_dp[j]->PutScalar(0.0);
00113 }
00114 
00115 #if SG_ACTIVE
00116 void
00117 FEApp::SolutionAverageResponseFunction::
00118 evaluateSGResponses(const Stokhos::VectorOrthogPoly<Epetra_Vector>* sg_xdot,
00119         const Stokhos::VectorOrthogPoly<Epetra_Vector>& sg_x,
00120         const ParamVec* p,
00121         const ParamVec* sg_p,
00122         const Teuchos::Array<SGType>* sg_p_vals,
00123         Stokhos::VectorOrthogPoly<Epetra_Vector>& sg_g)
00124 {
00125   unsigned int sz = sg_x.size();
00126   for (unsigned int i=0; i<sz; i++)
00127     sg_x[i].MeanValue(&sg_g[i][0]);
00128 }
00129 #endif

Generated on Wed May 12 21:39:33 2010 for Sacado Package Browser (Single Doxygen Collection) by  doxygen 1.4.7