| 1 | /*!\file BoolElementResult.c
|
|---|
| 2 | * \brief: implementation of the BoolElementResult 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 "./ElementResultLocal.h"
|
|---|
| 14 | #include "../objects.h"
|
|---|
| 15 | #include "../../EnumDefinitions/EnumDefinitions.h"
|
|---|
| 16 | #include "../../shared/shared.h"
|
|---|
| 17 | #include "../../Container/Container.h"
|
|---|
| 18 | #include "../../include/include.h"
|
|---|
| 19 |
|
|---|
| 20 | /*BoolElementResult constructors and destructor*/
|
|---|
| 21 | /*FUNCTION BoolElementResult::BoolElementResult(){{{1*/
|
|---|
| 22 | BoolElementResult::BoolElementResult(){
|
|---|
| 23 | return;
|
|---|
| 24 | }
|
|---|
| 25 | /*}}}*/
|
|---|
| 26 | /*FUNCTION BoolElementResult::BoolElementResult(int in_enum_type,IssmDouble in_value,int in_step, double in_time){{{1*/
|
|---|
| 27 | BoolElementResult::BoolElementResult(int in_enum_type,bool in_value,int in_step, double in_time){
|
|---|
| 28 |
|
|---|
| 29 | enum_type=in_enum_type;
|
|---|
| 30 | value=in_value;
|
|---|
| 31 | step=in_step;
|
|---|
| 32 | time=in_time;
|
|---|
| 33 | }
|
|---|
| 34 | /*}}}*/
|
|---|
| 35 | /*FUNCTION BoolElementResult::~BoolElementResult(){{{1*/
|
|---|
| 36 | BoolElementResult::~BoolElementResult(){
|
|---|
| 37 | return;
|
|---|
| 38 | }
|
|---|
| 39 | /*}}}*/
|
|---|
| 40 |
|
|---|
| 41 | /*Object virtual functions definitions:*/
|
|---|
| 42 | /*FUNCTION BoolElementResult::Echo {{{1*/
|
|---|
| 43 | void BoolElementResult::Echo(void){
|
|---|
| 44 | this->DeepEcho();
|
|---|
| 45 | }
|
|---|
| 46 | /*}}}*/
|
|---|
| 47 | /*FUNCTION BoolElementResult::DeepEcho{{{1*/
|
|---|
| 48 | void BoolElementResult::DeepEcho(void){
|
|---|
| 49 |
|
|---|
| 50 | printf("BoolElementResult:\n");
|
|---|
| 51 | printf(" enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
|
|---|
| 52 | printf(" value: %s\n",this->value?"true":"false");
|
|---|
| 53 | printf(" step: %i\n",this->step);
|
|---|
| 54 | printf(" time: %g\n",this->time);
|
|---|
| 55 | }
|
|---|
| 56 | /*}}}*/
|
|---|
| 57 | /*FUNCTION BoolElementResult::Id{{{1*/
|
|---|
| 58 | int BoolElementResult::Id(void){ return -1; }
|
|---|
| 59 | /*}}}*/
|
|---|
| 60 | /*FUNCTION BoolElementResult::MyRank{{{1*/
|
|---|
| 61 | int BoolElementResult::MyRank(void){
|
|---|
| 62 | extern int my_rank;
|
|---|
| 63 | return my_rank;
|
|---|
| 64 | }
|
|---|
| 65 | /*}}}*/
|
|---|
| 66 | #ifdef _SERIAL_
|
|---|
| 67 | /*FUNCTION BoolElementResult::Marshall{{{1*/
|
|---|
| 68 | void BoolElementResult::Marshall(char** pmarshalled_dataset){
|
|---|
| 69 |
|
|---|
| 70 | char* marshalled_dataset=NULL;
|
|---|
| 71 | int enum_value=0;
|
|---|
| 72 |
|
|---|
| 73 | /*recover marshalled_dataset: */
|
|---|
| 74 | marshalled_dataset=*pmarshalled_dataset;
|
|---|
| 75 |
|
|---|
| 76 | /*get enum value of BoolElementResult: */
|
|---|
| 77 | enum_value=BoolElementResultEnum;
|
|---|
| 78 |
|
|---|
| 79 | /*marshall enum: */
|
|---|
| 80 | memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
|
|---|
| 81 |
|
|---|
| 82 | /*marshall BoolElementResult data: */
|
|---|
| 83 | memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
|---|
| 84 | memcpy(marshalled_dataset,&value,sizeof(value));marshalled_dataset+=sizeof(value);
|
|---|
| 85 | memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
|
|---|
| 86 | memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
|
|---|
| 87 |
|
|---|
| 88 | *pmarshalled_dataset=marshalled_dataset;
|
|---|
| 89 | }
|
|---|
| 90 | /*}}}*/
|
|---|
| 91 | /*FUNCTION BoolElementResult::Demarshall{{{1*/
|
|---|
| 92 | void BoolElementResult::Demarshall(char** pmarshalled_dataset){
|
|---|
| 93 |
|
|---|
| 94 | char* marshalled_dataset=NULL;
|
|---|
| 95 | int i;
|
|---|
| 96 |
|
|---|
| 97 | /*recover marshalled_dataset: */
|
|---|
| 98 | marshalled_dataset=*pmarshalled_dataset;
|
|---|
| 99 |
|
|---|
| 100 | /*this time, no need to get enum type, the pointer directly points to the beginning of the
|
|---|
| 101 | *object data (thanks to DataSet::Demarshall):*/
|
|---|
| 102 | memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
|---|
| 103 | memcpy(&value,marshalled_dataset,sizeof(value));marshalled_dataset+=sizeof(value);
|
|---|
| 104 | memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
|
|---|
| 105 | memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
|
|---|
| 106 |
|
|---|
| 107 | /*return: */
|
|---|
| 108 | *pmarshalled_dataset=marshalled_dataset;
|
|---|
| 109 | return;
|
|---|
| 110 | }
|
|---|
| 111 | /*}}}*/
|
|---|
| 112 | /*FUNCTION BoolElementResult::MarshallSize{{{1*/
|
|---|
| 113 | int BoolElementResult::MarshallSize(){
|
|---|
| 114 |
|
|---|
| 115 | return sizeof(value)+
|
|---|
| 116 | +sizeof(enum_type)
|
|---|
| 117 | +sizeof(time)
|
|---|
| 118 | +sizeof(step)
|
|---|
| 119 | +sizeof(int); //sizeof(int) for enum value
|
|---|
| 120 | }
|
|---|
| 121 | /*}}}*/
|
|---|
| 122 | #endif
|
|---|
| 123 | /*FUNCTION BoolElementResult::ObjectEnum{{{1*/
|
|---|
| 124 | int BoolElementResult::ObjectEnum(void){
|
|---|
| 125 |
|
|---|
| 126 | return BoolElementResultEnum;
|
|---|
| 127 |
|
|---|
| 128 | }
|
|---|
| 129 | /*}}}*/
|
|---|
| 130 | /*FUNCTION BoolElementResult::copy{{{1*/
|
|---|
| 131 | Object* BoolElementResult::copy() {
|
|---|
| 132 |
|
|---|
| 133 | return new BoolElementResult(this->enum_type,this->value,this->step,this->time);
|
|---|
| 134 |
|
|---|
| 135 | }
|
|---|
| 136 | /*}}}*/
|
|---|
| 137 |
|
|---|
| 138 | /*ElementResult management*/
|
|---|
| 139 | /*FUNCTION BoolElementResult::InstanceEnum{{{1*/
|
|---|
| 140 | int BoolElementResult::InstanceEnum(void){
|
|---|
| 141 |
|
|---|
| 142 | return this->enum_type;
|
|---|
| 143 |
|
|---|
| 144 | }
|
|---|
| 145 | /*}}}*/
|
|---|
| 146 | /*FUNCTION BoolElementResult::SpawnTriaElementResult{{{1*/
|
|---|
| 147 | ElementResult* BoolElementResult::SpawnTriaElementResult(int* indices){
|
|---|
| 148 |
|
|---|
| 149 | /*output*/
|
|---|
| 150 | BoolElementResult* outresult=new BoolElementResult();
|
|---|
| 151 |
|
|---|
| 152 | /*copy fields: */
|
|---|
| 153 | outresult->enum_type=this->enum_type;
|
|---|
| 154 | outresult->value=this->value;
|
|---|
| 155 | outresult->time=this->time;
|
|---|
| 156 | outresult->step=this->step;
|
|---|
| 157 |
|
|---|
| 158 | /*Assign output*/
|
|---|
| 159 | return outresult;
|
|---|
| 160 |
|
|---|
| 161 | }
|
|---|
| 162 | /*}}}*/
|
|---|
| 163 | /*FUNCTION BoolElementResult::ProcessUnits{{{1*/
|
|---|
| 164 | void BoolElementResult::ProcessUnits(Parameters* parameters){
|
|---|
| 165 |
|
|---|
| 166 | this->value=UnitConversion(this->value,IuToExtEnum,this->enum_type);
|
|---|
| 167 |
|
|---|
| 168 | }
|
|---|
| 169 | /*}}}*/
|
|---|
| 170 | /*FUNCTION BoolElementResult::NumberOfNodalValues{{{1*/
|
|---|
| 171 | int BoolElementResult::NumberOfNodalValues(void){
|
|---|
| 172 | return 1;
|
|---|
| 173 | }
|
|---|
| 174 | /*}}}*/
|
|---|
| 175 | /*FUNCTION BoolElementResult::PatchFill{{{1*/
|
|---|
| 176 | void BoolElementResult::PatchFill(int row, Patch* patch){
|
|---|
| 177 |
|
|---|
| 178 | /*Here, we fill the result information into the patch object. First, let's remember what is in a row
|
|---|
| 179 | * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values
|
|---|
| 180 | * Here, we will supply the enum_type, step, time, interpolation and nodal_values: */
|
|---|
| 181 | double doublevalue=this->value?1:0;
|
|---|
| 182 | patch->fillresultinfo(row,this->enum_type,this->step,this->time,P0Enum,&doublevalue,1);
|
|---|
| 183 |
|
|---|
| 184 | }
|
|---|
| 185 | /*}}}*/
|
|---|
| 186 | /*FUNCTION BoolElementResult::GetVectorFromResults{{{1*/
|
|---|
| 187 | void BoolElementResult::GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs){
|
|---|
| 188 |
|
|---|
| 189 | _error_("cannot return vector on vertices");
|
|---|
| 190 | } /*}}}*/
|
|---|
| 191 | /*FUNCTION BoolElementResult::GetElementVectorFromResults{{{1*/
|
|---|
| 192 | void BoolElementResult::GetElementVectorFromResults(Vector* vector,int dof){
|
|---|
| 193 |
|
|---|
| 194 | vector->SetValue(dof,value,INS_VAL);
|
|---|
| 195 | } /*}}}*/
|
|---|