|
| v0.14.0
|
Mix transport problem.
More...
#include <users_modules/tutorials/cor-0to1/src/MixTransportElement.hpp>
|
| MixTransportElement (MoFEM::Interface &m_field) |
| construction of this data structure More...
|
|
virtual | ~MixTransportElement () |
| destructor More...
|
|
MoFEMErrorCode | getDirichletBCIndices (IS *is) |
| get dof indices where essential boundary conditions are applied More...
|
|
virtual MoFEMErrorCode | getSource (const EntityHandle ent, const double x, const double y, const double z, double &flux) |
| set source term More...
|
|
virtual MoFEMErrorCode | getResistivity (const EntityHandle ent, const double x, const double y, const double z, MatrixDouble3by3 &inv_k) |
| natural (Dirichlet) boundary conditions (set values) More...
|
|
virtual MoFEMErrorCode | getBcOnValues (const EntityHandle ent, const int gg, const double x, const double y, const double z, double &value) |
| evaluate natural (Dirichlet) boundary conditions More...
|
|
virtual MoFEMErrorCode | getBcOnFluxes (const EntityHandle ent, const double x, const double y, const double z, double &flux) |
| essential (Neumann) boundary condition (set fluxes) More...
|
|
MoFEMErrorCode | addFields (const std::string &values, const std::string &fluxes, const int order) |
| Add fields to database. More...
|
|
MoFEMErrorCode | addFiniteElements (const std::string &fluxes_name, const std::string &values_name) |
| add finite elements More...
|
|
MoFEMErrorCode | buildProblem (BitRefLevel &ref_level) |
| Build problem. More...
|
|
MoFEMErrorCode | postProc (const string out_file) |
| Post process results. More...
|
|
MoFEMErrorCode | createMatrices () |
| create matrices More...
|
|
MoFEMErrorCode | solveLinearProblem () |
| solve problem More...
|
|
MoFEMErrorCode | calculateResidual () |
| calculate residual More...
|
|
MoFEMErrorCode | evaluateError () |
| Calculate error on elements. More...
|
|
MoFEMErrorCode | destroyMatrices () |
| destroy matrices More...
|
|
Mix transport problem.
Note to solve this system you need to use direct solver or proper preconditioner for saddle problem.
It is based on [6] [7] [reviartthomas1996] https://www.researchgate.net/profile/Richard_Falk/publication/226454406_Differential_Complexes_and_Stability_of_Finite_Element_Methods_I._The_de_Rham_Complex/links/02e7e5214f0426ff77000000.pdf
General problem have form,
\[ \mathbf{A} \boldsymbol\sigma + \textrm{grad}[u] = \mathbf{0} \; \textrm{on} \; \Omega \\ \textrm{div}[\boldsymbol\sigma] = f \; \textrm{on} \; \Omega \]
Definition at line 29 of file MixTransportElement.hpp.
◆ MixTransportElement()
MixTransport::MixTransportElement::MixTransportElement |
( |
MoFEM::Interface & |
m_field | ) |
|
|
inline |
◆ ~MixTransportElement()
virtual MixTransport::MixTransportElement::~MixTransportElement |
( |
| ) |
|
|
inlinevirtual |
◆ addFields()
MoFEMErrorCode MixTransport::MixTransportElement::addFields |
( |
const std::string & |
values, |
|
|
const std::string & |
fluxes, |
|
|
const int |
order |
|
) |
| |
|
inline |
Add fields to database.
- Parameters
-
values | name of the fields |
fluxes | name of filed for fluxes |
order | order of approximation |
- Returns
- error code
Definition at line 189 of file MixTransportElement.hpp.
◆ addFiniteElements()
MoFEMErrorCode MixTransport::MixTransportElement::addFiniteElements |
( |
const std::string & |
fluxes_name, |
|
|
const std::string & |
values_name |
|
) |
| |
|
inline |
add finite elements
Definition at line 208 of file MixTransportElement.hpp.
244 Mat_Thermal temp_data;
245 CHKERR it->getAttributeDataStructure(temp_data);
247 temp_data.data.Conductivity;
248 setOfBlocks[it->getMeshsetId()].cApacity = temp_data.data.HeatCapacity;
250 it->meshset, MBTET,
setOfBlocks[it->getMeshsetId()].tEts,
true);
252 setOfBlocks[it->getMeshsetId()].tEts, MBTET,
"MIX");
256 setOfBlocks[it->getMeshsetId()].tEts, 2,
false, skeleton,
257 moab::Interface::UNION);
◆ buildProblem()
MoFEMErrorCode MixTransport::MixTransportElement::buildProblem |
( |
BitRefLevel & |
ref_level | ) |
|
|
inline |
Build problem.
- Parameters
-
ref_level | mesh refinement on which mesh problem you like to built. |
- Returns
- error code
Definition at line 291 of file MixTransportElement.hpp.
307 ref_tets = subtract(ref_tets, done_tets);
321 ref_faces = subtract(ref_faces, done_faces);
340 ProblemsManager *prb_mng_ptr;
342 CHKERR prb_mng_ptr->buildProblem(
"MIX",
true);
345 CHKERR prb_mng_ptr->partitionProblem(
"MIX");
346 CHKERR prb_mng_ptr->partitionFiniteElements(
"MIX");
348 CHKERR prb_mng_ptr->partitionGhostDofs(
"MIX");
◆ calculateResidual()
MoFEMErrorCode MixTransport::MixTransportElement::calculateResidual |
( |
| ) |
|
|
inline |
calculate residual
Definition at line 612 of file MixTransportElement.hpp.
615 CHKERR VecGhostUpdateBegin(
F, INSERT_VALUES, SCATTER_FORWARD);
616 CHKERR VecGhostUpdateEnd(
F, INSERT_VALUES, SCATTER_FORWARD);
624 new OpFluxDivergenceAtGaussPts(*
this,
"FLUXES"));
627 new OpDivTauU_HdivL2(*
this,
"FLUXES",
"VALUES",
F));
629 new OpTauDotSigma_HdivHdiv(*
this,
"FLUXES", PETSC_NULL,
F));
631 new OpVDivSigma_L2Hdiv(*
this,
"VALUES",
"FLUXES", PETSC_NULL,
F));
636 CHKERR VecGhostUpdateBegin(
F, ADD_VALUES, SCATTER_REVERSE);
637 CHKERR VecGhostUpdateEnd(
F, ADD_VALUES, SCATTER_REVERSE);
643 std::vector<int> ids;
645 std::vector<double> vals(ids.size(), 0);
653 CHKERR VecNorm(
F, NORM_2, &nrm2_F);
654 PetscPrintf(PETSC_COMM_WORLD,
"nrm2_F = %6.4e\n", nrm2_F);
655 const double eps = 1e-8;
◆ createMatrices()
MoFEMErrorCode MixTransport::MixTransportElement::createMatrices |
( |
| ) |
|
|
inline |
◆ destroyMatrices()
MoFEMErrorCode MixTransport::MixTransportElement::destroyMatrices |
( |
| ) |
|
|
inline |
◆ evaluateError()
MoFEMErrorCode MixTransport::MixTransportElement::evaluateError |
( |
| ) |
|
|
inline |
Calculate error on elements.
- Todo:
- this functions runs serial, in future should be parallel and work on distributed meshes.
Definition at line 670 of file MixTransportElement.hpp.
683 new OpFluxDivergenceAtGaussPts(*
this,
"FLUXES"));
685 new OpValuesGradientAtGaussPts(*
this,
"VALUES"));
689 const Problem *problem_ptr;
692 "Nb dofs %d error flux^2 = %6.4e error div^2 = %6.4e error "
693 "jump^2 = %6.4e error tot^2 = %6.4e\n",
◆ getBcOnFluxes()
◆ getBcOnValues()
◆ getDirichletBCIndices()
MoFEMErrorCode MixTransport::MixTransportElement::getDirichletBCIndices |
( |
IS * |
is | ) |
|
|
inline |
get dof indices where essential boundary conditions are applied
- Parameters
-
- Returns
- error code
Definition at line 87 of file MixTransportElement.hpp.
93 ids.empty() ? PETSC_NULL : &ids[0],
94 PETSC_COPY_VALUES, &is_local);
95 CHKERR ISAllGather(is_local, is);
96 CHKERR ISDestroy(&is_local);
◆ getResistivity()
virtual MoFEMErrorCode MixTransport::MixTransportElement::getResistivity |
( |
const EntityHandle |
ent, |
|
|
const double |
x, |
|
|
const double |
y, |
|
|
const double |
z, |
|
|
MatrixDouble3by3 & |
inv_k |
|
) |
| |
|
inlinevirtual |
natural (Dirichlet) boundary conditions (set values)
- Parameters
-
ent | handle to finite element entity |
x | coord |
y | coord |
z | coord |
value | reference to value set by function |
- Returns
- error code
Definition at line 126 of file MixTransportElement.hpp.
131 for (
int dd = 0;
dd < 3;
dd++) {
◆ getSource()
set source term
- Parameters
-
ent | handle to entity on which function is evaluated |
x | coord |
y | coord |
z | coord |
flux | reference to source term set by function |
- Returns
- error code
Reimplemented in MyTransport, and MyTransport.
Definition at line 109 of file MixTransportElement.hpp.
◆ postProc()
MoFEMErrorCode MixTransport::MixTransportElement::postProc |
( |
const string |
out_file | ) |
|
|
inline |
Post process results.
- Returns
- error code
Definition at line 428 of file MixTransportElement.hpp.
431 PostProcBrokenMeshInMoab<VolumeElementForcesAndSourcesCore> post_proc(
434 CHKERR AddHOOps<3, 3, 3>::add(post_proc.getOpPtrVector(), {HDIV, L2});
436 auto values_ptr = boost::make_shared<VectorDouble>();
437 auto grad_ptr = boost::make_shared<MatrixDouble>();
438 auto flux_ptr = boost::make_shared<MatrixDouble>();
440 post_proc.getOpPtrVector().push_back(
441 new OpCalculateScalarFieldValues(
"VALUES", values_ptr));
442 post_proc.getOpPtrVector().push_back(
443 new OpCalculateScalarFieldGradient<3>(
"VALUES", grad_ptr));
444 post_proc.getOpPtrVector().push_back(
445 new OpCalculateHVecVectorField<3>(
"FLUXES", flux_ptr));
447 using OpPPMap = OpPostProcMapInMoab<3, 3>;
449 post_proc.getOpPtrVector().push_back(
451 new OpPPMap(post_proc.getPostProcMesh(), post_proc.getMapGaussPts(),
453 {{
"VALUES", values_ptr}},
455 {{
"GRAD", grad_ptr}, {
"FLUXES", flux_ptr}},
461 post_proc.getOpPtrVector().push_back(
new OpPostProc(
462 post_proc.getPostProcMesh(), post_proc.getMapGaussPts()));
466 CHKERR post_proc.writeFile(out_file.c_str());
◆ solveLinearProblem()
MoFEMErrorCode MixTransport::MixTransportElement::solveLinearProblem |
( |
| ) |
|
|
inline |
solve problem
- Returns
- error code
Definition at line 488 of file MixTransportElement.hpp.
492 CHKERR VecGhostUpdateBegin(
F, INSERT_VALUES, SCATTER_FORWARD);
493 CHKERR VecGhostUpdateEnd(
F, INSERT_VALUES, SCATTER_FORWARD);
495 CHKERR VecGhostUpdateBegin(
D0, INSERT_VALUES, SCATTER_FORWARD);
496 CHKERR VecGhostUpdateEnd(
D0, INSERT_VALUES, SCATTER_FORWARD);
498 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
499 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
502 "MIX",
COL,
D, INSERT_VALUES, SCATTER_REVERSE);
515 CHKERR VecGhostUpdateBegin(
D0, INSERT_VALUES, SCATTER_REVERSE);
516 CHKERR VecGhostUpdateEnd(
D0, INSERT_VALUES, SCATTER_REVERSE);
525 new OpFluxDivergenceAtGaussPts(*
this,
"FLUXES"));
528 new OpDivTauU_HdivL2(*
this,
"FLUXES",
"VALUES",
F));
530 new OpTauDotSigma_HdivHdiv(*
this,
"FLUXES",
Aij,
F));
532 new OpVDivSigma_L2Hdiv(*
this,
"VALUES",
"FLUXES",
Aij,
F));
542 CHKERR MatAssemblyBegin(
Aij, MAT_FINAL_ASSEMBLY);
543 CHKERR MatAssemblyEnd(
Aij, MAT_FINAL_ASSEMBLY);
544 CHKERR VecGhostUpdateBegin(
F, ADD_VALUES, SCATTER_REVERSE);
545 CHKERR VecGhostUpdateEnd(
F, ADD_VALUES, SCATTER_REVERSE);
551 CHKERR VecNorm(
F, NORM_2, &nrm2_F);
552 PetscPrintf(PETSC_COMM_WORLD,
"nrm2_F = %6.4e\n", nrm2_F);
563 CHKERR MatZeroRowsColumnsIS(
Aij, essential_bc_ids, 1,
D0,
F);
564 CHKERR ISDestroy(&essential_bc_ids);
574 CHKERR VecNorm(
F, NORM_2, &nrm2_F);
575 PetscPrintf(PETSC_COMM_WORLD,
"With BC nrm2_F = %6.4e\n", nrm2_F);
588 CHKERR KSPCreate(PETSC_COMM_WORLD, &solver);
590 CHKERR KSPSetFromOptions(solver);
593 CHKERR KSPDestroy(&solver);
597 CHKERR VecNorm(
D, NORM_2, &nrm2_D);
599 PetscPrintf(PETSC_COMM_WORLD,
"nrm2_D = %6.4e\n", nrm2_D);
601 CHKERR VecGhostUpdateBegin(
D, INSERT_VALUES, SCATTER_FORWARD);
602 CHKERR VecGhostUpdateEnd(
D, INSERT_VALUES, SCATTER_FORWARD);
606 "MIX",
COL,
D, INSERT_VALUES, SCATTER_REVERSE);
◆ Aij
Mat MixTransport::MixTransportElement::Aij |
◆ bcIndices
set<int> MixTransport::MixTransportElement::bcIndices |
Vec MixTransport::MixTransportElement::D |
◆ D0
Vec MixTransport::MixTransportElement::D0 |
◆ divergenceAtGaussPts
VectorDouble MixTransport::MixTransportElement::divergenceAtGaussPts |
◆ errorMap
Vec MixTransport::MixTransportElement::F |
◆ feTri
MyTriFE MixTransport::MixTransportElement::feTri |
◆ feVol
MyVolumeFE MixTransport::MixTransportElement::feVol |
◆ fluxesAtGaussPts
MatrixDouble MixTransport::MixTransportElement::fluxesAtGaussPts |
◆ mField
◆ setOfBlocks
std::map<int, BlockData> MixTransport::MixTransportElement::setOfBlocks |
◆ sumErrorDiv
double MixTransport::MixTransportElement::sumErrorDiv |
◆ sumErrorFlux
double MixTransport::MixTransportElement::sumErrorFlux |
◆ sumErrorJump
double MixTransport::MixTransportElement::sumErrorJump |
◆ valuesAtGaussPts
VectorDouble MixTransport::MixTransportElement::valuesAtGaussPts |
◆ valuesGradientAtGaussPts
MatrixDouble MixTransport::MixTransportElement::valuesGradientAtGaussPts |
The documentation for this struct was generated from the following file:
#define MoFEMFunctionReturnHot(a)
Last executable line of each PETSc function used for error handling. Replaces return()
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface refernce to pointer of interface.
virtual MoFEMErrorCode loop_finite_elements(const std::string problem_name, const std::string &fe_name, FEMethod &method, boost::shared_ptr< NumeredEntFiniteElement_multiIndex > fe_ptr=nullptr, MoFEMTypes bh=MF_EXIST, CacheTupleWeakPtr cache_ptr=CacheTupleSharedPtr(), int verb=DEFAULT_VERBOSITY)=0
Make a loop over finite elements.
virtual MoFEMErrorCode modify_problem_ref_level_set_bit(const std::string &name_problem, const BitRefLevel &bit)=0
set ref level for problem
virtual MPI_Comm & get_comm() const =0
virtual MoFEMErrorCode modify_finite_element_add_field_row(const std::string &fe_name, const std::string name_row)=0
set field row which finite element use
@ L2
field with C-1 continuity
#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet in a moFEM field.
virtual const Problem * get_problem(const std::string problem_name) const =0
Get the problem object.
MoFEMErrorCode getDirichletBCIndices(IS *is)
get dof indices where essential boundary conditions are applied
MoFEMErrorCode VecSetValues(Vec V, const EntitiesFieldData::EntData &data, const double *ptr, InsertMode iora)
Assemble PETSc vector.
virtual MoFEMErrorCode add_ents_to_field_by_type(const Range &ents, const EntityType type, const std::string &name, int verb=DEFAULT_VERBOSITY)=0
Add entities to field meshset.
virtual MoFEMErrorCode add_ents_to_finite_element_by_type(const EntityHandle entities, const EntityType type, const std::string &name, const bool recursive=true)=0
add entities to finite element
#define CHKERR
Inline error check.
virtual MoFEMErrorCode add_finite_element(const std::string &fe_name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
add finite element
virtual moab::Interface & get_moab()=0
virtual MoFEMErrorCode modify_finite_element_add_field_col(const std::string &fe_name, const std::string name_row)=0
set field col which finite element use
@ MAT_THERMALSET
block name is "MAT_THERMAL"
virtual MoFEMErrorCode build_finite_elements(int verb=DEFAULT_VERBOSITY)=0
Build finite elements.
virtual MoFEMErrorCode add_field(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_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add field.
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
MyTriFE feTri
Instance of surface element.
virtual int get_comm_size() const =0
std::map< int, BlockData > setOfBlocks
maps block set id with appropriate BlockData
MyVolumeFE feVol
Instance of volume element.
const Tensor2_symmetric_Expr< const ddTensor0< T, Dim, i, j >, typename promote< T, double >::V, Dim, i, j > dd(const Tensor0< T * > &a, const Index< i, Dim > index1, const Index< j, Dim > index2, const Tensor1< int, Dim > &d_ijk, const Tensor1< double, Dim > &d_xyz)
#define BITREFLEVEL_SIZE
max number of refinements
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
boost::ptr_deque< UserDataOperator > & getOpPtrVector()
Use to push back operator for row operator.
virtual MoFEMErrorCode build_fields(int verb=DEFAULT_VERBOSITY)=0
virtual MoFEMErrorCode modify_finite_element_add_field_data(const std::string &fe_name, const std::string name_filed)=0
set finite element field data
map< double, EntityHandle > errorMap
virtual MoFEMErrorCode modify_problem_add_finite_element(const std::string name_problem, const std::string &fe_name)=0
add finite element to problem, this add entities assigned to finite element to a particular problem
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
virtual MoFEMErrorCode build_adjacencies(const Range &ents, int verb=DEFAULT_VERBOSITY)=0
build adjacencies
#define MoFEMFunctionBeginHot
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
virtual MoFEMErrorCode set_field_order(const EntityHandle meshset, const EntityType type, const std::string &name, const ApproximationOrder order, int verb=DEFAULT_VERBOSITY)=0
Set order approximation of the entities in the field.
virtual MoFEMErrorCode add_problem(const std::string &name, enum MoFEMTypes bh=MF_EXCL, int verb=DEFAULT_VERBOSITY)=0
Add problem.
MoFEM::Interface & mField
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
@ HDIV
field with continuous normal traction
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
Post post-proc data at points from hash maps.