3#include <boost/container/flat_set.hpp>
33 constexpr double pi = 3.1415926535897931;
34 const double ratio = r /
_c;
41 factor = 5. * (1. / (3 *
_c));
69 double functionRadius)
72 PRECICE_CHECK(functionRadius > 0,
"Function radius must be greater zero.");
76 const short grainDim = 3;
77 _lucyFunction = std::make_unique<impl::LucyKernelFunction>(
static_cast<short>(grainDim), functionRadius);
91 for (Eigen::Index i = 0; i < coordinates.cols(); ++i) {
93 auto dest = index.getVerticesInsideBox(src,
_lucyFunction->getFunctionRadius());
95 for (
const auto &d : dest) {
99 target.col(d) += coeff * source.col(i);
124 PRECICE_ERROR(
"only just-in-time-mapping variant is implemented.");
129 PRECICE_ERROR(
"only just-in-time-mapping conservative variant is implemented.");
146 return "coarse-graining";
172 PRECICE_ASSERT(
false,
"Only just-in-time mapping is implemented, but the mapping is not configured as just-in-time.");
#define PRECICE_ERROR(...)
#define PRECICE_TRACE(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
#define PRECICE_UNREACHABLE(...)
const std::string & getName() const
Returns the name of the mesh, as set in the config file.
Vertex & vertex(VertexID id)
Mutable access to a vertex by VertexID.
const query::Index & index() const
Call preprocess() before index() to ensure correct projection handling.
void mapConsistent(const time::Sample &inData, Eigen::VectorXd &outData) override
Maps data using a consistent constraint.
void clear() final override
Removes a computed mapping.
CoarseGrainingMapping(Constraint constraint, int meshDimension, double functionRadius)
Constructor.
void tagMeshFirstRound() final override
Method used by partition. Tags vertices that could be owned by this rank.
void mapConservative(const time::Sample &inData, Eigen::VectorXd &outData) override
Maps data using a conservative constraint.
void mapConsistentAt(const Eigen::Ref< const Eigen::MatrixXd > &coordinates, const impl::MappingDataCache &cache, Eigen::Ref< Eigen::MatrixXd > values) final override
For reading data just-in-time (only consistent at the moment)
std::unique_ptr< impl::LucyKernelFunction > _lucyFunction
std::string getName() const final override
name of the coarse-graining mapping
void computeMapping() final override
Computes the mapping coefficients from the in- and output mesh.
void mapConservativeAt(const Eigen::Ref< const Eigen::MatrixXd > &coordinates, const Eigen::Ref< const Eigen::MatrixXd > &source, impl::MappingDataCache &cache, Eigen::Ref< Eigen::MatrixXd > target) final override
For writing data just-in-time (only conservative at the moment)
void tagMeshSecondRound() final override
Method used by partition. Tags vertices that can be filtered out.
mesh::PtrMesh output() const
Returns pointer to output mesh.
Constraint
Specifies additional constraints for a mapping.
Mapping(Constraint constraint, int dimensions, bool requiresGradientData, InitialGuessRequirement initialGuessRequirement)
Constructor, takes mapping constraint.
mesh::PtrMesh input() const
Returns pointer to input mesh.
bool _hasComputedMapping
Flag to indicate whether computeMapping() has been called.
bool isJustInTimeMapping() const
Constraint getConstraint() const
Returns the constraint (consistent/conservative) of the mapping.
virtual bool hasConstraint(const Constraint &constraint) const
Checks whether the mapping has the given constraint or not.
InitialGuessRequirement
Specifies whether the mapping requires an initial guess.
double getFunctionRadius() const
LucyKernelFunction(short grainDim, double functionRadius)
double evaluate(double r) const
const RawCoords & rawCoords() const
Direct access to the coordinates.
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.
constexpr T pow_int(const T base)
Computes the power of a given number by an integral exponent given at compile time,...
static constexpr SynchronizeTag Synchronize
Convenience instance of the SynchronizeTag.
constexpr auto get(span< E, S > s) -> decltype(s[N])