1 // Copyright (C) 2007-2024 CEA, EDF, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : CalciumCouplingPolicy.cxx
24 // Author : Eric Fayolle (EDF)
28 #include "CalciumCouplingPolicy.hxx"
30 CalciumCouplingPolicy::CalciumCouplingPolicy():_dependencyType(CalciumTypes::UNDEFINED_DEPENDENCY),
31 _storageLevel(CalciumTypes::UNLIMITED_STORAGE_LEVEL),
32 _dateCalSchem(CalciumTypes::TI_SCHEM),
33 _interpolationSchem(CalciumTypes::L1_SCHEM),
34 _extrapolationSchem(CalciumTypes::UNDEFINED_EXTRA_SCHEM),
35 _alpha(0.0),_deltaT(CalciumTypes::EPSILON),
36 _disconnectDirective(CalciumTypes::UNDEFINED_DIRECTIVE){}
38 void CalciumCouplingPolicy::setDependencyType (CalciumTypes::DependencyType dependencyType) {_dependencyType=dependencyType;}
39 CalciumTypes::DependencyType CalciumCouplingPolicy::getDependencyType () const { return _dependencyType;}
41 void CalciumCouplingPolicy::setStorageLevel (size_t storageLevel) {
42 MESSAGE( "CalciumCouplingPolicy::setStorageLevel: " << storageLevel );
43 if ( storageLevel < 1 && (storageLevel != (size_t)CalciumTypes::UNLIMITED_STORAGE_LEVEL) )
44 throw CalciumException(CalciumTypes::CPRENA,LOC("StorageLevel < 1 is not allowed"));
45 _storageLevel = storageLevel;
47 size_t CalciumCouplingPolicy::getStorageLevel () const {return _storageLevel;}
48 void CalciumCouplingPolicy::setDateCalSchem (CalciumTypes::DateCalSchem dateCalSchem) {
49 MESSAGE( "CalciumCouplingPolicy::setDateCalSchem: " << dateCalSchem );
50 if ( _dependencyType != CalciumTypes::TIME_DEPENDENCY )
51 throw CalciumException(CalciumTypes::CPITVR,LOC("Can't set a temporal scheme on a port that is not time dependent"));
52 _dateCalSchem = dateCalSchem;
55 CalciumTypes::DateCalSchem CalciumCouplingPolicy::getDateCalSchem () const { return _dateCalSchem; }
57 void CalciumCouplingPolicy::setAlpha(double alpha) {
58 MESSAGE( "CalciumCouplingPolicy::setAlpha: " << alpha );
59 if ( _dependencyType != CalciumTypes::TIME_DEPENDENCY )
60 throw CalciumException(CalciumTypes::CPITVR,LOC("Can't set alpha on a port that is not time dependent"));
62 if ( 0 <= alpha && alpha <= 1 ) _alpha = alpha;
64 throw CalciumException(CalciumTypes::CPRENA,LOC("alpha must be between [0,1]"));
67 double CalciumCouplingPolicy::getAlpha() const { return _alpha; }
69 void CalciumCouplingPolicy::setDeltaT(double deltaT ) {
70 if ( _dependencyType != CalciumTypes::TIME_DEPENDENCY )
71 throw CalciumException(CalciumTypes::CPITVR,LOC("Can't set deltaT on a port that is not time dependent"));
72 if ( 0 <= deltaT && deltaT <= 1 ) _deltaT = deltaT;
74 throw(CalciumException(CalciumTypes::CPRENA,LOC("deltaT must be between [0,1]")));
76 double CalciumCouplingPolicy::getDeltaT() const {return _deltaT;}
78 void CalciumCouplingPolicy::setInterpolationSchem (CalciumTypes::InterpolationSchem interpolationSchem) {
79 MESSAGE( "CalciumCouplingPolicy::setInterpolationSchem: " << interpolationSchem );
80 if ( _dependencyType != CalciumTypes::TIME_DEPENDENCY )
81 throw CalciumException(CalciumTypes::CPITVR,LOC("Can't set InterpolationSchem on a port that is not time dependent"));
82 _interpolationSchem=interpolationSchem;
85 void CalciumCouplingPolicy::setExtrapolationSchem (CalciumTypes::ExtrapolationSchem extrapolationSchem) {
86 if ( _dependencyType != CalciumTypes::TIME_DEPENDENCY )
87 throw CalciumException(CalciumTypes::CPITVR,LOC("Can't set ExtrapolationSchem on a port that is not time dependent"));
88 _extrapolationSchem=extrapolationSchem;
91 CalciumTypes::InterpolationSchem CalciumCouplingPolicy::getInterpolationSchem () const { return _interpolationSchem; }
92 CalciumTypes::ExtrapolationSchem CalciumCouplingPolicy::getExtrapolationSchem () const { return _extrapolationSchem; }
95 CalciumCouplingPolicy::TimeType
96 CalciumCouplingPolicy::getEffectiveTime(CalciumCouplingPolicy::TimeType ti,
97 CalciumCouplingPolicy::TimeType tf) {
98 if ( _dateCalSchem == CalciumTypes::TI_SCHEM ) return ti;
99 if ( _dateCalSchem == CalciumTypes::TF_SCHEM ) return tf;
101 //CalciumTypes::ALPHA_SCHEM
102 return tf*_alpha + ti*(1-_alpha);
105 void CalciumCouplingPolicy::disconnect(bool provideLastGivenValue) {
107 if (provideLastGivenValue) {
108 if (SALOME::VerbosityActivated())
109 std::cout << "-------- CalciumCouplingPolicy::disconnect CP_CONT ------------------" << std::endl;
111 _disconnectDirective = CalciumTypes::CONTINUE;
113 if (SALOME::VerbosityActivated())
114 std::cout << "-------- CalciumCouplingPolicy::disconnect CP_ARRET ------------------" << std::endl;
116 _disconnectDirective = CalciumTypes::STOP;
119 //Wakeup get data if any