v0.16.0
Loading...
Searching...
No Matches
mofem/src/materials/MatOps.hpp
/**
* \file MatOps.hpp
* \example mofem/src/materials/MatOps.hpp
*
* @copyright Copyright (c) 2023
*/
#ifndef __MAT_OPS_HPP__
#define __MAT_OPS_HPP__
namespace MatOps {
// One valid tag-info type for addTagDGProjectionOps(...).
// Equivalent to std::tuple<std::string, Tag, int>.
struct StateTag {
std::string name;
Tag tag = 0;
int numComponents = 0;
};
using StateTags = std::vector<StateTag>;
using DataDictionary = std::map<std::string, std::string>;
struct MatOpsTagsRegistry {
static int atTagName(std::string name);
static int setTagName(std::string name, int tag = -1);
static std::string getTagName(int tag);
protected:
static int getTagByName(std::string name);
static inline std::map<std::string, int> tagNameVsTag;
};
/** \name MatOps Data Interface */
/**@{*/
struct MatOpsData : public boost::enable_shared_from_this<MatOpsData> {
virtual ~MatOpsData() = default;
using MatrixPtr = boost::shared_ptr<MatrixDouble>;
using StateMatrixPtr = boost::shared_ptr<MatrixAdaptor>;
virtual std::pair<bool, MatrixPtr>
insertCommonData(const std::string &name,
const MatrixDouble &data = MatrixDouble(),
int shift = 0) = 0;
virtual std::pair<bool, MatrixPtr>
insertActiveData(const std::string &name,
const MatrixDouble &data = MatrixDouble(),
int shift = 0) = 0;
virtual std::pair<bool, MatrixPtr>
insertDependentData(const std::string &name,
const MatrixDouble &data = MatrixDouble(),
int shift = 0) = 0;
virtual std::pair<bool, MatrixPtr>
insertDependentDerivativesData(const std::string &name,
const MatrixDouble &data = MatrixDouble(),
int shift = 0) = 0;
virtual MatrixPtr getCommonDataPtr(const std::string &name) = 0;
virtual MatrixPtr getActiveDataPtr(const std::string &name) = 0;
virtual MatrixPtr getDependentDataPtr(const std::string &name) = 0;
virtual MatrixPtr getDependentDerivativesDataPtr(const std::string &name) = 0;
virtual StateMatrixPtr getStateDataPtr(const std::string &name,
EntityHandle ent, int gg) = 0;
virtual StateTags getStateTags() const = 0;
virtual MoFEMErrorCode bindStateTag(MoFEM::Interface &m_field,
const std::string &tag_name,
int num_components) = 0;
virtual MoFEMErrorCode setupStateData() = 0;
virtual MoFEMErrorCode
setActiveContinuousVector(std::vector<double> &active_variables) = 0;
virtual MoFEMErrorCode
setDependentContinuousVector(std::vector<double> &dependent_variables) = 0;
std::vector<double> &dependent_variables_derivatives) = 0;
virtual MoFEMErrorCode
getActiveContinuousVector(const std::vector<double> &active_variables) = 0;
virtual MoFEMErrorCode getDependentContinuousVector(
const std::vector<double> &dependent_variables) = 0;
const std::vector<double> &dependent_variables_derivatives) = 0;
};
/**@}*/
/** \name Physical Equation Interface */
/**@{*/
struct AdolCEvaluation {
static MoFEMErrorCode
evaluateVariable(boost::shared_ptr<MatOpsData> mat_ops_data_ptr,
int tag, EntityHandle entity, int gg);
static MoFEMErrorCode
evaluateDerivatives(boost::shared_ptr<MatOpsData> mat_ops_data_ptr,
int tag, EntityHandle entity, int gg);
private:
inline static std::vector<double> activeVariables;
inline static std::vector<double> dependentVariables;
inline static std::vector<double> dependentVariablesDerivatives;
inline static std::vector<double *> jacPtrVec;
};
struct PhysicalEquations {
PhysicalEquations() = delete;
boost::shared_ptr<MatOpsData> mat_ops_data_ptr, int tag,
boost::shared_ptr<std::map<int, Range>> tag_vs_range_ptr = nullptr)
: matOpsDataPtr(mat_ops_data_ptr), tAg(tag),
tagVsRangePtr(tag_vs_range_ptr) {}
virtual ~PhysicalEquations() = default;
virtual MoFEMErrorCode
getOptions(MoFEM::Interface *m_field_ptr = nullptr) = 0;
virtual MoFEMErrorCode setParams(FEMethod *fe_ptr, int gg) = 0;
virtual MoFEMErrorCode recordTape() = 0;
virtual ForcesAndSourcesCore::UserDataOperator *
createOp(boost::shared_ptr<PhysicalEquations> physical_ptr, bool eval_stress,
bool eval_tangent, bool update) = 0;
using HookFunction = std::function<MoFEMErrorCode(
boost::shared_ptr<MatOpsData>, int, EntityHandle, int)>;
virtual MoFEMErrorCode evaluateVariable(int tag, EntityHandle entity, int gg) {
return hookEvaluateVariable(this->matOpsDataPtr, tag, entity, gg);
}
virtual MoFEMErrorCode evaluateDerivatives(int tag, EntityHandle entity,
int gg) {
return hookEvaluateDerivatives(matOpsDataPtr, tag, entity, gg);
}
virtual MoFEMErrorCode updateState(int tag, EntityHandle entity, int gg) {
return hookUpdateState(this->matOpsDataPtr, tag, entity, gg);
}
int tAg;
boost::shared_ptr<std::map<int, Range>> tagVsRangePtr;
std::vector<std::pair<Range, std::vector<double>>> paramVecByRange;
boost::shared_ptr<MatOpsData> matOpsDataPtr;
};
/**@}*/
/** \name Data Factory */
/**@{*/
boost::shared_ptr<MatOpsData> createMatOpsDataPtr();
boost::shared_ptr<MatOpsData> createMatOpsDataPtr(
boost::weak_ptr<MatOpsData>,
DataDictionary common_data_dictionary = {},
DataDictionary state_data_dictionary = {});
/**@}*/
/** \name Generic Operator Factory */
/**@{*/
enum ModelType {
};
struct MODEL {
MODEL() = delete;
};
template <class MODEL, int MODEL_TYPE>
boost::shared_ptr<PhysicalEquations>
createMatOpsPhysicalEquationsPtr(boost::shared_ptr<MatOpsData> mat_ops_data_ptr,
int tag);
template <class MODEL, int MODEL_TYPE> struct OpMaterialFactory {
OpMaterialFactory() = delete;
};
/**@}*/
} // namespace MatOps
#endif // __MAT_OPS_HPP__
std::map< std::string, std::string > DataDictionary
Definition MatOps.hpp:22
@ MODEL_AXISYMMETRIC
Definition MatOps.hpp:174
@ MODEL_3D
Definition MatOps.hpp:171
@ MODEL_2D_PLANE_STRESS
Definition MatOps.hpp:173
@ MODEL_2D_PLANE_STRAIN
Definition MatOps.hpp:172
std::vector< StateTag > StateTags
Definition MatOps.hpp:21
boost::shared_ptr< PhysicalEquations > createMatOpsPhysicalEquationsPtr(boost::shared_ptr< MatOpsData > mat_ops_data_ptr, int tag)
boost::shared_ptr< MatOpsData > createMatOpsDataPtr()
Definition MatOps.cpp:671
static MoFEMErrorCode evaluateVariable(boost::shared_ptr< MatOpsData > mat_ops_data_ptr, int tag, EntityHandle entity, int gg)
Definition MatOps.cpp:685
static std::vector< double > dependentVariablesDerivatives
Definition MatOps.hpp:107
static std::vector< double > dependentVariables
Definition MatOps.hpp:106
static MoFEMErrorCode evaluateDerivatives(boost::shared_ptr< MatOpsData > mat_ops_data_ptr, int tag, EntityHandle entity, int gg)
Definition MatOps.cpp:705
static std::vector< double > activeVariables
Definition MatOps.hpp:105
static std::vector< double * > jacPtrVec
Definition MatOps.hpp:108
MODEL()=delete
virtual MoFEMErrorCode setActiveContinuousVector(std::vector< double > &active_variables)=0
virtual MoFEMErrorCode getDependentDerivativesContinuousVector(const std::vector< double > &dependent_variables_derivatives)=0
virtual MoFEMErrorCode setDependentDerivativesContinuousVector(std::vector< double > &dependent_variables_derivatives)=0
virtual MatrixPtr getActiveDataPtr(const std::string &name)=0
virtual std::pair< bool, MatrixPtr > insertDependentData(const std::string &name, const MatrixDouble &data=MatrixDouble(), int shift=0)=0
virtual MoFEMErrorCode setupStateData()=0
virtual std::pair< bool, MatrixPtr > insertActiveData(const std::string &name, const MatrixDouble &data=MatrixDouble(), int shift=0)=0
boost::shared_ptr< MatrixAdaptor > StateMatrixPtr
Definition MatOps.hpp:41
virtual MoFEMErrorCode bindStateTag(MoFEM::Interface &m_field, const std::string &tag_name, int num_components)=0
virtual ~MatOpsData()=default
virtual MoFEMErrorCode getActiveContinuousVector(const std::vector< double > &active_variables)=0
virtual std::pair< bool, MatrixPtr > insertCommonData(const std::string &name, const MatrixDouble &data=MatrixDouble(), int shift=0)=0
boost::shared_ptr< MatrixDouble > MatrixPtr
Definition MatOps.hpp:40
virtual MatrixPtr getCommonDataPtr(const std::string &name)=0
virtual StateTags getStateTags() const =0
virtual StateMatrixPtr getStateDataPtr(const std::string &name, EntityHandle ent, int gg)=0
virtual MatrixPtr getDependentDataPtr(const std::string &name)=0
virtual MoFEMErrorCode setDependentContinuousVector(std::vector< double > &dependent_variables)=0
virtual MatrixPtr getDependentDerivativesDataPtr(const std::string &name)=0
virtual std::pair< bool, MatrixPtr > insertDependentDerivativesData(const std::string &name, const MatrixDouble &data=MatrixDouble(), int shift=0)=0
virtual MoFEMErrorCode getDependentContinuousVector(const std::vector< double > &dependent_variables)=0
static int setTagName(std::string name, int tag=-1)
Definition MatOps.cpp:30
static std::string getTagName(int tag)
Definition MatOps.cpp:83
static int atTagName(std::string name)
Definition MatOps.cpp:26
static int getTagByName(std::string name)
Definition MatOps.cpp:73
static std::map< std::string, int > tagNameVsTag
Definition MatOps.hpp:32
virtual MoFEMErrorCode recordTape()=0
virtual ~PhysicalEquations()=default
virtual MoFEMErrorCode setParams(FEMethod *fe_ptr, int gg)=0
std::vector< std::pair< Range, std::vector< double > > > paramVecByRange
Definition MatOps.hpp:152
boost::shared_ptr< std::map< int, Range > > tagVsRangePtr
Definition MatOps.hpp:151
boost::shared_ptr< MatOpsData > matOpsDataPtr
Definition MatOps.hpp:154
virtual MoFEMErrorCode evaluateVariable(int tag, EntityHandle entity, int gg)
Definition MatOps.hpp:137
virtual MoFEMErrorCode evaluateDerivatives(int tag, EntityHandle entity, int gg)
Definition MatOps.hpp:141
virtual ForcesAndSourcesCore::UserDataOperator * createOp(boost::shared_ptr< PhysicalEquations > physical_ptr, bool eval_stress, bool eval_tangent, bool update)=0
HookFunction hookUpdateState
Definition MatOps.hpp:135
HookFunction hookEvaluateVariable
Definition MatOps.hpp:133
HookFunction hookEvaluateDerivatives
Definition MatOps.hpp:134
virtual MoFEMErrorCode getOptions(MoFEM::Interface *m_field_ptr=nullptr)=0
std::function< MoFEMErrorCode(boost::shared_ptr< MatOpsData >, int, EntityHandle, int)> HookFunction
Definition MatOps.hpp:131
virtual MoFEMErrorCode updateState(int tag, EntityHandle entity, int gg)
Definition MatOps.hpp:146
std::string name
Definition MatOps.hpp:16
Deprecated interface functions.