47 int number_boundary = ess_tdof_list.
Size(),
52 for (
int i = 0; i < number_boundary; i++)
54 int idx = ess_tdof_list[i];
55 for (
int d = 0; d <
dim; d++)
57 bnd(i+d*number_boundary) = vxyz(idx + d*number_true);
59 colorv[i] = (
unsigned int)color;
67 for (
int i = 0; i < number_boundary; i++)
69 int idx = ess_tdof_list[i];
70 if (code_out[i] != 2) { ess_tdof_list_int.
Append(idx); }
74int main(
int argc,
char *argv[])
84 Array <const char *> mesh_file_list(lim_meshes);
85 Array <int> np_list(lim_meshes), rs_levels(lim_meshes),
86 rp_levels(lim_meshes);
87 mesh_file_list[0] =
"../../data/square-disc.mesh";
88 mesh_file_list[1] =
"../../data/inline-quad.mesh";
89 mesh_file_list[2] =
"../../data/inline-quad.mesh";
91 bool visualization =
true;
95 double rel_tol = 1.e-8;
99 args.
AddOption(&mesh_file_list[0],
"-m1",
"--mesh",
100 "Mesh file to use.");
101 args.
AddOption(&mesh_file_list[1],
"-m2",
"--mesh",
102 "Mesh file to use.");
103 args.
AddOption(&mesh_file_list[2],
"-m3",
"--mesh",
104 "Mesh file to use.");
106 "Finite element order (polynomial degree) or -1 for"
107 " isoparametric space.");
108 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
109 "--no-visualization",
110 "Enable or disable GLVis visualization.");
111 args.
AddOption(&rs_levels[0],
"-r1",
"--refine-serial",
112 "Number of times to refine the mesh 1 uniformly in serial.");
113 args.
AddOption(&rs_levels[1],
"-r2",
"--refine-serial",
114 "Number of times to refine the mesh 2 uniformly in serial.");
115 args.
AddOption(&rs_levels[2],
"-r3",
"--refine-serial",
116 "Number of times to refine the mesh 3 uniformly in serial.");
117 args.
AddOption(&rp_levels[0],
"-rp1",
"--refine-parallel",
118 "Number of times to refine the mesh 1 uniformly in parallel.");
119 args.
AddOption(&rp_levels[1],
"-rp2",
"--refine-parallel",
120 "Number of times to refine the mesh 2 uniformly in parallel.");
121 args.
AddOption(&rp_levels[2],
"-rp3",
"--refine-parallel",
122 "Number of times to refine the mesh 3 uniformly in parallel.");
123 args.
AddOption(&np_list[0],
"-np1",
"--np1",
124 "number of MPI ranks for mesh 1");
125 args.
AddOption(&np_list[1],
"-np2",
"--np2",
126 "number of MPI ranks for mesh 2");
127 args.
AddOption(&np_list[2],
"-np3",
"--np3",
128 "number of MPI ranks for mesh 3");
131 args.
AddOption(&rel_tol,
"-rt",
"--relative tolerance",
132 "Tolerance for Schwarz iteration convergence criterion.");
147 MFEM_VERIFY(num_procs >= nmeshes,
"Not enough MPI ranks.");
148 if (np_list.Sum() == 0)
150 int np_per_mesh = num_procs/nmeshes;
151 for (
int i = 0; i < nmeshes; i++)
153 np_list[i] = np_per_mesh;
155 np_list[nmeshes-1] += num_procs - nmeshes*np_per_mesh;
157 MFEM_VERIFY(np_list.Sum() == num_procs,
" The individual mpi ranks for each"
158 " of the meshes do not add up to the total ranks specified.");
161 MPI_Comm *comml =
new MPI_Comm;
164 for (
int i = 0; i < nmeshes; i++)
167 if (myid < npsum) { color = i;
break; }
170 MPI_Comm_split(MPI_COMM_WORLD, color, myid, comml);
171 int myidlocal, numproclocal;
172 MPI_Comm_rank(*comml, &myidlocal);
173 MPI_Comm_size(*comml, &numproclocal);
178 Mesh *mesh =
new Mesh(mesh_file_list[color], 1, 1);
190 pmesh =
new ParMesh(*comml, *mesh);
191 for (
int l = 0; l < rp_levels[color]; l++)
210 cout <<
"Using isoparametric FEs: " << fec->
Name() << endl;
221 cout <<
"Number of finite element unknowns: " << size << endl;
260 if (strcmp(mesh_file_list[0],
"../../data/square-disc.mesh") == 0 &&
261 strcmp(mesh_file_list[1],
"../../data/inline-quad.mesh") == 0 &&
262 strcmp(mesh_file_list[2],
"../../data/inline-quad.mesh") == 0 )
268 for (
int i = 0; i < vxyz.
Size(); i++)
270 vxyz(i) = 0.5 + 0.5*(vxyz(i)-0.5);
274 else if (nmeshes == 3)
279 const int pts_cnt = vxyz.
Size()/
dim;
280 for (
int i = 0; i < pts_cnt; i++)
282 vxyz(i) = 0.41 + 0.4*(vxyz(i)-0.5);
284 for (
int i = 0; i < pts_cnt; i++)
286 vxyz(i+pts_cnt) = 0.5 + 0.5*(vxyz(i+pts_cnt)-0.5);
292 const int pts_cnt = vxyz.
Size()/
dim;
293 for (
int i = 0; i < pts_cnt; i++)
295 vxyz(i) = 0.6 + 0.4*(vxyz(i)-0.5);
297 for (
int i = 0; i < pts_cnt; i++)
299 vxyz(i+pts_cnt) = 0.5 + 0.6*(vxyz(i+pts_cnt)-0.5);
312 finder.
Setup(*pmesh, color);
316 ess_tdof_list, ess_tdof_list_int,
dim);
320 const int number_boundary = ess_tdof_list_int.
Size(),
323 int number_boundary_g = number_boundary;
324 MPI_Allreduce(&number_boundary, &number_boundary_g, 1, MPI_INT, MPI_SUM,
326 MFEM_VERIFY(number_boundary_g != 0,
" Please use overlapping grids.");
329 colorv.
SetSize(number_boundary);
331 MPI_Barrier(MPI_COMM_WORLD);
333 for (
int i = 0; i < number_boundary; i++)
335 int idx = ess_tdof_list_int[i];
336 for (
int d = 0; d <
dim; d++)
338 bnd(i+d*number_boundary) = vxyz(idx + d*number_true);
340 colorv[i] = (
unsigned int)color;
342 Vector interp_vals1(number_boundary);
362 int NiterSchwarz = 100;
371 a->FormLinearSystem(ess_tdof_list, x, *
b, A, X, B);
393 double dxmax = std::numeric_limits<float>::min();
396 MPI_Allreduce(&xinf, &xinfg, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
399 for (
int i = 0; i < number_boundary; i++)
401 int idx = ess_tdof_list_int[i];
402 double dx = std::abs(xt(idx)-interp_vals1(i))/xinfg;
403 if (dx > dxmax) { dxmax = dx; }
404 xt(idx) = interp_vals1(i);
407 double dxmaxg = dxmax;
408 MPI_Allreduce(&dxmax, &dxmaxg, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD);
414 std::cout << std::setprecision(8) <<
416 ", Relative residual: " << dxmaxg << endl;
419 if (dxmaxg < rel_tol) {
break; }
428 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
429 sol_sock.precision(8);
430 sol_sock <<
"solution\n" << *pmesh << x << flush;
437 if (order > 0) {
delete fec; }
T Max() const
Find the maximal element in the array, using the comparison operator < for class T.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int Size() const
Return the logical size of the array.
int Append(const T &el)
Append element 'el' to array, resize if necessary.
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 .
virtual const Array< unsigned int > & GetCode() const
Collection of finite elements from the same family in multiple dimensions. This class is used to matc...
virtual const char * Name() const
void SetTrueVector()
Shortcut for calling GetTrueDofs() with GetTrueVector() as argument.
const Vector & GetTrueVector() const
Read only access to the (optional) internal true-dof Vector.
Arbitrary order H1-conforming (continuous) finite elements.
The BoomerAMG solver in hypre.
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.
int Dimension() const
Dimension of the reference space used within the elements.
void GetNodes(Vector &node_coord) const
void SetNodes(const Vector &node_coord)
Updates the vertex/node locations. Invokes NodesUpdated().
void UniformRefinement(int i, const DSTable &, int *, int *, int *)
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).
Pointer to an Operator of a specified type.
virtual void RecoverFEMSolution(const Vector &X, const Vector &b, Vector &x)
Reconstruct a solution vector x (e.g. a GridFunction) from the solution X of a constrained linear sys...
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.
OversetFindPointsGSLIB enables use of findpts for arbitrary number of overlapping grids....
void Setup(Mesh &m, const int meshid, GridFunction *gfmax=NULL, const double bb_t=0.1, const double newt_tol=1.0e-12, const int npt_max=256)
void Interpolate(const Vector &point_pos, Array< unsigned int > &point_id, const GridFunction &field_in, Vector &field_out, int point_pos_ordering=Ordering::byNODES)
void FindPoints(const Vector &point_pos, Array< unsigned int > &point_id, int point_pos_ordering=Ordering::byNODES)
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
Class for parallel grid function.
void SetFromTrueDofs(const Vector &tv) override
Set the GridFunction from the given true-dof vector.
Class for parallel meshes.
void SetCurvature(int order, bool discont=false, int space_dim=-1, int ordering=1) override
Set the curvature of the mesh nodes using the given polynomial degree.
real_t Normlinf() const
Returns the l_infinity norm of the vector.
int Size() const
Returns the size of the vector.
struct schwarz_common schwarz
void GetInterdomainBoundaryPoints(OversetFindPointsGSLIB &finder, Vector &vxyz, int color, Array< int > ess_tdof_list, Array< int > &ess_tdof_list_int, int dim)