41#ifdef DEBUG_SYSBOUNDARY
52 for(uint
i=0;
i<6;
i++) {
61 }
else if (it ==
"x-") {
63 }
else if (it ==
"y+") {
65 }
else if (it ==
"y-") {
67 }
else if (it ==
"z+") {
69 }
else if (it ==
"z-") {
106 for (uint
i = 0;
i < 6;
i++) {
126 const std::array<Real, 3>& gridSpacing,
127 const std::array<fsgrid::FsSize_t, 3>& globalCoordinates,
128 const fsgrid::FsStencil& stencil,
cuint component) {
137 bool isThisCellOnAFace[6];
140 for (uint
i = 0;
i < 6;
i++) {
141 if (isThisCellOnAFace[
i]) {
155 const fsgrid::FsStencil& stencil,
cuint component) {
160 const fsgrid::FsStencil& stencil,
cuint component) {
161 std::array<Real, fsgrids::ehall::N_EHALL>& cp = ehall[stencil.ooo()];
194 const fsgrid::FsStencil& stencil,
cuint RKCase,
cuint component) {
199 const fsgrid::FsStencil& stencil,
cuint component) {
204 const CellID& cellID,
const uint popID,
const bool doCalcMomentsV) {
213 const bool resetSolved) {
215 std::array<bool, 3> periodic_local = this->
periodic;
216 const auto templateB_local = this->
templateB;
217 fsgrid.parallel_for([](
int timerId) -> phiprof::Timer {
return phiprof::Timer{timerId}; },
218 phiprof::initializeTimer(
"setBFromTemplate"), technical,
219 [=](
const fsgrid::Coordinates &coordinates,
const fsgrid::FsStencil& stencil,
cuint sysBoundaryFlag,
cuint sysBoundaryLayer) {
221 creal dy =
P::dy_ini * pow(2, -technical[stencil.ooo()].refLevel);
222 creal dz =
P::dz_ini * pow(2, -technical[stencil.ooo()].refLevel);
224 std::array<bool, 6> isThisCellOnAFace = {{
false}};
225 const std::array<Real, 3> coords = coordinates.getPhysicalCoords(stencil.i, stencil.j, stencil.k);
226 const std::array<Real, 3> gridSpacing = coordinates.physicalGridSpacing;
228 determineFaceNoClassMembers(isThisCellOnAFace.data(), coords[0] + 0.5 * gridSpacing[0], coords[1] + 0.5 * gridSpacing[1], coords[2] + 0.5 * gridSpacing[2],
dx, dy, dz, periodic_local);
230 cuint bitfield = technical[stencil.ooo()].SOLVE;
232 for (uint iface = 0; iface < 6; iface++) {
233 if (facesToProcess_local[iface] && isThisCellOnAFace[iface]) {
253 #pragma omp parallel for schedule(dynamic, 1)
254 for (
size_t c = 0;
c < cells.size();
c++) {
266 bool isThisCellOnAFace[6];
269 for (uint
i = 0;
i < 6;
i++) {
287 for (uint
i = 0;
i < 6;
i++) {
295 for (uint
i = 0;
i < 6;
i++) {
308 vector<std::vector<Real>> dataset(0, std::vector<Real>(nParams, 0));
315 cerr <<
"Could not open input file " << fn <<
"!" << endl;
316 MPI_Abort(MPI_COMM_WORLD, 1);
321 while (getline(fi, line)) {
322 vector<Real> vars(nParams, -7777);
329 stringstream ss(line);
334 if (
i ==
int(nParams)) {
335 cerr <<
"Extra input values at line " << nlines + 1 <<
" in " << fn << endl;
336 MPI_Abort(MPI_COMM_WORLD, 1);
342 for (vector<Real>::iterator v = vars.begin(); v != vars.end(); ++v) {
343 if (fabs(*v + 7777.) < numeric_limits<double>::epsilon()) {
344 cerr <<
"Missing input values at line " << nlines + 1 <<
" in " << fn << endl;
345 MPI_Abort(MPI_COMM_WORLD, 1);
349 dataset.push_back(vars);
354 cerr <<
"Input file " << fn <<
" is empty!" << endl;
355 MPI_Abort(MPI_COMM_WORLD, 1);
356 }
else if (nlines > 1) {
357 for (uint
i = 1;
i < nlines; ++
i) {
358 if (dataset[
i][0] < dataset[
i - 1][0]) {
359 cerr <<
"Parameter data must be in ascending temporal order!" << endl;
360 MPI_Abort(MPI_COMM_WORLD, 1);
376 for (uint
i = 0;
i < 6;
i++) {
399 if (t < sP.
inputData[inputDataIndex][0][0]) {
403 for (uint
i = 0;
i < sP.
inputData[inputDataIndex].size();
i++) {
404 if (sP.
inputData[inputDataIndex][
i][0] >= t) {
418 s = (t - sP.
inputData[inputDataIndex][i1][0]) /
422 i1 = i2 = sP.
inputData[inputDataIndex].size() - 1;
430 outputData[
i] = s1 * sP.
inputData[inputDataIndex][i1][
i + 1] + s * sP.
inputData[inputDataIndex][i2][
i + 1];
spatial_cell::SpatialCell templateCells[6]
void interpolate(const int inputDataIndex, const uint popID, creal t, Real *outputData)
virtual void fieldSolverBoundaryCondElectricField(fsgrids::efieldspan e, const fsgrid::FsStencil &stencil, cuint component) override
virtual void fieldSolverBoundaryCondHallElectricField(fsgrids::ehallspan ehall, const fsgrid::FsStencil &stencil, cuint component) override
virtual void getFaces(bool *faces) override
virtual void vlasovBoundaryCondition(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const CellID &cellID, const uint popID, const bool doCalcMomentsV) override
void generateTemplateCells(creal t)
virtual void updateState(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, fsgrids::perbspan perb, fsgrids::bgbspan bgb, creal t) override
virtual void initSysBoundary(creal &t, Project &project) override
virtual void fieldSolverBoundaryCondDerivatives(fsgrids::dperbspan dperb, fsgrids::dmomentsspan dmoments, const fsgrid::FsStencil &stencil, cuint RKCase, cuint component) override
virtual void fieldSolverBoundaryCondBVOLDerivatives(fsgrids::volspan vols, const fsgrid::FsStencil &stencil, cuint component) override
std::vector< InflowSpeciesParameters > speciesParams
void setCellsFromTemplate(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const uint popID)
void loadInputData(const uint popID)
std::vector< std::string > faceList
virtual Real fieldSolverBoundaryCondMagneticField(fsgrids::perbspan b, fsgrids::constbgbspan bgb, fsgrids::consttechnicalspan technical, const std::array< Real, 3 > &gridSpacing, const std::array< fsgrid::FsSize_t, 3 > &globalCoordinates, const fsgrid::FsStencil &stencil, cuint component) override
virtual void applyInitialState(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, fsgrids::perbspan perb, fsgrids::bgbspan bgb, Project &project) override
void setBFromTemplate(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, fsgrids::perbspan perb, fsgrids::bgbspan bgb, fsgrids::technicalspan technical, FieldSolverGrid &fsgrid, const bool resetSolved)
std::vector< std::vector< Real > > loadFile(const char *file, unsigned int nParams)
virtual void fieldSolverBoundaryCondGradPeElectricField(fsgrids::egradpespan EGradPe, const fsgrid::FsStencil &stencil, cuint component) override
std::array< bool, 6 > facesToProcess
virtual void getParameters()
static void setCellBVOLDerivativesToZero(fsgrids::volspan vols, const fsgrid::FsStencil &stencil, cuint component)
void determineFace(bool *isThisCellOnAFace, const creal x, const creal y, const creal z, const creal dx, const creal dy, const creal dz, const bool excludeSlicesAndPeriodicDimensions=false) const
Function used to determine on which face(s) if any the cell at given coordinates is.
virtual void generateTemplateCell()
void copyCellData(const SpatialCell *from, SpatialCell *to, const bool copyMomentsOnly, const uint popID, const bool copy_V_moments)
static void setCellDerivativesToZero(fsgrids::dperbspan dperb, fsgrids::dmomentsspan dmoments, const fsgrid::FsStencil &stencil, cuint component)
std::array< bool, 3 > periodic
std::array< Real, CellParams::N_SPATIAL_CELL_PARAMS > parameters
void setReservation(const uint popID, const vmesh::LocalID reservationsize, bool force=false)
void abort_mpi(const std::string str, const int err_type)
const std::vector< CellID > & getLocalCells()
T convert(const T &number)
fsgrid::FsGrid< FS_STENCIL_WIDTH > FieldSolverGrid
void updateRemoteVelocityBlockLists(dccrg::Dccrg< SpatialCell, dccrg::Cartesian_Geometry > &mpiGrid, const uint popID, const uint neighborhood)
ObjectWrapper & getObjectWrapper()
void determineFaceNoClassMembers(bool *isThisCellOnAFace, creal x, creal y, creal z, creal dx, creal dy, creal dz, const std::array< bool, 3 > periodicity, const bool excludeSlicesAndPeriodicDimensions)
std::span< std::array< Real, fsgrids::bfield::N_BFIELD > > perbspan
std::span< const std::array< Real, bgbfield::N_BGB > > constbgbspan
std::span< std::array< Real, fsgrids::egradpe::N_EGRADPE > > egradpespan
std::span< std::array< Real, fsgrids::dmoments::N_DMOMENTS > > dmomentsspan
std::span< technical > technicalspan
std::span< std::array< Real, bgbfield::N_BGB > > bgbspan
std::span< std::array< Real, fsgrids::dperb::N_DPERB > > dperbspan
std::span< const technical > consttechnicalspan
std::span< std::array< Real, fsgrids::efield::N_EFIELD > > efieldspan
std::span< std::array< Real, fsgrids::volfields::N_VOL > > volspan
std::span< std::array< Real, fsgrids::ehall::N_EHALL > > ehallspan
std::vector< species::Species > particleSpecies
std::vector< std::vector< Real > > inputData[6]