26#ifndef OOMPH_REFINEABLE_MESH_HEADER
27#define OOMPH_REFINEABLE_MESH_HEADER
132 outfile <<
"Targets for mesh adaptation: " << std::endl;
133 outfile <<
"---------------------------- " << std::endl;
137 <<
" elements need unrefinement." << std::endl;
259 err_stream <<
"p_adapt() called in base class RefineableMeshBase."
261 <<
"This needs to be implemented in the derived class."
286 <<
"p_refine_uniformly() called in base class RefineableMeshBase."
288 <<
"This needs to be implemented in the derived class." << std::endl;
314 <<
"p_unrefine_uniformly() called in base class RefineableMeshBase."
316 <<
"This needs to be implemented in the derived class." << std::endl;
470 outfile <<
"Targets for mesh adaptation: " << std::endl;
471 outfile <<
"---------------------------- " << std::endl;
481 <<
" elements need unrefinement." << std::endl;
665 ->ncont_interpolated_values();
667 unsigned ncont_interpolated_values = 0;
669 &ncont_interpolated_values,
683 <<
"TreeBasedRefineableMeshBase::synchronise_hanging_nodes() "
684 <<
"incl. time for initial allreduce in "
685 <<
"TreeBasedRefineableMeshBase::classify_halo_and_haloed_nodes(): "
721 const unsigned& ncont_interpolated_values) = 0;
807 template<
class ELEMENT>
820 for (
unsigned long e = 0;
e < n_tree;
e++)
823 &Tree::split_if_required<ELEMENT>);
834 Mesh* mesh_pt =
this;
839 for (
unsigned long e = 0;
e < n_tree;
e++)
842 &Tree::p_refine_if_required<ELEMENT>, mesh_pt);
856 const unsigned& ncont_interpolated_values);
906 outfile <<
"Targets for mesh adaptation: " << std::endl;
907 outfile <<
"---------------------------- " << std::endl;
915 <<
" elements need unrefinement." << std::endl;
931 for (
unsigned e = 0;
e < nel;
e++)
942 for (
unsigned n = 0;
n < 4; ++
n)
944 for (
unsigned i = 0;
i < 3; ++
i)
953 for (
unsigned i = 0;
i < 3; ++
i)
962 for (
unsigned i = 0;
i < 3; ++
i)
965 for (
unsigned k = 0;
k < 3; ++
k)
983 for (
unsigned start = 0; start < 4; ++start)
985 for (
unsigned end = start + 1;
end < 4; ++
end)
987 for (
unsigned i = 0;
i < 3; ++
i)
Class of matrices containing doubles, and stored as a DenseMatrix<double>, but with solving functiona...
Information for documentation of results: Directory and file number to enable output in the form RESL...
void disable_doc()
Disable documentation.
std::string directory() const
Output directory.
void solve(DoubleVector &rhs)
Complete LU solve (replaces matrix by its LU decomposition and overwrites RHS with solution)....
Base class for spatial error estimators.
A general Finite Element class.
double size() const
Calculate the size of the element (length, area, volume,...) in Eulerian computational coordinates....
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Class that contains data for hanging nodes.
FiniteElement * finite_element_pt(const unsigned &e) const
Upcast (downcast?) to FiniteElement (needed to access FiniteElement member functions).
virtual void classify_halo_and_haloed_nodes(DocInfo &doc_info, const bool &report_stats)
Classify the halo and haloed nodes in the mesh. Virtual so it can be overloaded to perform additional...
OomphCommunicator * Comm_pt
Pointer to communicator – set to NULL if mesh is not distributed.
const Vector< GeneralisedElement * > & element_pt() const
Return reference to the Vector of elements.
bool Resize_halo_nodes_not_required
Set this to true to suppress resizing of halo nodes (at your own risk!)
void resize_halo_nodes()
Helper function that resizes halo nodes to the same size as their non-halo counterparts if required....
unsigned long nelement() const
Return number of elements in the mesh.
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
double & x(const unsigned &i)
Return the i-th nodal coordinate.
An OomphLibError object which should be thrown when an run-time error is encountered....
RefineableElements are FiniteElements that may be subdivided into children to provide a better local ...
Base class for refineable meshes. Provides standardised interfaces for the following standard mesh ad...
virtual void p_adapt(const Vector< double > &elemental_error)
p-adapt mesh: Refine elements whose error is lager than err_max and (try to) unrefine those whose err...
unsigned & max_keep_unrefined()
Max. number of elements that we allow to remain unrefined if no other mesh adaptation is required (to...
bool P_adapt_flag
Flag that requests p-adaptation.
unsigned Nrefined
Stats: Number of elements that were refined.
double & min_permitted_error()
Access fct for min. error (i.e. (try to) merge elements if their error is smaller)
void enable_p_adaptation()
Enable adaptation.
unsigned nunrefined()
Access fct for number of elements that were unrefined.
DocInfo *& doc_info_pt()
Access fct for pointer to DocInfo.
DocInfo doc_info()
Access fct for DocInfo.
RefineableMeshBase()
Constructor sets default values for refinement targets etc. and initialises pointer to spatial error ...
bool Adapt_flag
Flag that requests adaptation.
void operator=(const RefineableMeshBase &)=delete
Broken assignment operator.
void enable_adaptation()
Enable adaptation.
DocInfo * Doc_info_pt
Pointer to DocInfo.
ErrorEstimator * spatial_error_estimator_pt() const
Access to spatial error estimator (const version.
virtual void p_refine_uniformly(DocInfo &doc_info)
p-refine mesh uniformly and doc process
unsigned & nrefinement_overruled()
Number of elements that would have liked to be refined further but can't because they've reached the ...
unsigned Max_keep_unrefined
Max. number of elements that can remain unrefined if no other mesh adaptation is required (to avoid m...
virtual unsigned unrefine_uniformly()=0
Unrefine mesh uniformly: Return 0 for success, 1 for failure (if unrefinement has reached the coarses...
unsigned Nunrefined
Stats: Number of elements that were unrefined.
virtual void p_refine_uniformly()
p-refine mesh uniformly
void p_unrefine_uniformly(DocInfo &doc_info)
p-unrefine mesh uniformly
bool Additional_synchronisation_of_hanging_nodes_not_required
Flag that disables additional synchronisation of hanging nodes.
void disable_p_adaptation()
Disable adaptation.
void disable_adaptation()
Disable adaptation.
void enable_additional_synchronisation_of_hanging_nodes()
Enable additional synchronisation of hanging nodes.
ErrorEstimator *& spatial_error_estimator_pt()
Access to spatial error estimator.
bool is_additional_synchronisation_of_hanging_nodes_disabled() const
Return whether additional synchronisation is enabled.
bool is_adaptation_enabled() const
Return whether the mesh is to be adapted.
ErrorEstimator * Spatial_error_estimator_pt
Pointer to spatial error estimator.
bool is_p_adaptation_enabled() const
Return whether the mesh is to be adapted.
virtual void doc_adaptivity_targets(std::ostream &outfile)
Doc the targets for mesh adaptation.
double Max_error
Max. actual error.
virtual void refine_uniformly()
Refine mesh uniformly.
double Min_error
Min.actual error.
virtual void adapt(const Vector< double > &elemental_error)=0
Adapt mesh: Refine elements whose error is lager than err_max and (try to) unrefine those whose error...
unsigned nrefined()
Access fct for number of elements that were refined.
RefineableMeshBase(const RefineableMeshBase &dummy)=delete
Broken copy constructor.
double & min_error()
Access fct for min. actual error in present solution (i.e. before re-solve on adapted mesh)
double Min_permitted_error
Min. error (i.e. (try to) merge elements if their error is smaller)
virtual ~RefineableMeshBase()
Empty Destructor:
unsigned Nrefinement_overruled
Number of elements that would like to be refined further but can't because they've reached the max....
void disable_additional_synchronisation_of_hanging_nodes()
Disable additional synchronisation of hanging nodes.
double & max_error()
Access fct for max. actual error in present solution (i.e. before re-solve on adapted mesh)
double & max_permitted_error()
Access fct for max. error (i.e. split elements if their error is larger)
double Max_permitted_error
Max. error (i.e. split elements if their error is larger)
virtual void refine_uniformly(DocInfo &doc_info)=0
Refine mesh uniformly and doc process.
Base class for refineable tet meshes.
void doc_adaptivity_targets(std::ostream &outfile)
Doc the targets for mesh adaptation.
double compute_volume_target(const Vector< double > &elem_error, Vector< double > &target_volume)
Compute target volume based on the elements' error and the error target; return max edge ratio.
double & min_element_size()
Min element size allowed during adaptation.
double & max_element_size()
Max element size allowed during adaptation.
double & max_permitted_edge_ratio()
Min edge ratio before remesh gets triggered.
double Max_element_size
Max permitted element size.
double Min_element_size
Min permitted element size.
double Max_permitted_edge_ratio
Max edge ratio before remesh gets triggered.
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
Base class for tree-based refineable meshes.
TreeForest * forest_pt()
Return pointer to the Forest represenation of the mesh.
void synchronise_hanging_nodes(const unsigned &ncont_interpolated_values)
Synchronise the hanging nodes if the mesh is distributed.
virtual void read_refinement(std::ifstream &restart_file, Vector< Vector< unsigned > > &to_be_refined)
Read refinement pattern to allow for rebuild.
virtual void get_elements_at_refinement_level(unsigned &refinement_level, Vector< RefineableElement * > &level_elements)
Extract the elements at a particular refinement level in the refinement pattern - used in Mesh::redis...
void classify_halo_and_haloed_nodes(const bool &report_stats=false)
Classify the halo and haloed nodes in the mesh.
virtual void refine_selected_elements(const Vector< unsigned > &elements_to_be_refined)
Refine mesh by splitting the elements identified by their numbers.
unsigned & max_p_refinement_level()
Access fct for max. permissible p-refinement level (relative to base mesh)
unsigned Uniform_refinement_level_when_pruned
Level to which the mesh was uniformly refined when it was pruned.
unsigned uniform_refinement_level_when_pruned() const
Level to which the mesh was uniformly refined when it was pruned (const version)
virtual void dump_refinement(std::ostream &outfile)
Dump refinement pattern to allow for rebuild.
unsigned Max_p_refinement_level
Max. permissible p-refinement level (relative to base mesh)
unsigned unrefine_uniformly()
Unrefine mesh uniformly: Return 0 for success, 1 for failure (if unrefinement has reached the coarses...
virtual void refine(std::ifstream &restart_file)
Refine mesh according to refinement pattern in restart file.
virtual void additional_synchronise_hanging_nodes(const unsigned &ncont_interpolated_values)=0
Additional synchronisation of hanging nodes Required for reconcilliation of hanging nodes on the oute...
unsigned & min_refinement_level()
Access fct for min. permissible refinement level (relative to base mesh)
virtual void adapt_mesh()
Perform the actual tree-based mesh adaptation. A simple wrapper to call the function without document...
virtual void refine_base_mesh_as_in_reference_mesh(TreeBasedRefineableMeshBase *const &ref_mesh_pt)
Refine base mesh to same degree as reference mesh (relative to original unrefined mesh).
virtual void get_refinement_pattern(Vector< Vector< unsigned > > &to_be_refined)
Extract refinement pattern: Consider the hypothetical mesh obtained by truncating the refinement of t...
void complete_hanging_nodes_recursively(Node *&nod_pt, Vector< Node * > &master_nodes, Vector< double > &hang_weights, const int &ival)
Auxiliary routine for recursive hanging node completion.
unsigned & max_refinement_level()
Access fct for max. permissible refinement level (relative to base mesh)
virtual void refine_as_in_reference_mesh(TreeBasedRefineableMeshBase *const &ref_mesh_pt)
Refine mesh once so that its topology etc becomes that of the (finer!) reference mesh – if possible!...
void refine_base_mesh(Vector< Vector< unsigned > > &to_be_refined)
Refine base mesh according to specified refinement pattern.
void operator=(const TreeBasedRefineableMeshBase &)=delete
Broken assignment operator.
void p_refine_selected_elements(const Vector< unsigned > &elements_to_be_refined)
p-refine mesh by refining the elements identified by their numbers.
unsigned & min_p_refinement_level()
Access fct for min. permissible p-refinement level (relative to base mesh)
virtual void split_elements_if_required()=0
Split all the elements in the mesh if required. This template free interface will be overloaded in Re...
void doc_adaptivity_targets(std::ostream &outfile)
Doc the targets for mesh adaptation.
TreeBasedRefineableMeshBase(const TreeBasedRefineableMeshBase &dummy)=delete
Broken copy constructor.
void refine_uniformly()
Refine mesh uniformly.
void p_unrefine_uniformly(DocInfo &doc_info)
p-unrefine mesh uniformly
virtual void get_refinement_levels(unsigned &min_refinement_level, unsigned &max_refinement_level)
Get max/min refinement levels in mesh.
virtual void p_refine_elements_if_required()=0
p-refine all the elements in the mesh if required. This template free interface will be overloaded in...
void complete_hanging_nodes(const int &ncont_interpolated_values)
Complete the hanging node scheme recursively.
virtual void setup_tree_forest()=0
Set up the tree forest associated with the Mesh (if any)
TreeBasedRefineableMeshBase()
Constructor.
TreeForest * Forest_pt
Forest representation of the mesh.
virtual ~TreeBasedRefineableMeshBase()
Empty Destructor:
unsigned Min_p_refinement_level
Min. permissible p-refinement level (relative to base mesh)
void synchronise_nonhanging_nodes()
Synchronise the positions of non-hanging nodes that depend on non-existent neighbours (e....
void adapt(const Vector< double > &elemental_error)
Adapt mesh: Refine elements whose error is lager than err_max and (try to) unrefine those whose error...
unsigned Max_refinement_level
Max. permissible refinement level (relative to base mesh)
void p_adapt(const Vector< double > &elemental_error)
p-adapt mesh: Refine elements whose error is lager than err_max and (try to) unrefine those whose err...
void p_adapt_mesh()
Perform the actual tree-based mesh p-adaptation. A simple wrapper to call the function without docume...
virtual bool refine_base_mesh_as_in_reference_mesh_minus_one(TreeBasedRefineableMeshBase *const &ref_mesh_pt)
Refine base mesh to same degree as reference mesh minus one level of refinement (relative to original...
void p_refine_uniformly()
p-refine mesh uniformly
void classify_halo_and_haloed_nodes(DocInfo &doc_info, const bool &report_stats)
Classify all halo and haloed information in the mesh (overloaded version from Mesh base class....
unsigned Min_refinement_level
Min. permissible refinement level (relative to base mesh)
unsigned & uniform_refinement_level_when_pruned()
Level to which the mesh was uniformly refined when it was pruned.
Templated base class for refineable meshes. The use of the template parameter is required only for cr...
virtual ~TreeBasedRefineableMesh()
Empty virtual destructor.
void additional_synchronise_hanging_nodes(const unsigned &ncont_interpolated_values)
Additional setup of shared node scheme This is Required for reconcilliation of hanging nodes acrross ...
TreeBasedRefineableMesh(const TreeBasedRefineableMesh &dummy)=delete
Broken copy constructor.
void split_elements_if_required()
Split all the elements if required. Overload the template-free interface so that any new elements tha...
TreeBasedRefineableMesh()
Constructor, call the constructor of the base class.
void p_refine_elements_if_required()
p-refine all the elements if required. Overload the template-free interface so that any temporary cop...
A TreeForest consists of a collection of TreeRoots. Each member tree can have neighbours in various e...
unsigned ntree()
Number of trees in forest.
TreeRoot * tree_pt(const unsigned &i) const
Return pointer to i-th tree in forest.
void traverse_leaves(Tree::VoidMemberFctPt member_function)
Traverse the tree and execute void Tree member function member_function() only at its leaves.
A slight extension to the standard template vector class so that we can include "graceful" array rang...
bool Doc_comprehensive_timings
Global boolean to switch on comprehensive timing – can probably be declared const false when developm...
double timer()
returns the time in seconds after some point in past
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
OomphInfo oomph_info
Single (global) instantiation of the OomphInfo object – this is used throughout the library as a "rep...
Helper struct to collate data required during TreeBasedRefineableMeshBase::synchronise_hanging_nodes.
unsigned Shared_node_proc
unsigned Sending_processor
unsigned Shared_node_id_on_sending_processor
unsigned Master_node_index