26 #ifdef MFEM_USE_SIMMETRIX
34 #include <apfConvert.h>
41 int main(
int argc,
char *argv[])
45 MPI_Init(&argc, &argv);
46 MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
47 MPI_Comm_rank(MPI_COMM_WORLD, &myid);
50 const char *mesh_file =
"../../data/pumi/parallel/Kova/Kova100k_8.smb";
51 #ifdef MFEM_USE_SIMMETRIX
52 const char *model_file =
"../../data/pumi/geom/Kova.x_t";
53 const char *smd_file = NULL;
55 const char *model_file =
"../../data/pumi/geom/Kova.dmg";
58 bool static_cond =
false;
59 bool visualization = 1;
61 double adapt_ratio = 0.05;
64 args.
AddOption(&mesh_file,
"-m",
"--mesh",
67 "Finite element order (polynomial degree) or -1 for"
68 " isoparametric space.");
69 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
70 "--no-static-condensation",
"Enable static condensation.");
71 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
73 "Enable or disable GLVis visualization.");
74 args.
AddOption(&model_file,
"-p",
"--model",
75 "parasolid or .dmg model to use.");
76 #ifdef MFEM_USE_SIMMETRIX
77 args.
AddOption(&smd_file,
"-sm",
"--smd_model",
78 "smd model file to use.");
80 args.
AddOption(&geom_order,
"-go",
"--geometry_order",
81 "Geometric order of the model");
82 args.
AddOption(&adapt_ratio,
"-ar",
"--adapt_ratio",
83 "adaptation factor used in MeshAdapt");
101 #ifdef MFEM_USE_SIMMETRIX
102 Sim_readLicenseFile(0);
108 apf::Mesh2* pumi_mesh;
109 #ifdef MFEM_USE_SIMMETRIX
112 gmi_model *mixed_model = gmi_sim_load(model_file, smd_file);
113 pumi_mesh = apf::loadMdsMesh(mixed_model, mesh_file);
118 pumi_mesh = apf::loadMdsMesh(model_file, mesh_file);
124 int dim = pumi_mesh->getDimension();
125 int nEle = pumi_mesh->count(dim);
126 int ref_levels = (int)floor(log(100000./nEle)/log(2.)/
dim);
130 crv::BezierCurver bc(pumi_mesh, geom_order, 2);
137 std::cout <<
" ref level : " << ref_levels << std::endl;
142 ma::Input* uniInput = ma::configureUniformRefine(pumi_mesh, ref_levels);
146 crv::adapt(uniInput);
174 cout <<
"Using isoparametric FEs: " << fec->
Name() << endl;
185 cout <<
"Number of finite element unknowns: " << size << endl;
202 char vishost[] =
"localhost";
208 sout.
open(vishost, visport);
213 cout <<
"Unable to connect to GLVis server at "
214 << vishost <<
':' << visport << endl;
215 cout <<
"GLVis visualization disabled.\n";
217 visualization =
false;
237 apf::Field* Tmag_field = 0;
238 apf::Field* temp_field = 0;
239 apf::Field* ipfield = 0;
240 apf::Field* sizefield = 0;
243 for (
int Itr = 0; Itr < max_iter; Itr++)
248 cout <<
"\nAMR iteration " << Itr << endl;
249 cout <<
"Number of unknowns: " << global_dofs << endl;
268 const int copy_interior = 1;
280 pcg.SetPrintLevel(3);
291 ostringstream mesh_name, sol_name;
292 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
293 sol_name <<
"sol." << setfill(
'0') << setw(6) << myid;
295 ofstream mesh_ofs(mesh_name.str().c_str());
296 mesh_ofs.precision(8);
297 pmesh->
Print(mesh_ofs);
299 ofstream sol_ofs(sol_name.str().c_str());
300 sol_ofs.precision(8);
308 sout <<
"parallel " << num_procs <<
" " << myid <<
"\n";
309 sout <<
"solution\n" << *pmesh << x << flush;
314 if (order > geom_order)
316 Tmag_field = apf::createField(pumi_mesh,
"field_mag",
317 apf::SCALAR, apf::getLagrange(order));
318 temp_field = apf::createField(pumi_mesh,
"T_field",
319 apf::SCALAR, apf::getLagrange(order));
323 Tmag_field = apf::createFieldOn(pumi_mesh,
"field_mag",apf::SCALAR);
324 temp_field = apf::createFieldOn(pumi_mesh,
"T_field", apf::SCALAR);
330 ipfield= spr::getGradIPField(Tmag_field,
"MFEM_gradip", 2);
331 sizefield = spr::getSPRSizeField(ipfield, adapt_ratio);
333 apf::destroyField(Tmag_field);
334 apf::destroyField(ipfield);
335 apf::destroyNumbering(pumi_mesh->findNumbering(
"LocalVertexNumbering"));
338 ma::Input* erinput = ma::configure(pumi_mesh, sizefield);
339 erinput->shouldFixShape =
true;
340 erinput->maximumIterations = 2;
364 apf::destroyField(temp_field);
365 apf::destroyField(sizefield);
372 if (order > 0) {
delete fec; }
375 pumi_mesh->destroyNative();
376 apf::destroyMesh(pumi_mesh);
379 #ifdef MFEM_USE_SIMMETRIX
381 Sim_unregisterAllKeys();
void FieldPUMItoMFEM(apf::Mesh2 *apf_mesh, apf::Field *ScalarField, ParGridFunction *Pr)
Transfer a field from PUMI to MFEM after mesh adapt [Scalar].
int Size() const
Logical size of the array.
void UpdateMesh(const ParMesh *AdaptedpMesh)
Update the mesh after adaptation.
Class for domain integration L(v) := (f, v)
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
Conjugate gradient method.
MPI_Comm GetComm() const
MPI communicator.
Subclass constant coefficient.
virtual void Update(bool want_transform=true)
virtual void Save(std::ostream &out) const
Abstract parallel finite element space.
int main(int argc, char *argv[])
Class for PUMI parallel meshes.
The BoomerAMG solver in hypre.
virtual void Update()
Transform by the Space UpdateMatrix (e.g., on Mesh change).
void SetPrintLevel(int print_level)
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
HYPRE_Int GlobalTrueVSize() const
virtual void Print(std::ostream &out=mfem::out) const
void FieldMFEMtoPUMI(apf::Mesh2 *apf_mesh, ParGridFunction *Vel, ParGridFunction *Pr, apf::Field *VelField, apf::Field *PrField, apf::Field *VelMagField)
Transfer field from MFEM mesh to PUMI mesh [Mixed].
void PrintUsage(std::ostream &out) const
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void AddOption(bool *var, const char *enable_short_name, const char *enable_long_name, const char *disable_short_name, const char *disable_long_name, const char *description, bool required=false)
virtual const char * Name() const
void PrintOptions(std::ostream &out) const
int open(const char hostname[], int port)
void GetNodes(Vector &node_coord) const
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Arbitrary order H1-conforming (continuous) finite elements.
Class for parallel grid function.
Wrapper for hypre's ParCSR matrix class.
Class for parallel meshes.