source: issm/trunk-jpl/src/c/objects/ElementResults/PentaP1ElementResult.cpp@ 12560

Last change on this file since 12560 was 12560, checked in by utke, 13 years ago

according to M. Morlighem all Results should be passive and the idea is to pass in active values to the constructors and in the constructor reCast and drop the derivatives under the assumption that cost functions etc. are computed before the results are formed so that the adjoint has the dependency it needs. The current problem is that the Results also call unit conversions which is an active method and therefore should not be applied to passive data. A solution for the latter is needed.

File size: 4.7 KB
RevLine 
[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*/
[12365]21/*FUNCTION PentaP1ElementResult::PentaP1ElementResult(){{{*/
[11292]22PentaP1ElementResult::PentaP1ElementResult(){
[4050]23 return;
24}
25/*}}}*/
[12463]26/*FUNCTION PentaP1ElementResult::PentaP1ElementResult(int in_enum_type,IssmDouble* in_values,int in_step, IssmDouble in_time){{{*/
27PentaP1ElementResult::PentaP1ElementResult(int in_enum_type,IssmDouble* in_values,int in_step, IssmDouble in_time){
[4050]28
[4239]29 int i;
30
31 enum_type=in_enum_type;
[12560]32 for(i=0;i<6;i++)values[i]=reCast<IssmPDouble>(in_values[i]);
[4050]33 step=in_step;
[12560]34 time=reCast<IssmPDouble>(in_time);
[4050]35}
36/*}}}*/
[12365]37/*FUNCTION PentaP1ElementResult::~PentaP1ElementResult(){{{*/
[11292]38PentaP1ElementResult::~PentaP1ElementResult(){
[4050]39 return;
40}
41/*}}}*/
42
[4248]43/*Object virtual functions definitions:*/
[12365]44/*FUNCTION PentaP1ElementResult::Echo {{{*/
[11292]45void PentaP1ElementResult::Echo(void){
[4248]46 this->DeepEcho();
[4050]47}
48/*}}}*/
[12365]49/*FUNCTION PentaP1ElementResult::DeepEcho{{{*/
[11292]50void PentaP1ElementResult::DeepEcho(void){
[4050]51
[12511]52 _printLine_("PentaP1ElementResult:");
53 _printLine_(" enum: " << this->enum_type << " (" << EnumToStringx(this->enum_type) << ")");
54 _printLine_(" values: [" << this->values[0] << " " << this->values[1] << " " << this->values[2] << " " << this->values[3] << " " << this->values[4] << " " << this->values[5] << "]");
55 _printLine_(" step: " << this->step);
56 _printLine_(" time: " << this->time);
[4050]57
58}
59/*}}}*/
[12365]60/*FUNCTION PentaP1ElementResult::Id{{{*/
[11292]61int PentaP1ElementResult::Id(void){ return -1; }
[4050]62/*}}}*/
[12365]63/*FUNCTION PentaP1ElementResult::MyRank{{{*/
[11292]64int PentaP1ElementResult::MyRank(void){
[4248]65 extern int my_rank;
66 return my_rank;
[4050]67}
68/*}}}*/
[12365]69/*FUNCTION PentaP1ElementResult::ObjectEnum{{{*/
[11292]70int PentaP1ElementResult::ObjectEnum(void){
[4050]71
[11292]72 return PentaP1ElementResultEnum;
[4248]73
74}
75/*}}}*/
[12365]76/*FUNCTION PentaP1ElementResult::copy{{{*/
[11292]77Object* PentaP1ElementResult::copy() {
[4248]78
[11292]79 return new PentaP1ElementResult(this->enum_type,this->values,this->step,this->time);
[4248]80
81}
82/*}}}*/
83
84/*ElementResult management*/
[12365]85/*FUNCTION PentaP1ElementResult::InstanceEnum{{{*/
[11292]86int PentaP1ElementResult::InstanceEnum(void){
[4248]87
88 return this->enum_type;
89
90}
91/*}}}*/
[12365]92/*FUNCTION PentaP1ElementResult::SpawnTriaElementResult{{{*/
[11292]93ElementResult* PentaP1ElementResult::SpawnTriaElementResult(int* indices){
[4050]94
95 /*output*/
[11292]96 TriaP1ElementResult* outresult=NULL;
[12560]97 IssmPDouble newvalues[3];
[4050]98
99 /*Loop over the new indices*/
100 for(int i=0;i<3;i++){
101
102 /*Check index value*/
[6412]103 _assert_(indices[i]>=0 && indices[i]<6);
[4050]104
105 /*Assign value to new result*/
106 newvalues[i]=this->values[indices[i]];
107 }
108
109 /*Create new Tria result*/
[11292]110 outresult=new TriaP1ElementResult(this->enum_type,&newvalues[0],this->step,this->time);
[4050]111
112 /*Assign output*/
113 return outresult;
114
115}
116/*}}}*/
[12365]117/*FUNCTION PentaP1ElementResult::ProcessUnits{{{*/
[11292]118void PentaP1ElementResult::ProcessUnits(Parameters* parameters){
[4050]119
[8967]120 UnitConversion(this->values,6,IuToExtEnum,this->enum_type);
[4050]121
122}
123/*}}}*/
[12365]124/*FUNCTION PentaP1ElementResult::NumberOfNodalValues{{{*/
[11292]125int PentaP1ElementResult::NumberOfNodalValues(void){
[4050]126 return 6;
127}
128/*}}}*/
[12365]129/*FUNCTION PentaP1ElementResult::PatchFill{{{*/
[11292]130void PentaP1ElementResult::PatchFill(int row, Patch* patch){
[4050]131
132 /*Here, we fill the result information into the patch object. First, let's remember what is in a row
133 * of the patch object: enum_type step time element_id interpolation vertices_ids nodal_values
134 * Here, we will supply the enum_type, step, time, interpolation and nodal_values: */
135 patch->fillresultinfo(row,this->enum_type,this->step,this->time,P1Enum,this->values,6);
136
137}
138/*}}}*/
[12365]139/*FUNCTION PentaP1ElementResult::GetVectorFromResults{{{*/
[11695]140void PentaP1ElementResult::GetVectorFromResults(Vector* vector,int* doflist,int* connectivitylist,int numdofs){
[9874]141
[12560]142 IssmPDouble data[6];
[11001]143
[12493]144 if(numdofs!=6)_error2_("Result " << EnumToStringx(this->enum_type) << " is a PentaP1ElementResult and cannot write vector of " << numdofs << " dofs");
[12560]145 for(int i=0;i<6;i++) data[i]=this->values[i]/(IssmPDouble)connectivitylist[i];
[11695]146 vector->SetValues(numdofs,doflist,&data[0],ADD_VAL);
[9874]147
148} /*}}}*/
[12365]149/*FUNCTION PentaP1ElementResult::GetElementVectorFromResults{{{*/
[11695]150void PentaP1ElementResult::GetElementVectorFromResults(Vector* vector,int dof){
[10990]151
[12493]152 _error2_("Result " << EnumToStringx(enum_type) << " is a PentaP1ElementResult and should not write vector of size numberofelemenrs");
[10990]153} /*}}}*/
Note: See TracBrowser for help on using the repository browser.