source: issm/trunk/src/c/objects/ElementResults/PentaVertexElementResult.cpp@ 9874

Last change on this file since 9874 was 9874, checked in by Mathieu Morlighem, 13 years ago

Added support for result_on_vertices

File size: 6.1 KB
Line 
1/*!\file PentaVertexElementResult.c
2 * \brief: implementation of the PentaVertexElementResult 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/*PentaVertexElementResult constructors and destructor*/
21/*FUNCTION PentaVertexElementResult::PentaVertexElementResult(){{{1*/
22PentaVertexElementResult::PentaVertexElementResult(){
23 return;
24}
25/*}}}*/
26/*FUNCTION PentaVertexElementResult::PentaVertexElementResult(int in_enum_type,double* in_values,int in_step, double in_time){{{1*/
27PentaVertexElementResult::PentaVertexElementResult(int in_enum_type,double* in_values,int in_step, double in_time){
28
29 int i;
30
31 enum_type=in_enum_type;
32 for(i=0;i<6;i++)values[i]=in_values[i];
33 step=in_step;
34 time=in_time;
35}
36/*}}}*/
37/*FUNCTION PentaVertexElementResult::~PentaVertexElementResult(){{{1*/
38PentaVertexElementResult::~PentaVertexElementResult(){
39 return;
40}
41/*}}}*/
42
43/*Object virtual functions definitions:*/
44/*FUNCTION PentaVertexElementResult::Echo {{{1*/
45void PentaVertexElementResult::Echo(void){
46 this->DeepEcho();
47}
48/*}}}*/
49/*FUNCTION PentaVertexElementResult::DeepEcho{{{1*/
50void PentaVertexElementResult::DeepEcho(void){
51
52 printf("PentaVertexElementResult:\n");
53 printf(" enum: %i (%s)\n",this->enum_type,EnumToStringx(this->enum_type));
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]);
55 printf(" step: %i\n",this->step);
56 printf(" time: %g\n",this->time);
57
58}
59/*}}}*/
60/*FUNCTION PentaVertexElementResult::Id{{{1*/
61int PentaVertexElementResult::Id(void){ return -1; }
62/*}}}*/
63/*FUNCTION PentaVertexElementResult::MyRank{{{1*/
64int PentaVertexElementResult::MyRank(void){
65 extern int my_rank;
66 return my_rank;
67}
68/*}}}*/
69#ifdef _SERIAL_
70/*FUNCTION PentaVertexElementResult::Marshall{{{1*/
71void 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*/
95int 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/*}}}*/
104/*FUNCTION PentaVertexElementResult::Demarshall{{{1*/
105void 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;
123}
124/*}}}*/
125#endif
126/*FUNCTION PentaVertexElementResult::Enum{{{1*/
127int PentaVertexElementResult::Enum(void){
128
129 return PentaVertexElementResultEnum;
130
131}
132/*}}}*/
133/*FUNCTION PentaVertexElementResult::copy{{{1*/
134Object* 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*/
143int PentaVertexElementResult::EnumType(void){
144
145 return this->enum_type;
146
147}
148/*}}}*/
149/*FUNCTION PentaVertexElementResult::SpawnTriaElementResult{{{1*/
150ElementResult* 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*/
160 _assert_(indices[i]>=0 && indices[i]<6);
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/*}}}*/
174/*FUNCTION PentaVertexElementResult::ProcessUnits{{{1*/
175void PentaVertexElementResult::ProcessUnits(Parameters* parameters){
176
177 UnitConversion(this->values,6,IuToExtEnum,this->enum_type);
178
179}
180/*}}}*/
181/*FUNCTION PentaVertexElementResult::NumberOfNodalValues{{{1*/
182int PentaVertexElementResult::NumberOfNodalValues(void){
183 return 6;
184}
185/*}}}*/
186/*FUNCTION PentaVertexElementResult::PatchFill{{{1*/
187void 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/*}}}*/
196/*FUNCTION PentaVertexElementResult::GetVectorFromResults{{{1*/
197void 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} /*}}}*/
Note: See TracBrowser for help on using the repository browser.