39 #include <boost/core/ignore_unused.hpp>
53 "Computes Lambda 2 Criterion.");
98 p = (d1 - q) * (d1 - q) + (d2 - q) * (d2 - q) + (d3 - q) * (d3 - q) +
103 (a * a * d3 - a * a * q - 2.0 * a * b * c + b * b * d2 - b * b * q +
104 c * c * d1 - c * c * q - d1 * d2 * d3 + d1 * d2 * q + d1 * d3 * q -
105 d1 * q * q + d2 * d3 * q - d2 * q * q - d3 * q * q + q * q * q) /
123 l3 = q + 2.0 *
p * cos(phi);
124 l1 = q + 2.0 *
p * cos(phi + (2.0 * M_PI / 3.0));
126 l2 = 3.0 * q - l1 - l3;
134 auto nfields =
m_f->m_variables.size();
135 m_f->m_variables.push_back(
"L2");
138 if (
m_f->m_exp[0]->GetNumElmts() == 0)
144 int expdim =
m_f->m_graph->GetMeshDimension();
145 int spacedim = expdim + (
m_f->m_numHomogeneousDir);
149 "ProcessL2Criterion must be computed for a 3D (or quasi-3D) case.");
151 int npoints =
m_f->m_exp[0]->GetNpoints();
157 NekDouble t1, t2, t3, t4, t5, t6, t7, t8, t10, t11, t13, t14, t15;
162 m_f->m_session->LoadParameter(
"Strip_Z", nstrips, 1);
164 for (i = 0; i < spacedim * spacedim; ++i)
171 for (s = 0; s < nstrips; ++s)
173 for (i = 0; i < spacedim; ++i)
175 m_f->m_exp[s * nfields + i]->PhysDeriv(
176 m_f->m_exp[s * nfields + i]->GetPhys(), grad[i * spacedim],
177 grad[i * spacedim + 1], grad[i * spacedim + 2]);
186 for (
int j = 0; j < npoints; ++j)
189 t1 = grad[0 * spacedim + 1][j] + grad[1 * spacedim + 0][j];
191 t2 = grad[0 * spacedim + 2][j] + grad[2 * spacedim + 0][j];
193 t3 = grad[0 * spacedim + 1][j] - grad[1 * spacedim + 0][j];
195 t4 = grad[0 * spacedim + 2][j] - grad[2 * spacedim + 0][j];
203 t10 = grad[2 * spacedim + 1][j] + grad[1 * spacedim + 2][j];
205 t11 = grad[2 * spacedim + 1][j] - grad[1 * spacedim + 2][j];
207 t13 = 0.25 * (t10 * t2 + t11 * t4) +
209 (grad[0 * spacedim + 0][j] + grad[1 * spacedim + 1][j]);
211 (grad[0 * spacedim + 0][j] + grad[2 * spacedim + 2][j]) +
212 0.25 * (t1 * t10 - t11 * t3);
216 (grad[1 * spacedim + 1][j] + grad[2 * spacedim + 2][j]) -
217 0.25 * (-t1 * t2 + t3 * t4);
219 a00 = 0.25 * (t5 - t6 - t7 + t8) +
220 grad[0 * spacedim + 0][j] * grad[0 * spacedim + 0][j];
223 a11 = 0.25 * (-t7 + t8 + t15 - t11) +
224 grad[1 * spacedim + 1][j] * grad[1 * spacedim + 1][j];
226 a22 = 0.25 * (t5 - t6 + t15 - t11) +
227 grad[2 * spacedim + 2][j] * grad[2 * spacedim + 2][j];
230 MatSymEVals(a00, a11, a22, a01, a02, a12, outfield1, outfield2[j],
234 Exp =
m_f->AppendExpList(
m_f->m_numHomogeneousDir);
235 Vmath::Vcopy(npoints, outfield2, 1, Exp->UpdatePhys(), 1);
236 Exp->FwdTrans_IterPerExp(outfield2, Exp->UpdateCoeffs());
237 auto it =
m_f->m_exp.begin() + s * (nfields + 1) + nfields;
238 m_f->m_exp.insert(it, Exp);
#define ASSERTL0(condition, msg)
FieldSharedPtr m_f
Field object.
virtual void Process(po::variables_map &vm)
virtual ~ProcessL2Criterion()
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.
The above copyright notice and this permission notice shall be included.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
scalarT< T > sqrt(scalarT< T > in)