Skip to content

Commit 9fe2aa7

Browse files
Removes cartesian angles and rotation as a capability from sources and references to it.
1 parent 5dd67ef commit 9fe2aa7

File tree

5 files changed

+9
-360
lines changed

5 files changed

+9
-360
lines changed

src/components/Sources.cpp

Lines changed: 3 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,50 +9,15 @@ namespace maxwell {
99

1010
constexpr double TOLERANCE = 10.0*DBL_EPSILON;
1111

12-
mfem::DenseMatrix getRotationMatrix(const Source::CartesianAngles& angles_)
13-
{
14-
std::array<mfem::DenseMatrix, 3> rotMat;
15-
double rotationAxisX[3] = { 1.0,0.0,0.0 }, rotationAxisY[3] = { 0.0,1.0,0.0 }, rotationAxisZ[3] = { 0.0,0.0,1.0 };
16-
mfem::NURBSPatch::Get3DRotationMatrix(rotationAxisX, angles_[X], 1.0, rotMat[X]);
17-
mfem::NURBSPatch::Get3DRotationMatrix(rotationAxisY, angles_[Y], 1.0, rotMat[Y]);
18-
mfem::NURBSPatch::Get3DRotationMatrix(rotationAxisZ, angles_[Z], 1.0, rotMat[Z]);
19-
mfem::DenseMatrix tMat(3), res(3);
20-
mfem::Mult(rotMat[X], rotMat[Y], tMat);
21-
mfem::Mult(tMat , rotMat[Z], res);
22-
return res;
23-
}
24-
25-
mfem::Vector rotateAroundAxis(
26-
const mfem::Vector& v, const Source::CartesianAngles& angles_)
27-
{
28-
auto rotMat{ getRotationMatrix(angles_) };
29-
30-
mfem::Vector pos3D(3), newPos3D(3);
31-
pos3D = 0.0;
32-
for (auto d{ 0 }; d < v.Size(); d++) {
33-
pos3D[d] = v[d];
34-
}
35-
36-
rotMat.Mult(pos3D, newPos3D);
37-
38-
mfem::Vector res(v.Size());
39-
for (auto d{ 0 }; d < v.Size(); d++) {
40-
res[d] = newPos3D[d];
41-
}
42-
return res;
43-
}
44-
4512
InitialField::InitialField(
4613
const Function& f,
4714
const FieldType& fT,
4815
const Polarization& p,
49-
const Position& centerIn,
50-
const CartesianAngles anglesIn ) :
16+
const Position& centerIn) :
5117
magnitude_{ f.clone() },
5218
fieldType_{ fT },
5319
polarization_{ p },
54-
center_{ centerIn },
55-
angles_{ anglesIn }
20+
center_{ centerIn }
5621
{
5722
assert(std::abs(1.0 - polarization_.Norml2()) <= TOLERANCE);
5823
}
@@ -61,8 +26,7 @@ InitialField::InitialField(const InitialField& rhs) :
6126
magnitude_{ rhs.magnitude_->clone() },
6227
fieldType_{ rhs.fieldType_ },
6328
polarization_{ rhs.polarization_ },
64-
center_{ rhs.center_ },
65-
angles_{ rhs.angles_ }
29+
center_{ rhs.center_ }
6630
{}
6731

6832
std::unique_ptr<Source> InitialField::clone() const
@@ -84,9 +48,6 @@ double InitialField::eval(
8448
for (int i{ 0 }; i < p.Size(); ++i) {
8549
pos[i] = p[i] - center_[i];
8650
}
87-
if (angles_[0] != 0.0 || angles_[1] != 0.0 || angles_[2] != 0.0) {
88-
pos = rotateAroundAxis(pos, angles_);
89-
}
9051

9152
return magnitude_->eval(pos) * polarization_[d];
9253
}

src/components/Sources.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class Source {
1111
using Time = double;
1212
using Polarization = mfem::Vector;
1313
using Propagation = mfem::Vector;
14-
using CartesianAngles = std::vector<double>;
1514

1615
virtual ~Source() = default;
1716
virtual std::unique_ptr<Source> clone() const = 0;
@@ -27,8 +26,7 @@ class InitialField : public Source {
2726
const Function&,
2827
const FieldType&,
2928
const Polarization&,
30-
const Position& center_,
31-
const CartesianAngles rotAngle = CartesianAngles({ 0.0,0.0,0.0 })
29+
const Position& center
3230
);
3331
InitialField(const InitialField&);
3432

@@ -47,7 +45,6 @@ class InitialField : public Source {
4745
FieldType fieldType_{ E };
4846
Polarization polarization_;
4947
Position center_;
50-
CartesianAngles angles_;
5148
};
5249

5350
class Planewave : public Source {

test/maxwell/SourceFixtures.h

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,14 @@ static Sources buildGaussianInitialField(
1212
const double spread = 0.1,
1313
const mfem::Vector& center_ = mfem::Vector({ 0.5 }),
1414
const Source::Polarization& p = Source::Polarization({ 0.0,0.0,1.0 }),
15-
const int dimension = 1,
16-
const Source::CartesianAngles angles_ = Source::CartesianAngles({ 0.0,0.0,0.0 }))
15+
const int dimension = 1)
1716
{
1817
mfem::Vector gaussianCenter(dimension);
1918
gaussianCenter = 0.0;
2019

2120
Sources res;
2221
res.add(std::make_unique<InitialField>(
23-
Gaussian{ spread, gaussianCenter, dimension }, ft, p, center_, angles_)
22+
Gaussian{ spread, gaussianCenter, dimension }, ft, p, center_)
2423
);
2524
return res;
2625
}
@@ -58,15 +57,14 @@ static Sources buildPlanewaveInitialField(
5857
const Function& mf,
5958
const Source::Position& center_,
6059
const Source::Polarization& polIn,
61-
const Source::Propagation& propagationDir,
62-
const Source::CartesianAngles& angles_ = Source::CartesianAngles({0.0,0.0,0.0}))
60+
const Source::Propagation& propagationDir)
6361
{
6462
Sources res;
6563
res.add(
66-
std::make_unique<InitialField>(mf, E, polIn, center_, angles_)
64+
std::make_unique<InitialField>(mf, E, polIn, center_)
6765
);
6866
res.add(
69-
std::make_unique<InitialField>(mf, H, crossProduct(propagationDir, polIn), center_, angles_)
67+
std::make_unique<InitialField>(mf, H, crossProduct(propagationDir, polIn), center_)
7068
);
7169
return res;
7270
}

test/maxwell/solver/Solver2DTest.cpp

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -554,35 +554,6 @@ TEST_F(Solver2DTest, sma_quads_1dot5D)
554554

555555
}
556556

557-
TEST_F(Solver2DTest, rotated_centered_quads_1dot5D)
558-
{
559-
auto mesh{ Mesh::LoadFromFile((mfemMeshes2DFolder() + "severalrotatedquads.mesh").c_str(),1,0)};
560-
mesh.UniformRefinement();
561-
AttributeToBoundary attToBdr{ {1,BdrCond::PEC}, {2,BdrCond::PMC}};
562-
Model model{ mesh, AttributeToMaterial{}, attToBdr, AttributeToInteriorConditions{} };
563-
auto probes{ buildProbesWithAnExportProbe(30) };
564-
565-
fieldCenter = Vector({ 2.0, 2.0 });
566-
567-
maxwell::Solver solver {
568-
model,
569-
probes,
570-
buildGaussianInitialField(E, 0.5, fieldCenter, unitVec(Z), 1, Source::CartesianAngles({0.0,0.0,-M_PI_4})),
571-
SolverOptions{}
572-
.setTimeStep(1e-3)
573-
.setFinalTime(4.95)
574-
.setCentered()
575-
.setOrder(3)
576-
};
577-
578-
auto normOld{ solver.getFields().getNorml2() };
579-
solver.run();
580-
581-
double tolerance{ 1e-2 };
582-
EXPECT_NEAR(normOld, solver.getFields().getNorml2(), tolerance);
583-
584-
}
585-
586557
TEST_F(Solver2DSpectralTest, periodic_centered_tris_spectral_and_base_comparison) {
587558

588559
Probes probes;

0 commit comments

Comments
 (0)