16 using namespace MoFEM;
17 #include <MethodForForceScaling.hpp>
23 static 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) {
104 if (lastEnt == ent) {
108 for (BcFluxMap::iterator mit = bcFluxMap.begin(); mit != bcFluxMap.end();
110 Range &tris = mit->second.eNts;
111 if (tris.find(ent) != tris.end()) {
112 flux = mit->second.fLux;
137 Skinner skin(&mField.get_moab());
139 CHKERR skin.find_skin(0, tets,
false, skin_faces);
146 CHKERR it->getMeshsetIdEntitiesByDimension(mField.get_moab(), 2, tris,
148 natural_bc.insert(tris.begin(), tris.end());
153 CHKERR it->getBcDataStructure(mydata);
154 if (mydata.
data.flag1 == 1) {
156 CHKERR it->getMeshsetIdEntitiesByDimension(mField.get_moab(), 2, tris,
158 bcFluxMap[it->getMeshsetId()].eNts = tris;
159 bcFluxMap[it->getMeshsetId()].fLux = mydata.
data.value1;
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);
170 CHKERR mField.add_ents_to_finite_element_by_type(essential_bc, MBTRI,
172 CHKERR mField.add_ents_to_finite_element_by_type(natural_bc, MBTRI,
211 auto ref_ents_ptr = mField.get_ref_ents();
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;
237 CHKERR mField.get_moab().get_adjacencies(
238 tets_to_refine, 1,
false, tets_to_refine_edges, moab::Interface::UNION);
239 refined_edges.merge(tets_to_refine_edges);
240 CHKERR mField.getInterface(refine_ptr);
241 for (
int ll = 0; ll !=
nb_levels; ll++) {
245 edges = intersect(edges, refined_edges);
255 CHKERR updateMeshsetsFieldsAndElements(ll + 1);
260 CHKERR mField.get_moab().create_meshset(MESHSET_SET, ref_meshset);
268 CHKERR mField.get_moab().get_entities_by_type(ref_meshset, MBTET,
272 CHKERR mField.add_ents_to_field_by_type(ref_meshset, MBTET,
"FLUXES");
273 CHKERR mField.add_ents_to_field_by_type(ref_meshset, MBTET,
"VALUES");
274 CHKERR mField.set_field_order(0, MBTET,
"FLUXES",
order + 1);
275 CHKERR mField.set_field_order(0, MBTRI,
"FLUXES",
order + 1);
276 CHKERR mField.set_field_order(0, MBTET,
"VALUES",
order);
282 CHKERR mField.add_ents_to_finite_element_by_type(ref_tris, MBTRI,
289 CHKERR it->getAttributeDataStructure(temp_data);
290 setOfBlocks[it->getMeshsetId()].cOnductivity =
291 temp_data.
data.Conductivity;
292 setOfBlocks[it->getMeshsetId()].cApacity = temp_data.
data.HeatCapacity;
293 CHKERR mField.get_moab().get_entities_by_type(
294 it->meshset, MBTET, setOfBlocks[it->getMeshsetId()].tEts,
true);
295 setOfBlocks[it->getMeshsetId()].tEts =
296 intersect(ref_tets, setOfBlocks[it->getMeshsetId()].tEts);
297 CHKERR mField.add_ents_to_finite_element_by_type(
298 setOfBlocks[it->getMeshsetId()].tEts, MBTET,
"MIX");
301 CHKERR mField.get_moab().delete_entities(&ref_meshset, 1);
320 auto ref_ents_ptr = mField.get_ref_ents();
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,
357 int 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;
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)