33 #ifdef MFEM_USE_SIMMETRIX
41 #include <apfConvert.h>
46 #error This example requires that MFEM is built with MFEM_USE_PUMI=YES
52 int main(
int argc,
char *argv[])
55 Mpi::Init(argc, argv);
56 int num_procs = Mpi::WorldSize();
57 int myid = Mpi::WorldRank();
61 const char *mesh_file =
"../../data/pumi/parallel/Kova/Kova100k_8.smb";
62 #ifdef MFEM_USE_SIMMETRIX
63 const char *model_file =
"../../data/pumi/geom/Kova.x_t";
64 const char *smd_file = NULL;
66 const char *model_file =
"../../data/pumi/geom/Kova.dmg";
69 bool static_cond =
false;
70 bool visualization = 1;
72 double adapt_ratio = 0.05;
75 args.
AddOption(&mesh_file,
"-m",
"--mesh",
78 "Finite element order (polynomial degree) or -1 for"
79 " isoparametric space.");
80 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
81 "--no-static-condensation",
"Enable static condensation.");
82 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
84 "Enable or disable GLVis visualization.");
85 args.
AddOption(&model_file,
"-p",
"--model",
86 "parasolid or .dmg model to use.");
87 #ifdef MFEM_USE_SIMMETRIX
88 args.
AddOption(&smd_file,
"-sm",
"--smd_model",
89 "smd model file to use.");
91 args.
AddOption(&geom_order,
"-go",
"--geometry_order",
92 "Geometric order of the model");
93 args.
AddOption(&adapt_ratio,
"-ar",
"--adapt_ratio",
94 "adaptation factor used in MeshAdapt");
111 #ifdef MFEM_USE_SIMMETRIX
112 Sim_readLicenseFile(0);
118 apf::Mesh2* pumi_mesh;
119 #ifdef MFEM_USE_SIMMETRIX
122 gmi_model *mixed_model = gmi_sim_load(model_file, smd_file);
123 pumi_mesh = apf::loadMdsMesh(mixed_model, mesh_file);
128 pumi_mesh = apf::loadMdsMesh(model_file, mesh_file);
134 int dim = pumi_mesh->getDimension();
135 int nEle = pumi_mesh->count(dim);
136 int ref_levels = (int)floor(log(100000./nEle)/log(2.)/
dim);
140 crv::BezierCurver bc(pumi_mesh, geom_order, 2);
147 std::cout <<
" ref level : " << ref_levels << std::endl;
152 auto uniInput = ma::configureUniformRefine(pumi_mesh, ref_levels);
156 crv::adapt(uniInput);
184 cout <<
"Using isoparametric FEs: " << fec->
Name() << endl;
195 cout <<
"Number of finite element unknowns: " << size << endl;
218 sout.
open(vishost, visport);
223 cout <<
"Unable to connect to GLVis server at "
224 << vishost <<
':' << visport << endl;
225 cout <<
"GLVis visualization disabled.\n";
227 visualization =
false;
247 apf::Field* Tmag_field = 0;
248 apf::Field* temp_field = 0;
249 apf::Field* ipfield = 0;
250 apf::Field* sizefield = 0;
253 for (
int Itr = 0; Itr < max_iter; Itr++)
258 cout <<
"\nAMR iteration " << Itr << endl;
259 cout <<
"Number of unknowns: " << global_dofs << endl;
278 const int copy_interior = 1;
290 pcg.SetPrintLevel(3);
301 ostringstream mesh_name, sol_name;
302 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
303 sol_name <<
"sol." << setfill(
'0') << setw(6) << myid;
305 ofstream mesh_ofs(mesh_name.str().c_str());
306 mesh_ofs.precision(8);
307 pmesh->
Print(mesh_ofs);
309 ofstream sol_ofs(sol_name.str().c_str());
310 sol_ofs.precision(8);
318 sout <<
"parallel " << num_procs <<
" " << myid <<
"\n";
319 sout <<
"solution\n" << *pmesh << x << flush;
324 if (order > geom_order)
326 Tmag_field = apf::createField(pumi_mesh,
"field_mag",
327 apf::SCALAR, apf::getLagrange(order));
328 temp_field = apf::createField(pumi_mesh,
"T_field",
329 apf::SCALAR, apf::getLagrange(order));
333 Tmag_field = apf::createFieldOn(pumi_mesh,
"field_mag",apf::SCALAR);
334 temp_field = apf::createFieldOn(pumi_mesh,
"T_field", apf::SCALAR);
340 ipfield= spr::getGradIPField(Tmag_field,
"MFEM_gradip", 2);
341 sizefield = spr::getSPRSizeField(ipfield, adapt_ratio);
343 apf::destroyField(Tmag_field);
344 apf::destroyField(ipfield);
347 auto erinput = ma::configure(pumi_mesh, sizefield);
371 apf::destroyField(temp_field);
372 apf::destroyField(sizefield);
379 if (order > 0) {
delete fec; }
382 pumi_mesh->destroyNative();
383 apf::destroyMesh(pumi_mesh);
386 #ifdef MFEM_USE_SIMMETRIX
388 Sim_unregisterAllKeys();
int Size() const
Return the 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.
A coefficient that is constant across space and time.
virtual void Update(bool want_transform=true)
HYPRE_BigInt GlobalTrueVSize() const
virtual void Save(std::ostream &out) const
Abstract parallel finite element space.
void FieldMFEMtoPUMI(apf::Mesh2 *apf_mesh, ParGridFunction *grid_vel, ParGridFunction *grid_pr, apf::Field *vel_field, apf::Field *pr_field, apf::Field *vel_mag_field)
Transfer field from MFEM mesh to PUMI mesh [Mixed].
Class for PUMI parallel meshes.
The BoomerAMG solver in hypre.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
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.
void PrintUsage(std::ostream &out) const
Print the usage message.
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
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)
Add a boolean option and set 'var' to receive the value. Enable/disable tags are used to set the bool...
void FieldPUMItoMFEM(apf::Mesh2 *apf_mesh, apf::Field *field, ParGridFunction *grid)
Transfer a field from PUMI to MFEM after mesh adapt [Scalar and Vector].
virtual const char * Name() const
void PrintOptions(std::ostream &out) const
Print the options.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.
void GetNodes(Vector &node_coord) const
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
Arbitrary order H1-conforming (continuous) finite elements.
void Print(std::ostream &out=mfem::out) const override
Class for parallel grid function.
Wrapper for hypre's ParCSR matrix class.
Class for parallel meshes.
bool Good() const
Return true if the command line options were parsed successfully.