openPSTD  2.0
Open source simulation for sound propagation in urban environments
Public Member Functions | Public Attributes | List of all members
OpenPSTD::Kernel::Domain Class Reference

A representation of one rectangular scene unit. More...

#include <Domain.h>

Inheritance diagram for OpenPSTD::Kernel::Domain:
Inheritance graph
Collaboration diagram for OpenPSTD::Kernel::Domain:
Collaboration graph

Public Member Functions

 Domain (std::shared_ptr< PSTDSettings > settings, int id, const float alpha, Point top_left, Point size, const bool is_pml, std::shared_ptr< WisdomCache > wnd, std::map< Direction, EdgeParameters > edge_param_map, const std::shared_ptr< Domain > pml_for_domain)
 Default constructor. More...
 
 Domain (std::shared_ptr< PSTDSettings > settings, int id, const float alpha, std::vector< float > top_left_vector, std::vector< float > size_vector, const bool is_pml, std::shared_ptr< WisdomCache > wnd, std::map< Direction, EdgeParameters > edge_param_map, const std::shared_ptr< Domain > pml_for_domain)
 Constructor that accepts vectors of real word coordinates instead of points. More...
 
void push_values ()
 Overrides the old values with the new values. More...
 
void clear_matrices ()
 Clears the matrices used in computing the field values.
 
void compute_pml_matrices ()
 Computes the matrices used in attenuating the field values in the PML domains. More...
 
void apply_pml_matrices ()
 Applies the PML attenuation to the field values.
 
int number_of_neighbours (bool count_pml)
 Returns the number of neighbours. More...
 
bool contains_point (Point point)
 Checks if a certain point is contained in this domain. More...
 
bool contains_location (std::vector< float > location)
 Checks if a certain (unrounded) location is contained in this domain. More...
 
std::vector< std::shared_ptr< Domain > > get_neighbours_at (Direction direction)
 Returns a vector of all domains touching this domain along the specified direction. More...
 
std::shared_ptr< Domainget_neighbour_at (Direction direction, std::vector< float > location)
 Returns a single neighbour domain (if existing) in the specified location. More...
 
void add_neighbour_at (std::shared_ptr< Domain > domain, Direction direction)
 Adds a neighbour to the set of neighbour domains. More...
 
bool is_neighbour_of (std::shared_ptr< Domain > domain)
 Method that checks if this domain is touching domain More...
 
bool is_pml_for (std::shared_ptr< Domain > domain)
 
bool is_rigid ()
 
std::vector< int > get_range (CalcDirection cd)
 Returns a vector of 1d locations of all nodes spanned by the domain in world grid coordinates in direction cd. More...
 
std::vector< int > get_intersection_with (std::shared_ptr< Domain > other_domain, Direction direction)
 Computes the grid points in a given direction the domain has in common with another domain. More...
 
Eigen::ArrayXXf calc (CalcDirection cd, CalculationType ct, Eigen::ArrayXcf dest)
 Calculate one timestep of propagation in this domain. More...
 
void calc (CalcDirection cd, CalculationType ct)
 Calculate one time step of propagation in this domain. More...
 
void post_initialization ()
 Process data after all methods have been initialized. More...
 
Eigen::ArrayXXi get_vacant_range (Direction direction)
 Get ranges of boundary grid points not connected to a neighbour domain along a specified direction. More...
 
Eigen::ArrayXXf extended_zeros (int x, int y, int z=0)
 Method that gives the current domain initialized with zeroes, extended by the input arguments in respective directions. More...
 

Public Attributes

std::shared_ptr< PSTDSettingssettings
 Settings from the PSTDKernel.
 
int id
 Domain identifier. Does not necessarily correspond to the GUI and CLI ids; no need for that.
 
float alpha
 Some coefficient...
 
float impedance
 Impedance of the boundary.
 
float rho
 Density of the domain interior. Defaults to air.
 
std::map< Direction, EdgeParametersedge_param_map
 Map with boundary coefficients.
 
std::map< CalcDirection, bool > should_update
 Map with update directions.
 
Point top_left
 Start of the domain (top left)
 
Point bottom_right
 End of the domain (bottom right)
 
Point size
 Domain size.
 
bool is_pml
 Whether the domain is a perfectly matched layer.
 
bool local
 Another parameter (PML-related)
 
FieldValues current_values
 Collection of state variables in this time step (not thread-safe)
 
FieldValues previous_values
 Collection of state variables in previous time step (should be thread-safe)
 
FieldLValues l_values
 Derivative approximations of the state variables.
 
std::shared_ptr< WisdomCachewnd
 Pointer to WisdomCache object.
 
bool is_secondary_pml
 Whether the domain is a PML domain for other PML domains.
 
std::vector< std::shared_ptr< Domain > > pml_for_domain_list
 List of domains that this domain functions for as a PML.
 

Detailed Description

A representation of one rectangular scene unit.

This object stores the values for pressure and velocities, and references to its neighbours. It supports boundaries with different impedance values as well as attenuating boundaries.

Constructor & Destructor Documentation

OpenPSTD::Kernel::Domain::Domain ( std::shared_ptr< PSTDSettings settings,
int  id,
const float  alpha,
Point  top_left,
Point  size,
const bool  is_pml,
std::shared_ptr< WisdomCache wnd,
std::map< Direction, EdgeParameters edge_param_map,
const std::shared_ptr< Domain pml_for_domain 
)

Default constructor.

Parameters
settingspointer to PSTDFile settings
idinteger identifier for this domain
alphaalpha of the domain, used in calculating impedance
top_leftcoordinates of the top left corner (x,y,(z))
sizelengths of the domain edges (x,y,(z))
is_pmltrue if domain is pml domain
pml_forarray of adjacent domains for a PML domain. nullptr if not PML domain.
Returns
: Domain object
OpenPSTD::Kernel::Domain::Domain ( std::shared_ptr< PSTDSettings settings,
int  id,
const float  alpha,
std::vector< float >  top_left_vector,
std::vector< float >  size_vector,
const bool  is_pml,
std::shared_ptr< WisdomCache wnd,
std::map< Direction, EdgeParameters edge_param_map,
const std::shared_ptr< Domain pml_for_domain 
)

Constructor that accepts vectors of real word coordinates instead of points.

Parameters
top_left_vectorvector with top left corner dimensions
sizevector with size dimensions
See also
Domain

Member Function Documentation

void OpenPSTD::Kernel::Domain::add_neighbour_at ( std::shared_ptr< Domain domain,
Direction  direction 
)

Adds a neighbour to the set of neighbour domains.

Parameters
domainPointer to fully initialized neighbour domain
directionDirection in which the domain is neighboured.
Eigen::ArrayXXf OpenPSTD::Kernel::Domain::calc ( CalcDirection  cd,
CalculationType  ct,
Eigen::ArrayXcf  dest 
)

Calculate one timestep of propagation in this domain.

Parameters
cdBoundary type (calculation direction)
ctCalculation type (pressure/velocity)
destValues to be used as factor to compute derivative in wavenumber domain
See also
kernel_functions.cpp
void OpenPSTD::Kernel::Domain::calc ( CalcDirection  cd,
CalculationType  ct 
)

Calculate one time step of propagation in this domain.

Near-alias to calc(CalcDirection cd, CalculationType ct, vector<float> dest), but with a default empty vector as dest.

Parameters
cdBoundary type (calculation direction)
ctCalculation type (pressure/velocity)
See also
Kernel::spatderp3()
void OpenPSTD::Kernel::Domain::compute_pml_matrices ( )

Computes the matrices used in attenuating the field values in the PML domains.

TK: Corner PML domains should have a horizontal as well as a vertical component. In particular: not to neighbours in the same direction.

bool OpenPSTD::Kernel::Domain::contains_location ( std::vector< float >  location)

Checks if a certain (unrounded) location is contained in this domain.

Parameters
locationCoordinates on grid.
Returns
: True if location falls within top_left and bottom_right, false otherwise.
See also
contains_point(Point point)
bool OpenPSTD::Kernel::Domain::contains_point ( Point  point)

Checks if a certain point is contained in this domain.

Parameters
pointGrid point object
Returns
: True if center of grid point is located in the domain, false otherwise
ArrayXXf OpenPSTD::Kernel::Domain::extended_zeros ( int  x,
int  y,
int  z = 0 
)

Method that gives the current domain initialized with zeroes, extended by the input arguments in respective directions.

Parameters
xextension in x direction
yextension in y direction
zextension in z direction (default: 0)
vector< int > OpenPSTD::Kernel::Domain::get_intersection_with ( std::shared_ptr< Domain other_domain,
Direction  direction 
)

Computes the grid points in a given direction the domain has in common with another domain.

Parameters
other_domainDomain this domain is compared to
directionDirection along which the grid points are checked.
Returns
: vector of integers with shared grid point coordinates (in x/y/z direction)
shared_ptr< Domain > OpenPSTD::Kernel::Domain::get_neighbour_at ( Direction  direction,
std::vector< float >  location 
)

Returns a single neighbour domain (if existing) in the specified location.

If no neighbour domain is present in that location, returns nullptr

Parameters
vector< shared_ptr< Domain > > OpenPSTD::Kernel::Domain::get_neighbours_at ( Direction  direction)

Returns a vector of all domains touching this domain along the specified direction.

Parameters
vector< int > OpenPSTD::Kernel::Domain::get_range ( CalcDirection  cd)

Returns a vector of 1d locations of all nodes spanned by the domain in world grid coordinates in direction cd.

This exists to facilitate porting the legacy code.

Parameters
cdDirection in which the range is requested
ArrayXXi OpenPSTD::Kernel::Domain::get_vacant_range ( Direction  direction)

Get ranges of boundary grid points not connected to a neighbour domain along a specified direction.

Parameters
directionDomain side under consideration
Returns
: 2D array each row a range start and end variable
bool OpenPSTD::Kernel::Domain::is_neighbour_of ( std::shared_ptr< Domain domain)

Method that checks if this domain is touching domain

Parameters
domainDomain to check against this domain
bool OpenPSTD::Kernel::Domain::is_pml_for ( std::shared_ptr< Domain domain)
Returns
: true if domain functions as a PML domain for the provided domain, false otherwise.
bool OpenPSTD::Kernel::Domain::is_rigid ( )
Returns
: true if the domain is rigid, false otherwise
int OpenPSTD::Kernel::Domain::number_of_neighbours ( bool  count_pml)

Returns the number of neighbours.

Parameters
count_pmlWhether or not to also include PML domains in the count
Returns
number of neighbour domains.
void OpenPSTD::Kernel::Domain::post_initialization ( )

Process data after all methods have been initialized.

Finds neighbouring domains and update information.

void OpenPSTD::Kernel::Domain::push_values ( )

Overrides the old values with the new values.

Needs to be called before the CLI or GUI can access the data


The documentation for this class was generated from the following files: