timestep.cpp
来自「不错的国外的有限元程序代码,附带详细的manual,可以节省很多的底层工作.」· C++ 代码 · 共 70 行
CPP
70 行
// file TIMESTEP.CXX
#include "timestep.hxx"
#include "domain.hxx"
#include "timinteg.hxx"
#include <stdio.h>
TimeStep :: TimeStep (int n, TimeIntegrationScheme* s)
: FEMComponent(n,s->giveDomain())
// Constructor. Creates a new time step, with number n, and belonging to
// the time history of s. Used for the initial step (0 or 1).
{
scheme = s ;
newLhs = UNKNOWN ;
if (n >= 1) {
deltaT = read("dt") ;
t = deltaT ;}
else { // case of a starting step (0)
deltaT = 0. ;
t = 0. ;}
}
TimeStep :: TimeStep (TimeIntegrationScheme* s, TimeStep* stepN)
: FEMComponent(stepN->giveNumber()+1,s->giveDomain())
// Standard constructor. Creates a new step n+1, following stepN, and
// belonging to the time history of s.
{
scheme = s ;
newLhs = UNKNOWN ;
deltaT = this -> read("dt") ;
t = stepN->giveTime() + deltaT ;
}
TimeStep* TimeStep :: givePreviousStep ()
// Not accepted in-line.
{
return scheme->givePreviousStep() ;
}
int TimeStep :: isNotTheLastStep ()
// Returns True if the time history contains steps after the receiver,
// else returns False.
{
return (number != scheme->giveNumberOfSteps()) ;
}
int TimeStep :: isTheCurrentTimeStep ()
// Not accepted in-line.
{
return this==scheme->giveCurrentStep() ;
}
int TimeStep :: requiresNewLhs ()
// Returns True if the linear system's LHS must be recomputed, else
// returns False.
{
if (newLhs == UNKNOWN)
newLhs = domain->giveTimeIntegrationScheme()->requiresNewLhsAt(this) ;
return newLhs ;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?