17#include <MethodForForceScaling.hpp>
23static char help[] =
"-my_file input file"
24 "-my_order order of approximation"
25 "-nb_levels number of refinements levels"
70 const double z,
double &flux) {
86 const double y,
const double z,
double &value) {
102 const double y,
const double z,
double &flux) {
110 Range &tris = mit->second.eNts;
111 if (tris.find(ent) != tris.end()) {
112 flux = mit->second.fLux;
139 CHKERR skin.find_skin(0, tets,
false, skin_faces);
148 natural_bc.insert(tris.begin(), tris.end());
153 CHKERR it->getBcDataStructure(mydata);
154 if (mydata.
data.flag1 == 1) {
158 bcFluxMap[it->getMeshsetId()].eNts = tris;
164 Range essential_bc = subtract(skin_faces, natural_bc);
168 essential_bc = intersect(bit_tris, essential_bc);
169 natural_bc = intersect(bit_tris, natural_bc);
212 typedef RefEntity_multiIndex::index<
214 const RefEntsByComposite &ref_ents =
216 RefEntsByComposite::iterator rit, hi_rit;
217 rit = ref_ents.lower_bound(boost::make_tuple(MBVERTEX, MBEDGE));
218 hi_rit = ref_ents.upper_bound(boost::make_tuple(MBVERTEX, MBEDGE));
221 for (; rit != hi_rit; rit++) {
222 refined_edges.insert((*rit)->getParentEnt());
225 Range tets_to_refine;
226 const double max_error = ufe.
errorMap.rbegin()->first;
228 for (map<double, EntityHandle>::iterator mit = ufe.
errorMap.begin();
232 if (mit->first < 0.25 * max_error)
234 tets_to_refine.insert(mit->second);
236 Range tets_to_refine_edges;
238 tets_to_refine, 1,
false, tets_to_refine_edges, moab::Interface::UNION);
239 refined_edges.merge(tets_to_refine_edges);
241 for (
int ll = 0; ll !=
nb_levels; ll++) {
245 edges = intersect(edges, refined_edges);
289 CHKERR it->getAttributeDataStructure(temp_data);
291 temp_data.
data.Conductivity;
292 setOfBlocks[it->getMeshsetId()].cApacity = temp_data.
data.HeatCapacity;
294 it->meshset, MBTET,
setOfBlocks[it->getMeshsetId()].tEts,
true);
296 intersect(ref_tets,
setOfBlocks[it->getMeshsetId()].tEts);
298 setOfBlocks[it->getMeshsetId()].tEts, MBTET,
"MIX");
321 RefEntity_multiIndex::iterator mit = ref_ents_ptr->begin();
322 for (; mit != ref_ents_ptr->end(); mit++) {
323 if (mit->get()->getEntType() == MBENTITYSET)
326 if ((all_but_0 &
bit) ==
bit) {
327 *(
const_cast<RefEntity *
>(mit->get())->getBitRefLevelPtr()) =
330 *(
const_cast<RefEntity *
>(mit->get())->getBitRefLevelPtr()) =
350 ->updateMeshsetByEntitiesChildren(meshset, ref_level, meshset,
357int main(
int argc,
char *argv[]) {
359 const string default_options =
"-ksp_type fgmres \n"
361 "-pc_factor_mat_solver_type mumps \n"
362 "-mat_mumps_icntl_20 0 \n"
365 string param_file =
"param_file.petsc";
366 if (!
static_cast<bool>(ifstream(param_file))) {
367 std::ofstream file(param_file.c_str(), std::ios::ate);
368 if (file.is_open()) {
369 file << default_options;
378 moab::Core mb_instance;
379 moab::Interface &moab = mb_instance;
381 MPI_Comm_rank(PETSC_COMM_WORLD, &rank);
384 PetscBool flg = PETSC_TRUE;
388 if (flg != PETSC_TRUE) {
390 "*** ERROR -my_file (MESH FILE NEEDED)");
406 PetscPrintf(PETSC_COMM_WORLD,
407 "Read meshsets add added meshsets for bc.cfg\n");
409 PetscPrintf(PETSC_COMM_WORLD,
"%s",
410 static_cast<std::ostringstream &
>(
411 std::ostringstream().seekp(0) << *it << endl)
429 if (flg != PETSC_TRUE) {
459 for (
int ll = 1; ll !=
nb_levels; ll++) {
473 static_cast<std::ostringstream &
>(std::ostringstream().seekp(0)
Mix implementation of transport element.
#define CATCH_ERRORS
Catch errors.
#define BITREFLEVEL_SIZE
max number of refinements
#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 ...
@ MAT_THERMALSET
block name is "MAT_THERMAL"
#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 ...
virtual const RefEntity_multiIndex * get_ref_ents() const =0
Get the ref ents object.
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
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_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.
#define _IT_CUBITMESHSETS_BY_BCDATA_TYPE_FOR_LOOP_(MESHSET_MANAGER, CUBITBCTYPE, IT)
Iterator that loops over a specific Cubit MeshSet in a moFEM field.
#define _IT_CUBITMESHSETS_FOR_LOOP_(MESHSET_MANAGER, IT)
Iterator that loops over all the Cubit MeshSets in a moFEM field.
map< int, BcFluxData > BcFluxMap
PetscErrorCode MoFEMErrorCode
MoFEM/PETSc error code.
std::bitset< BITREFLEVEL_SIZE > BitRefLevel
Bit structure attached to each entity identifying to what mesh entity is attached.
implementation of Data Operators for Forces and Sources
PetscErrorCode PetscOptionsGetInt(PetscOptions *, const char pre[], const char name[], PetscInt *ivalue, PetscBool *set)
PetscErrorCode PetscOptionsGetString(PetscOptions *, const char pre[], const char name[], char str[], size_t size, PetscBool *set)
MoFEMErrorCode postProc(const string out_file)
Post process results.
MoFEMErrorCode destroyMatrices()
destroy matrices
MoFEMErrorCode evaluateError()
Calculate error on elements.
MoFEMErrorCode solveLinearProblem()
solve problem
MoFEMErrorCode createMatrices()
create matrices
MoFEM::Interface & mField
MoFEMErrorCode calculateResidual()
calculate residual
MoFEMErrorCode addFiniteElements(const std::string &fluxes_name, const std::string &values_name)
add finite elements
map< double, EntityHandle > errorMap
MoFEMErrorCode addFields(const std::string &values, const std::string &fluxes, const int order)
Add fields to database.
std::map< int, BlockData > setOfBlocks
maps block set id with appropriate BlockData
MoFEMErrorCode buildProblem(BitRefLevel &ref_level)
Build problem.
virtual moab::Interface & get_moab()=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.
Definition of the heat flux bc data structure.
Thermal material data structure.
Mesh refinement interface.
MoFEMErrorCode refineTets(const EntityHandle meshset, const BitRefLevel &bit, int verb=QUIET, const bool debug=false)
refine TET in the meshset
MoFEMErrorCode addVerticesInTheMiddleOfEdges(const EntityHandle meshset, const BitRefLevel &bit, const bool recursive=false, int verb=QUIET, EntityHandle start_v=0)
make vertices in the middle of edges in meshset and add them to refinement levels defined by bit
Interface for managing meshsets containing materials and boundary conditions.
MoFEMErrorCode setMeshsetFromFile(const string file_name, const bool clean_file_options=true)
add blocksets reading config file
Struct keeps handle to refined handle.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
Application of mix transport data structure.
MoFEMErrorCode updateMeshsetsFieldsAndElements(const int nb_levels)
update meshsets with new entities after mesh refinement
MyTransport(MoFEM::Interface &m_field, BcFluxMap &bc_flux_map)
MoFEMErrorCode getBcOnValues(const EntityHandle ent, const double x, const double y, const double z, double &value)
natural (Dirihlet) boundary conditions (set values)
MoFEMErrorCode addBoundaryElements(BitRefLevel &ref_level)
set-up boundary conditions
MoFEMErrorCode getBcOnFluxes(const EntityHandle ent, const double x, const double y, const double z, double &flux)
essential (Neumann) boundary condition (set fluxes)
MoFEMErrorCode squashBits()
Squash bits of entities.
MoFEMErrorCode refineMesh(MixTransportElement &ufe, const int nb_levels, const int order)
Refine mesh.
MoFEMErrorCode getSource(EntityHandle ent, const double x, const double y, const double z, double &flux)
set source term