This file is indexed.

/usr/include/dolfin/io/XMLMeshFunction.h is in libdolfin1.0-dev 1.0.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
// Copyright (C) 2011 Garth N. Wells
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
//
// Modified by Anders Logg 2011
//
// First added:  2011-06-30
// Last changed: 2011-11-14

#ifndef __XML_MESH_FUNCTION_H
#define __XML_MESH_FUNCTION_H

#include <iomanip>
#include <iostream>
#include <ostream>
#include <string>

#include "pugixml.hpp"
#include <dolfin/mesh/LocalMeshValueCollection.h>
#include <dolfin/mesh/Mesh.h>
#include <dolfin/mesh/MeshFunction.h>
#include <dolfin/mesh/MeshPartitioning.h>
#include "XMLMesh.h"
#include "XMLMeshValueCollection.h"

namespace dolfin
{

  class XMLMeshFunction
  {
  public:

    // Read XML MeshFunction
    template <typename T>
    static void read(MeshFunction<T>& mesh_function, const std::string type,
                     const pugi::xml_node xml_mesh);

    // Read XML MeshFunction as a MeshValueCollection
    template <typename T>
    static void read(MeshValueCollection<T>& mesh_value_collection,
                     const std::string type, const pugi::xml_node xml_mesh);

    /// Write the XML file
    template<typename T>
    static void write(const MeshFunction<T>& mesh_function,
                      const std::string type, pugi::xml_node xml_node,
                      bool write_mesh=true);

  };

  //---------------------------------------------------------------------------
  template <typename T>
  inline void XMLMeshFunction::read(MeshFunction<T>& mesh_function,
                                    const std::string type,
                                    const pugi::xml_node xml_mesh)
  {
    // Check for old tag
    std::string tag_name("mesh_function");
    if (xml_mesh.child("meshfunction"))
    {
      warning("The XML tag <meshfunction> has been changed to <mesh_function>. "
              "I'll be nice and read your XML data anyway, for now, but you will "
              "need to update your XML files (a simple search and replace) to use "
              "future versions of DOLFIN.");
      tag_name = "meshfunction";
    }

    // Read main tag
    const pugi::xml_node xml_meshfunction = xml_mesh.child(tag_name.c_str());
    if (!xml_meshfunction)
      std::cout << "Not a DOLFIN MeshFunction XML file." << std::endl;

    // Check for new (MeshValueCollection) / old storage
    if (xml_meshfunction.attributes_begin() == xml_meshfunction.attributes_end())
    {
      const Mesh& mesh = mesh_function.mesh();

      // Read new-style MeshFunction
      MeshValueCollection<T> mesh_value_collection;
      if (MPI::num_processes() == 1)
        XMLMeshValueCollection::read<T>(mesh_value_collection, type, xml_meshfunction);
      else
      {
        uint dim = 0;
        if (MPI::process_number() == 0)
        {
          XMLMeshValueCollection::read<T>(mesh_value_collection, type, xml_meshfunction);
          dim = mesh_value_collection.dim();
        }
        MPI::broadcast(dim);
        mesh_value_collection.set_dim(dim);

        // Build local data
        LocalMeshValueCollection<T> local_data(mesh_value_collection, dim);

        // Distribute MeshValueCollection
        MeshPartitioning::build_distributed_value_collection<T>(mesh_value_collection,
                                                               local_data, mesh);
      }


      // Assign collection to mesh function (this is a local operation)
      mesh_function = mesh_value_collection;
    }
    else
    {
      // Read old-style MeshFunction
      if (MPI::num_processes() > 1)
      {
        dolfin_error("XMLMeshFunction.h",
                     "read mesh function from XML file",
                     "Reading old-style XML MeshFunctions is not supported in parallel. Consider using the new format");
      }

      // Get type and size
      const std::string file_data_type = xml_meshfunction.attribute("type").value();
      const unsigned int dim = xml_meshfunction.attribute("dim").as_uint();
      const unsigned int size = xml_meshfunction.attribute("size").as_uint();

      // Check that types match
      if (type != file_data_type)
      {
        dolfin_error("XMLMeshFunction.h",
                     "read mesh function from XML file",
                     "Type mismatch reading XML MeshFunction. MeshFunction type is \"%s\", but file type is \"%s\"",
                     file_data_type.c_str(), type.c_str());
      }

      // Initialise MeshFunction
      mesh_function.init(dim, size);

      // Iterate over entries (choose data type)
      if (type == "uint")
      {
        for (pugi::xml_node_iterator it = xml_meshfunction.begin(); it != xml_meshfunction.end(); ++it)
        {
          const unsigned int index = it->attribute("index").as_uint();
          dolfin_assert(index < size);
          mesh_function[index] = it->attribute("value").as_uint();
        }
      }
      else if (type == "int")
      {
        for (pugi::xml_node_iterator it = xml_meshfunction.begin(); it != xml_meshfunction.end(); ++it)
        {
          const unsigned int index = it->attribute("index").as_uint();
          dolfin_assert(index < size);
          mesh_function[index] = it->attribute("value").as_int();
        }
      }
      else if (type == "double")
      {
        for (pugi::xml_node_iterator it = xml_meshfunction.begin(); it != xml_meshfunction.end(); ++it)
        {
          const unsigned int index = it->attribute("index").as_uint();
          dolfin_assert(index < size);
          mesh_function[index] = it->attribute("value").as_double();
        }
      }
      else if (type == "bool")
      {
        for (pugi::xml_node_iterator it = xml_meshfunction.begin(); it != xml_meshfunction.end(); ++it)
        {
          const unsigned int index = it->attribute("index").as_uint();
          dolfin_assert(index < size);
          mesh_function[index] = it->attribute("value").as_bool();
        }
      }
      else
      {
        dolfin_error("XMLMeshFunction.h",
                     "read mesh function from XML file",
                     "Unknown value type (\"%s\")", type.c_str());
      }
    }
  }
  //---------------------------------------------------------------------------
  template <typename T>
  inline void XMLMeshFunction::read(MeshValueCollection<T>& mesh_value_collection,
                                    const std::string type,
                                    const pugi::xml_node xml_mesh)
  {
    // Check for old tag
    std::string tag_name("mesh_function");
    if (xml_mesh.child("meshfunction"))
    {
      warning("The XML tag <meshfunction> has been changed to <mesh_function>. "
              "I'll be nice and read your XML data anyway, for now, but you will "
              "need to update your XML files (a simple search and replace) to use "
              "future versions of DOLFIN.");
      tag_name = "meshfunction";
    }

    // Read main tag
    const pugi::xml_node xml_meshfunction = xml_mesh.child(tag_name.c_str());
    if (!xml_meshfunction)
      std::cout << "Not a DOLFIN MeshFunction XML file." << std::endl;

    // Check for new (MeshValueCollection) / old storage
    if (xml_meshfunction.attributes_begin() == xml_meshfunction.attributes_end())
    {
      // Read new-style MeshFunction
      XMLMeshValueCollection::read<T>(mesh_value_collection, type,
                                      xml_meshfunction);
    }
    else
    {
      dolfin_error("XMLMeshFunction.h",
                   "read mesh function from XML file",
                   "Cannot read old-style MeshFunction XML files as a MeshValueCollection");
    }
  }
  //---------------------------------------------------------------------------
  template<typename T>
  void XMLMeshFunction::write(const MeshFunction<T>& mesh_function,
                              const std::string type, pugi::xml_node xml_node,
                              bool write_mesh)
  {
    not_working_in_parallel("Writing XML MeshFunctions");

    // Write mesh if requested
    if (write_mesh)
      XMLMesh::write(mesh_function.mesh(), xml_node);

    // Add mesh function node and attributes
    pugi::xml_node mf_node = xml_node.append_child("mesh_function");

    // Create MeshValueCollection for output
    const MeshValueCollection<T> mesh_value_collection(mesh_function);

    // Write MeshValueCollection
    XMLMeshValueCollection::write(mesh_value_collection, type, mf_node);
  }
  //---------------------------------------------------------------------------

}
#endif