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;
100 args.
AddOption(&mesh_file_list[0],
"-m1",
"--mesh",
101 "Mesh file to use.");
102 args.
AddOption(&mesh_file_list[1],
"-m2",
"--mesh",
103 "Mesh file to use.");
104 args.
AddOption(&mesh_file_list[2],
"-m3",
"--mesh",
105 "Mesh file to use.");
107 "Finite element order (polynomial degree) or -1 for"
108 " isoparametric space.");
109 args.
AddOption(&visualization,
"-vis",
"--visualization",
"-no-vis",
110 "--no-visualization",
111 "Enable or disable GLVis visualization.");
112 args.
AddOption(&rs_levels[0],
"-r1",
"--refine-serial",
113 "Number of times to refine the mesh 1 uniformly in serial.");
114 args.
AddOption(&rs_levels[1],
"-r2",
"--refine-serial",
115 "Number of times to refine the mesh 2 uniformly in serial.");
116 args.
AddOption(&rs_levels[2],
"-r3",
"--refine-serial",
117 "Number of times to refine the mesh 3 uniformly in serial.");
118 args.
AddOption(&rp_levels[0],
"-rp1",
"--refine-parallel",
119 "Number of times to refine the mesh 1 uniformly in parallel.");
120 args.
AddOption(&rp_levels[1],
"-rp2",
"--refine-parallel",
121 "Number of times to refine the mesh 2 uniformly in parallel.");
122 args.
AddOption(&rp_levels[2],
"-rp3",
"--refine-parallel",
123 "Number of times to refine the mesh 3 uniformly in parallel.");
124 args.
AddOption(&np_list[0],
"-np1",
"--np1",
125 "number of MPI ranks for mesh 1");
126 args.
AddOption(&np_list[1],
"-np2",
"--np2",
127 "number of MPI ranks for mesh 2");
128 args.
AddOption(&np_list[2],
"-np3",
"--np3",
129 "number of MPI ranks for mesh 3");
132 args.
AddOption(&rel_tol,
"-rt",
"--relative tolerance",
133 "Tolerance for Schwarz iteration convergence criterion.");
134 args.
AddOption(&visport,
"-p",
"--send-port",
"Socket for GLVis.");
148 MFEM_VERIFY(num_procs >= nmeshes,
"Not enough MPI ranks.");
149 if (np_list.Sum() == 0)
151 int np_per_mesh = num_procs/nmeshes;
152 for (
int i = 0; i < nmeshes; i++)
154 np_list[i] = np_per_mesh;
156 np_list[nmeshes-1] += num_procs - nmeshes*np_per_mesh;
158 MFEM_VERIFY(np_list.Sum() == num_procs,
" The individual mpi ranks for each"
159 " of the meshes do not add up to the total ranks specified.");
162 MPI_Comm *comml =
new MPI_Comm;
165 for (
int i = 0; i < nmeshes; i++)
168 if (myid < npsum) { color = i;
break; }
171 MPI_Comm_split(MPI_COMM_WORLD, color, myid, comml);
172 int myidlocal, numproclocal;
173 MPI_Comm_rank(*comml, &myidlocal);
174 MPI_Comm_size(*comml, &numproclocal);
179 Mesh *mesh =
new Mesh(mesh_file_list[color], 1, 1);
191 pmesh =
new ParMesh(*comml, *mesh);
192 for (
int l = 0; l < rp_levels[color]; l++)
211 cout <<
"Using isoparametric FEs: " << fec->
Name() << endl;
222 cout <<
"Number of finite element unknowns: " << size << endl;
261 if (strcmp(mesh_file_list[0],
"../../data/square-disc.mesh") == 0 &&
262 strcmp(mesh_file_list[1],
"../../data/inline-quad.mesh") == 0 &&
263 strcmp(mesh_file_list[2],
"../../data/inline-quad.mesh") == 0 )
269 for (
int i = 0; i < vxyz.
Size(); i++)
271 vxyz(i) = 0.5 + 0.5*(vxyz(i)-0.5);
275 else if (nmeshes == 3)
280 const int pts_cnt = vxyz.
Size()/
dim;
281 for (
int i = 0; i < pts_cnt; i++)
283 vxyz(i) = 0.41 + 0.4*(vxyz(i)-0.5);
285 for (
int i = 0; i < pts_cnt; i++)
287 vxyz(i+pts_cnt) = 0.5 + 0.5*(vxyz(i+pts_cnt)-0.5);
293 const int pts_cnt = vxyz.
Size()/
dim;
294 for (
int i = 0; i < pts_cnt; i++)
296 vxyz(i) = 0.6 + 0.4*(vxyz(i)-0.5);
298 for (
int i = 0; i < pts_cnt; i++)
300 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; }
427 sol_sock <<
"parallel " << num_procs <<
" " << myid <<
"\n";
428 sol_sock.precision(8);
429 sol_sock <<
"solution\n" << *pmesh << x << flush;
435 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.
void Mult(const Vector &b, Vector &x) const override
Iterative solution of the linear system using the Conjugate Gradient method.
void SetOperator(const Operator &op) override
Set/update the solver for the given operator.
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)