[11292] | 1 | /*!\file PentaP1ElementResult.c
|
---|
| 2 | * \brief: implementation of the PentaP1ElementResult object
|
---|
[4050] | 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 |
|
---|
[11292] | 20 | /*PentaP1ElementResult constructors and destructor*/
|
---|
| 21 | /*FUNCTION PentaP1ElementResult::PentaP1ElementResult(){{{1*/
|
---|
| 22 | PentaP1ElementResult::PentaP1ElementResult(){
|
---|
[4050] | 23 | return;
|
---|
| 24 | }
|
---|
| 25 | /*}}}*/
|
---|
[11292] | 26 | /*FUNCTION PentaP1ElementResult::PentaP1ElementResult(int in_enum_type,double* in_values,int in_step, double in_time){{{1*/
|
---|
| 27 | PentaP1ElementResult::PentaP1ElementResult(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 | /*}}}*/
|
---|
[11292] | 37 | /*FUNCTION PentaP1ElementResult::~PentaP1ElementResult(){{{1*/
|
---|
| 38 | PentaP1ElementResult::~PentaP1ElementResult(){
|
---|
[4050] | 39 | return;
|
---|
| 40 | }
|
---|
| 41 | /*}}}*/
|
---|
| 42 |
|
---|
[4248] | 43 | /*Object virtual functions definitions:*/
|
---|
[11292] | 44 | /*FUNCTION PentaP1ElementResult::Echo {{{1*/
|
---|
| 45 | void PentaP1ElementResult::Echo(void){
|
---|
[4248] | 46 | this->DeepEcho();
|
---|
[4050] | 47 | }
|
---|
| 48 | /*}}}*/
|
---|
[11292] | 49 | /*FUNCTION PentaP1ElementResult::DeepEcho{{{1*/
|
---|
| 50 | void PentaP1ElementResult::DeepEcho(void){
|
---|
[4050] | 51 |
|
---|
[11292] | 52 | printf("PentaP1ElementResult:\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 | /*}}}*/
|
---|
[11292] | 60 | /*FUNCTION PentaP1ElementResult::Id{{{1*/
|
---|
| 61 | int PentaP1ElementResult::Id(void){ return -1; }
|
---|
[4050] | 62 | /*}}}*/
|
---|
[11292] | 63 | /*FUNCTION PentaP1ElementResult::MyRank{{{1*/
|
---|
| 64 | int PentaP1ElementResult::MyRank(void){
|
---|
[4248] | 65 | extern int my_rank;
|
---|
| 66 | return my_rank;
|
---|
[4050] | 67 | }
|
---|
| 68 | /*}}}*/
|
---|
[9777] | 69 | #ifdef _SERIAL_
|
---|
[11292] | 70 | /*FUNCTION PentaP1ElementResult::Marshall{{{1*/
|
---|
| 71 | void PentaP1ElementResult::Marshall(char** pmarshalled_dataset){
|
---|
[4050] | 72 |
|
---|
| 73 | char* marshalled_dataset=NULL;
|
---|
| 74 | int enum_value=0;
|
---|
| 75 |
|
---|
| 76 | /*recover marshalled_dataset: */
|
---|
| 77 | marshalled_dataset=*pmarshalled_dataset;
|
---|
| 78 |
|
---|
[11292] | 79 | /*get enum value of PentaP1ElementResult: */
|
---|
| 80 | enum_value=PentaP1ElementResultEnum;
|
---|
[4050] | 81 |
|
---|
| 82 | /*marshall enum: */
|
---|
| 83 | memcpy(marshalled_dataset,&enum_value,sizeof(enum_value));marshalled_dataset+=sizeof(enum_value);
|
---|
| 84 |
|
---|
[11292] | 85 | /*marshall PentaP1ElementResult data: */
|
---|
[4050] | 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 | /*}}}*/
|
---|
[11292] | 94 | /*FUNCTION PentaP1ElementResult::MarshallSize{{{1*/
|
---|
| 95 | int PentaP1ElementResult::MarshallSize(){
|
---|
[4050] | 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 | /*}}}*/
|
---|
[11292] | 104 | /*FUNCTION PentaP1ElementResult::Demarshall{{{1*/
|
---|
| 105 | void PentaP1ElementResult::Demarshall(char** pmarshalled_dataset){
|
---|
[4248] | 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
|
---|
[11292] | 126 | /*FUNCTION PentaP1ElementResult::ObjectEnum{{{1*/
|
---|
| 127 | int PentaP1ElementResult::ObjectEnum(void){
|
---|
[4050] | 128 |
|
---|
[11292] | 129 | return PentaP1ElementResultEnum;
|
---|
[4248] | 130 |
|
---|
| 131 | }
|
---|
| 132 | /*}}}*/
|
---|
[11292] | 133 | /*FUNCTION PentaP1ElementResult::copy{{{1*/
|
---|
| 134 | Object* PentaP1ElementResult::copy() {
|
---|
[4248] | 135 |
|
---|
[11292] | 136 | return new PentaP1ElementResult(this->enum_type,this->values,this->step,this->time);
|
---|
[4248] | 137 |
|
---|
| 138 | }
|
---|
| 139 | /*}}}*/
|
---|
| 140 |
|
---|
| 141 | /*ElementResult management*/
|
---|
[11292] | 142 | /*FUNCTION PentaP1ElementResult::InstanceEnum{{{1*/
|
---|
| 143 | int PentaP1ElementResult::InstanceEnum(void){
|
---|
[4248] | 144 |
|
---|
| 145 | return this->enum_type;
|
---|
| 146 |
|
---|
| 147 | }
|
---|
| 148 | /*}}}*/
|
---|
[11292] | 149 | /*FUNCTION PentaP1ElementResult::SpawnTriaElementResult{{{1*/
|
---|
| 150 | ElementResult* PentaP1ElementResult::SpawnTriaElementResult(int* indices){
|
---|
[4050] | 151 |
|
---|
| 152 | /*output*/
|
---|
[11292] | 153 | TriaP1ElementResult* outresult=NULL;
|
---|
[4050] | 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*/
|
---|
[11292] | 167 | outresult=new TriaP1ElementResult(this->enum_type,&newvalues[0],this->step,this->time);
|
---|
[4050] | 168 |
|
---|
| 169 | /*Assign output*/
|
---|
| 170 | return outresult;
|
---|
| 171 |
|
---|
| 172 | }
|
---|
| 173 | /*}}}*/
|
---|
[11292] | 174 | /*FUNCTION PentaP1ElementResult::ProcessUnits{{{1*/
|
---|
| 175 | void PentaP1ElementResult::ProcessUnits(Parameters* parameters){
|
---|
[4050] | 176 |
|
---|
[8967] | 177 | UnitConversion(this->values,6,IuToExtEnum,this->enum_type);
|
---|
[4050] | 178 |
|
---|
| 179 | }
|
---|
| 180 | /*}}}*/
|
---|
[11292] | 181 | /*FUNCTION PentaP1ElementResult::NumberOfNodalValues{{{1*/
|
---|
| 182 | int PentaP1ElementResult::NumberOfNodalValues(void){
|
---|
[4050] | 183 | return 6;
|
---|
| 184 | }
|
---|
| 185 | /*}}}*/
|
---|
[11292] | 186 | /*FUNCTION PentaP1ElementResult::PatchFill{{{1*/
|
---|
| 187 | void PentaP1ElementResult::PatchFill(int row, Patch* patch){
|
---|
[4050] | 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 | /*}}}*/
|
---|
[11292] | 196 | /*FUNCTION PentaP1ElementResult::GetVectorFromResults{{{1*/
|
---|
[11695] | 197 | void PentaP1ElementResult::GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs){
|
---|
[9874] | 198 |
|
---|
[11001] | 199 | double data[6];
|
---|
| 200 |
|
---|
[11292] | 201 | if(numdofs!=6)_error_("Result %s is a PentaP1ElementResult and cannot write vector of %i dofs",numdofs);
|
---|
[11001] | 202 | for(int i=0;i<6;i++) data[i]=this->values[i]/(double)connectivitylist[i];
|
---|
[11695] | 203 | vector->SetValues(numdofs,doflist,&data[0],ADD_VAL);
|
---|
[9874] | 204 |
|
---|
| 205 | } /*}}}*/
|
---|
[11292] | 206 | /*FUNCTION PentaP1ElementResult::GetElementVectorFromResults{{{1*/
|
---|
[11695] | 207 | void PentaP1ElementResult::GetElementVectorFromResults(Vector* vector,int dof){
|
---|
[10990] | 208 |
|
---|
[11292] | 209 | _error_("Result %s is a PentaP1ElementResult and should not write vector of size numberofelemenrs",EnumToStringx(enum_type));
|
---|
[10990] | 210 | } /*}}}*/
|
---|