openPSTD
2.0
Open source simulation for sound propagation in urban environments
|
A representation of one rectangular scene unit. More...
#include <Domain.h>
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< Domain > | get_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< PSTDSettings > | settings |
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, EdgeParameters > | edge_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< WisdomCache > | wnd |
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. | |
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.
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.
settings | pointer to PSTDFile settings |
id | integer identifier for this domain |
alpha | alpha of the domain, used in calculating impedance |
top_left | coordinates of the top left corner (x,y,(z)) |
size | lengths of the domain edges (x,y,(z)) |
is_pml | true if domain is pml domain |
pml_for | array of adjacent domains for a PML domain. nullptr if not PML domain. |
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.
top_left_vector | vector with top left corner dimensions |
size | vector with size dimensions |
void OpenPSTD::Kernel::Domain::add_neighbour_at | ( | std::shared_ptr< Domain > | domain, |
Direction | direction | ||
) |
Adds a neighbour to the set of neighbour domains.
domain | Pointer to fully initialized neighbour domain |
direction | Direction 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.
cd | Boundary type (calculation direction) |
ct | Calculation type (pressure/velocity) |
dest | Values to be used as factor to compute derivative in wavenumber domain |
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.
cd | Boundary type (calculation direction) |
ct | Calculation type (pressure/velocity) |
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.
location | Coordinates on grid. |
bool OpenPSTD::Kernel::Domain::contains_point | ( | Point | point | ) |
Checks if a certain point is contained in this domain.
point | Grid point object |
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.
x | extension in x direction |
y | extension in y direction |
z | extension 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.
other_domain | Domain this domain is compared to |
direction | Direction along which the grid points are checked. |
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
Returns a vector of all domains touching this domain along the specified direction.
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.
cd | Direction 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.
direction | Domain side under consideration |
bool OpenPSTD::Kernel::Domain::is_neighbour_of | ( | std::shared_ptr< Domain > | domain | ) |
Method that checks if this domain is touching domain
domain | Domain to check against this domain |
bool OpenPSTD::Kernel::Domain::is_pml_for | ( | std::shared_ptr< Domain > | domain | ) |
bool OpenPSTD::Kernel::Domain::is_rigid | ( | ) |
int OpenPSTD::Kernel::Domain::number_of_neighbours | ( | bool | count_pml | ) |
Returns the number of neighbours.
count_pml | Whether or not to also include PML domains in the count |
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 | ( | ) |