30 #ifndef OOMPH_REFINEABLE_MESH_HEADER 31 #define OOMPH_REFINEABLE_MESH_HEADER 135 outfile << std::endl;
136 outfile <<
"Targets for mesh adaptation: " << std::endl;
137 outfile <<
"---------------------------- " << std::endl;
141 <<
" elements need unrefinement." << std::endl;
142 outfile << std::endl;
222 std::ostringstream err_stream;
223 err_stream <<
"p_adapt() called in base class RefineableMeshBase." 225 <<
"This needs to be implemented in the derived class." 228 OOMPH_CURRENT_FUNCTION,
229 OOMPH_EXCEPTION_LOCATION);
248 std::ostringstream err_stream;
249 err_stream <<
"p_refine_uniformly() called in base class RefineableMeshBase." 251 <<
"This needs to be implemented in the derived class." 254 OOMPH_CURRENT_FUNCTION,
255 OOMPH_EXCEPTION_LOCATION);
276 std::ostringstream err_stream;
277 err_stream <<
"p_unrefine_uniformly() called in base class RefineableMeshBase." 279 <<
"This needs to be implemented in the derived class." 282 OOMPH_CURRENT_FUNCTION,
283 OOMPH_EXCEPTION_LOCATION);
354 Max_refinement_level=5;
355 Min_refinement_level=0;
358 Max_p_refinement_level=7;
359 Min_p_refinement_level=2;
372 Uniform_refinement_level_when_pruned=0;
434 virtual void setup_tree_forest()=0;
443 outfile << std::endl;
444 outfile <<
"Targets for mesh adaptation: " << std::endl;
445 outfile <<
"---------------------------- " << std::endl;
448 outfile <<
"Min. refinement level: " << Min_refinement_level << std::endl;
449 outfile <<
"Max. refinement level: " << Max_refinement_level << std::endl;
450 outfile <<
"Min. p-refinement level: " << Min_p_refinement_level
452 outfile <<
"Max. p-refinement level: " << Max_p_refinement_level
455 <<
" elements need unrefinement." << std::endl;
456 outfile << std::endl;
473 virtual void adapt_mesh(
DocInfo& doc_info);
484 adapt_mesh(doc_info);
489 void p_adapt_mesh(
DocInfo& doc_info);
500 p_adapt_mesh(doc_info);
506 elements_to_be_refined);
511 elements_to_be_refined);
516 elements_to_be_refined);
521 elements_to_be_refined_pt);
526 virtual void refine_base_mesh_as_in_reference_mesh(
533 virtual bool refine_base_mesh_as_in_reference_mesh_minus_one(
544 virtual void get_refinement_levels(
unsigned& min_refinement_level,
545 unsigned& max_refinement_level);
550 virtual void get_elements_at_refinement_level(
566 virtual void refine(std::ifstream& restart_file);
569 virtual void dump_refinement(std::ostream &outfile);
572 virtual void read_refinement(std::ifstream& restart_file,
580 return Uniform_refinement_level_when_pruned;
587 return Uniform_refinement_level_when_pruned;
596 const bool& report_stats)
615 synchronise_nonhanging_nodes();
618 unsigned local_ncont_interpolated_values=0;
627 unsigned ncont_interpolated_values=0;
628 MPI_Allreduce(&local_ncont_interpolated_values,
629 &ncont_interpolated_values,1,
630 MPI_UNSIGNED,MPI_MAX,
634 synchronise_hanging_nodes(ncont_interpolated_values);
641 <<
"TreeBasedRefineableMeshBase::synchronise_hanging_nodes() " 642 <<
"incl. time for initial allreduce in " 643 <<
"TreeBasedRefineableMeshBase::classify_halo_and_haloed_nodes(): " 644 << t_end-t_start << std::endl;
671 void synchronise_hanging_nodes(
const unsigned& ncont_interpolated_values);
679 virtual void additional_synchronise_hanging_nodes(
680 const unsigned& ncont_interpolated_values)=0;
686 void synchronise_nonhanging_nodes();
693 virtual void split_elements_if_required()=0;
699 virtual void p_refine_elements_if_required()=0;
702 void complete_hanging_nodes(
const int& ncont_interpolated_values);
706 void complete_hanging_nodes_recursively(
Node*& nod_pt,
768 template <
class ELEMENT>
779 unsigned n_tree = this->Forest_pt->ntree();
782 for (
unsigned long e=0;
e<n_tree;
e++)
784 this->Forest_pt->tree_pt(
e)->
785 traverse_leaves(&Tree::split_if_required<ELEMENT>);
797 unsigned n_tree = this->Forest_pt->ntree();
800 for (
unsigned long e=0;
e<n_tree;
e++)
802 this->Forest_pt->tree_pt(
e)->
803 traverse_leaves(&Tree::p_refine_if_required<ELEMENT>,mesh_pt);
817 void additional_synchronise_hanging_nodes(
818 const unsigned& ncont_interpolated_values);
869 outfile << std::endl;
870 outfile <<
"Targets for mesh adaptation: " << std::endl;
871 outfile <<
"---------------------------- " << std::endl;
874 outfile <<
"Target max edge ratio: " 875 << Max_permitted_edge_ratio << std::endl;
876 outfile <<
"Min. allowed element size: " << Min_element_size << std::endl;
877 outfile <<
"Max. allowed element size: " << Max_element_size << std::endl;
879 <<
" elements need unrefinement." << std::endl;
880 outfile << std::endl;
890 double max_edge_ratio=0.0;
891 unsigned count_unrefined=0;
892 unsigned count_refined=0;
896 for (
unsigned e=0;
e<nel;
e++)
902 double volume=el_pt->
size();
907 for(
unsigned n=0;n<4;++n)
909 for(
unsigned i=0;
i<3;++
i)
918 for(
unsigned i=0;
i<3;++
i)
920 A(0,
i) = vertex[1][
i] - vertex[0][
i];
921 A(1,
i) = vertex[2][
i] - vertex[0][
i];
922 A(2,
i) = vertex[3][
i] - vertex[0][
i];
927 for(
unsigned i=0;
i<3;++
i)
930 for(
unsigned k=0;k<3;++k)
932 rhs[
i] += A(
i,k)*A(
i,k);
942 double circum_radius =
943 sqrt(rhs[0]*rhs[0] + rhs[1]*rhs[1] + rhs[2]*rhs[2]);
947 double min_length = DBL_MAX;
950 for(
unsigned end=
start+1;end<4;++end)
952 for(
unsigned i=0;
i<3;++
i)
954 edge[
i] = vertex[
start][
i] - vertex[end][
i];
957 sqrt(edge[0]*edge[0] + edge[1]*edge[1] + edge[2]*edge[2]);
958 if(length < min_length) {min_length = length;}
963 double local_max_edge_ratio = circum_radius/min_length;
964 if(local_max_edge_ratio > max_edge_ratio)
966 max_edge_ratio = local_max_edge_ratio;
974 target_volume[
e]=std::max(volume/4.0,Min_element_size);
975 if (target_volume[
e]!=Min_element_size)
986 target_volume[
e]=std::min(4.0*volume,Max_element_size);
987 if (target_volume[
e]!=Max_element_size)
995 target_volume[
e] = std::max(volume,Min_element_size);
1004 return max_edge_ratio;
void p_refine_uniformly()
p-refine mesh uniformly
Class of matrices containing doubles, and stored as a DenseMatrix<double>, but with solving functiona...
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
unsigned & uniform_refinement_level_when_pruned()
Level to which the mesh was uniformly refined when it was pruned.
void refine_uniformly()
Refine mesh uniformly.
void resize_halo_nodes()
Helper function that resizes halo nodes to the same size as their non-halo counterparts if required...
void classify_halo_and_haloed_nodes(const bool &report_stats=false)
Classify the halo and haloed nodes in the mesh.
unsigned Min_p_refinement_level
Min. permissible p-refinement level (relative to base mesh)
double & max_error()
Access fct for max. actual error in present solution (i.e. before re-solve on adapted mesh) ...
virtual unsigned unrefine_uniformly()=0
Unrefine mesh uniformly: Return 0 for success, 1 for failure (if unrefinement has reached the coarses...
double & max_permitted_error()
Access fct for max. error (i.e. split elements if their error is larger)
Information for documentation of results: Directory and file number to enable output in the form RESL...
unsigned Uniform_refinement_level_when_pruned
Level to which the mesh was uniformly refined when it was pruned.
void operator=(const RefineableMeshBase &)
Broken assignment operator.
std::string directory() const
Output directory.
double & max_permitted_edge_ratio()
Min edge ratio before remesh gets triggered.
void doc_adaptivity_targets(std::ostream &outfile)
Doc the targets for mesh adaptation.
unsigned Max_keep_unrefined
Max. number of elements that can remain unrefined if no other mesh adaptation is required (to avoid m...
unsigned Master_node_index
TreeForest * forest_pt()
Return pointer to the Forest represenation of the mesh.
A general Finite Element class.
unsigned & nrefinement_overruled()
Number of elements that would have liked to be refined further but can't because they've reached the ...
virtual ~RefineableMeshBase()
Empty Destructor:
void p_refine_elements_if_required()
p-refine all the elements if required. Overload the template-free interface so that any temporary cop...
virtual ~TreeBasedRefineableMesh()
Empty virtual destructor.
virtual void p_refine_uniformly(DocInfo &doc_info)
p-refine mesh uniformly and doc process
unsigned & min_refinement_level()
Access fct for min. permissible refinement level (relative to base mesh)
Base class for spatial error estimators.
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...
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
unsigned & max_keep_unrefined()
Max. number of elements that we allow to remain unrefined if no other mesh adaptation is required (to...
TreeBasedRefineableMesh(const TreeBasedRefineableMesh &dummy)
Broken copy constructor.
unsigned Shared_node_proc
bool Doc_comprehensive_timings
Global boolean to switch on comprehensive timing – can probably be declared const false when develop...
TreeForest * Forest_pt
Forest representation of the mesh.
void enable_additional_synchronisation_of_hanging_nodes()
Enable additional synchronisation of hanging nodes.
bool is_p_adaptation_enabled() const
Return whether the mesh is to be adapted.
void solve(DoubleVector &rhs)
Complete LU solve (replaces matrix by its LU decomposition and overwrites RHS with solution)...
unsigned long nelement() const
Return number of elements in the mesh.
void disable_additional_synchronisation_of_hanging_nodes()
Disable additional synchronisation of hanging nodes.
unsigned & max_refinement_level()
Access fct for max. permissible refinement level (relative to base mesh)
TreeBasedRefineableMeshBase(const TreeBasedRefineableMeshBase &dummy)
Broken copy constructor.
double Max_element_size
Max permitted element size.
void enable_adaptation()
Enable adaptation.
unsigned Sending_processor
ErrorEstimator *& spatial_error_estimator_pt()
Access to spatial error estimator.
double & x(const unsigned &i)
Return the i-th nodal coordinate.
double Max_error
Max. actual error.
virtual void adapt_mesh()
Perform the actual tree-based mesh adaptation. A simple wrapper to call the function without document...
virtual void doc_adaptivity_targets(std::ostream &outfile)
Doc the targets for mesh adaptation.
bool P_adapt_flag
Flag that requests p-adaptation.
unsigned & max_p_refinement_level()
Access fct for max. permissible p-refinement level (relative to base mesh)
void operator=(const TreeBasedRefineableMeshBase &)
Broken assignment operator.
double Max_permitted_error
Max. error (i.e. split elements if their error is larger)
Helper struct to collate data required during TreeBasedRefineableMeshBase::synchronise_hanging_nodes...
void disable_adaptation()
Disable adaptation.
Base class for tree-based refineable meshes.
void classify_halo_and_haloed_nodes(DocInfo &doc_info, const bool &report_stats)
void start(const unsigned &i)
(Re-)start i-th timer
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...
void disable_p_adaptation()
Disable adaptation.
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...
void p_adapt_mesh()
Perform the actual tree-based mesh p-adaptation. A simple wrapper to call the function without docume...
RefineableMeshBase(const RefineableMeshBase &dummy)
Broken copy constructor.
TreeBasedRefineableMesh()
Constructor, call the constructor of the base class.
void enable_p_adaptation()
Enable adaptation.
virtual void refine_uniformly()
Refine mesh uniformly.
void p_unrefine_uniformly(DocInfo &doc_info)
p-unrefine mesh uniformly
double Min_element_size
Min permitted element size.
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
double timer()
returns the time in seconds after some point in past
virtual ~TreeBasedRefineableMeshBase()
Empty Destructor:
Class that contains data for hanging nodes.
bool Resize_halo_nodes_not_required
Set this to true to suppress resizing of halo nodes (at your own risk!)
bool Adapt_flag
Flag that requests adaptation.
FiniteElement * finite_element_pt(const unsigned &e) const
Upcast (downcast?) to FiniteElement (needed to access FiniteElement member functions).
unsigned nrefined()
Access fct for number of elements that were refined.
DocInfo *& doc_info_pt()
Access fct for pointer to DocInfo.
void doc_adaptivity_targets(std::ostream &outfile)
Doc the targets for mesh adaptation.
void disable_doc()
Disable documentation.
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
unsigned nunrefined()
Access fct for number of elements that were unrefined.
unsigned Max_refinement_level
Max. permissible refinement level (relative to base mesh)
unsigned Min_refinement_level
Min. permissible refinement level (relative to base mesh)
virtual void p_refine_uniformly()
p-refine mesh uniformly
DocInfo doc_info()
Access fct for DocInfo.
unsigned Shared_node_id_on_sending_processor
unsigned Nrefinement_overruled
Number of elements that would like to be refined further but can't because they've reached the max...
DocInfo * Doc_info_pt
Pointer to DocInfo.
bool Additional_synchronisation_of_hanging_nodes_not_required
Flag that disables additional synchronisation of hanging nodes.
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...
double & min_error()
Access fct for min. actual error in present solution (i.e. before re-solve on adapted mesh) ...
bool is_additional_synchronisation_of_hanging_nodes_disabled() const
Return whether additional synchronisation is enabled.
unsigned Max_p_refinement_level
Max. permissible p-refinement level (relative to base mesh)
unsigned Nunrefined
Stats: Number of elements that were unrefined.
const Vector< GeneralisedElement * > & element_pt() const
Return reference to the Vector of elements.
double Min_permitted_error
Min. error (i.e. (try to) merge elements if their error is smaller)
Base class for refineable tet meshes.
bool is_adaptation_enabled() const
Return whether the mesh is to be adapted.
unsigned Nrefined
Stats: Number of elements that were refined.
double Min_error
Min.actual error.
TreeBasedRefineableMeshBase()
Constructor.
ErrorEstimator * spatial_error_estimator_pt() const
Access to spatial error estimator (const version.
OomphCommunicator * Comm_pt
Pointer to communicator – set to NULL if mesh is not distributed.
double & min_permitted_error()
Access fct for min. error (i.e. (try to) merge elements if their error is smaller) ...
ErrorEstimator * Spatial_error_estimator_pt
Pointer to spatial error estimator.
unsigned & min_p_refinement_level()
Access fct for min. permissible p-refinement level (relative to base mesh)
unsigned uniform_refinement_level_when_pruned() const
Level to which the mesh was uniformly refined when it was pruned (const version)
double Max_permitted_edge_ratio
Max edge ratio before remesh gets triggered.
void split_elements_if_required()
Split all the elements if required. Overload the template-free interface so that any new elements tha...
double & max_element_size()
Max element size allowed during adaptation.
double & min_element_size()
Min element size allowed during adaptation.