35 GAUSS>::OpGradSymTensorGrad<1, SPACE_DIM, SPACE_DIM, 0>;
93 auto set_matrial_stiffens = [&]() {
100 auto t_D = getFTensor4DdgFromMat<SPACE_DIM, SPACE_DIM, 0>(*
matDPtr);
113 matDPtr = boost::make_shared<MatrixDouble>();
118 CHKERR set_matrial_stiffens();
172 for (
int n = 1;
n != 6; ++
n)
183 auto hi = dofs->upper_bound(lo_uid);
184 std::array<double, 3> coords;
186 for (
auto lo = dofs->lower_bound(lo_uid); lo != hi; ++lo) {
190 auto ent = (*lo)->getEnt();
193 if ((*lo)->getDofCoeffIdx() == 0) {
197 -coords[1], INSERT_VALUES);
200 -coords[2], INSERT_VALUES);
202 }
else if ((*lo)->getDofCoeffIdx() == 1) {
206 coords[0], INSERT_VALUES);
209 -coords[2], INSERT_VALUES);
211 }
else if ((*lo)->getDofCoeffIdx() == 2) {
216 coords[0], INSERT_VALUES);
218 coords[1], INSERT_VALUES);
243 auto dm =
simple->getDM();
247 auto calculate_stiffness_matrix = [&]() {
249 pipeline_mng->getDomainLhsFE().reset();
252 pipeline_mng->getOpDomainLhsPipeline(), {H1});
254 pipeline_mng->getOpDomainLhsPipeline().push_back(
262 pipeline_mng->getDomainLhsFE()->B =
K;
264 CHKERR pipeline_mng->loopFiniteElements();
265 CHKERR MatAssemblyBegin(
K, MAT_FINAL_ASSEMBLY);
266 CHKERR MatAssemblyEnd(
K, MAT_FINAL_ASSEMBLY);
270 auto calculate_mass_matrix = [&]() {
272 pipeline_mng->getDomainLhsFE().reset();
275 pipeline_mng->getOpDomainLhsPipeline(), {H1});
278 pipeline_mng->getOpDomainLhsPipeline().push_back(
286 pipeline_mng->getDomainLhsFE()->B =
M;
287 CHKERR pipeline_mng->loopFiniteElements();
288 CHKERR MatAssemblyBegin(
M, MAT_FINAL_ASSEMBLY);
289 CHKERR MatAssemblyEnd(
M, MAT_FINAL_ASSEMBLY);
293 CHKERR calculate_stiffness_matrix();
294 CHKERR calculate_mass_matrix();
304 auto create_eps = [](MPI_Comm comm) {
310 auto deflate_vectors = [&]() {
313 std::array<Vec, 6> deflate_vectors;
314 for (
int n = 0;
n != 6; ++
n) {
317 CHKERR EPSSetDeflationSpace(
ePS, 6, &deflate_vectors[0]);
321 auto print_info = [&]() {
326 PetscInt nev, maxit, its;
330 " Number of iterations of the method: %d", its);
334 CHKERR EPSGetDimensions(
ePS, &nev, NULL, NULL);
335 MOFEM_LOG_C(
"EXAMPLE", Sev::inform,
" Number of requested eigenvalues: %d",
339 " Stopping condition: tol=%.4g, maxit=%d", (
double)
tol, maxit);
341 PetscScalar eigr, eigi;
342 for (
int nn = 0; nn < nev; nn++) {
343 CHKERR EPSGetEigenpair(
ePS, nn, &eigr, &eigi, PETSC_NULLPTR,
346 " ncov = %d eigr = %.4g eigi = %.4g (inv eigr = %.4g)", nn,
347 eigr, eigi, 1. / eigr);
353 auto setup_eps = [&]() {
356 CHKERR EPSSetWhichEigenpairs(
ePS, EPS_SMALLEST_MAGNITUDE);
387 auto post_proc_fe = boost::make_shared<PostProcEle>(
mField);
390 post_proc_fe->getOpPtrVector(), {H1});
392 auto u_ptr = boost::make_shared<MatrixDouble>();
393 auto grad_ptr = boost::make_shared<MatrixDouble>();
394 auto strain_ptr = boost::make_shared<MatrixDouble>();
395 auto stress_ptr = boost::make_shared<MatrixDouble>();
397 post_proc_fe->getOpPtrVector().push_back(
399 post_proc_fe->getOpPtrVector().push_back(
401 post_proc_fe->getOpPtrVector().push_back(
403 post_proc_fe->getOpPtrVector().push_back(
405 strain_ptr, stress_ptr,
matDPtr));
409 post_proc_fe->getOpPtrVector().push_back(
412 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(),
426 pipeline_mng->getDomainPostProcFE() = post_proc_fe;
428 auto dm =
simple->getDM();
432 CHKERR EPSGetDimensions(ePS, &nev, NULL, NULL);
433 PetscScalar eigr, eigi, nrm2r;
434 for (
int nn = 0; nn < nev; nn++) {
435 CHKERR EPSGetEigenpair(ePS, nn, &eigr, &eigi,
D, PETSC_NULLPTR);
436 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
437 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
438 CHKERR VecNorm(
D, NORM_2, &nrm2r);
440 " ncov = %d omega2 = %.8g omega = %.8g frequency = %.8g", nn,
441 eigr, std::sqrt(std::abs(eigr)),
442 std::sqrt(std::abs(eigr)) / (2 * M_PI));
444 CHKERR pipeline_mng->loopFiniteElementsPostProc();
445 post_proc_fe->writeFile(
"out_eig_" + boost::lexical_cast<std::string>(nn) +
456 PetscBool test_flg = PETSC_FALSE;
460 PetscScalar eigr, eigi;
461 CHKERR EPSGetEigenpair(
ePS, 0, &eigr, &eigi, PETSC_NULLPTR, PETSC_NULLPTR);
462 constexpr double regression_value = 12579658;
463 if (fabs(eigr - regression_value) > 1)
465 "Regression test faileed; wrong eigen value.");
474int main(
int argc,
char *argv[]) {
477 const char param_file[] =
"param_file.petsc";
478 SlepcInitialize(&argc, &argv, param_file,
help);
482 auto core_log = logging::core::get();
491 DMType dm_name =
"DMMOFEM";
496 moab::Core mb_instance;
497 moab::Interface &moab = mb_instance;
#define MOFEM_LOG_C(channel, severity, format,...)
void simple(double P1[], double P2[], double P3[], double c[], const int N)
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpMass< 1, FIELD_DIM > OpDomainMass
Kronecker Delta class symmetric.
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_BERNSTEIN_BEZIER_BASE
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_ATOM_TEST_INVALID
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
static char help[]
[Check]
double rho
[Operators_definition]
int order
[Physical_parameters]
PetscErrorCode DMCreateMatrix_MoFEM(DM dm, Mat *M)
PetscErrorCode DMoFEMMeshToLocalVector(DM dm, Vec l, InsertMode mode, ScatterMode scatter_mode, RowColData rc=RowColData::COL)
set local (or ghosted) vector values on mesh for partition only
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
auto createDMVector(DM dm, RowColData rc=RowColData::COL)
Get smart vector from DM.
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
FTensor::Index< 'i', SPACE_DIM > i
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::BiLinearForm< GAUSS >::OpGradGrad< 1, 1, SPACE_DIM > OpDomainGradGrad
const double n
refractive index of diffusive medium
FTensor::Index< 'l', 3 > l
FTensor::Index< 'j', 3 > j
FTensor::Index< 'k', 3 > k
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
implementation of Data Operators for Forces and Sources
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
PetscErrorCode PetscOptionsGetScalar(PetscOptions *, const char pre[], const char name[], PetscScalar *dval, PetscBool *set)
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
SmartPetscObj< Mat > matDuplicate(Mat mat, MatDuplicateOption op)
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
static constexpr int approx_order
MoFEMErrorCode boundaryCondition()
MoFEMErrorCode assembleSystem()
MoFEMErrorCode readMesh()
MoFEMErrorCode checkResults()
MoFEMErrorCode solveSystem()
MoFEMErrorCode createCommonData()
boost::shared_ptr< MatrixDouble > matDPtr
std::array< SmartPetscObj< Vec >, 6 > rigidBodyMotion
Example(MoFEM::Interface &m_field)
MoFEMErrorCode runProblem()
MoFEM::Interface & mField
Reference to MoFEM interface.
MoFEMErrorCode setupProblem()
MoFEMErrorCode outputResults()
Add operators pushing bases from local to physical configuration.
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
virtual int get_comm_rank() 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.
static UId getUniqueIdCalculate(const DofIdx dof, UId ent_uid)
static boost::shared_ptr< SinkType > createSink(boost::shared_ptr< std::ostream > stream_ptr, std::string comm_filter)
Create a sink object.
static boost::shared_ptr< std::ostream > getStrmWorld()
Get the strm world object.
Get field gradients at integration pts for scalar field rank 0, i.e. vector field.
Specialization for MatrixDouble vector field values calculation.
Post post-proc data at points from hash maps.
std::map< std::string, ScalarDataPtr > DataMapVec
std::map< std::string, boost::shared_ptr< MatrixDouble > > DataMapMat
Operator for symmetrizing tensor fields.
PipelineManager interface.
auto & getNumeredRowDofsPtr() const
get access to numeredRowDofsPtr storing DOFs on rows
Simple interface for fast problem set-up.
MoFEMErrorCode addDomainField(const std::string name, const FieldSpace space, const FieldApproximationBase base, const FieldCoefficientsNumber nb_of_coefficients, const TagType tag_type=MB_TAG_SPARSE, const enum MoFEMTypes bh=MF_ZERO, int verb=-1)
Add field on domain.
MoFEMErrorCode getOptions()
get options
intrusive_ptr for managing petsc objects
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Volume finite element base.
double young_modulus
Young modulus.
#define EXECUTABLE_DIMENSION
double poisson_ratio
Poisson ratio.