Commit 4e79314f authored by Kevin Moreau's avatar Kevin Moreau

Separate the superposition procedure to another formulation.

Know polymorphism with virtual functions is used.



git-svn-id: https://svn.ec-nantes.fr/eXlibris/Applis/TLSDuctile@2344 fbbead7c-fb4d-4173-aa67-51132c73c120
parent bc117811
......@@ -65,7 +65,7 @@ public:
void writeCurrentToOldMaterialVariables();
// Writes strain given by std::string using disp field symmetric gradient.
void writeStrain(std::string, std::string="all");
virtual void writeStrain(std::string, std::string="all");
virtual void assembleGraphMatrix(LinearSystem&);
......@@ -81,7 +81,7 @@ public:
virtual void assembleInternalForce(LinearSystem&, std::string, std::string="all");
// Assembles external force vector by reading main.dat file
void assembleNaturalEnv(LinearSystem&);
virtual void assembleNaturalEnv(LinearSystem&);
// Constrains value by declaring it fixed (value state),
// gives the prescribed value from main.dat.
......
......@@ -65,20 +65,6 @@ QSFormulation::QSFormulation(TLSGeom& geom, TLSSolver& tls_solver,
std::abort();
}
if(parse_data.getInt("do_superposition")) {
if(mat_class=="elastic_plastic_damage") {
std::cout<<"Error: superposition has never been tested with elastic plastic damage model"<<std::endl;
std::abort();
}
std::cout<<"do superposition"<<std::endl;
ptfunc_write_strain=&QSFormulation::writeStrainSuperposition;
ptfunc_assemble_natural_env=&QSFormulation::assembleNaturalEnvSuperposition;
}
else {
ptfunc_write_strain=&Formulation::writeStrain;
ptfunc_assemble_natural_env=&Formulation::assembleNaturalEnv;
}
declareMaterialVariables();
declareDispField();
applyEssentialEnv(1.);
......@@ -336,37 +322,6 @@ void QSFormulation::addDisp(const xCSRVector& vec, std::string name) {
CustomValueDoubleSelector::which_val=0;
}
void QSFormulation::assembleNaturalEnv(LinearSystem& system) {
(this->*ptfunc_assemble_natural_env)(system);
}
void QSFormulation::assembleNaturalEnvSuperposition(LinearSystem& system) {
Formulation::assembleNaturalEnv(system);
NonUniformMaterialSensitivity_c<xTensor4> eval_stiffness("secant_matrix", variab_manager);
xEvalConstant<xTensor2> eval_strain(parse_data.getTensor2("superimposed_strain"));
xEvalBinary<xMult<xTensor4, xTensor2, xTensor2> > eval_stress(eval_stiffness, eval_strain);
xFormLinearWithLoad<xGradOperator<xSymmetrize>, xEval<xTensor2> > form_linear(eval_stress);
system.setAssemblerCoeff(-1.);
Assemble(form_linear, system.getAssembler(), geom.getIntegRuleSmart(), disp_field, geom.begin(), geom.end());
system.setAssemblerCoeff(1.);
}
void QSFormulation::writeStrain(std::string name, std::string domain_name) {
(this->*ptfunc_write_strain)(name, domain_name);
}
void QSFormulation::writeStrainSuperposition(std::string name, std::string domain_name) {
OldAndCurrent_c::current();
xEvalConstant<xTensor2> eval_strain_hom(parse_data.getTensor2("superimposed_strain"));
xEvalGradField<xSymmetrize> eval_strain_tilde(disp_field);
xEvalBinary<std::plus<xTensor2> > eval_strain(eval_strain_tilde, eval_strain_hom);
SetMaterialVariablesVisitor_c<xEvalBinary<std::plus<xTensor2>>> set_visitor(name, eval_strain);
UpdateMaterialVariablesVisitor_c update_visitor(name);
xeCompositeMaterialVariablesVisitor_c composite_visitor(set_visitor, update_visitor);
VisitMaterialVariablesCommand_c visit_command(composite_visitor, variab_manager);
ApplyCommandOnIntegrationRule(visit_command, geom.getIntegRuleSmart(), geom.begin(domain_name), geom.end(domain_name));
}
void QSFormulation::writeCurrentToOld() {
writeCurrentToOldMaterialVariables();
tls_solver.writeCurrentToOldLevelSetField();
......
......@@ -16,7 +16,7 @@ public:
const xfem::xData&, const xParseData&,
PreProcessing&, PostProcessing&);
virtual ~QSFormulation();
public:
// Updates level set field and material variables
virtual void updateCurrentState();
......@@ -29,11 +29,6 @@ public:
// Computes load factor
double computeLoadFactor();
// Assembles external force vector by reading main.dat file.
// If superposition is used, assembles forces due to prescribed
// strain field.
void assembleNaturalEnv(LinearSystem&);
// Writes to disp field dof values from xCSRVector, a specific
// disp field is selected by the string
void writeDisp(const lalg::xCSRVector&, std::string);
......@@ -41,9 +36,6 @@ public:
// Appends to disp field dof values from xCSRVector.
void addDisp(const lalg::xCSRVector&, std::string);
// Writes strain given by std::string using disp field symmetric gradient.
void writeStrain(std::string, std::string="all");
// Writes current values of level set field and material variables
// to old values
void writeCurrentToOld();
......@@ -71,9 +63,6 @@ protected:
void clearDispMeasField();
void declareDispMeasField();
void writeStrainSuperposition(std::string, std::string);
void assembleNaturalEnvSuperposition(LinearSystem&);
xfem::xVector computeRefForce();
xfem::xVector computeRefDisp();
protected:
......@@ -87,9 +76,6 @@ protected:
xfem::xVector old_ref_force, ref_force, old_ref_disp, ref_disp;
const double delta_phi_max;
bool is_forced, is_nonlinear, do_anticipated_exit;
void (QSFormulation::*ptfunc_write_strain)(std::string, std::string);
void (QSFormulation::*ptfunc_assemble_natural_env)(LinearSystem&);
};
#endif
/*
Copyright © 2004 Nicolas MOES, Fabien CAZES, Kévin MOREAU and Benoît LE All Right Reserved
TLSDuctile source code is subject to non-permissive licence,
see the LICENSE files for conditions.
*/
#include "FormulationQSSuperimposed.h"
#include "TLSGeom.h"
#include "LinearSystem.h"
#include "xAlgorithm.h"
#include "xAssembler.h"
#include "MaterialCommand.h"
#include "NonUniformMaterialSensitivity.h"
using namespace xfem;
QSFormulationSuperimposed::QSFormulationSuperimposed(TLSGeom& geom, TLSSolver& tls_solver,
const xData& data, const xParseData& parse_data,
PreProcessing& pre_pro, PostProcessing& post_pro,
const xEval<xTensor2>& eval_strain_superimposed) :
QSFormulation(geom, tls_solver, data, parse_data, pre_pro, post_pro),
eval_strain_superimposed(eval_strain_superimposed)
{}
QSFormulationSuperimposed::~QSFormulationSuperimposed() {}
void QSFormulationSuperimposed::assembleNaturalEnv(LinearSystem& system) {
Formulation::assembleNaturalEnv(system);
NonUniformMaterialSensitivity_c<xTensor4> eval_stiffness("secant_matrix", variab_manager);
xEvalBinary<xMult<xTensor4, xTensor2, xTensor2> > eval_stress(eval_stiffness, eval_strain_superimposed);
xFormLinearWithLoad<xGradOperator<xSymmetrize>, xEval<xTensor2> > form_linear(eval_stress);
system.setAssemblerCoeff(-1.);
Assemble(form_linear, system.getAssembler(), geom.getIntegRuleSmart(), disp_field, geom.begin(), geom.end());
system.setAssemblerCoeff(1.);
}
void QSFormulationSuperimposed::writeStrain(std::string name, std::string domain_name) {
OldAndCurrent_c::current();
xEvalGradField<xSymmetrize> eval_strain_tilde(disp_field);
xEvalBinary<std::plus<xTensor2> > eval_strain(eval_strain_tilde, eval_strain_superimposed);
SetMaterialVariablesVisitor_c<xEvalBinary<std::plus<xTensor2>>> set_visitor(name, eval_strain);
UpdateMaterialVariablesVisitor_c update_visitor(name);
xeCompositeMaterialVariablesVisitor_c composite_visitor(set_visitor, update_visitor);
VisitMaterialVariablesCommand_c visit_command(composite_visitor, variab_manager);
ApplyCommandOnIntegrationRule(visit_command, geom.getIntegRuleSmart(), geom.begin(domain_name), geom.end(domain_name));
}
/*
Copyright © 2004 Nicolas MOES, Fabien CAZES, Kévin MOREAU and Benoît LE All Right Reserved
TLSDuctile source code is subject to non-permissive licence,
see the LICENSE files for conditions.
*/
#ifndef _TLSDuctile_FormulationQSSuperimposed_h_
#define _TLSDuctile_FormulationQSSuperimposed_h_
#include "FormulationQS.h"
// This class slightly modifies FormulationQS. It considers a
// displacement field decomposed into two parts u=u_1+u_2, where u_2
// is assumed to be known. Then the solver only as to find u_1, the
// eps_2 contribution appears in the right hand side of the linear
// system.
class QSFormulationSuperimposed : public QSFormulation {
public:
QSFormulationSuperimposed(TLSGeom&, TLSSolver&,
const xfem::xData&, const xParseData&,
PreProcessing&, PostProcessing&, const xfem::xEval<xfem::xTensor2>&);
virtual ~QSFormulationSuperimposed();
// Assembles external force vector by reading main.dat file and
// assembles forces due to prescribed strain field.
virtual void assembleNaturalEnv(LinearSystem&);
// Writes strain given by std::string using disp field symmetric gradient.
virtual void writeStrain(std::string, std::string="all");
private:
const xfem::xEval<xfem::xTensor2>& eval_strain_superimposed;
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment