ivutils
Loading...
Searching...
No Matches
region_3.hpp File Reference

Template function definitions for region.h. More...

#include <limits>
#include <utility>
#include "region_3.h"
#include "region_2.hpp"
Include dependency graph for region_3.hpp:

Functions

template<int N, class contour_t >
vec_type MonteCarloTestContour (const Region< N > *reg, const contour_t &cnt, Vector_Nt< vec_type, N > *subcenter, int nt)
 Returns the area fraction of the contour part that is inside the region reg, subcontour which is inside the region (if pointer is not nullptr) and the center of the subcontour (if pointer is not nullptr) by Monte Carlo method.
 
template<int N>
int MonteCarloTestLine (const Region< N > *reg, const Vector_Nt< vec_type, N > &p, const Vector_Nt< vec_type, N > &dir, vec_type *frac, Vector_Nt< vec_type, N > *surfp, Vector_Nt< vec_type, N > *surfn, vec_type length, int nt)
 Records the fractions frac1 and frac2 of the interval (p,p+dir*length/dir.norm()) corresponding to the intersections surfpi=p+fraci*dir, surfni - coords of intersection and corresponding outer normal.
 
template<class inp_it , class weight_integral_t >
int MakeBoxDomains (const Box &box, int nproc, int nx, int ny, int nz, inp_it result, const weight_integral_t &weight_integral, const Vector_3 &dx)
 Domain decomposition of the Box, abs(nproc) is number of domains.
 
template<class contour_t >
vec_type GetContourFraction (const Region_3 *reg, const contour_t &cnt, int volume_step, vec_type a0, const Vector_3 &center, const Vector_3 &dir, VecContour<> *subcont, Vector_3 *normv)
 gets area fraction of the contour (if volume_step=0) or volume fraction of the control volume around contour (if volume_step>0), which is entering the region reg subcontour inside the region is recorded to subcont (if subcont!=NULL) normal to the region (in proximity to contour intersection with region) is recorded to normv (if norm!=NULL) if volume_step>0, calculate fraction of the control volume, considering area fractions of 2*volume_step+1 copies of the contour in this volume This function can be used, for example, to calculate averaged dielectric function in FDTD subpixel smoothing, see A.
 

Detailed Description

Template function definitions for region.h.

Function Documentation

◆ GetContourFraction()

template<class contour_t >
vec_type GetContourFraction ( const Region_3 reg,
const contour_t &  cnt,
int  volume_step,
vec_type  a0,
const Vector_3 center,
const Vector_3 dir,
VecContour<> *  subcont,
Vector_3 normv 
)

gets area fraction of the contour (if volume_step=0) or volume fraction of the control volume around contour (if volume_step>0), which is entering the region reg subcontour inside the region is recorded to subcont (if subcont!=NULL) normal to the region (in proximity to contour intersection with region) is recorded to normv (if norm!=NULL) if volume_step>0, calculate fraction of the control volume, considering area fractions of 2*volume_step+1 copies of the contour in this volume This function can be used, for example, to calculate averaged dielectric function in FDTD subpixel smoothing, see A.

Deinega and I. Valuev, “Subpixel smoothing for conductive and dispersive media in the FDTD method”, Optics Letters 32, 3429 (2007)

Parameters
a0contour area
centercontour center
dirnormal to the contour
regregion
cntcontour
volume_stepif it is>0, makes 2*volume_step steps in different contour placements along the normal, the result is averaged
subcontподконтур, образуемый пересечением контура с регионом
normvвектор нормали к телу в районе пересечения им контура

◆ MakeBoxDomains()

template<class inp_it , class weight_integral_t >
int MakeBoxDomains ( const Box box,
int  nproc,
int  nx,
int  ny,
int  nz,
inp_it  result,
const weight_integral_t &  weight_integral,
const Vector_3 dx = 0 
)

Domain decomposition of the Box, abs(nproc) is number of domains.

nx, ny, nz - preferable number of sections per each dimension. This function is used in parallel implementation of numerical algorithms requiring spatial domain decomposition: each processor simulates a subBox (domain) of the whole Box. If any of the numbers is negative, then optimal number for the corresponding direction will be found. Resulting subdomains will be collected in result, if nproc>0.

Returns
the number of domains that are generated (or will be generated if nproc<0) weight_integral is a class which defines operator()(const Vector_3 &p1, const Vector_3 &p2) as a positive function giving a weight proportional to CPU load inside a box limited by (p1,p2). The argument of type volume_integral_const_t may be used when the CPU load is uniform inside box. dx is space step used in domain decomposition algorithm (default value 0 means that dx will be chosen automatically)

◆ MonteCarloTestContour()

template<int N, class contour_t >
vec_type MonteCarloTestContour ( const Region< N > *  reg,
const contour_t &  cnt,
Vector_Nt< vec_type, N > *  subcenter = nullptr,
int  nt = 1000 
)

Returns the area fraction of the contour part that is inside the region reg, subcontour which is inside the region (if pointer is not nullptr) and the center of the subcontour (if pointer is not nullptr) by Monte Carlo method.

nt is number of random points used in Monte Carlo method.

◆ MonteCarloTestLine()

template<int N>
int MonteCarloTestLine ( const Region< N > *  reg,
const Vector_Nt< vec_type, N > &  p,
const Vector_Nt< vec_type, N > &  dir,
vec_type *  frac,
Vector_Nt< vec_type, N > *  surfp,
Vector_Nt< vec_type, N > *  surfn,
vec_type  length,
int  nt = 1000 
)

Records the fractions frac1 and frac2 of the interval (p,p+dir*length/dir.norm()) corresponding to the intersections surfpi=p+fraci*dir, surfni - coords of intersection and corresponding outer normal.

returns the number of intersections: 0, 1 or 2 (if there are more than 2 intersections, skip them). in calculations nt points at the interval (p, p+length*dir/dir.norm()) are checked if they are inside or outside the region