59 #include "../../general/text.hpp"
61 #ifdef MFEM_USE_SIMMETRIX
68 #include <apfConvert.h>
73 #error This example requires that MFEM is built with MFEM_USE_PUMI=YES
79 int main(
int argc,
char *argv[])
82 Mpi::Init(argc, argv);
83 int num_proc = Mpi::WorldSize();
84 int myId = Mpi::WorldRank();
88 const char *mesh_file =
"../../data/pumi/serial/pillbox.smb";
89 const char *boundary_file =
"../../data/pumi/serial/boundary.mesh";
90 #ifdef MFEM_USE_SIMMETRIX
91 const char *model_file =
"../../data/pumi/geom/pillbox.smd";
93 const char *model_file =
"../../data/pumi/geom/pillbox.dmg";
96 bool static_cond =
false;
97 bool visualization = 1;
101 args.
AddOption(&mesh_file,
"-m",
"--mesh",
102 "Mesh file to use.");
104 "Finite element order (polynomial degree).");
105 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
106 "--no-static-condensation",
"Enable static condensation.");
107 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
108 "--no-visualization",
109 "Enable or disable GLVis visualization.");
110 args.
AddOption(&model_file,
"-p",
"--parasolid",
111 "Parasolid model to use.");
112 args.
AddOption(&geom_order,
"-go",
"--geometry_order",
113 "Geometric order of the model");
114 args.
AddOption(&boundary_file,
"-bf",
"--txt",
115 "txt file containing boundary tags");
126 #ifdef MFEM_USE_SIMMETRIX
127 Sim_readLicenseFile(0);
133 apf::Mesh2* pumi_mesh;
134 pumi_mesh = apf::loadMdsMesh(model_file, mesh_file);
139 crv::BezierCurver bc(pumi_mesh, geom_order, 0);
148 getline(input_bdr, bdr_tags);
150 cout <<
" the boundary tag is : " << bdr_tags << endl;
153 if (bdr_tags ==
"Dirichlet")
155 input_bdr >> numOfent;
156 cout <<
" num of Dirichlet bdr conditions : " << numOfent << endl;
158 for (
int kk = 0; kk < numOfent; kk++)
160 input_bdr >> Dirichlet[kk];
167 input_bdr >> bdr_tags;
169 cout <<
" the boundary tag is : " << bdr_tags << endl;
170 if (bdr_tags ==
"Load")
172 input_bdr >> numOfent;
174 cout <<
" num of load bdr conditions : " << numOfent << endl;
175 for (
int kk = 0; kk < numOfent; kk++)
177 input_bdr >> load_bdr[kk];
189 apf::MeshIterator* itr = pumi_mesh->begin(dim-1);
190 apf::MeshEntity* ent ;
192 while ((ent = pumi_mesh->iterate(itr)))
194 apf::ModelEntity *me = pumi_mesh->toModel(ent);
195 if (pumi_mesh->getModelType(me) == (dim-1))
199 int tag = pumi_mesh->getModelTag(me);
200 if (Dirichlet.
Find(tag) != -1)
205 else if (load_bdr.
Find(tag) != -1)
218 for (
int el = 0; el < mesh->
GetNE(); el++)
222 if (cent(0) <= -0.05)
226 else if (cent(0) >= 0.05)
238 cerr <<
"\nInput mesh should have at least two materials and "
239 <<
"two boundary attributes! (See schematic in ex2.cpp)\n"
250 (int)floor(log(5000./mesh->
GetNE())/log(2.)/
dim);
251 for (
int l = 0; l < ref_levels; l++)
267 fespace = mesh->
GetNodes()->FESpace();
274 cout <<
"Number of finite element unknowns: " << fespace->
GetTrueVSize()
275 << endl <<
"Assembling: " << flush;
295 for (
int i = 0; i < dim-1; i++)
302 pull_force(1) = -3.0e-2;
309 cout <<
"r.h.s. ... " << flush;
323 lambda(0) = lambda(1)*10;
324 lambda(1) = lambda(1)*100;
339 cout <<
"matrix ... " << flush;
346 cout <<
"done." << endl;
348 cout <<
"Size of linear system: " << A.
Height() << endl;
350 #ifndef MFEM_USE_SUITESPARSE
354 PCG(A, M, B, X, 1, 500, 1e-8, 0.0);
358 umf_solver.
Control[UMFPACK_ORDERING] = UMFPACK_ORDERING_METIS;
360 umf_solver.
Mult(B, X);
385 ofstream mesh_ofs(
"displaced.mesh");
386 mesh_ofs.precision(8);
387 mesh->
Print(mesh_ofs);
388 ofstream sol_ofs(
"sol.gf");
389 sol_ofs.precision(8);
400 sol_sock.precision(8);
401 sol_sock <<
"solution\n" << *mesh << x << flush;
414 pumi_mesh->destroyNative();
415 apf::destroyMesh(pumi_mesh);
417 #ifdef MFEM_USE_SIMMETRIX
419 Sim_unregisterAllKeys();
Vector coefficient defined by an array of scalar coefficients. Coefficients that are not set will eva...
Class for grid function - Vector with associated FE space.
A coefficient that is constant across space and time.
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
Get a list of essential true dofs, ess_tdof_list, corresponding to the boundary attributes marked in ...
int GetNE() const
Returns number of elements.
Base class for PUMI meshes.
const IntegrationPoint & GetCenter(int GeomType)
Return the center of the given Geometry::Type, GeomType.
Geometry::Type GetElementBaseGeometry(int i) const
void skip_comment_lines(std::istream &is, const char comment_char)
Check if the stream starts with comment_char. If so skip it.
Data type for Gauss-Seidel smoother of sparse matrix.
Direct sparse solver using UMFPACK.
virtual void Save(std::ostream &out) const
Save the GridFunction to an output stream.
void Parse()
Parse the command-line options. Note that this function expects all the options provided through the ...
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
virtual void SetAttributes()
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void Set(int i, Coefficient *c, bool own=true)
Sets coefficient in the vector.
void PCG(const Operator &A, Solver &B, const Vector &b, Vector &x, int print_iter, int max_num_iter, double RTOLERANCE, double ATOLERANCE)
Preconditioned conjugate gradient method. (tolerances are squared)
virtual int GetTrueVSize() const
Return the number of vector true (conforming) dofs.
virtual void SetNodalFESpace(FiniteElementSpace *nfes)
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.
double Control[UMFPACK_CONTROL]
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
int Find(const T &el) const
Return the first index where 'el' is found; return -1 if not found.
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 SetSize(int nsize)
Change the logical size of the array, keep existing entries.
NURBSExtension * NURBSext
Optional NURBS mesh extension.
A piecewise constant coefficient with the constants keyed off the element attribute numbers...
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
virtual void Print(std::ostream &os=mfem::out) const
void PrintOptions(std::ostream &out) const
Print the options.
void Print(std::ostream &out=mfem::out, int width=4) const
Prints array to stream with width elements per row.
void filter_dos(std::string &line)
Check for, and remove, a trailing '\r' from and std::string.
void SetAttribute(int i, int attr)
Set the attribute of element i.
void GetNodes(Vector &node_coord) const
Arbitrary order H1-conforming (continuous) finite elements.
Array< int > attributes
A list of all unique element attributes used by the Mesh.
virtual void Mult(const Vector &b, Vector &x) const
Operator application: y=A(x).
const Element * GetBdrElement(int i) const
double f(const Vector &p)
virtual void SetOperator(const Operator &op)
Factorize the given Operator op which must be a SparseMatrix.
bool Good() const
Return true if the command line options were parsed successfully.