Back to index

salome-kernel  6.5.0
CalciumCouplingPolicy.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //  File   : CalciumCouplingPolicy.cxx
00024 //  Author : Eric Fayolle (EDF)
00025 //  Module : KERNEL
00026 // Id          : $Id: CalciumCouplingPolicy.cxx,v 1.3.2.3.10.2.12.1 2012-04-12 14:05:06 vsr Exp $
00027 //
00028 #include "CalciumCouplingPolicy.hxx"
00029 
00030 CalciumCouplingPolicy::CalciumCouplingPolicy():_dependencyType(CalciumTypes::UNDEFINED_DEPENDENCY),
00031                                                _storageLevel(CalciumTypes::UNLIMITED_STORAGE_LEVEL),
00032                                                _dateCalSchem(CalciumTypes::TI_SCHEM),
00033                                                _interpolationSchem(CalciumTypes::L1_SCHEM),
00034                                                _extrapolationSchem(CalciumTypes::UNDEFINED_EXTRA_SCHEM),
00035                                                _alpha(0.0),_deltaT(CalciumTypes::EPSILON),
00036                                                _disconnectDirective(CalciumTypes::UNDEFINED_DIRECTIVE){};
00037 
00038 void CalciumCouplingPolicy::setDependencyType (CalciumTypes::DependencyType dependencyType) {_dependencyType=dependencyType;}
00039 CalciumTypes::DependencyType CalciumCouplingPolicy::getDependencyType () const              { return _dependencyType;}
00040  
00041 void   CalciumCouplingPolicy::setStorageLevel   (size_t         storageLevel)   {
00042   MESSAGE( "CalciumCouplingPolicy::setStorageLevel: " << storageLevel );
00043   if ( storageLevel < 1 && (storageLevel != CalciumTypes::UNLIMITED_STORAGE_LEVEL)  )
00044     throw CalciumException(CalciumTypes::CPRENA,LOC("StorageLevel < 1 is not allowed"));
00045   _storageLevel = storageLevel;
00046 }
00047 size_t CalciumCouplingPolicy::getStorageLevel   () const                        {return _storageLevel;}
00048 void   CalciumCouplingPolicy::setDateCalSchem   (CalciumTypes::DateCalSchem   dateCalSchem)   {
00049   MESSAGE( "CalciumCouplingPolicy::setDateCalSchem: " << dateCalSchem );
00050   if ( _dependencyType != CalciumTypes::TIME_DEPENDENCY )
00051     throw CalciumException(CalciumTypes::CPITVR,LOC("Can't set a temporal scheme on a port that is not time dependent"));
00052   _dateCalSchem = dateCalSchem;
00053 }
00054 
00055 CalciumTypes::DateCalSchem CalciumCouplingPolicy::getDateCalSchem () const   { return _dateCalSchem; }
00056 
00057 void CalciumCouplingPolicy::setAlpha(double alpha) {
00058   MESSAGE( "CalciumCouplingPolicy::setAlpha: " << alpha );
00059   if ( _dependencyType != CalciumTypes::TIME_DEPENDENCY )
00060     throw CalciumException(CalciumTypes::CPITVR,LOC("Can't set alpha on a port that is not time dependent"));
00061   
00062   if ( 0 <= alpha && alpha <= 1 ) _alpha = alpha; 
00063   else 
00064     throw CalciumException(CalciumTypes::CPRENA,LOC("alpha must be between [0,1]"));
00065 }
00066 
00067 double CalciumCouplingPolicy::getAlpha() const   { return _alpha; }
00068 
00069 void CalciumCouplingPolicy::setDeltaT(double deltaT ) {
00070   if ( _dependencyType != CalciumTypes::TIME_DEPENDENCY )
00071     throw CalciumException(CalciumTypes::CPITVR,LOC("Can't set deltaT on a port that is not time dependent"));
00072   if ( 0 <= deltaT && deltaT <= 1 ) _deltaT = deltaT; 
00073   else 
00074     throw(CalciumException(CalciumTypes::CPRENA,LOC("deltaT must be between [0,1]")));
00075 }
00076 double CalciumCouplingPolicy::getDeltaT() const  {return _deltaT;}
00077 
00078 void CalciumCouplingPolicy::setInterpolationSchem (CalciumTypes::InterpolationSchem interpolationSchem) {
00079   MESSAGE( "CalciumCouplingPolicy::setInterpolationSchem: " << interpolationSchem );
00080   if ( _dependencyType != CalciumTypes::TIME_DEPENDENCY )
00081     throw CalciumException(CalciumTypes::CPITVR,LOC("Can't set InterpolationSchem on a port that is not time dependent"));
00082   _interpolationSchem=interpolationSchem;
00083 }
00084 
00085 void CalciumCouplingPolicy::setExtrapolationSchem (CalciumTypes::ExtrapolationSchem extrapolationSchem) {
00086   if ( _dependencyType != CalciumTypes::TIME_DEPENDENCY )
00087     throw CalciumException(CalciumTypes::CPITVR,LOC("Can't set ExtrapolationSchem on a port that is not time dependent"));
00088 _extrapolationSchem=extrapolationSchem;
00089 }
00090 
00091 CalciumTypes::InterpolationSchem CalciumCouplingPolicy::getInterpolationSchem () const { return _interpolationSchem; };
00092 CalciumTypes::ExtrapolationSchem CalciumCouplingPolicy::getExtrapolationSchem () const { return _extrapolationSchem; };
00093 
00094 
00095 CalciumCouplingPolicy::TimeType 
00096 CalciumCouplingPolicy::getEffectiveTime(CalciumCouplingPolicy::TimeType ti, 
00097                                         CalciumCouplingPolicy::TimeType tf) {
00098   if ( _dateCalSchem == CalciumTypes::TI_SCHEM )  return ti;
00099   if ( _dateCalSchem == CalciumTypes::TF_SCHEM )  return tf;
00100   
00101   //CalciumTypes::ALPHA_SCHEM
00102   return tf*_alpha + ti*(1-_alpha);
00103 }
00104 
00105 void CalciumCouplingPolicy::disconnect(bool provideLastGivenValue) {
00106 
00107   if (provideLastGivenValue) {
00108 #ifdef MYDEBUG
00109     std::cout << "-------- CalciumCouplingPolicy::disconnect CP_CONT  ------------------" << std::endl;
00110 #endif
00111     _disconnectDirective = CalciumTypes::CONTINUE;
00112   } else {
00113 #ifdef MYDEBUG
00114     std::cout << "-------- CalciumCouplingPolicy::disconnect CP_ARRET  ------------------" << std::endl;
00115 #endif
00116     _disconnectDirective = CalciumTypes::STOP;
00117   }
00118 
00119   //Wakeup get data if any
00120   wakeupWaiting();  
00121 }