28 return IT::Record(
"OutputMesh",
"Parameters of the refined output mesh.")
30 "Maximal level of refinement of the output mesh.")
32 "Set true for using error_control_field. Set false for global uniform refinement to max_level.")
34 "Name of an output field, according to which the output mesh will be refined. The field must be a SCALAR one.")
36 "Tolerance for element refinement by error. If tolerance is reached, refinement is stopped." 37 "Relative difference between error control field and its linear approximation on element is computed" 38 "and compared with tolerance.")
102 unsigned int elm_idx[1];
103 unsigned int node_idx[1];
104 unsigned int region_idx[1];
106 elem_ids_ = std::make_shared< ElementDataCache<unsigned int> >(
"elements_ids", (
unsigned int)1, 1, this->
n_elements());
107 node_ids_ = std::make_shared< ElementDataCache<unsigned int> >(
"node_ids", (
unsigned int)1, 1, this->
n_nodes());
108 region_ids_ = std::make_shared< ElementDataCache<unsigned int> >(
"region_ids", (
unsigned int)1, 1, this->
n_elements());
109 partitions_ = std::make_shared< ElementDataCache<int> >(
"partitions", (
unsigned int)1, 1, this->
n_elements());
111 for (
unsigned int i = 0; i < this->
n_elements(); ++i, ++it) {
113 else elm_idx[0] = it->idx();
117 region_ids_->store_value( i, region_idx );
120 partitions_->store_value( i, partition );
123 for (
unsigned int j = 0; j < it->n_nodes(); ++j) {
125 else node_idx[0] = node_list[j];
126 node_ids_->store_value( node_list[j], node_idx );
161 DebugOut() <<
"Create outputmesh identical to computational one.";
167 unsigned int coord_id = 0,
169 auto &node_vec = *(
nodes_->get_component_data(0).get() );
174 node_vec[coord_id] = node->getX(); coord_id++;
175 node_vec[coord_id] = node->getY(); coord_id++;
176 node_vec[coord_id] = node->getZ(); coord_id++;
184 unsigned int ele_id = 0,
188 auto &offset_vec = *( offsets_->get_component_data(0).get() );
191 offset += ele->dim() + 1;
192 offset_vec[ele_id] = offset;
193 (*orig_element_indices_)[ele_id] = ele_id;
197 const unsigned int n_connectivities = offset_vec[offset_vec.size()-1];
199 1, n_connectivities);
200 auto &connect_vec = *(
connectivity_->get_component_data(0).get() );
203 node = ele->node[li];
204 connect_vec[connect_id] = node->
aux;
213 ASSERT(0).error(
"Not implemented yet.");
219 ASSERT(0).error(
"Not implemented yet.");
226 ASSERT(0).error(
"Not implemented yet.");
257 DebugOut() <<
"Create discontinuous outputmesh.";
264 unsigned int ele_id = 0,
270 auto &offset_vec = *( offsets_->get_component_data(0).get() );
273 offset += ele->dim() + 1;
274 offset_vec[ele_id] = offset;
275 (*orig_element_indices_)[ele_id] = ele_id;
280 const unsigned int n_corners = offset_vec[offset_vec.size()-1];
286 auto &node_vec = *(
nodes_->get_component_data(0).get() );
287 auto &conn_vec = *(
connectivity_->get_component_data(0).get() );
293 node = ele->node[li];
294 node_vec[coord_id] = node->
getX(); ++coord_id;
295 node_vec[coord_id] = node->
getY(); ++coord_id;
296 node_vec[coord_id] = node->
getZ(); ++coord_id;
298 conn_vec[corner_id] = corner_id;
309 DebugOut() <<
"Create refined discontinuous outputmesh.\n";
317 unsigned int last_offset = 0;
319 auto &node_vec = *(
nodes_->get_component_data(0).get() );
320 auto &conn_vec = *(
connectivity_->get_component_data(0).get() );
321 auto &offset_vec = *(
offsets_->get_component_data(0).get() );
331 ele_idx = ele->index();
335 aux_ele.
nodes.resize(ele->n_nodes());
338 Node* node;
unsigned int li;
340 node = ele->node[li];
347 case 1: this->refine_aux_element<1>(aux_ele, refinement, ele->element_accessor());
break;
348 case 2: this->refine_aux_element<2>(aux_ele, refinement, ele->element_accessor());
break;
349 case 3: this->refine_aux_element<3>(aux_ele, refinement, ele->element_accessor());
break;
350 default:
ASSERT(0 < dim && dim < 4);
355 unsigned int node_offset = node_vec.size(),
356 con_offset = conn_vec.size();
357 node_vec.resize(node_vec.size() + (refinement.size() * (dim+1))*
spacedim);
358 conn_vec.resize(conn_vec.size() + refinement.size()*(dim+1));
363 for(
unsigned int i=0; i < refinement.size(); i++)
365 last_offset += dim+1;
366 offset_vec.push_back(last_offset);
367 (*orig_element_indices_).push_back(ele_idx);
368 for(
unsigned int j=0; j < dim+1; j++)
370 unsigned int con = i*(dim+1) + j;
371 conn_vec[con_offset + con] = con_offset + con;
373 for(
unsigned int k=0; k <
spacedim; k++) {
374 node_vec[node_offset + con*spacedim + k] = refinement[i].nodes[j][k];
380 conn_vec.shrink_to_fit();
381 node_vec.shrink_to_fit();
382 offset_vec.shrink_to_fit();
386 offsets_->set_n_values(offset_vec.size());
411 static const unsigned int n_subelements = 1 << dim;
491 refinement.push_back(aux_element);
503 nodes.reserve(n_old_nodes+n_new_nodes);
506 for(
unsigned int e=0; e < n_new_nodes; e++)
510 nodes.push_back( p / 2.0);
514 unsigned int diagonal = 0;
517 double min_diagonal = arma::norm(nodes[4]-nodes[9],2);
518 double d = arma::norm(nodes[5]-nodes[8],2);
519 if(d < min_diagonal){
523 d = arma::norm(nodes[6]-nodes[7],2);
524 if(d < min_diagonal){
530 for(
unsigned int i=0; i < n_subelements; i++)
533 sub_ele.
nodes.resize(n_old_nodes);
537 for(
unsigned int j=0; j < n_old_nodes; j++)
539 unsigned int conn_id = (n_old_nodes)*i + j;
540 sub_ele.
nodes[j] = nodes[conn[dim+diagonal][conn_id]];
542 refine_aux_element<dim>(sub_ele, refinement, ele_acc);
550 DebugOut() <<
"Create output submesh containing only local elements.";
555 const unsigned int n_local_elements = el_ds->
lsize();
560 unsigned int ele_id = 0,
565 auto &offset_vec = *( offsets_->get_component_data(0).get() );
566 for (
unsigned int loc_el = 0; loc_el < n_local_elements; loc_el++) {
569 offset += ele->dim() + 1;
570 offset_vec[ele_id] = offset;
571 (*orig_element_indices_)[ele_id] = el_4_loc[loc_el];
576 const unsigned int n_corners = offset_vec[offset_vec.size()-1];
582 auto &node_vec = *(
nodes_->get_component_data(0).get() );
583 auto &conn_vec = *(
connectivity_->get_component_data(0).get() );
585 for (
unsigned int loc_el = 0; loc_el < n_local_elements; loc_el++) {
589 node = ele->node[li];
590 node_vec[coord_id] = node->
getX(); ++coord_id;
591 node_vec[coord_id] = node->
getY(); ++coord_id;
592 node_vec[coord_id] = node->
getZ(); ++coord_id;
594 conn_vec[corner_id] = corner_id;
619 for(
auto& v : aux_ele.
nodes ) centre += v;
620 centre = centre/aux_ele.
nodes.size();
642 point_list.push_back(centre);
643 point_list.insert(point_list.end(), ele.
nodes.begin(), ele.
nodes.end());
650 double average_val = 0.0;
651 for(
unsigned int i=1; i<ele.
nodes.size()+1; ++i)
652 average_val += val_list[i];
653 average_val = average_val / ele.
nodes.size();
655 double diff = std::abs((average_val - val_list[0])/val_list[0]);
Classes for auxiliary output mesh.
void create_refined_mesh() override
Creates refined mesh.
int IdxInt
Define integers that are indices into large arrays (elements, nodes, dofs etc.)
static const unsigned int spacedim
Shortcut instead of spacedim template. We suppose only spacedim=3 at the moment.
#define FOR_ELEMENT_NODES(i, j)
Base class for Output mesh.
GeneralIterator< OutputElement > OutputElementIterator
std::function< void(const std::vector< Space< spacedim >::Point > &, const ElementAccessor< spacedim > &, std::vector< double > &)> ErrorControlFieldFunc
bool refinement_criterion_error(const AuxElement &ele, const Space< spacedim >::Point ¢re, const ElementAccessor< spacedim > &ele_acc)
Refinement flag - measures discretisation error according to error control field. ...
unsigned int n_elements()
Returns number of element.
Mesh * orig_mesh_
Pointer to the computational mesh.
#define FOR_ELEMENTS(_mesh_, __i)
void create_mesh() override
Creates the output mesh identical to the orig mesh.
IdxInt * get_el_4_loc() const
~OutputMeshDiscontinuous()
void create_mesh() override
Creates the output mesh identical to the orig mesh.
static const Input::Type::Record & get_input_type()
The specification of output mesh.
const unsigned int max_level_
Maximal level of refinement.
double refinement_error_tolerance_
Tolerance for error criterion refinement.
std::shared_ptr< ElementDataCache< unsigned int > > connectivity_
Vector maps the nodes to their coordinates in vector nodes_.
bool refinement_criterion(const AuxElement &ele, const ElementAccessor< spacedim > &ele_acc)
Collects different refinement criteria results.
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
std::shared_ptr< ElementDataCache< unsigned int > > node_ids_
Vector gets ids of nodes. Data is used in GMSH output.
std::shared_ptr< ElementDataCache< unsigned int > > offsets_
Vector of offsets of node indices of elements. Maps elements to their nodes in connectivity_.
unsigned int n_nodes()
Returns number of nodes.
std::shared_ptr< ElementDataCache< double > > nodes_
Vector of node coordinates. [spacedim x n_nodes].
unsigned int n_elements() const
ErrorControlFieldFunc error_control_field_func_
Refinement error control field function (hold value_list function of field).
arma::vec::fixed< spacedim > Point
static const IdxVector< (InDim >OutDim?InDim+1:dim-InDim) > interact(TInteraction< OutDim, InDim > interaction)
Auxiliary structure defining element of refined output mesh.
void refine_aux_element(const AuxElement &aux_element, std::vector< AuxElement > &refinement, const ElementAccessor< spacedim > &ele_acc)
Performs the actual refinement of AuxElement. Recurrent.
void set_error_control_field(ErrorControlFieldFunc error_control_field_func)
Selects the error control field computing function of output field set according to input record...
std::shared_ptr< ElementDataCache< unsigned int > > region_ids_
Vector gets ids of regions. Data is used in GMSH output.
bool refinement_criterion()
virtual ~OutputMeshBase()
void create_sub_mesh() override
Creates sub mesh.
#define FOR_NODES(_mesh_, i)
Distribution * get_el_ds() const
OutputMeshDiscontinuous(Mesh &mesh)
Input::Record input_record_
Input record for output mesh.
bool refinement_criterion_uniform(const AuxElement &ele)
Refinement flag - checks only maximal level of refinement.
OutputElementIterator end()
Gives iterator to the LAST element of the output mesh.
Support classes for parallel programing.
friend class OutputElement
Friend provides access to vectors for element accessor class.
std::shared_ptr< ElementDataCache< int > > partitions_
Vector gets partitions of elements. Data is used in GMSH output.
#define ELEMENT_FULL_ITER_NULL(_mesh_)
#define ASSERT_PTR(ptr)
Definition of assert macro checking non-null pointer (PTR)
bool refine_by_error_
True, if output mesh is to be refined by error criterion.
Class OutputElement and its iterator OutputElementIterator on the output mesh.
Class RefElement defines numbering of vertices, sides, calculation of normal vectors etc...
unsigned int n_nodes() const
MeshType mesh_type_
Type of OutputMesh.
std::vector< Space< spacedim >::Point > nodes
General iterator template. Provides iterator over objects in some container.
void create_id_caches()
Create nodes and elements data caches.
bool is_created()
Check if nodes_, connectivity_ and offsets_ data caches are created.
std::shared_ptr< ElementDataCache< unsigned int > > elem_ids_
Vector gets ids of elements. Data is used in GMSH output.
#define DebugOut()
Macro defining 'debug' record of log.
#define ASSERT_PTR_DBG(ptr)
Definition of assert macro checking non-null pointer (PTR) only for debug mode.
void create_refined_mesh() override
Creates discontinuous refined mesh.
same as original (computational) mesh
NodeVector node_vector
Vector of nodes of the mesh.
std::shared_ptr< std::vector< unsigned int > > orig_element_indices_
Vector of element indices in the computational mesh. (Important when refining.)
OutputElementIterator begin()
Gives iterator to the FIRST element of the output mesh.
void create_sub_mesh() override
Creates sub mesh.
ElementVector element
Vector of elements of the mesh.
OutputMeshBase(Mesh &mesh)
Constructor. Takes computational mesh as a parameter.
unsigned int lsize(int proc) const
get local size