Skip to content

Commit

Permalink
Clang format
Browse files Browse the repository at this point in the history
  • Loading branch information
reverendbedford committed Mar 2, 2023
1 parent c67364a commit 298dcf3
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 27 deletions.
16 changes: 8 additions & 8 deletions include/auxkernels/IPFColoring.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@

class IPFColoring : public AuxKernel
{
public:
static InputParameters validParams();
public:
static InputParameters validParams();

IPFColoring(const InputParameters & parameters);
IPFColoring(const InputParameters & parameters);

protected:
protected:
virtual Real computeValue();
/// quaternion

/// quaternion
/// @{
const VariableValue & _q1;
const VariableValue & _q2;
const VariableValue & _q3;
const VariableValue & _q4;
/// @}

/// Sample direction
const Point _sample_direction;

/// Crystal symmetry code
const std::string _crystal_symmetry;

Expand Down
57 changes: 38 additions & 19 deletions src/auxkernels/IPFColoring.C
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ IPFColoring::validParams()

params.addParam<std::string>("sample_symmetry", "222", "Sample symmetry Orbifold code");

params.addParam<Point>("v1", Point(0,0,1), "First point of triangle");
params.addParam<Point>("v2", Point(1,0,1), "Second point of triangle");
params.addParam<Point>("v3", Point(1,1,1), "Third point of triangle");
params.addParam<Point>("v1", Point(0, 0, 1), "First point of triangle");
params.addParam<Point>("v2", Point(1, 0, 1), "Second point of triangle");
params.addParam<Point>("v3", Point(1, 1, 1), "Third point of triangle");

return params;
}
Expand All @@ -38,36 +38,50 @@ IPFColoring::IPFColoring(const InputParameters & parameters)
_q4(coupledValue("q4")),
_sample_direction(getParam<Point>("sample_direction")),
_crystal_symmetry(getParam<std::string>("crystal_symmetry")),
_comp(getParam<unsigned int>("component")),
_comp(getParam<unsigned int>("component")),
_sample_symmetry(getParam<std::string>("sample_symmetry")),
_v1(getParam<Point>("v1")),
_v2(getParam<Point>("v2")),
_v3(getParam<Point>("v3"))
{


}

Real
IPFColoring::computeValue()
{
Point rgb = rgb_ipf_quaternion(_q1[0], _q2[0], _q3[0], _q4[0], _sample_direction,
_crystal_symmetry, _sample_symmetry, _v1, _v2, _v3);
Point rgb = rgb_ipf_quaternion(_q1[0],
_q2[0],
_q3[0],
_q4[0],
_sample_direction,
_crystal_symmetry,
_sample_symmetry,
_v1,
_v2,
_v3);

return rgb(_comp);
}

Point
rgb_ipf_quaternion(Real q1, Real q2, Real q3, Real q4, Point sd, std::string crystal_sym,
std::string sample_sym, Point v1, Point v2, Point v3)
rgb_ipf_quaternion(Real q1,
Real q2,
Real q3,
Real q4,
Point sd,
std::string crystal_sym,
std::string sample_sym,
Point v1,
Point v2,
Point v3)
{
auto pts = project_ipf({q1, q2, q3, q4}, sd, crystal_sym, sample_sym);
auto fpts = filter_ipf_points_triangle(pts, v1, v2, v3);

// This really shouldn't fail at least for nice crystals...
if (fpts.size() == 0)
mooseError("Failed to project an inverse pole figure point");

Point pt = fpts[0];

// Actually do the color projection
Expand All @@ -82,15 +96,17 @@ rgb_ipf_quaternion(Real q1, Real q2, Real q3, Real q4, Point sd, std::string cry
for (size_t i = 0; i < 3; i++)
color(i) = vs[i].contract(pt);

for (size_t i = 0; i < 3; i++) {
for (size_t i = 0; i < 3; i++)
{
Real mf = 1.0;
for (size_t j = 0; j < 3; j++) {
for (size_t j = 0; j < 3; j++)
{
Real t = vs[i].contract(vs[j]);
if (t < mf)
mf = t;
}
color(i) -= mf;
color(i) /= (1-mf);
color(i) /= (1 - mf);
}

return color;
Expand All @@ -102,7 +118,7 @@ project_ipf(std::vector<Real> q, Point sd, std::string crystal_sym, std::string
// Setup sample direction
neml::Vector d({sd(0), sd(1), sd(2)});
d.normalize();

// Setup orientation
neml::Orientation qa(q);
neml::Orientation qo = qa.inverse(); // The following assumes a passive rotation
Expand All @@ -113,9 +129,11 @@ project_ipf(std::vector<Real> q, Point sd, std::string crystal_sym, std::string

std::vector<Point> results;

for (auto srot : sample_ops) {
for (auto srot : sample_ops)
{
auto cpt = qo.apply(srot.apply(d));
for (auto crot : crystal_ops) {
for (auto crot : crystal_ops)
{
auto fpt = crot.apply(cpt);
if (fpt(2) > 0)
results.push_back(Point(fpt(0), fpt(1), fpt(2)));
Expand All @@ -132,15 +150,16 @@ filter_ipf_points_triangle(std::vector<Point> pts, Point v1, Point v2, Point v3)
v1 /= v1.norm();
v2 /= v2.norm();
v3 /= v3.norm();

// Get the adjoints
auto n1 = v1.cross(v2);
auto n2 = v2.cross(v3);
auto n3 = v3.cross(v1);

// Filter
std::vector<Point> res;
for (auto pt : pts) {
for (auto pt : pts)
{
if ((pt.contract(n1) >= 0) && (pt.contract(n2) >= 0) && (pt.contract(n3) >= 0))
res.push_back(pt);
}
Expand Down

0 comments on commit 298dcf3

Please sign in to comment.