G+Smo  24.08.0
Geometry + Simulation Modules
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
gsPreCICEFunction.h
Go to the documentation of this file.
1 
14 #pragma once
15 
16 #include <gsCore/gsLinearAlgebra.h>
17 #include <gsCore/gsGeometry.h>
19 #include <gsPreCICE/gsPreCICE.h>
20 
21 namespace gismo
22 {
23 
29 template <class T>
30 class gsPreCICEFunction : public gsFunction<T>
31 {
32 public:
33  typedef gsGeometry<T> Base;
34 
36  typedef memory::shared_ptr< gsPreCICEFunction > Ptr;
37 
39  typedef memory::unique_ptr< gsPreCICEFunction > uPtr;
40 
43 
53  gsPreCICEFunction( gsPreCICE<T> * interface,
54  const index_t & meshID,
55  const index_t & dataID,
56  const gsMultiPatch<T> & patches,
57  const bool parametric = false)
58  :
59  m_interface(interface),
60  m_meshID(meshID),
61  m_dataID(dataID),
62  m_patches(patches),
63  m_parametric(parametric),
64  m_patchID(0),
65  m_domainDim(m_patches.domainDim())
66  {
67  }
68 
70  static uPtr make( const gsPreCICE<T> * interface,
71  const index_t & meshID,
72  const index_t & dataID,
73  const gsMultiPatch<T> & patches,
74  const bool parametric = false)
75  { return uPtr(new gsPreCICEFunction(interface, meshID, dataID, patches, parametric)); }
76 
77  GISMO_CLONE_FUNCTION(gsPreCICEFunction)
78 
79 
80  const gsPreCICEFunction<T> & piece(const index_t) const
81  {
82  return *this;
83  }
84 
86  virtual short_t domainDim() const
87  { return m_domainDim; }
88 
90  virtual short_t targetDim() const
91  { return 1; }
92 
94  virtual void eval_into(const gsMatrix<T>& u, gsMatrix<T>& result) const
95  {
96  GISMO_ASSERT(u.rows() == m_domainDim, "Wrong domain dimension "<< u.rows()
97  << ", expected "<< m_domainDim);
98 
99  // Does not work
100  // if (m_parametric)
101  // m_interface->readBlockScalarData(m_meshID,m_dataID,m_patches.patch(m_patchID).eval(u),result);
102  // if (m_parametric)
103  // m_interface->readBlockScalarData(m_meshID,m_dataID,u,result);
104 
105  gsMatrix<T> coords(m_patches.targetDim(),u.cols());
106  if (m_parametric)
107  m_patches.patch(m_patchID).eval_into(u,coords);
108  else
109  coords = u;
110 
111  m_interface->readBlockScalarData(m_meshID,m_dataID,coords,result);
112  }
113 
115  virtual void deriv_into(const gsMatrix<T>& u, gsMatrix<T>& result) const
116  {
117  // This would be nice to have with higher-order (IGA) coupling of precice
119  }
120 
122  virtual void deriv2_into(const gsMatrix<T>& u, gsMatrix<T>& result) const
123  {
124  // This would be nice to have with higher-order (IGA) coupling of precice
126  }
127 
129  void evalAllDers_into(const gsMatrix<T> & u, int n,
130  std::vector<gsMatrix<T> > & result) const
131  {
132  // This would be nice to have with higher-order (IGA) coupling of precice
133  gsMatrix<T> tmp;
134  this->eval_into(u,tmp);
135  result.push_back(tmp);
136  }
137 
139  virtual std::ostream &print(std::ostream &os) const
140  {
141  os << "gsPreCICEFunction, defined using gsPreCICE (precice::SolverInterface):\n";
142  os << m_interface;
143  return os;
144  }
145 
146 
147 private:
148 
149  gsPreCICE<T> * m_interface;
150  index_t m_meshID, m_dataID;
151  gsMultiPatch<T> m_patches;
152  bool m_parametric;
153  index_t m_patchID;
154  index_t m_domainDim;
155 
156 };
157 
158 }
Abstract base class representing a geometry map.
Definition: gsGeometry.h:92
virtual short_t targetDim() const
Gives the targetDomain, currently only scalar functions (todo)
Definition: gsPreCICEFunction.h:90
#define GISMO_NO_IMPLEMENTATION
Definition: gsDebug.h:129
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
See gsFunction.
Definition: gsPreCICEFunction.h:94
#define short_t
Definition: gsConfig.h:35
memory::unique_ptr< gsPreCICEFunction > uPtr
Unique pointer for gsPreCICEFunction.
Definition: gsPreCICEFunction.h:39
Provides declaration of Geometry abstract interface.
#define index_t
Definition: gsConfig.h:32
A function from a n-dimensional domain to an m-dimensional image.
Definition: gsFunction.h:59
virtual std::ostream & print(std::ostream &os) const
See gsFunction.
Definition: gsPreCICEFunction.h:139
memory::unique_ptr< gsFunction > uPtr
Unique pointer for gsFunction.
Definition: gsFunction.h:68
Provides combinatorial unitilies.
#define GISMO_ASSERT(cond, message)
Definition: gsDebug.h:89
virtual short_t domainDim() const
See gsFunction.
Definition: gsPreCICEFunction.h:86
Header file for using gsPreCICE extension.
static uPtr make(const gsPreCICE< T > *interface, const index_t &meshID, const index_t &dataID, const gsMultiPatch< T > &patches, const bool parametric=false)
Constructs a function pointer.
Definition: gsPreCICEFunction.h:70
Interface for the set of functions defined on a domain (the total number of functions in the set equa...
Definition: gsFuncData.h:23
Container class for a set of geometry patches and their topology, that is, the interface connections ...
Definition: gsMultiPatch.h:33
const gsPreCICEFunction< T > & piece(const index_t) const
Access a piece.
Definition: gsPreCICEFunction.h:80
memory::shared_ptr< gsPreCICEFunction > Ptr
Shared pointer for gsPreCICEFunction.
Definition: gsPreCICEFunction.h:36
gsPreCICEFunction()
Default constructor.
Definition: gsPreCICEFunction.h:42
void evalAllDers_into(const gsMatrix< T > &u, int n, std::vector< gsMatrix< T > > &result) const
See gsFunction.
Definition: gsPreCICEFunction.h:129
This is the main header file that collects wrappers of Eigen for linear algebra.
virtual void deriv_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
See gsFunction.
Definition: gsPreCICEFunction.h:115
virtual void deriv2_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
See gsFunction.
Definition: gsPreCICEFunction.h:122
gsPreCICEFunction(gsPreCICE< T > *interface, const index_t &meshID, const index_t &dataID, const gsMultiPatch< T > &patches, const bool parametric=false)
Constructs a new instance of the gsPreCICEFunction.
Definition: gsPreCICEFunction.h:53
Class defining a gsFunction that reads from the precice::SolverInterface.
Definition: gsPreCICEFunction.h:30