33#ifdef MFEM_USE_SIMMETRIX
41#include <apfConvert.h>
46#error This example requires that MFEM is built with MFEM_USE_PUMI=YES
52int main(
int argc,
char *argv[])
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;
223 cout <<
"Unable to connect to GLVis server at "
225 cout <<
"GLVis visualization disabled.\n";
227 visualization =
false;
243 if (static_cond) {
a->EnableStaticCondensation(); }
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;
279 a->FormLinearSystem(ess_tdof_list, x, *
b, A, X, B, copy_interior);
295 a->RecoverFEMSolution(X, *
b, x);
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();
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
int Size() const
Return the logical size of the array.
Conjugate gradient method.
virtual void SetOperator(const Operator &op)
Also calls SetOperator for the preconditioner if there is one.
virtual void Mult(const Vector &b, Vector &x) const
Iterative solution of the linear system using the Conjugate Gradient method.
A coefficient that is constant across space and time.
Class for domain integration .
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
virtual const char * Name() const
Arbitrary order H1-conforming (continuous) finite elements.
The BoomerAMG solver in hypre.
void SetPrintLevel(int print_level)
Wrapper for hypre's ParCSR matrix class.
MPI_Comm GetComm() const
MPI communicator.
static void Init()
Initialize hypre by calling HYPRE_Init() and set default options. After calling Hypre::Init(),...
void SetRelTol(real_t rtol)
virtual void SetPreconditioner(Solver &pr)
This should be called before SetOperator.
virtual void SetPrintLevel(int print_lvl)
Legacy method to set the level of verbosity of the solver output.
void SetMaxIter(int max_it)
Array< int > bdr_attributes
A list of all unique boundary attributes used by the Mesh.
void GetNodes(Vector &node_coord) const
static int WorldRank()
Return the MPI rank in MPI_COMM_WORLD.
static int WorldSize()
Return the size of MPI_COMM_WORLD.
static void Init(int &argc, char **&argv, int required=default_thread_required, int *provided=nullptr)
Singleton creation with Mpi::Init(argc, argv).
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
void PrintUsage(std::ostream &out) const
Print the usage message.
void PrintOptions(std::ostream &out) const
Print the options.
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...
bool Good() const
Return true if the command line options were parsed successfully.
Abstract parallel finite element space.
void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1) const override
HYPRE_BigInt GlobalTrueVSize() const
void Update(bool want_transform=true) override
Class for parallel grid function.
void Save(std::ostream &out) const override
void Update() override
Transform by the Space UpdateMatrix (e.g., on Mesh change).
Class for parallel meshes.
void Print(std::ostream &out=mfem::out, const std::string &comments="") const override
Class for PUMI parallel meshes.
void FieldPUMItoMFEM(apf::Mesh2 *apf_mesh, apf::Field *field, ParGridFunction *grid)
Transfer a field from PUMI to MFEM after mesh adapt [Scalar and Vector].
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].
void UpdateMesh(const ParMesh *AdaptedpMesh)
Update the mesh after adaptation.
int open(const char hostname[], int port)
Open the socket stream on 'port' at 'hostname'.