\[ -(v_{j}, \sigma_{j}(\mathbf{u}))_\Omega -\sum_{i} (\left\{[v n_j] - \theta\gamma\sigma_{j}(\mathbf{v})\right\} + \theta\gamma\sigma_{j}(\mathbf{v}), \hat{\sigma}_{j}(\mathbf{u}))_{F_i}+(v_i, \overline{t}_i)_{S^\sigma}= 0 \]
\[ -(v_{j}, \sigma_{j}(\mathbf{u}))_\Omega+(v_i, \overline{t})_{S^\sigma} -\sum_{i} (\left\{[v_i n_j] - \theta\gamma\sigma_{ij}(\mathbf{v})\right\}, \hat{\sigma}_{j}(\mathbf{u}))_{F_i}-\sum_{i} (\theta\gamma\sigma_{j}(\mathbf{v}),\sigma_{j}(\mathbf{u}))_{F_i} = 0 \]
\[ \hat{\sigma} = \gamma^{-1} \left\{ [u n_j] - \gamma \sigma_{j} (\mathbf{u}) \right\} \]
\[ -(v_{j}, \sigma_{j}(\mathbf{u}))_\Omega+(v, \overline{t})_{S^\sigma} -\sum_{i} (\left\{[v n_j] - \theta\gamma\sigma_{j}(\mathbf{v})\right\}, \gamma^{-1} \left\{ [u n_j] - \gamma \sigma_{j}(\mathbf{u})\right\})_{F_i} -\sum_{i} (\theta\gamma\sigma_{j}(\mathbf{v}), \gamma^{-1} \left\{\gamma \sigma_{j}(\mathbf{u})\right\})_{F_i} = 0 \]
-1;
auto u_exact = [](
const double x,
const double y,
const double) {
return x * x * y * y;
else
return cos(2 * x * M_PI) * cos(2 * y * M_PI);
};
else
-2 * M_PI * cos(2 * M_PI * y) * sin(2 * M_PI * x),
-2 * M_PI * cos(2 * M_PI * x) * sin(2 * M_PI * y)
};
};
auto source = [](
const double x,
const double y,
const double) {
return -(2 * x * x + 2 * y * y);
else
return 8 * M_PI * M_PI * cos(2 * x * M_PI) * cos(2 * y * M_PI);
};
static char help[] =
"...\n\n";
public:
private:
int oRder;
};
}
PETSC_NULL);
PETSC_NULL);
auto save_shared = [&](auto meshset, std::string prefix) {
auto file_name =
prefix + "_" +
1);
};
}
}
auto add_base_ops = [&](auto &pipeline) {
auto det_ptr = boost::make_shared<VectorDouble>();
auto jac_ptr = boost::make_shared<MatrixDouble>();
auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
};
add_base_ops(pipeline_mng->getOpDomainLhsPipeline());
[](const double, const double, const double) { return 1; }));
pipeline_mng->getOpDomainRhsPipeline().push_back(
auto side_fe_ptr = boost::make_shared<FaceSideEle>(
mField);
add_base_ops(side_fe_ptr->getOpPtrVector());
side_fe_ptr->getOpPtrVector().push_back(
pipeline_mng->getOpSkeletonLhsPipeline().push_back(
pipeline_mng->getOpBoundaryLhsPipeline().push_back(
pipeline_mng->getOpBoundaryRhsPipeline().push_back(
}
auto rule_lhs = [](
int,
int,
int p) ->
int {
return 2 * p; };
auto rule_rhs = [](
int,
int,
int p) ->
int {
return 2 * p; };
CHKERR pipeline_mng->setDomainLhsIntegrationRule(rule_lhs);
CHKERR pipeline_mng->setDomainRhsIntegrationRule(rule_rhs);
CHKERR pipeline_mng->setSkeletonLhsIntegrationRule(rule_2);
CHKERR pipeline_mng->setSkeletonRhsIntegrationRule(rule_2);
CHKERR pipeline_mng->setBoundaryLhsIntegrationRule(rule_2);
CHKERR pipeline_mng->setBoundaryRhsIntegrationRule(rule_2);
}
auto ksp_solver = pipeline_mng->createKSP();
CHKERR KSPSetFromOptions(ksp_solver);
CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
}
pipeline_mng->getDomainRhsFE().reset();
pipeline_mng->getDomainLhsFE().reset();
pipeline_mng->getSkeletonRhsFE().reset();
pipeline_mng->getSkeletonLhsFE().reset();
pipeline_mng->getBoundaryRhsFE().reset();
pipeline_mng->getBoundaryLhsFE().reset();
auto rule = [](
int,
int,
int p) ->
int {
return 2 * p; };
CHKERR pipeline_mng->setDomainRhsIntegrationRule(rule);
CHKERR pipeline_mng->setSkeletonRhsIntegrationRule(rule_2);
auto add_base_ops = [&](auto &pipeline) {
auto det_ptr = boost::make_shared<VectorDouble>();
auto jac_ptr = boost::make_shared<MatrixDouble>();
auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
};
auto u_vals_ptr = boost::make_shared<VectorDouble>();
auto u_grad_ptr = boost::make_shared<MatrixDouble>();
add_base_ops(pipeline_mng->getOpDomainRhsPipeline());
pipeline_mng->getOpDomainRhsPipeline().push_back(
pipeline_mng->getOpDomainRhsPipeline().push_back(
enum NORMS {
L2 = 0, SEMI_NORM,
H1, LAST_NORM };
std::array<int, LAST_NORM> error_indices;
for (
int i = 0;
i != LAST_NORM; ++
i)
if (
const size_t nb_dofs = data.
getIndices().size()) {
const int nb_integration_pts = o->getGaussPts().size2();
auto t_w = o->getFTensor0IntegrationWeight();
auto t_grad = getFTensor1FromMat<2>(*u_grad_ptr);
auto t_coords = o->getFTensor1CoordsAtGaussPts();
std::array<double, LAST_NORM> error;
std::fill(error.begin(), error.end(), 0);
for (int gg = 0; gg != nb_integration_pts; ++gg) {
const double alpha = t_w * o->getMeasure();
const double diff =
t_val -
u_exact(t_coords(0), t_coords(1), t_coords(2));
auto t_exact_grad =
u_grad_exact(t_coords(0), t_coords(1), t_coords(2));
const double diff_grad =
(t_grad(
i) - t_exact_grad(
i)) * (t_grad(
i) - t_exact_grad(
i));
error[
L2] += alpha * pow(diff, 2);
error[SEMI_NORM] += alpha * diff_grad;
++t_w;
++t_val;
++t_grad;
++t_coords;
}
error[
H1] = error[
L2] + error[SEMI_NORM];
ADD_VALUES);
}
};
auto side_fe_ptr = boost::make_shared<FaceSideEle>(
mField);
add_base_ops(side_fe_ptr->getOpPtrVector());
side_fe_ptr->getOpPtrVector().push_back(
std::array<VectorDouble, 2> side_vals;
std::array<double, 2> area_map;
side_vals_op->doWorkRhsHook = [&](
DataOperator *op_ptr,
int side,
const auto nb_in_loop = o->getFEMethod()->nInTheLoop;
area_map[nb_in_loop] = o->getMeasure();
side_vals[nb_in_loop] = *u_vals_ptr;
if (!nb_in_loop) {
area_map[1] = 0;
side_vals[1].clear();
}
};
side_fe_ptr->getOpPtrVector().push_back(side_vals_op);
CHKERR o->loopSideFaces(
"dFE", *side_fe_ptr);
const auto in_the_loop = side_fe_ptr->nInTheLoop;
#ifndef NDEBUG
const std::array<std::string, 2> ele_type_name = {"BOUNDARY", "SKELETON"};
<< "do_work_rhs_error in_the_loop " << ele_type_name[in_the_loop];
#endif
const double s = o->getMeasure() / (area_map[0] + area_map[1]);
constexpr std::array<int, 2> sign_array{1, -1};
std::array<double, LAST_NORM> error;
std::fill(error.begin(), error.end(), 0);
const int nb_integration_pts = o->getGaussPts().size2();
if (!in_the_loop) {
side_vals[1].resize(nb_integration_pts, false);
auto t_coords = o->getFTensor1CoordsAtGaussPts();
for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
t_val_m =
u_exact(t_coords(0), t_coords(1), t_coords(2));
++t_coords;
++t_val_m;
}
}
auto t_w = o->getFTensor0IntegrationWeight();
for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
const double alpha = o->getMeasure() * t_w;
const auto diff = t_val_p - t_val_m;
error[SEMI_NORM] += alpha * p * diff * diff;
++t_w;
++t_val_p;
++t_val_m;
}
error[
H1] = error[SEMI_NORM];
ADD_VALUES);
};
skeleton_error_op->doWorkRhsHook = do_work_rhs_error;
boundary_error_op->doWorkRhsHook = do_work_rhs_error;
pipeline_mng->getOpDomainRhsPipeline().push_back(error_op);
pipeline_mng->getOpSkeletonLhsPipeline().push_back(skeleton_error_op);
pipeline_mng->getOpBoundaryRhsPipeline().push_back(boundary_error_op);
CHKERR pipeline_mng->loopFiniteElements();
CHKERR VecAssemblyBegin(l2_vec);
CHKERR VecAssemblyEnd(l2_vec);
const double *array;
CHKERR VecGetArrayRead(l2_vec, &array);
MOFEM_LOG_C(
"SELF", Sev::inform,
"Error Norm L2 %6.4e",
MOFEM_LOG_C(
"SELF", Sev::inform,
"Error Norm Energetic %6.4e",
std::sqrt(array[SEMI_NORM]));
MOFEM_LOG_C(
"SELF", Sev::inform,
"Error Norm H1 %6.4e",
constexpr
double eps = 1e-12;
if (std::sqrt(array[
H1]) >
eps)
}
CHKERR VecRestoreArrayRead(l2_vec, &array);
}
}
pipeline_mng->getDomainLhsFE().reset();
pipeline_mng->getSkeletonRhsFE().reset();
pipeline_mng->getSkeletonLhsFE().reset();
pipeline_mng->getBoundaryRhsFE().reset();
pipeline_mng->getBoundaryLhsFE().reset();
auto post_proc_fe = boost::make_shared<PostProcEle>(
mField);
auto u_ptr = boost::make_shared<VectorDouble>();
post_proc_fe->getOpPtrVector().push_back(
post_proc_fe->getOpPtrVector().push_back(
post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
{{"U", u_ptr}},
{},
{},
{})
);
pipeline_mng->getDomainRhsFE() = post_proc_fe;
CHKERR pipeline_mng->loopFiniteElements();
CHKERR post_proc_fe->writeFile(
"out_result.h5m");
}
}
int main(
int argc,
char *argv[]) {
const char param_file[] = "param_file.petsc";
try {
DMType dm_name = "DMMOFEM";
CHKERR poisson_problem.runProgram();
}
return 0;
}
#ifndef __POISSON2DISGALERKIN_HPP__
#define __POISSON2DISGALERKIN_HPP__
std::array<VectorInt, 2>
std::array<VectorInt, 2>
std::fill(&doEntities[MBVERTEX], &doEntities[MBMAXTYPE], false);
for (
auto t = moab::CN::TypeDimensionMap[
SPACE_DIM].first;
t <= moab::CN::TypeDimensionMap[
SPACE_DIM].second; ++
t)
}
EntityType col_type,
EntData &row_data,
if ((CN::Dimension(row_type) ==
SPACE_DIM) &&
const auto nb_in_loop = getFEMethod()->nInTheLoop;
areaMap[nb_in_loop] = getMeasure();
senseMap[nb_in_loop] = getSkeletonSense();
if (!nb_in_loop) {
}
} else {
}
}
};
template <
typename T>
inline auto get_ntensor(T &base_mat) {
&*base_mat.data().begin());
};
template <
typename T>
inline auto get_ntensor(T &base_mat,
int gg,
int bb) {
double *ptr = &base_mat(gg, bb);
};
double *ptr = &*base_mat.data().begin();
return getFTensor1FromPtr<2>(ptr);
};
template <typename T>
double *ptr = &base_mat(gg, 2 * bb);
return getFTensor1FromPtr<2>(ptr);
};
public:
const auto in_the_loop =
#ifndef NDEBUG
const std::array<std::string, 2> ele_type_name = {"BOUNDARY", "SKELETON"};
<< "OpL2LhsPenalty inTheLoop " << ele_type_name[in_the_loop];
#endif
auto t_normal = getFTensor1Normal();
const size_t nb_integration_pts = getGaussPts().size2();
const double beta =
static_cast<double>(
nitsche) / (in_the_loop + 1);
if (nb_rows) {
locMat.resize(nb_rows, nb_cols,
false);
auto t_w = getFTensor0IntegrationWeight();
for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
const double alpha = getMeasure() * t_w;
auto t_mat =
locMat.data().begin();
size_t rr = 0;
for (; rr != nb_rows; ++rr) {
t_vn_plus(
i) = beta * (
phi * t_diff_row_base(
i) / p);
t_vn(
i) = t_row_base * t_normal(
i) * sense_row - t_vn_plus(
i);
auto t_diff_col_base =
for (size_t cc = 0; cc != nb_cols; ++cc) {
t_un(
i) = -p * (t_col_base * t_normal(
i) * sense_col -
beta * t_diff_col_base(
i) / p);
*t_mat -= alpha * (t_vn(
i) * t_un(
i));
*t_mat -= alpha * (t_vn_plus(
i) * (beta * t_diff_col_base(
i)));
++t_col_base;
++t_diff_col_base;
++t_mat;
}
++t_row_base;
++t_diff_row_base;
}
for (; rr < nb_row_base_functions; ++rr) {
++t_row_base;
++t_diff_row_base;
}
++t_w;
}
&*
locMat.data().begin(), ADD_VALUES);
if (!in_the_loop)
}
}
}
}
private:
boost::shared_ptr<FaceSideEle>
};
public:
const auto in_the_loop =
const double s = getMeasure() / (
areaMap[0]);
auto t_normal = getFTensor1Normal();
auto t_w = getFTensor0IntegrationWeight();
if (!nb_rows)
rhsF.resize(nb_rows,
false);
const size_t nb_integration_pts = getGaussPts().size2();
auto t_coords = getFTensor1CoordsAtGaussPts();
const double beta =
static_cast<double>(
nitsche) / (in_the_loop + 1);
for (size_t gg = 0; gg != nb_integration_pts; ++gg) {
const double alpha = getMeasure() * t_w;
const double source_val =
-p *
sourceFun(t_coords(0), t_coords(1), t_coords(2));
auto t_f =
rhsF.data().begin();
size_t rr = 0;
for (; rr != nb_rows; ++rr) {
t_vn_plus(
i) = beta * (
phi * t_diff_row_base(
i) / p);
t_vn(
i) = t_row_base * t_normal(
i) * sense_row - t_vn_plus(
i);
*t_f -= alpha * t_vn(
i) * (source_val * t_normal(
i));
++t_row_base;
++t_diff_row_base;
++t_f;
}
for (; rr < nb_row_base_functions; ++rr) {
++t_row_base;
++t_diff_row_base;
}
++t_w;
++t_coords;
}
ADD_VALUES);
}
private:
boost::shared_ptr<FaceSideEle>
};
};
#endif //__POISSON2DISGALERKIN_HPP__