00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <sstream>
00033
00034 template <typename ScalarT>
00035 FEApp::ConstantNodeBCStrategy<ScalarT>::
00036 ConstantNodeBCStrategy(
00037 unsigned int solution_index,
00038 unsigned int residual_index,
00039 const ScalarT& value,
00040 unsigned int bc_id,
00041 const Teuchos::RCP<Sacado::ScalarParameterLibrary>& paramLib) :
00042 sol_index(solution_index),
00043 res_index(residual_index),
00044 val(value),
00045 offsets(1)
00046 {
00047 offsets[0] = residual_index;
00048
00049
00050 std::stringstream ss;
00051 ss << "Constant Node BC " << bc_id;
00052 std::string name = ss.str();
00053 if (!paramLib->isParameter(name))
00054 paramLib->addParameterFamily(name, true, false);
00055 if (!paramLib->template isParameterForType<ScalarT>(name)) {
00056 Teuchos::RCP< ConstantNodeBCParameter<ScalarT> > tmp =
00057 Teuchos::rcp(new ConstantNodeBCParameter<ScalarT>(Teuchos::rcp(this,false)));
00058 paramLib->template addEntry<ScalarT>(name, tmp);
00059 }
00060 }
00061
00062 template <typename ScalarT>
00063 FEApp::ConstantNodeBCStrategy<ScalarT>::
00064 ~ConstantNodeBCStrategy()
00065 {
00066 }
00067
00068 template <typename ScalarT>
00069 const std::vector<unsigned int>&
00070 FEApp::ConstantNodeBCStrategy<ScalarT>::
00071 getOffsets() const
00072 {
00073 return offsets;
00074 }
00075
00076 template <typename ScalarT>
00077 void
00078 FEApp::ConstantNodeBCStrategy<ScalarT>::
00079 evaluateResidual(const std::vector<ScalarT>* dot,
00080 const std::vector<ScalarT>& solution,
00081 std::vector<ScalarT>& residual) const
00082 {
00083 residual[res_index] = solution[sol_index] - val;
00084 }
00085
00086 template <typename ScalarT>
00087 void
00088 FEApp::ConstantNodeBCStrategy<ScalarT>::
00089 setValue(const ScalarT& value, bool mark_constant)
00090 {
00091 val = value;
00092 if (mark_constant)
00093 Sacado::MarkConstant<ScalarT>::eval(val);
00094 }
00095
00096 template <typename ScalarT>
00097 const ScalarT&
00098 FEApp::ConstantNodeBCStrategy<ScalarT>::
00099 getValue() const
00100 {
00101 return val;
00102 }