39void addSubtagsToParents(std::list<xml::XMLTag> &subtags,
40 std::list<xml::XMLTag> &parents)
42 for (
auto &p : parents) {
43 p.addSubtags(subtags);
49using variant_t = std::variant<xml::XMLAttribute<double>, xml::XMLAttribute<std::string>, xml::XMLAttribute<bool>, xml::XMLAttribute<int>>;
50template <
typename TagStorage>
51void addAttributes(TagStorage &storage,
const std::vector<variant_t> &attributes)
53 for (
auto &s : storage) {
54 for (
auto &a : attributes)
55 std::visit([&s](
auto &&arg) { s.addAttribute(arg); }, a);
60enum struct RBFBackend {
69template <RBFBackend Backend,
typename RBF>
70struct BackendSelector {
75template <
typename RBF>
76struct BackendSelector<RBFBackend::Eigen, RBF> {
77 typedef mapping::RadialBasisFctMapping<RadialBasisFctSolver<RBF>> type;
81#ifndef PRECICE_NO_PETSC
82template <
typename RBF>
83struct BackendSelector<RBFBackend::PETSc, RBF> {
84 typedef mapping::PetRadialBasisFctMapping<RBF> type;
89#ifndef PRECICE_NO_GINKGO
90template <
typename RBF>
91struct BackendSelector<RBFBackend::Ginkgo, RBF> {
92 typedef mapping::RadialBasisFctMapping<GinkgoRadialBasisFctSolver<RBF>, MappingConfiguration::GinkgoParameter> type;
96template <
typename RBF>
97struct BackendSelector<RBFBackend::PUM, RBF> {
98 typedef mapping::PartitionOfUnityMapping<RBF> type;
102using rbf_variant_t = std::variant<CompactPolynomialC0, CompactPolynomialC2, CompactPolynomialC4, CompactPolynomialC6, CompactPolynomialC8, CompactThinPlateSplinesC2, ThinPlateSplines, VolumeSplines, Multiquadrics, InverseMultiquadrics, Gaussian>;
105template <RBFBackend T,
typename RADIAL_BASIS_FUNCTION_T,
typename... Args>
109 return PtrMapping(
new typename BackendSelector<T, RADIAL_BASIS_FUNCTION_T>::type(constraint, dimension, function, std::forward<Args>(args)...));
113rbf_variant_t constructRBF(
BasisFunction functionType,
double supportRadius,
double shapeParameter)
116 switch (functionType) {
118 return mapping::CompactPolynomialC0(supportRadius);
121 return mapping::CompactPolynomialC2(supportRadius);
124 return mapping::CompactPolynomialC4(supportRadius);
127 return mapping::CompactPolynomialC6(supportRadius);
130 return mapping::CompactPolynomialC8(supportRadius);
153 }
catch (std::invalid_argument &e) {
154 logging::Logger
_log{
"MappingConfiguration"};
162template <RBFBackend T,
typename... Args>
167 auto functionVariant = constructRBF(functionType, supportRadius, shapeParameter);
169 return std::visit([&](
auto &&func) {
return instantiateRBFMapping<T>(constraint, dimension, func, std::forward<Args>(args)...); }, functionVariant);
182 XMLTag::Occurrence occ = XMLTag::OCCUR_ARBITRARY;
183 std::list<XMLTag> projectionTags{
184 XMLTag{*
this,
TYPE_NEAREST_NEIGHBOR, occ,
TAG}.setDocumentation(
"Nearest-neighbour mapping which uses a rstar-spatial index tree to index meshes and run nearest-neighbour queries."),
185 XMLTag{*
this,
TYPE_NEAREST_PROJECTION, occ,
TAG}.setDocumentation(
"Nearest-projection mapping which uses a rstar-spatial index tree to index meshes and locate the nearest projections."),
186 XMLTag{*
this,
TYPE_NEAREST_NEIGHBOR_GRADIENT, occ,
TAG}.setDocumentation(
"Nearest-neighbor-gradient mapping which uses nearest-neighbor mapping with an additional linear approximation using gradient data."),
187 XMLTag{*
this,
TYPE_LINEAR_CELL_INTERPOLATION, occ,
TAG}.setDocumentation(
"Linear cell interpolation mapping which uses a rstar-spatial index tree to index meshes and locate the nearest cell. Only supports 2D meshes.")};
188 std::list<XMLTag> rbfDirectTags{
189 XMLTag{*
this,
TYPE_RBF_GLOBAL_DIRECT, occ,
TAG}.setDocumentation(
"Radial-basis-function mapping using a direct solver with a gather-scatter parallelism.")};
190 std::list<XMLTag> rbfIterativeTags{
191 XMLTag{*
this,
TYPE_RBF_GLOBAL_ITERATIVE, occ,
TAG}.setDocumentation(
"Radial-basis-function mapping using an iterative solver with a distributed parallelism.")};
192 std::list<XMLTag> pumDirectTags{
193 XMLTag{*
this,
TYPE_RBF_PUM_DIRECT, occ,
TAG}.setDocumentation(
"Radial-basis-function mapping using a partition of unity method, which supports a distributed parallelism.")};
194 std::list<XMLTag> rbfAliasTag{
195 XMLTag{*
this,
TYPE_RBF_ALIAS, occ,
TAG}.setDocumentation(
"Alias tag, which auto-selects a radial-basis-function mapping depending on the simulation parameter,")};
196 std::list<XMLTag> coarseGrainingTags{
197 XMLTag{*
this,
TYPE_COARSE_GRAINING, occ,
TAG}.setDocumentation(
"Coarse graining specifically designed for particle-mesh coupling to write data from the particles to the mesh. The mapping transforms an extensive quantity (e.g., volume, force) into an intensive quantity (e.g., porosity, force-density). "
198 " Currently implemented as just-in-time mapping. Although the constraint does not really fit here (the input is conservative, the output not), we classify it as \"conservative\" for the configuration.")};
199 std::list<XMLTag> axialGeoMultiscaleTags{
201 .setDocumentation(
"Axial geometric multiscale mapping between one 1D and multiple 3D vertices.")};
202 std::list<XMLTag> radialGeoMultiscaleTags{
204 .setDocumentation(
"Radial geometric multiscale mapping between multiple 1D and multiple 3D vertices, distributed along a principle axis.")};
209 .setDocumentation(
"Write mappings map written data prior to communication, thus in the same participant who writes the data. "
210 "Read mappings map received data after communication, thus in the same participant who reads the data.");
212 auto attrFromMesh = XMLAttribute<std::string>(
ATTR_FROM,
"")
213 .setDocumentation(
"The mesh to map the data from. The default name is an empty mesh name, which is only valid for a just-in-time mapping (using the API functions \"writeAndMapData\" or \"mapAndReadData\").");
215 auto attrToMesh = XMLAttribute<std::string>(
ATTR_TO,
"")
216 .setDocumentation(
"The mesh to map the data to. The default name is an empty mesh name, which is only valid for a just-in-time mapping (using the API functions \"writeAndMapData\" or \"mapAndReadData\").");
219 .setDocumentation(
"Use conservative to conserve the nodal sum of the data over the interface (needed e.g. for force mapping). Use consistent for normalized quantities such as temperature or pressure. Use scaled-consistent-surface or scaled-consistent-volume for normalized quantities where conservation of integral values (surface or volume) is needed (e.g. velocities when the mass flow rate needs to be conserved). Mesh connectivity is required to use scaled-consistent.")
221 auto attrXDead = makeXMLAttribute(
ATTR_X_DEAD,
false)
222 .setDocumentation(
"If set to true, the x axis will be ignored for the mapping");
223 auto attrYDead = makeXMLAttribute(
ATTR_Y_DEAD,
false)
224 .setDocumentation(
"If set to true, the y axis will be ignored for the mapping");
225 auto attrZDead = makeXMLAttribute(
ATTR_Z_DEAD,
false)
226 .setDocumentation(
"If set to true, the z axis will be ignored for the mapping");
228 .setDocumentation(
"Toggles use of the global polynomial")
231 .setDocumentation(
"Toggles use a local (per cluster) polynomial")
235 .setDocumentation(
"Radius or range of the coarsening function (Lucy function).");
238 .setDocumentation(
"Solver relative tolerance for convergence");
244 .setDocumentation(
"Average number of vertices per cluster (partition) applied in the rbf partition of unity method.");
246 .setDocumentation(
"Value between 0 and 1 indicating the relative overlap between clusters. A value of 0.15 is usually a good trade-off between accuracy and efficiency.");
248 .setDocumentation(
"If enabled, places the cluster centers at the closest vertex of the input mesh. Should be enabled in case of non-uniform point distributions such as for shell structures.");
251 .setDocumentation(
"Specifies the dimensionality pairing used in geometric multiscale mapping. Options: '1D-3D', '1D-2D' or '2D-3D'.")
254 .setDocumentation(
"Type of geometric multiscale mapping. Either 'spread' or 'collect'.")
257 .setDocumentation(
"Principle axis along which geometric multiscale mapping is performed.")
260 .setDocumentation(
"Radius of the cross-sectional interface between the participants.");
262 .setDocumentation(
"Profile of the mapped variable along the cross-sectional interface: 'uniform' or 'parabolic'")
266 .setDocumentation(
"Cross section of the interface of the participants: 'circle' or 'square'")
271 addAttributes(projectionTags, {attrFromMesh, attrToMesh, attrDirection, attrConstraint});
272 addAttributes(rbfDirectTags, {attrFromMesh, attrToMesh, attrDirection, attrConstraint, attrPolynomial, attrXDead, attrYDead, attrZDead});
273 addAttributes(rbfIterativeTags, {attrFromMesh, attrToMesh, attrDirection, attrConstraint, attrPolynomial, attrXDead, attrYDead, attrZDead, attrSolverRtol});
274 addAttributes(pumDirectTags, {attrFromMesh, attrToMesh, attrDirection, attrConstraint, attrPumPolynomial, verticesPerCluster, relativeOverlap, projectToInput});
275 addAttributes(rbfAliasTag, {attrFromMesh, attrToMesh, attrDirection, attrConstraint, attrXDead, attrYDead, attrZDead});
276 addAttributes(coarseGrainingTags, {attrFromMesh, attrToMesh, attrDirection, attrConstraint, attrcgRadius});
277 addAttributes(axialGeoMultiscaleTags, {attrFromMesh, attrToMesh, attrDirection, attrConstraint});
278 addAttributes(radialGeoMultiscaleTags, {attrFromMesh, attrToMesh, attrDirection, attrConstraint});
279 addAttributes(axialGeoMultiscaleTags, {attrGeoMultiscaleDimension, attrGeoMultiscaleType, attrGeoMultiscaleAxis, attrGeoMultiscaleRadius, attrGeoMultiscaleCrossSectionProfile, attrGeoMultiscaleCrossSection});
280 addAttributes(radialGeoMultiscaleTags, {attrGeoMultiscaleType, attrGeoMultiscaleAxis, attrGeoMultiscaleRadius});
283 XMLTag::Occurrence once = XMLTag::OCCUR_NOT_OR_ONCE;
285 auto attrDeviceId = makeXMLAttribute(
ATTR_DEVICE_ID,
static_cast<std::string
>(
"0"))
286 .setDocumentation(
"Setting of the GPU device: Set \"auto\" to assign GPUs to each MPI rank in a round robin fashion or specify a number between 0 and the number of available GPUs-1 to assign all MPI ranks to one GPU device with the given ID.");
287 auto attrNThreads = makeXMLAttribute(
ATTR_N_THREADS,
static_cast<int>(0))
288 .setDocumentation(
"Specifies the number of threads for the OpenMP executor that should be used for the Ginkgo OpenMP backend. If a value of \"0\" is set, preCICE doesn't set the number of threads and the default behavior of OpenMP applies.");
292 std::list<XMLTag> cpuExecutor{
293 XMLTag{*
this,
EXECUTOR_CPU, once,
SUBTAG_EXECUTOR}.setDocumentation(
"The default executor, which uses a single-core CPU with a gather-scatter parallelism.")};
294 std::list<XMLTag> deviceExecutors{
295 XMLTag{*
this,
EXECUTOR_CUDA, once,
SUBTAG_EXECUTOR}.setDocumentation(
"Cuda (Nvidia) executor, which uses cuSolver/Ginkgo and a direct QR decomposition with a gather-scatter parallelism."),
296 XMLTag{*
this,
EXECUTOR_HIP, once,
SUBTAG_EXECUTOR}.setDocumentation(
"Hip (AMD/Nvidia) executor, which uses hipSolver/Ginkgo and a direct QR decomposition with a gather-scatter parallelism.")};
298 addAttributes(deviceExecutors, {attrDeviceId});
299 addSubtagsToParents(cpuExecutor, rbfDirectTags);
300 addSubtagsToParents(deviceExecutors, rbfDirectTags);
304 std::list<XMLTag> cpuExecutor{
305 XMLTag{*
this,
EXECUTOR_CPU, once,
SUBTAG_EXECUTOR}.setDocumentation(
"The default executor relying on PETSc, which uses CPUs and distributed memory parallelism via MPI.")};
306 std::list<XMLTag> deviceExecutors{
307 XMLTag{*
this,
EXECUTOR_CUDA, once,
SUBTAG_EXECUTOR}.setDocumentation(
"Cuda (Nvidia) executor, which uses Ginkgo with a gather-scatter parallelism."),
308 XMLTag{*
this,
EXECUTOR_HIP, once,
SUBTAG_EXECUTOR}.setDocumentation(
"Hip (AMD/Nvidia) executor, which uses hipSolver with a gather-scatter parallelism.")};
309 std::list<XMLTag> ompExecutor{
310 XMLTag{*
this,
EXECUTOR_OMP, once,
SUBTAG_EXECUTOR}.setDocumentation(
"OpenMP executor, which uses Ginkgo with a gather-scatter parallelism.")};
312 addAttributes(deviceExecutors, {attrDeviceId});
313 addAttributes(ompExecutor, {attrNThreads});
314 addSubtagsToParents(cpuExecutor, rbfIterativeTags);
315 addSubtagsToParents(deviceExecutors, rbfIterativeTags);
316 addSubtagsToParents(ompExecutor, rbfIterativeTags);
319 std::list<XMLTag> cpuExecutor{
320 XMLTag{*
this,
EXECUTOR_CPU, once,
SUBTAG_EXECUTOR}.setDocumentation(
"The default executor using a CPU and a distributed memory parallelism via MPI.")};
321 std::list<XMLTag> deviceExecutors{
322 XMLTag{*
this,
EXECUTOR_CUDA, once,
SUBTAG_EXECUTOR}.setDocumentation(
"Cuda (Nvidia) executor, which uses Kokkos-kernels, fully parallel"),
323 XMLTag{*
this,
EXECUTOR_HIP, once,
SUBTAG_EXECUTOR}.setDocumentation(
"Hip (AMD/Nvidia) executor, which uses Kokkos-kernels, fully parallel."),
324 XMLTag{*
this,
EXECUTOR_SYCL, once,
SUBTAG_EXECUTOR}.setDocumentation(
"SYCL (e.g. Intel) executor, which uses Kokkos-kernels, fully parallel.")};
325 std::list<XMLTag> ompExecutor{
326 XMLTag{*
this,
EXECUTOR_OMP, once,
SUBTAG_EXECUTOR}.setDocumentation(
"OpenMP executor, which uses Kokkos-kernel, fully parallel.")};
329 .setDocumentation(
"Toggle to switch between a minimal-memory vs a minimal-compute algorithm. For option \"minimal-memory\", the RBF evaluation is recomputed for each data mapping on-the-fly, which saves approximately half the memory consumption (if meshes have a similar resolution), but may (!) be slower (depends heavily on the hardware). "
330 "For the option \"minimal-compute\", the RBF evaluation is precomputed, which may be faster, but consumes more memory.")
331 .setOptions({
"minimal-memory",
"minimal-compute"});
333 addAttributes(deviceExecutors, {attrDeviceId, attrExecutionMode});
334 addAttributes(ompExecutor, {attrNThreads, attrExecutionMode});
335 addSubtagsToParents(cpuExecutor, pumDirectTags);
336 addSubtagsToParents(deviceExecutors, pumDirectTags);
337 addSubtagsToParents(ompExecutor, pumDirectTags);
343 std::list<XMLTag> supportRadiusRBF{
352 .setDocumentation(
"Support radius of each RBF basis function (global choice).");
354 addAttributes(supportRadiusRBF, {attrSupportRadius});
355 addSubtagsToParents(supportRadiusRBF, rbfIterativeTags);
356 addSubtagsToParents(supportRadiusRBF, rbfDirectTags);
357 addSubtagsToParents(supportRadiusRBF, pumDirectTags);
358 addSubtagsToParents(supportRadiusRBF, rbfAliasTag);
361 std::list<XMLTag> shapeParameterRBF{
366 .setDocumentation(
"Specific shape parameter for RBF basis function.");
368 addAttributes(shapeParameterRBF, {attrShapeParam});
369 addSubtagsToParents(shapeParameterRBF, rbfIterativeTags);
370 addSubtagsToParents(shapeParameterRBF, rbfDirectTags);
371 addSubtagsToParents(shapeParameterRBF, pumDirectTags);
372 addSubtagsToParents(shapeParameterRBF, rbfAliasTag);
375 std::list<XMLTag> GaussRBF{
377 attrShapeParam.setDefaultValue(std::numeric_limits<double>::quiet_NaN());
378 attrSupportRadius.setDefaultValue(std::numeric_limits<double>::quiet_NaN());
379 addAttributes(GaussRBF, {attrShapeParam, attrSupportRadius});
380 addSubtagsToParents(GaussRBF, rbfIterativeTags);
381 addSubtagsToParents(GaussRBF, rbfDirectTags);
382 addSubtagsToParents(GaussRBF, pumDirectTags);
383 addSubtagsToParents(GaussRBF, rbfAliasTag);
386 std::list<XMLTag> attributelessRBFs{
390 addSubtagsToParents(attributelessRBFs, rbfIterativeTags);
391 addSubtagsToParents(attributelessRBFs, rbfDirectTags);
392 addSubtagsToParents(attributelessRBFs, pumDirectTags);
393 addSubtagsToParents(attributelessRBFs, rbfAliasTag);
422 std::string type = tag.
getName();
426 PRECICE_CHECK(!toMesh.empty() || !fromMesh.empty(),
"Neither a \"to\" nor a \"from\" mesh was defined in a preCICE mapping. Most data mappings require a \"to\" and a \"from\" mesh. "
427 "For just-in-time mapping, at least one of both attributes has to be specified.");
433 "The mapping from mesh \"{0}\" has no \"to\" mesh, which configures a just-in-time mapping for the mesh \"{0}\". For just-in-time mapping, only read-consistent (direction = \"read\" and no \"to\" mesh) and write-conservative (direction = \"write\" and no \"from\" mesh) are implemented.", fromMesh);
435 "The mapping to mesh \"{0}\" has no \"from\" mesh, which configures a just-in-time mapping for the mesh \"{0}\". For just-in-time mapping, only read-consistent (direction = \"read\" and no \"to\" mesh) and write-conservative (direction = \"write\" and no \"from\" mesh) are implemented.", toMesh);
437 PRECICE_INFO_IF(toMesh.empty(),
"Using just-in-time mapping from mesh \"{}\"", fromMesh);
438 PRECICE_INFO_IF(fromMesh.empty(),
"Using just-in-time mapping to mesh \"{}\"", toMesh);
459 PRECICE_CHECK(
_experimental,
"The configured mapping \"{}\" is experimental and the configuration can change between minor releases. Set experimental=\"on\" in the precice-configuration tag.", type);
463 throw std::runtime_error{
"Axial geometric multiscale mapping is not available for parallel participants."};
467 throw std::runtime_error{
"Radial geometric multiscale mapping is not available for parallel participants."};
488 ConfiguredMapping configuredMapping =
createMapping(dir, type, fromMesh, toMesh, cgRadius, geoMultiscaleDimension, geoMultiscaleType, geoMultiscaleAxis, multiscaleRadius, geoMultiscaleProfile, geoMultiscaleCrossSection);
497 PRECICE_CHECK(
_mappings.back().requiresBasisFunction ==
true,
"A basis-function was defined for the mapping "
498 "from mesh \"{}\" to mesh \"{}\", but no basis-function is required for this mapping type. "
499 "Please remove the basis-function tag or configure an rbf mapping, which requires a basis-function.",
502 PRECICE_CHECK(
_rbfConfig.basisFunctionDefined ==
false,
"More than one basis-function was defined for the mapping "
503 "from mesh \"{}\" to mesh \"{}\".",
506 std::string basisFctName = tag.
getName();
514 const bool exactlyOneSet = (std::isfinite(supportRadius) && !std::isfinite(shapeParameter)) ||
515 (std::isfinite(shapeParameter) && !std::isfinite(supportRadius));
516 PRECICE_CHECK(exactlyOneSet,
"The specified parameters for the Gaussian RBF mapping are invalid. Please specify either a \"shape-parameter\" or a \"support-radius\".");
518 if (std::isfinite(supportRadius) && !std::isfinite(shapeParameter)) {
546 PRECICE_CHECK(
_executorConfig->deviceId >= 0,
"The argument provided to \"gpu-device-id\" in the precice configuration file is invalid (negative device id)");
547 }
catch (
const std::invalid_argument &e) {
548 throw precice::Error(
"The argument provided to \"gpu-device-id\" in the precice configuration file is invalid (not a valid input).");
549 }
catch (
const std::out_of_range &e) {
550 throw precice::Error(
"The argument provided to \"gpu-device-id\" in the precice configuration file is invalid (out of range).");
556 if (mode ==
"minimal-memory")
558 else if (mode ==
"minimal-compute")
567 const std::string &polynomial,
568 bool xDead,
bool yDead,
bool zDead,
570 double verticesPerCluster,
571 double relativeOverlap,
572 bool projectToInput)
const
600 rbfConfig.deadAxis = {{xDead, yDead, zDead}};
603 rbfConfig.verticesPerCluster = verticesPerCluster;
604 rbfConfig.relativeOverlap = relativeOverlap;
605 rbfConfig.projectToInput = projectToInput;
611 const std::string &direction,
612 const std::string &type,
613 const std::string &fromMeshName,
614 const std::string &toMeshName,
615 const double cgRadius,
616 const std::string &geoMultiscaleDimension,
617 const std::string &geoMultiscaleType,
618 const std::string &geoMultiscaleAxis,
619 const double &multiscaleRadius,
620 const std::string &geoMultiscaleProfile,
621 const std::string &geoMultiscaleCrossSection)
const
630 if (!fromMesh && fromMeshName.empty()) {
632 "Mesh \"{0}\" was not found while creating a mapping. "
633 "Please correct the to=\"{0}\" attribute.",
637 if (!toMesh && toMeshName.empty()) {
639 "Mesh \"{0}\" was not found while creating a mapping. "
640 "Please correct the from=\"{0}\" attribute.",
646 "Mesh \"{0}\" was not found while creating a mapping. "
647 "Please correct the from=\"{0}\" attribute.",
650 "Mesh \"{0}\" was not found while creating a mapping. "
651 "Please correct the to=\"{0}\" attribute.",
656 "A just-in-time mapping was configured from mesh \"{}\" to mesh \"{}\" using \"mapping:{}\", which is currently not implemented. "
657 "Available mapping types are \"mapping:{}\", \"mapping:{}\", \"mapping:{}\" and \"mapping:{}\".",
662 "Mapping between meshes of different dimensions is not allowed yet. "
663 "Please set the same dimensions attribute to meshes \"{}\" and \"{}\", "
664 "or choose different meshes.",
665 fromMeshName, toMeshName);
667 configuredMapping.
fromMesh = fromMesh;
668 configuredMapping.
toMesh = toMesh;
691 "Nearest-neighbor-gradient mapping is not implemented using a \"conservative\" constraint. "
692 "Please select constraint=\" consistent\" or a different mapping method.");
700 "Axial geometric multiscale mapping is not implemented for the \"conservative\" constraint. "
701 "Please select constraint=\" consistent\" or a different mapping method.");
705 if (geoMultiscaleAxis ==
"x") {
707 }
else if (geoMultiscaleAxis ==
"y") {
709 }
else if (geoMultiscaleAxis ==
"z") {
716 if (geoMultiscaleDimension ==
"1d-3d") {
718 }
else if (geoMultiscaleDimension ==
"1d-2d") {
720 }
else if (geoMultiscaleDimension ==
"2d-3d") {
727 if (geoMultiscaleType ==
"spread") {
729 }
else if (geoMultiscaleType ==
"collect") {
736 if (geoMultiscaleProfile ==
"parabolic") {
738 }
else if (geoMultiscaleProfile ==
"uniform") {
745 if (geoMultiscaleCrossSection ==
"circle") {
747 }
else if (geoMultiscaleCrossSection ==
"square") {
759 "Radial geometric multiscale mapping is not implemented for the \"conservative\" constraint. "
760 "Please select constraint=\" consistent\" or a different mapping method.");
764 if (geoMultiscaleAxis ==
"x") {
766 }
else if (geoMultiscaleAxis ==
"y") {
768 }
else if (geoMultiscaleAxis ==
"z") {
775 if (geoMultiscaleType ==
"spread") {
777 }
else if (geoMultiscaleType ==
"collect") {
788 configuredMapping.
mapping =
nullptr;
794 return configuredMapping;
800 bool sameToMesh =
mapping.toMesh->getName() == configuredMapping.toMesh->getName();
801 bool sameFromMesh =
mapping.fromMesh->getName() == configuredMapping.fromMesh->getName();
802 bool sameMapping = sameToMesh && sameFromMesh;
804 "There cannot be two mappings from mesh \"{}\" to mesh \"{}\". "
805 "Please remove one of the duplicated meshes. ",
809 bool sameToMesh =
mapping.toMesh->getName() == configuredMapping.toMesh->getName();
811 bool sameMapping = sameToMesh && isWrite && (
mapping.fromMesh->isJustInTime() || configuredMapping.fromMesh->isJustInTime());
813 "There cannot be two mappings to mesh \"{}\". "
814 "Here, we have a mixture of just-in-time mapping and a conventional mapping. ",
846#ifndef PRECICE_NO_PETSC
852 PRECICE_ERROR(
"The global-iterative RBF solver on a CPU requires a preCICE build with PETSc enabled.");
868#ifndef PRECICE_WITH_CUDA
869 PRECICE_ERROR(
"The cuda-executor (configured for the mapping from mesh {} to mesh {}) requires a Kokkos and preCICE build with Cuda enabled.",
mapping.fromMesh->getName(),
mapping.toMesh->getName());
873#ifndef PRECICE_WITH_HIP
874 PRECICE_ERROR(
"The hip-executor (configured for the mapping from mesh {} to mesh {}) requires a Kokkos and preCICE build with HIP enabled.",
mapping.fromMesh->getName(),
mapping.toMesh->getName());
878#ifndef PRECICE_WITH_SYCL
879 PRECICE_ERROR(
"The sycl-executor (configured for the mapping from mesh {} to mesh {}) requires a Kokkos and preCICE build with SYCL enabled.",
mapping.fromMesh->getName(),
mapping.toMesh->getName());
884#ifndef PRECICE_WITH_OPENMP
885 PRECICE_ERROR(
"The omp-executor (configured for the mapping from mesh {} to mesh {}) requires a Kokkos and preCICE build with OpenMP enabled.",
mapping.fromMesh->getName(),
mapping.toMesh->getName());
889#ifndef PRECICE_NO_GINKGO
893 PRECICE_ERROR(
"The selected direct solver for the global RBF mapping on executor {} from mesh {} to mesh {} requires a preCICE build with Ginkgo enabled.",
_ginkgoParameter.executor,
mapping.fromMesh->getName(),
mapping.toMesh->getName());
896#ifndef PRECICE_NO_GINKGO
901 PRECICE_ERROR(
"The selected iterative solver for the global RBF mapping on executor {} from mesh {} to mesh {} requires a preCICE build with Ginkgo enabled.",
_ginkgoParameter.executor,
mapping.fromMesh->getName(),
mapping.toMesh->getName());
904#ifndef PRECICE_NO_KOKKOS_KERNELS
906 mapping.mapping = getRBFMapping<RBFBackend::PUM>(
_rbfConfig.basisFunction,
constraintValue,
mapping.fromMesh->getDimensions(),
_rbfConfig.supportRadius,
_rbfConfig.shapeParameter,
_rbfConfig.polynomial,
_rbfConfig.verticesPerCluster,
_rbfConfig.relativeOverlap,
_rbfConfig.projectToInput,
_ginkgoParameter,
_executorConfig->computeEvaluationOffline);
908 PRECICE_ERROR(
"The selected pu-rbf solver using executor \"{}\" for the mapping from mesh {} to mesh {} requires a preCICE build with Kokkos-kernels enabled.",
_ginkgoParameter.executor,
mapping.fromMesh->getName(),
mapping.toMesh->getName());
953 return basisFunction;
#define PRECICE_ERROR(...)
#define PRECICE_TRACE(...)
#define PRECICE_INFO_IF(condition,...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
#define PRECICE_UNREACHABLE(...)
int getDimensions() const
const std::string & getName() const
Returns the name of the mesh, as set in the config file.
bool isJustInTime() const
Geometric multiscale mapping in axial direction.
MultiscaleType
Geometric multiscale nature of the mapping (spread or collect).
MultiscaleProfile
Profile to use when type == SPREAD.
static constexpr double cutoffThreshold
Below that value the function is supposed to be zero. Defines the support radius if not explicitly gi...
Mapping using orthogonal projection to nearest triangle/edge/vertex and linear interpolation from pro...
const std::string ATTR_GEOMETRIC_MULTISCALE_CROSS_SECTION
const std::string ATTR_TO
RBFConfiguration configureRBFMapping(const std::string &type, const std::string &polynomial, bool xDead, bool yDead, bool zDead, double solverRtol, double verticesPerCluster, double relativeOverlap, bool projectToInput) const
const std::string GEOMETRIC_MULTISCALE_AXIS_X
const std::string GEOMETRIC_MULTISCALE_DIMENSION_2D3D
const std::string ATTR_GEOMETRIC_MULTISCALE_DIMENSION
const std::string SUBTAG_BASIS_FUNCTION
const std::string ATTR_VERTICES_PER_CLUSTER
const std::string TYPE_RBF_PUM_DIRECT
void xmlTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &callingTag) override
Callback function required for use of automatic configuration.
ConfiguredMapping createMapping(const std::string &direction, const std::string &type, const std::string &fromMeshName, const std::string &toMeshName, const double cgRange, const std::string &geoMultiscaleDimension, const std::string &geoMultiscaleType, const std::string &geoMultiscaleAxis, const double &multiscaleRadius, const std::string &geoMultiscaleProfile, const std::string &geoMultiscaleCrossSection) const
const std::string RBF_CPOLYNOMIAL_C2
const std::string ATTR_X_DEAD
const std::string SUBTAG_EXECUTOR
const std::vector< ConfiguredMapping > & mappings()
Returns all configured mappings.
GinkgoParameter _ginkgoParameter
const std::string ATTR_DIRECTION
const std::string RBF_VOLUME_SPLINES
Mapping::Constraint constraintValue
const std::string DIRECTION_WRITE
const std::string ATTR_SOLVER_RTOL
mesh::PtrMeshConfiguration _meshConfig
const std::string EXECUTOR_HIP
const std::string DIRECTION_READ
const std::string ATTR_GEOMETRIC_MULTISCALE_CROSS_SECTION_PROFILE
const std::string POLYNOMIAL_OFF
const std::string ATTR_EXECUTION_MODE
std::unique_ptr< ExecutorConfiguration > _executorConfig
const std::string ATTR_Y_DEAD
const std::string RBF_MULTIQUADRICS
const std::string RBF_CPOLYNOMIAL_C4
const std::string ATTR_SHAPE_PARAM
const std::string CONSTRAINT_SCALED_CONSISTENT_VOLUME
const std::string EXECUTOR_CPU
const std::string TYPE_RBF_ALIAS
const std::string TYPE_RBF_GLOBAL_DIRECT
const std::string TYPE_COARSE_GRAINING
const std::string ATTR_PROJECT_TO_INPUT
const std::string GEOMETRIC_MULTISCALE_AXIS_Z
bool requiresBasisFunction(const std::string &mappingType) const
const std::string RBF_CPOLYNOMIAL_C6
const std::string TYPE_AXIAL_GEOMETRIC_MULTISCALE
BasisFunction parseBasisFunctions(const std::string &basisFctName) const
Given a basis function name (as a string), transforms the string into an enum of the BasisFunction.
const std::string RBF_TPS
const std::string GEOMETRIC_MULTISCALE_DIMENSION_1D2D
const std::string ATTR_DEVICE_ID
void finishRBFConfiguration()
const std::string RBF_CPOLYNOMIAL_C0
const std::string ATTR_CG_RADIUS
const std::string CONSTRAINT_CONSISTENT
RBFConfiguration _rbfConfig
const std::string TYPE_RBF_GLOBAL_ITERATIVE
const std::string ATTR_RELATIVE_OVERLAP
const std::string ATTR_GEOMETRIC_MULTISCALE_AXIS
const std::string TYPE_LINEAR_CELL_INTERPOLATION
const std::string GEOMETRIC_MULTISCALE_AXIS_Y
const std::string RBF_GAUSSIAN
std::vector< ConfiguredMapping > _mappings
const std::string ATTR_CONSTRAINT
const std::string TYPE_NEAREST_NEIGHBOR
const std::string ATTR_Z_DEAD
const std::string EXECUTOR_CUDA
const std::string GEOMETRIC_MULTISCALE_CROSS_SECTION_SQUARE
const std::string ATTR_GEOMETRIC_MULTISCALE_TYPE
const std::string GEOMETRIC_MULTISCALE_CROSS_SECTION_CIRCLE
const std::string ATTR_SUPPORT_RADIUS
const std::string GEOMETRIC_MULTISCALE_CROSS_SECTION_PROFILE_UNIFORM
void checkDuplicates(const ConfiguredMapping &mapping)
Check whether a mapping to and from the same mesh already exists.
const std::string EXECUTOR_SYCL
void xmlEndTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &callingTag) override
Callback function required for use of automatic configuration.
const std::string TYPE_NEAREST_PROJECTION
const std::string GEOMETRIC_MULTISCALE_CROSS_SECTION_PROFILE_PARABOLIC
const std::string RBF_CPOLYNOMIAL_C8
const std::string POLYNOMIAL_ON
const std::string ATTR_N_THREADS
const std::string GEOMETRIC_MULTISCALE_DIMENSION_1D3D
const std::string ATTR_POLYNOMIAL
const std::string POLYNOMIAL_SEPARATE
const std::string TYPE_NEAREST_NEIGHBOR_GRADIENT
const std::string RBF_INV_MULTIQUADRICS
const RBFConfiguration & rbfConfig() const
const std::string TYPE_RADIAL_GEOMETRIC_MULTISCALE
const std::string RBF_CTPS_C2
MappingConfiguration(xml::XMLTag &parent, mesh::PtrMeshConfiguration meshConfiguration)
const std::string GEOMETRIC_MULTISCALE_TYPE_SPREAD
const std::string CONSTRAINT_CONSERVATIVE
const std::string ATTR_FROM
const std::string EXECUTOR_OMP
void setExperimental(bool experimental)
const std::string ATTR_GEOMETRIC_MULTISCALE_RADIUS
const std::string CONSTRAINT_SCALED_CONSISTENT_SURFACE
const std::string GEOMETRIC_MULTISCALE_TYPE_COLLECT
Constraint
Specifies additional constraints for a mapping.
@ SCALED_CONSISTENT_VOLUME
@ SCALED_CONSISTENT_SURFACE
Mapping using nearest neighboring vertices and their local gradient values.
Mapping using nearest neighboring vertices.
Mapping using orthogonal projection to nearest triangle/edge/vertex and linear interpolation from pro...
Geometric multiscale mapping in radial direction.
MultiscaleType
Geometric multiscale type of the mapping (spread or collect).
static mesh::PtrMesh getJustInTimeMappingMesh(int dimension)
static CommStatePtr current()
Returns an owning pointer to the current CommState.
static void initialize(utils::Parallel::Communicator comm)
Initializes the Petsc environment.
Represents an XML tag to be configured automatically.
const std::string & getNamespace() const
Returns xml namespace.
void addSubtags(const Container &subtags)
std::string getStringAttributeValue(const std::string &name, std::optional< std::string > default_value=std::nullopt) const
bool getBooleanAttributeValue(const std::string &name, std::optional< bool > default_value=std::nullopt) const
const std::string & getName() const
Returns name (without namespace).
int getIntAttributeValue(const std::string &name, std::optional< int > default_value=std::nullopt) const
double getDoubleAttributeValue(const std::string &name, std::optional< double > default_value=std::nullopt) const
contains data mapping from points to meshes.
@ CompactThinPlateSplinesC2
std::shared_ptr< Mapping > PtrMapping
std::shared_ptr< Mesh > PtrMesh
std::shared_ptr< MeshConfiguration > PtrMeshConfiguration
contains the XML configuration parser.
static precice::logging::Logger _log("precicec")
Tightly coupled to the parameters of Participant()