source: issm/branches/trunk-larour-NatGeoScience2016/src/c/classes/Inputs/IntInput.cpp@ 21243

Last change on this file since 21243 was 20827, checked in by agscott1, 9 years ago

CHG: Alphabetized all function names under classes

File size: 3.5 KB
Line 
1/*!\file IntInput.c
2 * \brief: implementation of the IntInput object
3 */
4
5#ifdef HAVE_CONFIG_H
6 #include <config.h>
7#else
8#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
9#endif
10
11#include "../classes.h"
12#include "../../shared/shared.h"
13
14/*IntInput constructors and destructor*/
15IntInput::IntInput(){/*{{{*/
16 return;
17}
18/*}}}*/
19IntInput::IntInput(int in_enum_type,IssmInt in_value){/*{{{*/
20
21 enum_type=in_enum_type;
22 value=in_value;
23}
24/*}}}*/
25IntInput::~IntInput(){/*{{{*/
26 return;
27}
28/*}}}*/
29
30/*Object virtual functions definitions:*/
31Object* IntInput::copy() {/*{{{*/
32
33 return new IntInput(this->enum_type,this->value);
34
35}
36/*}}}*/
37void IntInput::DeepEcho(void){/*{{{*/
38
39 _printf_(setw(15)<<" IntInput "<<setw(25)<<left<<EnumToStringx(this->enum_type)<<" "<<this->value<<"\n");
40}
41/*}}}*/
42int IntInput::Id(void){ return -1; }/*{{{*/
43/*}}}*/
44void IntInput::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/
45
46 MARSHALLING_ENUM(IntInputEnum);
47
48 MARSHALLING(enum_type);
49 MARSHALLING(value);
50
51}
52/*}}}*/
53int IntInput::ObjectEnum(void){/*{{{*/
54
55 return IntInputEnum;
56
57}
58/*}}}*/
59
60/*IntInput management*/
61void IntInput::Echo(void){/*{{{*/
62 this->DeepEcho();
63}
64/*}}}*/
65int IntInput::InstanceEnum(void){/*{{{*/
66
67 return this->enum_type;
68
69}
70/*}}}*/
71Input* IntInput::SpawnSegInput(int index1,int index2){/*{{{*/
72
73 /*output*/
74 IntInput* outinput=new IntInput();
75
76 /*only copy current value*/
77 outinput->enum_type=this->enum_type;
78 outinput->value=this->value;
79
80 /*Assign output*/
81 return outinput;
82}
83/*}}}*/
84Input* IntInput::SpawnTriaInput(int index1,int index2,int index3){/*{{{*/
85
86 /*output*/
87 IntInput* outinput=new IntInput();
88
89 /*only copy current value*/
90 outinput->enum_type=this->enum_type;
91 outinput->value=this->value;
92
93 /*Assign output*/
94 return outinput;
95}
96/*}}}*/
97
98/*Object functions*/
99void IntInput::AXPY(Input* xinput,IssmDouble scalar){/*{{{*/
100
101 IssmDouble dvalue;
102 IntInput* xintinput=NULL;
103
104 /*xinput is of the same type, so cast it: */
105 xintinput=(IntInput*)xinput;
106
107 /*Carry out the AXPY operation depending on type:*/
108 switch(xinput->ObjectEnum()){
109
110 case IntInputEnum:
111 dvalue=(IssmDouble)this->value+scalar*(IssmDouble)xintinput->value;
112 this->value=reCast<int>(dvalue);
113 return;
114
115 default:
116 _error_("not implemented yet");
117 }
118
119}
120/*}}}*/
121void IntInput::ChangeEnum(int newenumtype){/*{{{*/
122 this->enum_type=newenumtype;
123}
124/*}}}*/
125void IntInput::Configure(Parameters* parameters){/*{{{*/
126 /*do nothing: */
127}
128/*}}}*/
129void IntInput::Constrain(IssmDouble cm_min, IssmDouble cm_max){/*{{{*/
130
131 if(!xIsNan<IssmDouble>(cm_min)) if (this->value<cm_min)this->value=reCast<int>(cm_min);
132 if(!xIsNan<IssmDouble>(cm_max)) if (this->value>cm_max)this->value=reCast<int>(cm_max);
133
134}
135/*}}}*/
136void IntInput::GetInputValue(bool* pvalue){_error_("not supported yet!");}/*{{{*/
137/*}}}*/
138void IntInput::GetInputValue(int* pvalue){/*{{{*/
139 *pvalue=value;
140}
141/*}}}*/
142void IntInput::GetInputValue(IssmDouble* pvalue){/*{{{*/
143 _error_("IntInput cannot return a IssmDouble in parallel");
144}
145/*}}}*/
146void IntInput::GetInputValue(IssmDouble* pvalue,Gauss* gauss){_error_("not supported yet!");}/*{{{*/
147/*}}}*/
148void IntInput::GetVectorFromInputs(Vector<IssmDouble>* vector,int* doflist){/*{{{*/
149
150 _error_("not supporte yet!");
151
152}
153/*}}}*/
154void IntInput::Scale(IssmDouble scale_factor){/*{{{*/
155 IssmDouble dvalue=(IssmDouble)value*scale_factor;
156 value=reCast<int>(dvalue);
157}
158/*}}}*/
159void IntInput::SquareMin(IssmDouble* psquaremin,Parameters* parameters){/*{{{*/
160
161 /*square min of an integer is the square of the integer itself: */
162 *psquaremin=pow((IssmDouble)value,2);
163}
164/*}}}*/
Note: See TracBrowser for help on using the repository browser.