Skip to content

Commit

Permalink
Add tons of warnings and associated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
thelfer committed Feb 6, 2025
1 parent 2ce1611 commit ad14ea9
Show file tree
Hide file tree
Showing 54 changed files with 1,088 additions and 69 deletions.
2 changes: 1 addition & 1 deletion cmake/modules/tfel.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ macro(tfel_project tfel_version_major tfel_version_minor tfel_version_patch)
tfel_add_c_cxx_definitions("TFEL_APPEND_SUFFIX")
endif(TFEL_APPEND_VERSION OR TFEL_VERSION_FLAVOUR)

set(TFEL_WEBSITE "http://tfel.sourceforce.net")
set(TFEL_WEBSITE "http://thelfer.github.io/tfel/web/index.html")
# the version number.
set(TFEL_VERSION_MAJOR "${tfel_version_major}")
set(TFEL_VERSION_MINOR "${tfel_version_minor}")
Expand Down
40 changes: 36 additions & 4 deletions docs/web/release-notes-5.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ secPrefixTemplate: "$$i$$"
eqnPrefixTemplate: "($$i$$)"
---

\newcommand{\tenseurq}[1]{\underline{\underline{\mathbf{#1}}}}

# Known incompatibilities

When compiling with option `TFEL_APPEND_VERSION` set to `ON` or when
Expand Down Expand Up @@ -106,10 +108,13 @@ $ tfel-config-5.1.0-release --python-module-suffix

### Ellipsoidal inclusion embedded in anisotropic matrix

When \(\tenseur C_0\) is anisotropic, the Eshelby tensor can be computed
with `computeAnisotropicEshelbyTensor` in 3D and `computePlainStrainAnisotropicEshelbyTensor`
in 2D. There are also `computeAnisotropicHillTensor`, `computePlainStrainAnisotropicHillTensor`,
and also `computeAnisotropicLocalisationTensor` and `computePlainStrainAnisotropicLocalisationTensor`.
When \(\tenseuq{C}_0\) is anisotropic, the Eshelby tensor can be
computed with `computeAnisotropicEshelbyTensor` in 3D and
`computePlainStrainAnisotropicEshelbyTensor` in 2D. There are also
`computeAnisotropicHillTensor`,
`computePlainStrainAnisotropicHillTensor`, and also
`computeAnisotropicLocalisationTensor` and
`computePlainStrainAnisotropicLocalisationTensor`.

### Homogenization bounds

Expand Down Expand Up @@ -156,6 +161,33 @@ choices.

### Warnings added to all DSLs

### Warnings added to the DSLs of the `Default` family

- check that the increments of all gradients are used in the
`@Integrator` code block.
- check that the all thermodynamic forces are used in the
`@Integrator` code block.
- check that the increment of all state variables are used in the
`@Integrator` code block.
- check that all auxiliary state variables are used in the `@Integrator`
code block or in `UpdateAuxiliaryStateVariable` code block.
- check that the consistent tangent operator `Dt` or all the tangent
operator blocks are used in the `@PredictionOperator` code block, if
defined.
- check that the consistent tangent operator `Dt` or all the tangent
operator blocks are used in the `@TangentOperator` code block, if
defined.
- check that the consistent tangent operator `Dt` or all the tangent
operator blocks are used in the `@Integrator` code block if the
implementation declares that the `@Integrator` computes it (using any
of the `@ProvidesTangentOperator` and
`@ProvidesSymmetricTangentOperator`) keywords).
- check that neither the consistent tangent operator `Dt` and any of the
tangent operator blocks are used in the `@Integrator` code block if a
`@TangentOperator` code block has been declared or if the
implementation has not stated that it shall compute the consistent
tangent operator.

### Warnings added to isotropic DSLs

#### Warnings related to the convergence threshold
Expand Down
2 changes: 1 addition & 1 deletion docs/web/tfel-material.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ the function `computeEshelbyTensor` which computes the Eshelby tensor
of an ellipsoid.
If we consider a constant stress-free strain \(\tenseur \varepsilon^\mathrm{T}\)
filling an ellipsoidal volume embedded in an infinite homogeneous medium whose
elasticity is \(\tenseur C_0\), the strain tensor inside the ellipsoid is given by
elasticity is \(\tenseurq{C}_0\), the strain tensor inside the ellipsoid is given by

\(\tenseur \varepsilon=\tenseur S_0:\tenseur \varepsilon^\mathrm{T}\).

Expand Down
13 changes: 9 additions & 4 deletions mfront/include/MFront/BehaviourDSLCommon.hxx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


/*!
* \file mfront/include/MFront/BehaviourDSLCommon.hxx
* \brief
Expand Down Expand Up @@ -755,6 +753,13 @@ namespace mfront {
setComputeFinalThermodynamicForcesFromComputeFinalThermodynamicForcesCandidateIfNecessary();
//! \brief perform pedantic checks
virtual void doPedanticChecks() const;
/*!
* \brief performs common checks on a code block computing the consistent
* tangent operator or the tangent operator blocks
* \param[in] cname: name of the code block
* \param[in] c: code block
*/
void checkTangentOperatorBlock(const std::string&, const CodeBlock&) const;
//! \brief behaviour description
BehaviourDescription mb;
//! \brief registred bricks
Expand All @@ -774,8 +779,8 @@ namespace mfront {
std::vector<ThermodynamicForce> thermodynamic_forces;

bool explicitlyDeclaredUsableInPurelyImplicitResolution;
}; // end of struct BehaviourDSLCommon
}; // end of struct BehaviourDSLCommon

} // end of namespace mfront
} // end of namespace mfront

#endif /* LIB_MFRONT_MFRONTBEHAVIOURDSLCOMMON_HXX */
22 changes: 22 additions & 0 deletions mfront/include/MFront/BehaviourDescription.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,19 @@ namespace mfront {
~BehaviourDescription() override;

private:
/*!
* \brief add a new main variable
* \param[in] g: gradient
* \param[in] th: thermodynamic force
* \param[in] registerGradientGlossaryName: register the glossary name
* assocated with the gradient.
* \param[in] registerTangentOperatorBlock: register the tangent operator
* block.
*/
void addMainVariable2(const Gradient&,
const ThermodynamicForce&,
const bool,
const bool);
//! \brief check and complete the physical bounds of variables
void checkAndCompletePhysicalBoundsDeclaration();
/*!
Expand Down Expand Up @@ -2108,6 +2121,15 @@ namespace mfront {
const BehaviourDescription&,
const BehaviourDescription::Hypothesis,
const CheckInitializeMethodsOptions& = {});
/*!
* \return a list of the consistent tangent operator blocks, separated by a
* comma.
* \param[in] bd: behaviour description
* \param[in] tblocks: list of tangent operator blocks
*/
MFRONT_VISIBILITY_EXPORT std::string makeTangentOperatorBlocksList(
const BehaviourDescription&,
const std::vector<std::pair<VariableDescription, VariableDescription>>&);

} // end of namespace mfront

Expand Down
7 changes: 7 additions & 0 deletions mfront/include/MFront/DefaultDSLBase.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace mfront {
std::string getCodeBlockTemplate(
const std::string&,
const MFrontTemplateGenerationOptions&) const override;
void endsInputFileProcessing() override;
//! \brief default destructor
~DefaultDSLBase() override;

Expand All @@ -41,6 +42,12 @@ namespace mfront {
//
virtual void treatProvidesTangentOperator();
virtual void treatProvidesSymmetricTangentOperator();
/*!
* \brief perform checks of the Integrator code block
* \param[in] h: modelling hypothesis
*/
virtual void checkIntegratorBlock(const Hypothesis) const;

}; // end of struct DefaultDSLBase

} // end of namespace mfront
Expand Down
122 changes: 119 additions & 3 deletions mfront/src/BehaviourDSLCommon.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ namespace mfront {
add("@Profiling", &BehaviourDSLCommon::treatProfiling);
add("@Behaviour", &BehaviourDSLCommon::treatBehaviour);
add("@BehaviourVariable", &BehaviourDSLCommon::treatBehaviourVariable);
add("@BehaviourVariableFactory", &BehaviourDSLCommon::treatBehaviourVariableFactory);
add("@BehaviourVariableFactory",
&BehaviourDSLCommon::treatBehaviourVariableFactory);
add("@StrainMeasure", &BehaviourDSLCommon::treatStrainMeasure);
add("@Author", &BehaviourDSLCommon::treatAuthor);
add("@Date", &BehaviourDSLCommon::treatDate);
Expand Down Expand Up @@ -1374,10 +1375,34 @@ namespace mfront {
}
}
//
//
for (const auto& pb : this->bricks) {
pb->endTreatment();
}
//
for (const auto& h : this->mb.getDistinctModellingHypotheses()) {
if (this->mb.getBehaviourType() ==
BehaviourDescription::STANDARDFINITESTRAINBEHAVIOUR) {
// all available tangent operators for finite strain behaviours
for (const auto& t :
tfel::material::getFiniteStrainBehaviourTangentOperatorFlags()) {
const auto cto_name =
std::string(BehaviourData::ComputeTangentOperator) + '-' +
convertFiniteStrainBehaviourTangentOperatorFlagToString(t);
if (this->mb.hasCode(h, cto_name)) {
const auto& cto = this->mb.getCodeBlock(h, cto_name);
this->checkTangentOperatorBlock(cto_name, cto);
}
}
} else {
if (this->mb.hasCode(h, BehaviourData::ComputeTangentOperator)) {
const auto& cto =
this->mb.getCodeBlock(h, BehaviourData::ComputeTangentOperator);
this->checkTangentOperatorBlock(BehaviourData::ComputeTangentOperator,
cto);
}
}
}
//
if (getVerboseMode() >= VERBOSE_DEBUG) {
getLogStream() << "BehaviourDSLCommon::endsInputFileProcessing: end\n";
}
Expand Down Expand Up @@ -2862,7 +2887,7 @@ namespace mfront {
this->reserveName(getBehaviourWrapperClassName(d));
this->reserveName("mfront_behaviour_variable_" + d.name);
return d;
} // end of readBehaviourVariableDescription
} // end of readBehaviourVariableDescription

void BehaviourDSLCommon::treatBehaviourVariable() {
this->mb.addBehaviourVariable(this->readBehaviourVariableDescription());
Expand Down Expand Up @@ -3767,6 +3792,7 @@ namespace mfront {
<< "return false;\n"
<< "}\n";
tangentOperator.code = code.str();
tangentOperator.members.insert({"Dt", "D"});
this->mb.setCode(h, BehaviourData::ComputeTangentOperator,
tangentOperator, BehaviourData::CREATEBUTDONTREPLACE,
BehaviourData::BODY);
Expand Down Expand Up @@ -4059,6 +4085,96 @@ namespace mfront {
return this->interfaces;
} // end of getBehaviourInterfaces

void BehaviourDSLCommon::checkTangentOperatorBlock(const std::string& cname,
const CodeBlock& c) const {
if (isSafe(c)) {
return;
}
if (this->mb.getBehaviourType() ==
BehaviourDescription::STANDARDFINITESTRAINBEHAVIOUR) {
if (!c.members.contains("Dt")) {
reportWarning("the variable 'Dt' is not used in the '" + cname +
"' code block.");
}
return;
}
if (this->mb.getBehaviourType() ==
BehaviourDescription::COHESIVEZONEMODEL) {
const auto uses_Dt = c.members.contains("Dt");
const auto uses_Dt_c =
c.members.contains("Dt_nn") || c.members.contains("Dt_tt") ||
c.members.contains("Dt_tn") || c.members.contains("Dt_nt");
if ((!uses_Dt) && (!uses_Dt_c)) {
reportWarning("the variable 'Dt' is not used in the '" + cname +
"' code block, nor its block decomposition ('Dt_nn', "
"'Dt_tt', 'Dt_tn', 'Dt_nt').");
}
if ((uses_Dt) && (uses_Dt_c)) {
reportWarning(
"both the variable 'Dt' and some parts of its block decomposition "
"('Dt_nn', 'Dt_tt', 'Dt_tn', 'Dt_nt') are used in the '" +
cname + "' code block. This is unexpected.");
}
if (uses_Dt_c) {
if (!c.members.contains("Dt_nn")) {
reportWarning(
"some parts of its block decomposition of the tangent operator "
"are used in the '" +
cname + "' code block, but not 'Dt_nn'). This is unexpected.");
}
if (!c.members.contains("Dt_tt")) {
reportWarning(
"some parts of its block decomposition of the tangent operator "
"are used in the '" +
cname + "' code block, but not 'Dt_tt'). This is unexpected.");
}
}
return;
}
auto used_tblocks =
std::vector<std::pair<VariableDescription, VariableDescription>>{};
auto unused_tblocks =
std::vector<std::pair<VariableDescription, VariableDescription>>{};
const auto& tblocks = this->mb.getTangentOperatorBlocks();
for (const auto& tblock : tblocks) {
const auto bn = this->mb.getTangentOperatorBlockName(tblock);
if (c.members.contains(bn)) {
used_tblocks.push_back(tblock);
} else {
unused_tblocks.push_back(tblock);
}
}
const auto uses_Dt = c.members.contains("Dt");
if ((!this->mb.hasTrivialTangentOperatorStructure()) && (uses_Dt)) {
reportWarning(
"the consistent tangent operator has a non trivial structure so "
"using directly the variable 'Dt' in the '" +
cname + "' code block is unexpected.");
}
if ((!uses_Dt) && (used_tblocks.empty())) {
reportWarning(
"nor the variable 'Dt' or any of the tangent operator blocks "
"(" +
makeTangentOperatorBlocksList(this->mb, unused_tblocks) +
") is used in the '" + cname + "' code block.");
}
if ((uses_Dt) && (!used_tblocks.empty())) {
reportWarning(
"both the variable 'Dt' and some tangent operator blocks (" +
makeTangentOperatorBlocksList(this->mb, used_tblocks) +
") are used in the '" + cname +
"' code block, which is unexepected.");
}
if ((!used_tblocks.empty()) && (!unused_tblocks.empty())) {
reportWarning("some tangent operator blocks (" +
makeTangentOperatorBlocksList(this->mb, used_tblocks) +
") are used while other are not (" +
makeTangentOperatorBlocksList(this->mb, unused_tblocks) +
") in the '" + cname +
"' code block, which is unexepected.");
}
} // end of checkTangentOperatorBlock

BehaviourDSLCommon::~BehaviourDSLCommon() = default;

} // end of namespace mfront
Loading

0 comments on commit ad14ea9

Please sign in to comment.