v0.10.0
ep.cpp

Implementation of mix-element for Large strains

Todo:
Implementation of plasticity
/**
* \file ep.cpp
* \example ep.cpp
*
* \brief Implementation of mix-element for Large strains
*
* \todo Implementation of plasticity
*
*/
/* This file is part of MoFEM.
* MoFEM is free software: you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* MoFEM is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with MoFEM. If not, see <http://www.gnu.org/licenses/>. */
#include <BasicFiniteElements.hpp>
#include <TSEPAdapt.hpp>
#include <cholesky.hpp>
using namespace MoFEM;
using namespace EshelbianPlasticity;
static char help[] = "...\n\n";
int main(int argc, char *argv[]) {
// initialize petsc
const char param_file[] = "param_file.petsc";
// Add logging channel for example
auto core_log = logging::core::get();
core_log->add_sink(LogManager::createSink(LogManager::getStrmWorld(), "EP"));
MOFEM_LOG_TAG("EP", "ep");
core_log->add_sink(
LogManager::setLog("EPSYNC");
MOFEM_LOG_TAG("EPSYNC", "ep");
try {
// Get mesh file
PetscBool flg = PETSC_TRUE;
char mesh_file_name[255];
CHKERR PetscOptionsGetString(PETSC_NULL, "", "-my_file", mesh_file_name,
255, &flg);
char restart_file[255];
PetscBool restart_flg = PETSC_TRUE;
CHKERR PetscOptionsGetString(PETSC_NULL, "", "-restart", restart_file, 255,
&restart_flg);
double time = 0;
CHKERR PetscOptionsGetScalar(PETSC_NULL, "", "-time", &time, PETSC_NULL);
// Register DM Manager
DMType dm_name = "DMMOFEM";
// Create MoAB database
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);
// Read mesh to MOAB
const char *option;
option = "PARALLEL=READ_PART;"
"PARALLEL_RESOLVE_SHARED_ENTS;"
"PARTITION=PARALLEL_PARTITION";
CHKERR moab.load_file(mesh_file_name, 0, option);
// Create MoFEM database and link it to MoAB
MoFEM::Core mofem_core(moab);
MoFEM::Interface &m_field = mofem_core;
// Register mofem DM
BitRefLevel bit_level0 = BitRefLevel().set(0);
CHKERR m_field.getInterface<BitRefManager>()->setBitRefLevelByDim(
0, 3, bit_level0);
// Data stuctures
EshelbianCore ep(m_field);
CHKERR ep.getSpatialDispBc();
CHKERR ep.getSpatialRotationBc();
CHKERR ep.getSpatialTractionBc();
CHKERR ep.getSpatialTractionFreeBc();
CHKERR ep.addFields();
CHKERR ep.addVolumeFiniteElement();
CHKERR ep.addBoundaryFiniteElement();
CHKERR ep.addDMs();
// CHKERR ep.addMaterial_HMHHStVenantKirchhoff(1, LAMBDA(1, 0), MU(1, 0),
// 0);
CHKERR ep.addMaterial_HMHMooneyRivlin(1, MU(1, 0) / 2., 0, LAMBDA(1, 0), 0);
CHKERR ep.setElasticElementOps(1);
CHKERR ep.setElasticElementToTs(ep.dmElastic);
SmartPetscObj<Vec> x_elastic, f_elastic;
CHKERR DMCreateGlobalVector_MoFEM(ep.dmElastic, x_elastic);
f_elastic = smartVectorDuplicate(x_elastic);
CHKERR VecSetOption(f_elastic, VEC_IGNORE_NEGATIVE_INDICES, PETSC_TRUE);
SmartPetscObj<Mat> m_elastic;
CHKERR DMCreateMatrix_MoFEM(ep.dmElastic, m_elastic);
if (restart_flg) {
PetscViewer viewer;
CHKERR PetscViewerBinaryOpen(PETSC_COMM_WORLD, restart_file,
FILE_MODE_READ, &viewer);
CHKERR VecLoad(x_elastic, viewer);
CHKERR PetscViewerDestroy(&viewer);
CHKERR DMoFEMMeshToLocalVector(ep.dmElastic, x_elastic, INSERT_VALUES,
SCATTER_REVERSE);
}
auto ts_elastic = createTS(PETSC_COMM_WORLD);
CHKERR TSSetType(ts_elastic, TSBEULER);
CHKERR TSAdaptRegister(TSADAPTEP, TSAdaptCreate_EP);
TSAdapt adapt;
CHKERR TSGetAdapt(ts_elastic, &adapt);
CHKERR TSAdaptSetType(adapt, TSADAPTEP);
CHKERR ep.setUpTSElastic(ts_elastic, m_elastic, f_elastic);
CHKERR TSSetTime(ts_elastic, time);
CHKERR ep.solveElastic(ts_elastic, x_elastic);
}
// finish work cleaning memory, getting statistics, etc.
}
std::string param_file
Eshelbian plasticity interface.
Step adaptation.
#define TSADAPTEP
Definition: TSEPAdapt.hpp:15
PetscErrorCode TSAdaptCreate_EP(TSAdapt adapt)
Definition: TSEPAdapt.hpp:81
cholesky decomposition
#define CATCH_ERRORS
Catch errors.
Definition: definitions.h:441
#define MYPCOMM_INDEX
default communicator number PCOMM
Definition: definitions.h:292
#define CHKERR
Inline error check.
Definition: definitions.h:604
int main(int argc, char *argv[])
Definition: ep.cpp:35
static char help[]
Definition: ep.cpp:33
#define MU(E, NU)
Definition: fem_tools.h:33
#define LAMBDA(E, NU)
Definition: fem_tools.h:32
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode)
set local (or ghosted) vector values on mesh for partition only
Definition: DMMMoFEM.cpp:445
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
Definition: DMMMoFEM.cpp:1053
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
Definition: DMMMoFEM.cpp:48
PetscErrorCode DMCreateGlobalVector_MoFEM(DM dm, Vec *g)
DMShellSetCreateGlobalVector.
Definition: DMMMoFEM.cpp:1026
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
Definition: LogManager.cpp:368
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
Definition: LogManager.hpp:343
char mesh_file_name[255]
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
Definition: Types.hpp:51
implementation of Data Operators for Forces and Sources
Definition: Common.hpp:21
auto createTS
PetscErrorCode PetscOptionsGetScalar(PetscOptions *, const char pre[], const char name[], PetscScalar *dval, PetscBool *set)
CoreTmp< 0 > Core
Definition: Core.hpp:1129
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
DeprecatedCoreInterface Interface
Definition: Interface.hpp:1943
SmartPetscObj< Vec > smartVectorDuplicate(SmartPetscObj< Vec > &vec)
Create duplicate vector of smart vector.
Core (interface) class.
Definition: Core.hpp:77
static MoFEMErrorCode Initialize(int *argc, char ***args, const char file[], const char help[])
Initializes the MoFEM database PETSc, MOAB and MPI.
Definition: Core.cpp:60
static MoFEMErrorCode Finalize()
Checks for options to be called at the conclusion of the program.
Definition: Core.cpp:100
Deprecated interface functions.
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
Definition: LogManager.cpp:283
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Definition: LogManager.cpp:327
static boost::shared_ptr< std::ostream > getStrmSync()
Get the strm sync object.
Definition: LogManager.cpp:331
MoFEMErrorCode getInterface(const MOFEMuuid &uuid, IFACE *&iface) const
Get interface by uuid and return reference to pointer of interface.