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 {
CHKERR JsonConfigManager::setMeshFileFromJson();
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 JsonConfigManager::addCanonicalAttributeNames(
{"kn", "kt"});
CHKERR DMRegister_MoFEM(
"DMMOFEM");
0, 3, bit_level0);
CHKERR PhysicalEquations::create(ep);
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));
auto x_elastic = createDMVector(ep.
dmElastic);
PetscInt start_step = 0;
TestIncrementalOptimizationTransaction ||
EshelbianCore::SolverType::
TestIncrementalOptimizationObjectiveDerivative ||
"Incremental optimization does not support -restart");
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);
SCATTER_REVERSE);
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: Incremental Optimization";
SCATTER_REVERSE);
start_step, 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;
<< "Solver type: Test Equilibrated Mechanical Value";
SCATTER_REVERSE);
start_step, time);
break;
<< "Solver type: Test Incremental Optimization Layout";
start_step, time);
break;
<< "Solver type: Test Incremental Optimization Transaction";
SCATTER_REVERSE);
ts_elastic, x_elastic, start_step, time);
break;
<< "Solver type: Test Incremental Optimization Objective Derivative";
SCATTER_REVERSE);
ts_elastic, x_elastic, start_step, time);
break;
<< "Solver type: Test Incremental Optimization Constraint Derivative";
SCATTER_REVERSE);
ts_elastic, x_elastic, start_step, time);
break;
default:
"Unknown solver type");
break;
}
}
#ifdef ENABLE_PYTHON_BINDING
if (Py_FinalizeEx() < 0) {
exit(120);
}
#endif
}
Eshelbian plasticity interface.
Native restart vector layout validation.
#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.
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()
static enum SolverType solverType
MoFEMErrorCode solveSchapeOptimisation(TS ts, Vec x, int start_step, double start_time)
Solve shape optimisation problem.
MoFEMErrorCode setBlockTagsOnSkin()
MoFEMErrorCode solveTestIncrementalOptimizationLayout(TS ts, Vec x, int start_step, double start_time)
MoFEMErrorCode solveElastic(TS ts, Vec x)
@ TestIncrementalOptimizationConstraintDerivative
@ TestIncrementalOptimizationLayout
@ TestIncrementalOptimizationTransaction
@ TestIncrementalOptimizationObjectiveDerivative
@ IncrementalOptimization
@ TestTopologicalDerivative
@ TestEquilibratedMechanicalValue
MoFEMErrorCode solveTestIncrementalOptimizationTransaction(TS ts, Vec x, int start_step, double start_time)
MoFEMErrorCode setElasticElementToTs(DM dm)
MoFEMErrorCode solveTestEquilibratedMechanicalValue(TS ts, Vec x, int start_step, double start_time)
MoFEMErrorCode solveIncrementalOptimizationTAO(TS ts, Vec x, int start_step, double start_time)
Solve the incremental constitutive optimization with TAO.
MoFEMErrorCode solveTestIncrementalOptimizationObjectiveDerivative(TS ts, Vec x, int start_step, double start_time)
MoFEMErrorCode resolveDissipationEntities(const EntityHandle meshset=0)
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 solveTestIncrementalOptimizationConstraintDerivative(TS ts, Vec x, int start_step, double start_time)
MoFEMErrorCode getSpatialTractionFreeBc(const EntityHandle meshset=0)
MoFEMErrorCode getExternalStrain()
MoFEMErrorCode getSpatialTractionBc()
MoFEMErrorCode addDMs(const BitRefLevel bit=BitRefLevel().set(0), const EntityHandle meshset=0)
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)
SmartPetscObj< Vec > solTSStep
SmartPetscObj< DM > dmElastic
Elastic problem.
MoFEMErrorCode addFields(const EntityHandle meshset=0, const bool add_bubble=true)
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.