00001 #include<config.h>
00002 CPS_START_NAMESPACE
00008
00009
00010
00011
00012 CPS_END_NAMESPACE
00013 #include <alg/w_all.h>
00014 #include <alg/w_gamma_mat.h>
00015 #ifdef PARALLEL
00016 #include <comms/sysfunc_cps.h>
00017 #endif
00018 #include <util/error.h>
00019 #include <util/qcdio.h>
00020 #include <util/verbose.h>
00021 #include <util/vector.h>
00022 #include <comms/glb.h>
00023 #include <alg/alg_w_spect.h>
00024 #include <comms/cbuf.h>
00025
00026 CPS_START_NAMESPACE
00027
00028
00029 #define DEBUG_W_EXT_MESON_BE
00030
00031 #define MATRIX_SIZE 18
00032
00033
00034
00035
00036
00037
00038
00039
00040 char *WspectExtendedMesonsBE::d_class_name="WspectExtendedMesonsBE";
00041 int WspectExtendedMesonsBE::tableInitialized=0;
00042 struct WMesonBEOpInfo
00043 WspectExtendedMesonsBE::WMesonOpTable[NUM_WEXTMESON_BE_OPS];
00044 struct WMesonBEStateInfo
00045 WspectExtendedMesonsBE::WMesonStateTable[NUM_WEXTMESON_BE_STATES];
00046
00047
00048
00049
00050 WspectExtendedMesonsBE::WspectExtendedMesonsBE(WspectArg *w_arg_p,
00051 const WspectHyperRectangle & whr,
00052 const int fuzzing_id,
00053 const WspectField *field_ptr)
00054 : WspectExtendedMesons(w_arg_p,whr,fuzzing_id),field_p(field_ptr){
00055
00056
00057
00058
00059 d_size = d_glb_walls* NUM_WEXTMESON_BE_STATES * COMPLEXs;
00060 d_output_size = d_glb_walls* NUM_WEXTMESON_BE_OUTPUT * COMPLEXs;
00061
00062 coor_data_p = (Complex *) smalloc(d_size * sizeof(Float));
00063 if (!coor_data_p)
00064 ERR.Pointer(d_class_name, ctor_str, "coor_data_p");
00065 VRB.Smalloc(d_class_name, ctor_str,
00066 "coor_data_p", coor_data_p, d_size * sizeof(Float));
00067 {
00068
00069 Float *flt_p = (Float *)coor_data_p;
00070 for (int i = 0; i < d_size; ++i)
00071 *flt_p++ = 0.0;
00072 }
00073
00074 coor_output_p = (Complex *) smalloc(d_output_size * sizeof(Float));
00075 if (!coor_output_p)
00076 ERR.Pointer(d_class_name, ctor_str, "coor_output_p");
00077 VRB.Smalloc(d_class_name, ctor_str,
00078 "coor_output_p", coor_output_p, d_output_size * sizeof(Float));
00079 {
00080
00081 Float *flt_p = (Float *)coor_output_p;
00082 for (int i = 0; i < d_output_size; ++i)
00083 *flt_p++ = 0.0;
00084 }
00085
00086
00087
00088
00089 {
00090
00092
00093
00094
00095 for(int i=0;i<NUM_WEXTMESON_BE_STATES;i++){
00096 map[i]=i;
00097 }
00098 }
00099
00100
00101 if(!tableInitialized){
00102 initWMesonOpTable();
00103 initWMesonStateTable(arg_p);
00104 tableInitialized=1;
00105 }
00106
00107 }
00108
00109
00110
00111
00112 WspectExtendedMesonsBE::~WspectExtendedMesonsBE(){
00113
00114 VRB.Func(d_class_name, dtor_str);
00115
00116 VRB.Sfree(d_class_name, dtor_str, empty_str, coor_data_p);
00117 sfree(coor_data_p);
00118
00119
00120 VRB.Sfree(d_class_name, dtor_str, empty_str, coor_output_p);
00121 sfree(coor_output_p);
00122
00123
00124
00125 }
00126
00127
00128
00129
00130
00131
00132 void WspectExtendedMesonsBE::collect(const WspectQuark &q_l, WspectQuark &q_nl){
00133
00134 char *fname="collect";
00135 VRB.Func(d_class_name, fname);
00136
00137 DEVOperatorKind sour_op;
00138 sour_op=q_nl.srcOpKind();
00139
00140 #ifdef DEBUG_W_EXT_MESON_BE
00141 printf("colleting BE extmesons - source operator = %d \n", sour_op);
00142 #endif
00143
00144 const Float *ql_p=(Float *)q_l.Data();
00145 const Float *qnl_p=(Float *)q_nl.Data();
00146
00147 for(int sink_op=BEGIN_BE_OP+1; sink_op < END_BE_OP; sink_op++){
00148
00149 Float weight_test=0.;
00150 int state=0;
00151
00152 while (weight_test==0. && state <NUM_WEXTMESON_BE_STATES ){
00153 weight_test = table(state, -1, sour_op, -1, sink_op);
00154 state += 1;
00155 }
00156
00157 if (weight_test == 0.) continue;
00158
00159 int lclWalls=lcl_sites[d_prop_dir];
00160 for(int lclW=0;lclW<lclWalls;lclW++){
00161 DiracAlgebra(ql_p,qnl_p,lclW, sour_op, sink_op);
00162 }
00163 }
00164 return;
00165
00166 }
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 void WspectExtendedMesonsBE::finish(){
00182
00183 #ifdef DEBUG_W_EXT_MESON_BE
00184 printf("finish().Do global sum.\n");
00185 #endif
00186 Float *Flt_p = (Float *)coor_data_p;
00187 for (int i = 0; i < d_size; ++i) glb_sum(Flt_p++);
00188
00189 }
00190
00191
00192
00193
00194 void WspectExtendedMesonsBE::print()const{
00195
00196 #if TARGET==cpsMPI
00197 using MPISCU::fprintf;
00198 #endif
00199 char *fname = "print";
00200 char outputfilename[100];
00201 VRB.Func(d_class_name, fname);
00202
00203
00204
00205 {
00206 for(int wall=0;wall< d_glb_walls;wall++){
00207 int offset_data_wall=wall*NUM_WEXTMESON_BE_STATES;
00208 int offset_output_wall=wall*NUM_WEXTMESON_BE_OUTPUT;
00209 int num_pol;
00210
00211
00212
00213 for(int mesonId=0;mesonId<NUM_WEXTMESON_BE_OUTPUT;mesonId++){
00214
00215
00216 num_pol=0;
00217 int output_offset=offset_output_wall+mesonId;
00218 for(int mesonState=0;mesonState<NUM_WEXTMESON_BE_STATES;mesonState++){
00219
00220 if(WMesonStateTable[mesonState].mesonId!=mesonId){
00221 continue;
00222 }
00223
00224 num_pol++;
00225
00226 if(WMesonStateTable[mesonState].measure==0) {
00227
00228 break;
00229 }
00230
00231
00232 int data_offset=offset_data_wall+map[mesonState];
00233 coor_output_p[output_offset]+=coor_data_p[data_offset];
00234 }
00235
00236
00237 if(num_pol!=0) coor_output_p[output_offset]/=num_pol;
00238 }
00239 }
00240 }
00241
00242
00243
00244 FILE *fp;
00245 for (int meson = 0; meson < NUM_WEXTMESON_BE_OUTPUT; ++meson) {
00246
00247
00248 int measure_flag=0;
00249
00250
00251 for(int state=0;state<NUM_WEXTMESON_BE_STATES;state++){
00252 if(WMesonStateTable[state].mesonId==meson){
00253 if(WMesonStateTable[state].measure) {
00254 measure_flag=1;
00255 if(!arg_p->fuzzing_on){
00256
00257 sprintf(outputfilename,"%s",WMesonStateTable[state].stateName);
00258 }else{
00259
00260
00261 sprintf(outputfilename,"%sF%.1f",WMesonStateTable[state].stateName,arg_p->fuzzing_c[fuzzing_c_index]);
00262 }
00263 break;
00264 }
00265 }
00266 }
00267
00268 if(measure_flag){
00269 #ifdef DEBUG_W_EXT_MESON
00270 printf("Writing extended meson#%d data to file %s\n",meson,outputfilename);
00271 #endif
00272
00273 if ( !(fp = Fopen(outputfilename, "a")) )
00274 ERR.FileA(d_class_name,fname, outputfilename);
00275
00276 for (int wall = 0; wall <= d_glb_walls/2; ++wall) {
00277
00278 Complex tmp = coor_output_p[meson + NUM_WEXTMESON_BE_OUTPUT*
00279 ((d_whr.glbCoord() + wall)%d_glb_walls)];
00280 tmp += coor_output_p[meson + NUM_WEXTMESON_BE_OUTPUT*
00281 ((d_whr.glbCoord() + d_glb_walls - wall)%d_glb_walls)];
00282 tmp /= 2.0;
00283
00284
00285 Fprintf(fp, "%d %d %d %.10e\n",
00286 AlgWspect::GetCounter(), wall, 0, tmp.real());
00287 }
00288 Fclose(fp);
00289 }
00290 }
00291
00292 }
00293
00294
00295
00296
00297
00298 Float WspectExtendedMesonsBE::table(int state, int sour_gamma, int sour_op, int sink_gamma, int sink_int) const{
00299 return 0;
00300
00301 }
00302
00303 int WspectExtendedMesonsBE::isInOpGroup(int op, int groupId) const{
00304 char *fname="isInOpGroup";
00305 int result=0;
00306 switch(groupId){
00307 case 0:
00308 if(op>=FB1_OP && op<=FUNIT_OP) result=1;
00309 break;
00310 case 1:
00311 if(op==SUM_MAGN_OP || op==SUM_ELEC_OP || op == FUNIT) result=1;
00312 break;
00313 case 2:
00314 if(op==SUM_MAGN_ELEC_OP ||
00315 op==SUM_S_SYM || op==SUM_S_DIAG) result= 1;
00316 break;
00317 case 3:
00318 if(op==UNIT || op==SUM_F_S_ANTISYM ||
00319 op==SUM_S_SYM_DIAG) result=1;
00320 break;
00321 case 4:
00322 if(op==SUM_UNIT_F_S_ANTISYM ||
00323 op==SUM_S_SYM_DIAG) result= 1;
00324 break;
00325
00326 default:
00327 ERR.General(d_class_name, fname, "invalid grpId");
00328 }
00329
00330 return result;
00331 }
00332
00333 int WspectExtendedMesonsBE::matchSUMOp(int op, int sum_op) const{
00334
00335 return 0;
00336 }
00337
00338
00339
00340
00341
00342 void WspectExtendedMesonsBE::initWMesonStateTable(WspectArg *arg){
00343
00344 WMesonStateTable[BE_MS_pionxB_x].stateName="BEpionxB";
00345 WMesonStateTable[BE_MS_pionxB_x].mesonId=BE_pionxB;
00346 WMesonStateTable[BE_MS_pionxB_x].category=MAG_HYBRID_BE;
00347 WMesonStateTable[BE_MS_pionxB_x].polarization=0;
00348 WMesonStateTable[BE_MS_pionxB_x].measure=0;
00349 WMesonStateTable[BE_MS_pionxB_x].srcOp=BE_MO_pionxB_x;
00350 WMesonStateTable[BE_MS_pionxB_x].sinkOp=BE_MO_pionxB_x;
00351
00352 WMesonStateTable[BE_MS_pionxB_y]=WMesonStateTable[BE_MS_pionxB_x];
00353 WMesonStateTable[BE_MS_pionxB_y].polarization=1;
00354 WMesonStateTable[BE_MS_pionxB_y].srcOp=BE_MO_pionxB_y;
00355 WMesonStateTable[BE_MS_pionxB_y].sinkOp=BE_MO_pionxB_y;
00356
00357 WMesonStateTable[BE_MS_pionxB_z]=WMesonStateTable[BE_MS_pionxB_x];
00358 WMesonStateTable[BE_MS_pionxB_z].polarization=1;
00359 WMesonStateTable[BE_MS_pionxB_z].srcOp=BE_MO_pionxB_z;
00360 WMesonStateTable[BE_MS_pionxB_z].sinkOp=BE_MO_pionxB_z;
00361
00362
00363 WMesonStateTable[BE_MS_rhoxB_T1_x].stateName="BErhoxB_T1";
00364 WMesonStateTable[BE_MS_rhoxB_T1_x].mesonId=BE_rhoxB_T1;
00365 WMesonStateTable[BE_MS_rhoxB_T1_x].category=MAG_HYBRID_BE;
00366 WMesonStateTable[BE_MS_rhoxB_T1_x].polarization=0;
00367 WMesonStateTable[BE_MS_rhoxB_T1_x].measure=0;
00368 WMesonStateTable[BE_MS_rhoxB_T1_x].srcOp=BE_MO_rhoxB_T1_x;
00369 WMesonStateTable[BE_MS_rhoxB_T1_x].sinkOp=BE_MO_rhoxB_T1_x;
00370
00371 WMesonStateTable[BE_MS_rhoxB_T1_y]=WMesonStateTable[BE_MS_rhoxB_T1_x];
00372 WMesonStateTable[BE_MS_rhoxB_T1_y].polarization=1;
00373 WMesonStateTable[BE_MS_rhoxB_T1_y].srcOp=BE_MO_rhoxB_T1_y;
00374 WMesonStateTable[BE_MS_rhoxB_T1_y].sinkOp=BE_MO_rhoxB_T1_y;
00375
00376 WMesonStateTable[BE_MS_rhoxB_T1_z]=WMesonStateTable[BE_MS_rhoxB_T1_x];
00377 WMesonStateTable[BE_MS_rhoxB_T1_z].polarization=1;
00378 WMesonStateTable[BE_MS_rhoxB_T1_z].srcOp=BE_MO_rhoxB_T1_z;
00379 WMesonStateTable[BE_MS_rhoxB_T1_z].sinkOp=BE_MO_rhoxB_T1_z;
00380
00381
00383 for(int stateId=0;stateId<NUM_WEXTMESON_BE_STATES;stateId++){
00384 int cat=WMesonStateTable[stateId].category;
00385 WMesonStateTable[stateId].measure=1;
00386 }
00387 }
00388
00389
00390
00391
00392 void WspectExtendedMesonsBE::initWMesonOpTable(){
00393
00394
00395 WMesonOpTable[BE_MO_pionxB_x].num_terms=1;
00396 setWMesonOpTerm(&(WMesonOpTable[BE_MO_pionxB_x].terms[0][0]),1,WGAM_5,FB1);
00397
00398 WMesonOpTable[BE_MO_pionxB_y].num_terms=1;
00399 setWMesonOpTerm(&(WMesonOpTable[BE_MO_pionxB_y].terms[0][0]),1,WGAM_5,FB2);
00400
00401 WMesonOpTable[BE_MO_pionxB_z].num_terms=1;
00402 setWMesonOpTerm(&(WMesonOpTable[BE_MO_pionxB_z].terms[0][0]),1,WGAM_5,FB3);
00403
00404
00405 WMesonOpTable[BE_MO_rhoxB_T1_x].num_terms=2;
00406 setWMesonOpTerm(&(WMesonOpTable[BE_MO_rhoxB_T1_x].terms[0][0]),1,WGAM_2,FB3);
00407 setWMesonOpTerm(&(WMesonOpTable[BE_MO_rhoxB_T1_x].terms[1][0]),-1,WGAM_3,FB2);
00408
00409 WMesonOpTable[BE_MO_rhoxB_T1_y].num_terms=2;
00410 setWMesonOpTerm(&(WMesonOpTable[BE_MO_rhoxB_T1_y].terms[0][0]),1,WGAM_3,FB1);
00411 setWMesonOpTerm(&(WMesonOpTable[BE_MO_rhoxB_T1_y].terms[1][0]),-1,WGAM_1,FB3);
00412
00413 WMesonOpTable[BE_MO_rhoxB_T1_z].num_terms=2;
00414 setWMesonOpTerm(&(WMesonOpTable[BE_MO_rhoxB_T1_z].terms[0][0]),1,WGAM_1,FB2);
00415 setWMesonOpTerm(&(WMesonOpTable[BE_MO_rhoxB_T1_z].terms[1][0]),-1,WGAM_2,FB1);
00416
00417
00418 }
00419
00420
00421
00422
00423 void WspectExtendedMesonsBE::setWMesonOpTerm(int *term_p, int weight, WGammaMatrix gammaMat, FieldTensorId fieldId){
00424 term_p[0]=weight;
00425 term_p[1]=gammaMat;
00426 term_p[2]=fieldId;
00427 }
00428
00429
00430
00431 CPS_END_NAMESPACE