initial.cpp

来自「不错的国外的有限元程序代码,附带详细的manual,可以节省很多的底层工作.」· C++ 代码 · 共 57 行

CPP
57
字号
//   file INITIAL.CXX
 
#include "initial.hxx"
#include <stdlib.h>


double  InitialCondition :: give (char u)
   // Returns the value of the prescribed value of the kinematic unknown 'u'.
{
   if (this -> hasConditionOn(u))
      return  initialValueDictionary -> at(u) ;
   else
      return  0. ;
}


int  InitialCondition :: hasConditionOn (char u) 
   // Returns True if the receiver submits the unknown 'u' to an initial
   // condition, else returns False.
{
   if (initialValueDictionary == NULL)
      this -> readConditions() ;
   return  (initialValueDictionary->includes(u)) ;
}


void  InitialCondition :: printYourself ()
   // Prints the receiver on screen.
{
   printf ("Initial condition %d\ninitial values :\n",number) ;
   if (initialValueDictionary)
      initialValueDictionary -> printYourself() ;
   else
      printf ("   NULL\n") ;
}


void  InitialCondition :: readConditions ()
   // Sets up the dictionary where the receiver stores the conditions it
   // imposes.
{
   char   key [1] ;
   double value ;
   int    nCond,i,j ;

   initialValueDictionary = new Dictionary() ;
   i     = 0 ;
   nCond = this->readInteger("conditions",++i) ;

   for (j=1 ; j<=nCond ; j++) {
      this -> readString("conditions",++i,key) ;
      value = this->read("conditions",++i) ;
      initialValueDictionary -> add(key[0],value) ;}
}


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?