diff --git a/src/SIM/NonLinSIM.C b/src/SIM/NonLinSIM.C index b47b4e60..052f22e1 100644 --- a/src/SIM/NonLinSIM.C +++ b/src/SIM/NonLinSIM.C @@ -90,7 +90,7 @@ bool NonLinSIM::parse (char* keyWord, std::istream& is) } -void NonLinSIM::init (SolvePrm& param) +void NonLinSIM::init (SolvePrm& param, const Vector& initVal) { param.startTime = startTime; param.stopTime = stopTime; @@ -103,12 +103,15 @@ void NonLinSIM::init (SolvePrm& param) param.divgLim = divgLim; param.eta = eta; - // TODO perhaps set initial conditions for time-dependent problems here size_t nSols = model->getNoSolutions(); if (nSols < 2) nSols = 2; solution.resize(nSols); for (size_t n = 0; n < nSols; n++) solution[n].resize(model->getNoDOFs(),true); + + // Set initial conditions for time-dependent problems + if (initVal.size() == model->getNoDOFs()) + solution.front() = initVal; } diff --git a/src/SIM/NonLinSIM.h b/src/SIM/NonLinSIM.h index 6b71f4dc..f102ead8 100644 --- a/src/SIM/NonLinSIM.h +++ b/src/SIM/NonLinSIM.h @@ -55,7 +55,9 @@ public: }; //! \brief Initializes the solution parameters with values read from file. - virtual void init(SolvePrm& param); + //! \param param Solution algorithm parameters + //! \param[in] initVal Initial values of the primary solution + virtual void init(SolvePrm& param, const Vector& initVal = Vector()); //! \brief Advances the time/load step one step forward. virtual bool advanceStep(SolvePrm& param); @@ -65,6 +67,10 @@ public: //! \param[in] nViz Number of visualization points over a knot-span bool saveModel(char* fileName, int format, int* nViz); + //! \brief Sets the initial guess in the Newton-Raphson iterations. + //! \param value The initial guess to use + void setInitialGuess(const Vector& value) { solution.front() = value; } + //! \brief Solves the nonlinear equations by Newton-Raphson iterations. //! \param param Solution algorithm parameters //! \param[in] mode Solution mode to use for this step @@ -98,6 +104,9 @@ public: void dumpStep(int iStep, double time, std::ostream& os, bool withID = true) const; + //! \brief Returns a const reference to current solution vector. + const Vector& getSolution() const { return solution.front(); } + protected: //! \brief Convergence status enum. enum ConvStatus { NONE, CONVERGED, DIVERGED }; diff --git a/src/SIM/SIMbase.C b/src/SIM/SIMbase.C index dfd40866..b3c65c1c 100644 --- a/src/SIM/SIMbase.C +++ b/src/SIM/SIMbase.C @@ -602,7 +602,9 @@ bool SIMbase::solutionNorms (const TimeDomain& time, const Vectors& psol, NormBase* norm = myProblem->getNormIntegrand(mySol); if (!norm) { +#ifdef SP_DEBUG std::cerr <<" *** SIMbase::solutionNorms: No integrand."<< std::endl; +#endif return false; }