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[])
56 MPI_Init(&argc, &argv);
57 MPI_Comm_size(MPI_COMM_WORLD, &num_procs);
58 MPI_Comm_rank(MPI_COMM_WORLD, &myid);
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");
112 #ifdef MFEM_USE_SIMMETRIX
113 Sim_readLicenseFile(0);
119 apf::Mesh2* pumi_mesh;
120 #ifdef MFEM_USE_SIMMETRIX
123 gmi_model *mixed_model = gmi_sim_load(model_file, smd_file);
124 pumi_mesh = apf::loadMdsMesh(mixed_model, mesh_file);
129 pumi_mesh = apf::loadMdsMesh(model_file, mesh_file);
135 int dim = pumi_mesh->getDimension();
136 int nEle = pumi_mesh->count(dim);
137 int ref_levels = (int)floor(log(100000./nEle)/log(2.)/
dim);
141 crv::BezierCurver bc(pumi_mesh, geom_order, 2);
148 std::cout <<
" ref level : " << ref_levels << std::endl;
153 ma::Input* uniInput = ma::configureUniformRefine(pumi_mesh, ref_levels);
157 crv::adapt(uniInput);
185 cout <<
"Using isoparametric FEs: " << fec->
Name() << endl;
196 cout <<
"Number of finite element unknowns: " << size << endl;
219 sout.
open(vishost, visport);
224 cout <<
"Unable to connect to GLVis server at "
225 << vishost <<
':' << visport << endl;
226 cout <<
"GLVis visualization disabled.\n";
228 visualization =
false;
248 apf::Field* Tmag_field = 0;
249 apf::Field* temp_field = 0;
250 apf::Field* ipfield = 0;
251 apf::Field* sizefield = 0;
254 for (
int Itr = 0; Itr < max_iter; Itr++)
259 cout <<
"\nAMR iteration " << Itr << endl;
260 cout <<
"Number of unknowns: " << global_dofs << endl;
279 const int copy_interior = 1;
291 pcg.SetPrintLevel(3);
302 ostringstream mesh_name, sol_name;
303 mesh_name <<
"mesh." << setfill(
'0') << setw(6) << myid;
304 sol_name <<
"sol." << setfill(
'0') << setw(6) << myid;
306 ofstream mesh_ofs(mesh_name.str().c_str());
307 mesh_ofs.precision(8);
308 pmesh->
Print(mesh_ofs);
310 ofstream sol_ofs(sol_name.str().c_str());
311 sol_ofs.precision(8);
319 sout <<
"parallel " << num_procs <<
" " << myid <<
"\n";
320 sout <<
"solution\n" << *pmesh << x << flush;
325 if (order > geom_order)
327 Tmag_field = apf::createField(pumi_mesh,
"field_mag",
328 apf::SCALAR, apf::getLagrange(order));
329 temp_field = apf::createField(pumi_mesh,
"T_field",
330 apf::SCALAR, apf::getLagrange(order));
334 Tmag_field = apf::createFieldOn(pumi_mesh,
"field_mag",apf::SCALAR);
335 temp_field = apf::createFieldOn(pumi_mesh,
"T_field", apf::SCALAR);
341 ipfield= spr::getGradIPField(Tmag_field,
"MFEM_gradip", 2);
342 sizefield = spr::getSPRSizeField(ipfield, adapt_ratio);
344 apf::destroyField(Tmag_field);
345 apf::destroyField(ipfield);
348 ma::Input* erinput = ma::configure(pumi_mesh, sizefield);
349 erinput->shouldFixShape =
true;
350 erinput->maximumIterations = 2;
374 apf::destroyField(temp_field);
375 apf::destroyField(sizefield);
382 if (order > 0) {
delete fec; }
385 pumi_mesh->destroyNative();
386 apf::destroyMesh(pumi_mesh);
389 #ifdef MFEM_USE_SIMMETRIX
391 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)
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].
int main(int argc, char *argv[])
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.
HYPRE_Int GlobalTrueVSize() const
virtual void Print(std::ostream &out=mfem::out) const
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.
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.