33 #ifndef __H__UG__LIB_DISC__IO__VTK_EXPORT_HO__
34 #define __H__UG__LIB_DISC__IO__VTK_EXPORT_HO__
75 template <
typename TDomain,
class TElem>
84 typedef typename TDomain::subset_handler_type SH_type;
97 for (iter_t eiter = sel.
begin<TElem>(); eiter != sel.
end<TElem>(); ++eiter)
100 vrts.
resize(e->num_vertices());
101 for (
size_t iv = 0; iv < e->num_vertices(); ++iv)
107 destSH->assign_subset(ne, srcSH->get_subset_index(e));
111 template <
typename TDomain>
119 typedef typename TDomain::position_attachment_type APos_type;
120 typedef typename TDomain::subset_handler_type SH_type;
128 APos_type& aPos = srcDom->position_attachment();
139 for (
int si = destSH->num_subsets(); si < srcSH->num_subsets(); ++si)
140 destSH->subset_info(si) = srcSH->subset_info(si);
152 aaPosDest[nv] = aaPosSrc[v];
153 destSH->assign_subset(nv, srcSH->get_subset_index(v));
156 CopySelectedElements<TDomain,Edge>(destDom, srcDom, sel, aNewVrt);
157 CopySelectedElements<TDomain,Face>(destDom, srcDom, sel, aNewVrt);
158 CopySelectedElements<TDomain,Volume>(destDom, srcDom, sel, aNewVrt);
164 template <
typename TElem,
typename TGr
idFunction,
typename TGGFND>
168 const TGGFND& u_orig,
173 typedef typename TGridFunction::domain_type dom_type;
178 size_t numSubsets = u_new->num_subsets();
179 for (
size_t si = 0; si < numSubsets; ++si)
181 if (!u_new->is_def_in_subset(fct, si))
continue;
183 const_iter_type elem_iter = u_new->template begin<TElem>(si);
184 const_iter_type iterEnd = u_new->template end<TElem>(si);
186 std::vector<DoFIndex> ind;
187 for (; elem_iter != iterEnd; ++elem_iter)
189 u_new->inner_dof_indices(*elem_iter, fct, ind);
192 std::vector<MathVector<dim> > globPos;
193 InnerDoFPosition<dom_type>(globPos, *elem_iter, *u_new->domain(), lfeid);
196 "#DoF mismatch: InnerDoFPosition() found " << globPos.size()
197 <<
", but grid function has " << ind.size() << std::endl
201 for (
size_t dof = 0; dof < ind.size(); ++dof)
203 if (!u_orig.evaluate(
DoFRef(*u_new, ind[dof]), globPos[dof]))
205 DoFRef(*u_new, ind[dof]) = std::numeric_limits<number>::quiet_NaN();
215 template <
typename TGr
idFunction,
int trueDim>
219 const std::vector<std::string>& vFct,
222 const char* filename,
232 bool printAll = ssg.
size() == (size_t) u->subset_handler()->num_subsets();
234 vtkOutput->print(filename, *u, step, time);
237 for (
size_t s = 0;
s < ssg.
size(); ++
s)
238 vtkOutput->print_subset(filename, *u, ssg[
s], step, time);
244 typedef typename TGridFunction::domain_type dom_type;
245 typedef typename TGridFunction::algebra_type algebra_type;
246 typedef typename dom_type::position_attachment_type position_attachment_type;
247 typedef typename TGridFunction::approximation_space_type approx_space_type;
248 typedef typename TGridFunction::template dim_traits<trueDim>::grid_base_object elem_type;
256 srcSel.
select(u->template begin<elem_type>(), u->template end<elem_type>());
260 try {dom_ptr =
new dom_type();}
275 size_t numRefs = (size_t) ceil(log2(order));
276 for (
size_t iref = 0; iref <
numRefs; ++iref)
278 try {refiner.refine();}
279 UG_CATCH_THROW(
"Refinement step " << iref <<
" could not be carried out.");
283 FunctionGroup fg(srcApproxSpace->dof_distribution_info(), vFct);
286 approx_space_type* approx_ptr;
287 try {approx_ptr =
new approx_space_type(destDom, algebra_type::get_type());}
288 UG_CATCH_THROW(
"Temporary approximation space could not be created.");
291 for (
size_t fct = 0; fct < fg.
size(); ++fct)
294 destApproxSpace->add(fg.
name(fct),
"Lagrange", 1);
299 for (
int si = 0; si < num_subsets; ++si)
304 if (!subsets.empty())
307 destApproxSpace->add(fg.
name(fct),
"Lagrange", 1, subsets.c_str());
310 destApproxSpace->init_top_surface();
312 TGridFunction* gridFct_ptr;
313 try {gridFct_ptr =
new TGridFunction(destApproxSpace);}
318 for (
size_t fct = 0; fct < fg.
size(); ++fct)
320 const LFEID lfeid = u_new->dof_distribution()->lfeid(fct);
327 if (u_new->max_dofs(
VERTEX))
328 interpolate_from_original_fct<Vertex, TGridFunction, GlobalGridFunctionNumberData<TGridFunction, trueDim> >
329 (u_new, ggfnd, fct, lfeid);
345 u_new->set_storage_type(u->get_storage_mask());
346 u_new->set_layouts(u->layouts());
350 bool printAll = ssg.
size() == (size_t) u->subset_handler()->num_subsets();
352 vtkOutput->print(filename, *u_new, step, time);
355 for (
size_t s = 0;
s < ssg.
size(); ++
s)
356 vtkOutput->print_subset(filename, *u_new, ssg[
s], step, time);
382 template <
typename TGr
idFunction>
386 const std::vector<std::string>& vFct,
389 const char* filename,
392 const std::vector<std::string>& vSubset
407 MultiGrid& srcGrid = *u->approx_space()->domain()->grid();
410 (u, vFct, order, vtkOutput, filename, step, time, ssg);
413 (u, vFct, order, vtkOutput, filename, step, time, ssg);
416 (u, vFct, order, vtkOutput, filename, step, time, ssg);
419 (u, vFct, order, vtkOutput, filename, step, time, ssg);
421 vtk_export_ho<TGridFunction, TGridFunction::dim>(u, vFct, order, vtkOutput, filename, step, time, ssg);
425 template <
typename TGr
idFunction>
429 const std::vector<std::string>& vFct,
432 const char* filename,
433 const std::vector<std::string>& vSubset
436 vtk_export_ho(u, vFct, order, vtkOutput, filename, 0, 0.0, vSubset);
440 template <
typename TGr
idFunction>
444 const std::vector<std::string>& vFct,
447 const char* filename,
452 vtk_export_ho(u, vFct, order, vtkOutput, filename, step, time, std::vector<std::string>());
456 template <
typename TGr
idFunction>
460 const std::vector<std::string>& vFct,
466 vtk_export_ho(u, vFct, order, vtkOutput, filename, 0, 0.0, std::vector<std::string>());
Definition: smart_pointer.h:296
this class can be used if one wants to create a custom element from a set of vertices.
Definition: grid_base_objects.h:336
void set_vertex(size_t index, Vertex *vrt)
Definition: grid_base_objects.h:350
void resize(size_t newSize)
Definition: grid_base_objects.h:347
Definition: function_group.h:52
ConstSmartPtr< FunctionPattern > function_pattern() const
get underlying function pattern
Definition: function_group.h:73
const char * name(size_t i) const
returns the name of a function
Definition: function_group.cpp:205
size_t unique_id(size_t i) const
returns unique function id of a function
Definition: function_group.h:128
size_t size() const
number of functions in this group
Definition: function_group.h:116
Definition: grid_function_global_user_data.h:58
Definition: global_multi_grid_refiner.h:48
size_t num_volumes() const
Definition: grid.h:554
size_t num_faces() const
Definition: grid.h:553
size_t num_vertices() const
Definition: grid.h:551
void detach_from_vertices(IAttachment &attachment)
Definition: grid.h:787
bool has_vertex_attachment(IAttachment &attachment)
Definition: grid.h:798
size_t num_edges() const
Definition: grid.h:552
void attach_to_vertices(IAttachment &attachment, bool passOnValues)
Definition: grid.h:728
void select(GridObject *elem, byte status)
selects an element
Definition: selector_interface_impl.hpp:56
Identifier for Local Finite Elements.
Definition: local_finite_element_id.h:98
Definition: multi_grid.h:72
VertexIterator create_by_cloning(Vertex *pCloneMe, int level)
this method creates a new vertex, which has the same type as pCloneMe.
Definition: multi_grid.cpp:128
specialization of ISelector for a grid of class Grid.
Definition: selector_grid.h:96
geometry_traits< TElem >::iterator end()
Definition: selector_grid_impl.hpp:134
geometry_traits< TElem >::iterator begin()
Definition: selector_grid_impl.hpp:106
Group of subsets.
Definition: subset_group.h:51
size_t size() const
number of subsets in this group
Definition: subset_group.h:122
void add_all()
select all subsets of underlying subset handler
Definition: subset_group.cpp:133
void add(int si)
adds a subset by number to this group
Definition: subset_group.cpp:64
Const iterator to traverse the surface of a multi-grid hierarchy.
Definition: surface_view.h:237
Adds parallel support to a global refiner.
Definition: parallel_global_refiner_t.h:50
output writer to the VTK file format
Definition: vtkoutput.h:150
Base-class for all vertex-types.
Definition: grid_base_objects.h:231
std::string ElementDebugInfo(const Grid &grid, GridObject *e)
Returns a string containing information on the given element.
Definition: debug_util.cpp:991
void SelectAssociatedGridObjects(TSelector &sel, ISelector::status_t status)
selects associated geometric objects of selected ones on each level.
Definition: selection_util.cpp:221
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_CATCH_THROW(msg)
Definition: error.h:64
#define UG_COND_THROW(cond, msg)
UG_COND_THROW(cond, msg) : performs a UG_THROW(msg) if cond == true.
Definition: error.h:61
double number
Definition: types.h:124
ElementStorage< Vertex >::SectionContainer::iterator VertexIterator
This Iterator will be used as base-class for iterators of specialized geometric objects.
Definition: grid_base_object_traits.h:73
void CopySelectedElements(SmartPtr< TDomain > destDom, SmartPtr< TDomain > srcDom, Selector &sel, AVertex &aNewVrt)
Definition: vtk_export_ho.h:77
number & DoFRef(TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)
Definition: multi_index.h:276
@ VERTEX
Definition: grid_base_objects.h:60
void CopySelected(SmartPtr< TDomain > destDom, SmartPtr< TDomain > srcDom, Selector &sel)
Definition: vtk_export_ho.h:113
void vtk_export_ho(SmartPtr< TGridFunction > u, const std::vector< std::string > &vFct, size_t order, SmartPtr< VTKOutput< TGridFunction::domain_type::dim > > vtkOutput, const char *filename, size_t step, number time, const SubsetGroup &ssg)
Definition: vtk_export_ho.h:217
void interpolate_from_original_fct(SmartPtr< TGridFunction > u_new, const TGGFND &u_orig, size_t fct, const LFEID &lfeid)
Definition: vtk_export_ho.h:166
SmartPtr< T, FreePolicy > make_sp(T *inst)
returns a SmartPtr for the passed raw pointer
Definition: smart_pointer.h:836
geometry_traits< TElem >::iterator iterator
Definition: grid.h:143