hext_cu.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 static char const Id[] = "$Id: hext_cu.c 2962 2010-02-04 19:50:44Z scholz $\n\n";
00025 static char const Td[] = "$Today: " __FILE__ " " __DATE__ " " __TIME__ " $\n\n";
00026
00027 #include "field.h"
00028
00029 static int doinit=1;
00030 static int fieldon=0;
00031 static Vec VHthis;
00032 static PetscReal hextamp=0.5;
00033
00034 int Hext_cu_Init(GridData *gdata)
00035 {
00036 PetscTruth flg;
00037
00038 MagparFunctionLogBegin;
00039
00040 ierr = PetscOptionsGetInt(PETSC_NULL,"-hext_cu",(PetscInt*)&fieldon,&flg);CHKERRQ(ierr);
00041 if (flg!=PETSC_TRUE) {
00042 fieldon=0;
00043 PetscPrintf(PETSC_COMM_WORLD,
00044 "Option -hext_cu not found, using default value: %i (field off)\n",
00045 fieldon
00046 );
00047 }
00048 if (!fieldon) {
00049 PetscPrintf(PETSC_COMM_WORLD,"Hext_cu off\n");
00050 MagparFunctionLogReturn(0);
00051 }
00052 PetscPrintf(PETSC_COMM_WORLD,"Hext_cu on\n");
00053
00054 ierr = VecDuplicate(gdata->M,&VHthis);CHKERRQ(ierr);
00055
00056
00057
00058
00059
00060
00061 PetscReal *ta_Hext;
00062 ierr = VecGetArray(VHthis,&ta_Hext);CHKERRQ(ierr);
00063
00064
00065 for (int j=0; j<gdata->ln_vert; j++) {
00066
00067 if (
00068 gdata->vertxyz[ND*gdata->vertl2g[j]+0]>=65.0 &&
00069 gdata->vertxyz[ND*gdata->vertl2g[j]+0]<=250.0 &&
00070 gdata->vertxyz[ND*gdata->vertl2g[j]+1]>=192.0 &&
00071 gdata->vertxyz[ND*gdata->vertl2g[j]+1]<=310.0
00072 ) {
00073
00074
00075 PetscReal hextxyz[ND]={1.0,0.0,0.0};
00076 for (int i=0; i<ND; i++) {
00077 ta_Hext[ND*j+i]=hextxyz[i];
00078 }
00079 }
00080 else {
00081
00082 for (int i=0; i<ND; i++) {
00083 ta_Hext[ND*j+i]=0.0;
00084 }
00085 }
00086 }
00087 ierr = VecRestoreArray(VHthis,&ta_Hext);CHKERRQ(ierr);
00088
00089
00090 ierr = VecScale(gdata->VHext,hextamp);CHKERRQ(ierr);
00091
00092 MagparFunctionLogReturn(0);
00093 }
00094
00095
00096 int Hext_cu(GridData *gdata,Vec VHextsum,PetscReal *hext)
00097 {
00098 MagparFunctionInfoBegin;
00099
00100
00101
00102 if (doinit) {
00103 ierr = Hext_cu_Init(gdata);CHKERRQ(ierr);
00104 doinit=0;
00105 }
00106 if (!fieldon) {
00107 MagparFunctionInfoReturn(0);
00108 }
00109
00110 ierr = VecAXPY(VHextsum,1.0,VHthis);CHKERRQ(ierr);
00111
00112 *hext=hextamp;
00113
00114 MagparFunctionProfReturn(0);
00115 }
00116