From 53e51aac16dbfa7bedb0f101312a8d9a645cae73 Mon Sep 17 00:00:00 2001 From: Vinayak Gholap <vinugholap@gmail.com> Date: Thu, 1 Jun 2023 00:59:30 +0200 Subject: [PATCH] Add get and getRef functions in IP to access and modify internal state variables --- .../ipElecMagGenericThermoMech.cpp | 16 ++++++++++++++++ .../ipElecMagGenericThermoMech.h | 2 ++ .../internalPoints/ipElecMagInductor.cpp | 10 ++++++++++ .../internalPoints/ipElecMagInductor.h | 2 ++ .../internalPoints/ipGenericTM.cpp | 16 ++++++++++++++++ NonLinearSolver/internalPoints/ipGenericTM.h | 2 ++ .../ipLinearElecMagInductor.cpp | 10 ++++++++++ .../internalPoints/ipLinearElecMagInductor.h | 2 ++ .../ipLinearElecMagTherMech.cpp | 9 +++++++++ .../internalPoints/ipLinearElecMagTherMech.h | 2 ++ .../internalPoints/ipLinearElecTherMech.cpp | 9 +++++++++ .../internalPoints/ipLinearElecTherMech.h | 2 ++ .../ipLinearThermoMechanics.cpp | 8 ++++++++ .../internalPoints/ipLinearThermoMechanics.h | 2 ++ .../mlawElecMagGenericThermoMech.cpp | 7 ------- dG3D/src/dG3DIPVariable.cpp | 19 +++++++++++++++---- dG3D/src/dG3DIPVariable.h | 1 + 17 files changed, 108 insertions(+), 11 deletions(-) diff --git a/NonLinearSolver/internalPoints/ipElecMagGenericThermoMech.cpp b/NonLinearSolver/internalPoints/ipElecMagGenericThermoMech.cpp index ce957ed76..f9dfcc4d3 100644 --- a/NonLinearSolver/internalPoints/ipElecMagGenericThermoMech.cpp +++ b/NonLinearSolver/internalPoints/ipElecMagGenericThermoMech.cpp @@ -53,6 +53,22 @@ IPElecMagGenericThermoMech& IPElecMagGenericThermoMech::operator=(const IPVariab return *this; } +double IPElecMagGenericThermoMech::get(const int comp) const +{ + double val=IPVariable::get(comp); + if(val==0.) + val = _ipThermoMech->get(comp); + return val; +} + +double & IPElecMagGenericThermoMech::getRef(const int comp) +{ + double & val=IPVariable::getRef(comp); + if(val==0.) + val = _ipThermoMech->getRef(comp); + return val; +} + void IPElecMagGenericThermoMech::restart() { IPVariable::restart(); diff --git a/NonLinearSolver/internalPoints/ipElecMagGenericThermoMech.h b/NonLinearSolver/internalPoints/ipElecMagGenericThermoMech.h index b47cf9818..d330f03eb 100644 --- a/NonLinearSolver/internalPoints/ipElecMagGenericThermoMech.h +++ b/NonLinearSolver/internalPoints/ipElecMagGenericThermoMech.h @@ -56,5 +56,7 @@ public: } _ipThermoMech= (dynamic_cast<IPGenericTM*>((ipThermoMech.clone()))); } + virtual double get(const int comp) const; + virtual double & getRef(const int comp); }; #endif //IPELECMAGGENERICTHERMOMECH_H_ diff --git a/NonLinearSolver/internalPoints/ipElecMagInductor.cpp b/NonLinearSolver/internalPoints/ipElecMagInductor.cpp index 1c370ed9c..d85e16333 100644 --- a/NonLinearSolver/internalPoints/ipElecMagInductor.cpp +++ b/NonLinearSolver/internalPoints/ipElecMagInductor.cpp @@ -51,6 +51,16 @@ double IPElecMagInductor::defoEnergy() const return IPElecMagGenericThermoMech::defoEnergy(); } +double IPElecMagInductor::get(const int comp) const +{ + return IPElecMagGenericThermoMech::get(comp); +} + +double & IPElecMagInductor::getRef(const int comp) +{ + return IPElecMagGenericThermoMech::getRef(comp); +} + void IPElecMagInductor::restart() { IPElecMagGenericThermoMech::restart(); diff --git a/NonLinearSolver/internalPoints/ipElecMagInductor.h b/NonLinearSolver/internalPoints/ipElecMagInductor.h index bda80da9b..84b201deb 100644 --- a/NonLinearSolver/internalPoints/ipElecMagInductor.h +++ b/NonLinearSolver/internalPoints/ipElecMagInductor.h @@ -30,6 +30,8 @@ public: virtual void restart(); virtual IPVariable* clone() const {return new IPElecMagInductor(*this);} virtual double defoEnergy() const; + virtual double get(const int comp) const; + virtual double & getRef(const int comp); }; #endif //IPELECMAGINDUCTOR_H_ diff --git a/NonLinearSolver/internalPoints/ipGenericTM.cpp b/NonLinearSolver/internalPoints/ipGenericTM.cpp index 172fe9037..0f7bab22b 100644 --- a/NonLinearSolver/internalPoints/ipGenericTM.cpp +++ b/NonLinearSolver/internalPoints/ipGenericTM.cpp @@ -58,4 +58,20 @@ void IPGenericTM::restart() restartManager::restart(referenceF); restartManager::restart(FthI0); restartManager::restart(_thermalEnergy); +} + +double IPGenericTM::get(const int comp) const +{ + double val=IPVariable::get(comp); + if(val==0.) + val = _ipMeca->get(comp); + return val; +} + +double & IPGenericTM::getRef(const int comp) +{ + double & val=IPVariable::getRef(comp); + if(val==0.) + val = _ipMeca->getRef(comp); + return val; } \ No newline at end of file diff --git a/NonLinearSolver/internalPoints/ipGenericTM.h b/NonLinearSolver/internalPoints/ipGenericTM.h index f817833c8..7b8c52a48 100644 --- a/NonLinearSolver/internalPoints/ipGenericTM.h +++ b/NonLinearSolver/internalPoints/ipGenericTM.h @@ -58,6 +58,8 @@ public: const STensor3 & getConstRefToFthI() const { return FthI0;} STensor3 & getRefToFthI(){ return FthI0;} + virtual double get(const int comp) const; + virtual double & getRef(const int comp); }; #endif //IPGENERICTM_H_ diff --git a/NonLinearSolver/internalPoints/ipLinearElecMagInductor.cpp b/NonLinearSolver/internalPoints/ipLinearElecMagInductor.cpp index efed5d3e2..5143cabc9 100644 --- a/NonLinearSolver/internalPoints/ipLinearElecMagInductor.cpp +++ b/NonLinearSolver/internalPoints/ipLinearElecMagInductor.cpp @@ -43,6 +43,16 @@ double IPLinearElecMagInductor::defoEnergy() const return IPLinearElecMagTherMech::defoEnergy(); } +double IPLinearElecMagInductor::get(const int comp) const +{ + return IPLinearElecMagTherMech::get(comp); +} + +double & IPLinearElecMagInductor::getRef(const int comp) +{ + return IPLinearElecMagTherMech::getRef(comp); +} + void IPLinearElecMagInductor::restart() { IPLinearElecMagTherMech::restart(); diff --git a/NonLinearSolver/internalPoints/ipLinearElecMagInductor.h b/NonLinearSolver/internalPoints/ipLinearElecMagInductor.h index b8af67684..94c587a72 100644 --- a/NonLinearSolver/internalPoints/ipLinearElecMagInductor.h +++ b/NonLinearSolver/internalPoints/ipLinearElecMagInductor.h @@ -25,6 +25,8 @@ public: virtual void restart(); virtual IPVariable* clone() const {return new IPLinearElecMagInductor(*this);} virtual double defoEnergy() const; + virtual double get(const int comp) const; + virtual double & getRef(const int comp); private: IPLinearElecMagInductor(); }; diff --git a/NonLinearSolver/internalPoints/ipLinearElecMagTherMech.cpp b/NonLinearSolver/internalPoints/ipLinearElecMagTherMech.cpp index 219cbc68d..221e4ca7e 100644 --- a/NonLinearSolver/internalPoints/ipLinearElecMagTherMech.cpp +++ b/NonLinearSolver/internalPoints/ipLinearElecMagTherMech.cpp @@ -29,3 +29,12 @@ void IPLinearElecMagTherMech::restart() { IPLinearElecTherMech::restart(); } +double IPLinearElecMagTherMech::get(const int comp) const +{ + return IPLinearElecTherMech::get(comp); +} + +double & IPLinearElecMagTherMech::getRef(const int comp) +{ + return IPLinearElecTherMech::getRef(comp); +} \ No newline at end of file diff --git a/NonLinearSolver/internalPoints/ipLinearElecMagTherMech.h b/NonLinearSolver/internalPoints/ipLinearElecMagTherMech.h index 0efffa8ef..85ba82fa9 100644 --- a/NonLinearSolver/internalPoints/ipLinearElecMagTherMech.h +++ b/NonLinearSolver/internalPoints/ipLinearElecMagTherMech.h @@ -26,6 +26,8 @@ public: return new IPLinearElecMagTherMech(*this); } virtual void restart(); + virtual double get(const int comp) const; + virtual double & getRef(const int comp); }; #endif // IPLinearElecMagTherMech_H_ diff --git a/NonLinearSolver/internalPoints/ipLinearElecTherMech.cpp b/NonLinearSolver/internalPoints/ipLinearElecTherMech.cpp index 17d5b6d99..f4a8ed3dc 100644 --- a/NonLinearSolver/internalPoints/ipLinearElecTherMech.cpp +++ b/NonLinearSolver/internalPoints/ipLinearElecTherMech.cpp @@ -29,3 +29,12 @@ void IPLinearElecTherMech::restart() IPVariableMechanics::restart(); restartManager::restart( _elasticEnergy); } +double IPLinearElecTherMech::get(const int comp) const +{ + return IPLinearThermoMechanics::get(comp); +} + +double & IPLinearElecTherMech::getRef(const int comp) +{ + return IPLinearThermoMechanics::getRef(comp); +} diff --git a/NonLinearSolver/internalPoints/ipLinearElecTherMech.h b/NonLinearSolver/internalPoints/ipLinearElecTherMech.h index 218b580e4..64922fdda 100644 --- a/NonLinearSolver/internalPoints/ipLinearElecTherMech.h +++ b/NonLinearSolver/internalPoints/ipLinearElecTherMech.h @@ -26,6 +26,8 @@ public: virtual IPVariable* clone() const {return new IPLinearElecTherMech(*this);}; //virtual void restart(){return IPLinearThermoMechanics::restart();} virtual void restart(); + virtual double get(const int comp) const; + virtual double &getRef(const int comp); }; #endif // IPLinearElecTherMech_H_ diff --git a/NonLinearSolver/internalPoints/ipLinearThermoMechanics.cpp b/NonLinearSolver/internalPoints/ipLinearThermoMechanics.cpp index 40054cc67..4e2c430f1 100644 --- a/NonLinearSolver/internalPoints/ipLinearThermoMechanics.cpp +++ b/NonLinearSolver/internalPoints/ipLinearThermoMechanics.cpp @@ -45,6 +45,14 @@ double IPLinearThermoMechanics::getThermalEnergy() const return _fracEnergy; }*/ +double IPLinearThermoMechanics::get(const int comp) const +{ + return IPVariableMechanics::get(comp); +} +double & IPLinearThermoMechanics::getRef(const int comp) +{ + return IPVariableMechanics::getRef(comp); +} void IPLinearThermoMechanics::restart() { diff --git a/NonLinearSolver/internalPoints/ipLinearThermoMechanics.h b/NonLinearSolver/internalPoints/ipLinearThermoMechanics.h index 4babe78f1..8b24febb9 100644 --- a/NonLinearSolver/internalPoints/ipLinearThermoMechanics.h +++ b/NonLinearSolver/internalPoints/ipLinearThermoMechanics.h @@ -26,6 +26,8 @@ class IPLinearThermoMechanics : public IPVariableMechanics virtual void restart(); virtual IPVariable* clone() const {return new IPLinearThermoMechanics(*this);}; virtual double getConstRefToFractureEnergy() const {return _fracEnergy;}; + virtual double get(const int comp) const; + virtual double & getRef(const int comp); }; #endif // IPLINEARTHERMOMECHANICS_H_ diff --git a/NonLinearSolver/materialLaw/mlawElecMagGenericThermoMech.cpp b/NonLinearSolver/materialLaw/mlawElecMagGenericThermoMech.cpp index dcf9e7ce2..bab9ae1be 100644 --- a/NonLinearSolver/materialLaw/mlawElecMagGenericThermoMech.cpp +++ b/NonLinearSolver/materialLaw/mlawElecMagGenericThermoMech.cpp @@ -548,13 +548,6 @@ void mlawElecMagGenericThermoMech::constitutive( } } - if(applyReferenceF) - { - // in weak EM problem with Fn = I - // d*dFn = 0 always because Fn is constant - STensorOperation::zero(dFTotdFn); - } - //from HERE NO MORE applyReferenceFq // Magnetic permeability tensor from constitutive model diff --git a/dG3D/src/dG3DIPVariable.cpp b/dG3D/src/dG3DIPVariable.cpp index 27a28a223..fae3f2dd4 100644 --- a/dG3D/src/dG3DIPVariable.cpp +++ b/dG3D/src/dG3DIPVariable.cpp @@ -4743,10 +4743,12 @@ LinearElecMagTherMechDG3DIPVariable& LinearElecMagTherMechDG3DIPVariable::operat return *this; } -double LinearElecMagTherMechDG3DIPVariable::get(const int i) const +double LinearElecMagTherMechDG3DIPVariable::get(const int comp) const { - - return ElecMagTherMechDG3DIPVariableBase::get(i); + double val =ElecMagTherMechDG3DIPVariableBase::get(comp); + if (val == 0) + val = _linearEMTMIP.get(comp); + return val; } double & LinearElecMagTherMechDG3DIPVariable::getRef(const int i) @@ -4797,7 +4799,11 @@ LinearElecMagInductorDG3DIPVariable & LinearElecMagInductorDG3DIPVariable::opera double LinearElecMagInductorDG3DIPVariable::get(const int comp) const { - return ElecMagTherMechDG3DIPVariableBase::get(comp); + double val =ElecMagTherMechDG3DIPVariableBase::get(comp); + if (val == 0) + val = _linearEMInductor.get(comp); + return val; + } double & LinearElecMagInductorDG3DIPVariable::getRef(const int comp) @@ -5079,6 +5085,11 @@ double ElecMagGenericThermoMechanicsDG3DIPVariable::get(const int i) const return val; } +double & ElecMagGenericThermoMechanicsDG3DIPVariable::getRef(const int i) +{ + return ElecMagTherMechDG3DIPVariableBase::getRef(i); +} + double ElecMagGenericThermoMechanicsDG3DIPVariable::defoEnergy() const { return getConstRefToIpThermoMech().defoEnergy(); diff --git a/dG3D/src/dG3DIPVariable.h b/dG3D/src/dG3DIPVariable.h index 645f7e272..081272073 100644 --- a/dG3D/src/dG3DIPVariable.h +++ b/dG3D/src/dG3DIPVariable.h @@ -5005,6 +5005,7 @@ public: _elecMagGenericThermoMechIP = NULL; } virtual double get(const int i) const; + virtual double & getRef(const int i); virtual double defoEnergy() const; virtual double getInternalEnergyExtraDofDiffusion() const {return _elecMagGenericThermoMechIP->getThermalEnergy();}; virtual double plasticEnergy() const; -- GitLab