49 "Computes Lambda 2 Criterion.");
94 p = (d1 -
q) * (d1 -
q) + (d2 -
q) * (d2 -
q) + (d3 -
q) * (d3 -
q) +
99 (a * a * d3 - a * a *
q - 2.0 * a * b * c + b * b * d2 - b * b *
q +
100 c * c * d1 - c * c *
q - d1 * d2 * d3 + d1 * d2 *
q + d1 * d3 *
q -
101 d1 *
q *
q + d2 * d3 *
q - d2 *
q *
q - d3 *
q *
q +
q *
q *
q) /
119 l3 =
q + 2.0 *
p * cos(phi);
120 l1 =
q + 2.0 *
p * cos(phi + (2.0 * M_PI / 3.0));
122 l2 = 3.0 *
q - l1 - l3;
130 auto nfields =
m_f->m_variables.size();
131 m_f->m_variables.push_back(
"L2");
134 if (
m_f->m_exp[0]->GetNumElmts() == 0)
140 int expdim =
m_f->m_graph->GetMeshDimension();
141 int spacedim = expdim + (
m_f->m_numHomogeneousDir);
145 "ProcessL2Criterion must be computed for a 3D (or quasi-3D) case.");
147 int npoints =
m_f->m_exp[0]->GetNpoints();
153 NekDouble t1, t2, t3, t4, t5, t6, t7, t8, t10, t11, t13, t14, t15;
158 m_f->m_session->LoadParameter(
"Strip_Z", nstrips, 1);
160 for (i = 0; i < spacedim * spacedim; ++i)
167 for (s = 0; s < nstrips; ++s)
169 Exp =
m_f->AppendExpList(
m_f->m_numHomogeneousDir);
170 auto it =
m_f->m_exp.begin() + s * (nfields + 1) + nfields;
171 m_f->m_exp.insert(it, Exp);
174 for (s = 0; s < nstrips; ++s)
176 for (i = 0; i < spacedim; ++i)
178 m_f->m_exp[s * nfields + i]->PhysDeriv(
179 m_f->m_exp[s * nfields + i]->GetPhys(), grad[i * spacedim],
180 grad[i * spacedim + 1], grad[i * spacedim + 2]);
189 for (
int j = 0; j < npoints; ++j)
192 t1 = grad[0 * spacedim + 1][j] + grad[1 * spacedim + 0][j];
194 t2 = grad[0 * spacedim + 2][j] + grad[2 * spacedim + 0][j];
196 t3 = grad[0 * spacedim + 1][j] - grad[1 * spacedim + 0][j];
198 t4 = grad[0 * spacedim + 2][j] - grad[2 * spacedim + 0][j];
206 t10 = grad[2 * spacedim + 1][j] + grad[1 * spacedim + 2][j];
208 t11 = grad[2 * spacedim + 1][j] - grad[1 * spacedim + 2][j];
210 t13 = 0.25 * (t10 * t2 + t11 * t4) +
212 (grad[0 * spacedim + 0][j] + grad[1 * spacedim + 1][j]);
214 (grad[0 * spacedim + 0][j] + grad[2 * spacedim + 2][j]) +
215 0.25 * (t1 * t10 - t11 * t3);
219 (grad[1 * spacedim + 1][j] + grad[2 * spacedim + 2][j]) -
220 0.25 * (-t1 * t2 + t3 * t4);
222 a00 = 0.25 * (t5 - t6 - t7 + t8) +
223 grad[0 * spacedim + 0][j] * grad[0 * spacedim + 0][j];
226 a11 = 0.25 * (-t7 + t8 + t15 - t11) +
227 grad[1 * spacedim + 1][j] * grad[1 * spacedim + 1][j];
229 a22 = 0.25 * (t5 - t6 + t15 - t11) +
230 grad[2 * spacedim + 2][j] * grad[2 * spacedim + 2][j];
233 MatSymEVals(a00, a11, a22, a01, a02, a12, outfield1, outfield2[j],
237 int fid = s * (nfields + 1) + nfields;
239 m_f->m_exp[fid]->FwdTransLocalElmt(outfield2,
240 m_f->m_exp[fid]->UpdateCoeffs());
#define ASSERTL0(condition, msg)
FieldSharedPtr m_f
Field object.
void v_Process(po::variables_map &vm) override
~ProcessL2Criterion() override
static std::shared_ptr< Module > create(FieldSharedPtr f)
Creates an instance of this class.
static ModuleKey className
ProcessL2Criterion(FieldSharedPtr f)
Abstract base class for processing modules.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
void MatSymEVals(NekDouble d1, NekDouble d2, NekDouble d3, NekDouble a, NekDouble b, NekDouble c, NekDouble &l1, NekDouble &l2, NekDouble &l3)
Calculates eigenvalues of a 3x3 Symmetric matrix.
std::shared_ptr< Field > FieldSharedPtr
std::pair< ModuleType, std::string > ModuleKey
ModuleFactory & GetModuleFactory()
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::vector< double > q(NPUPPER *NPUPPER)
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
scalarT< T > sqrt(scalarT< T > in)