00001
00002
00003
00004
00005
00006 #include "Albany_ResponseUtilities.hpp"
00007 #include "Albany_Utils.hpp"
00008
00009 #include "QCAD_ResponseFieldIntegral.hpp"
00010 #include "QCAD_ResponseFieldValue.hpp"
00011 #include "QCAD_ResponseFieldAverage.hpp"
00012 #include "QCAD_ResponseSaveField.hpp"
00013 #include "QCAD_ResponseCenterOfMass.hpp"
00014 #include "PHAL_ResponseFieldIntegral.hpp"
00015 #include "Adapt_ElementSizeField.hpp"
00016 #include "PHAL_SaveNodalField.hpp"
00017 #include "FELIX_ResponseSurfaceVelocityMismatch.hpp"
00018 #ifdef ALBANY_QCAD
00019 #include "QCAD_ResponseSaddleValue.hpp"
00020 #include "QCAD_ResponseRegionBoundary.hpp"
00021 #endif
00022 #ifdef ALBANY_LCM
00023 #include "IPtoNodalField.hpp"
00024 #endif
00025
00026 template<typename EvalT, typename Traits>
00027 Albany::ResponseUtilities<EvalT,Traits>::ResponseUtilities(
00028 Teuchos::RCP<Albany::Layouts> dl_) :
00029 dl(dl_)
00030 {
00031 }
00032
00033 template<typename EvalT, typename Traits>
00034 Teuchos::RCP<const PHX::FieldTag>
00035 Albany::ResponseUtilities<EvalT,Traits>::constructResponses(
00036 PHX::FieldManager<PHAL::AlbanyTraits>& fm,
00037 Teuchos::ParameterList& responseParams,
00038 Teuchos::RCP<Teuchos::ParameterList> paramsFromProblem,
00039 Albany::StateManager& stateMgr)
00040 {
00041 using Teuchos::RCP;
00042 using Teuchos::rcp;
00043 using Teuchos::ParameterList;
00044 using PHX::DataLayout;
00045
00046 std::string responseName = responseParams.get<std::string>("Name");
00047 RCP<ParameterList> p = rcp(new ParameterList);
00048 p->set<ParameterList*>("Parameter List", &responseParams);
00049 p->set<RCP<ParameterList> >("Parameters From Problem", paramsFromProblem);
00050 Teuchos::RCP<const PHX::FieldTag> response_tag;
00051
00052 if (responseName == "Field Integral")
00053 {
00054 RCP<QCAD::ResponseFieldIntegral<EvalT,Traits> > res_ev =
00055 rcp(new QCAD::ResponseFieldIntegral<EvalT,Traits>(*p, dl));
00056 fm.template registerEvaluator<EvalT>(res_ev);
00057 response_tag = res_ev->getResponseFieldTag();
00058 fm.requireField<EvalT>(*(res_ev->getEvaluatedFieldTag()));
00059 }
00060
00061 else if (responseName == "Field Value")
00062 {
00063 RCP<QCAD::ResponseFieldValue<EvalT,Traits> > res_ev =
00064 rcp(new QCAD::ResponseFieldValue<EvalT,Traits>(*p,dl));
00065 fm.template registerEvaluator<EvalT>(res_ev);
00066 response_tag = res_ev->getResponseFieldTag();
00067 fm.requireField<EvalT>(*(res_ev->getEvaluatedFieldTag()));
00068 }
00069
00070 else if (responseName == "Field Average")
00071 {
00072 RCP<QCAD::ResponseFieldAverage<EvalT,Traits> > res_ev =
00073 rcp(new QCAD::ResponseFieldAverage<EvalT,Traits>(*p,dl));
00074 fm.template registerEvaluator<EvalT>(res_ev);
00075 response_tag = res_ev->getResponseFieldTag();
00076 fm.requireField<EvalT>(*(res_ev->getEvaluatedFieldTag()));
00077 }
00078
00079 else if (responseName == "Surface Velocity Mismatch")
00080 {
00081 RCP<FELIX::ResponseSurfaceVelocityMismatch<EvalT,Traits> > res_ev =
00082 rcp(new FELIX::ResponseSurfaceVelocityMismatch<EvalT,Traits>(*p,dl));
00083 fm.template registerEvaluator<EvalT>(res_ev);
00084 response_tag = res_ev->getResponseFieldTag();
00085 fm.requireField<EvalT>(*(res_ev->getEvaluatedFieldTag()));
00086 }
00087
00088 else if (responseName == "Center Of Mass")
00089 {
00090 RCP<QCAD::ResponseCenterOfMass<EvalT,Traits> > res_ev =
00091 rcp(new QCAD::ResponseCenterOfMass<EvalT,Traits>(*p, dl));
00092 fm.template registerEvaluator<EvalT>(res_ev);
00093 response_tag = res_ev->getResponseFieldTag();
00094 fm.requireField<EvalT>(*(res_ev->getEvaluatedFieldTag()));
00095 }
00096
00097 else if (responseName == "Save Field")
00098 {
00099 p->set< Albany::StateManager* >("State Manager Ptr", &stateMgr );
00100 RCP<QCAD::ResponseSaveField<EvalT,Traits> > res_ev =
00101 rcp(new QCAD::ResponseSaveField<EvalT,Traits>(*p, dl));
00102 fm.template registerEvaluator<EvalT>(res_ev);
00103 response_tag = res_ev->getResponseFieldTag();
00104 fm.requireField<EvalT>(*(res_ev->getEvaluatedFieldTag()));
00105 }
00106 #ifdef ALBANY_QCAD
00107 else if (responseName == "Saddle Value")
00108 {
00109 p->set< RCP<DataLayout> >("Dummy Data Layout", dl->dummy);
00110 p->set<std::string>("Coordinate Vector Name", "Coord Vec");
00111 p->set<std::string>("Weights Name", "Weights");
00112 RCP<QCAD::ResponseSaddleValue<EvalT,Traits> > res_ev =
00113 rcp(new QCAD::ResponseSaddleValue<EvalT,Traits>(*p, dl));
00114 fm.template registerEvaluator<EvalT>(res_ev);
00115 response_tag = res_ev->getResponseFieldTag();
00116 fm.requireField<EvalT>(*(res_ev->getEvaluatedFieldTag()));
00117 }
00118
00119 else if (responseName == "Region Boundary")
00120 {
00121 RCP<QCAD::ResponseRegionBoundary<EvalT,Traits> > res_ev =
00122 rcp(new QCAD::ResponseRegionBoundary<EvalT,Traits>(*p, dl));
00123 fm.template registerEvaluator<EvalT>(res_ev);
00124 response_tag = res_ev->getResponseFieldTag();
00125 fm.requireField<EvalT>(*(res_ev->getEvaluatedFieldTag()));
00126 }
00127 #endif
00128
00129 else if (responseName == "PHAL Field Integral")
00130 {
00131 RCP<PHAL::ResponseFieldIntegral<EvalT,Traits> > res_ev =
00132 rcp(new PHAL::ResponseFieldIntegral<EvalT,Traits>(*p, dl));
00133 fm.template registerEvaluator<EvalT>(res_ev);
00134 response_tag = res_ev->getResponseFieldTag();
00135 fm.requireField<EvalT>(*(res_ev->getEvaluatedFieldTag()));
00136 }
00137
00138 else if (responseName == "Element Size Field")
00139 {
00140 p->set< Albany::StateManager* >("State Manager Ptr", &stateMgr );
00141 p->set< RCP<DataLayout> >("Dummy Data Layout", dl->dummy);
00142 p->set<std::string>("Coordinate Vector Name", "Coord Vec");
00143 p->set<std::string>("Weights Name", "Weights");
00144 RCP<Adapt::ElementSizeField<EvalT,Traits> > res_ev =
00145 rcp(new Adapt::ElementSizeField<EvalT,Traits>(*p, dl));
00146 fm.template registerEvaluator<EvalT>(res_ev);
00147 response_tag = res_ev->getResponseFieldTag();
00148 fm.requireField<EvalT>(*(res_ev->getEvaluatedFieldTag()));
00149 }
00150
00151 else if (responseName == "Save Nodal Fields")
00152 {
00153 p->set< Albany::StateManager* >("State Manager Ptr", &stateMgr );
00154 RCP<PHAL::SaveNodalField<EvalT,Traits> > res_ev =
00155 rcp(new PHAL::SaveNodalField<EvalT,Traits>(*p, dl));
00156 fm.template registerEvaluator<EvalT>(res_ev);
00157 response_tag = res_ev->getResponseFieldTag();
00158 fm.requireField<EvalT>(*(res_ev->getEvaluatedFieldTag()));
00159 }
00160
00161 #ifdef ALBANY_LCM
00162 else if (responseName == "IP to Nodal Field")
00163 {
00164 p->set< Albany::StateManager* >("State Manager Ptr", &stateMgr );
00165 p->set< RCP<DataLayout> >("Dummy Data Layout", dl->dummy);
00166
00167
00168 RCP<LCM::IPtoNodalField<EvalT,Traits> > res_ev =
00169 rcp(new LCM::IPtoNodalField<EvalT,Traits>(*p, dl));
00170 fm.template registerEvaluator<EvalT>(res_ev);
00171 response_tag = res_ev->getResponseFieldTag();
00172 fm.requireField<EvalT>(*(res_ev->getEvaluatedFieldTag()));
00173 }
00174 #endif
00175
00176 else
00177 TEUCHOS_TEST_FOR_EXCEPTION(
00178 true, Teuchos::Exceptions::InvalidParameter,
00179 std::endl << "Error! Unknown response function " << responseName <<
00180 "!" << std::endl << "Supplied parameter list is " <<
00181 std::endl << responseParams);
00182
00183 return response_tag;
00184
00185 }