[22755] | 1 | Index: ../trunk-jpl/src/c/classes/Numberedcostfunction.cpp
|
---|
| 2 | ===================================================================
|
---|
| 3 | --- ../trunk-jpl/src/c/classes/Numberedcostfunction.cpp (nonexistent)
|
---|
| 4 | +++ ../trunk-jpl/src/c/classes/Numberedcostfunction.cpp (revision 22423)
|
---|
| 5 | @@ -0,0 +1,159 @@
|
---|
| 6 | +/*!\file Numberedcostfunction.cpp
|
---|
| 7 | + * \brief: implementation for the Numberedcostfunction object
|
---|
| 8 | + */
|
---|
| 9 | +/*Include files: {{{*/
|
---|
| 10 | +#ifdef HAVE_CONFIG_H
|
---|
| 11 | + #include <config.h>
|
---|
| 12 | +#else
|
---|
| 13 | +#error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
---|
| 14 | +#endif
|
---|
| 15 | +
|
---|
| 16 | +
|
---|
| 17 | +/*Headers:*/
|
---|
| 18 | +//#include "./Definition.h"
|
---|
| 19 | +//#include "../datastructures/datastructures.h"
|
---|
| 20 | +#include "./classes.h"
|
---|
| 21 | +#include "./Elements/Element.h"
|
---|
| 22 | +#include "./Elements/Elements.h"
|
---|
| 23 | +#include "./FemModel.h"
|
---|
| 24 | +#include "./ExternalResults/ExternalResult.h"
|
---|
| 25 | +#include "./ExternalResults/Results.h"
|
---|
| 26 | +#include "../modules/SurfaceAbsVelMisfitx/SurfaceAbsVelMisfitx.h"
|
---|
| 27 | +#include "../modules/SurfaceRelVelMisfitx/SurfaceRelVelMisfitx.h"
|
---|
| 28 | +#include "../modules/SurfaceLogVelMisfitx/SurfaceLogVelMisfitx.h"
|
---|
| 29 | +#include "../modules/SurfaceLogVxVyMisfitx/SurfaceLogVxVyMisfitx.h"
|
---|
| 30 | +#include "../modules/ThicknessAbsMisfitx/ThicknessAbsMisfitx.h"
|
---|
| 31 | +#include "../modules/ThicknessAlongGradientx/ThicknessAlongGradientx.h"
|
---|
| 32 | +#include "../modules/ThicknessAcrossGradientx/ThicknessAcrossGradientx.h"
|
---|
| 33 | +#include "../modules/RheologyBbarAbsGradientx/RheologyBbarAbsGradientx.h"
|
---|
| 34 | +#include "../modules/DragCoefficientAbsGradientx/DragCoefficientAbsGradientx.h"
|
---|
| 35 | +
|
---|
| 36 | +/*}}}*/
|
---|
| 37 | +
|
---|
| 38 | +/*Numberedcostfunction constructors, destructors :*/
|
---|
| 39 | +Numberedcostfunction::Numberedcostfunction(){/*{{{*/
|
---|
| 40 | +
|
---|
| 41 | + this->definitionenum = -1;
|
---|
| 42 | + this->name = NULL;
|
---|
| 43 | + this->number_cost_functions = -1;
|
---|
| 44 | + this->cost_functions_list = NULL;
|
---|
| 45 | +
|
---|
| 46 | +}
|
---|
| 47 | +/*}}}*/
|
---|
| 48 | +Numberedcostfunction::Numberedcostfunction(char* in_name, int in_definitionenum,int number_cost_functions_in,int* cost_functions_list_in){/*{{{*/
|
---|
| 49 | + _assert_(number_cost_functions_in>0);
|
---|
| 50 | + _assert_(cost_functions_list_in);
|
---|
| 51 | +
|
---|
| 52 | + this->definitionenum=in_definitionenum;
|
---|
| 53 | + this->name = xNew<char>(strlen(in_name)+1);
|
---|
| 54 | + xMemCpy<char>(this->name,in_name,strlen(in_name)+1);
|
---|
| 55 | +
|
---|
| 56 | + this->number_cost_functions = number_cost_functions_in;
|
---|
| 57 | + this->cost_functions_list = xNew<int>(number_cost_functions_in);
|
---|
| 58 | +
|
---|
| 59 | + for(int i=0;i<number_cost_functions_in;i++){
|
---|
| 60 | + this->cost_functions_list[i] = cost_functions_list_in[i];
|
---|
| 61 | + }
|
---|
| 62 | +}
|
---|
| 63 | +/*}}}*/
|
---|
| 64 | +Numberedcostfunction::~Numberedcostfunction(){/*{{{*/
|
---|
| 65 | + xDelete<int>(this->cost_functions_list);
|
---|
| 66 | + if(this->name)xDelete(this->name);
|
---|
| 67 | +}
|
---|
| 68 | +/*}}}*/
|
---|
| 69 | +
|
---|
| 70 | +/*Object virtual function resolutoin: */
|
---|
| 71 | +Object* Numberedcostfunction::copy() {/*{{{*/
|
---|
| 72 | + Numberedcostfunction* out = new Numberedcostfunction(this->name,this->definitionenum,this->number_cost_functions,this->cost_functions_list);
|
---|
| 73 | + return (Object*)out;
|
---|
| 74 | +}
|
---|
| 75 | +/*}}}*/
|
---|
| 76 | +void Numberedcostfunction::DeepEcho(void){/*{{{*/
|
---|
| 77 | + this->Echo();
|
---|
| 78 | +}
|
---|
| 79 | +/*}}}*/
|
---|
| 80 | +void Numberedcostfunction::Echo(void){/*{{{*/
|
---|
| 81 | + _printf_(" Numberedcostfunction: " << this->name << " " << this->definitionenum << "\n");
|
---|
| 82 | + _printf_(" number_cost_functions: "<<this->number_cost_functions<<"\n");
|
---|
| 83 | + _printf_(" ");
|
---|
| 84 | + for(int i=0;i<this->number_cost_functions;i++){
|
---|
| 85 | + _printf_(this->cost_functions_list[i]<< " ");
|
---|
| 86 | + }
|
---|
| 87 | + _printf_("\n");
|
---|
| 88 | +}
|
---|
| 89 | +/*}}}*/
|
---|
| 90 | +int Numberedcostfunction::Id(void){/*{{{*/
|
---|
| 91 | + return -1;
|
---|
| 92 | +}
|
---|
| 93 | +/*}}}*/
|
---|
| 94 | +void Numberedcostfunction::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){/*{{{*/
|
---|
| 95 | + _error_("not implemented yet!");
|
---|
| 96 | +}
|
---|
| 97 | +/*}}}*/
|
---|
| 98 | +int Numberedcostfunction::ObjectEnum(void){/*{{{*/
|
---|
| 99 | + return NumberedcostfunctionEnum;
|
---|
| 100 | +}
|
---|
| 101 | +/*}}}*/
|
---|
| 102 | +
|
---|
| 103 | +/*Definition virtual function resolutoin: */
|
---|
| 104 | +int Numberedcostfunction::DefinitionEnum(){/*{{{*/
|
---|
| 105 | + return this->definitionenum;
|
---|
| 106 | +}
|
---|
| 107 | +/*}}}*/
|
---|
| 108 | +char* Numberedcostfunction::Name(){/*{{{*/
|
---|
| 109 | +
|
---|
| 110 | + char* name2=xNew<char>(strlen(this->name)+1);
|
---|
| 111 | + xMemCpy(name2,this->name,strlen(this->name)+1);
|
---|
| 112 | +
|
---|
| 113 | + return name2;
|
---|
| 114 | +}
|
---|
| 115 | +/*}}}*/
|
---|
| 116 | +IssmDouble Numberedcostfunction::Response(FemModel* femmodel){/*{{{*/
|
---|
| 117 | +
|
---|
| 118 | + _assert_(number_cost_functions>0 && number_cost_functions<1e3);
|
---|
| 119 | +
|
---|
| 120 | + /*output:*/
|
---|
| 121 | + IssmDouble value;
|
---|
| 122 | + IssmDouble value_sum = 0.;
|
---|
| 123 | +
|
---|
| 124 | + /*Scalar control output*/
|
---|
| 125 | + for(int i=0;i<this->number_cost_functions;i++){
|
---|
| 126 | + switch(this->cost_functions_list[i]){
|
---|
| 127 | + case SurfaceAbsVelMisfitEnum:
|
---|
| 128 | + SurfaceAbsVelMisfitx(&value,femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters);
|
---|
| 129 | + break;
|
---|
| 130 | + case SurfaceRelVelMisfitEnum:
|
---|
| 131 | + SurfaceRelVelMisfitx(&value, femmodel->elements,femmodel->nodes,femmodel-> vertices,femmodel-> loads,femmodel-> materials,femmodel->parameters);
|
---|
| 132 | + break;
|
---|
| 133 | + case SurfaceLogVelMisfitEnum:
|
---|
| 134 | + SurfaceLogVelMisfitx(&value,femmodel-> elements,femmodel->nodes,femmodel-> vertices,femmodel-> loads,femmodel-> materials,femmodel->parameters);
|
---|
| 135 | + break;
|
---|
| 136 | + case SurfaceLogVxVyMisfitEnum:
|
---|
| 137 | + SurfaceLogVxVyMisfitx(&value,femmodel-> elements,femmodel->nodes,femmodel-> vertices,femmodel-> loads,femmodel-> materials,femmodel->parameters);
|
---|
| 138 | + break;
|
---|
| 139 | + case ThicknessAbsMisfitEnum:
|
---|
| 140 | + ThicknessAbsMisfitx(&value,femmodel-> elements,femmodel->nodes,femmodel-> vertices,femmodel-> loads,femmodel-> materials,femmodel-> parameters);
|
---|
| 141 | + break;
|
---|
| 142 | + case ThicknessAlongGradientEnum:
|
---|
| 143 | + ThicknessAlongGradientx(&value,femmodel-> elements,femmodel->nodes,femmodel-> vertices,femmodel-> loads,femmodel-> materials,femmodel-> parameters);
|
---|
| 144 | + break;
|
---|
| 145 | + case ThicknessAcrossGradientEnum:
|
---|
| 146 | + ThicknessAcrossGradientx(&value,femmodel-> elements,femmodel->nodes,femmodel-> vertices,femmodel-> loads,femmodel-> materials,femmodel-> parameters);
|
---|
| 147 | + break;
|
---|
| 148 | + case RheologyBbarAbsGradientEnum:
|
---|
| 149 | + RheologyBbarAbsGradientx(&value,femmodel-> elements,femmodel->nodes,femmodel-> vertices,femmodel-> loads,femmodel-> materials,femmodel-> parameters);
|
---|
| 150 | + break;
|
---|
| 151 | + case DragCoefficientAbsGradientEnum:
|
---|
| 152 | + DragCoefficientAbsGradientx(&value,femmodel-> elements,femmodel->nodes,femmodel-> vertices,femmodel-> loads,femmodel-> materials,femmodel-> parameters);
|
---|
| 153 | + break;
|
---|
| 154 | + default:
|
---|
| 155 | + _error_("not supported");
|
---|
| 156 | + }
|
---|
| 157 | + value_sum += value;
|
---|
| 158 | + }
|
---|
| 159 | +
|
---|
| 160 | + /*done:*/
|
---|
| 161 | + return value_sum;
|
---|
| 162 | + }
|
---|
| 163 | + /*}}}*/
|
---|
| 164 | +
|
---|