5#include <boost/container/flat_set.hpp>
32template <
typename RADIAL_BASIS_FUNCTION_T>
55 RADIAL_BASIS_FUNCTION_T function,
64 void computeCacheData(
const Eigen::Ref<const Eigen::MatrixXd> &globalIn, Eigen::MatrixXd &polyOut, Eigen::MatrixXd &coefficientsOut)
const;
94 void initializeCacheData(Eigen::MatrixXd &polynomial, Eigen::MatrixXd &coeffs,
const int nComponents);
138template <
typename RADIAL_BASIS_FUNCTION_T>
142 RADIAL_BASIS_FUNCTION_T function,
157 auto inIDs = inputMesh->index().getVerticesInsideBox(center, radius);
161 _inputIDs.insert(inIDs.begin(), inIDs.end());
162 _outputIDs.insert(outIDs.begin(), outIDs.end());
169 PRECICE_DEBUG(
"SphericalVertexCluster input size: {}", inIDs.size());
170 PRECICE_DEBUG(
"SphericalVertexCluster output size: {}", outIDs.size());
184template <
typename RADIAL_BASIS_FUNCTION_T>
201template <
typename RADIAL_BASIS_FUNCTION_T>
210 const unsigned int nComponents = inData.
dataDims;
211 const auto &localInData = inData.
values;
214 Eigen::VectorXd in(
_rbfSolver.getOutputSize());
217 for (
unsigned int c = 0; c < nComponents; ++c) {
220 for (
unsigned int i = 0; i <
_outputIDs.size(); ++i) {
222 PRECICE_ASSERT(dataIndex * nComponents + c < localInData.size(), dataIndex * nComponents + c, localInData.size());
233 for (
unsigned int i = 0; i <
_inputIDs.size(); ++i) {
234 const auto dataIndex = *(
_inputIDs.nth(i));
235 PRECICE_ASSERT(dataIndex * nComponents + c < outData.size(), dataIndex * nComponents + c, outData.size());
236 outData[dataIndex * nComponents + c] += result(i);
241template <
typename RADIAL_BASIS_FUNCTION_T>
244 Eigen::MatrixXd localIn(
_inputIDs.size(), Au.cols());
245 _rbfSolver.evaluateConservativeCache(epsilon, Au, localIn);
248 const auto dataIndex = *(
_inputIDs.nth(i));
250 out.col(dataIndex) += localIn.row(i);
254template <
typename RADIAL_BASIS_FUNCTION_T>
258 Eigen::MatrixXd in(
_rbfSolver.getInputSize(), globalIn.rows());
262 const auto dataIndex = *(
_inputIDs.nth(i));
264 in.row(i) = globalIn.col(dataIndex);
270template <
typename RADIAL_BASIS_FUNCTION_T>
277template <
typename RADIAL_BASIS_FUNCTION_T>
279 Eigen::MatrixXd &epsilon, Eigen::MatrixXd &Au,
286template <
typename RADIAL_BASIS_FUNCTION_T>
290 poly.resize(
_rbfSolver.getNumberOfPolynomials(), nComponents);
292 coeffs.resize(
_inputIDs.size(), nComponents);
295template <
typename RADIAL_BASIS_FUNCTION_T>
304 const unsigned int nComponents = inData.
dataDims;
305 const auto &localInData = inData.
values;
307 Eigen::VectorXd in(
_rbfSolver.getInputSize());
310 for (
unsigned int c = 0; c < nComponents; ++c) {
313 for (
unsigned int i = 0; i <
_inputIDs.size(); i++) {
314 const auto dataIndex = *(
_inputIDs.nth(i));
315 PRECICE_ASSERT(dataIndex * nComponents + c < localInData.size(), dataIndex * nComponents + c, localInData.size());
316 in[i] = localInData[dataIndex * nComponents + c];
324 for (
unsigned int i = 0; i <
_outputIDs.size(); ++i) {
326 PRECICE_ASSERT(dataIndex * nComponents + c < outData.size(), dataIndex * nComponents + c, outData.size());
334template <
typename RADIAL_BASIS_FUNCTION_T>
340 return _weightingFunction.evaluate(
std::sqrt(res));
343template <
typename RADIAL_BASIS_FUNCTION_T>
349template <
typename RADIAL_BASIS_FUNCTION_T>
355template <
typename RADIAL_BASIS_FUNCTION_T>
361template <
typename RADIAL_BASIS_FUNCTION_T>
#define PRECICE_DEBUG(...)
#define PRECICE_TRACE(...)
#define PRECICE_ASSERT(...)
This class provides a lightweight logger.
Wendland radial basis function with compact support.
boost::container::flat_set< VertexID > _outputIDs
Global VertexIDs associated to the output mesh (see constructor)
void computeCacheData(const Eigen::Ref< const Eigen::MatrixXd > &globalIn, Eigen::MatrixXd &polyOut, Eigen::MatrixXd &coefficientsOut) const
Computes and saves the RBF coefficients.
unsigned int getNumberOfInputVertices() const
Number of input vertices this partition operates on.
Eigen::VectorXd _normalizedWeights
mesh::Vertex _center
center vertex of the cluster
const double _radius
radius of the vertex cluster
std::array< double, 3 > getCenterCoords() const
The center coordinate of this cluster.
double computeWeight(const mesh::Vertex &v) const
Compute the weight for a given vertex.
void initializeCacheData(Eigen::MatrixXd &polynomial, Eigen::MatrixXd &coeffs, const int nComponents)
bool _hasComputedMapping
Boolean switch in order to indicate that a mapping was computed.
CompactPolynomialC2 _weightingFunction
The weighting function.
Eigen::VectorXd interpolateAt(const mesh::Vertex &v, const Eigen::MatrixXd &poly, const Eigen::MatrixXd &coeffs, const mesh::Mesh &inMesh) const
void setNormalizedWeight(double normalizedWeight, VertexID vertexID)
Set the normalized weight for the given vertexID in the outputMesh.
Polynomial _polynomial
Polynomial treatment in the RBF solver.
RadialBasisFctSolver< RADIAL_BASIS_FUNCTION_T > _rbfSolver
The RBF solver.
void mapConsistent(const time::Sample &inData, Eigen::VectorXd &outData) const
Evaluates a consistent mapping and agglomerates the result in the given output data.
void clear()
Invalidates and erases data structures the cluster holds.
void evaluateConservativeCache(Eigen::MatrixXd &epsilon, const Eigen::MatrixXd &Au, Eigen::Ref< Eigen::MatrixXd > out)
SphericalVertexCluster(mesh::Vertex center, double radius, RADIAL_BASIS_FUNCTION_T function, Polynomial polynomial, mesh::PtrMesh inputMesh, mesh::PtrMesh outputMesh)
boost::container::flat_set< VertexID > _inputIDs
Global VertexIDs associated to the input mesh (see constructor)
void mapConservative(const time::Sample &inData, Eigen::VectorXd &outData) const
Evaluates a conservative mapping and agglomerates the result in the given output data.
RADIAL_BASIS_FUNCTION_T _function
precice::logging::Logger _log
logger, as usual
void addWriteDataToCache(const mesh::Vertex &v, const Eigen::VectorXd &load, Eigen::MatrixXd &epsilon, Eigen::MatrixXd &Au, const mesh::Mesh &inMesh)
Container and creator for meshes.
const RawCoords & rawCoords() const
Direct access to the coordinates.
void stop()
Stops a running event.
contains data mapping from points to meshes.
double computeSquaredDifference(const std::array< double, 3 > &u, std::array< double, 3 > v, const std::array< bool, 3 > &activeAxis={{true, true, true}})
Deletes all dead directions from fullVector and returns a vector of reduced dimensionality.
Polynomial
How to handle the polynomial?
constexpr double NUMERICAL_ZERO_DIFFERENCE
std::shared_ptr< Mesh > PtrMesh
int dataDims
The dimensionality of the data.