From 4c972cfc352ae5ba851cae142ca6fe594d88bc04 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 23 May 2019 11:01:00 +0200 Subject: egs: add support for MPI-based multi-component solves --- components.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 components.h (limited to 'components.h') diff --git a/components.h b/components.h new file mode 100644 index 0000000..bc3c38f --- /dev/null +++ b/components.h @@ -0,0 +1,73 @@ +/* + * Multi-component utility code + * Copyright 2019 Anton Khirnov + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef MG2D_COMPONENTS_H +#define MG2D_COMPONENTS_H + +#include +#include + +typedef struct Rect { + ptrdiff_t start[2]; + size_t size[2]; +} Rect; + +typedef struct DomainComponent { + /* points that belong to this component */ + Rect interior; + /* interior + ghost points on the physical boundaries */ + Rect exterior; + int bnd_is_outer[4]; +} DomainComponent; + +typedef struct DomainGeometry { + size_t domain_size[2]; + + unsigned int nb_components; + DomainComponent *components; +} DomainGeometry; + +DomainGeometry *mg2di_dg_alloc(unsigned int nb_components); +void mg2di_dg_free(DomainGeometry **dg); + +int mg2di_dg_copy(DomainGeometry **dst, const DomainGeometry *src); + +/** + * Compute the intersection of src1 and src2, store the result in dst. + */ +int mg2di_rect_intersect(Rect *dst, const Rect *src1, const Rect *src2); + +/** + * For the component in domain geometry , internal edges are + * rectangles along each non-outer boundary. Edge overlap with component + * is the intersection of internal edges of and exterior of (must + * necessarily be a rectangle). + * + * NB: edge overlap of a component with itself is empty. + * + * This function computes, for the given component + * - edge overlaps of with every component in dg (i.e. the ghost points + * to be received from each remote component) - written into overlaps_recv + * - edge overlaps of every component in dg with (i.e. the ghost points + * to be set to each remote component) - written into overlaps_send + */ +int mg2di_dg_edge_overlaps(Rect *overlaps_recv, Rect *overlaps_send, + const DomainGeometry *dg, unsigned int comp, + unsigned int edge_width); + +#endif // MG2D_COMPONENTS_H -- cgit v1.2.3