33 #ifndef __H__UG__LIB_DISC__FUNCTION_SPACE__GRID_FUNCTION_UTIL__
34 #define __H__UG__LIB_DISC__FUNCTION_SPACE__GRID_FUNCTION_UTIL__
39 #include <boost/function.hpp>
71 using boost::math::isnan;
75 using boost::math::isinf;
79 template <
typename TBaseElem,
typename TGr
idFunction>
85 const std::vector<number>& vScale
89 std::vector<DoFIndex> vInd;
96 for (; iter != iterEnd; ++iter)
98 for (
size_t fi = 0; fi < dd->num_fct(); ++fi)
100 size_t nInd = dd->inner_dof_indices(*iter, fi, vInd);
103 for (
size_t dof = 0; dof < nInd; ++dof)
104 DoFRef(*vecOut, vInd[dof]) = vScale[fi] *
DoFRef(*vecIn, vInd[dof]);
121 template <
typename TGr
idFunction>
126 const std::vector<number>& scalingFactors
130 size_t n = scalingFactors.size();
131 UG_COND_THROW(n != vecIn->num_fct(),
"Number of scaling factors (" << n <<
") "
132 "does not match number of functions given in dimless vector (" << vecIn->num_fct() <<
").");
135 UG_COND_THROW(n != scaledVecOut->num_fct(),
"Input and output vectors do not have "
136 "the same number of functions (" << n <<
" vs. " << scaledVecOut->num_fct() <<
").");
137 for (
size_t fct = 0; fct < n; ++fct)
139 UG_COND_THROW(vecIn->num_dofs(fct) != scaledVecOut->num_dofs(fct),
140 "Input and output vectors do not have the same number of DoFs for function " << fct
141 <<
" (" << vecIn->num_dofs(fct) <<
" vs. " << scaledVecOut->num_dofs(fct) <<
").");
147 ScaleGFOnElems<Vertex, TGridFunction>(dd, scaledVecOut, vecIn, scalingFactors);
148 if (dd->max_dofs(
EDGE))
149 ScaleGFOnElems<Edge, TGridFunction>(dd, scaledVecOut, vecIn, scalingFactors);
150 if (dd->max_dofs(
FACE))
151 ScaleGFOnElems<Face, TGridFunction>(dd, scaledVecOut, vecIn, scalingFactors);
153 ScaleGFOnElems<Volume, TGridFunction>(dd, scaledVecOut, vecIn, scalingFactors);
170 template<
typename TGr
idFunction,
typename TBaseElem>
173 typedef TGridFunction GF;
174 typedef typename GF::template traits<TBaseElem>::const_iterator iter_type;
176 iter_type iter = spGF->template begin<TBaseElem>();
177 iter_type iterEnd = spGF->template end<TBaseElem>();
182 std::vector<DoFIndex> vMultInd;
183 for(; iter != iterEnd; ++iter)
189 if (pbm && pbm->
is_slave(elem))
continue;
192 spGF->inner_dof_indices(elem, fct, vMultInd);
195 for(
size_t i = 0; i < vMultInd.size(); ++i)
197 DoFRef(*spGF, vMultInd[i]) -= sub;
212 template<
typename TGr
idFunction>
216 const std::vector<std::string>& vCmp,
220 typedef TGridFunction GF;
227 UG_THROW(
"AverageComponent: expects a valid GridFunction.");
230 spGF->approx_space()->dof_distribution_info();
234 std::vector<number> vIntegral(vCmp.size(), 0.0);
235 for(
size_t f = 0; f < vCmp.size(); f++){
236 const size_t fct = spGF->fct_id_by_name(vCmp[f].c_str());
237 vIntegral[f] =
Integral(spGF, vCmp[f].c_str(), NULL, ddinfo->lfeid(fct).order());
241 for(
size_t f = 0; f < vCmp.size(); f++)
243 const number sub = (vIntegral[f] - mean) / area;
244 const size_t fct = spGF->fct_id_by_name(vCmp[f].c_str());
246 if(ddinfo->max_fct_dofs(fct,
VERTEX)) SubtractValueFromComponent<GF, Vertex>(spGF, fct, sub);
247 if(ddinfo->max_fct_dofs(fct,
EDGE)) SubtractValueFromComponent<GF, Edge>(spGF, fct, sub);
248 if(ddinfo->max_fct_dofs(fct,
FACE)) SubtractValueFromComponent<GF, Face>(spGF, fct, sub);
249 if(ddinfo->max_fct_dofs(fct,
VOLUME)) SubtractValueFromComponent<GF, Volume>(spGF, fct, sub);
260 template<
typename TGr
idFunction>
273 template<
typename TGr
idFunction>
289 template<
typename TGr
idFunction>
305 template <
typename TGr
idFunction,
typename TBaseElem>
312 typedef typename TGridFunction::template traits<TBaseElem>::const_iterator t_elem_iter;
314 std::vector<DoFIndex> ind;
319 for (t_elem_iter vi = u->template begin<TBaseElem> ();
320 vi != u->template end<TBaseElem> (); ++vi)
325 u->inner_dof_indices (vert, fct, ind);
327 if (ind.size () != 1)
328 UG_THROW (
"SumGFValuesAt: The function must be scalar!");
331 sum +=
DoFRef (*u, ind [0]);
350 template <
typename TGr
idFunction,
typename TBaseElem>
354 const char * fct_names
358 std::vector<std::string> vfctNames;
360 if (vfctNames.size () != 1)
361 UG_THROW (
"SumGFValuesAt: Exactly one function name must be specified.");
363 fctGroup.
add (vfctNames [0]);
366 return SumGFValuesAt<TGridFunction, TBaseElem> (u, fctGroup[0]);
375 template <
typename TGr
idFunction,
typename TBaseElem>
383 typedef typename TGridFunction::template traits<TBaseElem>::const_iterator t_elem_iter;
385 std::vector<DoFIndex> ind;
390 for (
size_t i = 0; i < ssGroup.
size (); i++)
392 int ssi = ssGroup [i];
395 for (t_elem_iter vi = u->template begin<TBaseElem> (ssi);
396 vi != u->template end<TBaseElem> (ssi); ++vi)
401 u->inner_dof_indices (vert, fct, ind);
403 if (ind.size () != 1)
404 UG_THROW (
"SumGFValuesAt: The function must be scalar!");
407 sum +=
DoFRef (*u, ind [0]);
427 template <
typename TGr
idFunction,
typename TBaseElem>
431 const char * fct_names,
432 const char * subset_names
436 std::vector<std::string> vfctNames;
438 if (vfctNames.size () != 1)
439 UG_THROW (
"SumGFValuesAt: Exactly one function name must be specified.");
441 fctGroup.
add (vfctNames [0]);
444 std::vector<std::string> vssNames;
446 SubsetGroup ssGroup (u->domain()->subset_handler ());
447 ssGroup.
add (vssNames);
450 return SumGFValuesAt<TGridFunction, TBaseElem> (u, fctGroup[0], ssGroup);
463 template <
typename TGr
idFunction,
typename TBaseElem>
466 const TGridFunction * u,
470 typedef typename TGridFunction::template traits<TBaseElem>::const_iterator t_elem_iter;
472 std::vector<DoFIndex> ind;
475 for (t_elem_iter vi = u->template begin<TBaseElem> ();
476 vi != u->template end<TBaseElem> (); ++vi)
481 u->inner_dof_indices (vert, fct, ind);
483 if (ind.size () != 1)
484 UG_THROW (
"CheckGFforNaN: The function must be scalar!");
490 int si = u->domain()->subset_handler()->get_subset_index (vert);
491 UG_LOG (
"nan at index " << ind [0] <<
", grid data idx " << vert->grid_data_index ());
493 UG_LOG (
", subset " << u->domain()->subset_handler()->get_subset_name (si))
499 int si = u->domain()->subset_handler()->get_subset_index (vert);
500 UG_LOG (
"inf at index " << ind [0] <<
", grid data idx " << vert->grid_data_index ());
502 UG_LOG (
", subset " << u->domain()->subset_handler()->get_subset_name (si))
519 template <
typename TGr
idFunction,
typename TBaseElem>
522 const TGridFunction * u,
523 const char * fct_names
527 std::vector<std::string> vfctNames;
530 for (
size_t i = 0; i < vfctNames.size (); i++)
531 fctGroup.
add (vfctNames [i]);
535 for (
size_t i = 0; i < vfctNames.size (); i++)
537 UG_LOG (
"Checking " << vfctNames[i] <<
" ... ");
538 if (CheckGFforNaN<TGridFunction, TBaseElem> (u, fctGroup[i]))
554 template <
typename TGr
idFunction,
typename TBaseElem>
557 const TGridFunction * u,
563 for (
size_t i = 0; i < fctGroup.
size (); i++)
565 UG_LOG (
"Checking fct #" << i <<
" ... ");
566 if (CheckGFforNaN<TGridFunction, TBaseElem> (u, fctGroup[i]))
577 template <
typename TGr
idFunction,
typename TBaseElem>
586 typedef typename TGridFunction::template traits<TBaseElem>::const_iterator elem_it;
591 std::vector<DoFIndex> vDI;
592 elem_it it = u->template begin<TBaseElem>();
593 elem_it itEnd = u->template end<TBaseElem>();
594 for (; it != itEnd; ++it)
599 const size_t nInd = u->inner_dof_indices(elem, cmp, vDI,
true);
600 for (
size_t i = 0; i < nInd; ++i)
603 if (val < lowerBnd || val > upperBnd)
605 UG_LOG_ALL_PROCS(
"Function value for component " << cmp <<
" (" << val <<
") "
606 "is outside the specified range [" << lowerBnd <<
", " << upperBnd <<
"] "
625 template <
typename TGr
idFunction>
635 if (u->max_fct_dofs(cmp, 0))
636 ret = ret && CheckGFValuesWithinBounds<TGridFunction, Vertex>(u, cmp, lowerBnd, upperBnd);
637 if (u->max_fct_dofs(cmp, 1))
638 ret = ret && CheckGFValuesWithinBounds<TGridFunction, Edge>(u, cmp, lowerBnd, upperBnd);
639 if (u->max_fct_dofs(cmp, 2))
640 ret = ret && CheckGFValuesWithinBounds<TGridFunction, Face>(u, cmp, lowerBnd, upperBnd);
641 if (u->max_fct_dofs(cmp, 3))
642 ret = ret && CheckGFValuesWithinBounds<TGridFunction, Volume>(u, cmp, lowerBnd, upperBnd);
647 template <
typename TGr
idFunction>
651 const char* fctNames,
656 std::vector<std::string> vFctNames;
659 const size_t nFct = vFctNames.size();
660 for (
size_t f = 0; f < nFct; ++f)
662 try {fctGroup.
add(vFctNames[f]);}
663 UG_CATCH_THROW(
"Could not add function " << vFctNames[f] <<
" to function group.");
667 const size_t fctGrpSz = fctGroup.
size();
668 for (
size_t f = 0; f < fctGrpSz; ++f)
681 template<
typename TDomain>
690 std::vector<size_t> fctIndex;
691 std::vector<std::string> fctNames;
693 ExtractAlgebraIndices<TDomain>(domain, dd, fctIndex);
695 size_t numFct = dd->num_fct();
696 if(numFct <= 1)
return;
698 fctNames.resize(numFct);
699 for(
size_t i=0; i<numFct; i++)
700 fctNames[i] = dd->name(i);
702 name.append(
".indices");
703 std::fstream file(
name.c_str(), std::ios::out);
706 file <<
"NUMDOF " << fctNames.size() <<
"\n";
707 for(
size_t i=0; i<numFct; i++)
708 file << fctNames[i] <<
"\n";
710 for(
size_t i=0; i<fctIndex.size(); i++)
711 file << fctIndex[i] <<
"\n";
714 template<
class TFunction>
716 const typename TFunction::algebra_type::matrix_type &A,
717 const TFunction &u) {
722 UG_THROW(
"Only '.mat' format supported for matrices, but"
723 " filename is '" << filename <<
"'." );
728 std::vector<MathVector<dim> > vPos;
741 template<
typename TGr
idFunction>
745 typename TGridFunction::vector_type>& A,
746 const char* filename) {
764 std::string comment=
"%Generated with ug4." ) {
769 UG_THROW(
"Please use '.mtx' as file extension for MatrixMarket exchange files."
770 " (Filename is '" << filename <<
"')" );
781 template<
class TFunction>
783 const typename TFunction::algebra_type::vector_type &b,
785 const typename TFunction::algebra_type::vector_type *pCompareVec = NULL) {
789 UG_THROW(
"Only '.vec' format supported for vectors, but"
790 " filename is '" << filename <<
"'." );
795 std::vector<MathVector<dim> > vPos;
803 template<
class TFunction>
805 const char *filename,
806 const typename TFunction::algebra_type::matrix_type &A,
807 const typename TFunction::algebra_type::vector_type &b,
809 const typename TFunction::algebra_type::vector_type *pCompareVec = NULL) {
816 UG_THROW(
"Only '.vec' format supported for vectors." );
820 std::vector<MathVector<dim> > positions;
827 template<
typename TGr
idFunction>
832 template<
typename TGr
idFunction>
837 template<
typename TGr
idFunction>
841 typename TGridFunction::vector_type>& A,
842 const char* filename) {
846 template<
typename TGr
idFunction>
849 TGridFunction& compareVec,
851 typename TGridFunction::vector_type>& A,
852 const char* filename) {
859 template<
typename vector_type>
863 std::cout <<
" Reading std::vector from " << filename <<
"... ";
864 std::fstream matfile(filename.c_str(), std::ios::in);
865 if(matfile.is_open() ==
false) { std::cout <<
"failed.\n";
return false; }
867 int version=-1, dimension=-1, gridsize;
870 matfile >> dimension;
873 assert(version == 1);
874 assert(dimension ==
dim);
876 assert(gridsize == (
int)vec.size());
879 PROGRESS_START(prog, gridsize*2,
"ReadVector " << dimension <<
"d from " << filename <<
" , " << gridsize <<
" x " << gridsize);
880 for(
int i=0; i<gridsize; i++)
885 std::cout <<
" failed.\n";
891 if(dimension==3) matfile >> z;
894 int printStringsInWindow;
895 matfile >> printStringsInWindow;
898 bool bEOF = matfile.eof();
901 int from, to;
double value;
902 char c = matfile.peek();
903 if(c == -1 || c ==
'c' || c ==
'v' || matfile.eof())
906 matfile >> from >> to >> value;
910 bEOF = matfile.eof();
917 template<
typename TGr
idFunction>
920 typename TGridFunction::algebra_type::vector_type b;
921 b.resize(u.num_indices());
927 template<
class TFunction>
929 const typename TFunction::algebra_type::vector_type &b,
930 const TFunction &u) {
937 UG_THROW(
"Only '.csv' format supported for vectors, but"
938 " filename is '" << filename <<
"'." );
944 std::string
name(filename);
945 size_t iExtPos =
name.find_last_of(
".");
946 name.resize(iExtPos);
948 char ext[20]; snprintf(ext, 20,
"_p%05d.csv", rank);
953 std::vector<MathVector<dim> > positions;
960 template<
typename TGr
idFunction>
979 template<
typename TDomain,
typename TAlgebra>
982 std::string subset, std::string fct1, std::string fct2 )
986 size_t subSetID = spGridFct->subset_id_by_name( subset.c_str() );
989 size_t fct1ID = spGridFct->fct_id_by_name( fct1.c_str() );
990 size_t fct2ID = spGridFct->fct_id_by_name( fct2.c_str() );
994 size_t numElements = 0;
998 for( gridFctIterator iter = spGridFct->template begin<Vertex>((
int)subSetID);
999 iter != spGridFct->template end<Vertex>((
int)subSetID); ++iter ) {
1001 std::vector< DoFIndex > indFct1, indFct2;
1002 spGridFct->template dof_indices<Vertex>( *iter, fct1ID, indFct1 );
1003 spGridFct->template dof_indices<Vertex>( *iter, fct2ID, indFct2 );
1006 sum +=
DoFRef( *spGridFct, indFct1[0] ) -
DoFRef( *spGridFct, indFct2[0] );
1011 return sum / numElements;
1019 template<
typename TDomain,
typename TAlgebra>
1115 UG_THROW(
"Only '.mat' format supported for matrices, but"
1116 " filename is '" << filename <<
"'." );
1122 if(mat.num_rows() != mat.num_cols())
1123 UG_THROW(
"DebugWriter: grid level the same, but non-square matrix.");
1125 const std::vector<MathVector<dim> >& vPos = this->
template get_positions<dim>();
1132 const std::vector<MathVector<dim> >& vFromPos = this->
template get_positions<dim>();
1134 std::vector<MathVector<dim> > vToPos;
1139 if(mat.num_cols() == vFromPos.size() && mat.num_rows() == vToPos.size())
1144 UG_THROW(
"GridFunctionDebugWriter: Wrong size of matrix for writing"
1146 <<vToPos.size()<<
" x "<<vFromPos.size()<<
") matrix. But "
1147 "passed matrix of size ("<<mat.num_rows()<<
" x "
1148 <<mat.num_cols()<<
").");
1164 std::vector<MathVector<dim> >& vPos =
1165 this->
template positions<dim>();
1168 ExtractPositions<TDomain>(
1176 const char* filename)
1186 UG_THROW(
"Only '.vec' format supported for vectors, but"
1187 " filename is '" <<
name <<
"'.");
1192 const std::vector<MathVector<dim> >& vPos =
1193 this->
template get_positions<dim>();
1209 TGridFunction vtkFunc(
1212 vtkFunc.resize_values(vec.size());
1213 vtkFunc.assign(vec);
1240 template<
typename TGr
idFunction>
1258 "provide a grid function with set_reference_grid_function");
1271 template<
typename TGr
idFunction,
typename TVector>
1299 "provide a grid function with set_reference_grid_function");
1306 const typename domain_type::position_accessor_type& aaPos =
1307 u.domain()->position_accessor();
1310 int nr = u.num_indices();
1315 typedef typename TGridFunction::template traits<Vertex>::const_iterator const_iterator;
1318 for (
int si = 0; si < u.num_subsets(); ++si) {
1320 const_iterator iter = u.template begin<Vertex>(si);
1321 const_iterator iterEnd = u.template end<Vertex>(si);
1323 for (; iter != iterEnd; ++iter) {
1328 std::vector<size_t> ind;
1331 u.inner_algebra_indices(v, ind);
1336 (*m_userData)(d, aaPos[v], t, si);
1339 for (
size_t i = 0; i < ind.size(); ++i) {
1340 const size_t index = ind[i];
1358 template<
typename TGr
idFunction>
1360 typename TGridFunction::algebra_type::vector_type> {
1405 vec.resize(numDoFs);
location name
Definition: checkpoint_util.lua:128
Definition: smart_pointer.h:296
bool invalid() const
returns true if the pointer is invalid, false if not.
Definition: smart_pointer.h:212
Definition: pcl_process_communicator.h:70
void allreduce(const void *sendBuf, void *recBuf, int count, DataType type, ReduceOperation op) const
performs MPI_Allreduce on the processes of the communicator.
Definition: pcl_process_communicator.cpp:318
base class for approximation spaces without type of algebra or dof distribution
Definition: approximation_space.h:279
Definition: function_group.h:52
void add(size_t fct)
adds a function by id to this group
Definition: function_group.cpp:79
size_t size() const
number of functions in this group
Definition: function_group.h:116
Definition: grid_function_util.h:1021
bool bConnViewerOut
Definition: grid_function_util.h:1223
ApproximationSpace< TDomain > approximation_space_type
type of approximation space
Definition: grid_function_util.h:1036
GridFunctionDebugWriter(SmartPtr< ApproximationSpace< TDomain > > spApproxSpace)
Constructor.
Definition: grid_function_util.h:1043
static const int dim
dimension
Definition: grid_function_util.h:1023
algebra_type::vector_type vector_type
type of vector
Definition: grid_function_util.h:1030
void set_print_consistent(bool b)
sets if data shall be made consistent before printing
Definition: grid_function_util.h:1083
virtual void write_matrix(const matrix_type &mat, const char *filename)
write matrix
Definition: grid_function_util.h:1102
GridLevel m_glTo
Definition: grid_function_util.h:1233
bool bConnViewerIndices
Definition: grid_function_util.h:1224
void set_grid_levels(const GridLevel &glFrom, const GridLevel &glTo)
sets the grid level
Definition: grid_function_util.h:1060
void set_grid_level(const GridLevel &gridLevel)
sets the grid level
Definition: grid_function_util.h:1055
virtual void write_vector(const vector_type &vec, const char *filename)
write vector
Definition: grid_function_util.h:1086
GridLevel grid_level() const
returns current grid level
Definition: grid_function_util.h:1065
void set_vtk_output(bool b)
sets if writing to vtk
Definition: grid_function_util.h:1074
SmartPtr< approximation_space_type > m_spApproxSpace
Definition: grid_function_util.h:1220
bool bVTKOut
Definition: grid_function_util.h:1227
IDebugWriter< TAlgebra > super
Definition: grid_function_util.h:1038
GridLevel m_glFrom
Definition: grid_function_util.h:1233
void set_conn_viewer_indices(bool b)
sets if .indices file is written or conn viewer
Definition: grid_function_util.h:1080
bool m_printConsistent
Definition: grid_function_util.h:1230
virtual ~GridFunctionDebugWriter()
Definition: grid_function_util.h:1052
void write_algebra_indices_CV(std::string name)
Definition: grid_function_util.h:1155
virtual void write_vector_to_conn_viewer(const vector_type &vec, const char *filename)
write vector
Definition: grid_function_util.h:1175
void reset()
sets to toplevel on surface
Definition: grid_function_util.h:1068
TAlgebra algebra_type
type of matrix
Definition: grid_function_util.h:1027
void set_conn_viewer_output(bool b)
sets if writing to conn viewer
Definition: grid_function_util.h:1077
algebra_type::matrix_type matrix_type
type of matrix
Definition: grid_function_util.h:1033
virtual void update_positions()
Definition: grid_function_util.h:1096
void extract_positions(const GridLevel &gridLevel)
reads the positions
Definition: grid_function_util.h:1162
void write_vector_to_vtk(const vector_type &vec, const char *filename)
Definition: grid_function_util.h:1200
represents numerical solutions on a grid using an algebraic vector
Definition: grid_function.h:121
Definition: grid_function_util.h:1242
GridFunctionPositionProvider()
Constructor.
Definition: grid_function_util.h:1245
GridFunctionPositionProvider(const TGridFunction &u)
Definition: grid_function_util.h:1248
void set_reference_grid_function(const TGridFunction &u)
Definition: grid_function_util.h:1251
virtual bool get_positions(std::vector< MathVector< TGridFunction::domain_type::dim > > &vec)
Definition: grid_function_util.h:1255
const TGridFunction * m_pGridFunc
Definition: grid_function_util.h:1264
Definition: grid_function_util.h:1360
TGridFunction::domain_type domain_type
Definition: grid_function_util.h:1362
algebra_type::vector_type vector_type
Definition: grid_function_util.h:1367
GridFunctionVectorWriterDirichlet0()
Constructor.
Definition: grid_function_util.h:1372
vector_type::value_type value_type
Definition: grid_function_util.h:1368
virtual bool update(vector_type &vec)
Definition: grid_function_util.h:1390
void set_level(size_t level)
Definition: grid_function_util.h:1376
TGridFunction::approximation_space_type approximation_space_type
Definition: grid_function_util.h:1364
size_t m_level
Definition: grid_function_util.h:1416
SmartPtr< IConstraint< algebra_type > > m_spPostProcess
Definition: grid_function_util.h:1415
TGridFunction::algebra_type algebra_type
Definition: grid_function_util.h:1366
approximation_space_type * m_pApproxSpace
Definition: grid_function_util.h:1414
void init(SmartPtr< IConstraint< algebra_type > > pp, approximation_space_type &approxSpace)
Definition: grid_function_util.h:1380
Definition: grid_function_util.h:1272
void set_user_data(SmartPtr< UserData< number, domain_type::dim > > userData)
Definition: grid_function_util.h:1284
virtual bool update(vector_type &vec)
write vector
Definition: grid_function_util.h:1296
GridFunctionVectorWriter()
Constructor.
Definition: grid_function_util.h:1280
void set_reference_grid_function(const TGridFunction &u)
Definition: grid_function_util.h:1288
TVector vector_type
Definition: grid_function_util.h:1276
const TGridFunction * m_pGridFunc
Definition: grid_function_util.h:1350
TGridFunction::domain_type domain_type
Definition: grid_function_util.h:1275
SmartPtr< UserData< number, domain_type::dim > > m_userData
Definition: grid_function_util.h:1351
TVector::value_type value_type
Definition: grid_function_util.h:1274
Definition: grid_level.h:42
@ TOP
Definition: grid_level.h:45
@ SURFACE
Definition: grid_level.h:48
@ LEVEL
Definition: grid_level.h:48
interface for adjustment of constraints
Definition: constraint_interface.h:63
base class for all debug writer
Definition: debug_writer.h:244
TAlgebra::vector_type vector_type
type of vector
Definition: debug_writer.h:250
TAlgebra::matrix_type matrix_type
type of matrix
Definition: debug_writer.h:253
Interface for providing vertex positions.
Definition: debug_writer.h:46
base class for all vector debug writer
Definition: debug_writer.h:118
std::string get_base_dir()
Definition: debug_writer.h:192
void compose_file_path(std::string &path)
composes the path for the files and creates the intermediate directories (up to the base one):
Definition: debug_writer.h:210
Interface for modifying a vector (e.g, setting Dirichlet values, ...)
Definition: vector_writer.h:42
OpenMode
Specifies how file names pointing to non-existing files should be handeld.
Definition: matrix_io.h:129
@ EXISTING
Only existing files are valid files (i.e. non-existing file result in error)
Definition: matrix_io.h:131
@ NEW
Non-existing files are created with the specified file name.
Definition: matrix_io.h:133
Provides I/O functionality for MatrixMarket exchange file format.
Definition: matrix_io_mtx.h:84
void write_from(matrix_type &matrix, std::string comment="%Generated with ug4.")
Writes a ug matrix into the associated MatrixMarket exchange file.
Definition: matrix_io_mtx.h:287
Definition: matrix_operator.h:49
virtual M & get_matrix()
Definition: matrix_operator.h:74
Definition: periodic_boundary_manager.h:99
bool is_slave(TElem *) const
Definition: periodic_boundary_manager_impl.hpp:498
Definition: progress.h:50
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(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
@ ALL
Definition: surface_view.h:102
Type based UserData.
Definition: user_data.h:143
output writer to the VTK file format
Definition: vtkoutput.h:150
void print(const char *filename, TFunction &u, int step, number time, bool makeConsistent)
Definition: vtkoutput_impl.h:184
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
#define PCL_RO_SUM
Definition: pcl_methods.h:63
int ProcRank()
returns the rank of the process
Definition: pcl_base.cpp:83
int NumProcs()
returns the number of processes
Definition: pcl_base.cpp:91
#define PCL_RO_BAND
Definition: pcl_methods.h:66
base_type::TBaseElem TBaseElem
UG_API bool FileExists(const char *filename)
!!! Serial i/o version !!!
Definition: file_util.cpp:53
bool FileTypeIs(const char *filename, const char *extension)
!!! Serial i/o version !!!
Definition: file_util.cpp:86
#define UG_LOG_ALL_PROCS(msg)
Definition: log.h:371
#define UG_ASSERT(expr, msg)
Definition: assert.h:70
#define UG_CATCH_THROW(msg)
Definition: error.h:64
#define UG_THROW(msg)
Definition: error.h:57
#define UG_LOG(msg)
Definition: log.h:367
#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
void WriteVectorPar(std::string filename, const Vector_type &b, const postype *positions, int dimensions, const Vector_type *compareVec=NULL)
Definition: connection_viewer_output.h:425
void WriteMatrixPar(std::string name, const Matrix_type &A, const postype *positions, int dimensions)
Definition: connection_viewer_output.h:153
string GetParallelName(string name, const pcl::ProcessCommunicator &pc, bool bWriteHeader)
Definition: connection_viewer_output.cpp:51
CPUAlgebra::vector_type vector_type
bool CheckGFforNaN(const TGridFunction *u, size_t fct)
Definition: grid_function_util.h:465
bool ReadVector(std::string filename, vector_type &vec, int dim)
Definition: grid_function_util.h:860
@ CT_DIRICHLET
Definition: ass_tuner.h:59
number SumGFValuesAt(TGridFunction *u, size_t fct)
Definition: grid_function_util.h:307
void SaveMatrixForConnectionViewer(TGridFunction &u, MatrixOperator< typename TGridFunction::algebra_type::matrix_type, typename TGridFunction::vector_type > &A, const char *filename)
Definition: grid_function_util.h:742
void ScaleGF(SmartPtr< TGridFunction > scaledVecOut, ConstSmartPtr< TGridFunction > vecIn, const std::vector< number > &scalingFactors)
Scales all functions contained in a grid function.
Definition: grid_function_util.h:123
number & DoFRef(TMatrix &mat, const DoFIndex &iInd, const DoFIndex &jInd)
Definition: multi_index.h:276
void SaveVectorForConnectionViewer(TGridFunction &b, const char *filename)
Definition: grid_function_util.h:828
void ExtractPositions(ConstSmartPtr< TDomain > domain, ConstSmartPtr< DoFDistribution > dd, std::vector< MathVector< TDomain::dim > > &vPos)
Definition: dof_position_util.cpp:424
void TokenizeTrimString(const string &str, vector< string > &vToken, const char delimiter)
Definition: string_util.cpp:83
void SaveMatrixToMTX(const char *filename, MatrixOperator< CPUAlgebra::matrix_type, CPUAlgebra::vector_type > &A, std::string comment="%Generated with ug4.")
Save the assembled matrix of a matrix operator to MatrixMarket format.
Definition: grid_function_util.h:762
void WriteVectorCSV(const char *filename, const Vector_type &b, postype *positions, int dimensions)
writes to a file in somewhat SparseMatrix-market format (for connection viewer)
Definition: csv_gnuplot_output.h:59
void TokenizeString(const string &str, vector< string > &vToken, const char delimiter)
Definition: string_util.cpp:56
void WriteAlgebraIndices(std::string name, ConstSmartPtr< TDomain > domain, ConstSmartPtr< DoFDistribution > dd)
Definition: grid_function_util.h:682
void SaveVectorDiffForConnectionViewer(TGridFunction &b, TGridFunction &bCompare, const char *filename)
Definition: grid_function_util.h:833
void LoadVector(TGridFunction &u, const char *filename)
Definition: grid_function_util.h:918
void SubtractValueFromComponent(SmartPtr< TGridFunction > spGF, size_t fct, number sub)
Definition: grid_function_util.h:171
void WriteVectorToConnectionViewer(const char *filename, const typename TFunction::algebra_type::vector_type &b, const TFunction &u, const typename TFunction::algebra_type::vector_type *pCompareVec=NULL)
Definition: grid_function_util.h:782
double & BlockRef(T &vec, size_t i)
Definition: blocks.h:66
number AverageFunctionDifference(SmartPtr< GridFunction< TDomain, TAlgebra > > spGridFct, std::string subset, std::string fct1, std::string fct2)
Calculates the average of the pointwise difference of two functions on given subset.
Definition: grid_function_util.h:980
void AdjustMeanValue(SmartPtr< TGridFunction > spGF, const std::vector< std::string > &vCmp, number mean)
Definition: grid_function_util.h:214
@ VOLUME
Definition: grid_base_objects.h:63
@ VERTEX
Definition: grid_base_objects.h:60
@ EDGE
Definition: grid_base_objects.h:61
@ FACE
Definition: grid_base_objects.h:62
void WriteMatrixToConnectionViewer(const char *filename, const typename TFunction::algebra_type::matrix_type &A, const TFunction &u)
Definition: grid_function_util.h:715
void SaveVectorCSV(TGridFunction &b, const char *filename)
Definition: grid_function_util.h:961
static void ScaleGFOnElems(ConstSmartPtr< DoFDistribution > dd, SmartPtr< TGridFunction > vecOut, ConstSmartPtr< TGridFunction > vecIn, const std::vector< number > &vScale)
Definition: grid_function_util.h:81
bool CheckGFValuesWithinBounds(ConstSmartPtr< TGridFunction > u, size_t cmp, number lowerBnd, number upperBnd)
Definition: grid_function_util.h:579
size_t GetSize(const T &t)
number Integral(SmartPtr< UserData< number, TGridFunction::dim > > spData, TGridFunction &spGridFct, const char *subsets, number time, int quadOrder, std::string quadType)
Definition: integrate.h:856
#define PROFILE_FUNC_GROUP(groups)
Definition: profiler.h:258
#define PROFILE_FUNC()
Definition: profiler.h:257
#define PROGRESS_START(progVarName, dSize, msg)
Definition: progress.h:111
#define PROGRESS_UPDATE(progVarName, d)
Definition: progress.h:117
T value_type
Definition: sparsematrix_interface.h:2