preCICE v3.1.1
Loading...
Searching...
No Matches
MappingConfiguration.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4#include <vector>
5#include "logging/Logger.hpp"
6#include "mapping/Mapping.hpp"
10#include "xml/XMLTag.hpp"
11
12namespace precice::mapping {
13
16public:
18 enum Direction {
20 READ
21 };
22
38
40 std::string executor = "reference-executor";
41 std::string solver = "cg-solver";
42 std::string preconditioner = "jacobi-preconditioner";
43 double residualNorm = 1e-8;
45 bool usePreconditioner = false;
46 unsigned int jacobiBlockSize = 4;
47 unsigned int deviceId = 0;
48 unsigned int nThreads = 0;
49 bool enableUnifiedMemory = false;
50 };
51
53 xml::XMLTag & parent,
54 mesh::PtrMeshConfiguration meshConfiguration);
55
56 void setExperimental(bool experimental);
57
63 virtual void xmlTagCallback(
64 const xml::ConfigurationContext &context,
65 xml::XMLTag & callingTag);
66
72 virtual void xmlEndTagCallback(
73 const xml::ConfigurationContext &context,
74 xml::XMLTag & callingTag);
75
78
79 // Only relevant for RBF related mappings
80 // Being public here is only required for testing purposes
100
107
111 {
112 return _rbfConfig;
113 }
114
116 {
117 _mappings.clear();
118 }
119
120private:
121 mutable logging::Logger _log{"config:MappingConfiguration"};
122
123 bool _experimental = false;
124
125 const std::string TAG = "mapping";
126
127 // First, declare common attributes and associated options
128 const std::string ATTR_TYPE = "type";
129 const std::string TYPE_NEAREST_NEIGHBOR = "nearest-neighbor";
130 const std::string TYPE_NEAREST_NEIGHBOR_GRADIENT = "nearest-neighbor-gradient";
131 const std::string TYPE_NEAREST_PROJECTION = "nearest-projection";
132 const std::string TYPE_LINEAR_CELL_INTERPOLATION = "linear-cell-interpolation";
133 const std::string TYPE_RBF_GLOBAL_DIRECT = "rbf-global-direct";
134 const std::string TYPE_RBF_GLOBAL_ITERATIVE = "rbf-global-iterative";
135 const std::string TYPE_RBF_PUM_DIRECT = "rbf-pum-direct";
137 const std::string TYPE_AXIAL_GEOMETRIC_MULTISCALE = "axial-geometric-multiscale";
138 const std::string TYPE_RADIAL_GEOMETRIC_MULTISCALE = "radial-geometric-multiscale";
139
140 const std::string ATTR_DIRECTION = "direction";
143
144 const std::string ATTR_FROM = "from";
145 const std::string ATTR_TO = "to";
146
147 const std::string ATTR_CONSTRAINT = "constraint";
148 const std::string CONSTRAINT_CONSISTENT = "consistent";
149 const std::string CONSTRAINT_CONSERVATIVE = "conservative";
150 const std::string CONSTRAINT_SCALED_CONSISTENT_SURFACE = "scaled-consistent-surface";
151 const std::string CONSTRAINT_SCALED_CONSISTENT_VOLUME = "scaled-consistent-volume";
152
153 // RBF specific options
154 const std::string ATTR_X_DEAD = "x-dead";
155 const std::string ATTR_Y_DEAD = "y-dead";
156 const std::string ATTR_Z_DEAD = "z-dead";
157
158 const std::string ATTR_POLYNOMIAL = "polynomial";
162
163 // For iterative RBFs
164 const std::string ATTR_SOLVER_RTOL = "solver-rtol";
165
166 // For the future
167 // const std::string ATTR_PARALLELISM = "parallelism";
168 // const std::string PARALLELISM_GATHER_SCATTER = "gather-scatter";
169 // const std::string PARALLELISM = "distributed";
170
171 // For PUM
172 const std::string ATTR_VERTICES_PER_CLUSTER = "vertices-per-cluster";
173 const std::string ATTR_RELATIVE_OVERLAP = "relative-overlap";
174 const std::string ATTR_PROJECT_TO_INPUT = "project-to-input";
175
176 // We declare the basis function as subtag
177 const std::string SUBTAG_BASIS_FUNCTION = "basis-function";
178 const std::string RBF_TPS = "thin-plate-splines";
179 const std::string RBF_MULTIQUADRICS = "multiquadrics";
180 const std::string RBF_INV_MULTIQUADRICS = "inverse-multiquadrics";
181 const std::string RBF_VOLUME_SPLINES = "volume-splines";
182 const std::string RBF_GAUSSIAN = "gaussian";
183 const std::string RBF_CTPS_C2 = "compact-tps-c2";
184 const std::string RBF_CPOLYNOMIAL_C0 = "compact-polynomial-c0";
185 const std::string RBF_CPOLYNOMIAL_C2 = "compact-polynomial-c2";
186 const std::string RBF_CPOLYNOMIAL_C4 = "compact-polynomial-c4";
187 const std::string RBF_CPOLYNOMIAL_C6 = "compact-polynomial-c6";
188 const std::string RBF_CPOLYNOMIAL_C8 = "compact-polynomial-c8";
189
190 // Attributes for the subtag
191 const std::string ATTR_SHAPE_PARAM = "shape-parameter";
192 const std::string ATTR_SUPPORT_RADIUS = "support-radius";
193
194 // Attributes for geometric multiscale
203
204 // For iterative RBFs using Ginkgo
205 const std::string SUBTAG_EXECUTOR = "executor";
209 const std::string EXECUTOR_OMP = "openmp";
210
211 const std::string ATTR_DEVICE_ID = "gpu-device-id";
212 const std::string ATTR_N_THREADS = "n-threads";
213 // const std::string ATTR_ENABLE_UNIFIED_MEMORY = "enable-unified-memory";
214 // const std::string ATTR_SOLVER = "solver";
215 // const std::string ATTR_USE_PRECONDITIONER = "use-preconditioner";
216 // const std::string ATTR_PRECONDITIONER = "preconditioner";
217 // const std::string ATTR_JACOBI_BLOCK_SIZE = "jacobi-block-size";
218 // const std::string ATTR_MAX_ITERATIONS = "max-iterations";
219
220 // mapping constraint
222
224
225 // main data structure storing the configurations
227
228 // Relevant information in order to store the RBF related settings,
229 // as we can only instantiate the RBF classes when we know the RBF
230 // which is configured in the subtag
232
234 enum struct Executor {
235 CPU,
236 CUDA,
237 HIP,
238 OpenMP
239 };
240
242 int deviceId{};
243 int nThreads{};
244 };
245
247
248 // Settings for the iterative solvers provided by Ginkgo
250
260 const std::string &direction,
261 const std::string &type,
262 const std::string &fromMeshName,
263 const std::string &toMeshName,
264 const std::string &geoMultiscaleType,
265 const std::string &geoMultiscaleAxis,
266 const double & multiscaleRadius) const;
267
275 const std::string &polynomial,
276 bool xDead, bool yDead, bool zDead,
277 double solverRtol,
278 double verticesPerCluster,
279 double relativeOverlap,
280 bool projectToInput) const;
281
283
285 void checkDuplicates(const ConfiguredMapping &mapping);
286
289 bool requiresBasisFunction(const std::string &mappingType) const;
290
292 BasisFunction parseBasisFunctions(const std::string &basisFctName) const;
293};
294} // namespace precice::mapping
This class provides a lightweight logger.
Definition Logger.hpp:16
Performs XML configuration and holds configured mappings.
virtual void xmlEndTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &callingTag)
Callback function required for use of automatic configuration.
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
virtual void xmlTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &callingTag)
Callback function required for use of automatic configuration.
const std::vector< ConfiguredMapping > & mappings()
Returns all configured mappings.
std::unique_ptr< ExecutorConfiguration > _executorConfig
bool requiresBasisFunction(const std::string &mappingType) const
BasisFunction parseBasisFunctions(const std::string &basisFctName) const
Given a basis function name (as a string), transforms the string into an enum of the BasisFunction.
std::vector< ConfiguredMapping > _mappings
Direction
Constants defining the direction of a mapping.
ConfiguredMapping createMapping(const std::string &direction, const std::string &type, const std::string &fromMeshName, const std::string &toMeshName, const std::string &geoMultiscaleType, const std::string &geoMultiscaleAxis, const double &multiscaleRadius) const
void checkDuplicates(const ConfiguredMapping &mapping)
Check whether a mapping to and from the same mesh already exists.
const RBFConfiguration & rbfConfig() const
MappingConfiguration(xml::XMLTag &parent, mesh::PtrMeshConfiguration meshConfiguration)
Constraint
Specifies additional constraints for a mapping.
Definition Mapping.hpp:29
Represents an XML tag to be configured automatically.
Definition XMLTag.hpp:31
contains data mapping from points to meshes.
Polynomial
How to handle the polynomial?
Direction direction
Direction of mapping (important to set input and output mesh).
bool configuredWithAliasTag
used the automatic rbf alias tag in order to set the mapping
Tightly coupled to the parameters of Participant()
Definition XMLTag.hpp:24
Callback interface for configuration classes using XMLTag.
Definition XMLTag.hpp:43