19#include <fmt/ranges.h>
20#include <spdlog/fmt/ostr.h>
21#include <spdlog/sinks/stdout_color_sinks.h>
22#include <spdlog/spdlog.h>
26#include "dofhandler.h"
112template <
typename TMPMATRIX,
class ENTITY_MATRIX_PROVIDER>
115 ENTITY_MATRIX_PROVIDER &entity_matrix_provider,
118 auto mesh = dof_handler_trial.
Mesh();
119 LF_ASSERT_MSG(mesh == dof_handler_test.
Mesh(),
120 "Trial and test space must be defined on the same mesh");
125 if (entity_matrix_provider.isActive(*entity)) {
128 mesh->Index(*entity));
140 const auto elem_mat{entity_matrix_provider.Eval(*entity)};
141 LF_ASSERT_MSG(elem_mat.rows() >= nrows_loc,
142 "nrows mismatch " << elem_mat.rows() <<
" <-> " << nrows_loc
143 <<
", entity " << mesh->Index(*entity));
144 LF_ASSERT_MSG(elem_mat.cols() >= ncols_loc,
145 "ncols mismatch " << elem_mat.cols() <<
" <-> " << nrows_loc
146 <<
", entity " << mesh->Index(*entity));
154 nrows_loc, ncols_loc);
162 std::stringstream ss;
164 for (
int i = 0; i < nrows_loc; i++) {
165 for (
int j = 0; j < ncols_loc; j++) {
168 matrix.AddToEntry(row_idx[i], col_idx[j], elem_mat(i, j));
173 ss <<
"(" << row_idx[i] <<
',' << col_idx[j]
174 <<
")+= " << elem_mat(i, j) <<
", ";
207template <
typename TMPMATRIX,
class ENTITY_MATRIX_PROVIDER>
211 ENTITY_MATRIX_PROVIDER &entity_matrix_provider) {
212 TMPMATRIX matrix{dof_handler_test.
NumDofs(), dof_handler_trial.
NumDofs()};
214 AssembleMatrixLocally<TMPMATRIX, ENTITY_MATRIX_PROVIDER>(
215 codim, dof_handler_trial, dof_handler_test, entity_matrix_provider,
241template <
typename TMPMATRIX,
class ENTITY_MATRIX_PROVIDER>
244 ENTITY_MATRIX_PROVIDER &entity_matrix_provider) {
245 return AssembleMatrixLocally<TMPMATRIX, ENTITY_MATRIX_PROVIDER>(
246 codim, dof_handler, dof_handler, entity_matrix_provider);
296template <
typename VECTOR,
class ENTITY_VECTOR_PROVIDER>
298 ENTITY_VECTOR_PROVIDER &entity_vector_provider,
299 VECTOR &resultvector) {
301 auto mesh = dof_handler.
Mesh();
307 if (entity_vector_provider.isActive(*entity)) {
315 const auto elem_vec{entity_vector_provider.Eval(*entity)};
316 LF_ASSERT_MSG(elem_vec.size() >= veclen,
317 "length mismatch " << elem_vec.size() <<
" <-> " << veclen
318 <<
", entity " << mesh->Index(*entity));
320 for (
int i = 0; i < veclen; i++) {
321 resultvector[dof_idx[i]] += elem_vec[i];
346template <
typename VECTOR,
class ENTITY_VECTOR_PROVIDER>
348 ENTITY_VECTOR_PROVIDER &entity_vector_provider) {
350 VECTOR resultvector{dof_handler.
NumDofs()};
352 resultvector.setZero();
354 AssembleVectorLocally<VECTOR, ENTITY_VECTOR_PROVIDER>(
355 codim, dof_handler, entity_vector_provider, resultvector);
A general (interface) class for DOF handling, see Lecture Document Paragraph 2.7.4....
virtual std::shared_ptr< const lf::mesh::Mesh > Mesh() const =0
Acess to underlying mesh object.
virtual nonstd::span< const gdof_idx_t > GlobalDofIndices(const lf::mesh::Entity &entity) const =0
access to indices of global dof's belonging to an entity
virtual size_type NumLocalDofs(const lf::mesh::Entity &entity) const =0
tells the number of degrees of freedom subordinate/_belonging_ to to an entity
virtual size_type NumDofs() const =0
total number of dof's handled by the object
Interface class representing a topological entity in a cellular complex
void AssembleMatrixLocally(dim_t codim, const DofHandler &dof_handler_trial, const DofHandler &dof_handler_test, ENTITY_MATRIX_PROVIDER &entity_matrix_provider, TMPMATRIX &matrix)
Assembly function for standard assembly of finite element matrices.
std::shared_ptr< spdlog::logger > & AssembleMatrixLogger()
The logger that is used by AssembleMatrixLocally() to log additional information. (for logging levels...
void AssembleVectorLocally(dim_t codim, const DofHandler &dof_handler, ENTITY_VECTOR_PROVIDER &entity_vector_provider, VECTOR &resultvector)
entity-local assembly of (right-hand-side) vectors from element vectors
D.o.f. index mapping and assembly facilities.
lf::base::size_type size_type