Skip to content

Commit 9c332c6

Browse files
committed
make isPrintable available to users
1 parent e1ddbb7 commit 9c332c6

File tree

7 files changed

+75
-51
lines changed

7 files changed

+75
-51
lines changed

apf/apf.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include "apfArrayData.h"
1818
#include "apfTagData.h"
1919
#include "apfUserData.h"
20+
#include "apfVtk.h"
21+
#include "apfNumberingClass.h"
2022
#include <cstdio>
2123
#include <cstdlib>
2224
#include <pcu_util.h>
@@ -436,7 +438,12 @@ void sharedReduction(Field* f, Sharing* shr, bool delete_shr,
436438
reduceFieldData(f->getData(), shr, delete_shr, sum);
437439
}
438440

439-
441+
bool isPrintable(Field* f)
442+
{
443+
// cast to FieldBase and call the other method
444+
FieldBase* f2 = f;
445+
return isPrintable(f2);
446+
}
440447

441448
void fail(const char* why)
442449
{

apf/apf.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,10 @@ void accumulate(Field* f, Sharing* shr = 0, bool delete_shr = false);
684684
void sharedReduction(Field* f, Sharing* shr, bool delete_shr,
685685
const ReductionOp<double>& sum = ReductionSum<double>());
686686

687+
/** \brief Checks whether a Field/Numbering/GlobalNumbering is complete and
688+
* therefore printable to visualization files
689+
*/
690+
bool isPrintable(Field* f);
687691

688692
/** \brief Declare failure of code inside APF.
689693
\details This function prints the string as an APF

apf/apfNumbering.cc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "apfMesh.h"
1313
#include "apfShape.h"
1414
#include "apfTagData.h"
15+
#include "apfVtk.h"
1516
#include <pcu_util.h>
1617

1718
namespace apf {
@@ -172,6 +173,12 @@ const char* getName(Numbering* n)
172173
return n->getName();
173174
}
174175

176+
bool isPrintable(Numbering* f)
177+
{
178+
FieldBase* f2 = f;
179+
return isPrintable(f2);
180+
}
181+
175182
Mesh* getMesh(Numbering* n)
176183
{
177184
return n->getMesh();
@@ -479,6 +486,12 @@ const char* getName(GlobalNumbering* n)
479486
return n->getName();
480487
}
481488

489+
bool isPrintable(GlobalNumbering* f)
490+
{
491+
FieldBase* f2 = f;
492+
return isPrintable(f2);
493+
}
494+
482495
Mesh* getMesh(GlobalNumbering* n)
483496
{
484497
return n->getMesh();

apf/apfNumbering.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ Field* getField(Numbering* n);
7474
FieldShape* getShape(Numbering* n);
7575
/** \brief get the name of a Numbering */
7676
const char* getName(Numbering* n);
77+
78+
bool isPrintable(Numbering* f);
7779
/** \brief get the mesh associated with a Numbering */
7880
Mesh* getMesh(Numbering* n);
7981
int countComponents(Numbering* n);
@@ -166,6 +168,7 @@ GlobalNumbering* createGlobalNumbering(Field* f);
166168

167169
FieldShape* getShape(GlobalNumbering* n);
168170
const char* getName(GlobalNumbering* n);
171+
bool isPrintable(GlobalNumbering* f);
169172
/** \brief get the mesh associated with a global numbering */
170173
Mesh* getMesh(GlobalNumbering* n);
171174
/** \brief get the components associated with a global numbering */

apf/apfVtk.cc

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include <cstdlib>
2121
#include <stdint.h>
2222
#include <vector>
23+
#include <apfVtk.h>
2324

2425
// === includes for safe_mkdir ===
2526
#include <reel.h>
@@ -30,27 +31,6 @@
3031

3132
namespace apf {
3233

33-
class HasAll : public FieldOp
34-
{
35-
public:
36-
virtual bool inEntity(MeshEntity* e)
37-
{
38-
if (!f->getData()->hasEntity(e))
39-
ok = false;
40-
return false;
41-
}
42-
bool run(FieldBase* f_)
43-
{
44-
f = f_;
45-
ok = true;
46-
this->apply(f);
47-
return ok;
48-
}
49-
private:
50-
bool ok;
51-
FieldBase* f;
52-
};
53-
5434
static bool shouldPrint(
5535
FieldBase* f,
5636
std::vector<std::string> writeFields)
@@ -63,7 +43,7 @@ static bool shouldPrint(
6343
return print;
6444
}
6545

66-
static bool isPrintable(FieldBase* f)
46+
bool isPrintable(FieldBase* f)
6747
{
6848
HasAll op;
6949
return PCU_And(op.run(f));

apf/apfVtk.h

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2011 Scientific Computation Research Center
3+
*
4+
* This work is open source software, licensed under the terms of the
5+
* BSD license as described in the LICENSE file in the top-level directory.
6+
*/
7+
8+
#ifndef APFVTK_H
9+
#define APFVTK_H
10+
11+
#include "apfField.h"
12+
13+
14+
namespace apf {
15+
16+
class HasAll : public FieldOp
17+
{
18+
public:
19+
virtual bool inEntity(MeshEntity* e)
20+
{
21+
if (!f->getData()->hasEntity(e))
22+
ok = false;
23+
return false;
24+
}
25+
bool run(FieldBase* f_)
26+
{
27+
f = f_;
28+
ok = true;
29+
this->apply(f);
30+
return ok;
31+
}
32+
private:
33+
bool ok;
34+
FieldBase* f;
35+
};
36+
37+
38+
39+
bool isPrintable(FieldBase* f);
40+
41+
42+
} // namespace apf
43+
44+
#endif

crv/crvVtk.cc

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "apfDynamicVector.h"
1111
#include "apfFieldData.h"
1212
#include "apfMDS.h"
13+
#include "apfVtk.h"
1314
#include <sstream>
1415
#include <fstream>
1516
#include <pcu_util.h>
@@ -28,34 +29,6 @@ namespace crv {
2829
/* this file has all the VTK commands for curved meshing,
2930
it is more meant as a debugging tool as proper visualization
3031
does not exist in paraview past second order */
31-
32-
class HasAll : public apf::FieldOp
33-
{
34-
public:
35-
virtual bool inEntity(apf::MeshEntity* e)
36-
{
37-
if (!f->getData()->hasEntity(e) && f->countNodesOn(e))
38-
ok = false;
39-
return false;
40-
}
41-
bool run(apf::FieldBase* f_)
42-
{
43-
f = f_;
44-
ok = true;
45-
this->apply(f);
46-
return ok;
47-
}
48-
private:
49-
bool ok;
50-
apf::FieldBase* f;
51-
};
52-
53-
static bool isPrintable(apf::FieldBase* f)
54-
{
55-
HasAll op;
56-
return op.run(f);
57-
}
58-
5932
static void describeArray(
6033
std::ostream& file,
6134
const char* name,

0 commit comments

Comments
 (0)