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
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 #include "LOCA_Pitchfork_MinimallyAugmented_Constraint.H"
00043 #include "LOCA_Pitchfork_MinimallyAugmented_AbstractGroup.H"
00044 #include "LOCA_BorderedSolver_AbstractStrategy.H"
00045 #include "LOCA_Parameter_SublistParser.H"
00046 #include "LOCA_GlobalData.H"
00047 #include "LOCA_ErrorCheck.H"
00048 #include "LOCA_Factory.H"
00049 #include "NOX_Utils.H"
00050 #include "Teuchos_ParameterList.hpp"
00051
00052 LOCA::Pitchfork::MinimallyAugmented::Constraint::
00053 Constraint(
00054 const Teuchos::RCP<LOCA::GlobalData>& global_data,
00055 const Teuchos::RCP<LOCA::Parameter::SublistParser>& topParams,
00056 const Teuchos::RCP<Teuchos::ParameterList>& pfParams,
00057 const Teuchos::RCP<LOCA::Pitchfork::MinimallyAugmented::AbstractGroup>& g,
00058 bool is_symmetric,
00059 const NOX::Abstract::Vector& a,
00060 const NOX::Abstract::Vector* b,
00061 const Teuchos::RCP<const NOX::Abstract::Vector>& psi,
00062 int bif_param) :
00063 LOCA::TurningPoint::MinimallyAugmented::Constraint(global_data, topParams,
00064 pfParams, g, is_symmetric,
00065 a, b, bif_param),
00066 pf_grp(g),
00067 psi_vector(psi),
00068 dgdx(psi->createMultiVector(2, NOX::ShapeCopy)),
00069 pf_constraints(2, 1)
00070 {
00071 }
00072
00073 LOCA::Pitchfork::MinimallyAugmented::Constraint::
00074 Constraint(const LOCA::Pitchfork::MinimallyAugmented::Constraint& source,
00075 NOX::CopyType type) :
00076 LOCA::TurningPoint::MinimallyAugmented::Constraint(source, type),
00077 pf_grp(Teuchos::null),
00078 psi_vector(source.psi_vector),
00079 dgdx(source.dgdx->clone(type)),
00080 pf_constraints(source.pf_constraints)
00081 {
00082
00083
00084 }
00085
00086 LOCA::Pitchfork::MinimallyAugmented::Constraint::
00087 ~Constraint()
00088 {
00089 }
00090
00091 void
00092 LOCA::Pitchfork::MinimallyAugmented::Constraint::
00093 setGroup(const Teuchos::RCP<LOCA::TurningPoint::MinimallyAugmented::AbstractGroup>& g)
00094 {
00095 LOCA::TurningPoint::MinimallyAugmented::Constraint::setGroup(g);
00096 pf_grp = Teuchos::rcp_dynamic_cast<LOCA::Pitchfork::MinimallyAugmented::AbstractGroup>(g,true);
00097 }
00098
00099 void
00100 LOCA::Pitchfork::MinimallyAugmented::Constraint::
00101 copy(const LOCA::MultiContinuation::ConstraintInterface& src)
00102 {
00103 const LOCA::Pitchfork::MinimallyAugmented::Constraint& source =
00104 dynamic_cast<const LOCA::Pitchfork::MinimallyAugmented::Constraint&>(src);
00105
00106 if (this != &source) {
00107 LOCA::TurningPoint::MinimallyAugmented::Constraint::copy(src);
00108 psi_vector = source.psi_vector;
00109 *dgdx = *source.dgdx;
00110 pf_constraints.assign(source.pf_constraints);
00111
00112
00113
00114 }
00115 }
00116
00117 Teuchos::RCP<LOCA::MultiContinuation::ConstraintInterface>
00118 LOCA::Pitchfork::MinimallyAugmented::Constraint::
00119 clone(NOX::CopyType type) const
00120 {
00121 return Teuchos::rcp(new Constraint(*this, type));
00122 }
00123
00124 int
00125 LOCA::Pitchfork::MinimallyAugmented::Constraint::
00126 numConstraints() const
00127 {
00128 return 2;
00129 }
00130
00131 NOX::Abstract::Group::ReturnType
00132 LOCA::Pitchfork::MinimallyAugmented::Constraint::
00133 computeConstraints()
00134 {
00135 if (isValidConstraints)
00136 return NOX::Abstract::Group::Ok;
00137
00138
00139 NOX::Abstract::Group::ReturnType status =
00140 LOCA::TurningPoint::MinimallyAugmented::Constraint::computeConstraints();
00141 pf_constraints(0,0) = constraints(0,0);
00142
00143
00144
00145 pf_constraints(1,0) = pf_grp->innerProduct(*psi_vector, pf_grp->getX());
00146
00147 return status;
00148 }
00149
00150 NOX::Abstract::Group::ReturnType
00151 LOCA::Pitchfork::MinimallyAugmented::Constraint::
00152 computeDX()
00153 {
00154 if (isValidDX)
00155 return NOX::Abstract::Group::Ok;
00156
00157
00158 NOX::Abstract::Group::ReturnType status =
00159 LOCA::TurningPoint::MinimallyAugmented::Constraint::computeDX();
00160 (*dgdx)[0] = (*sigma_x)[0];
00161
00162
00163 (*dgdx)[1] = *psi_vector;
00164
00165 return status;
00166 }
00167
00168 NOX::Abstract::Group::ReturnType
00169 LOCA::Pitchfork::MinimallyAugmented::Constraint::
00170 computeDP(const vector<int>& paramIDs,
00171 NOX::Abstract::MultiVector::DenseMatrix& dgdp,
00172 bool isValidG)
00173 {
00174
00175 NOX::Abstract::MultiVector::DenseMatrix dgdp_sub(Teuchos::View, dgdp, 1,
00176 paramIDs.size()+1, 0, 0);
00177 NOX::Abstract::Group::ReturnType status =
00178 LOCA::TurningPoint::MinimallyAugmented::Constraint::computeDP(paramIDs,
00179 dgdp_sub,
00180 isValidG);
00181
00182
00183 if (!isValidG)
00184 dgdp(1,0) = pf_grp->innerProduct(*psi_vector, pf_grp->getX());
00185 for (unsigned int i=0; i<paramIDs.size(); i++)
00186 dgdp(1,i+1) = 0.0;
00187
00188 return status;
00189 }
00190
00191 const NOX::Abstract::MultiVector::DenseMatrix&
00192 LOCA::Pitchfork::MinimallyAugmented::Constraint::
00193 getConstraints() const
00194 {
00195 return pf_constraints;
00196 }
00197
00198 const NOX::Abstract::MultiVector*
00199 LOCA::Pitchfork::MinimallyAugmented::Constraint::
00200 getDX() const
00201 {
00202 return dgdx.get();
00203 }