16#ifndef INCG_LF_ASSEMBLE_H
17#define INCG_LF_ASSEMBLE_H
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 "assemble_concepts.h"
27#include "dofhandler.h"
114template <
typename TMPMATRIX, EntityMatrixProv
ider ENTITY_MATRIX_PROVIDER>
117 ENTITY_MATRIX_PROVIDER &entity_matrix_provider,
120 auto mesh = dof_handler_trial.
Mesh();
121 LF_ASSERT_MSG(
mesh == dof_handler_test.
Mesh(),
122 "Trial and test space must be defined on the same mesh");
127 if (entity_matrix_provider.isActive(*entity)) {
130 mesh->Index(*entity));
135 std::span<const gdof_idx_t> row_idx(
138 std::span<const gdof_idx_t> col_idx(
142 const auto elem_mat{entity_matrix_provider.Eval(*entity)};
143 LF_ASSERT_MSG(elem_mat.rows() >= nrows_loc,
144 "nrows mismatch " << elem_mat.rows() <<
" <-> " << nrows_loc
145 <<
", entity " <<
mesh->Index(*entity));
146 LF_ASSERT_MSG(elem_mat.cols() >= ncols_loc,
147 "ncols mismatch " << elem_mat.cols() <<
" <-> " << nrows_loc
148 <<
", entity " <<
mesh->Index(*entity));
156 nrows_loc, ncols_loc);
164 std::stringstream ss;
166 for (
int i = 0; i < nrows_loc; i++) {
167 for (
int j = 0; j < ncols_loc; j++) {
170 matrix.AddToEntry(row_idx[i], col_idx[j], elem_mat(i, j));
175 ss <<
"(" << row_idx[i] <<
',' << col_idx[j]
176 <<
")+= " << elem_mat(i, j) <<
", ";
209template <
typename TMPMATRIX, EntityMatrixProv
ider ENTITY_MATRIX_PROVIDER>
213 ENTITY_MATRIX_PROVIDER &entity_matrix_provider) {
214 TMPMATRIX matrix{dof_handler_test.
NumDofs(), dof_handler_trial.
NumDofs()};
217 codim, dof_handler_trial, dof_handler_test, entity_matrix_provider,
243template <
typename TMPMATRIX, EntityMatrixProv
ider ENTITY_MATRIX_PROVIDER>
246 ENTITY_MATRIX_PROVIDER &entity_matrix_provider) {
248 codim, dof_handler, dof_handler, entity_matrix_provider);
298template <
typename VECTOR, EntityVectorProv
ider ENTITY_VECTOR_PROVIDER>
300 ENTITY_VECTOR_PROVIDER &entity_vector_provider,
301 VECTOR &resultvector) {
309 if (entity_vector_provider.isActive(*entity)) {
313 const std::span<const gdof_idx_t> dof_idx(
317 const auto elem_vec{entity_vector_provider.Eval(*entity)};
318 LF_ASSERT_MSG(elem_vec.size() >= veclen,
319 "length mismatch " << elem_vec.size() <<
" <-> " << veclen
320 <<
", entity " <<
mesh->Index(*entity));
322 for (
int i = 0; i < veclen; i++) {
323 resultvector[dof_idx[i]] += elem_vec[i];
354template <
typename VECTOR,
class ENTITY_VECTOR_PROVIDER>
356 ENTITY_VECTOR_PROVIDER &entity_vector_provider) {
358 VECTOR resultvector{dof_handler.
NumDofs()};
360 resultvector.setZero();
363 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 std::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
Defines a set of interface classes that define a mesh manager and provides mesh-related tools that bu...