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 #ifndef FEAPP_CONSTANTNODEBCSTRATEGY_HPP
00033 #define FEAPP_CONSTANTNODEBCSTRATEGY_HPP
00034
00035 #include "FEApp_AbstractNodeBCStrategy.hpp"
00036 #include "Sacado_ScalarParameterLibrary.hpp"
00037
00038 namespace FEApp {
00039
00040 template <typename ScalarT>
00041 class ConstantNodeBCStrategy :
00042 public FEApp::AbstractNodeBCStrategy<ScalarT> {
00043 public:
00044
00046 ConstantNodeBCStrategy(
00047 unsigned int solution_index,
00048 unsigned int residual_index,
00049 const ScalarT& value,
00050 unsigned int bc_id,
00051 const Teuchos::RCP<Sacado::ScalarParameterLibrary>& paramLib);
00052
00054 virtual ~ConstantNodeBCStrategy();
00055
00057 const std::vector<unsigned int>& getOffsets() const;
00058
00060 virtual void evaluateResidual(const std::vector<ScalarT>* dot,
00061 const std::vector<ScalarT>& solution,
00062 std::vector<ScalarT>& residual) const;
00063
00065 void setValue(const ScalarT& value, bool mark_constant);
00066
00068 const ScalarT& getValue() const;
00069
00070 private:
00071
00073 ConstantNodeBCStrategy(const ConstantNodeBCStrategy&);
00074
00076 ConstantNodeBCStrategy& operator=(const ConstantNodeBCStrategy&);
00077
00078 protected:
00079
00081 unsigned int sol_index;
00082
00084 unsigned int res_index;
00085
00087 ScalarT val;
00088
00090 std::vector<unsigned int> offsets;
00091
00092 };
00093
00094 class ConstantNodeBCStrategy_TemplateBuilder {
00095 public:
00096 ConstantNodeBCStrategy_TemplateBuilder(
00097 unsigned int solution_index,
00098 unsigned int residual_index,
00099 double value,
00100 unsigned int bc_id,
00101 const Teuchos::RCP<Sacado::ScalarParameterLibrary>& paramLib) :
00102 sol_index(solution_index), res_index(residual_index), val(value),
00103 bcid(bc_id), pl(paramLib) {}
00104 template <typename T>
00105 Teuchos::RCP<FEApp::AbstractNodeBCStrategy_NTBase> build() const {
00106 return Teuchos::rcp( new ConstantNodeBCStrategy<T>(sol_index,
00107 res_index,
00108 val,
00109 bcid,
00110 pl));
00111 }
00112 protected:
00113 unsigned int sol_index;
00114 unsigned int res_index;
00115 double val;
00116 unsigned int bcid;
00117 Teuchos::RCP<Sacado::ScalarParameterLibrary> pl;
00118 };
00119
00124 template <typename ScalarT>
00125 class ConstantNodeBCParameter :
00126 public Sacado::ScalarParameterEntry<ScalarT> {
00127
00128 public:
00129
00131 ConstantNodeBCParameter(
00132 const Teuchos::RCP< ConstantNodeBCStrategy<ScalarT> >& s) :
00133 bc(s) {}
00134
00136 virtual ~ConstantNodeBCParameter() {}
00137
00139 virtual void setRealValue(double value) {
00140 setValueAsConstant(ScalarT(value)); }
00141
00143 virtual void setValueAsConstant(const ScalarT& value) {
00144 bc->setValue(value, true); }
00145
00147 virtual void setValueAsIndependent(const ScalarT& value) {
00148 bc->setValue(value, false); }
00149
00151 virtual const ScalarT& getValue() const { return bc->getValue(); }
00152
00153 protected:
00154
00156 Teuchos::RCP< ConstantNodeBCStrategy<ScalarT> > bc;
00157
00158 };
00159
00160 }
00161
00162
00163 #ifndef SACADO_ETI
00164 #include "FEApp_ConstantNodeBCStrategyImpl.hpp"
00165 #endif
00166
00167 #endif // FEAPP_CONSTANTNODEBCSTRATEGY_HPP