[2333] | 1 | /*!\file Numpar.c
|
---|
| 2 | * \brief: implementation of the Numpar 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 "./Numpar.h"
|
---|
| 13 | #include <string.h>
|
---|
| 14 | #include "../EnumDefinitions/EnumDefinitions.h"
|
---|
| 15 | #include "../shared/shared.h"
|
---|
| 16 | #include "../DataSet/DataSet.h"
|
---|
| 17 | #include "../include/typedefs.h"
|
---|
| 18 |
|
---|
| 19 |
|
---|
| 20 | Numpar::Numpar(){
|
---|
| 21 | return;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
[2344] | 24 |
|
---|
[2333] | 25 | Numpar::Numpar(int numpar_id){
|
---|
| 26 | id=numpar_id;
|
---|
| 27 |
|
---|
| 28 | meanvel=UNDEF;
|
---|
| 29 | epsvel=UNDEF;
|
---|
| 30 | artdiff=UNDEF;
|
---|
| 31 | viscosity_overshoot=UNDEF;
|
---|
| 32 | stokesreconditioning=UNDEF;
|
---|
| 33 | cm_noisedampening=UNDEF;
|
---|
| 34 |
|
---|
| 35 | return;
|
---|
| 36 | }
|
---|
| 37 | Numpar::~Numpar(){
|
---|
| 38 | return;
|
---|
| 39 | }
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | #undef __FUNCT__
|
---|
| 43 | #define __FUNCT__ "Numpar::Echo"
|
---|
| 44 | void Numpar::Echo(void){
|
---|
| 45 |
|
---|
| 46 | printf("Numpar:\n");
|
---|
| 47 | printf(" id: %i\n",id);
|
---|
| 48 | printf(" meanvel: %g\n",meanvel);
|
---|
| 49 | printf(" epsvel: %g\n",epsvel);
|
---|
| 50 | printf(" artdiff: %i\n",artdiff);
|
---|
| 51 | printf(" viscosity_overshoot: %g\n",viscosity_overshoot);
|
---|
| 52 | printf(" stokesreconditioning: %g\n",stokesreconditioning);
|
---|
| 53 | printf(" cm_noisedampening: %g\n",cm_noisedampening);
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 | #undef __FUNCT__
|
---|
| 57 | #define __FUNCT__ "Numpar::DeepEcho"
|
---|
| 58 | void Numpar::DeepEcho(void){
|
---|
| 59 |
|
---|
| 60 | printf("Numpar:\n");
|
---|
| 61 | printf(" id: %i\n",id);
|
---|
| 62 | printf(" meanvel: %g\n",meanvel);
|
---|
| 63 | printf(" epsvel: %g\n",epsvel);
|
---|
| 64 | printf(" artdiff: %i\n",artdiff);
|
---|
| 65 | printf(" viscosity_overshoot: %g\n",viscosity_overshoot);
|
---|
| 66 | printf(" stokesreconditioning: %g\n",stokesreconditioning);
|
---|
| 67 | printf(" cm_noisedampening: %g\n",cm_noisedampening);
|
---|
| 68 | }
|
---|
| 69 |
|
---|
| 70 |
|
---|
| 71 | void Numpar::Marshall(char** pmarshalled_dataset){
|
---|
| 72 |
|
---|
| 73 | char* marshalled_dataset=NULL;
|
---|
| 74 | int enum_type=0;
|
---|
| 75 |
|
---|
| 76 | /*recover marshalled_dataset: */
|
---|
| 77 | marshalled_dataset=*pmarshalled_dataset;
|
---|
| 78 |
|
---|
| 79 | /*get enum type of Numpar: */
|
---|
| 80 | enum_type=NumparEnum();
|
---|
| 81 |
|
---|
| 82 | /*marshall enum: */
|
---|
| 83 | memcpy(marshalled_dataset,&enum_type,sizeof(enum_type));marshalled_dataset+=sizeof(enum_type);
|
---|
| 84 |
|
---|
| 85 | /*marshall Numpar data: */
|
---|
| 86 | memcpy(marshalled_dataset,&id,sizeof(id));marshalled_dataset+=sizeof(id);
|
---|
| 87 | memcpy(marshalled_dataset,&meanvel,sizeof(meanvel));marshalled_dataset+=sizeof(meanvel);
|
---|
| 88 | memcpy(marshalled_dataset,&epsvel,sizeof(epsvel));marshalled_dataset+=sizeof(epsvel);
|
---|
| 89 | memcpy(marshalled_dataset,&artdiff,sizeof(artdiff));marshalled_dataset+=sizeof(artdiff);
|
---|
| 90 | memcpy(marshalled_dataset,&viscosity_overshoot,sizeof(viscosity_overshoot));marshalled_dataset+=sizeof(viscosity_overshoot);
|
---|
| 91 | memcpy(marshalled_dataset,&stokesreconditioning,sizeof(stokesreconditioning));marshalled_dataset+=sizeof(stokesreconditioning);
|
---|
| 92 | memcpy(marshalled_dataset,&cm_noisedampening,sizeof(cm_noisedampening));marshalled_dataset+=sizeof(cm_noisedampening);
|
---|
| 93 |
|
---|
| 94 | *pmarshalled_dataset=marshalled_dataset;
|
---|
| 95 | return;
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | int Numpar::MarshallSize(){
|
---|
| 99 | return sizeof(id)
|
---|
| 100 | +sizeof(meanvel)
|
---|
| 101 | +sizeof(epsvel)
|
---|
| 102 | +sizeof(artdiff)
|
---|
| 103 | +sizeof(viscosity_overshoot)
|
---|
| 104 | +sizeof(stokesreconditioning)
|
---|
| 105 | +sizeof(cm_noisedampening)
|
---|
| 106 | +sizeof(int); //sizeof(int) for enum type
|
---|
| 107 | }
|
---|
| 108 |
|
---|
| 109 | char* Numpar::GetName(void){
|
---|
| 110 | return "beam";
|
---|
| 111 | }
|
---|
| 112 |
|
---|
| 113 | void Numpar::Demarshall(char** pmarshalled_dataset){
|
---|
| 114 |
|
---|
| 115 | char* marshalled_dataset=NULL;
|
---|
| 116 | int i;
|
---|
| 117 |
|
---|
| 118 | /*recover marshalled_dataset: */
|
---|
| 119 | marshalled_dataset=*pmarshalled_dataset;
|
---|
| 120 |
|
---|
| 121 | /*this time, no need to get enum type, the pointer directly points to the beginning of the
|
---|
| 122 | *object data (thanks to DataSet::Demarshall):*/
|
---|
| 123 |
|
---|
| 124 | memcpy(&id,marshalled_dataset,sizeof(id));marshalled_dataset+=sizeof(id);
|
---|
| 125 | memcpy(&meanvel,marshalled_dataset,sizeof(meanvel));marshalled_dataset+=sizeof(meanvel);
|
---|
| 126 | memcpy(&epsvel,marshalled_dataset,sizeof(epsvel));marshalled_dataset+=sizeof(epsvel);
|
---|
| 127 | memcpy(&artdiff,marshalled_dataset,sizeof(artdiff));marshalled_dataset+=sizeof(artdiff);
|
---|
| 128 | memcpy(&viscosity_overshoot,marshalled_dataset,sizeof(viscosity_overshoot));marshalled_dataset+=sizeof(viscosity_overshoot);
|
---|
| 129 | memcpy(&stokesreconditioning,marshalled_dataset,sizeof(stokesreconditioning));marshalled_dataset+=sizeof(stokesreconditioning);
|
---|
| 130 | memcpy(&cm_noisedampening,marshalled_dataset,sizeof(cm_noisedampening));marshalled_dataset+=sizeof(cm_noisedampening);
|
---|
| 131 |
|
---|
| 132 | /*return: */
|
---|
| 133 | *pmarshalled_dataset=marshalled_dataset;
|
---|
| 134 | return;
|
---|
| 135 | }
|
---|
| 136 | int Numpar::Enum(void){
|
---|
| 137 |
|
---|
| 138 | return NumparEnum();
|
---|
| 139 |
|
---|
| 140 | }
|
---|
| 141 | int Numpar::GetId(void){ return id; }
|
---|
| 142 |
|
---|
| 143 | int Numpar::MyRank(void){
|
---|
| 144 | extern int my_rank;
|
---|
| 145 | return my_rank;
|
---|
| 146 | }
|
---|
| 147 |
|
---|
| 148 |
|
---|
| 149 | #undef __FUNCT__
|
---|
| 150 | #define __FUNCT__ "Numpar::Configure"
|
---|
| 151 | void Numpar::Configure(void* pparametersin){
|
---|
| 152 |
|
---|
| 153 | DataSet* parameters=NULL;
|
---|
| 154 |
|
---|
| 155 | /*Recover virtual pointer:*/
|
---|
| 156 | parameters=(DataSet*)pparametersin;
|
---|
| 157 |
|
---|
| 158 | /*Go through parameters dataset, and find the Param object corresponding to our fields,
|
---|
| 159 | * and update the fields: */
|
---|
| 160 | if(!parameters->FindParam(&meanvel,"meanvel"))throw ErrorException(__FUNCT__," error message: could not update meanvel field");
|
---|
| 161 | if(!parameters->FindParam(&epsvel,"epsvel"))throw ErrorException(__FUNCT__," error message: could not update epsvel field");
|
---|
| 162 | if(!parameters->FindParam(&artdiff,"artdiff"))throw ErrorException(__FUNCT__," error message: could not update artdiff field");
|
---|
| 163 | if(!parameters->FindParam(&viscosity_overshoot,"viscosity_overshoot"))throw ErrorException(__FUNCT__," error message: could not update viscosity_overshoot field");
|
---|
| 164 | if(!parameters->FindParam(&stokesreconditioning,"stokesreconditioning"))throw ErrorException(__FUNCT__," error message: could not update stokesreconditioning field");
|
---|
| 165 | if(!parameters->FindParam(&cm_noisedampening,"cm_noisedampening"))throw ErrorException(__FUNCT__," error message: could not update cm_noisedampening field");
|
---|
| 166 |
|
---|
| 167 | return;
|
---|
| 168 | }
|
---|
| 169 |
|
---|
| 170 |
|
---|
| 171 | #undef __FUNCT__
|
---|
| 172 | #define __FUNCT__ "Numpar::UpdateFromInputs"
|
---|
| 173 | void Numpar::UpdateFromInputs(void* vinputs){
|
---|
| 174 |
|
---|
| 175 | ParameterInputs* inputs=NULL;
|
---|
| 176 |
|
---|
| 177 | /*recover pointers: */
|
---|
| 178 | inputs=(ParameterInputs*)vinputs;
|
---|
| 179 |
|
---|
| 180 | /*Update internal data if inputs holds new values: */
|
---|
| 181 | inputs->Recover("meanvel",&meanvel);
|
---|
| 182 | inputs->Recover("epsvel",&epsvel);
|
---|
| 183 | inputs->Recover("artdiff",&artdiff);
|
---|
| 184 | inputs->Recover("viscosity_overshoot",&viscosity_overshoot);
|
---|
| 185 | inputs->Recover("stokesreconditioning",&stokesreconditioning);
|
---|
| 186 | inputs->Recover("cm_noisedampening",&cm_noisedampening);
|
---|
| 187 |
|
---|
| 188 | }
|
---|
| 189 |
|
---|
| 190 | Object* Numpar::copy() {
|
---|
| 191 |
|
---|
| 192 | return new Numpar(*this);
|
---|
| 193 |
|
---|
| 194 | }
|
---|
| 195 |
|
---|