refactor: move common problem parameters out of NonLinSIM to a class for reuse in other SIMclasses.

git-svn-id: http://svn.sintef.no/trondheim/IFEM/trunk@802 e10b68d5-8a6e-419e-a041-bce267b0401d
This commit is contained in:
akva 2011-02-17 11:02:52 +00:00 committed by Knut Morten Okstad
parent c2a225f2d1
commit 9333737c50
5 changed files with 109 additions and 56 deletions

View File

@ -18,7 +18,7 @@
FSRC = Eig/eig_drv1.f Eig/eig_drv2.f Eig/eig_drv3.f \
Eig/eig_drv4.f Eig/eig_drv5.f Eig/eig_drv6.f
CSRC = SIM/SIMinput.C SIM/SIMbase.C SIM/SIM3D.C SIM/SIM2D.C SIM/SIM1D.C \
SIM/NonLinSIM.C ASM/Lagrange.C \
SIM/NonLinSIM.C SIM/SIMparameters.C ASM/Lagrange.C \
ASM/AlgEqSystem.C ASM/ASMbase.C ASM/ASMmxBase.C ASM/ASMstruct.C \
ASM/ASMs3D.C ASM/ASMs3DLag.C ASM/ASMs3DSpec.C \
ASM/ASMs3Dmx.C ASM/ASMs3DmxLag.C \

View File

@ -124,38 +124,6 @@ bool NonLinSIM::advanceStep (SolvePrm& param)
}
bool NonLinSIM::SolvePrm::multiSteps () const
{
if (tInc.empty()) return false;
const double epsT = 1.0e-6;
return (startTime+(1.0+epsT)*tInc.front() < stopTime);
}
bool NonLinSIM::SolvePrm::increment ()
{
const double epsT = 1.0e-6;
if (++step <= (int)tInc.size())
time.dt = tInc[step-1];
if (time.t+time.dt*epsT >= stopTime)
return false;
time.t += time.dt;
if (time.t > stopTime)
{
// Adjust the size of the last time step
time.dt += stopTime - time.t;
time.t = stopTime;
}
return true;
}
bool NonLinSIM::solveStep (SolvePrm& param, SIM::SolutionMode mode)
{
PROFILE1("NonLinSIM::solveStep");

View File

@ -18,6 +18,7 @@
#include "SIMenums.h"
#include "TimeDomain.h"
#include "MatVec.h"
#include "SIMparameters.h"
class SIMbase;
@ -39,31 +40,23 @@ public:
virtual ~NonLinSIM();
/*!
\brief A struct for nonlinear solution parameters.
\brief A class for nonlinear solution parameters.
*/
struct SolvePrm
{
int step; //!< Load/time step counter
int& iter; //!< Iteration counter
int maxit; //!< Maximum number of iterations
int nupdat; //!< Number of iterations with updated tangent
double startTime; //!< Start (pseudo)time of simulation
double stopTime; //!< Stop (pseudo)time of simulation
RealArray tInc; //!< Time (or pseudo time) increment size(s)
double convTol; //!< Relative convergence tolerance
double divgLim; //!< Relative divergence limit
double refNorm; //!< Reference energy norm used in convergence checks
double alpha; //!< Iteration acceleration parameter (line search)
double eta; //!< Line searce tolerance
TimeDomain time; //!< Time domain data
//! \brief The constructor initializes the counters to zero.
SolvePrm() : iter(time.it) { step = maxit = 0; refNorm = alpha = 1.0; }
//! \brief Returns \e true if the simulation consists of several load steps.
bool multiSteps() const;
//! \brief Increments the time/load step.
//! \return \e true, if we have reached the end of the simulation.
bool increment();
class SolvePrm : public SIMparameters
{
public:
int maxit; //!< Maximum number of iterations
int nupdat; //!< Number of iterations with updated tangent
double convTol; //!< Relative convergence tolerance
double divgLim; //!< Relative divergence limit
double refNorm; //!< Reference energy norm used in convergence checks
double alpha; //!< Iteration acceleration parameter (line search)
double eta; //!< Line searce tolerance
SolvePrm()
{
refNorm = alpha = 1;
}
};
//! \brief Initializes solution parameters object with values read from file.

49
src/SIM/SIMparameters.C Normal file
View File

@ -0,0 +1,49 @@
//==============================================================================
//!
//! \file SIMparameters.C
//!
//! \date Feb 11 2011
//!
//! \author Arne Morten Kvarving / SINTEF
//!
//! \brief Class for encapsulation generic simulation parameters.
//!
//==============================================================================
#include "SIMparameters.h"
SIMparameters::SIMparameters() :
iter(time.it), step(0)
{
}
bool SIMparameters::multiSteps () const
{
if (tInc.empty()) return false;
const double epsT = 1.0e-6;
return (startTime+(1.0+epsT)*tInc.front() < stopTime);
}
bool SIMparameters::increment ()
{
const double epsT = 1.0e-6;
if (++step <= (int)tInc.size())
time.dt = tInc[step-1];
if (time.t+time.dt*epsT >= stopTime)
return false;
time.t += time.dt;
if (time.t > stopTime)
{
// Adjust the size of the last time step
time.dt += stopTime - time.t;
time.t = stopTime;
}
return true;
}

43
src/SIM/SIMparameters.h Normal file
View File

@ -0,0 +1,43 @@
//==============================================================================
//!
//! \file SIMparameters.h
//!
//! \date Feb 11 2011
//!
//! \author Arne Morten Kvarving / SINTEF
//!
//! \brief Class for encapsulation generic simulation parameters.
//!
//==============================================================================
#ifndef SIMPARAMETERS_H_
#define SIMPARAMETERS_H_
#include "MatVec.h"
#include "TimeDomain.h"
class SIMparameters {
public:
//! \brief The constructor initializes the counters to zero.
SIMparameters();
//! \brief Empty destructor
virtual ~SIMparameters() {};
//! \brief Returns \e true if the simulation consists of several load steps.
bool multiSteps() const;
//! \brief Increments the time/load step.
//! \return \e true, if we have reached the end of the simulation.
bool increment();
int step; //!< Load/time step counter
int& iter; //!< Iteration counter
double startTime; //!< Start (pseudo)time of simulation
double stopTime; //!< Stop (pseudo)time of simulation
RealArray tInc; //!< Time (or pseudo time) increment size(s)
TimeDomain time; //!< Time domain data
};
#endif // SIMPARAMETERS_H_