1#ifndef __MESH_SMOOTHING_OP_FACTORY_HPP__
2#define __MESH_SMOOTHING_OP_FACTORY_HPP__
5#error "MoFEM need to be compiled with ADOL-C"
49 boost::shared_ptr<SurfaceSlidingConstrains::DriverElementOrientation>
52 boost::shared_ptr<MoFEM::VolumeElementForcesAndSourcesCore>
minQualityFe;
61 double *min_quality_ptr)
66 MoFEMErrorCode
doWork(
int, EntityType type, EntitiesFieldData::EntData &data) {
78 const Range &fixed_vertices,
79 const Range &edge_entities,
83 handles.
smoother = boost::make_shared<Smoother>(m_field);
84 handles.
qualityAdouble = boost::make_shared<VolumeLengthQuality<adouble>>(
86 handles.
qualityDouble = boost::make_shared<VolumeLengthQuality<double>>(
91 handles.
smoother->setOfBlocks[0].tEts.merge(tets);
103 rhs_ops.push_back(
new OpCalculateVectorFieldGradient<3, 3>(
113 lhs_ops.push_back(
new OpCalculateVectorFieldGradient<3, 3>(
122 boost::make_shared<MoFEM::VolumeElementForcesAndSourcesCore>(m_field);
124 boost::make_shared<double>(std::numeric_limits<double>::max());
129 if (!fixed_vertices.empty()) {
130 auto *prb_mng = m_field.
getInterface<ProblemsManager>();
133 CHKERR prb_mng->removeDofsOnEntities(
simple->getProblemName(),
138 CHKERR prb_mng->removeDofsOnEntities(
simple->getProblemName(),
145 CHKERR prb_mng->removeDofsOnEntities(
simple->getProblemName(),
165 CHKERR skin.find_skin(0, tets,
false, skin_faces);
166 if (skin_faces.empty()) {
168 "No skin faces found for edge constrains");
170 handles.
edgeConstraint = boost::make_shared<EdgeSlidingConstrains>(m_field);
182 boost::shared_ptr<ForcesAndSourcesCore> null;
190 CHKERR DMMoFEMSNESSetFunction(dm,
"SURFACE_SLIDING",
193 CHKERR DMMoFEMSNESSetJacobian(dm,
"SURFACE_SLIDING",
199 CHKERR DMMoFEMSNESSetFunction(dm,
"EDGE_SLIDING",
201 CHKERR DMMoFEMSNESSetJacobian(dm,
"EDGE_SLIDING",
209 const std::string &domain_fe_name,
211 double &min_quality) {
216 "Min quality operators are not initialised");
220 CHKERR DMoFEMLoopFiniteElements(dm, domain_fe_name.c_str(),
224 CHKERR DMoFEMGetInterfacePtr(dm, &m_field_ptr);
226 CHKERR MPI_Allreduce(&local_min, &min_quality, 1, MPI_DOUBLE, MPI_MIN,
241inline MoFEMErrorCode
createSnes(DM dm, SmartPetscObj<SNES> &snes) {
244 CHKERR DMoFEMGetInterfacePtr(dm, &m_field_ptr);
245 snes = createSNES(m_field_ptr->
get_comm());
246 CHKERR SNESSetFromOptions(snes);
247 CHKERR SNESSetDM(snes, dm);
254 const std::vector<std::string> &zero_vertex_fields = {}) {
256 if (!zero_vertex_fields.empty()) {
258 CHKERR DMoFEMGetInterfacePtr(dm, &m_field_ptr);
259 auto field_blas = m_field_ptr->
getInterface<FieldBlas>();
260 for (
const auto &
field_name : zero_vertex_fields) {
268 CHKERR SNESSolve(snes, f, d);
ForcesAndSourcesCore::UserDataOperator UserDataOperator
void simple(double P1[], double P2[], double P3[], double c[], const int N)
#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 ...
@ MOFEM_DATA_INCONSISTENCY
#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)
set local (or ghosted) vector values on mesh for partition only
auto createDMVector(DM dm)
Get smart vector from DM.
PetscErrorCode DMoFEMMeshToGlobalVector(DM dm, Vec g, InsertMode mode, ScatterMode scatter_mode)
set ghosted vector values on all existing mesh entities
virtual bool check_field(const std::string &name) const =0
check if field is in database
MoFEMErrorCode updateBarrierGamma(Handles &handles, double gamma)
MoFEMErrorCode evaluateMinQuality(DM dm, const std::string &domain_fe_name, const Handles &handles, double &min_quality)
MoFEMErrorCode createSnes(DM dm, SmartPetscObj< SNES > &snes)
MoFEMErrorCode solveSnes(DM dm, SNES snes, const std::vector< std::string > &zero_vertex_fields={})
MoFEMErrorCode createOperators(MoFEM::Interface &m_field, const Config &cfg, const Range &fixed_vertices, const Range &edge_entities, Handles &handles)
MoFEMErrorCode addToSnesDM(DM dm, const Config &cfg, const Handles &handles)
implementation of Data Operators for Forces and Sources
SmartPetscObj< Vec > vectorDuplicate(Vec vec)
Create duplicate vector of smart vector.
constexpr auto field_name
VolumeLengthQualityType qualityType
std::string geometryField
std::string lambdaEdgeField
std::string meshReferenceField
std::string lambdaSurfaceField
bool enableSurfaceSliding
boost::shared_ptr< double > minQualityValue
boost::shared_ptr< Smoother > smoother
boost::shared_ptr< VolumeLengthQuality< double > > qualityDouble
boost::shared_ptr< EdgeSlidingConstrains > edgeConstraint
boost::shared_ptr< MoFEM::VolumeElementForcesAndSourcesCore > minQualityFe
boost::shared_ptr< SurfaceSlidingConstrains > surfaceConstraint
boost::shared_ptr< Smoother::MyVolumeFE > feSmootherLhs
boost::shared_ptr< Smoother::MyVolumeFE > feSmootherRhs
boost::shared_ptr< SurfaceSlidingConstrains::DriverElementOrientation > surfaceOrientation
boost::shared_ptr< VolumeLengthQuality< adouble > > qualityAdouble
MinQualityOp(const std::string &field_name, double *min_quality_ptr)
MoFEMErrorCode doWork(int, EntityType type, EntitiesFieldData::EntData &data)
virtual moab::Interface & get_moab()=0
virtual MPI_Comm & get_comm() const =0
Deprecated interface functions.
@ OPROW
operator doWork function is executed on FE rows
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.
BiLinearForm::OpGradTensorGrad< 1, 3, 3, 1 > OpKPiola
LinearForm::OpGradTimesTensor< 1, 3, 3 > OpInternalForcePiola
Class implemented by user to detect face orientation.
Shape preserving constrains, i.e. nodes sliding on body surface.
Implementing surface sliding constrains.
Implementation of Volume-Length-Quality measure with barrier.