G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsAdaptiveMeshingUtils.h
1 
14 #pragma once
15 
16 
17 #include <iostream>
18 
19 namespace gismo
20 {
21 
22 
31 template<typename T>
33 {
34 public:
41  gsElementErrorPlotter(const gsBasis<T>& basis, const std::vector<T>& errors )
42  : m_basis(basis),m_errors(errors)
43  { }
44 
45  virtual void eval_into(const gsMatrix<T>& u, gsMatrix<T>& res) const
46  {
47  // Initialize domain element iterator -- using unknown 0
48  res.setZero(1,u.cols());
49  for(index_t i=0; i<u.cols();++i)
50  {
51  int iter =0;
52  // Start iteration over elements
53 
54  typename gsBasis<T>::domainIter domIt = m_basis.makeDomainIterator();
55  for (; domIt->good(); domIt->next() )
56  {
57  bool flag = true;
58  const gsVector<T>& low = domIt->lowerCorner();
59  const gsVector<T>& upp = domIt->upperCorner();
60 
61 
62  for(int d=0; d<domainDim();++d )
63  {
64  if(low(d)> u(d,i) || u(d,i) > upp(d))
65  {
66  flag = false;
67  break;
68  }
69  }
70  if(flag)
71  {
72  res(0,i) = m_errors.at(iter);
73  break;
74  }
75  iter++;
76  }
77  }
78  }
79 
80  short_t domainDim() const { return m_basis.dim();}
81 
82 private:
83  const gsBasis<T>& m_basis;
84  const std::vector<T>& m_errors;
85 };
86 
87 } // namespace gismo
#define short_t
Definition: gsConfig.h:35
#define index_t
Definition: gsConfig.h:32
A function from a n-dimensional domain to an m-dimensional image.
Definition: gsFunction.h:59
short_t domainDim() const
Dimension of the (source) domain.
Definition: gsAdaptiveMeshingUtils.h:80
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &res) const
Evaluate the function at points u into result.
Definition: gsAdaptiveMeshingUtils.h:45
const gsBasis< T > & basis(const index_t k) const
Helper which casts and returns the k-th piece of this function set as a gsBasis.
Definition: gsFunctionSet.hpp:33
This class provides a function that returns a constant error on each element.
Definition: gsAdaptiveMeshingUtils.h:32
A basis represents a family of scalar basis functions defined over a common parameter domain...
Definition: gsBasis.h:78
gsElementErrorPlotter(const gsBasis< T > &basis, const std::vector< T > &errors)
Constructs a function to plot the error of elements.
Definition: gsAdaptiveMeshingUtils.h:41