📄 spatialg.cpp
字号:
//spatialg.cpp#include "advisman.h"#include "spatialg.h"#include "abswag.h"#include "lnchwag.h"#include "speciesg.h"#include "maxwelln.h"#include "fields.h"#include "diags.h"#include "mcc.h"#include "loadg.h"#include "varloadg.h"#include "diagg.h"#include "sptlrgn.h"#include "conductg.h"#include "cylaxisg.h"#include "femitg.h"#include "bemitg.h"#include "fowler_nordheim_emit_g.h"#include "vbemitg.h"#include "plsmsrcg.h"#include "laserplasmasrcg.h"#include "eportg.h"#include "portteg.h"#include "porttmg.h"#include "portgaussg.h"#include "gapg.h"#include "eqpotg.h"#include "foilg.h"#include "emitprtg.h"#include "polarg.h"#include "iloopg.h"#include "iregiong.h"#include "varg.h"#include "spboundg.h"#include "spemitg.h"#include "periodic.h"#include "ptclgrp.h"#include "porttemmwg.h"#include "loadpwg.h"#include "cursrcg.h"#if defined(_MSC_VER)extern "C" int WasDumpFileGiven;#elseextern int WasDumpFileGiven;#endifvoid Restore(SpatialRegion*); extern "C++" void printf(char *);#ifdef MPI_VERSION#include "mpi.h"extern MPI_Comm XOOPIC_COMM;extern int MPI_RANK;#define SRB_ANNOUNCE_TAG 100#define SRB_LINK_TAG 200typedef struct { char *name; int index; int linkedP;} SRBdat;#endif
using namespace std;//=================== SpatialRegionGroup Classostring SpatialRegionGroup::CreateParamGroup(ifstream &fin, ostring &groupname) throw(Oops){ ostring message; if (groupname ==(ostring) "Grid") message = GP.InitializeFromStream(fin); else if (groupname == (ostring)"Variables") message = VG.InitializeFromStream(fin); else if (groupname == (ostring)"Control") message = CP.InitializeFromStream(fin); else if (groupname == (ostring)"ParticleGroup") message = PGP.InitializeFromStream(fin); else if (groupname == (ostring)"Species") message = readSpecies(fin); else if (groupname == (ostring)"MCC") message = AddMCCParamsList(fin); else if ( groupname == (ostring)"Load" ) message = AddLoadParamsList(fin); else if ( groupname == (ostring)"Load_PW") message = AddLoadPWParamsList(fin); else if ( groupname == (ostring)"VarWeightLoad" ) message = AddVarWeightLoadParamsList(fin); else if (groupname == (ostring)"Diagnostic") message = AddDiagParamsList(fin); else if (advisorp->KnownBoundary(groupname)){ try{ message = CreateBoundaryParams(fin, groupname); } catch(Oops& oops3){
oops3.prepend("SpatialRegionGroup::CreateParamGroup: Error: \n");
throw oops3;
} } else if (groupname == (ostring)"H5Diagnostic") message = AddH5DiagDumpParamsList(fin); else message = "Unknown name ecountered for parameterGroup in input deck"; return(message);}ostring SpatialRegionGroup::CreateBoundaryParams(ifstream &fin, ostring groupname)throw(Oops){ BoundaryParams* bptr = 0; try{ bptr = constructBoundaryParams(groupname); } catch(Oops& oops2){
oops2.prepend("SpatialRegionGroup::CreateBoundaryParams: Error: \n");//done
throw oops2;
} ostring message("WARNING: Invalid boundary type was requested!"); if (bptr) { message = bptr->InitializeFromStream(fin); Boundaries.add(bptr); } return(message);}ostring SpatialRegionGroup::AddMCCParamsList(ifstream& fin){ MCCParams* mPtr = new MCCParams(this); ostring message = mPtr->InitializeFromStream(fin); MCCParamsList.add(mPtr); return message;}ostring SpatialRegionGroup::AddLoadParamsList(ifstream &fin){ LoadParams* lptr = new LoadParams(this); ostring message = lptr->InitializeFromStream(fin); Loads.add(lptr); return(message);}ostring SpatialRegionGroup::AddLoadPWParamsList(ifstream &fin){ LoadPWParams* lptr = new LoadPWParams(this); ostring message = lptr->InitializeFromStream(fin); Loads.add(lptr); return(message);}ostring SpatialRegionGroup::AddVarWeightLoadParamsList(ifstream &fin){ VarWeightLoadParams* lptr = new VarWeightLoadParams(this); ostring message = lptr->InitializeFromStream(fin); Loads.add(lptr); return(message);}ostring SpatialRegionGroup::AddDiagParamsList(ifstream &fin){ DiagParams* dptr = new DiagParams(&(this->GP),this); ostring message = dptr->InitializeFromStream(fin); Diags.add(dptr); return(message);}ostring SpatialRegionGroup::AddH5DiagDumpParamsList(ifstream &fin) { H5DiagParams* dptr = new H5DiagParams(); ostring message = dptr->InitializeFromStream(fin); H5DiagDumpParams.add(dptr); return(message); }void SpatialRegionGroup::describe(){ cout << "testing echoFlag..." << endl; if (CP.get_echoFlag()==0) {cout << "echoFlag=0" << endl; return;} GP.describe(); CP.describe(); PGP.describe(); { oopicListIter<LoadParams> nL(Loads); for (nL.restart(); !nL.Done(); nL++) nL.current()->describe(); } { oopicListIter<DiagParams> nD(Diags); for (nD.restart(); !nD.Done(); nD++) nD.current()->describe(); } { oopicListIter<BoundaryParams> nB(Boundaries); for (nB.restart(); !nB.Done(); nB++) nB.current()->describe(); }}void SpatialRegionGroup::writeOutputFile(ofstream &fout){GP.writeOutputFile(fout); CP.writeOutputFile(fout); oopicListIter<BoundaryParams> nB(Boundaries); for (nB.restart(); !nB.Done(); nB++) {nB.current()->writeOutputFile(fout);}}void SpatialRegionGroup::checkRules(){}SpatialRegion* SpatialRegionGroup::CreateCounterPart() throw(Oops){ if (CP.getFrandseed()) frandseed = CP.getFrandseed(); GP.checkRules(); GP.showRuleMessages(); CP.checkRules(); CP.showRuleMessages(); Grid *G;#ifdef MPI_VERSION int MPI_MAX_RANK; MPI_Comm_size(XOOPIC_COMM,&MPI_MAX_RANK); if (MPI_MAX_RANK > 1) { // if we have more than one region.#ifdef MPI_DEBUG printf("\n%d: Creating grid with %d partitions.",MPI_RANK,MPI_MAX_RANK);#endif G = GP.CreateCounterPart(CP.getMPIpartition()); } else#endif /* MPI_VERSION */ G = GP.CreateCounterPart(); oopicList<Boundary> *BList = new BoundaryList; //put the periodic boundary on the boundary list MUST BE FIRST HERE SO THAT IT IS LAST IN PHYSICS if ((GP.getPeriodicFlagX1())||(GP.getPeriodicFlagX2())){ oopicList<LineSegment> *LineSegmentList = new oopicList<LineSegment>; LineSegment *newSeg = new LineSegment(Vector2(0,0),Vector2(GP.getJ(),GP.getK()),1); LineSegmentList->add(newSeg); Boundary* B = new Periodic(LineSegmentList, GP.getPeriodicFlagX1(), GP.getPeriodicFlagX2()); BList->add(B); } oopicListIter<BoundaryParams> nB(Boundaries); for (nB.restart(); !nB.Done(); nB++) { BoundaryParams *bParam=nB.current(); try{ bParam->toGrid(G); //cause the boundary to 'snap to' j,k's if given MKS // moved toGrid to checkRules because some of the rules are for j1,j2,k1,k2. // moved back to CreateCounter Part and removed checkRules } catch(Oops& oops){
oops.prepend("SpatialRegionGroup::CreateCounterPart: Error:\n"); //AdvisorManager::createDevice
throw oops;
}
#ifdef MPI_VERSION if(! (bParam->j1.getValue()==-1 && bParam->A1.getValue()==-1)) { // we don't want to create boundaries which are out-of-bounds!#endif /* MPI_VERSION */ bParam->checkRules(); bParam->showRuleMessages(); Boundary* bPtr = 0; try{ bPtr = bParam->CreateCounterPart(); } catch(Oops& oops2){
oops2.prepend("SpatialRegionGroup::CreateCounterPart: Error: \n");//done
throw oops2;
} bParam->setBoundaryParams(bPtr); //should probably cascade CreateCounterPart() BList->add(bPtr);#ifdef MPI_VERSION }#endif /*MPI_VERSION */ } // Move this call here. It saves trouble with deciding where to put any SRB's. G->setBoundaryMask(*BList);#ifdef MPI_VERSION /* At this point, we should add all the necessary SRB's to our region. */ try{ addNeededSRBstoRegion(BList,G); } catch(Oops& oops3){
oops3.prepend("SpatialRegionGroup::CreateCounterPart: Error: \n");
throw oops3;
}#endif /*MPI_VERSION*/ SpeciesParamsList* speciesParamsList = advisorp->get_speciesParamsList(); int tmpDim = speciesParamsList->nItems(); ParticleGroupList** pgListArray = new ParticleGroupList*[tmpDim]; for (int i=0; i<tmpDim; i++) pgListArray[i] = new ParticleGroupList; SpeciesList* speciesList = advisorp->get_speciesList(); Scalar epsilonR = 1.0; Fields *F = new Fields(G, BList, speciesList, epsilonR, CP.getElectrostaticFlag(),CP.get_presidue(), CP.getBoltzmannFlag(),CP.getSynchRadiationFlag()); F->set_bSpecies(get_speciesPtr(CP.getBoltzSpecies())); if (!F->setBNodeStatic(Vector3(CP.getB01(),CP.getB02(),CP.getB03()), CP.getbetwig(), CP.getzoff(),CP.getBf().c_str(), CP.getB01analytic(),CP.getB02analytic(), CP.getB03analytic())) abort();; F->setBeamDump(CP.get_j1BeamDump(), CP.get_j2BeamDump()); F->setMarderIter(CP.getMarderIter()); F->setDivergenceCleanFlag(CP.getDivergenceCleanFlag()); F->setCurrentWeightingFlag(CP.getCurrentWeighting()); F->set_freezeFields(CP.get_FreezeFields()); F->setNonRelativisticFlag(CP.getNonRelativisticFlag()); F->set_nSmoothing(CP.get_nSmoothing()); F->setInfiniteBFlag(CP.getInfiniteBFlag()); F->setFieldSubFlag(CP.getFieldSubFlag()); F->setMarderParameter(CP.getMarderParameter()); F->setEMdamping(CP.getEMdamping()); if ( (CP.getElectrostaticFlag()) && (CP.getBoltzmannFlag()) ) { Species* species = get_speciesPtr(CP.getBoltzSpecies()); Boltzmann* boltzmann= new Boltzmann(F,CP.getBoltzmannTemp(), species, CP.getBoltzmannEBFlag()); F->setBoltzmann(boltzmann); } MCC* mcc = 0; MCTI* mcti = 0; SpatialRegion *region = new SpatialRegion(F,BList, pgListArray, speciesList, mcc, mcti, get_dt()); if (MCCParamsList.nItems() > 0) { mcc = new MCC; mcti = new MCTI; oopicListIter<MCCParams> mIter(MCCParamsList); for (mIter.restart(); !mIter.Done(); mIter++) { mIter()->checkRules(); mIter()->showRuleMessages(); try{ mIter()->CreateCounterPart(region, mcc, mcti); } catch(Oops& oops2){
oops2.prepend("SpatialRegionGroup::CreateCounterPart: Error: \n");//OK
throw oops2;
} /** * note the difference in the call to * CreateCoungerPart(...) in the line of code above * from its earlier use: * mcc->addPackage(mIter()->CreateCounterPart(region)); * which was the case when tunneling ionization was not * coded. For the tunneling ionization we have a class * MCTI analogous to the MCC class and the pointers to * these two classes are now passed to the * CreateCounterPart for proper initialization of the * list objects these clases contain. * dad: 12/20/2000. */ } region->setMCC(mcc); region->setMCTI(mcti); region->setNGDListPtrs();#ifdef MPI_VERSION // // allocate memory for the buffers in the SpatialRegionBoundary // objects for the NGD data // oopicListIter<Boundary> nextb(*BList); for(nextb.restart(); !nextb.Done(); nextb++) nextb.current()->allocMemNGDbuffers();#endif // MPI_VERSION }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -