Skip to content
Snippets Groups Projects
Commit 5af95953 authored by mohib's avatar mohib
Browse files

[GenericCrackPhaseField] - Creation of mlaw

parent 26fc537c
No related branches found
No related tags found
1 merge request!427[GenericCrackPhaseField] - Feature | Benchmark
//
// C++ Interface: material law
//
// Description: Generic Crack Phase Field
//
// Mohib Mustafa
// 03/12/24
#include "mlawNonLocalDamage.h"
#include "mlawGenericCrackPhaseField.h"
mlawGenericCrackPhaseField::mlawGenericCrackPhaseField(const int num, const double rho, const double lc,
const double gc) : materialLaw(num, true), _rho(rho), _lc(lc), _gc(gc){
_matlaw = NULL;
}
mlawGenericCrackPhaseField::mlawGenericCrackPhaseField(const mlawGenericCrackPhaseField& source) :
materialLaw(source), _matlaw(NULL), _rho(source._rho), _lc(source._lc), _gc(source._gc) {
if (source._matlaw != NULL) {
if(_matlaw != NULL) {
delete _matlaw;
_matlaw = NULL;
}
_matlaw=source._matlaw->clone();
}
}
void mlawGenericCrackPhaseField::setMechanicalMaterialLaw(const materialLaw *matlaw) {
if(_matlaw != NULL) {
delete _matlaw;
_matlaw = NULL;
}
_matlaw = matlaw->clone();
}
const materialLaw& mlawGenericCrackPhaseField::getConstRefMechanicalMaterialLaw() const {
if(_matlaw == NULL) {
Msg::Error("getConstRefMechanicalMaterialLaw: Mechanic law is null");
}
return *_matlaw;
}
materialLaw& mlawGenericCrackPhaseField::getRefMechanicalMaterialLaw() {
if(_matlaw == NULL) {
Msg::Error("getRefMechanicalMaterialLaw: Mechanic law is null");
}
return *_matlaw;
}
void mlawGenericCrackPhaseField::setTime(const double ctime, const double dtime) {
materialLaw::setTime(ctime, dtime);
if(_matlaw == NULL) {
Msg::Error("setTime: Mechanic law is null");
}
_matlaw->setTime(ctime, dtime);
}
void mlawGenericCrackPhaseField::setMacroSolver(const nonLinearMechSolver *sv) {
materialLaw::setMacroSolver(sv);
if(_matlaw == NULL) {
Msg::Error("setMacroSolver: Mechanic law is null");
}
_matlaw->setMacroSolver(sv);
}
mlawGenericCrackPhaseField& mlawGenericCrackPhaseField::operator=(const materialLaw &source){
materialLaw::operator=(source);
const mlawGenericCrackPhaseField* src = static_cast<const mlawGenericCrackPhaseField*>(&source);
_rho = src->_rho;
_lc = src->_lc;
_gc = src->_gc;
return *this;
}
mlawGenericCrackPhaseField::~mlawGenericCrackPhaseField() {
if(_matlaw != NULL) {
delete _matlaw;
_matlaw = NULL;
}
}
//
// C++ Interface: material law
//
// Description: Generic Crack Phase Field
//
// Mohib Mustafa
// 03/12/24
#ifndef MLAWGENERICCRACKPHASEFIELD_H
#define MLAWGENERICCRACKPHASEFIELD_H
#include "mlaw.h"
#include "mlawNonLocalDamage.h"
#include "material.h"
#include "../../../gmsh/contrib/domhex/cross3D.h"
#include "../../../gmsh/contrib/untangle/mat.h"
class mlawGenericCrackPhaseField : public materialLaw{
protected:
materialLaw* _matlaw;
double _rho;
double _lc;
double _gc;
public:
mlawGenericCrackPhaseField(int num, double rho, double lc, double gc);
virtual void setMechanicalMaterialLaw(const materialLaw *matlaw);
const materialLaw& getConstRefMechanicalMaterialLaw() const;
materialLaw &getRefMechanicalMaterialLaw();
virtual void setTime(const double ctime, const double dtime);
virtual void setMacroSolver(const nonLinearMechSolver *sv);
#ifndef SWIG
mlawGenericCrackPhaseField(const mlawGenericCrackPhaseField& source);
virtual ~mlawGenericCrackPhaseField();
mlawGenericCrackPhaseField& operator=(const materialLaw &source);
//irtual materialLaw* clone() const {return new mlawGenericCrackPhaseField(*this);}
#endif //SWIG
};
#endif //MLAWGENERICCRACKPHASEFIELD_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment