51 #include "../../general/text.hpp"
53 #ifdef MFEM_USE_SIMMETRIX
60 #include <apfConvert.h>
67 int main(
int argc,
char *argv[])
71 MPI_Init(&argc, &argv);
72 MPI_Comm_size(MPI_COMM_WORLD, &num_proc);
73 MPI_Comm_rank(MPI_COMM_WORLD, &myId);
76 const char *mesh_file =
"../../data/pumi/serial/pillbox.smb";
77 const char *boundary_file =
"../../data/pumi/serial/boundary.mesh";
78 #ifdef MFEM_USE_SIMMETRIX
79 const char *model_file =
"../../data/pumi/geom/pillbox.smd";
81 const char *model_file =
"../../data/pumi/geom/pillbox.dmg";
84 bool static_cond =
false;
85 bool visualization = 1;
89 args.
AddOption(&mesh_file,
"-m",
"--mesh",
92 "Finite element order (polynomial degree).");
93 args.
AddOption(&static_cond,
"-sc",
"--static-condensation",
"-no-sc",
94 "--no-static-condensation",
"Enable static condensation.");
95 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
97 "Enable or disable GLVis visualization.");
98 args.
AddOption(&model_file,
"-p",
"--parasolid",
99 "Parasolid model to use.");
100 args.
AddOption(&geom_order,
"-go",
"--geometry_order",
101 "Geometric order of the model");
102 args.
AddOption(&boundary_file,
"-bf",
"--txt",
103 "txt file containing boundary tags");
114 #ifdef MFEM_USE_SIMMETRIX
115 Sim_readLicenseFile(0);
121 apf::Mesh2* pumi_mesh;
122 pumi_mesh = apf::loadMdsMesh(model_file, mesh_file);
127 crv::BezierCurver bc(pumi_mesh, geom_order, 0);
136 getline(input_bdr, bdr_tags);
138 cout <<
" the boundary tag is : " << bdr_tags << endl;
141 if (bdr_tags ==
"Dirichlet")
143 input_bdr >> numOfent;
144 cout <<
" num of Dirichlet bdr conditions : " << numOfent << endl;
146 for (
int kk = 0; kk < numOfent; kk++)
148 input_bdr >> Dirichlet[kk];
155 input_bdr >> bdr_tags;
157 cout <<
" the boundary tag is : " << bdr_tags << endl;
158 if (bdr_tags ==
"Load")
160 input_bdr >> numOfent;
162 cout <<
" num of load bdr conditions : " << numOfent << endl;
163 for (
int kk = 0; kk < numOfent; kk++)
165 input_bdr >> load_bdr[kk];
177 apf::MeshIterator* itr = pumi_mesh->begin(dim-1);
178 apf::MeshEntity* ent ;
180 while ((ent = pumi_mesh->iterate(itr)))
182 apf::ModelEntity *me = pumi_mesh->toModel(ent);
183 if (pumi_mesh->getModelType(me) == (dim-1))
187 int tag = pumi_mesh->getModelTag(me);
188 if (Dirichlet.
Find(tag) != -1)
193 else if (load_bdr.
Find(tag) != -1)
206 for (
int el = 0; el < mesh->
GetNE(); el++)
210 if (cent(0) <= -0.05)
214 else if (cent(0) >= 0.05)
226 cerr <<
"\nInput mesh should have at least two materials and "
227 <<
"two boundary attributes! (See schematic in ex2.cpp)\n"
238 (int)floor(log(5000./mesh->
GetNE())/log(2.)/
dim);
239 for (
int l = 0; l < ref_levels; l++)
255 fespace = mesh->
GetNodes()->FESpace();
262 cout <<
"Number of finite element unknowns: " << fespace->
GetTrueVSize()
263 << endl <<
"Assembling: " << flush;
283 for (
int i = 0; i < dim-1; i++)
290 pull_force(1) = -3.0e-2;
297 cout <<
"r.h.s. ... " << flush;
311 lambda(0) = lambda(1)*10;
312 lambda(1) = lambda(1)*100;
327 cout <<
"matrix ... " << flush;
334 cout <<
"done." << endl;
336 cout <<
"Size of linear system: " << A.
Height() << endl;
338 #ifndef MFEM_USE_SUITESPARSE
342 PCG(A, M, B, X, 1, 500, 1e-8, 0.0);
346 umf_solver.
Control[UMFPACK_ORDERING] = UMFPACK_ORDERING_METIS;
348 umf_solver.
Mult(B, X);
373 ofstream mesh_ofs(
"displaced.mesh");
374 mesh_ofs.precision(8);
375 mesh->
Print(mesh_ofs);
376 ofstream sol_ofs(
"sol.gf");
377 sol_ofs.precision(8);
385 char vishost[] =
"localhost";
388 sol_sock.precision(8);
389 sol_sock <<
"solution\n" << *mesh << x << flush;
402 pumi_mesh->destroyNative();
403 apf::destroyMesh(pumi_mesh);
405 #ifdef MFEM_USE_SIMMETRIX
407 Sim_unregisterAllKeys();
virtual void Print(std::ostream &out=mfem::out) const
Vector coefficient defined by an array of scalar coefficients.
Class for grid function - Vector with associated FE space.
Subclass constant coefficient.
virtual void GetEssentialTrueDofs(const Array< int > &bdr_attr_is_ess, Array< int > &ess_tdof_list, int component=-1)
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.
int main(int argc, char *argv[])
Geometry::Type GetElementBaseGeometry(int i) const
void skip_comment_lines(std::istream &is, const char comment_char)
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.
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.
void SetNodalFESpace(FiniteElementSpace *nfes)
void PrintUsage(std::ostream &out) const
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...
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)
void SetSize(int nsize)
Change logical size of the array, keep existing entries.
NURBSExtension * NURBSext
Optional NURBS mesh extension.
class for piecewise constant coefficient
void GetElementTransformation(int i, IsoparametricTransformation *ElTr)
void PrintOptions(std::ostream &out) const
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)
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
virtual void SetOperator(const Operator &op)
Factorize the given Operator op which must be a SparseMatrix.