Skip to content

Commit 2810366

Browse files
Nightly Botcwsmith
authored andcommitted
Merging develop into master
2 parents 18cdb53 + d86c1ea commit 2810366

File tree

4 files changed

+140
-120
lines changed

4 files changed

+140
-120
lines changed

README.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
# SCOREC Core #
22

3-
[![Coverity Scan Build Status](https://scan.coverity.com/projects/6698/badge.svg)](https://scan.coverity.com/projects/scorec-core)
4-
53
The SCOREC Core is a set of C/C++ libraries for unstructured mesh
64
simulations on supercomputers.
75

ma/maDBG.cc

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include <cassert>
2727
#include <stdarg.h>
2828

29+
static double PI = 3.14159265359;
2930

3031
namespace ma_dbg {
3132

@@ -256,5 +257,133 @@ void createCavityMesh(ma::Adapt* a,
256257
createCavityMesh(a, tetsArray, prefix);
257258
}
258259

260+
static apf::Vector3 getPointOnEllipsoid(
261+
apf::Vector3 center,
262+
apf::Vector3 abc,
263+
apf::Matrix3x3 rotation,
264+
double scaleFactor,
265+
double u,
266+
double v)
267+
{
268+
apf::Vector3 result;
269+
result[0] = abc[0] * cos(u) * cos(v);
270+
result[1] = abc[1] * cos(u) * sin(v);
271+
result[2] = abc[2] * sin(u);
272+
273+
result = result * scaleFactor;
274+
275+
result = rotation * result + center;
276+
return result;
277+
}
278+
279+
static void makeEllipsoid(
280+
apf::Mesh2* msf,
281+
apf::Mesh2* mesh,
282+
apf::Field* sizes,
283+
apf::Field* frames,
284+
apf::MeshEntity* ent,
285+
int node,
286+
double scaleFactor,
287+
int sampleSize[2])
288+
{
289+
// first get the coordinate at node location
290+
apf::Vector3 xi;
291+
apf::Vector3 center;
292+
apf::FieldShape* fs = apf::getShape(sizes);
293+
fs->getNodeXi(mesh->getType(ent), node, xi);
294+
apf::MeshElement* me = apf::createMeshElement(mesh, ent);
295+
apf::mapLocalToGlobal(me, xi, center);
296+
apf::destroyMeshElement(me);
297+
298+
299+
// second get the sizes and frames at node
300+
apf::Vector3 abc;
301+
apf::getVector(sizes, ent, node, abc);
302+
303+
apf::Matrix3x3 rotation;
304+
apf::getMatrix(frames, ent, node, rotation);
305+
306+
307+
double U0 = 0.0;
308+
double U1 = 2 * PI;
309+
double V0 = -PI/2.;
310+
double V1 = PI/2.;
311+
int n = sampleSize[0];
312+
int m = sampleSize[1];
313+
double dU = (U1 - U0) / (n-1);
314+
double dV = (V1 - V0) / (m-1);
315+
316+
// make the array of vertex coordinates in the physical space
317+
std::vector<ma::Vector> ps;
318+
for (int j = 0; j < m; j++) {
319+
for (int i = 0; i < n; i++) {
320+
double u = U0 + i * dU;
321+
double v = V0 + j * dV;
322+
apf::Vector3 pt = getPointOnEllipsoid(center, abc, rotation, scaleFactor, u, v);
323+
ps.push_back(pt);
324+
}
325+
}
326+
// make the vertexes and set the coordinates using the array
327+
std::vector<apf::MeshEntity*> vs;
328+
for (size_t i = 0; i < ps.size(); i++) {
329+
apf::MeshEntity* newVert = msf->createVert(0);
330+
msf->setPoint(newVert, 0, ps[i]);
331+
vs.push_back(newVert);
332+
}
333+
334+
PCU_ALWAYS_ASSERT(vs.size() == ps.size());
335+
336+
apf::MeshEntity* v[3];
337+
// make the lower/upper t elems
338+
for (int i = 0; i < n-1; i++) {
339+
for (int j = 0; j < m-1; j++) {
340+
// upper triangle
341+
v[0] = vs[(i + 0) + n * (j + 0)];
342+
v[1] = vs[(i + 0) + n * (j + 1)];
343+
v[2] = vs[(i + 1) + n * (j + 0)];
344+
apf::buildElement(msf, 0, apf::Mesh::TRIANGLE, v);
345+
// upper triangle
346+
v[0] = vs[(i + 0) + n * (j + 1)];
347+
v[1] = vs[(i + 1) + n * (j + 1)];
348+
v[2] = vs[(i + 1) + n * (j + 0)];
349+
apf::buildElement(msf, 0, apf::Mesh::TRIANGLE, v);
350+
}
351+
}
352+
}
353+
354+
void visualizeSizeField(
355+
apf::Mesh2* m,
356+
apf::Field* sizes,
357+
apf::Field* frames,
358+
int sampleSize[2],
359+
double userScale,
360+
const char* outputPrefix)
361+
{
362+
// create the size-field visualization mesh
363+
apf::Mesh2* msf = apf::makeEmptyMdsMesh(gmi_load(".null"), 2, false);
364+
365+
apf::FieldShape* fs = apf::getShape(sizes);
366+
int dim = m->getDimension();
367+
368+
apf::MeshEntity* ent;
369+
apf::MeshIterator* it;
370+
371+
for (int d = 0; d <= dim; d++) {
372+
if (!fs->hasNodesIn(d)) continue;
373+
it = m->begin(d);
374+
while ( (ent = m->iterate(it)) ) {
375+
int type = m->getType(ent);
376+
int non = fs->countNodesOn(type);
377+
for (int n = 0; n < non; n++)
378+
makeEllipsoid(msf, m, sizes, frames, ent, n, userScale , sampleSize);
379+
}
380+
m->end(it);
381+
}
382+
383+
apf::writeVtkFiles(outputPrefix, msf);
384+
385+
msf->destroyNative();
386+
apf::destroyMesh(msf);
387+
}
259388

260389
}

ma/maDBG.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,13 @@ void createCavityMesh(ma::Adapt* a,
6060
ma::EntitySet& tets,
6161
const char* prefix);
6262

63+
void visualizeSizeField(
64+
apf::Mesh2* m,
65+
apf::Field* sizes,
66+
apf::Field* frames,
67+
int smapleSize[2],
68+
double userScale,
69+
const char* OutputPrefix);
70+
6371
}
6472
#endif

test/visualizeAnisoSizes.cc

Lines changed: 3 additions & 118 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <maStats.h>
44
#include <gmi_mesh.h>
55
#include <gmi_null.h>
6+
#include <maDBG.h>
67
#include <PCU.h>
78
#include <lionPrint.h>
89

@@ -25,27 +26,10 @@
2526
#include <errno.h> /* for checking the error from mkdir */
2627
// ===============================
2728

28-
static double PI = 3.14159265359;
29-
3029
void safe_mkdir(const char* path);
3130
double getLargetsSize(
3231
apf::Mesh2* m,
3332
apf::Field* sizes);
34-
apf::Vector3 getPointOnEllipsoid(
35-
apf::Vector3 center,
36-
apf::Vector3 abc,
37-
apf::Matrix3x3 rotation,
38-
double scaleFactor,
39-
double u,
40-
double v);
41-
void makeEllipsoid(
42-
apf::Mesh2* msf,
43-
apf::Mesh2* m,
44-
apf::Field* sizes,
45-
apf::Field* frames,
46-
apf::MeshEntity* vert,
47-
double scaleFactor,
48-
int sampleSize[2]);
4933
void visualizeSizeField(
5034
const char* modelFile,
5135
const char* meshFile,
@@ -140,94 +124,6 @@ double getLargetsSize(
140124
return maxSize;
141125
}
142126

143-
apf::Vector3 getPointOnEllipsoid(
144-
apf::Vector3 center,
145-
apf::Vector3 abc,
146-
apf::Matrix3x3 rotation,
147-
double scaleFactor,
148-
double u,
149-
double v)
150-
{
151-
apf::Vector3 result;
152-
result[0] = abc[0] * cos(u) * cos(v);
153-
result[1] = abc[1] * cos(u) * sin(v);
154-
result[2] = abc[2] * sin(u);
155-
156-
result = result * scaleFactor;
157-
158-
result = rotation * result + center;
159-
return result;
160-
}
161-
162-
163-
void makeEllipsoid(
164-
apf::Mesh2* msf,
165-
apf::Mesh2* mesh,
166-
apf::Field* sizes,
167-
apf::Field* frames,
168-
apf::MeshEntity* vert,
169-
double scaleFactor,
170-
int sampleSize[2])
171-
{
172-
173-
apf::Vector3 center;
174-
mesh->getPoint(vert, 0, center);
175-
176-
apf::Vector3 abc;
177-
apf::getVector(sizes, vert, 0, abc);
178-
179-
apf::Matrix3x3 rotation;
180-
apf::getMatrix(frames, vert, 0, rotation);
181-
182-
183-
double U0 = 0.0;
184-
double U1 = 2 * PI;
185-
double V0 = -PI/2.;
186-
double V1 = PI/2.;
187-
int n = sampleSize[0];
188-
int m = sampleSize[1];
189-
double dU = (U1 - U0) / (n-1);
190-
double dV = (V1 - V0) / (m-1);
191-
192-
// make the array of vertex coordinates in the physical space
193-
std::vector<ma::Vector> ps;
194-
for (int j = 0; j < m; j++) {
195-
for (int i = 0; i < n; i++) {
196-
double u = U0 + i * dU;
197-
double v = V0 + j * dV;
198-
apf::Vector3 pt = getPointOnEllipsoid(center, abc, rotation, scaleFactor, u, v);
199-
ps.push_back(pt);
200-
}
201-
}
202-
// make the vertexes and set the coordinates using the array
203-
std::vector<apf::MeshEntity*> vs;
204-
for (size_t i = 0; i < ps.size(); i++) {
205-
apf::MeshEntity* newVert = msf->createVert(0);
206-
msf->setPoint(newVert, 0, ps[i]);
207-
vs.push_back(newVert);
208-
}
209-
210-
PCU_ALWAYS_ASSERT(vs.size() == ps.size());
211-
212-
apf::MeshEntity* v[3];
213-
// make the lower/upper t elems
214-
for (int i = 0; i < n-1; i++) {
215-
for (int j = 0; j < m-1; j++) {
216-
// upper triangle
217-
v[0] = vs[(i + 0) + n * (j + 0)];
218-
v[1] = vs[(i + 0) + n * (j + 1)];
219-
v[2] = vs[(i + 1) + n * (j + 0)];
220-
apf::buildElement(msf, 0, apf::Mesh::TRIANGLE, v);
221-
// upper triangle
222-
v[0] = vs[(i + 0) + n * (j + 1)];
223-
v[1] = vs[(i + 1) + n * (j + 1)];
224-
v[2] = vs[(i + 1) + n * (j + 0)];
225-
apf::buildElement(msf, 0, apf::Mesh::TRIANGLE, v);
226-
}
227-
}
228-
}
229-
230-
231127
void visualizeSizeField(
232128
const char* modelFile,
233129
const char* meshFile,
@@ -290,23 +186,12 @@ void visualizeSizeField(
290186

291187
m->verify();
292188

293-
// create the size-field visualization mesh
294-
apf::Mesh2* msf = apf::makeEmptyMdsMesh(gmi_load(".null"), 2, false);
295-
296-
apf::MeshEntity* vert;
297-
apf::MeshIterator* it = m->begin(0);
298-
while ( (vert = m->iterate(it)) )
299-
if (m->isOwned(vert))
300-
makeEllipsoid(msf, m, sizes, frames, vert, userScale , sampleSize);
301-
m->end(it);
302-
303189
std::stringstream ss;
304190
ss << outputPrefix << "/size_field_vis";
305-
apf::writeVtkFiles(ss.str().c_str(), msf);
191+
ma_dbg::visualizeSizeField(
192+
m, sizes, frames, sampleSize, userScale, ss.str().c_str());
306193
ss.str("");
307194

308-
msf->destroyNative();
309-
apf::destroyMesh(msf);
310195
m->destroyNative();
311196
apf::destroyMesh(m);
312197
}

0 commit comments

Comments
 (0)