Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

535 mfront doc add support for material properties #593

Merged
merged 8 commits into from
Jul 5, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/web/release-notes-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,16 @@ use the `TFEL` libraries in `C++` projects, using either the

# Issues fixed

## Issue 535: [mfront-doc] add support for material properties

Allows mfront-doc to be used with the `MaterialLaw` DSL. Example of use:

~~~~{.bash}
$ mfront-doc T91MartensiticSteel_gamma1_ROUX2007.mfront
~~~~

For more details, see <https://github.com/thelfer/tfel/issues/535>

## Issue 582: [cast3m interface] add explicit names and 4-letter mapping of internal variables to the castem file

Adds the correspondence between variable names and the 4-letter
Expand Down
2 changes: 1 addition & 1 deletion mfront-doc/include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
install_mfront_header(MFront BehaviourDocumentationGenerator.hxx)
install_mfront_header(MFront DocumentationGeneratorBase.hxx BehaviourDocumentationGenerator.hxx MaterialPropertyDocumentationGenerator.hxx)
74 changes: 22 additions & 52 deletions mfront-doc/include/MFront/BehaviourDocumentationGenerator.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,29 +20,15 @@
#include <utility>
#include <functional>

#include "TFEL/Utilities/ArgumentParserBase.hxx"
#include "TFEL/Material/ModellingHypothesis.hxx"
#include "MFront/MFrontBase.hxx"
#include "MFront/DocumentationGeneratorBase.hxx"

namespace mfront {

// forward declaration
struct AbstractBehaviourDSL;
// forward declaration
struct BehaviourDescription;
// forward declaration
struct FileDescription;

/*!
* Class used by the mfront-query tool to extract information from
* behaviour implementation
*/
struct BehaviourDocumentationGenerator
: public tfel::utilities::ArgumentParserBase<
BehaviourDocumentationGenerator>,
public MFrontBase {
//! \brief type of documentation to be generated
enum OutputType { FULL, WEB };
struct BehaviourDocumentationGenerator : public DocumentationGeneratorBase {
/*!
* build a BehaviourDocumentationGenerator object based on command line
* arguments
Expand All @@ -56,48 +42,32 @@ namespace mfront {
std::shared_ptr<AbstractBehaviourDSL>,
const std::string &);
//! treat the requests
void exe();
void exe() const override;
//! destructor
~BehaviourDocumentationGenerator() override;

struct VariableInformation
: DocumentationGeneratorBase::VariableInformationBase {
using Hypothesis = tfel::material::ModellingHypothesis::Hypothesis;
VariableInformation();
VariableInformation(VariableInformation &&) noexcept;
VariableInformation(const VariableInformation &);
VariableInformation &operator=(VariableInformation &&);
VariableInformation &operator=(const VariableInformation &);
~VariableInformation() noexcept;
std::map<Hypothesis, std::string> descriptions;
std::vector<Hypothesis> hypotheses;
};

private:
//! ArgumentParserBase must be a friend
friend struct tfel::utilities::ArgumentParserBase<
BehaviourDocumentationGenerator>;
//! \brief register call-backs associated with command line arguments
virtual void registerCommandLineCallBacks();
//! treat the web argument
virtual void treatWeb();
virtual void writeWebOutput(std::ostream &,
const BehaviourDescription &,
const FileDescription &) const;
virtual void writeFullOutput(std::ostream &,
const BehaviourDescription &,
const FileDescription &) const;
//! return the current argument
const tfel::utilities::Argument &getCurrentCommandLineArgument()
const override final;
//! treat an unknown argument
void treatUnknownArgument() override final;
//! get the version description
std::string getVersionDescription() const override final;
//! get the usage description
std::string getUsageDescription() const override final;
void writeWebOutput(std::ostream &,
const BehaviourDescription &,
const FileDescription &) const;
void writeFullOutput(std::ostream &,
const BehaviourDescription &,
const FileDescription &) const;
//! abstract behaviour dsl
std::shared_ptr<AbstractBehaviourDSL> dsl;
//! input file name
std::string file;
//! type of ouput
OutputType otype;
//! \brief generate output on standard output
bool std_output = false;
/*!
* \brief boolean whose meaning is the following:
* - if true, the generated documentation is contained in a whole document.
* - if false, the generated documentation is contained in a section meant
* to be included in a bigger document.
*/
bool standalone = false;
}; // end of struct BehaviourDocumentationGenerator

} // end of namespace mfront
Expand Down
111 changes: 111 additions & 0 deletions mfront-doc/include/MFront/DocumentationGeneratorBase.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/*!
* \file DocumentationGeneratorBase.hxx
* \brief
* \author Maxence Wangermez
* \date 16 avril 2024
* \copyright Copyright (C) 2006-2024 CEA/DEN, EDF R&D. All rights
* reserved.
* This project is publicly released under either the GNU GPL Licence
* or the CECILL-A licence. A copy of thoses licences are delivered
* with the sources of TFEL. CEA or EDF may also distribute this
* project under specific licensing conditions.
*/

#ifndef LIB_MFRONT_DOCUMENTATIONGENERATORBASE_H
#define LIB_MFRONT_DOCUMENTATIONGENERATORBASE_H

#include <string>
#include <vector>
#include <memory>
#include <utility>
#include <functional>

#include "TFEL/Utilities/ArgumentParserBase.hxx"
#include "MFront/MFrontBase.hxx"

namespace mfront {

// forward declaration
struct BehaviourDescription;
// forward declaration
struct FileDescription;

/*!
* Class used by the mfront-query tool to extract information from
* behaviour implementation
*/
struct DocumentationGeneratorBase
: public tfel::utilities::ArgumentParserBase<DocumentationGeneratorBase>,
public MFrontBase {
//! \brief type of documentation to be generated
enum OutputType { FULL, WEB };
/*!
* build a DocumentationGeneratorBase object based on command line
* arguments
* \param[in] argc : number of command line arguments
* \param[in] argv : command line arguments
* \param[in] f : filename
*/
DocumentationGeneratorBase(const int,
const char *const *const,
const std::string &);
virtual void exe() const = 0;
//! destructor
~DocumentationGeneratorBase() override;

// Private member data
//! input file name
std::string file;
/*!
* \brief boolean whose meaning is the following:
* - if true, the generated documentation is contained in a whole document.
* - if false, the generated documentation is contained in a section meant
* to be included in a bigger document.
*/
bool standalone = false;

//! \brief generate output on standard output
bool std_output = false;
//! type of ouput
OutputType otype;
//! \brief generate latex macros for header of output file
void writeStandardLatexMacros(std::ostream &) const;
maxence-wz marked this conversation as resolved.
Show resolved Hide resolved

//! \brief data structure describing a variable
struct VariableInformationBase {
VariableInformationBase();
VariableInformationBase(VariableInformationBase &&) noexcept;
VariableInformationBase(const VariableInformationBase &);
VariableInformationBase &operator=(VariableInformationBase &&);
VariableInformationBase &operator=(const VariableInformationBase &);
~VariableInformationBase() noexcept;
std::string name;
std::string type;
std::string description;
std::string externalName;
unsigned short arraySize;
};

private:
//! ArgumentParserBase must be a friend
friend struct tfel::utilities::ArgumentParserBase<
DocumentationGeneratorBase>;
//! \brief register call-backs associated with command line arguments
virtual void registerCommandLineCallBacks();
//! treat the web argument
virtual void treatWeb();
//! return the current argument
const tfel::utilities::Argument &getCurrentCommandLineArgument()
const override final;
//! treat an unknown argument
void treatUnknownArgument() override final;
//! get the version description
std::string getVersionDescription() const override final;
//! get the usage description
std::string getUsageDescription() const override final;

}; // end of struct DocumentationGeneratorBase

} // end of namespace mfront

#endif /* LIB_MFRONT_DOCUMENTATIONGENERATORBASE_H */
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*!
* \file MaterialPropertyDocumentationGenerator.hxx
* \brief
* \author Maxence Wangermez
* \date 16 avril 2024
* \copyright Copyright (C) 2006-2024 CEA/DEN, EDF R&D. All rights
* reserved.
* This project is publicly released under either the GNU GPL Licence
* or the CECILL-A licence. A copy of thoses licences are delivered
* with the sources of TFEL. CEA or EDF may also distribute this
* project under specific licensing conditions.
*/

#ifndef LIB_MFRONT_MATERIALPROPERTYDOCUMENTATIONGENERATOR_H
#define LIB_MFRONT_MATERIALPROPERTYDOCUMENTATIONGENERATOR_H

#include <string>
#include <vector>
#include <memory>
#include <utility>
#include <functional>

#include "MFront/MaterialPropertyDSL.hxx"
#include "MFront/DocumentationGeneratorBase.hxx"

namespace mfront {

/*!
* Class used by the mfront-query tool to extract information from
* behaviour implementation
*/
struct MaterialPropertyDocumentationGenerator
: public DocumentationGeneratorBase {
/*!
* build a MaterialPropertyDocumentationGenerator object based on command
* line arguments \param[in] argc : number of command line arguments
* \param[in] argv : command line arguments
* \param[in] d : behaviour domain specific language
* \param[in] f : behaviour domain specific language
*/
MaterialPropertyDocumentationGenerator(const int,
const char *const *const,
std::shared_ptr<MaterialPropertyDSL>,
const std::string &);
//! treat the requests
void exe() const override;
//! destructor
~MaterialPropertyDocumentationGenerator() override;

struct VariableInformation
: DocumentationGeneratorBase::VariableInformationBase {
VariableInformation();
VariableInformation(VariableInformation &&) noexcept;
VariableInformation(const VariableInformation &);
VariableInformation &operator=(VariableInformation &&);
VariableInformation &operator=(const VariableInformation &);
~VariableInformation() noexcept;
};

private:
void writeWebOutput(std::ostream &,
const MaterialPropertyDescription &,
const FileDescription &) const;
void writeFullOutput(std::ostream &,
const MaterialPropertyDescription &,
const FileDescription &) const;
//! abstract behaviour dsl
std::shared_ptr<MaterialPropertyDSL> dsl;
}; // end of struct MaterialPropertyDocumentationGenerator

} // end of namespace mfront

#endif /* LIB_MFRONT_MATERIALPROPERTYDOCUMENTATIONGENERATOR_H */
Loading
Loading