dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #22428
patch for boundary indicators (e.g. VMTK) in parallel
Please consider the attached patch.
Kent
# Bazaar merge directive format 2 (Bazaar 0.90)
# revision_id: kent-and@xxxxxxxxx-20110404064913-n944nlrq5w2oylgy
# target_branch: bzr+ssh://bazaar.launchpad.net/%2Bbranch/dolfin/
# testament_sha1: eca4dcac14855f7fa199e2a4a8a809ede8a378b6
# timestamp: 2011-04-04 08:50:12 +0200
# base_revision_id: gnw20@xxxxxxxxx-20110331151943-p5on3xia9fukuy1t
#
# Begin patch
=== modified file 'dolfin/io/XMLLocalMeshData.cpp'
--- dolfin/io/XMLLocalMeshData.cpp 2011-01-24 14:28:43 +0000
+++ dolfin/io/XMLLocalMeshData.cpp 2011-04-04 06:49:13 +0000
@@ -2,9 +2,10 @@
// Licensed under the GNU LGPL Version 2.1.
//
// First added: 2008-11-28
-// Last changed: 2009-09-14
+// Last changed: 2011-03-30
//
// Modified by Anders Logg, 2008.
+// Modified by Kent-Andre Mardal, 2011.
#include <boost/assign/list_of.hpp>
#include <boost/scoped_ptr.hpp>
@@ -13,6 +14,7 @@
#include <dolfin/common/MPI.h>
#include <dolfin/mesh/CellType.h>
#include "XMLLocalMeshData.h"
+#include "XMLArray.h"
using namespace dolfin;
@@ -92,8 +94,22 @@
read_array(name, attrs);
state = INSIDE_ARRAY;
}
-
- break;
+ else if (xmlStrcasecmp(name, (xmlChar* ) "data_entry") == 0)
+ {
+ read_data_entry(name, attrs);
+ state = INSIDE_DATA_ENTRY;
+ }
+
+ break;
+
+ case INSIDE_DATA_ENTRY:
+ if (xmlStrcasecmp(name, (xmlChar* ) "array") == 0)
+ {
+ read_array(name, attrs);
+ state = INSIDE_ARRAY;
+ }
+
+ break;
default:
error("Inconsistent state in XML reader: %d.", state);
@@ -150,14 +166,28 @@
}
break;
+
+ case INSIDE_DATA_ENTRY:
+
+ if (xmlStrcasecmp(name, (xmlChar* ) "data_entry") == 0)
+ {
+ state = INSIDE_DATA;
+ }
+
case INSIDE_ARRAY:
if (xmlStrcasecmp(name, (xmlChar* ) "array") == 0)
{
+ state = INSIDE_DATA_ENTRY;
+ }
+
+ if (xmlStrcasecmp(name, (xmlChar* ) "data_entry") == 0)
+ {
state = INSIDE_DATA;
}
+
break;
default:
@@ -340,12 +370,45 @@
//-----------------------------------------------------------------------------
void XMLLocalMeshData::read_array(const xmlChar* name, const xmlChar** attrs)
{
- error("Local mesh data can not read arrays.");
+ std::string array_type = parse_string(name, attrs, "type");
+ uint size = parse_uint(name, attrs, "size");
+
+ XMLArray* xml_array;
+
+ if ( array_type.compare("int") == 0 )
+ {
+ // FIXME: Add support for more types in MeshData?
+ std::vector<int>* ux = new std::vector<int>();
+ delete xml_array;
+ xml_array = new XMLArray(*ux, parser, size);
+ xml_array->handle();
+ }
+ else if ( array_type.compare("uint") == 0 )
+ {
+ //FIXME this is uint
+ std::vector<unsigned int>* ux = new std::vector<unsigned int>();
+ delete xml_array;
+ xml_array = new XMLArray(*ux, parser, size);
+ xml_array->handle();
+ mesh_data.arrays[data_entry_name] = ux;
+ }
+ else if ( array_type.compare("double") == 0 )
+ {
+ // FIXME: Add support for more types in MeshData?
+ std::vector<double>* dx = new std::vector<double>();
+ delete xml_array;
+ xml_array = new XMLArray(*dx, parser, size);
+ xml_array->handle();
+ }
}
//-----------------------------------------------------------------------------
void XMLLocalMeshData::read_mesh_data(const xmlChar* name, const xmlChar** attrs)
{
- not_working_in_parallel("Reading auxiliary mesh data");
+}
+//-----------------------------------------------------------------------------
+void XMLLocalMeshData::read_data_entry(const xmlChar* name, const xmlChar** attrs)
+{
+ data_entry_name = parse_string(name, attrs, "name");
}
//-----------------------------------------------------------------------------
dolfin::uint XMLLocalMeshData::num_local_vertices() const
=== modified file 'dolfin/io/XMLLocalMeshData.h'
--- dolfin/io/XMLLocalMeshData.h 2010-08-07 21:11:22 +0000
+++ dolfin/io/XMLLocalMeshData.h 2011-04-04 06:49:13 +0000
@@ -2,7 +2,8 @@
// Licensed under the GNU LGPL Version 2.1.
//
// First added: 2009-03-10
-// Last changed: 2009-09-08
+// Last changed: 2011-03-30
+// Modified by Kent-Andre Mardal, 2011.
#ifndef __XMLLOCALMESHDATA_H
#define __XMLLOCALMESHDATA_H
@@ -35,6 +36,7 @@
enum ParserState {OUTSIDE,
INSIDE_MESH, INSIDE_VERTICES, INSIDE_CELLS,
INSIDE_DATA, INSIDE_MESH_FUNCTION, INSIDE_ARRAY,
+ INSIDE_DATA_ENTRY,
DONE};
// Callbacks for reading XML data
@@ -48,6 +50,7 @@
void read_mesh_function(const xmlChar* name, const xmlChar** attrs);
void read_array (const xmlChar* name, const xmlChar** attrs);
void read_mesh_data (const xmlChar* name, const xmlChar** attrs);
+ void read_data_entry (const xmlChar* name, const xmlChar** attrs);
// Number of local vertices
uint num_local_vertices() const;
@@ -70,6 +73,9 @@
// Result object to build
LocalMeshData& mesh_data;
+ // name of the array
+ std::string data_entry_name;
+
ParserState state;
};
=== modified file 'dolfin/mesh/LocalMeshData.h'
--- dolfin/mesh/LocalMeshData.h 2011-03-28 13:12:20 +0000
+++ dolfin/mesh/LocalMeshData.h 2011-04-04 06:49:13 +0000
@@ -2,9 +2,10 @@
// Licensed under the GNU LGPL Version 2.1.
//
// First added: 2008-11-28
-// Last changed: 2011-03-25
+// Last changed: 2009-04-04
//
// Modified by Anders Logg, 2008-2009.
+// Modified by Kent-Andre Mardal, 2011.
#ifndef __LOCAL_MESH_DATA_H
#define __LOCAL_MESH_DATA_H
@@ -105,6 +106,9 @@
/// Topological dimension
uint tdim;
+ // A map from named mesh data to arrays
+ std::map<std::string, std::vector<uint>* > arrays;
+
// Friends
friend class XMLLocalMeshData;
friend class MeshPartitioning;
=== modified file 'dolfin/mesh/MeshData.h'
--- dolfin/mesh/MeshData.h 2011-03-12 09:54:55 +0000
+++ dolfin/mesh/MeshData.h 2011-04-04 06:49:13 +0000
@@ -159,6 +159,7 @@
/// Friends
friend class XMLFile;
friend class XMLMeshData;
+ friend class MeshPartitioning;
private:
=== modified file 'dolfin/mesh/MeshPartitioning.cpp'
--- dolfin/mesh/MeshPartitioning.cpp 2011-03-22 22:58:27 +0000
+++ dolfin/mesh/MeshPartitioning.cpp 2011-04-04 06:49:13 +0000
@@ -1,8 +1,10 @@
// Copyright (C) 2008-2009 Niclas Jansson, Ola Skavhaug and Anders Logg.
// Licensed under the GNU LGPL Version 2.1.
//
+// Modified by Kent-Andre Mardal, 2011
+//
// First added: 2008-12-01
-// Last changed: 2011-03-17
+// Last changed: 2011-04-04
#include <algorithm>
#include <iterator>
@@ -683,6 +685,9 @@
for(uint i = 0; i < gci.size(); ++i)
global_cell_indices[i] = gci[i];
+ // distribute data
+ distribute_data(mesh, mesh_data, glob2loc, gci);
+
// Close mesh: Note that this must be done after creating the global vertex map or
// otherwise the ordering in mesh.close() will be wrong (based on local numbers).
editor.close();
@@ -776,3 +781,48 @@
(*exterior)[entities.find(it->first)->second] = 0;
}
//-----------------------------------------------------------------------------
+void MeshPartitioning::distribute_data(Mesh& mesh, const LocalMeshData& local_mesh_data, std::map<uint, uint>& glob2loc,
+const std::vector<uint>& gci)
+
+{
+ // Make global to local mapping
+ std::map<uint,uint> lci;
+ uint cell_index=0;
+ for (uint i=0; i< gci.size(); i++)
+ {
+ lci[gci[i]] = i;
+ }
+
+ // Loop through the arrays
+ const uint num_processes = MPI::num_processes();
+ const uint process_number = MPI::process_number();
+ std::map<std::string, std::vector<uint>* >::const_iterator it;
+ for (it = local_mesh_data.arrays.begin(); it != local_mesh_data.arrays.end(); ++it)
+ {
+ const std::string name = it->first;
+ const std::vector<uint>* array = it->second;
+ if (name == "boundary_facet_cells")
+ {
+ std::vector<uint>* non_const_array = (std::vector<uint>*) array;
+ std::vector<uint>* cell_array = new std::vector<uint>(array->size());
+ for (uint i=0; i< array->size(); i++)
+ {
+ if (lci.find((*array)[i]) != lci.end())
+ {
+ (*cell_array)[i] = lci[(*array)[i]];
+ }
+ else
+ {
+ (*cell_array)[i] = 0;
+ }
+ }
+ mesh.data().arrays[name] = cell_array;
+ }
+ else
+ {
+ std::vector<uint>* non_const_array = (std::vector<uint>*) array;
+ mesh.data().arrays[name] = non_const_array;
+ }
+ }
+}
+//-----------------------------------------------------------------------------
=== modified file 'dolfin/mesh/MeshPartitioning.h'
--- dolfin/mesh/MeshPartitioning.h 2011-03-12 23:18:09 +0000
+++ dolfin/mesh/MeshPartitioning.h 2011-04-04 06:49:13 +0000
@@ -2,9 +2,10 @@
// Licensed under the GNU LGPL Version 2.1.
//
// Modified by Garth N. Wells, 2010
+// Modified by Kent-Andre Mardal, 2011
//
// First added: 2008-12-01
-// Last changed: 2010-02-05
+// Last changed: 2010-04-04
#ifndef __MESH_PARTITIONING_H
#define __MESH_PARTITIONING_H
@@ -81,6 +82,11 @@
static void distribute_vertices(LocalMeshData& data,
std::map<uint, uint>& glob2loc);
+ // Distribute data
+ static void distribute_data(Mesh& mesh, const LocalMeshData& data,
+ std::map<uint, uint>& glob2loc,
+ const std::vector<uint>& gci);
+
// Build mesh
static void build_mesh(Mesh& mesh, const LocalMeshData& data,
std::map<uint, uint>& glob2loc);
# Begin bundle
IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWTh5ABEACDX/gHrQEAB5f///
/y9car////pgDP2vt7ut3bb01p5HBRSgTrqpluh3s1IUAB6U1nCSRRlJ4MQJ6p+UxT1PymA1T001
GyhkGgA0AAlCaTCZCNAjKRtI9T1GjQ0AAGgABo9IMiZBSDQeoGjTIAAAaAAAAAAkKU8pPUxTTyj1
GammniT1GjRoaA0AAANBpocwmgNAaNGEaDEaYmTE0GEaBkAyYCRIQCaaaCZGRGjJkaZQ1PFPFGgD
QDTIepcLZaSS0cuaUdFHI+DRntn0TrGRrLOV4M+LFuXbunTK0hBWKfs8u3Rqd5GPi3etPYMtjJN9
snHYt4xouJjAWQetAGN68MjKMjKtULZDXp+rrDaMVY6y4lqquTo6XI4MdUEhkuZuLrZ5PVfroIDS
0EGgqzos5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