Electromagnetic Template Library (EMTL)
Loading...
Searching...
No Matches
fix.h File Reference

Each mesh provides basic update procedure for dielectric medium (e.g. More...

#include <vector>
#include <cstring>
#include <tuple>
#include <type_traits>
#include <bitset>
#include <math.h>
#include <cstdint>
#include "emdefs.h"
#include "alignedallocator.h"
#include "ctlist.h"
#include "seqpack.h"
Include dependency graph for fix.h:
This graph shows which files directly or indirectly include this file:

Classes

class  emFixStorage
 emFixStorage is aligned storage for fix local data, i.e. More...
 
class  emFakeStorage
 Like emFixStorage but doesn't actually store anything. More...
 
class  FixStorageCopyJoinInterface
 emFixStorage interface for LocalPointer. More...
 
struct  emFixRecorderBefore
 Helper structure, that calls record_before for each fix local data instance in FixTypeLocalList. More...
 
struct  emFixRecorderNonlocal
 Helper structure, that calls record_nonlocal for each fix local data instance in FixTypeLocalList. More...
 
struct  emFixRecorderAfter
 Helper structure, that calls record_after for each fix local data instance in FixTypeLocalList. More...
 
struct  Stepper_local_before
 Helper class to call Step for all Fixes in FixTypeList. More...
 
struct  Stepper_local_after
 Helper class to call Step for all Fixes in FixTypeList. More...
 
struct  Stepper_nonlocal
 Helper class to call Step for all Fixes in FixTypeList. More...
 

Enumerations

enum  InitPassStage : int
 Initialization passes stages. More...
 

Functions

template<class solver_t >
int solver_step (emtype *ptr, refvector< pack_t< indtype, indtype >::data > &inds, refvector< solver_t > &solver, int(solver_t::*function)(const typename solver_t::iterator &data, emtype *out))
 apply chosen function of the solver to indices of array ptr packed in the packer inds.
 
template<typename CTL , typename T , typename ... IArgs>
void append (CTL &ctl, IArgs &&... iargs)
 Template to forward append method to corresponding append function of a fix.
 

Detailed Description

Each mesh provides basic update procedure for dielectric medium (e.g.

Yee procedure for rectangular mesh). This repeatedly executed bulk update takes usually the major part of CPU time and should be optimized separately for each mesh type. In the space regions where dispersive or nonlinear materials, absorbing boundary conditions, etc. are located, special algorithms should be applied Traditionally these algorithms are included in basic procedure: (1) each algorithm is represented by some flag, (2) this flag is tested in the basic update procedre to find if corresponding algorithm should be applied.

In EMTL we use different approach: each algorithm is performed separately from the update procedure as a "fix". Separation basic update procefure from fix allows more efficient implementation of the former.

Each different types of fixes are implemented as separate classes. These classes store all necessary information about special contours (contours inside dispersive medium, PML, etc.) and apply fix algorithm to them.

All fix classes share common interface to work with them, which assumes 3 stages reflected in the value of the flag rec_state.

  1. Intialization using function init (rec_state=0)
  2. Record data necessary to apply fix, function record (rec_state=1). Each fix can request different data (contours, their location correspondingly to TF/SF/ border and some media, etc.). After all data is recorded, one should call function end_record, and record cannot be resumed. However, one can call function clear and start record again.
  3. Application of a fix algorithm to recorded data using function step (rec_state=2). There are possible functions step_before and step_after for the case if fix should be applied before and after basic update procedure.

In fix algorithm requires parallel MPI transfers, it contains functions: prepare_transfers - prepare MPI transfers start_transfers - start MPI transfers complete_transfers - complete MPI transfers prepare_next_iteration - prepare for the next iteration in the case of iterative FDTD techniques (e.g. iterative technique for oblique incidence).

Function prepare_transfers should be called once after record of the data is complete. Functions start_transfers and complete_transfers are called at the each time step.

Fix class can store auxilliary mesh arrays (e.g., for current J in the case of dispersive medium). One can use function ClearMesh to fill these arrays with zero.

Sometimes, fix classes contain some packers (e.g., emFixCoefs in emFixSourceTFSF). They pack some specific data and have iterators which are used in the function step.

Objects of fix classes emFixSmth are stored in bdescr (which are stored in emBlockContainer). Function emBlockContainer::StepSmth calls emFixSmth::step for objects of the type emFixSmth stored in bdescr.

Enumeration Type Documentation

◆ InitPassStage

enum InitPassStage : int

Initialization passes stages.

If a pass is not set, fix specific actions like prepare_parallel_init, join_parallel_init, or release_init_resources are not performed for this pass

Function Documentation

◆ append()

template<typename CTL , typename T , typename ... IArgs>
void append ( CTL &  ctl,
IArgs &&...  iargs 
)

Template to forward append method to corresponding append function of a fix.

It will cause an error if it's called for a Fix type which doesn't have append method.

◆ solver_step()

template<class solver_t >
int solver_step ( emtype *  ptr,
refvector< pack_t< indtype, indtype >::data > &  inds,
refvector< solver_t > &  solver,
int(solver_t::*)(const typename solver_t::iterator &data, emtype *out)  function 
)

apply chosen function of the solver to indices of array ptr packed in the packer inds.

this procedure is used in emFixDispersion, emFixUPML.