FEApp_HeatNonlinearSourceProblem.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_HeatNonlinearSourceProblem.hpp"
00033 #include "FEApp_ConstantNodeBCStrategy.hpp"
00034 #include "FEApp_BoundaryFlux1DResponseFunction.hpp"
00035 #include "FEApp_SolutionAverageResponseFunction.hpp"
00036 #include "FEApp_SolutionTwoNormResponseFunction.hpp"
00037 
00038 FEApp::HeatNonlinearSourceProblem::
00039 HeatNonlinearSourceProblem(
00040               const Teuchos::RCP<Teuchos::ParameterList>& params_,
00041               const Teuchos::RCP<ParamLib>& paramLib_) :
00042   params(params_),
00043   paramLib(paramLib_)
00044 {
00045   leftBC = params->get("Left BC", 0.0);
00046   rightBC = params->get("Right BC", 0.0);
00047 }
00048 
00049 FEApp::HeatNonlinearSourceProblem::
00050 ~HeatNonlinearSourceProblem()
00051 {
00052 }
00053 
00054 unsigned int
00055 FEApp::HeatNonlinearSourceProblem::
00056 numEquations() const
00057 {
00058   return 1;
00059 }
00060 
00061 void
00062 FEApp::HeatNonlinearSourceProblem:: 
00063 buildProblem(
00064       const Epetra_Map& dofMap,
00065       const Epetra_Map& overlapped_dofMap,
00066       FEApp::AbstractPDE_TemplateManager<EvalTypes>& pdeTM,
00067       std::vector< Teuchos::RCP<FEApp::NodeBC> >& bcs,
00068       std::vector< Teuchos::RCP<FEApp::AbstractResponseFunction> >& responses,
00069       const Teuchos::RCP<Epetra_Vector>& u)
00070 {
00071   // Build PDE equations
00072   FEApp::HeatNonlinearSourcePDE_TemplateBuilder pdeBuilder(params, paramLib);
00073   pdeTM.buildObjects(pdeBuilder);
00074 
00075   // Build boundary conditions
00076   FEApp::ConstantNodeBCStrategy_TemplateBuilder leftBuilder(0, 0, leftBC, 1,
00077                                                             paramLib);
00078   FEApp::ConstantNodeBCStrategy_TemplateBuilder rightBuilder(0, 0, rightBC, 2,
00079                                                              paramLib);
00080   int left_node = dofMap.MinAllGID();
00081   int right_node = dofMap.MaxAllGID();
00082   bcs.resize(2);
00083   bcs[0] = Teuchos::rcp(new FEApp::NodeBC(dofMap, overlapped_dofMap,
00084                                           left_node, 1, leftBuilder));
00085   bcs[1] = Teuchos::rcp(new FEApp::NodeBC(dofMap, overlapped_dofMap,
00086                                           right_node, 1, rightBuilder));
00087 
00088   // Build response functions
00089   Teuchos::ParameterList& responseList = params->sublist("Response Functions");
00090   int num_responses = responseList.get("Number", 0);
00091   responses.resize(num_responses);
00092   for (int i=0; i<num_responses; i++) {
00093      std::ostringstream ss;
00094      ss << "Response " << i;
00095      std::string name = responseList.get(ss.str(), "??");
00096 
00097      if (name == "Boundary Flux 1D") {
00098        double h = 1.0 / (dofMap.NumGlobalElements() - 1);
00099        responses[i] =
00100          Teuchos::rcp(new BoundaryFlux1DResponseFunction(left_node,
00101                                                          right_node,
00102                                                          0, 1, h,
00103                                                          dofMap));
00104      }
00105 
00106      else if (name == "Solution Average")
00107        responses[i] = Teuchos::rcp(new SolutionAverageResponseFunction());
00108 
00109      else if (name == "Solution Two Norm")
00110        responses[i] = Teuchos::rcp(new SolutionTwoNormResponseFunction());
00111 
00112      else {
00113        TEST_FOR_EXCEPTION(true, Teuchos::Exceptions::InvalidParameter,
00114                           std::endl <<
00115                           "Error!  Unknown response function " << name <<
00116                           "!" << std::endl << "Supplied parameter list is " <<
00117                           std::endl << responseList);
00118      }
00119   }
00120 
00121   // Build initial solution
00122   u->PutScalar(1.0);
00123 }

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