106 CellManagerType& cell_manager,
107 const DofHandlerType& dof_handler,
108 double value = 1.0) {
109 const auto& mesh = cell_manager.getMesh();
110 const auto& fe_space = cell_manager.getFeSpace();
111 const auto& constant_mode = fe_space.getBasisFast()[0];
112 using Point =
typename std::decay_t<
decltype(mesh)>::SelfPoint;
113 const double mode_value = constant_mode.evaluate(Point::Zero());
115 std::abs(constant_mode.evaluate(Point::Ones()) - mode_value) <=
116 1e-12 * std::abs(mode_value) &&
117 "the first basis function must be the constant mode");
119 const auto n_cells = [&]() {
120 if constexpr (std::decay_t<
decltype(mesh)>::parallel()) {
121 return mesh.nOwnedCells();
123 return mesh.numCells();
126 Vector coeffs(dof_handler);
127 for (std::decay_t<
decltype(n_cells)> cell_id = 0; cell_id < n_cells;
129 cell_manager.getCell(cell_id);
132 double basis_value = mode_value;
133 if constexpr (std::decay_t<
decltype(fe_space)>::needBasisScaling()) {
135 std::sqrt(cell_manager.getMapping(cell_id)->jacobianDet({}));
138 dof_handler.getCellToDof()[cell_id][0], value / basis_value);
void setValue(PetscInt idx, PetscScalar value, InsertMode mode=INSERT_VALUES)
Set a single value in the vector.
Definition vector.cpp:146
Vector constantModalCoefficients(CellManagerType &cell_manager, const DofHandlerType &dof_handler, double value=1.0)
Coefficients of a constant function in a modal DG space.
Definition gamg.hpp:105