Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions include/base/dof_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -1077,6 +1077,34 @@ class DofMap : public DofMapBase,
*/
void create_dof_constraints (const MeshBase &, Real time=0);

/**
* Recomputes the DirichletBoundary constraint values at a new \p
* time. The result is the same as that of create_dof_constraints()
* at \p time.
*
* Only the DirichletBoundary values change with time. The degrees
* of freedom that each DirichletBoundary claims depend only on the
* mesh. The hanging-node, periodic and p-refinement constraints also
* depend only on the mesh. Thus create_dof_constraints() keeps a
* copy of the constraints that it builds before it applies the
* DirichletBoundary objects. It also records the local elements that
* carry a DirichletBoundary id. This method restores that copy. Then
* it applies the DirichletBoundary objects again, on those elements
* only and in the same order. Thus overlapping boundaries resolve as
* they do in create_dof_constraints(). Last, it processes any spline
* constraint rows of the mesh, as create_dof_constraints() does.
*
* This method calls create_dof_constraints() instead if one of these
* conditions is true:
* - No copy matches the current degrees of freedom and boundaries.
* - There are no DirichletBoundary objects.
*
* As after create_dof_constraints(), add any user constraints and
* then call process_constraints().
* System::reinit_dirichlet_constraint_values() does these steps.
*/
void reinit_dirichlet_constraint_values (const MeshBase & mesh, Real time);

/**
* Gathers constraint equation dependencies from other processors
*/
Expand Down Expand Up @@ -1664,6 +1692,22 @@ class DofMap : public DofMapBase,
*/
void check_dirichlet_bcid_consistency (const MeshBase & mesh,
const DirichletBoundary & boundary) const;

private:
/**
* Adds the constraints of each primal and adjoint DirichletBoundary
* at \p time on the elements of \p range.
*
* \returns If \p record_elems is true, the elements of \p range
* that carry a DirichletBoundary id, sorted by id. Otherwise, an
* empty vector.
*/
std::vector<const Elem *> apply_dirichlet_boundaries (const MeshBase & mesh,
Real time,
ConstElemRange & range,
bool record_elems);

public:
#endif // LIBMESH_ENABLE_DIRICHLET


Expand Down Expand Up @@ -2291,6 +2335,33 @@ class DofMap : public DofMapBase,
AdjointDofConstraintValues _adjoint_constraint_values;
#endif

#ifdef LIBMESH_ENABLE_DIRICHLET
/**
* The data from the last create_dof_constraints() call that
* reinit_dirichlet_constraint_values() uses at a new time.
*/
struct DirichletConstraintCache
{
/// Whether the cache matches the current degrees of freedom and boundaries
bool valid = false;

/// The constraints that create_dof_constraints() built before it
/// applied the DirichletBoundary objects
DofConstraints dof_constraints;
DofConstraintValueMap primal_constraint_values;
AdjointDofConstraintValues adjoint_constraint_values;
#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
NodeConstraints node_constraints;
#endif

/// The local active elements carrying any DirichletBoundary id,
/// sorted by id
std::vector<const Elem *> boundary_elems;
};

DirichletConstraintCache _dirichlet_cache;
#endif

#ifdef LIBMESH_ENABLE_NODE_CONSTRAINTS
/**
* Data structure containing DofObject constraints.
Expand Down
4 changes: 4 additions & 0 deletions include/parallel/threads_allocators.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class scalable_allocator : public tbb::scalable_allocator<T>
scalable_allocator (const scalable_allocator & a) :
tbb::scalable_allocator<T>(a) {}

scalable_allocator & operator= (const scalable_allocator &) = default;

template<typename U>
scalable_allocator(const scalable_allocator<U> & a) :
tbb::scalable_allocator<T>(a) {}
Expand Down Expand Up @@ -115,6 +117,8 @@ class scalable_allocator : public std::allocator<T>
scalable_allocator (const scalable_allocator & a) :
std::allocator<T>(a) {}

scalable_allocator & operator= (const scalable_allocator &) = default;

template<typename U>
scalable_allocator(const scalable_allocator<U> & a) :
std::allocator<T>(a) {}
Expand Down
12 changes: 12 additions & 0 deletions include/systems/system.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,18 @@ class System : public ReferenceCountedObject<System>,
*/
virtual void reinit_constraints ();

/**
* Recomputes the DirichletBoundary constraint values of this system
* at the current \p time. If only time changed since the last call
* to this method or to reinit_constraints(), the result is the same
* as that of reinit_constraints(). This method reuses the
* constraints that do not depend on time. See
* DofMap::reinit_dirichlet_constraint_values().
*
* This method also prepares the send_list.
*/
void reinit_dirichlet_constraint_values ();

/**
* Reinitializes the system with a new mesh.
*/
Expand Down
8 changes: 8 additions & 0 deletions src/base/dof_map.C
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,9 @@ void DofMap::clear()
_stashed_dof_constraints.clear();
_primal_constraint_values.clear();
_adjoint_constraint_values.clear();
#ifdef LIBMESH_ENABLE_DIRICHLET
_dirichlet_cache = DirichletConstraintCache();
#endif
_n_old_dfs = 0;
_first_old_df.clear();
_end_old_df.clear();
Expand Down Expand Up @@ -973,6 +976,11 @@ std::size_t DofMap::distribute_dofs (MeshBase & mesh)
constraining_subdomains =
this->calculate_constraining_subdomains();

#ifdef LIBMESH_ENABLE_DIRICHLET
// New degree of freedom indices invalidate every cached constraint
_dirichlet_cache = DirichletConstraintCache();
#endif

// re-init in case the mesh has changed
this->reinit(mesh,
constraining_subdomains);
Expand Down
Loading