33 : TAG(
"acceleration"),
34 TAG_RELAX(
"relaxation"),
35 TAG_INIT_RELAX(
"initial-relaxation"),
36 TAG_MAX_USED_ITERATIONS(
"max-used-iterations"),
37 TAG_TIME_WINDOWS_REUSED(
"time-windows-reused"),
40 TAG_ESTIMATEJACOBIAN(
"estimate-jacobian"),
41 TAG_PRECONDITIONER(
"preconditioner"),
42 TAG_IMVJRESTART(
"imvj-restart-mode"),
45 ATTR_SCALING(
"scaling"),
47 ATTR_ENFORCE(
"enforce"),
48 ATTR_SINGULARITYLIMIT(
"limit"),
50 ATTR_BUILDJACOBIAN(
"always-build-jacobian"),
51 ATTR_REDUCEDTIMEGRIDQN(
"reduced-time-grid"),
52 ATTR_IMVJCHUNKSIZE(
"chunk-size"),
53 ATTR_RSLS_REUSED_TIME_WINDOWS(
"reused-time-windows-at-restart"),
54 ATTR_RSSVD_TRUNCATIONEPS(
"truncation-threshold"),
55 ATTR_PRECOND_NONCONST_TIME_WINDOWS(
"freeze-after"),
56 ATTR_PRECOND_UPDATE_ON_THRESHOLD(
"update-on-threshold"),
57 VALUE_CONSTANT(
"constant"),
58 VALUE_AITKEN(
"aitken"),
59 VALUE_IQNILS(
"IQN-ILS"),
60 VALUE_IQNIMVJ(
"IQN-IMVJ"),
61 VALUE_QR1FILTER(
"QR1"),
62 VALUE_QR1_ABSFILTER(
"QR1-absolute"),
63 VALUE_QR2FILTER(
"QR2"),
64 VALUE_QR3FILTER(
"QR3"),
65 VALUE_CONSTANT_PRECONDITIONER(
"constant"),
66 VALUE_VALUE_PRECONDITIONER(
"value"),
67 VALUE_RESIDUAL_PRECONDITIONER(
"residual"),
68 VALUE_RESIDUAL_SUM_PRECONDITIONER(
"residual-sum"),
69 VALUE_LS_RESTART(
"RS-LS"),
70 VALUE_ZERO_RESTART(
"RS-0"),
71 VALUE_SVD_RESTART(
"RS-SVD"),
72 VALUE_SLIDE_RESTART(
"RS-SLIDE"),
73 VALUE_NO_RESTART(
"no-restart"),
74 _meshConfig(meshConfig),
90 XMLTag::Occurrence occ = XMLTag::OCCUR_NOT_OR_ONCE;
94 tag.setDocumentation(
"Accelerates coupling data with constant underrelaxation.");
100 tag.setDocumentation(
"Accelerates coupling data with dynamic Aitken under-relaxation.");
106 tag.setDocumentation(
"Accelerates coupling data with the interface quasi-Newton inverse least-squares method.");
109 .setDocumentation(
"Whether only the last time step of each time window is used to construct the Jacobian.");
110 tag.addAttribute(reducedTimeGridQN);
117 tag.setDocumentation(
"Accelerates coupling data with the interface quasi-Newton inverse multi-vector Jacobian method.");
120 .setDocumentation(
"If set to true, the IMVJ will set up the Jacobian matrix"
121 " in each coupling iteration, which is inefficient. If set to false (or not set)"
122 " the Jacobian is only build in the last iteration and the updates are computed using (relatively) cheap MATVEC products.");
123 tag.addAttribute(alwaybuildJacobian);
126 .setDocumentation(
"Whether only the last time step of each time window is used to construct the Jacobian.");
127 tag.addAttribute(reducedTimeGridQN);
133 for (XMLTag &tag : tags) {
165 "You have provided a subtag <data name=\"{}\" mesh=\"{}\"/> more than once in your <acceleration:.../>. "
166 "Please remove the duplicated entry.",
170 double scaling = 1.0;
176 "Data with name \"{0}\" associated to mesh \"{1}\" not found on configuration of acceleration. "
177 "Add \"{0}\" to the \"<mesh name={1}>\" tag, or change the data name in the acceleration scheme.",
222#ifndef PRECICE_NO_MPI
226 "Please remove 'always-build-jacobian' from the configuration file or do not run in restart mode.");
244 PRECICE_ERROR(
"Acceleration IQN-IMVJ only works if preCICE is compiled with MPI");
272 PRECICE_CHECK(!
_acceleration,
"You are trying to define multiple acceleration schemes, which is not allowed. Please remove one of them.");
299#ifndef PRECICE_NO_MPI
345 PRECICE_ERROR(
"Acceleration IQN-IMVJ only works if preCICE is compiled with MPI");
373 "To improve the performance of a parallel or a multi coupling schemes, "
374 "each data set can be manually scaled using this scaling factor with preconditioner type = \"constant\". For all other preconditioner types, the factor is ignored. "
375 "We recommend, however, to use an automatic scaling via a preconditioner.");
383 "maintain good conditioning in the least-squares system. Possible filters:\n"
384 " - `QR1-filter`: updateQR-dec with (relative) test \\\\(R(i,i) < \\epsilon *\\lVert R\\rVert_F\\\\)\n"
385 " - `QR1_absolute-filter`: updateQR-dec with (absolute) test \\\\(R(i, i) < \\epsilon\\\\)\n"
386 " - `QR2-filter`: en-block QR-dec with test \\\\(\\lVert v_\\text{orth} \\rVert_2 < \\epsilon * \\lVert v \\rVert_2\\\\)\n\n"
387 "Please note that a QR1 is based on Given's rotations whereas QR2 uses "
388 "modified Gram-Schmidt. This can give different results even when no columns "
389 "are filtered out.\n"
390 "When this tag is not provided, the QR2-filter with the limit value 1e-2 is used.");
399 .setDocumentation(
"Type of the filter.");
416 tagInitRelax.
setDocumentation(
"Initial relaxation factor. If this tag is not provided, an initial relaxation of 0.5 is used.");
430 "To improve the performance of a parallel or a multi coupling schemes, "
431 "each data set can be manually scaled using this scaling factor with preconditioner type = \"constant\". For all other preconditioner types, the factor is ignored. "
432 "We recommend, however, to use an automatic scaling via a preconditioner.");
439 tagPreconditioner.
setDocumentation(
"To improve the numerical stability of multiple data vectors a preconditioner"
440 " can be applied. A constant preconditioner scales every acceleration data by a constant value, which you can define as"
441 " an attribute of data. "
442 " A value preconditioner scales every acceleration data by the norm of the data in the previous time window."
443 " A residual preconditioner scales every acceleration data by the current residual."
444 " A residual-sum preconditioner scales every acceleration data by the sum of the residuals from the current time window.");
450 .setDocumentation(
"The type of the preconditioner.");
454 "After the given number of time windows, the preconditioner weights "
455 "are frozen and the preconditioner acts like a constant preconditioner.");
461 tagInitRelax.
setDocumentation(
"Initial relaxation factor. If this tag is not provided, an initial relaxation of 0.1 is used.");
466 attrEnforce.
setDocumentation(
"Enforce initial relaxation in every time window.");
471 tagMaxUsedIter.
setDocumentation(
"Maximum number of columns used in low-rank approximation of Jacobian. If this tag is not provided, the attribute value of 100 is used.");
478 tagTimeWindowsReused.
setDocumentation(
"Number of past time windows from which columns are used to approximate Jacobian. If this tag is not provided, the default attribute value of 10 is used.");
481 tagTimeWindowsReused.
addAttribute(attrNumTimeWindowsReused);
487 tagPreconditioner.
setDocumentation(
"To improve the performance of a parallel or a multi coupling schemes a preconditioner"
489 "- A constant preconditioner scales every acceleration data by a constant value, which you can define as an attribute of data. \n "
490 "- A value preconditioner scales every acceleration data by the norm of the data in the previous time window.\n"
491 "- A residual preconditioner scales every acceleration data by the current residual.\n"
492 "- A residual-sum preconditioner scales every acceleration data by the sum of the residuals from the current time window.\n"
493 " If this tag is not provided, the residual-sum preconditioner is employed.");
499 .setDocumentation(
"The type of the preconditioner.");
502 .
setDocumentation(
"To update the preconditioner weights after the first time window:"
503 "- `true`: The preconditioner weights are only updated if the weights will change by more than one order of magnitude.\n"
504 "- `false`: The preconditioner weights are updated after every iteration.");
505 tagPreconditioner.
addAttribute(attrpreconditionerUpdateOnThreshold);
508 "After the given number of time windows, the preconditioner weights "
509 "are frozen and the preconditioner acts like a constant preconditioner.");
515 tagInitRelax.
setDocumentation(
"Initial relaxation factor. If this tag is not provided, an initial relaxation of 0.1 is used.");
533 "- `no-restart`: IMVJ runs in normal mode with explicit representation of Jacobian\n"
534 "- `RS-0`: IMVJ runs in restart mode. After M time windows all Jacobain information is dropped, restart with no information\n"
535 "- `RS-LS`: IMVJ runs in restart mode. After M time windows a IQN-LS like approximation for the initial guess of the Jacobian is computed.\n"
536 "- `RS-SVD`: IMVJ runs in restart mode. After M time windows a truncated SVD of the Jacobian is updated.\n"
537 "- `RS-SLIDE`: IMVJ runs in sliding window restart mode.\n"
538 "If this tag is not provided, IMVJ runs in restart mode with SVD-method.");
540 .setDocumentation(
"Specifies the number of time windows M after which the IMVJ restarts, if run in restart-mode. Default value is M=8.");
542 .setDocumentation(
"If IMVJ restart-mode=RS-LS, the number of reused time windows at restart can be specified.");
544 .setDocumentation(
"If IMVJ restart-mode=RS-SVD, the truncation threshold for the updated SVD can be set.");
546 tagIMVJRESTART.
addAttribute(attrReusedTimeWindowsAtRestart);
551 tagMaxUsedIter.
setDocumentation(
"Maximum number of columns used in low-rank approximation of Jacobian. If this tag is not provided, the default attribute value of 20 is used.");
558 tagTimeWindowsReused.
setDocumentation(
"Number of past time windows from which columns are used to approximate Jacobian. If this tag is not provided, the attribute value of 0 is used.");
566 "To improve the performance of a parallel or a multi coupling schemes a preconditioner can be applied."
567 "- A constant preconditioner scales every acceleration data by a constant value, which you can define as an attribute of data.\n"
568 "- A value preconditioner scales every acceleration data by the norm of the data in the previous time window.\n"
569 "- A residual preconditioner scales every acceleration data by the current residual.\n"
570 "- A residual-sum preconditioner scales every acceleration data by the sum of the residuals from the current time window.\n"
571 " If this tag is not provided, the residual-sum preconditioner is employed.");
577 .setDocumentation(
"Type of the preconditioner.");
580 .
setDocumentation(
"To update the preconditioner weights after the first time window:"
581 "- `true`: The preconditioner weights are only updated if the weights will change by more than one order of magnitude.\n"
582 "- `false`: The preconditioner weights are updated after every iteration.");
583 tagPreconditioner.
addAttribute(attrpreconditionerUpdateOnThreshold);
585 .setDocumentation(
"After the given number of time windows, the preconditioner weights are frozen and the preconditioner acts like a constant preconditioner.");
590 PRECICE_ERROR(
"Acceleration of type \"{}\" is unknown. Please choose a valid acceleration scheme or check the spelling in the configuration file.", tag.
getName());
#define PRECICE_ERROR(...)
#define PRECICE_TRACE(...)
#define PRECICE_CHECK(check,...)
#define PRECICE_ASSERT(...)
const double _defaultAitkenRelaxationFactor
const std::string VALUE_ZERO_RESTART
const std::string VALUE_VALUE_PRECONDITIONER
const std::string ATTR_PRECOND_UPDATE_ON_THRESHOLD
void addCommonIQNSubtags(xml::XMLTag &tag)
const std::string TAG_FILTER
const std::string VALUE_RESIDUAL_PRECONDITIONER
std::set< std::pair< std::string, std::string > > _uniqueDataAndMeshNames
const std::string ATTR_RSSVD_TRUNCATIONEPS
const std::string VALUE_AITKEN
const std::string ATTR_SINGULARITYLIMIT
const std::string TAG_RELAX
const std::string VALUE_QR2FILTER
const std::string ATTR_PRECOND_NONCONST_TIME_WINDOWS
const std::string ATTR_RSLS_REUSED_TIME_WINDOWS
const std::string ATTR_REDUCEDTIMEGRIDQN
const std::string VALUE_NO_RESTART
const std::string ATTR_NAME
const mesh::PtrMeshConfiguration _meshConfig
struct precice::acceleration::AccelerationConfiguration::UserDefinitions _userDefinitions
impl::PtrPreconditioner _preconditioner
const std::string ATTR_ENFORCE
const std::string VALUE_RESIDUAL_SUM_PRECONDITIONER
const std::string TAG_MAX_USED_ITERATIONS
std::vector< std::string > _neededMeshes
const std::string VALUE_IQNILS
struct precice::acceleration::AccelerationConfiguration::ConfigurationData _config
const struct precice::acceleration::AccelerationConfiguration::DefaultValuesIMVJ _defaultValuesIQNIMVJ
PtrAcceleration getAcceleration()
Returns the configured coupling scheme.
void xmlTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &callingTag) override
Callback method required when using xml::XMLTag.
const std::string ATTR_TYPE
void connectTags(xml::XMLTag &tag)
Connect tags.
const std::string TAG_DATA
const std::string VALUE_QR1_ABSFILTER
const std::string VALUE_LS_RESTART
PtrAcceleration _acceleration
const std::string VALUE_CONSTANT_PRECONDITIONER
const std::string TAG_INIT_RELAX
AccelerationConfiguration(const mesh::PtrMeshConfiguration &meshConfig)
const std::string VALUE_QR3FILTER
const std::string TAG_IMVJRESTART
const struct precice::acceleration::AccelerationConfiguration::DefaultValuesIQN _defaultValuesIQNILS
const std::string TAG_TIME_WINDOWS_REUSED
const std::string VALUE_QR1FILTER
const std::string VALUE_CONSTANT
const std::string VALUE_SVD_RESTART
void clear()
Removes configured acceleration.
const std::string TAG_PRECONDITIONER
const std::string ATTR_MESH
const std::string VALUE_SLIDE_RESTART
const std::string ATTR_BUILDJACOBIAN
const std::string ATTR_SCALING
const std::string ATTR_IMVJCHUNKSIZE
const std::string ATTR_VALUE
void addTypeSpecificSubtags(xml::XMLTag &tag)
const std::string VALUE_IQNIMVJ
void xmlEndTagCallback(const xml::ConfigurationContext &context, xml::XMLTag &callingTag) override
Callback method required when using xml::XMLTag.
static const int QR1FILTER_ABS
static const int QR3FILTER
static const int QR2FILTER
static const int QR1FILTER
Interface quasi-Newton with interface least-squares approximation.
Multi vector quasi-Newton update scheme.
static const int RS_SLIDE
static const int NO_RESTART
Preconditioner that uses the constant user-defined factors to scale the quasi-Newton system.
Preconditioner that uses the recent residual to scale the quasi-Newton system.
Preconditioner that uses the residuals of all iterations of the current time window summed up to scal...
Preconditioner that uses the values from the previous time window to scale the quasi-Newton system.
XMLAttribute & setOptions(std::vector< ATTRIBUTE_T > options)
XMLAttribute & setDocumentation(std::string_view documentation)
Sets a documentation string for the attribute.
Represents an XML tag to be configured automatically.
const std::string & getNamespace() const
Returns xml namespace.
bool hasAttribute(const std::string &attributeName) const
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
XMLTag & setDocumentation(std::string_view documentation)
Adds a description of the purpose of this XML tag.
const std::string & getName() const
Returns name (without namespace).
const std::string & getFullName() const
Returns full name consisting of xml namespace + ":" + name.
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
XMLTag & addAttribute(const XMLAttribute< double > &attribute)
Adds a XML attribute by making a copy of the given attribute.
XMLTag & addSubtag(const XMLTag &tag)
Adds an XML tag as subtag by making a copy of the given tag.
std::shared_ptr< Preconditioner > PtrPreconditioner
contains implementations of acceleration schemes.
std::shared_ptr< Acceleration > PtrAcceleration
contains the XML configuration parser.
std::vector< double > scalingFactorsInOrder() const
int imvjRSLS_reusedTimeWindows
std::vector< int > dataIDs
std::string preconditionerType
bool preconditionerUpdateOnThreshold
double imvjRSSVD_truncationEps
int preconditionerNbNonConstTWindows
std::map< int, double > scalings
bool forceInitialRelaxation
bool preconditionerUpdateOnThreshold
bool preconditionerUpdateOnThreshold
int preconditionerNbNonConstTWindows
bool definedPreconditionerType
bool definedMaxIterationsUsed
bool definedRelaxationFactor
bool definedTimeWindowsReused
Tightly coupled to the parameters of Participant()