26 {
28
29 try {
30 DMType dm_name = "DMMOFEM";
32
33 moab::Core coarse_core;
34 moab::Interface &coarse_moab = coarse_core;
37
38 moab::Core fine_core;
39 moab::Interface &fine_moab = fine_core;
40
41
42 char coarse_file[255] = "coarse.h5m";
43 char surface_file[255] = "surface.h5m";
44 char output_file[255] = "out_geometry_fit.h5m";
45 char output_postproc[255] = "geometry_fit_postproc.h5m";
46 double planar_angle_deg = 2.0;
47 double max_disp_factor = 0.3;
48 PetscBool write_postproc = PETSC_TRUE;
49 PetscBool debug_surfaces = PETSC_FALSE;
50
51
52 PetscOptionsBegin(m_field.
get_comm(),
"",
"geometry fit tool",
"none");
53 CHKERR PetscOptionsString(
"-coarse_file",
"coarse 3d mesh file name",
"",
54 coarse_file, coarse_file, 255, PETSC_NULLPTR);
55 CHKERR PetscOptionsString(
"-surface_file",
"fine surface mesh file name",
56 "", surface_file, surface_file, 255,
57 PETSC_NULLPTR);
58 CHKERR PetscOptionsString(
"-output_file",
"output mesh file name",
"",
59 output_file, output_file, 255, PETSC_NULLPTR);
60 CHKERR PetscOptionsString(
"-output_postproc",
61 "output postprocess mesh file name", "",
62 output_postproc, output_postproc, 255,
63 PETSC_NULLPTR);
65 "-planar_angle_deg",
66 "angle threshold in degrees to skip planar edges", "",
67 planar_angle_deg, &planar_angle_deg, PETSC_NULLPTR);
69 "-max_midnode_disp_factor",
70 "skip adjustment if |delta| > factor * edge length", "",
71 max_disp_factor, &max_disp_factor, PETSC_NULLPTR);
72 CHKERR PetscOptionsBool(
"-write_postproc",
73 "write postprocess mesh output", "",
74 write_postproc, &write_postproc, PETSC_NULLPTR);
75 CHKERR PetscOptionsBool(
"-debug",
76 "dump intermediate fine-surface feature VTKs", "",
77 debug_surfaces, &debug_surfaces, PETSC_NULLPTR);
78 PetscOptionsEnd();
79
82
83
84
87 CHKERR fine_moab.load_file(surface_file);
88
89
91 CHKERR coarse_moab.get_entities_by_dimension(0, 3, coarse_vols);
92 if (coarse_vols.empty()) {
94 "no 3d entities found in coarse mesh");
95 }
96
97
98
101 CHKERR fine_moab.get_entities_by_dimension(0, 3, fine_vols);
102 if (!fine_vols.empty()) {
103 Skinner fine_skinner(&fine_moab);
104 CHKERR fine_skinner.find_skin(0, fine_vols,
false, fine_tris);
105 } else {
106 CHKERR fine_moab.get_entities_by_dimension(0, 2, fine_tris);
107 }
108 if (fine_tris.empty()) {
110 "no surface triangles found in fine mesh");
111 }
112
113 bool has_geometry = false;
116 has_geometry = true;
118 }
119 simple->addDomainField(
"GEOMETRY",
H1, base, 3);
122
123 if (!has_geometry) {
126 }
127
128
130 m_field, fine_moab, fine_tris, "GEOMETRY", planar_angle_deg,
131 max_disp_factor, debug_surfaces);
133
134
135 CHKERR coarse_moab.write_file(output_file);
136 MOFEM_LOG(
"WORLD", Sev::inform) <<
"Wrote file " << output_file;
137 if (write_postproc) {
139
140 auto post_proc_mesh = boost::make_shared<moab::Core>();
141 auto post_proc_begin =
142 boost::make_shared<PostProcBrokenMeshInMoabBaseBegin>(m_field,
143 post_proc_mesh);
144 auto post_proc_end = boost::make_shared<PostProcBrokenMeshInMoabBaseEnd>(
145 m_field, post_proc_mesh);
146
149 auto post_proc_fe =
150 boost::make_shared<PostProcEleDomain>(m_field, post_proc_mesh);
152 "GEOMETRY");
153 auto x_ptr = boost::make_shared<MatrixDouble>();
154 post_proc_fe->getOpPtrVector().push_back(
157 post_proc_fe->getOpPtrVector().push_back(
new OpPPMap(
158 post_proc_fe->getPostProcMesh(), post_proc_fe->getMapGaussPts(), {},
159 {{"GEOMETRY", x_ptr}}, {}, {}));
160
161 pip->getDomainRhsFE() = post_proc_fe;
162
164 post_proc_begin->getFEMethod());
165 CHKERR pip->loopFiniteElements();
167 post_proc_end->getFEMethod());
168 CHKERR post_proc_end->writeFile(output_postproc);
170 << "Wrote postprocess mesh " << output_postproc;
171 }
172 }
174
176 return 0;
177}
void simple(double P1[], double P2[], double P3[], double c[], const int N)
ElementsAndOps< SPACE_DIM >::DomainEle DomainEle
#define CATCH_ERRORS
Catch errors.
@ AINSWORTH_LEGENDRE_BASE
Ainsworth Cole (Legendre) approx. base .
@ MOFEM_DATA_INCONSISTENCY
#define CHKERR
Inline error check.
PostProcEleByDim< SPACE_DIM >::PostProcEleDomain PostProcEleDomain
PetscErrorCode DMoFEMPostProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (problem)
PetscErrorCode DMRegister_MoFEM(const char sname[])
Register MoFEM problem.
PetscErrorCode DMoFEMPreProcessFiniteElements(DM dm, MoFEM::FEMethod *method)
execute finite element method for each element in dm (problem)
virtual const Field * get_field_structure(const std::string &name, enum MoFEMTypes bh=MF_EXIST) const =0
get field structure
virtual MoFEMErrorCode loop_entities(const std::string field_name, EntityMethod &method, Range const *const ents=nullptr, int verb=DEFAULT_VERBOSITY)=0
Loop over field entities.
virtual bool check_field(const std::string &name) const =0
check if field is in database
#define MOFEM_LOG(channel, severity)
Log.
#define MOFEM_LOG_TAG(channel, tag)
Tag channel.
#define MOFEM_LOG_CHANNEL(channel)
Set and reset channel.
virtual MoFEMErrorCode loop_dofs(const Problem *problem_ptr, const std::string &field_name, RowColData rc, DofMethod &method, int lower_rank, int upper_rank, int verb=DEFAULT_VERBOSITY)=0
Make a loop over dofs.
OpPostProcMapInMoab< SPACE_DIM, SPACE_DIM > OpPPMap
Add operators pushing bases from local to physical configuration.
virtual MPI_Comm & get_comm() const =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.
FieldApproximationBase getApproxBase() const
Get approximation basis type.
Specialization for double precision vector field values calculation.
Post post-proc data at points from hash maps.
PipelineManager interface.
MoFEM::VolumeElementForcesAndSourcesCore VolEle
Project edge mid-nodes onto a fine surface mesh using closest points.
Projection of edge entities with one mid-node on hierarchical basis.
Simple interface for fast problem set-up.
MoFEMErrorCode loadFile(const std::string options, const std::string mesh_file_name, LoadFileFunc loadFunc=defaultLoadFileFunc)
Load mesh file.
MoFEMErrorCode getInterface(IFACE *&iface) const
Get interface reference to pointer of interface.