Implementation of mix-element for Large strains.
#define SINGULARITY
using namespace boost::multi_index;
using namespace boost::multiprecision;
using namespace boost::numeric;
#include <cmath>
#ifdef ENABLE_PYTHON_BINDING
#include <boost/python.hpp>
#include <boost/python/def.hpp>
#include <boost/python/numpy.hpp>
namespace bp = boost::python;
namespace np = boost::python::numpy;
#endif
static char help[] =
"...\n\n";
int main(
int argc,
char *argv[]) {
const char param_file[] = "param_file.petsc";
auto core_log = logging::core::get();
core_log->add_sink(LogManager::createSink(LogManager::getStrmWorld(), "EP"));
LogManager::setLog("EP");
core_log->add_sink(
LogManager::createSink(LogManager::getStrmSelf(), "EPSELF"));
LogManager::setLog("EPSELF");
#ifdef ENABLE_PYTHON_BINDING
Py_Initialize();
np::initialize();
MOFEM_LOG(
"EP", Sev::inform) <<
"Python initialised";
#else
MOFEM_LOG(
"EP", Sev::inform) <<
"Python NOT initialised";
#endif
core_log->add_sink(
LogManager::createSink(LogManager::getStrmSync(), "EPSYNC"));
LogManager::setLog("EPSYNC");
try {
PetscBool flg = PETSC_FALSE;
char mesh_file_name[255] = "";
CHKERR PetscOptionsGetString(PETSC_NULLPTR,
"",
"-my_file", mesh_file_name,
255, &flg);
if (!flg) {
CHKERR PetscOptionsGetString(PETSC_NULLPTR,
"",
"-file_name",
mesh_file_name, 255, &flg);
}
if (!flg) {
"Missing required mesh option: use -file_name or -my_file");
}
double time = 0;
CHKERR PetscOptionsGetScalar(PETSC_NULLPTR,
"",
"-time", &time, PETSC_NULLPTR);
MOFEM_LOG(
"EP", Sev::inform) <<
"Mesh file: " << mesh_file_name;
MOFEM_LOG(
"EP", Sev::inform) <<
"Time: " << time;
DMType dm_name = "DMMOFEM";
CHKERR DMRegister_MoFEM(dm_name);
DMType dm_name_mg = "DMMOFEM_MG";
CHKERR DMRegister_MGViaApproxOrders(dm_name_mg);
moab::Core moab_core;
moab::Interface &moab = moab_core;
ParallelComm *pcomm = ParallelComm::get_pcomm(&moab,
MYPCOMM_INDEX);
if (pcomm == NULL)
pcomm = new ParallelComm(&moab, PETSC_COMM_WORLD);
PetscBool fully_distributed = PETSC_FALSE;
CHKERR PetscOptionsGetBool(PETSC_NULLPTR,
"",
"-fully_distributed",
&fully_distributed, PETSC_NULLPTR);
if (fully_distributed) {
const char *option;
if (pcomm->proc_config().proc_size() == 1)
option = "";
else
option = "PARALLEL=READ_PART;"
"PARALLEL_RESOLVE_SHARED_ENTS;"
"PARTITION=PARALLEL_PARTITION";
CHKERR moab.load_file(mesh_file_name, 0, option);
} else {
CHKERR CommInterface::loadFileRootProcAllRestDistributed(
}
MOFEM_LOG(
"EP", Sev::inform) <<
"Initialise MoFEM database";
MOFEM_LOG(
"EP", Sev::inform) <<
"Initialise MoFEM database <- done";
CHKERR DMRegister_MoFEM(
"DMMOFEM");
0, 3, bit_level0);
auto meshset_ptr = get_temp_meshset_ptr(moab);
*meshset_ptr, CommInterface::getPartEntities(moab, pcomm->rank()));
auto get_adj = [&](
Range ents,
int dim) {
CHKERR moab.get_adjacencies(ents, dim,
false, adj,
moab::Interface::UNION);
return adj;
};
*meshset_ptr,
get_adj(CommInterface::getPartEntities(moab, pcomm->rank())
2));
*meshset_ptr,
get_adj(CommInterface::getPartEntities(moab, pcomm->rank())
1));
*meshset_ptr,
get_adj(CommInterface::getPartEntities(moab, pcomm->rank())
0));
"stvenant_kirchhoff", "mooney_rivlin", "hencky", "neo_hookean", "meta"};
CHKERR PetscOptionsGetEList(PETSC_NULLPTR, NULL,
"-material",
list_materials,
&choice_material, PETSC_NULLPTR);
auto material_model_names_dictionary = std::map<std::string, std::string>{
{"grad", "stretchH1AtPts"}, {"P", "PAtPts"}, {"P_dF", "PAtPts_du"}};
true;
switch (choice_material) {
MOFEM_LOG(
"EP", Sev::inform) <<
"St. Venant-Kirchhoff material model";
MOFEM_LOG(
"EP", Sev::inform) <<
"Meta Material model";
ep.
dataAtPts = boost::make_shared<DataAtIntegrationPts>();
material_model_names_dictionary),
CHKERR physical_equations_ptr->getOptions(&m_field);
CHKERR physical_equations_ptr->recordTape();
};
MOFEM_LOG(
"EP", Sev::inform) <<
"Mooney-Rivlin material model";
ep.
dataAtPts = boost::make_shared<DataAtIntegrationPts>();
material_model_names_dictionary),
CHKERR physical_equations_ptr->getOptions(&m_field);
CHKERR physical_equations_ptr->recordTape();
}; break;
MOFEM_LOG(
"EP", Sev::inform) <<
"Hencky material model";
break;
MOFEM_LOG(
"EP", Sev::inform) <<
"Neo-Hookean material model";
break;
MOFEM_LOG(
"EP", Sev::inform) <<
"Meta Material model";
ep.
dataAtPts = boost::make_shared<DataAtIntegrationPts>();
auto physical_equations_ptr =
material_model_names_dictionary),
CHKERR physical_equations_ptr->getOptions(&m_field);
CHKERR physical_equations_ptr->recordTape();
}; break;
default:
break;
}
auto x_elastic = createDMVector(ep.
dmElastic);
auto f_elastic = vectorDuplicate(x_elastic);
CHKERR VecSetOption(f_elastic, VEC_IGNORE_NEGATIVE_INDICES, PETSC_TRUE);
PetscInt start_step = 0;
PetscViewer viewer;
FILE_MODE_READ, &viewer);
CHKERR VecLoad(x_elastic, viewer);
CHKERR PetscViewerDestroy(&viewer);
CHKERR VecGhostUpdateBegin(x_elastic, INSERT_VALUES, SCATTER_FORWARD);
CHKERR VecGhostUpdateEnd(x_elastic, INSERT_VALUES, SCATTER_FORWARD);
std::regex restart_pattern(R"(restart_([1-9]\d*)\.dat)");
std::smatch match;
if (std::regex_search(restart_file_str, match, restart_pattern)) {
start_step = std::stoi(match[1]);
} else {
"Restart file name must be in the format restart_##.dat");
}
}
auto ts_elastic = createTS(PETSC_COMM_WORLD);
CHKERR TSSetType(ts_elastic, TSBEULER);
TSAdapt adapt;
CHKERR TSGetAdapt(ts_elastic, &adapt);
CHKERR TSAdaptSetType(adapt, TSADAPTNONE);
MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: TS";
CHKERR TSSetTime(ts_elastic, time);
CHKERR TSSetStepNumber(ts_elastic, start_step);
break;
MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: Dynamic Relaxation";
SCATTER_REVERSE);
break;
MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: Cohesive";
SCATTER_REVERSE);
time);
break;
MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: Load Factor";
SCATTER_REVERSE);
break;
MOFEM_LOG(
"EP", Sev::inform) <<
"Solver type: Shape Optimization";
SCATTER_REVERSE);
time);
break;
<< "Solver type: Test Topological Derivative";
SCATTER_REVERSE);
start_step, time);
break;
default:
"Unknown solver type");
break;
}
}
#ifdef ENABLE_PYTHON_BINDING
if (Py_FinalizeEx() < 0) {
exit(120);
}
#endif
}
Eshelbian plasticity interface.
#define CATCH_ERRORS
Catch errors.
#define MYPCOMM_INDEX
default communicator number PCOMM
@ MOFEM_DATA_INCONSISTENCY
#define CHKERR
Inline error check.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
boost::shared_ptr< PhysicalEquations > createMatOpsPhysicalEquationsPtr(boost::shared_ptr< MatOpsData > mat_ops_data_ptr, int tag)
boost::shared_ptr< MatOpsData > createMatOpsDataPtr()
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
implementation of Data Operators for Forces and Sources
MoFEMErrorCode setElasticElementOps(const int tag)
MoFEMErrorCode createCrackSurfaceMeshset()
MoFEMErrorCode addBoundaryFiniteElement(const EntityHandle meshset=0)
MoFEMErrorCode getSpatialRotationBc()
MoFEMErrorCode addMaterial_Hencky(double E, double nu)
static enum SolverType solverType
MoFEMErrorCode solveSchapeOptimisation(TS ts, Vec x, int start_step, double start_time)
Solve shape optimisation problem.
MoFEMErrorCode setBlockTagsOnSkin()
MoFEMErrorCode solveElastic(TS ts, Vec x)
@ TestTopologicalDerivative
static enum MaterialModel materialModel
MoFEMErrorCode setElasticElementToTs(DM dm)
MoFEMErrorCode projectGeometry(const EntityHandle meshset=0, double time=0)
MoFEMErrorCode projectMaterialTags(const EntityHandle meshset=0)
MoFEMErrorCode solveDynamicRelaxation(TS ts, Vec x, int start_step, double start_time)
Solve problem using dynamic relaxation method.
MoFEMErrorCode solveTestTopologicalDerivative(TS ts, Vec x, int start_step, double start_time)
MoFEMErrorCode addVolumeFiniteElement(const EntityHandle meshset=0, const bool add_bubble=true)
MoFEMErrorCode addMaterial_Core(boost::weak_ptr< MatOps::PhysicalEquations > mat_physical_equations_ptr)
MoFEMErrorCode getSpatialTractionFreeBc(const EntityHandle meshset=0)
MoFEMErrorCode getExternalStrain()
MoFEMErrorCode getSpatialTractionBc()
MoFEMErrorCode addDMs(const BitRefLevel bit=BitRefLevel().set(0), const EntityHandle meshset=0)
MoFEMErrorCode solveCohesiveCrackGrowth(TS ts, Vec x, int start_step, double start_time)
Solve cohesive crack growth problem.
MoFEMErrorCode getSpatialDispBc()
[Getting norms]
MoFEMErrorCode solveLoadFactor(TS ts, Vec x, int start_step, double start_time)
Solve load factor crack growth problem.
MoFEMErrorCode createExchangeVectors(Sev sev)
boost::shared_ptr< DataAtIntegrationPts > dataAtPts
MoFEMErrorCode addMaterial_HMHNeohookean(const int tape, const double c10, const double K)
SmartPetscObj< DM > dmElastic
Elastic problem.
MoFEMErrorCode addFields(const EntityHandle meshset=0, const bool add_bubble=true)
static bool useDeformationGradient
virtual MPI_Comm & get_comm() const =0
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Deprecated interface functions.
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.