[4050] | 1 | /*!\file PentaVertexElementResult.c
|
---|
| 2 | * \brief: implementation of the PentaVertexElementResult object
|
---|
| 3 | */
|
---|
| 4 |
|
---|
| 5 | #ifdef HAVE_CONFIG_H
|
---|
[9320] | 6 | #include <config.h>
|
---|
[4050] | 7 | #else
|
---|
| 8 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 9 | #endif
|
---|
| 10 |
|
---|
[9320] | 11 | #include <stdio.h>
|
---|
[4050] | 12 | #include <string.h>
|
---|
| 13 | #include "./ElementResultLocal.h"
|
---|
| 14 | #include "../objects.h"
|
---|
| 15 | #include "../../EnumDefinitions/EnumDefinitions.h"
|
---|
| 16 | #include "../../shared/shared.h"
|
---|
[4236] | 17 | #include "../../Container/Container.h"
|
---|
[4050] | 18 | #include "../../include/include.h"
|
---|
| 19 |
|
---|
[4248] | 20 | /*PentaVertexElementResult constructors and destructor*/
|
---|
[4050] | 21 | /*FUNCTION PentaVertexElementResult::PentaVertexElementResult(){{{1*/
|
---|
| 22 | PentaVertexElementResult::PentaVertexElementResult(){
|
---|
| 23 | return;
|
---|
| 24 | }
|
---|
| 25 | /*}}}*/
|
---|
| 26 | /*FUNCTION PentaVertexElementResult::PentaVertexElementResult(int in_enum_type,double* in_values,int in_step, double in_time){{{1*/
|
---|
[4239] | 27 | PentaVertexElementResult::PentaVertexElementResult(int in_enum_type,double* in_values,int in_step, double in_time){
|
---|
[4050] | 28 |
|
---|
[4239] | 29 | int i;
|
---|
| 30 |
|
---|
| 31 | enum_type=in_enum_type;
|
---|
| 32 | for(i=0;i<6;i++)values[i]=in_values[i];
|
---|
[4050] | 33 | step=in_step;
|
---|
| 34 | time=in_time;
|
---|
| 35 | }
|
---|
| 36 | /*}}}*/
|
---|
| 37 | /*FUNCTION PentaVertexElementResult::~PentaVertexElementResult(){{{1*/
|
---|
| 38 | PentaVertexElementResult::~PentaVertexElementResult(){
|
---|
| 39 | return;
|
---|
| 40 | }
|
---|
| 41 | /*}}}*/
|
---|
| 42 |
|
---|
[4248] | 43 | /*Object virtual functions definitions:*/
|
---|
| 44 | /*FUNCTION PentaVertexElementResult::Echo {{{1*/
|
---|
| 45 | void PentaVertexElementResult::Echo(void){
|
---|
| 46 | this->DeepEcho();
|
---|
[4050] | 47 | }
|
---|
| 48 | /*}}}*/
|
---|
| 49 | /*FUNCTION PentaVertexElementResult::DeepEcho{{{1*/
|
---|
| 50 | void PentaVertexElementResult::DeepEcho(void){
|
---|
| 51 |
|
---|
| 52 | printf("PentaVertexElementResult:\n");
|
---|
[8224] | 53 | printf(" enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
|
---|
[4239] | 54 | printf(" values: [%g %g %g %g %g %g]\n",this->values[0],this->values[1],this->values[2],this->values[3],this->values[4],this->values[5]);
|
---|
[4050] | 55 | printf(" step: %i\n",this->step);
|
---|
| 56 | printf(" time: %g\n",this->time);
|
---|
| 57 |
|
---|
| 58 | }
|
---|
| 59 | /*}}}*/
|
---|
[4248] | 60 | /*FUNCTION PentaVertexElementResult::Id{{{1*/
|
---|
| 61 | int PentaVertexElementResult::Id(void){ return -1; }
|
---|
[4050] | 62 | /*}}}*/
|
---|
[4248] | 63 | /*FUNCTION PentaVertexElementResult::MyRank{{{1*/
|
---|
| 64 | int PentaVertexElementResult::MyRank(void){
|
---|
| 65 | extern int my_rank;
|
---|
| 66 | return my_rank;
|
---|
[4050] | 67 | }
|
---|
| 68 | /*}}}*/
|
---|
[9777] | 69 | #ifdef _SERIAL_
|
---|
[4050] | 70 | /*FUNCTION PentaVertexElementResult::Marshall{{{1*/
|
---|
| 71 | void PentaVertexElementResult::Marshall(char** pmarshalled_dataset){
|
---|
| 72 |
|
---|
| 73 | char* marshalled_dataset=NULL;
|
---|
| 74 | int enum_value=0;
|
---|
| 75 |
|
---|
| 76 | /*recover marshalled_dataset: */
|
---|
| 77 | marshalled_dataset=*pmarshalled_dataset;
|
---|
| 78 |
|
---|
| 79 | /*get enum value of PentaVertexElementResult: */
|
---|
| 80 | enum_value=PentaVertexElementResultEnum;
|
---|
| 81 |
|
---|
| 82 | /*marshall enum: */
|
---|
| 83 | memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
|
---|
| 84 |
|
---|
| 85 | /*marshall PentaVertexElementResult data: */
|
---|
| 86 | memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
---|
| 87 | memcpy(marshalled_dataset,&values,sizeof(values));marshalled_dataset+=sizeof(values);
|
---|
| 88 | memcpy(marshalled_dataset,&time,sizeof(time));marshalled_dataset+=sizeof(time);
|
---|
| 89 | memcpy(marshalled_dataset,&step,sizeof(step));marshalled_dataset+=sizeof(step);
|
---|
| 90 |
|
---|
| 91 | *pmarshalled_dataset=marshalled_dataset;
|
---|
| 92 | }
|
---|
| 93 | /*}}}*/
|
---|
| 94 | /*FUNCTION PentaVertexElementResult::MarshallSize{{{1*/
|
---|
| 95 | int PentaVertexElementResult::MarshallSize(){
|
---|
| 96 |
|
---|
| 97 | return sizeof(values)+
|
---|
| 98 | +sizeof(enum_type)
|
---|
| 99 | +sizeof(time)
|
---|
| 100 | +sizeof(step)
|
---|
| 101 | +sizeof(int); //sizeof(int) for enum value
|
---|
| 102 | }
|
---|
| 103 | /*}}}*/
|
---|
[4248] | 104 | /*FUNCTION PentaVertexElementResult::Demarshall{{{1*/
|
---|
| 105 | void PentaVertexElementResult::Demarshall(char** pmarshalled_dataset){
|
---|
| 106 |
|
---|
| 107 | char* marshalled_dataset=NULL;
|
---|
| 108 | int i;
|
---|
| 109 |
|
---|
| 110 | /*recover marshalled_dataset: */
|
---|
| 111 | marshalled_dataset=*pmarshalled_dataset;
|
---|
| 112 |
|
---|
| 113 | /*this time, no need to get enum type, the pointer directly points to the beginning of the
|
---|
| 114 | *object data (thanks to DataSet::Demarshall):*/
|
---|
| 115 | memcpy(&enum_type,marshalled_dataset,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
---|
| 116 | memcpy(&values,marshalled_dataset,sizeof(values));marshalled_dataset+=sizeof(values);
|
---|
| 117 | memcpy(&time,marshalled_dataset,sizeof(time));marshalled_dataset+=sizeof(time);
|
---|
| 118 | memcpy(&step,marshalled_dataset,sizeof(step));marshalled_dataset+=sizeof(step);
|
---|
| 119 |
|
---|
| 120 | /*return: */
|
---|
| 121 | *pmarshalled_dataset=marshalled_dataset;
|
---|
| 122 | return;
|
---|
[4050] | 123 | }
|
---|
| 124 | /*}}}*/
|
---|
[9777] | 125 | #endif
|
---|
[4248] | 126 | /*FUNCTION PentaVertexElementResult::Enum{{{1*/
|
---|
| 127 | int PentaVertexElementResult::Enum(void){
|
---|
[4050] | 128 |
|
---|
[4248] | 129 | return PentaVertexElementResultEnum;
|
---|
| 130 |
|
---|
| 131 | }
|
---|
| 132 | /*}}}*/
|
---|
| 133 | /*FUNCTION PentaVertexElementResult::copy{{{1*/
|
---|
| 134 | Object* PentaVertexElementResult::copy() {
|
---|
| 135 |
|
---|
| 136 | return new PentaVertexElementResult(this->enum_type,this->values,this->step,this->time);
|
---|
| 137 |
|
---|
| 138 | }
|
---|
| 139 | /*}}}*/
|
---|
| 140 |
|
---|
| 141 | /*ElementResult management*/
|
---|
| 142 | /*FUNCTION PentaVertexElementResult::EnumType{{{1*/
|
---|
| 143 | int PentaVertexElementResult::EnumType(void){
|
---|
| 144 |
|
---|
| 145 | return this->enum_type;
|
---|
| 146 |
|
---|
| 147 | }
|
---|
| 148 | /*}}}*/
|
---|
[4050] | 149 | /*FUNCTION PentaVertexElementResult::SpawnTriaElementResult{{{1*/
|
---|
| 150 | ElementResult* PentaVertexElementResult::SpawnTriaElementResult(int* indices){
|
---|
| 151 |
|
---|
| 152 | /*output*/
|
---|
| 153 | TriaVertexElementResult* outresult=NULL;
|
---|
| 154 | double newvalues[3];
|
---|
| 155 |
|
---|
| 156 | /*Loop over the new indices*/
|
---|
| 157 | for(int i=0;i<3;i++){
|
---|
| 158 |
|
---|
| 159 | /*Check index value*/
|
---|
[6412] | 160 | _assert_(indices[i]>=0 && indices[i]<6);
|
---|
[4050] | 161 |
|
---|
| 162 | /*Assign value to new result*/
|
---|
| 163 | newvalues[i]=this->values[indices[i]];
|
---|
| 164 | }
|
---|
| 165 |
|
---|
| 166 | /*Create new Tria result*/
|
---|
| 167 | outresult=new TriaVertexElementResult(this->enum_type,&newvalues[0],this->step,this->time);
|
---|
| 168 |
|
---|
| 169 | /*Assign output*/
|
---|
| 170 | return outresult;
|
---|
| 171 |
|
---|
| 172 | }
|
---|
| 173 | /*}}}*/
|
---|
[4546] | 174 | /*FUNCTION PentaVertexElementResult::ProcessUnits{{{1*/
|
---|
[4050] | 175 | void PentaVertexElementResult::ProcessUnits(Parameters* parameters){
|
---|
| 176 |
|
---|
[8967] | 177 | UnitConversion(this->values,6,IuToExtEnum,this->enum_type);
|
---|
[4050] | 178 |
|
---|
| 179 | }
|
---|
| 180 | /*}}}*/
|
---|
[4546] | 181 | /*FUNCTION PentaVertexElementResult::NumberOfNodalValues{{{1*/
|
---|
[4050] | 182 | int PentaVertexElementResult::NumberOfNodalValues(void){
|
---|
| 183 | return 6;
|
---|
| 184 | }
|
---|
| 185 | /*}}}*/
|
---|
[4546] | 186 | /*FUNCTION PentaVertexElementResult::PatchFill{{{1*/
|
---|
[4050] | 187 | void PentaVertexElementResult::PatchFill(int row, Patch* patch){
|
---|
| 188 |
|
---|
| 189 | /*Here, we fill the result information into the patch object. First, let's remember what is in a row
|
---|
| 190 | * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values
|
---|
| 191 | * Here, we will supply the enum_type, step, time, interpolation and nodal_values: */
|
---|
| 192 | patch->fillresultinfo(row,this->enum_type,this->step,this->time,P1Enum,this->values,6);
|
---|
| 193 |
|
---|
| 194 | }
|
---|
| 195 | /*}}}*/
|
---|
[9874] | 196 | /*FUNCTION PentaVertexElementResult::GetVectorFromResults{{{1*/
|
---|
| 197 | void PentaVertexElementResult::GetVectorFromResults(Vec vector,int* doflist){
|
---|
| 198 |
|
---|
| 199 | const int numvertices=6;
|
---|
| 200 | VecSetValues(vector,numvertices,doflist,(const double*)this->values,INSERT_VALUES);
|
---|
| 201 |
|
---|
| 202 | } /*}}}*/
|
---|