1 #ifndef VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFERRORNORMS_IMPL_HPP
2 #define VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFERRORNORMS_IMPL_HPP
4 #include "utils/VertexCFD_Utils_VectorField.hpp"
6 #include <Panzer_GlobalIndexer.hpp>
7 #include <Panzer_HierarchicParallelism.hpp>
8 #include <Panzer_PureBasis.hpp>
9 #include <Panzer_Workset_Utilities.hpp>
11 #include <Teuchos_Array.hpp>
18 namespace ClosureModel
21 template<
class EvalType,
class Traits,
int NumSpaceDim>
22 IncompressibleLSVOFErrorNorms<EvalType, Traits, NumSpaceDim>::
23 IncompressibleLSVOFErrorNorms(
const panzer::IntegrationRule& ir,
24 const Teuchos::ParameterList& closure_params)
25 : _L1_error_continuity(
"L1_Error_continuity", ir.dl_scalar)
26 , _L2_error_continuity(
"L2_Error_continuity", ir.dl_scalar)
27 , _volume(
"volume", ir.dl_scalar)
28 , _dof_name(closure_params.get<std::string>(
"DOF Name"))
29 , _exact_pressure(
"Exact_lagrange_pressure", ir.dl_scalar)
30 , _exact_dof(
"Exact_" + _dof_name, ir.dl_scalar)
31 , _pressure(
"lagrange_pressure", ir.dl_scalar)
32 , _dof(_dof_name, ir.dl_scalar)
33 , _L1_error_dof(
"L1_Error_" + _dof_name, ir.dl_scalar)
34 , _L2_error_dof(
"L2_Error_" + _dof_name, ir.dl_scalar)
37 _solve_ns = closure_params.isType<
bool>(
"Compute NS Error Norms")
38 ? closure_params.get<
bool>(
"Compute NS Error Norms")
45 this->addDependentField(_exact_pressure);
46 this->addDependentField(_pressure);
48 Utils::addDependentVectorField(
49 *
this, ir.dl_scalar, _exact_velocity,
"Exact_velocity_");
50 Utils::addDependentVectorField(
51 *
this, ir.dl_scalar, _velocity,
"velocity_");
54 this->addEvaluatedField(_L1_error_continuity);
55 this->addEvaluatedField(_L2_error_continuity);
57 Utils::addEvaluatedVectorField(
58 *
this, ir.dl_scalar, _L1_error_momentum,
"L1_Error_momentum_");
59 Utils::addEvaluatedVectorField(
60 *
this, ir.dl_scalar, _L2_error_momentum,
"L2_Error_momentum_");
64 this->addDependentField(_dof);
65 this->addDependentField(_exact_dof);
66 this->addEvaluatedField(_L1_error_dof);
67 this->addEvaluatedField(_L2_error_dof);
69 this->addEvaluatedField(_volume);
71 this->setName(
"Incompressible LSVOF Error Norms "
72 + std::to_string(num_space_dim) +
"D");
76 template<
class EvalType,
class Traits,
int NumSpaceDim>
77 void IncompressibleLSVOFErrorNorms<EvalType, Traits, NumSpaceDim>::evaluateFields(
78 typename Traits::EvalData workset)
80 auto policy = panzer::HP::inst().teamPolicy<scalar_type, PHX::Device>(
82 Kokkos::parallel_for(this->getName(), policy, *
this);
86 template<
class EvalType,
class Traits,
int NumSpaceDim>
87 KOKKOS_INLINE_FUNCTION
void
88 IncompressibleLSVOFErrorNorms<EvalType, Traits, NumSpaceDim>::operator()(
89 const Kokkos::TeamPolicy<PHX::exec_space>::member_type& team)
const
91 const int cell = team.league_rank();
92 const int num_point = _volume.extent(1);
95 Kokkos::TeamThreadRange(team, 0, num_point), [&](
const int point) {
102 _L1_error_continuity(cell, point) = abs(
103 _pressure(cell, point) - _exact_pressure(cell, point));
105 _L2_error_continuity(cell, point) = pow(
106 _pressure(cell, point) - _exact_pressure(cell, point), 2.0);
108 for (
int i = 0; i < num_space_dim; ++i)
110 _L1_error_momentum[i](cell, point)
111 = abs(_velocity[i](cell, point)
112 - _exact_velocity[i](cell, point));
113 _L2_error_momentum[i](cell, point)
114 = pow(_velocity[i](cell, point)
115 - _exact_velocity[i](cell, point),
121 _L1_error_dof(cell, point)
122 = abs(_dof(cell, point) - _exact_dof(cell, point));
123 _L2_error_dof(cell, point)
124 = pow(_dof(cell, point) - _exact_dof(cell, point), 2.0);
126 _volume(cell, point) = 1.0;
135 #endif // VERTEXCFD_CLOSURE_INCOMPRESSIBLELSVOFERRORNORMS_IMPL_HPP