Example 1: TEFIE and NMFIE solvers for closed PEC objects. Demonstrates the computation of bistatic RCS for a PEC sphere with two different integral equation formulations.
#include <iostream>
#include <string>
int main(int argc, char** argv)
{
std::cout << "\n====================================================" << std::endl;
std::cout << "OpenBEM example 1" << std::endl;
std::cout << "====================================================\n" << std::endl;
std::size_t path_pos = std::string(__FILE__).find_last_of("/");
std::string path = std::string(__FILE__).substr(0, path_pos) + "/";
std::string msh_filename = path + "msh/sphere.msh";
std::cout <<
"Number of vertices: " << structure.
mesh().num_verts() << std::endl;
std::cout <<
"Number of triangles: " << structure.
mesh().num_elems() << std::endl;
std::cout <<
"Number of edges: " << structure.
mesh().num_edges() << std::endl;
bool flip_normals = true;
MatrixType j_tefie;
L.mat_solve(j_tefie, inc_e);
MatrixType j_nmfie;
K.mat_solve(j_nmfie, inc_h);
projection_points.
set_polar_data(arc_begin, arc_end, center, num_pts);
MatrixType e_tefie, h_tefie;
e_tefie.set_mat_mul(e_proj, j_tefie);
h_tefie.set_mat_mul(h_proj, j_tefie);
MatrixType e_nmfie, h_nmfie;
e_nmfie.set_mat_mul(e_proj, j_nmfie);
h_nmfie.set_mat_mul(h_proj, j_nmfie);
MatrixType e_tefie_reshaped;
e_tefie_reshaped.raw_matrix() = e_tefie.raw_matrix().reshaped(3, 100);
MatrixType e_nmfie_reshaped;
e_nmfie_reshaped.raw_matrix() = e_nmfie.raw_matrix().reshaped(3, 100);
MatrixType e_tefie_mag;
e_tefie_mag.raw_matrix() = e_tefie_reshaped.raw_matrix().colwise().norm();
MatrixType e_nmfie_mag;
e_nmfie_mag.raw_matrix() = e_nmfie_reshaped.raw_matrix().colwise().norm();
MatrixType rcs_tefie;
rcs_tefie.raw_matrix() = Eigen::pow(e_tefie_mag.raw_matrix().array(), 2) * bem::four_pi * std::pow(dist, 2);
MatrixType rcs_nmfie;
rcs_nmfie.raw_matrix() = Eigen::pow(e_nmfie_mag.raw_matrix().array(), 2) * bem::four_pi * std::pow(dist, 2);
MatrixType rcs_error;
rcs_error.raw_matrix() = (rcs_tefie.raw_matrix() - rcs_nmfie.raw_matrix()).array().abs();
MatrixType rcs_relative_error;
rcs_relative_error.raw_matrix() = rcs_error.raw_matrix().array() / rcs_tefie.raw_matrix().array().abs();
bem::Float rcs_max_relative_error = rcs_relative_error.raw_matrix().array().abs().maxCoeff();
std::cout << "TEFIE vs. NMFIE RCS maximum relative error: "
<< rcs_max_relative_error * 100
<< " %" << std::endl;
j_tefie,
structure.
mesh().elem_centroids(),
false
).array().real();
j_nmfie,
structure.
mesh().elem_centroids(),
false
).array().real();
return 0;
}
Eigen-based dense matrix wrapper.
static void read_gmsh_v2(Structure< TriangleMesh< 3 > > &structure, const std::string msh_filename, const bool decoupled_edges=false)
Reads a GMSH v2 mesh file and populates a TriangleMesh in a Structure.
static void write_gmsh_v2_vector_field(const Structure< TriangleMesh< 3 > > &structure, const std::string msh_filename, ConstEigRef< EigMatNX< Float, 3 > > field, std::string field_name="vector_field")
Writes a GMSH v2 mesh file from a TriangleMesh in a Structure with a superimposed vector field.
void set_polar_data(ConstEigRef< EigColVecN< Float, dim > > start, ConstEigRef< EigColVecN< Float, dim > > stop, ConstEigRef< EigColVecN< Float, dim > > center, ConstEigRef< EigColVecN< Index, dim > > num_pts)
Sets PointCloud data as points of a polar grid.
Class that defines a structure.
const Material & background_material() const
Returns the background material of the structure.
MeshType & mesh()
Returns the mesh associated with the structure in editable form.
Class defining the RWG-based NMFIE.
MatrixType exc_matrix(const Float f, const Material &material, ExcitationBase< 3 > &exc)
Returns the excitation matrix for a given excitation operator.
MatrixType j_matrix(const Float f, const Material &material)
Computes the operator matrix associated with the electric surface current density.
MatrixType j_projector(const Float f, const Material &material, const PointCloud< 3 > &points)
Returns the projector matrix associated with the electric surface current density.
Class for computing plane wave excitation vector coefficients when tested with rotated RWG functions.
Class for computing plane wave excitation vector coefficients when tested with RWG functions.
static EigMatNX< Complex, 3 > reconstruct_field(const TriangleMesh< 3 > &mesh, const MatrixBase< Complex > &coeffs, ConstEigRef< EigMatNX< Float, 3 > > points, const bool rotated=false)
Reconstructs a vector field expressed with RWG functions on a given triangle mesh.
Class defining the RWG-based TEFIE.
MatrixType j_projector(const Float f, const Material &material, const PointCloud< 3 > &points)
Returns the projector matrix associated with the electric surface current density.
MatrixType exc_matrix(const Float f, const Material &material, ExcitationBase< 3 > &exc)
Returns the excitation matrix for a given excitation operator.
MatrixType j_matrix(const Float f, const Material &material)
Returns the operator matrix associated with the electric surface current density.
const Float c0
Vacuum wave speed.
const Float eta0
Vacuum wave impedance.
double Float
Floating point number.
Eigen::Matrix< T, N, 1 > EigColVecN
Fixed-size column vector of size N containing type T.
Eigen::Matrix< T, N, Eigen::Dynamic > EigMatNX
Fixed-height matrix with N rows containing type T.