16static char help[] =
"...\n\n";
54 :
public boost::enable_shared_from_this<Example::CommonData> {
59 return boost::shared_ptr<VectorDouble>(shared_from_this(),
88 OpZero(boost::shared_ptr<CommonData> &common_data_ptr)
99 OpFirst(boost::shared_ptr<CommonData> &common_data_ptr)
111 OpSecond(boost::shared_ptr<CommonData> &common_data_ptr)
144 constexpr int order = 1;
174 auto set_density = [&](
VectorAdaptor &&field_data,
double *xcoord,
175 double *ycoord,
double *zcoord) {
242 "First moment of inertia [ %6.4e, %6.4e, %6.4e ]",
246 "Second moment of inertia [ %6.4e, %6.4e, %6.4e; %6.4e %6.4e; "
263 PetscBool test = PETSC_FALSE;
266 constexpr double eps = 1e-8;
267 constexpr double expected_volume = 1.;
268 constexpr double expected_first_moment = 0.;
269 constexpr double expected_second_moment = 1. / 12.;
272 "Wrong area %6.4e != %6.4e", expected_volume,
276 if (std::abs(array[
i] - expected_first_moment) >
eps)
278 "Wrong first moment %6.4e != %6.4e", expected_first_moment,
283 if (std::abs(array[
i] - expected_second_moment) >
eps)
285 "Wrong second moment %6.4e != %6.4e", expected_second_moment,
296int main(
int argc,
char *argv[]) {
306 DMType dm_name =
"DMMOFEM";
311 moab::Core mb_instance;
312 moab::Interface &moab = mb_instance;
333 if (type == MBVERTEX) {
335 const int nb_integration_pts =
343 double element_local_value = 0;
344 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
345 element_local_value += t_w * t_rho * volume;
363 const int nb_integration_pts = getGaussPts().size2();
364 auto t_w = getFTensor0IntegrationWeight();
368 getFTensor1CoordsAtGaussPts();
369 const double volume = getMeasure();
378 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
380 t_s(
i) += t_w * t_rho * volume * t_x(
i);
388 constexpr std::array<int, 3> indices = {
403 const int nb_integration_pts = getGaussPts().size2();
404 auto t_w = getFTensor0IntegrationWeight();
406 auto t_x = getFTensor1CoordsAtGaussPts();
407 const double volume = getMeasure();
410 std::array<double, 6> element_local_value;
411 std::fill(element_local_value.begin(), element_local_value.end(), 0.0);
415 &element_local_value[0], &element_local_value[1], &element_local_value[2],
416 &element_local_value[3], &element_local_value[4],
417 &element_local_value[5]);
423 for (
int gg = 0; gg != nb_integration_pts; ++gg) {
426 t_I(
i,
j) += (t_w * t_rho * volume) * (t_x(
i) ^ t_x(
j));
434 constexpr std::array<int, 6> indices = {
440 &element_local_value[0], ADD_VALUES);
#define MOFEM_LOG_C(channel, severity, format,...)
void simple(double P1[], double P2[], double P3[], double c[], const int N)
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#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.
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
MoFEMErrorCode loopFiniteElements(SmartPetscObj< DM > dm=nullptr)
Iterate finite elements.
boost::ptr_deque< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
VectorShallowArrayAdaptor< double > VectorAdaptor
implementation of Data Operators for Forces and Sources
auto createSmartVectorMPI(MPI_Comm comm, PetscInt n, PetscInt N)
Create MPI Vector.
PetscErrorCode PetscOptionsGetBool(PetscOptions *, const char pre[], const char name[], PetscBool *bval, PetscBool *set)
static auto getFTensor0FromVec(ublas::vector< T, A > &data)
Get tensor rank 0 (scalar) form data vector.
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
FTensor::Index< 'j', 3 > j
FTensor::Index< 'i', 3 > i
boost::shared_ptr< VectorDouble > getRhoAtIntegrationPtsPtr()
VecElements
Vector to indicate indices for storing zero, first and second moments of inertia.
SmartPetscObj< Vec > petscVec
Smart pointer which stores PETSc distributed vector.
VectorDouble rhoAtIntegrationPts
Storing density at integration points.
boost::shared_ptr< CommonData > commonDataPtr
MoFEMErrorCode doWork(int side, EntityType type, EntData &data)
[ZeroOp]
OpFirst(boost::shared_ptr< CommonData > &common_data_ptr)
MoFEMErrorCode doWork(int side, EntityType type, EntData &data)
[FirstOp]
boost::shared_ptr< CommonData > commonDataPtr
OpSecond(boost::shared_ptr< CommonData > &common_data_ptr)
MoFEMErrorCode doWork(int side, EntityType type, EntData &data)
[main]
boost::shared_ptr< CommonData > commonDataPtr
OpZero(boost::shared_ptr< CommonData > &common_data_ptr)
MoFEMErrorCode pushOperators()
[Set density distribution]
boost::shared_ptr< ContactOps::CommonData > commonDataPtr
boost::shared_ptr< CommonData > commonDataPtr
MoFEMErrorCode setUp()
[Run all]
MoFEMErrorCode checkResults()
MoFEMErrorCode createCommonData()
Example(MoFEM::Interface &m_field)
MoFEMErrorCode runProblem()
MoFEM::Interface & mField
MoFEMErrorCode postProcess()
MoFEMErrorCode setFieldValues()
[Create common data]
MoFEMErrorCode integrateElements()
[Push operators to pipeline]
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.
std::array< bool, MBMAXTYPE > doEntities
If true operator is executed for entity.
Deprecated interface functions.
Data on single entity (This is passed as argument to DataOperator::doWork)
MoFEMErrorCode setVertexDofs(VertexCoordsFunction lambda, const std::string field_name, Range *verts=nullptr)
Set DOFs on vertices using user function.
auto getFTensor0IntegrationWeight()
Get integration weights.
double getMeasure() const
get measure of element
@ OPROW
operator doWork function is executed on FE rows
MatrixDouble & getGaussPts()
matrix of integration (Gauss) points for Volume Element
Get value at integration points for scalar field.
PipelineManager interface.
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
Simple interface for fast problem set-up.
intrusive_ptr for managing petsc objects
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
Volume finite element base.