83 CHKERR PetscOptionsGetBool(PETSC_NULLPTR,
"",
"-ref_geom", &
refGeom,
91 "Adaptive order and geometry refinement cannot be used together");
94 simple->getAddSkeletonFE() =
true;
100 auto update_ghost_ents = [&]() {
104 std::regex((boost::format(
"%s(.*)") %
"MAT_ELASTIC").str()))
117 CHKERR update_ghost_ents();
127 Range domainEntities;
133 CHKERR PetscOptionsGetInt(PETSC_NULLPTR,
"",
"-order", &
oRder, PETSC_NULLPTR);
134 for (
auto ent : domainEntities) {
161 CHKERR KSPGetDM(solver, &dm);
162 auto D = createDMVector(dm);
163 auto F = vectorDuplicate(
D);
166 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
167 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
168 CHKERR DMoFEMMeshToLocalVector(dm,
D, INSERT_VALUES, SCATTER_REVERSE);
170 BOOST_LOG_SCOPED_THREAD_ATTR(
"Timeline", attrs::timer());
171 MOFEM_LOG(
"TIMER", Sev::inform) <<
"KSPSetUp";
173 MOFEM_LOG(
"TIMER", Sev::inform) <<
"KSPSetUp <= Done";
174 MOFEM_LOG(
"TIMER", Sev::inform) <<
"KSPSolve";
176 MOFEM_LOG(
"TIMER", Sev::inform) <<
"KSPSolve <= Done";
178 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
179 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
180 CHKERR DMoFEMMeshToLocalVector(dm,
D, INSERT_VALUES, SCATTER_REVERSE);
186inline auto sqr = [](
double v) {
return v *
v; };
193 double r = std::sqrt(x * x + y * y);
206 std::vector<double> v_u;
208 double u_r = (1. + nu) /
E * ((1. - 2. * nu) *
A * r +
B / r);
211 v_u = {u_r / r * x, u_r / r * y};
213 v_u = {u_r / r * x, u_r / r * y, 0.0};
226 std::ostringstream strm;
227 strm <<
"out_elastic";
229 strm <<
"_" << ref_iter;
236 {
"GEOMETRY_ERROR",
"SOLUTION_ERROR",
"ORDER"}, Sev::verbose);
248 auto evaluation_fe = boost::make_shared<DomainEle>(
mField);
251 auto &evaluation_pipeline = evaluation_fe->getOpPtrVector();
255 auto u_ptr = boost::make_shared<MatrixDouble>();
256 evaluation_pipeline.push_back(
257 new OpCalculateVectorFieldValues<SPACE_DIM>(
"U", u_ptr));
259 auto analytical_disp_ptr = boost::make_shared<MatrixDouble>();
261 evaluation_pipeline.push_back(
new OpGetTensor1fromFunc<SPACE_DIM, SPACE_DIM>(
267 evaluation_pipeline.push_back(
new OpCalcNormL2Tensor1<SPACE_DIM>(
268 u_ptr, normsVec, 0, analytical_disp_ptr));
270 CHKERR VecZeroEntries(normsVec);
273 CHKERR VecAssemblyBegin(normsVec);
274 CHKERR VecAssemblyEnd(normsVec);
278 CHKERR VecGetArrayRead(normsVec, &norms);
280 <<
"Displacement error L2 norm: " << std::scientific
281 << std::sqrt(norms[0]);
283 if (
atomTest == 3 && std::sqrt(norms[0]) > 2.195e-06) {
285 "atom test failed: displacement error L2 norm is too high: "
287 std::sqrt(norms[0]));
290 if (
atomTest == 4 && std::sqrt(norms[0]) > 1.995e-07) {
292 "atom test failed: displacement error L2 norm is too high: "
294 std::sqrt(norms[0]));
297 CHKERR VecRestoreArrayRead(normsVec, &norms);
Calculate error indicators.
static MoFEMErrorCode getTagHandle(MoFEM::Interface &m_field, const char *name, DataType type, Tag &tag_handle)
static MoFEMErrorCode copyTagOnSkin(MoFEM::Interface &m_field, const char *name, DataType type)
MoFEM::VectorFunc analyticalDisplacement
Implementation of elastic example class.
Higher Order Geometry refinement.
#define MOFEM_TAG_AND_LOG(channel, severity, tag)
Tag and log in channel.
void simple(double P1[], double P2[], double P3[], double c[], const int N)
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
ElementsAndOps< SPACE_DIM >::BoundaryEle BoundaryEle
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
@ MOFEM_DATA_INCONSISTENCY
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
FTensor::Index< 'i', SPACE_DIM > i
const double v
phase velocity of light in medium (cm/ns)
MoFEMErrorCode postProcessElasticResults(MoFEM::Interface &mField, SmartPetscObj< DM > dm, const std::string &domain_fe_name, const std::string &out_file_name, std::vector< std::pair< std::string, SmartPetscObj< Vec > > > extra_vectors={}, const std::vector< std::string > &tags_to_transfer={}, const Sev hooke_ops_sev=Sev::verbose)
boost::function< VectorDouble(const double, const double, const double)> VectorFunc
FTensor::Index< 'm', 3 > m
MoFEMErrorCode calculateGeometryError()
Calculate geometry error and save on a tag.
MoFEMErrorCode computeErrorNorms()
[Postprocess results]
ElasticAdaptiveExample(MoFEM::Interface &m_field)
std::array< double, 2 > meanError
MoFEMErrorCode kspSetUpAndSolve(SmartPetscObj< KSP > solver) override
[Set up problem]
MoFEMErrorCode refineOrder(int ref_level)
MoFEMErrorCode computeErrorIndicators()
MoFEMErrorCode refineGeometry()
MoFEMErrorCode runProblem()
[Run problem]
MoFEMErrorCode readMesh()
[Run problem]
MoFEMErrorCode setupAdaptivity()
[Read mesh]
virtual MoFEMErrorCode solveSystem()
[Solve]
virtual MoFEMErrorCode outputResults()
[Solve]
virtual MoFEMErrorCode assembleSystem()
[Boundary condition]
virtual MoFEMErrorCode setupProblem()
[Read mesh]
MoFEM::Interface & mField
virtual MoFEMErrorCode boundaryCondition()
[Set up problem]
virtual MoFEMErrorCode checkResults()
[Postprocess results]
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() const =0
Deprecated interface functions.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
ElementsAndOps< SPACE_DIM >::SideEle SideEle