Skip to content
Snippets Groups Projects
Commit f658fe81 authored by Yurov, Dmitry's avatar Yurov, Dmitry
Browse files

Default (vacuum) material factories

Redmine: #1858
parent 4a5251da
No related branches found
No related tags found
No related merge requests found
......@@ -20,6 +20,13 @@ Material HomogeneousMaterial(const std::string& name, double delta, double beta,
return Material(std::move(mat_impl));
}
Material HomogeneousMaterial()
{
std::unique_ptr<RefractiveCoefMaterial> mat_impl(
new RefractiveCoefMaterial("vacuum", 0.0, 0.0, kvector_t{}));
return Material(std::move(mat_impl));
}
Material MaterialBySLD(const std::string& name, double sld, double abs_term,
kvector_t magnetization)
{
......@@ -36,3 +43,10 @@ Material MaterialByAbsCX(const std::string& name, double sld, double abs_cx,
new WavelengthIndependentMaterial(name, sld, abs_cx / basic_wavelength, magnetization));
return Material(std::move(mat_impl));
}
Material MaterialBySLD()
{
std::unique_ptr<WavelengthIndependentMaterial> mat_impl(
new WavelengthIndependentMaterial("vacuum", 0.0, 0.0, kvector_t{}));
return Material(std::move(mat_impl));
}
......@@ -35,6 +35,14 @@ BA_CORE_API_ Material HomogeneousMaterial(const std::string& name, double delta,
//! @ingroup materials
//! Constructs vacuum material based on refractive coefficients.
//! Though in practice there is no difference between vacuum materials
//! produced with MaterialBySLD() and HomogeneousMaterial(), they are not equal because of
//! the difference in the type of underlying data
BA_CORE_API_ Material HomogeneousMaterial();
//! @ingroup materials
//! Constructs a wavelength-independent material with given sld and absorptive term
//! Absorptive term is wavelength-independent (normalized to a wavelength)
//! and can be considered as inverse of imaginary part of complex scattering length density:
......@@ -60,4 +68,12 @@ BA_CORE_API_ Material MaterialBySLD(const std::string& name, double sld, double
BA_CORE_API_ Material MaterialByAbsCX(const std::string& name, double sld, double abs_cx,
kvector_t magnetization = kvector_t());
//! @ingroup materials
//! Constructs wavelength-independent vacuum material.
//! Though in practice there is no difference between vacuum materials
//! produced with MaterialBySLD() and HomogeneousMaterial(), they are not equal because of
//! the difference in the type of underlying data
BA_CORE_API_ Material MaterialBySLD();
#endif /* MATERIALFACTORYFUNCS_H_ */
......@@ -30,6 +30,8 @@ public:
friend BA_CORE_API_ Material HomogeneousMaterial(const std::string&, double, double,
kvector_t);
friend BA_CORE_API_ Material HomogeneousMaterial();
virtual ~RefractiveCoefMaterial();
//! Returns pointer to a copy of material
......
......@@ -29,6 +29,8 @@ public:
friend BA_CORE_API_ Material MaterialByAbsCX(const std::string&, double, double, kvector_t);
friend BA_CORE_API_ Material MaterialBySLD();
virtual ~WavelengthIndependentMaterial();
//! Returns pointer to a copy of material
......
......@@ -131,6 +131,11 @@ TEST_F(MaterialTest, EqualityTest)
EXPECT_DOUBLE_EQ(material.materialData().real(), material3.materialData().real());
EXPECT_DOUBLE_EQ(material.materialData().imag(), material3.materialData().imag());
EXPECT_TRUE(material.dataType() == material3.dataType());
EXPECT_EQ(HomogeneousMaterial().getName(), MaterialBySLD().getName());
EXPECT_EQ(HomogeneousMaterial().materialData(), MaterialBySLD().materialData());
EXPECT_EQ(HomogeneousMaterial().magnetization(), MaterialBySLD().magnetization());
EXPECT_FALSE(HomogeneousMaterial() == MaterialBySLD());
}
TEST_F(MaterialTest, MaterialCopy)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment