16static char help[] =
"...\n\n";
111 boost::shared_ptr<VectorDouble> &approx_vals,
double &sum_temp,
140 constexpr int order = 3;
150 approxVals = boost::make_shared<VectorDouble>();
160 auto set_initial_temperature = [&](
VectorAdaptor &&field_data,
double *xcoord,
161 double *ycoord,
double *zcoord) {
181 auto det_ptr = boost::make_shared<VectorDouble>();
182 auto jac_ptr = boost::make_shared<MatrixDouble>();
183 auto inv_jac_ptr = boost::make_shared<MatrixDouble>();
237 CHKERR TSSetMaxTime(ts, ftime);
238 CHKERR TSSetFromOptions(ts);
239 CHKERR TSSetExactFinalTime(ts, TS_EXACTFINALTIME_MATCHSTEP);
249 PetscReal expected_time;
250 CHKERR TSGetTime(ts, &expected_time);
252 ts, expected_time, {1e-12, 1e-12},
"heat radiation");
254 CHKERR TSGetTime(ts, &ftime);
256 PetscInt steps, snesfails, rejects, nonlinits, linits;
257 CHKERR TSGetStepNumber(ts, &steps);
258 CHKERR TSGetSNESFailures(ts, &snesfails);
259 CHKERR TSGetStepRejections(ts, &rejects);
260 CHKERR TSGetSNESIterations(ts, &nonlinits);
261 CHKERR TSGetKSPIterations(ts, &linits);
263 "steps %d (%d rejected, %d SNES fails), ftime %g, nonlinits "
265 steps, rejects, snesfails, ftime, nonlinits, linits);
276 boost::make_shared<PostProcBrokenMeshInMoab<DomainEle>>(
mField);
278 auto t_ptr = boost::make_shared<VectorDouble>();
279 post_proc_fe->getOpPtrVector().push_back(
284 post_proc_fe->getOpPtrVector().push_back(
286 new OpPPMap(post_proc_fe->getPostProcMesh(),
287 post_proc_fe->getMapGaussPts(),
302 double sum_temperature;
305 new OpCalcSurfaceAverageTemperature(approxVals, sum_temperature,
307 auto calc_surfcae_area_op =
313 CHKERR post_proc_fe->writeFile(
"out_radiation.h5m");
315 MOFEM_LOG_C(
"EXAMPLE", Sev::inform,
"Surface area %3.4e [km]", surface_area);
317 "Average subsurface temperatute %3.4e [K]",
318 sum_temperature / surface_area);
328int main(
int argc,
char *argv[]) {
331 const char param_file[] =
"param_file.petsc";
335 auto core_log = logging::core::get();
344 DMType dm_name =
"DMMOFEM";
349 moab::Core mb_instance;
350 moab::Interface &moab = mb_instance;
379 const double vol = this->getMeasure();
381 auto t_w = getFTensor0IntegrationWeight();
387 auto t_coords = getFTensor1CoordsAtGaussPts();
393 const double r_cylinder = t_coords(0);
396 const double alpha = t_w * vol *
Beta * (2 * M_PI * r_cylinder);
398 for (
int rr = 0; rr !=
nbRows; ++rr) {
401 for (
int cc = 0; cc !=
nbCols; cc++) {
402 if (std::abs(t_coords(0)) > std::numeric_limits<double>::epsilon()) {
403 locMat(rr, cc) += alpha * t_row_base * t_col_base * 4 *
404 std::pow(
static_cast<double>(t_val), 3);
423 const double vol = getMeasure();
425 auto t_w = getFTensor0IntegrationWeight();
431 auto t_coords = getFTensor1CoordsAtGaussPts();
434 for (
int gg = 0; gg != nbIntegrationPts; gg++) {
437 const double r_cylinder = t_coords(0);
440 const double alpha = t_w * vol *
Beta * (2 * M_PI * r_cylinder);
442 for (
int rr = 0; rr != nbRows; ++rr) {
443 if (std::abs(t_coords(0)) > std::numeric_limits<double>::epsilon()) {
444 locF[rr] += alpha * t_row_base *
445 (std::pow(
static_cast<double>(t_val), 4) -
463 const double vol = getMeasure();
465 auto t_w = getFTensor0IntegrationWeight();
469 auto t_coords = getFTensor1CoordsAtGaussPts();
471 const double time = getFEMethod()->ts_t;
474 constexpr double flux_p = -0.03e6;
475 constexpr double flux_c = -0.23e6;
478 for (
int gg = 0; gg != nbIntegrationPts; gg++) {
481 const double r_cylinder = t_coords(0);
483 const double r = std::sqrt(t_coords(
i) * t_coords(
i));
484 const double s = std::abs(t_coords(1)) / r;
487 const double alpha = t_w * vol * (2 * M_PI * r_cylinder);
489 for (
int rr = 0; rr != nbRows; ++rr) {
490 locF[rr] += alpha * t_row_base * (s * flux_p + flux_c) * time;
506 if (
type == MBVERTEX) {
508 const double vol = getMeasure();
510 auto t_w = getFTensor0IntegrationWeight();
514 auto t_coords = getFTensor1CoordsAtGaussPts();
516 size_t nb_integration_pts = getGaussPts().size2();
519 for (
auto gg = 0; gg != nb_integration_pts; ++gg) {
522 const double r_cylinder = t_coords(0);
525 const double alpha = t_w * vol * (2 * M_PI * r_cylinder);
527 sumTemperature += alpha * t_val;
528 surfaceArea += alpha;
#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
#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 ...
#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 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.
boost::ptr_deque< UserDataOperator > & getOpBoundaryPostProcPipeline()
Get the Op Boundary PostProc Pipeline object.
boost::ptr_deque< UserDataOperator > & getOpDomainLhsPipeline()
Get the Op Domain Lhs Pipeline object.
SmartPetscObj< TS > createTSIM(SmartPetscObj< DM > dm=nullptr)
Create TS (time) implicit solver.
boost::ptr_deque< UserDataOperator > & getOpBoundaryLhsPipeline()
Get the Op Boundary Lhs Pipeline object.
boost::ptr_deque< UserDataOperator > & getOpBoundaryRhsPipeline()
Get the Op Boundary Rhs Pipeline object.
MoFEMErrorCode loopFiniteElementsPostProc(SmartPetscObj< DM > dm=nullptr)
Iterate postprocessing finite elements.
boost::ptr_deque< UserDataOperator > & getOpDomainRhsPipeline()
Get the Op Domain Rhs Pipeline object.
static LoggerType & setLog(const std::string channel)
Set ans resset chanel logger.
#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
FormsIntegrators< DomainEleOp >::Assembly< PETSC >::LinearForm< GAUSS >::OpGradTimesTensor< 1, 1, SPACE_DIM > OpDomainGradTimesVec
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
VectorShallowArrayAdaptor< double > VectorAdaptor
implementation of Data Operators for Forces and Sources
static auto getFTensor0FromVec(V &data)
Get tensor rank 0 (scalar) form data vector.
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
constexpr double boltzmann_constant
constexpr double T_ambient
constexpr double emissivity
constexpr double heat_conductivity
OpCalcSurfaceAverageTemperature(boost::shared_ptr< VectorDouble > &approx_vals, double &sum_temp, double &surf)
boost::shared_ptr< VectorDouble > approxVals
MoFEMErrorCode doWork(int side, EntityType type, EntitiesFieldData::EntData &data)
[Flux Rhs]
FTensor::Index< 'i', 2 > i
summit Index
MoFEMErrorCode iNtegrate(EntData &row_data)
[Radiation Lhs]
boost::shared_ptr< VectorDouble > approxVals
MoFEMErrorCode iNtegrate(EntData &row_data, EntData &col_data)
[Radiation Lhs]
OpRadiationLhs(boost::shared_ptr< VectorDouble > &approx_vals)
OpRadiationRhs(boost::shared_ptr< VectorDouble > &approx_vals)
boost::shared_ptr< VectorDouble > approxVals
MoFEMErrorCode iNtegrate(EntData &row_data)
[Radiation Lhs]
static int integrationRule(int, int, int p_data)
boost::shared_ptr< VectorDouble > approxVals
MoFEMErrorCode kspSolve()
[Push operators to pipeline]
MoFEMErrorCode checkResults()
MoFEMErrorCode createCommonData()
Example(MoFEM::Interface &m_field)
MoFEMErrorCode runProblem()
boost::shared_ptr< MatrixDouble > approxGradVals
MoFEM::Interface & mField
Reference to MoFEM interface.
MoFEMErrorCode postProcess()
MoFEMErrorCode setupProblem()
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.
default operator for EDGE element
Data on single entity (This is passed as argument to DataOperator::doWork)
FTensor::Tensor0< FTensor::PackPtr< double *, 1 > > getFTensor0N(const FieldApproximationBase base)
Get base function as Tensor0.
MoFEMErrorCode setVertexDofs(VertexCoordsFunction lambda, const std::string field_name, Range *verts=nullptr)
Set DOFs on vertices using user function.
@ OPROW
operator doWork function is executed on FE rows
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.
int nbRows
number of dofs on rows
int nbIntegrationPts
number of integration points
MatrixDouble locMat
local entity block matrix
int nbCols
number if dof on column
Get field gradients at integration pts for scalar field rank 0, i.e. vector field.
Specialization for double precision scalar field values calculation.
Operator for inverting matrices at integration points.
Post post-proc data at points from hash maps.
Set inverse jacobian to base functions.
Modify integration weights on face to take into account higher-order geometry.
PipelineManager interface.
MoFEM::FaceElementForcesAndSourcesCore FaceEle
boost::shared_ptr< FEMethod > & getDomainPostProcFE()
Get domain postprocessing finite element.
MoFEMErrorCode setDomainRhsIntegrationRule(RuleHookFun rule)
Set integration rule for domain right-hand side finite element.
MoFEMErrorCode setBoundaryLhsIntegrationRule(RuleHookFun rule)
Set integration rule for boundary left-hand side finite element.
MoFEMErrorCode setBoundaryRhsIntegrationRule(RuleHookFun rule)
Set integration rule for boundary right-hand side finite element.
MoFEM::EdgeElementForcesAndSourcesCore EdgeEle
MoFEMErrorCode setDomainLhsIntegrationRule(RuleHookFun rule)
Set integration rule for domain left-hand side finite element.
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 addBoundaryField(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 boundary.
MoFEMErrorCode getOptions()
get options
MoFEMErrorCode getDM(DM *dm)
Get DM.
MoFEMErrorCode setFieldOrder(const std::string field_name, const int order, const Range *ents=NULL)
Set field order.
MoFEMErrorCode setUp(const PetscBool is_partitioned=PETSC_TRUE)
Setup problem.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.