Commit b9a90544 authored by Benoît LÉ's avatar Benoît LÉ

[xInterfaceMatlib] Add xInterfaceMatlib

Based on work initiated by G. Legrain.

Interface between eXlibris and Matlib material library ("lite" version can be  downloaded here:
https://git.gem.ec-nantes.fr/MatLib/Lite).

To compile this interface:

1) Download and compile Matlib. It must be compiled using the add_definitions( -DMATLIB_USE_MATLIB_NAMESPACE)

2) Install Matlib in a /my/path/to/matlib/ such that libraries are installed in /my/path/to/matlib/lib and
include in /my/path/to/matlib/include. Path to sources /my/path/to/matlib/src will also be necessary

3) Add

if(USE_MATLIB)
    set(MATLIB_PATH "/my/path/to/matlib/src will also be necessary"  CACHE INTERNAL "Matlib install path")#
endif(USE_MATLIB)

to the LocalConfig.cmake file. The line "is_not_installed ( USE_MATLIB )" (which is by default activated in the
 template LocalConfig.cmake of GeMUtil) may eventually need to be commented

4) Set BUILD_XINTERFACE_MATLIB and USE_MATLIB to "ON" in the main CMakeLists.txt

5) (Try to) compile !

To use it in In your code:

1) You need to declare a

xinterface::aomd::xAttachedDataManagerAOMD<std::vector<xinterface::matlibinterface::xMaterialTwoStates>>

which will store some xMaterialTwoStates at each Gauss points

2) Each xMaterialTwoStatesInterface (defined in) contains two matlib::MaterialState, corresponding to the previous
and current material state

3) Still in xMaterialTwoStatesInterface.h, you will find classes to manipulate theses states. In particular, some
important classes are:
  - xInitVectorMatLibTwoStatesToAttachedDataManagerAOMD: must be used with an ApplyCommandOnIntegration rule to
  initialize the states
  - xMatLibStandardMaterialStateUpdatorVectorTwoStates: to update the material states at each Gauss points
  - xMatLibLipschitzMaterialStateUpdator: same, but update only softening variables, in the framework of the Lipfield
   regularization (an appli illustrating the implementation of the Lipfield approach should come soon)
  - xEvalVectorMatLibStandardMaterialTangent: evaluator of the material tangent

4) xEvalFromMatlib.h contains several evaluators to access the quantities stored at GaussPoints and use them in eXlibris.
For now they can be used to access scalar or tensorial matlib gradients, fluxes and internal variables (maybe evaluators
corresponding to vectorial quantities should be added ?)

5) xInterfaceMatlibToExlibris.h contains classes which are used by the previously mentionned classes. Basically, provides
sgome tools to read and/or write from/to matlib arrays

6)  xMatlibHelpers.h some helper functions to parse a material file and create Matlib objects

Note that for objects dealing with tensor 2 or 4 (example : xEvalVectorMatLibStandardMaterialTangent, evaluators in
xEvalFromMatlib.h), some builder functions are provide to instanciate the correct template object, which depends on the
problem dimension. In the case of the xEvalVectorMatLibStandardMaterialTangent, it can be used directly inside your main
appli (but special care must be given to the problem dimension), otherwise a xFormBilinearMatLibStandardMaterialTangentFactory
is provided in the interface to create the corresponding bilinear form (which is btw the only thing which is necessary in most
cases).
parent 681ab507
......@@ -143,6 +143,10 @@ if(BUILD_XTEMPLATEREFINEMESH)
add_subdirectory(xInterface/xTemplateRefineMesh "${CMAKE_CURRENT_BINARY_DIR}/xInterface/xTemplateRefineMesh")
endif()
if(BUILD_XINTERFACE_MATLIB)
add_subdirectory(xInterface/Matlib/ "${CMAKE_CURRENT_BINARY_DIR}/xInterface/Matlib")
endif()
if(BUILD_ATOMIC_TEST)
......
cmake_minimum_required(VERSION 2.6)
set(text "")
message_verbose(text)
set(text "--------------------------------")
message_verbose(text)
message(STATUS "building xInterfaceMatlib --")
set(text "--------------------------------")
message_verbose(text)
add_definitions( -DMATLIB_USE_MATLIB_NAMESPACE)
set(BUILD_SHARED_LIBS "SHARED")
define_archos_suffixe(ARCHOS)
file(GLOB sources src/*.cc src/*.h)
add_library(xInterfaceMatlib ${BUILD_SHARED_LIBS} ${sources} )
find_package(xTool REQUIRED )
find_package(Trellis REQUIRED )
find_package(xInterfaceAOMDGeneral REQUIRED )
find_package(xGeomTools REQUIRED )
find_package(xFEM REQUIRED )
find_package(xQuadrature REQUIRED )
find_package(Matlib REQUIRED )
include_directories(
src
${MPI_CXX_INCLUDE_PATH}
${xTool_INCLUDE_DIR}
${Trellis_INCLUDE_DIR}
${xInterfaceAOMDGeneral_INCLUDE_DIR}
${xGeomTools_INCLUDE_DIR}
${xFEM_INCLUDE_DIR}
${xQuadrature_INCLUDE_DIR}
${MATLIB_INCLUDE_DIR}
)
message(" include Matlib is ${MATLIB_INCLUDE_DIR}" )
install_target_in_destination(xInterfaceMatlib)
#include "xEvalFromMatlib.h"
using namespace std;
namespace xinterface
{
namespace matlibinterface
{
xEvalMatlibScalarGrad::xEvalMatlibScalarGrad(
matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_, int shift_, int istates_)
: eval_matlib_material_state(eval_matlib_two_material_states_), shift(shift_), istates(istates_)
{
if (istates != 0 && istates != 1)
{
cout << "Error in xEvalMatlibScalarGrad : istates must be 0 or 1 ! " << endl;
throw 123;
}
standard_material_.initState(material_properties_, m2[0]);
standard_material_.initState(material_properties_, m2[1]);
}
void xEvalMatlibScalarGrad::operator()(const xfem::xGeomElem* appro, const xfem::xGeomElem* integ, double& res) const
{
eval_matlib_material_state(appro, integ, m2);
matlib::MaterialState m = m2[istates];
res = m.grad[shift];
}
xEvalMatlibScalarFlux::xEvalMatlibScalarFlux(
matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_, int shift_, int istates_)
: eval_matlib_material_state(eval_matlib_two_material_states_), shift(shift_), istates(istates_)
{
if (istates != 0 && istates != 1)
{
cout << "Error in xEvalMatlibScalarFlux : istates must be 0 or 1 ! " << endl;
throw 123;
}
standard_material_.initState(material_properties_, m2[0]);
standard_material_.initState(material_properties_, m2[1]);
}
void xEvalMatlibScalarFlux::operator()(const xfem::xGeomElem* appro, const xfem::xGeomElem* integ, double& res) const
{
eval_matlib_material_state(appro, integ, m2);
matlib::MaterialState m = m2[istates];
res = m.flux[shift];
}
xEvalMatlibScalarInternalVariable::xEvalMatlibScalarInternalVariable(
matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_, int shift_, int istates_)
: eval_matlib_material_state(eval_matlib_two_material_states_), shift(shift_), istates(istates_)
{
if (istates != 0 && istates != 1)
{
cout << "Error in xEvalMatlibScalarInternalVariable : istates must be 0 or 1 ! " << endl;
throw 123;
}
standard_material_.initState(material_properties_, m2[0]);
standard_material_.initState(material_properties_, m2[1]);
}
void xEvalMatlibScalarInternalVariable::operator()(const xfem::xGeomElem* appro, const xfem::xGeomElem* integ, double& res) const
{
eval_matlib_material_state(appro, integ, m2);
matlib::MaterialState m = m2[istates];
res = m.internal[shift];
}
xfem::xEval<xtensor::xTensor2<>>* buildxEvalMatlibTensorGrad(
int dim, matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_, int shift_, int istates_)
{
switch (dim)
{
case 1:
return new xEvalMatlibTensorGrad<matlib::SymTensor1D>(standard_material_, material_properties_,
eval_matlib_two_material_states_, shift_, istates_);
break;
case 2:
return new xEvalMatlibTensorGrad<matlib::SymTensor2D>(standard_material_, material_properties_,
eval_matlib_two_material_states_, shift_, istates_);
break;
case 3:
return new xEvalMatlibTensorGrad<matlib::SymTensor3D>(standard_material_, material_properties_,
eval_matlib_two_material_states_, shift_, istates_);
break;
default:
cout << "Error in buildxEvalMatlibTensorGrad : dimension must be 1, 2 or 3" << endl;
throw 123;
}
}
xfem::xEval<xtensor::xTensor2<>>* buildxEvalMatlibTensorFlux(
int dim, matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_, int shift_, int istates_)
{
switch (dim)
{
case 1:
return new xEvalMatlibTensorFlux<matlib::SymTensor1D>(standard_material_, material_properties_,
eval_matlib_two_material_states_, shift_, istates_);
break;
case 2:
return new xEvalMatlibTensorFlux<matlib::SymTensor2D>(standard_material_, material_properties_,
eval_matlib_two_material_states_, shift_, istates_);
break;
case 3:
return new xEvalMatlibTensorFlux<matlib::SymTensor3D>(standard_material_, material_properties_,
eval_matlib_two_material_states_, shift_, istates_);
break;
default:
cout << "Error in buildxEvalMatlibTensorFlux : dimension must be 1, 2 or 3" << endl;
throw 123;
}
}
xfem::xEval<xtensor::xTensor2<>>* buildxEvalMatlibTensorInternalVariable(
int dim, matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_, int shift_, int istates_)
{
switch (dim)
{
case 1:
return new xEvalMatlibTensorInternalVariable<matlib::SymTensor1D>(standard_material_, material_properties_,
eval_matlib_two_material_states_, shift_, istates_);
break;
case 2:
return new xEvalMatlibTensorInternalVariable<matlib::SymTensor2D>(standard_material_, material_properties_,
eval_matlib_two_material_states_, shift_, istates_);
break;
case 3:
return new xEvalMatlibTensorInternalVariable<matlib::SymTensor3D>(standard_material_, material_properties_,
eval_matlib_two_material_states_, shift_, istates_);
break;
default:
cout << "Error in buildxEvalMatlibTensorInternalVariable : dimension must be 1, 2 or 3" << endl;
throw 123;
}
}
} // namespace matlibinterface
} // namespace xinterface
#ifndef _xEvalFromMatlib_h_
#define _xEvalFromMatlib_h_
#include "MatLib.h"
#include "xCommandOnGeomElem.h"
#include "xEval.h"
#include "xInterfaceMatlibToExlibris.h"
#include "xMaterialTwoStatesInterface.h"
namespace xinterface
{
namespace matlibinterface
{
class xEvalMatlibScalarGrad : public xfem::xEval<double>
{
public:
xEvalMatlibScalarGrad(matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_, int shift_,
int istates_);
void operator()(const xfem::xGeomElem* appro, const xfem::xGeomElem* integ, double& res) const;
private:
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_material_state;
mutable xMaterialTwoStates m2;
int shift;
int istates;
};
class xEvalMatlibScalarFlux : public xfem::xEval<double>
{
public:
xEvalMatlibScalarFlux(matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_, int shift_,
int istates_);
void operator()(const xfem::xGeomElem* appro, const xfem::xGeomElem* integ, double& res) const;
private:
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_material_state;
mutable xMaterialTwoStates m2;
int shift;
int istates;
};
class xEvalMatlibScalarInternalVariable : public xfem::xEval<double>
{
public:
xEvalMatlibScalarInternalVariable(matlib::StandardMaterial& standard_material_,
const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_,
int shift_, int istates_);
void operator()(const xfem::xGeomElem* appro, const xfem::xGeomElem* integ, double& res) const;
private:
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_material_state;
mutable xMaterialTwoStates m2;
int shift;
int istates;
};
template <typename MATLIBTENSOR2>
class xEvalMatlibTensorGrad : public xfem::xEval<xtensor::xTensor2<>>
{
public:
xEvalMatlibTensorGrad(matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_, int shift_,
int istates_)
: eval_matlib_material_state(eval_matlib_two_material_states_), shift(shift_), istates(istates_)
{
standard_material_.initState(material_properties_, m2[0]);
standard_material_.initState(material_properties_, m2[1]);
}
void operator()(const xfem::xGeomElem* appro, const xfem::xGeomElem* integ, xtensor::xTensor2<>& res) const
{
const bool debug{false};
eval_matlib_material_state(appro, integ, m2);
matlib::MaterialState m = m2[istates];
if (debug)
{
std::cout << "Before export grad \n";
integ->getEntity()->print();
std::cout << "bState1 " << m.grad << " " << m.flux << " " << m.internal << std::endl;
}
matlib::MatLibArray subarray(m.grad, MATLIBTENSOR2::MEMSIZE, shift);
MATLIBTENSOR2 tensor2Matlib(subarray);
// convert from tensor engineering
tensor2Matlib = tensor2Matlib.covariant();
res = xMatLibeXlibrisOp::convert<MATLIBTENSOR2>(0, tensor2Matlib);
}
private:
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_material_state;
mutable xMaterialTwoStates m2;
int shift;
int istates;
};
xfem::xEval<xtensor::xTensor2<>>* buildxEvalMatlibTensorGrad(
int dim, matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_, int shift_, int istates_);
template <typename MATLIBTENSOR2>
class xEvalMatlibTensorFlux : public xfem::xEval<xtensor::xTensor2<>>
{
public:
xEvalMatlibTensorFlux(matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_, int shift_,
int istates_)
: eval_matlib_material_state(eval_matlib_two_material_states_), shift(shift_), istates(istates_)
{
standard_material_.initState(material_properties_, m2[0]);
standard_material_.initState(material_properties_, m2[1]);
}
void operator()(const xfem::xGeomElem* appro, const xfem::xGeomElem* integ, xtensor::xTensor2<>& res) const
{
const bool debug{false};
eval_matlib_material_state(appro, integ, m2);
matlib::MaterialState m = m2[istates];
if (debug)
{
std::cout << "Before export flux \n";
integ->getEntity()->print();
std::cout << "bState1 " << m.grad << " " << m.flux << " " << m.internal << std::endl;
}
matlib::MatLibArray subarray(m.flux, MATLIBTENSOR2::MEMSIZE, shift);
MATLIBTENSOR2 tensor2Matlib(subarray);
// convert from tensor engineering
tensor2Matlib = tensor2Matlib.covariant();
res = xMatLibeXlibrisOp::convert<MATLIBTENSOR2>(0, tensor2Matlib);
}
private:
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_material_state;
mutable xMaterialTwoStates m2;
int shift;
int istates;
};
xfem::xEval<xtensor::xTensor2<>>* buildxEvalMatlibTensorFlux(
int dim, matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_, int shift_, int istates_);
template <typename MATLIBTENSOR2>
class xEvalMatlibTensorInternalVariable : public xfem::xEval<xtensor::xTensor2<>>
{
public:
xEvalMatlibTensorInternalVariable(matlib::StandardMaterial& standard_material_,
const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_,
int shift_, int istates_)
: eval_matlib_material_state(eval_matlib_two_material_states_), shift(shift_), istates(istates_)
{
standard_material_.initState(material_properties_, m2[0]);
standard_material_.initState(material_properties_, m2[1]);
}
void operator()(const xfem::xGeomElem* appro, const xfem::xGeomElem* integ, xtensor::xTensor2<>& res) const
{
const bool debug{false};
eval_matlib_material_state(appro, integ, m2);
matlib::MaterialState m = m2[istates];
if (debug)
{
std::cout << "Before export internal variable \n";
integ->getEntity()->print();
std::cout << "bState1 " << m.grad << " " << m.flux << " " << m.internal << std::endl;
}
matlib::MatLibArray subarray(m.internal, MATLIBTENSOR2::MEMSIZE, shift);
MATLIBTENSOR2 tensor2Matlib(subarray);
// convert from tensor engineering
tensor2Matlib = tensor2Matlib.covariant();
res = xMatLibeXlibrisOp::convert<MATLIBTENSOR2>(0, tensor2Matlib);
}
private:
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_material_state;
mutable xMaterialTwoStates m2;
int shift;
int istates;
};
xfem::xEval<xtensor::xTensor2<>>* buildxEvalMatlibTensorInternalVariable(
int dim, matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_matlib_two_material_states_, int shift_, int istates_);
} // namespace matlibinterface
} // namespace xinterface
#endif
#include "xInterfaceMatlibToExlibris.h"
using namespace xfem;
namespace xinterface
{
namespace matlibinterface
{
xtensor::xTensor2<> xMatLibeXlibrisOp::contract(const xtensor::xTensor2<>& a, const matlib::SymTensor4_1D& b)
{
xtensor::xTensor2<> c(0.0);
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
for (int k = 0; k < 3; k++)
{
for (int l = 0; l < 3; l++)
{
double factCov = 1.;
if (((i < 1 && j < 1) || i == j) && ((k < 1 && l < 1) || k == l)) c(i, j) += a(k, l) * b(k, l, i, j) * factCov;
}
}
}
}
return c;
}
xtensor::xTensor2<> xMatLibeXlibrisOp::contract(const xtensor::xTensor2<>& a, const matlib::SymTensor4_2D& b)
{
xtensor::xTensor2<> c(0.0);
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
for (int k = 0; k < 3; k++)
{
for (int l = 0; l < 3; l++)
{
double factCov = 1.;
if (((i < 2 && j < 2) || i == j) && ((k < 2 && l < 2) || k == l)) c(i, j) += a(k, l) * b(k, l, i, j) * factCov;
}
}
}
}
return c;
}
xtensor::xTensor2<> xMatLibeXlibrisOp::contract(const xtensor::xTensor2<>& a, const matlib::SymTensor4_3D& b)
{
xtensor::xTensor2<> c(0.0);
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
for (int k = 0; k < 3; k++)
{
for (int l = 0; l < 3; l++)
{
c(i, j) += a(k, l) * b(k, l, i, j);
}
}
}
}
return c;
}
xEvalMatLibArrayBase* buildxEvalMatlibArrayxTensor2Converter(int dim, const xEval<xtensor::xTensor2<>>& eval_)
{
switch (dim)
{
case 1:
return new xEvalMatLibArrayConverter<xtensor::xTensor2<>, matlib::SymTensor1D>(eval_);
break;
case 2:
return new xEvalMatLibArrayConverter<xtensor::xTensor2<>, matlib::SymTensor2D>(eval_);
break;
case 3:
return new xEvalMatLibArrayConverter<xtensor::xTensor2<>, matlib::SymTensor3D>(eval_);
break;
default:
std::cout << "Error in buildxEvalMatlibArrayxTensor2Converter : dimension must be 1, 2 or 3" << std::endl;
throw 123;
}
}
} // namespace matlibinterface
} // namespace xinterface
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
#ifndef _xMaterialTwoStatesInterface_imp_h_
#define _xMaterialTwoStatesInterface_imp_h_
namespace xinterface
{
namespace matlibinterface
{
template <typename MATLIBTENSOR4>
xEvalVectorMatLibStandardMaterialTangent<MATLIBTENSOR4>::xEvalVectorMatLibStandardMaterialTangent(
matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
const matlib::ParameterSet& parameter_set_, xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_states_,
const xfem::xEval<matlib::MaterialState>& init_state1_, xWriteVectorMatLibTwoStatesBase& writer_)
: standard_material(standard_material_),
material_properties(material_properties_),
parameter_set(parameter_set_),
eval_states(eval_states_),
init_state1(init_state1_),
writer(writer_),
time_step(1.),
forLastStep_(false)
{
}
template <typename MATLIBTENSOR4>
void xEvalVectorMatLibStandardMaterialTangent<MATLIBTENSOR4>::operator()(const xfem::xGeomElem* appro,
const xfem::xGeomElem* integ, result_type& res) const
{
const bool debug{false};
if (debug) std::cout << "enter xEvalVectorMatLibStandardMaterialTangent\n";
AOMD::mEntity* e = integ->getEntity();
// declare and initialize material state
matlib::MaterialState state1;
xMaterialTwoStates states;
// Init state for current Gp
standard_material.initState(material_properties, state1);
standard_material.initState(material_properties, states[0]);
standard_material.initState(material_properties, states[1]);
// Eval state for current GPs
eval_states(appro, integ, states);
if (debug) std::cout << "forLastStep " << forLastStep_ << std::endl;
if (forLastStep_)
state1 = states[0];
else
init_state1(appro, integ, state1);
// prepare matlib tangent
res.resize(standard_material.nExtVar());
if (debug)
{
std::cout << "Before Tangent \n";
integ->getEntity()->print();
matlib::MaterialState state0 = states[0];
std::cout << "bState0 " << state0.grad << " " << state0.flux << " " << state0.internal << std::endl;
std::cout << "bState1 " << state1.grad << " " << state1.flux << " " << state1.internal << std::endl;
std::cout << "time_step " << time_step << std::endl;
}
// Update constitutive law
standard_material.incrementalPotential(material_properties, parameter_set, states[0], state1, time_step, res, true, true);
if (debug) std::cout << "Tangent " << res << std::endl;
}
template <typename OperatorLeft, typename OperatorRight>
xFormBilinearMatLibStandardMaterialTangentFactory<OperatorLeft,
OperatorRight>::xFormBilinearMatLibStandardMaterialTangentFactory()
: dim(0),
eval_tangent_1D(nullptr),
eval_tangent_2D(nullptr),
eval_tangent_3D(nullptr),
bilinear_form_1D(nullptr),
bilinear_form_2D(nullptr),
bilinear_form_3D(nullptr)
{
}
template <typename OperatorLeft, typename OperatorRight>
xFormBilinearMatLibStandardMaterialTangentFactory<OperatorLeft, OperatorRight>::xFormBilinearMatLibStandardMaterialTangentFactory(
int dim_, matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
const matlib::ParameterSet& parameter_set_, xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_states_,
const xfem::xEval<matlib::MaterialState>& init_state1_, xWriteVectorMatLibTwoStatesBase& writer_)
: dim(dim_),
eval_tangent_1D(nullptr),
eval_tangent_2D(nullptr),
eval_tangent_3D(nullptr),
bilinear_form_1D(nullptr),
bilinear_form_2D(nullptr),
bilinear_form_3D(nullptr)
{
init(dim_, standard_material_, material_properties_, parameter_set_, eval_states_, init_state1_, writer_);
}
template <typename OperatorLeft, typename OperatorRight>
xFormBilinearMatLibStandardMaterialTangentFactory<OperatorLeft,
OperatorRight>::~xFormBilinearMatLibStandardMaterialTangentFactory()
{
switch (dim)
{
case 1:
delete bilinear_form_1D;
delete eval_tangent_1D;
break;
case 2:
delete bilinear_form_2D;
delete eval_tangent_2D;
break;
case 3:
delete bilinear_form_3D;
delete eval_tangent_3D;
break;
default:
std::cout << "Error in xFormBilinearMatLibStandardMaterialTangentFactory : dimension must be 1, 2 or 3" << std::endl;
throw 123;
}
}
template <typename OperatorLeft, typename OperatorRight>
void xFormBilinearMatLibStandardMaterialTangentFactory<OperatorLeft, OperatorRight>::init(
int dim_, matlib::StandardMaterial& standard_material_, const matlib::MaterialProperties& material_properties_,
const matlib::ParameterSet& parameter_set_, xEvalVectorMatLibTwoStatesFromAttachedDataManagerAOMD& eval_states_,
const xfem::xEval<matlib::MaterialState>& init_state1_, xWriteVectorMatLibTwoStatesBase& writer_)
{
dim = dim_;
switch (dim)
{
case 1:
eval_tangent_1D = new xEvalVectorMatLibStandardMaterialTangent<matlibTensor4Type1D>(
standard_material_, material_properties_, parameter_set_, eval_states_, init_state1_, writer_);
bilinear_form_1D =
new xfem::xFormBilinearWithLaw<OperatorLeft, xEvalVectorMatLibStandardMaterialTangent<matlibTensor4Type1D>,
OperatorRight>(*eval_tangent_1D);
break;
case 2:
eval_tangent_2D = new xEvalVectorMatLibStandardMaterialTangent<matlibTensor4Type2D>(
standard_material_, material_properties_, parameter_set_, eval_states_, init_state1_, writer_);
bilinear_form_2D =
new xfem::xFormBilinearWithLaw<OperatorLeft, xEvalVectorMatLibStandardMaterialTangent<matlibTensor4Type2D>,
OperatorRight>(*eval_tangent_2D);
break;
case 3:
eval_tangent_3D = new xEvalVectorMatLibStandardMaterialTangent<matlibTensor4Type3D>(
standard_material_, material_properties_, parameter_set_, eval_states_, init_state1_, writer_);
bilinear_form_3D =
new xfem::xFormBilinearWithLaw<OperatorLeft, xEvalVectorMatLibStandardMaterialTangent<matlibTensor4Type3D>,
OperatorRight>(*eval_tangent_3D);
break;
default:
std::cout << "Error in xFormBilinearMatLibStandardMaterialTangentFactory : dimension must be 1, 2 or 3" << std::endl;
throw 123;
}
}
template <typename OperatorLeft, typename OperatorRight>
xfem::xFormBilinear<>& xFormBilinearMatLibStandardMaterialTangentFactory<OperatorLeft, OperatorRight>::getBilinearForm() const
{
switch (dim)
{
case 1:
return *bilinear_form_1D;
break;
case 2:
return *bilinear_form_2D;
break;
case 3:
return *bilinear_form_3D;
break;
default:
std::cout << "Error in xFormBilinearMatLibStandardMaterialTangentFactory : dimension must be 1, 2 or 3" << std::endl;
throw 123;
}
}
template <typename OperatorLeft, typename OperatorRight>
void xFormBilinearMatLibStandardMaterialTangentFactory<OperatorLeft, OperatorRight>::forLastStep(bool b)
{
switch (dim)
{
case 1:
eval_tangent_1D->forLastStep(b);
break;
case 2:
eval_tangent_2D->forLastStep(b);
break;
case 3:
eval_tangent_3D->forLastStep(b);
break;
default:
std::cout << "Error in xFormBilinearMatLibStandardMaterialTangentFactory : dimension must be 1, 2 or 3" << std::endl;
throw 123;
}
}
template <typename OperatorLeft, typename OperatorRight>
void xFormBilinearMatLibStandardMaterialTangentFactory<OperatorLeft, OperatorRight>::setTimeStep(double time_step)
{
switch (dim)
{