From f4846d509edbf20aa3f199d377a781a7f9f793b0 Mon Sep 17 00:00:00 2001 From: kmo Date: Tue, 7 May 2013 17:01:59 +0000 Subject: [PATCH] Changed: Moved nSol argument from NonLinSIM constructor to init method git-svn-id: http://svn.sintef.no/trondheim/IFEM/trunk@2364 e10b68d5-8a6e-419e-a041-bce267b0401d --- src/SIM/NonLinSIM.C | 37 +++++++++++++++---------------------- src/SIM/NonLinSIM.h | 25 ++++++++++++------------- 2 files changed, 27 insertions(+), 35 deletions(-) diff --git a/src/SIM/NonLinSIM.C b/src/SIM/NonLinSIM.C index 34d98c18..32f575e1 100644 --- a/src/SIM/NonLinSIM.C +++ b/src/SIM/NonLinSIM.C @@ -22,8 +22,7 @@ #include -NonLinSIM::NonLinSIM (SIMbase& sim, CNORM n, int nSols) - : model(sim), nSolutions(nSols), iteNorm(n) +NonLinSIM::NonLinSIM (SIMbase& sim, CNORM n) : model(sim), iteNorm(n) { #ifndef SP_DEBUG msgLevel = 1; // prints the convergence history only @@ -47,17 +46,11 @@ NonLinSIM::NonLinSIM (SIMbase& sim, CNORM n, int nSols) } -NonLinSIM::~NonLinSIM () -{ -} - - -bool NonLinSIM::read(const char* fileName) +bool NonLinSIM::read (const char* fileName) { model.opt = IFEM::getOptions(); - bool result = SIMinput::read(fileName); + bool result = this->SIMinput::read(fileName); IFEM::applyCommandLineOptions(model.opt); - return result; } @@ -133,13 +126,19 @@ const char** NonLinSIM::getPrioritizedTags () const } -void NonLinSIM::init (const RealArray& initVal) -{ - int nSols = model.getNoSolutions(); - if (nSols > nSolutions) nSolutions = nSols; - solution.resize(nSolutions); +void NonLinSIM::setOptions (SIMoptions& opt2) +{ + model.opt = opt = opt2; +} - for (int n = 0; n < nSolutions; n++) + +void NonLinSIM::init (size_t nSol, const RealArray& initVal) +{ + size_t nSols = model.getNoSolutions(); + if (nSols > nSol) nSol = nSols; + solution.resize(nSol); + + for (size_t n = 0; n < nSol; n++) solution[n].resize(model.getNoDOFs(),true); // Set initial conditions for time-dependent problems @@ -536,9 +535,3 @@ void NonLinSIM::dumpResults (double time, std::ostream& os, model.dumpResults(solution.front(),time,os,true,precision); model.dumpMoreResults(time,os,precision); } - - -void NonLinSIM::setOptions(SIMoptions& opt2) -{ - model.opt = opt = opt2; -} diff --git a/src/SIM/NonLinSIM.h b/src/SIM/NonLinSIM.h index b372c915..894b53dc 100644 --- a/src/SIM/NonLinSIM.h +++ b/src/SIM/NonLinSIM.h @@ -17,8 +17,6 @@ #include "SIMinput.h" #include "SIMenums.h" #include "MatVec.h" -#include "Property.h" -#include "Function.h" class SIMbase; class TimeStep; @@ -45,14 +43,14 @@ public: //! \brief The constructor initializes default solution parameters. //! \param sim Pointer to the spline FE model //! \param[in] n Which type of iteration norm to use in convergence checks - //! \param[in] nSols Number of timesteps stored - NonLinSIM(SIMbase& sim, CNORM n = ENERGY, int nSols = 2); - //! \brief The destructor frees the dynamically allocated FE model object. - virtual ~NonLinSIM(); + NonLinSIM(SIMbase& sim, CNORM n = ENERGY); + //! \brief Empty destructor. + virtual ~NonLinSIM() {} //! \brief Initializes the primary solution vectors. + //! \param[in] nSol Number of consequtive solutions stored //! \param[in] initVal Initial values of the primary solution - virtual void init(const RealArray& initVal = RealArray()); + virtual void init(size_t nSol = 2, const RealArray& initVal = RealArray()); //! \brief Sets the initial guess in the Newton-Raphson iterations. //! \param[in] value Initial values of the primary solution @@ -129,6 +127,7 @@ protected: public: //! \brief Reads model data from the specified input file \a *fileName. virtual bool read(const char* fileName); + //! \brief Parses a data section from an input stream. //! \param[in] keyWord Keyword of current data section to read //! \param is The file stream to read from @@ -141,14 +140,14 @@ public: //! \brief Returns a list of prioritized XML-tags. virtual const char** getPrioritizedTags() const; - //! \brief Wrapper used to handle hierarchy issues + //! \brief Wrapper used to handle hierarchy issues. virtual void setOptions(SIMoptions& opt2); + protected: - SIMbase& model; //!< The isogeometric FE model - Vectors solution; //!< Primary solution vectors of the last increments - Vector linsol; //!< Linear solution vector - Vector residual; //!< Residual force vector - int nSolutions; //!< Number of solution vectors + SIMbase& model; //!< The isogeometric FE model + Vectors solution; //!< Primary solution vectors of the last increments + Vector linsol; //!< Linear solution vector + Vector residual; //!< Residual force vector // Nonlinear solution algorithm parameters CNORM iteNorm; //!< The norm type used to measure the residual