35 CHKERR PetscOptionsBegin(PETSC_COMM_WORLD,
"",
"Mesh cut options",
"none");
36 CHKERR PetscOptionsString(
"-my_file",
"mesh file name",
"",
"mesh.h5m",
38 CHKERR PetscOptionsInt(
"-edges_block_set",
"edges side set",
"",
40 CHKERR PetscOptionsInt(
"-vertex_block_set",
"vertex side set",
"",
42 CHKERR PetscOptionsBool(
"-output_vtk",
"if true outout vtk file",
"",
44 CHKERR PetscOptionsScalar(
"-quality_reduction_tol",
"",
45 "Tolerance of quality reduction",
tol, &
tol,
47 CHKERR PetscOptionsScalar(
"-gamma_factor",
"",
50 ierr = PetscOptionsEnd();
106 ->synchroniseFieldEntities(
"LAMBDA_EDGE");
111 "EDGE_SLIDING",
"MESH_NODE_POSITIONS");
113 "EDGE_SLIDING",
"MESH_NODE_POSITIONS");
115 "EDGE_SLIDING",
"MESH_NODE_POSITIONS");
145 struct ElementsAndOperators {
149 double *minQualityPtr;
154 CHKERRABORT(PETSC_COMM_WORLD,
ierr);
155 ierr = VecGetArray(minQualityVec, &minQualityPtr);
156 CHKERRABORT(PETSC_COMM_WORLD,
ierr);
159 virtual ~ElementsAndOperators() {
160 ierr = VecRestoreArray(minQualityVec, &minQualityPtr);
161 CHKERRABORT(PETSC_COMM_WORLD,
ierr);
162 ierr = VecDestroy(&minQualityVec);
163 CHKERRABORT(PETSC_COMM_WORLD,
ierr);
166 double getMinQuality()
const {
return *minQualityPtr; }
170 SURFACE_CONSTRAINS_TAG,
174 boost::shared_ptr<Smoother> smootherFe;
175 boost::shared_ptr<Smoother::MyVolumeFE>
177 boost::shared_ptr<Smoother::MyVolumeFE>
179 boost::shared_ptr<VolumeLengthQuality<double> > volumeLengthDouble;
180 boost::shared_ptr<VolumeLengthQuality<adouble> > volumeLengthAdouble;
182 boost::shared_ptr<SurfaceSlidingConstrains> surfaceConstrain;
183 boost::shared_ptr<SurfaceSlidingConstrains::DriverElementOrientation>
185 boost::shared_ptr<EdgeSlidingConstrains> edgeConstrain;
187 boost::shared_ptr<DirichletFixFieldAtEntitiesBc> fixMaterialEnts;
189 boost::shared_ptr<MoFEM::VolumeElementForcesAndSourcesCore> minQualityFe;
192 double *minQualityPtr;
193 MinQualityOp(
double *min_quality_ptr)
196 minQualityPtr(min_quality_ptr) {}
200 if (
type != MBVERTEX)
202 double q = Tools::volumeLengthQuality(&*data.
getFieldData().begin());
203 *minQualityPtr = fmin(*minQualityPtr, q);
210 smootherFe = boost::shared_ptr<Smoother>(
new Smoother(mField));
211 volumeLengthAdouble = boost::shared_ptr<VolumeLengthQuality<adouble> >(
213 volumeLengthDouble = boost::shared_ptr<VolumeLengthQuality<double> >(
218 smootherFe->setOfBlocks[0].tEts.merge(tets);
220 smootherFe->setOfBlocks[0].materialDoublePtr = volumeLengthDouble;
221 smootherFe->setOfBlocks[0].materialAdoublePtr = volumeLengthAdouble;
224 smootherFe->commonData.spatialPositions =
"MESH_NODE_POSITIONS";
225 smootherFe->commonData.meshPositions =
"NONE";
227 smootherFe->feRhs.meshPositionsFieldName =
"NONE";
228 smootherFe->feLhs.meshPositionsFieldName =
"NONE";
229 smootherFe->feRhs.addToRule = 0;
230 smootherFe->feLhs.addToRule = 0;
232 feSmootherRhs = smootherFe->feRhsPtr;
233 feSmootherLhs = smootherFe->feLhsPtr;
236 feSmootherRhs->getOpPtrVector().push_back(
238 "MESH_NODE_POSITIONS", smootherFe->commonData));
239 feSmootherRhs->getOpPtrVector().push_back(
241 "MESH_NODE_POSITIONS", smootherFe->setOfBlocks.at(0),
244 "MESH_NODE_POSITIONS", smootherFe->setOfBlocks[0],
245 smootherFe->commonData, smootherFe->smootherData));
248 feSmootherLhs->getOpPtrVector().push_back(
250 "MESH_NODE_POSITIONS", smootherFe->commonData));
251 feSmootherLhs->getOpPtrVector().push_back(
253 "MESH_NODE_POSITIONS", smootherFe->setOfBlocks.at(0),
256 "MESH_NODE_POSITIONS",
"MESH_NODE_POSITIONS",
257 smootherFe->setOfBlocks.at(0), smootherFe->commonData,
258 smootherFe->smootherData,
"LAMBDA_CRACKFRONT_AREA_TANGENT"));
261 boost::shared_ptr<MoFEM::VolumeElementForcesAndSourcesCore>(
263 minQualityFe->getOpPtrVector().push_back(
264 new MinQualityOp(minQualityPtr));
272 fixMaterialEnts = boost::shared_ptr<DirichletFixFieldAtEntitiesBc>(
275 fixMaterialEnts->fieldNames.push_back(
"LAMBDA_SURFACE");
276 fixMaterialEnts->fieldNames.push_back(
"LAMBDA_EDGE");
283 skinOrientation = boost::shared_ptr<
286 surfaceConstrain = boost::shared_ptr<SurfaceSlidingConstrains>(
289 surfaceConstrain->setOperators(SURFACE_CONSTRAINS_TAG,
"LAMBDA_SURFACE",
290 "MESH_NODE_POSITIONS");
303 CHKERR skin.find_skin(0, tets,
false, skin_faces);
305 edgeConstrain = boost::shared_ptr<EdgeSlidingConstrains>(
307 CHKERR edgeConstrain->setOperators(EDGE_CONSTRAINS_TAG, edges,
308 skin_faces,
"LAMBDA_EDGE",
309 "MESH_NODE_POSITIONS");
320 boost::shared_ptr<ForcesAndSourcesCore>
null;
327 surfaceConstrain->feRhsPtr,
null,
null);
329 edgeConstrain->feRhsPtr,
null,
null);
338 surfaceConstrain->feLhsPtr,
null,
null);
340 edgeConstrain->feLhsPtr,
null,
null);
355 CHKERR VecMin(minQualityVec, PETSC_NULL, minQualityPtr);
360 ElementsAndOperators elements_and_operators(m_field);
361 CHKERR elements_and_operators.createSmoothingFE();
362 CHKERR elements_and_operators.createConstrians();
366 CHKERR elements_and_operators.addFEtoDM(dm);
375 CHKERR DMCreateGlobalVector(dm, &
F);
380 CHKERR zeroLambdaFields(dm);
385 CHKERR SNESCreate(PETSC_COMM_WORLD, &solver);
386 CHKERR SNESSetFromOptions(solver);
387 CHKERR SNESSetDM(solver, dm);
399 CHKERR SNESDestroy(&solver);
411 "MESH_NODE_POSITIONS", it)) {
412 if (it->get()->getEntType() != MBVERTEX)
415 for(
int dd = 0;
dd!=3;++
dd)
416 coords[
dd] = it->get()->getEntFieldData()[
dd];
418 CHKERR m_field_ptr->
get_moab().set_coords(&ent, 1, &*coords.begin());
428 "MESH_NODE_POSITIONS", it)) {
429 if (it->get()->getEntType() != MBVERTEX)
433 CHKERR m_field_ptr->
get_moab().get_coords(&ent, 1, &*coords.begin());
434 for(
int dd = 0;
dd!=3;++
dd)
435 it->get()->getEntFieldData()[
dd] = coords[
dd];
446 0, MBVERTEX,
"LAMBDA_SURFACE");
455 CHKERR elements_and_operators.calcuteMinQuality(dm);
456 double min_quality = elements_and_operators.getMinQuality();
457 PetscPrintf(PETSC_COMM_WORLD,
"Min quality = %4.3f\n", min_quality);
459 double gamma = min_quality > 0 ?
gamma_factor * min_quality
461 elements_and_operators.volumeLengthDouble->gAmma = gamma;
462 elements_and_operators.volumeLengthAdouble->gAmma = gamma;
464 double min_quality_p,
eps;
467 min_quality_p = min_quality;
472 CHKERR elements_and_operators.calcuteMinQuality(dm);
473 min_quality = elements_and_operators.getMinQuality();
475 eps = (min_quality - min_quality_p) / min_quality;
476 PetscPrintf(PETSC_COMM_WORLD,
"Min quality = %4.3f eps = %4.3f\n",
479 double gamma = min_quality > 0 ?
gamma_factor * min_quality
481 elements_and_operators.volumeLengthDouble->gAmma = gamma;
482 elements_and_operators.volumeLengthAdouble->gAmma = gamma;