| 1 | /*!\file BoolInput.c
|
|---|
| 2 | * \brief: implementation of the BoolInput 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 <stdio.h>
|
|---|
| 12 | #include <string.h>
|
|---|
| 13 | #include "../../classes.h"
|
|---|
| 14 | #include "../../../EnumDefinitions/EnumDefinitions.h"
|
|---|
| 15 | #include "../../../shared/shared.h"
|
|---|
| 16 | #include "../../../Container/Container.h"
|
|---|
| 17 | #include "../../../include/include.h"
|
|---|
| 18 |
|
|---|
| 19 | /*BoolInput constructors and destructor*/
|
|---|
| 20 | /*FUNCTION BoolInput::BoolInput(){{{*/
|
|---|
| 21 | BoolInput::BoolInput(){
|
|---|
| 22 | return;
|
|---|
| 23 | }
|
|---|
| 24 | /*}}}*/
|
|---|
| 25 | /*FUNCTION BoolInput::BoolInput(IssmDouble* values){{{*/
|
|---|
| 26 | BoolInput::BoolInput(int in_enum_type,IssmBool in_value){
|
|---|
| 27 |
|
|---|
| 28 | enum_type=in_enum_type;
|
|---|
| 29 | value=in_value;
|
|---|
| 30 | }
|
|---|
| 31 | /*}}}*/
|
|---|
| 32 | /*FUNCTION BoolInput::~BoolInput(){{{*/
|
|---|
| 33 | BoolInput::~BoolInput(){
|
|---|
| 34 | return;
|
|---|
| 35 | }
|
|---|
| 36 | /*}}}*/
|
|---|
| 37 |
|
|---|
| 38 | /*Object virtual functions definitions:*/
|
|---|
| 39 | /*FUNCTION BoolInput::Echo {{{*/
|
|---|
| 40 | void BoolInput::Echo(void){
|
|---|
| 41 | this->DeepEcho();
|
|---|
| 42 | }
|
|---|
| 43 | /*}}}*/
|
|---|
| 44 | /*FUNCTION BoolInput::DeepEcho{{{*/
|
|---|
| 45 | void BoolInput::DeepEcho(void){
|
|---|
| 46 |
|
|---|
| 47 | _printLine_("BoolInput:");
|
|---|
| 48 | _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
|
|---|
| 49 | _printLine_(" value: " <<(value?"true":"false"));
|
|---|
| 50 | }
|
|---|
| 51 | /*}}}*/
|
|---|
| 52 | /*FUNCTION BoolInput::Id{{{*/
|
|---|
| 53 | int BoolInput::Id(void){ return -1; }
|
|---|
| 54 | /*}}}*/
|
|---|
| 55 | /*FUNCTION BoolInput::MyRank{{{*/
|
|---|
| 56 | int BoolInput::MyRank(void){
|
|---|
| 57 | extern int my_rank;
|
|---|
| 58 | return my_rank;
|
|---|
| 59 | }
|
|---|
| 60 | /*}}}*/
|
|---|
| 61 | /*FUNCTION BoolInput::ObjectEnum{{{*/
|
|---|
| 62 | int BoolInput::ObjectEnum(void){
|
|---|
| 63 |
|
|---|
| 64 | return BoolInputEnum;
|
|---|
| 65 |
|
|---|
| 66 | }
|
|---|
| 67 | /*}}}*/
|
|---|
| 68 | /*FUNCTION BoolInput::copy{{{*/
|
|---|
| 69 | Object* BoolInput::copy() {
|
|---|
| 70 |
|
|---|
| 71 | return new BoolInput(this->enum_type,this->value);
|
|---|
| 72 |
|
|---|
| 73 | }
|
|---|
| 74 | /*}}}*/
|
|---|
| 75 |
|
|---|
| 76 | /*BoolInput management*/
|
|---|
| 77 | /*FUNCTION BoolInput::InstanceEnum{{{*/
|
|---|
| 78 | int BoolInput::InstanceEnum(void){
|
|---|
| 79 |
|
|---|
| 80 | return this->enum_type;
|
|---|
| 81 |
|
|---|
| 82 | }
|
|---|
| 83 | /*}}}*/
|
|---|
| 84 | /*FUNCTION BoolInput::SpawnTriaInput{{{*/
|
|---|
| 85 | Input* BoolInput::SpawnTriaInput(int* indices){
|
|---|
| 86 |
|
|---|
| 87 | /*output*/
|
|---|
| 88 | BoolInput* outinput=new BoolInput();
|
|---|
| 89 |
|
|---|
| 90 | /*only copy current value*/
|
|---|
| 91 | outinput->enum_type=this->enum_type;
|
|---|
| 92 | outinput->value=this->value;
|
|---|
| 93 |
|
|---|
| 94 | /*Assign output*/
|
|---|
| 95 | return outinput;
|
|---|
| 96 |
|
|---|
| 97 | }
|
|---|
| 98 | /*}}}*/
|
|---|
| 99 | /*FUNCTION BoolInput::SpawnResult{{{*/
|
|---|
| 100 | ElementResult* BoolInput::SpawnResult(int step, IssmDouble time){
|
|---|
| 101 |
|
|---|
| 102 | return new BoolElementResult(this->enum_type,this->value,step,time);
|
|---|
| 103 |
|
|---|
| 104 | }
|
|---|
| 105 | /*}}}*/
|
|---|
| 106 |
|
|---|
| 107 | /*Object functions*/
|
|---|
| 108 | /*FUNCTION BoolInput::GetInputValue(bool* pvalue) {{{*/
|
|---|
| 109 | void BoolInput::GetInputValue(bool* pvalue){
|
|---|
| 110 | *pvalue=value;
|
|---|
| 111 | }
|
|---|
| 112 | /*}}}*/
|
|---|
| 113 | /*FUNCTION BoolInput::GetInputValue(int* pvalue){{{*/
|
|---|
| 114 | void BoolInput::GetInputValue(int* pvalue){_error2_("not supported yet!");}
|
|---|
| 115 | /*}}}*/
|
|---|
| 116 | /*FUNCTION BoolInput::GetInputValue(IssmDouble* pvalue){{{*/
|
|---|
| 117 | void BoolInput::GetInputValue(IssmDouble* pvalue){_error2_("not supported yet!");}
|
|---|
| 118 | /*}}}*/
|
|---|
| 119 | /*FUNCTION BoolInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){{{*/
|
|---|
| 120 | void BoolInput::GetInputValue(IssmDouble* pvalue,GaussTria* gauss){_error2_("not supported yet!");}
|
|---|
| 121 | /*}}}*/
|
|---|
| 122 | /*FUNCTION BoolInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){{{*/
|
|---|
| 123 | void BoolInput::GetInputValue(IssmDouble* pvalue,GaussPenta* gauss){_error2_("not supported yet!");}
|
|---|
| 124 | /*}}}*/
|
|---|
| 125 | /*FUNCTION BoolInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){{{*/
|
|---|
| 126 | void BoolInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussTria* gauss){_error2_("not supported yet!");}
|
|---|
| 127 | /*}}}*/
|
|---|
| 128 | /*FUNCTION BoolInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){{{*/
|
|---|
| 129 | void BoolInput::GetInputDerivativeValue(IssmDouble* derivativevalues, IssmDouble* xyz_list, GaussPenta* gauss){_error2_("not supported yet!");}
|
|---|
| 130 | /*}}}*/
|
|---|
| 131 | /*FUNCTION BoolInput::ChangeEnum{{{*/
|
|---|
| 132 | void BoolInput::ChangeEnum(int newenumtype){
|
|---|
| 133 | this->enum_type=newenumtype;
|
|---|
| 134 | }
|
|---|
| 135 | /*}}}*/
|
|---|
| 136 | /*FUNCTION BoolInput::SquareMin{{{*/
|
|---|
| 137 | void BoolInput::SquareMin(IssmDouble* psquaremin, bool process_units,Parameters* parameters){
|
|---|
| 138 | /*square of a bool is the bool itself: */
|
|---|
| 139 | *psquaremin=value;
|
|---|
| 140 | }
|
|---|
| 141 | /*}}}*/
|
|---|
| 142 | /*FUNCTION BoolInput::Scale{{{*/
|
|---|
| 143 | void BoolInput::Scale(IssmDouble scale_factor){
|
|---|
| 144 | /*a bool cannot be scaled: */
|
|---|
| 145 | }
|
|---|
| 146 | /*}}}*/
|
|---|
| 147 | /*FUNCTION BoolInput::AXPY{{{*/
|
|---|
| 148 | void BoolInput::AXPY(Input* xinput,IssmDouble scalar){
|
|---|
| 149 |
|
|---|
| 150 | BoolInput* xboolinput=NULL;
|
|---|
| 151 |
|
|---|
| 152 | /*xinput is of the same type, so cast it: */
|
|---|
| 153 | xboolinput=(BoolInput*)xinput;
|
|---|
| 154 |
|
|---|
| 155 | /*Carry out the AXPY operation depending on type:*/
|
|---|
| 156 | switch(xinput->ObjectEnum()){
|
|---|
| 157 |
|
|---|
| 158 | case BoolInputEnum:
|
|---|
| 159 | this->value=reCast<bool,IssmDouble>(this->value+scalar*xboolinput->value);
|
|---|
| 160 | return;
|
|---|
| 161 |
|
|---|
| 162 | default:
|
|---|
| 163 | _error2_("not implemented yet");
|
|---|
| 164 | }
|
|---|
| 165 |
|
|---|
| 166 | }
|
|---|
| 167 | /*}}}*/
|
|---|
| 168 | /*FUNCTION BoolInput::Extrude{{{*/
|
|---|
| 169 | void BoolInput::Extrude(void){
|
|---|
| 170 |
|
|---|
| 171 | /*do nothing*/
|
|---|
| 172 | return;
|
|---|
| 173 | }
|
|---|
| 174 | /*}}}*/
|
|---|
| 175 | /*FUNCTION BoolInput::GetVectorFromInputs{{{*/
|
|---|
| 176 | void BoolInput::GetVectorFromInputs(Vector* vector,int* doflist){
|
|---|
| 177 |
|
|---|
| 178 | _error2_("not supporte yet!");
|
|---|
| 179 |
|
|---|
| 180 | }
|
|---|
| 181 | /*}}}*/
|
|---|
| 182 | /*FUNCTION BoolInput::GetValuesPtr{{{*/
|
|---|
| 183 | void BoolInput::GetValuesPtr(IssmDouble** pvalues,int* pnum_values){
|
|---|
| 184 |
|
|---|
| 185 | _error2_("not supported yet!");
|
|---|
| 186 |
|
|---|
| 187 | }
|
|---|
| 188 | /*}}}*/
|
|---|
| 189 | /*FUNCTION BoolInput::Configure{{{*/
|
|---|
| 190 | void BoolInput::Configure(Parameters* parameters){
|
|---|
| 191 | /*do nothing: */
|
|---|
| 192 | }
|
|---|
| 193 | /*}}}*/
|
|---|