-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bezier Field Solution Transfer #321
base: develop
Are you sure you want to change the base?
Changes from all commits
d9eeb2b
b384d6c
d245e92
c33f4c4
ab96992
f7b1884
00bbb32
73e0dfb
c52aa74
f66ef98
7903280
d18ce6c
307f983
e8c5374
2cdb8ef
2b41420
89aee2b
bc34e3f
7037417
7f8f777
0627108
61ae04b
1d6ab96
775b743
2982d4e
76badb6
47fb3b6
2228cfc
f71dfee
9a09525
ac87f00
9804ab7
e10035f
7b571c0
81f419a
0d4cf81
50dfbcc
06b74c7
5b76fa9
dfe6876
2c083b7
1a8336c
515bf06
dd2ec78
fb2b3ed
097d33d
613983d
ffbffcc
e273e25
aa75b6a
44b059c
0b352bf
b77a821
251213b
1db8724
58be87e
721999b
3caaeb2
03cd0a2
83f850b
cfe92b4
e73749b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ | |
#include "apfMesh2.h" | ||
#include "apfShape.h" | ||
#include <ma.h> | ||
#include <maSolutionTransfer.h> | ||
#include <mth.h> | ||
#include <stdio.h> | ||
#include <vector> | ||
|
@@ -22,6 +23,9 @@ | |
* \brief the curving functions are contained in this namespace */ | ||
namespace crv { | ||
|
||
// forward declaration of the crv::Adapt | ||
class Adapt; | ||
|
||
/** \brief actually 1 greater than max order */ | ||
static unsigned const MAX_ORDER = 19; | ||
|
||
|
@@ -37,6 +41,13 @@ int getBlendingOrder(const int type); | |
/** \brief count invalid elements of the mesh */ | ||
int countNumberInvalidElements(apf::Mesh2* m); | ||
|
||
/** \ brief converts field f to Bezier entity wise */ | ||
void convertInterpolationFieldPoints(apf::MeshEntity* e, | ||
apf::Field* f, int n, int ne, apf::NewArray<double> &c); | ||
|
||
/** \brief converts field f, which is interpolating to Bezier */ | ||
void convertInterpolatingFieldToBezier(apf::Mesh2* m_mesh, apf::Field* f); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @avinmoharana There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mortezah There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @avinmoharana if it is not used outside, it should not be here. If they are design issues that prevent this we should discuss and resolve those appropriately. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mortezah |
||
|
||
/** \brief Base Mesh curving object | ||
\details P is the order, S is the space dimension, | ||
different from the mesh dimension, used to distinguish between planar 2D | ||
|
@@ -203,6 +214,10 @@ void writeInterpolationPointVtuFiles(apf::Mesh* m, const char* prefix); | |
int getTriNodeIndex(int P, int i, int j); | ||
int getTetNodeIndex(int P, int i, int j, int k); | ||
|
||
/** \brief adds bezier solution transfers */ | ||
ma::SolutionTransfer* setBezierSolutionTransfers( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this used by outside users or only internally? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mortezah There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. then it should be made static. It also seems that this file is not a correct location for this. In that case, it has to be moved to the file it is defined. Where is the implementation (the actual code)? Can you just remove this declaration make the implementation static in the file it is defined? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mortezah I can make the createBezierSolutionTransfer() accessible and define the setBezierSolutionTransfers routine in crvAdapt.cc, or define both only in crvAdapt. |
||
const std::vector<apf::Field*>& fields, crv::Adapt* a); | ||
|
||
/** \brief crv fail function */ | ||
void fail(const char* why) __attribute__((noreturn)); | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
/* | ||
* Copyright 2015 Scientific Computation Research Center | ||
* | ||
* This work is open source software, licensed under the terms of the | ||
* BSD license as described in the LICENSE file in the top-level directory. | ||
*/ | ||
|
||
#include "crv.h" | ||
#include "crvBezier.h" | ||
#include "crvBezierShapes.h" | ||
#include "crvMath.h" | ||
#include "crvShape.h" | ||
#include "crvTables.h" | ||
#include "crvQuality.h" | ||
#include <apfField.h> | ||
#include <lionPrint.h> | ||
#include <cstdlib> | ||
#include <mth_def.h> | ||
#include <iostream> | ||
#include <pcu_util.h> | ||
|
||
namespace crv { | ||
|
||
static void convertVectorFieldInterpolationPoints(int n, int ne, | ||
apf::NewArray<apf::Vector3>& nodes, | ||
apf::NewArray<double>& c, | ||
apf::NewArray<apf::Vector3>& newNodes){ | ||
|
||
for(int i = 0; i < ne; ++i) | ||
newNodes[i].zero(); | ||
|
||
for( int i = 0; i < ne; ++i) | ||
for( int j = 0; j < n; ++j) | ||
newNodes[i] += nodes[j]*c[i*n+j]; | ||
} | ||
|
||
static void convertScalarFieldInterpolationPoints(int n, int ne, | ||
apf::NewArray<double>& nodes, | ||
apf::NewArray<double>& c, | ||
apf::NewArray<double>& newNodes) | ||
{ | ||
|
||
for(int i = 0; i < ne; ++i) | ||
newNodes[i] = 0.; | ||
|
||
for( int i = 0; i < ne; ++i) | ||
for( int j = 0; j < n; ++j) | ||
newNodes[i] += nodes[j]*c[i*n+j]; | ||
} | ||
|
||
void convertInterpolationFieldPoints(apf::MeshEntity* e, | ||
apf::Field* f, | ||
int n, int ne, apf::NewArray<double>& c) | ||
{ | ||
|
||
apf::NewArray<apf::Vector3> l, b(ne); | ||
apf::NewArray<double> ls, bs(ne); | ||
apf::MeshElement* me = | ||
apf::createMeshElement(f->getMesh(),e); | ||
apf::Element* elem = | ||
apf::createElement(f,me); | ||
|
||
if (apf::getValueType(f) == apf::VECTOR) { | ||
apf::getVectorNodes(elem,l); | ||
convertVectorFieldInterpolationPoints(n, ne, l, c, b); | ||
for(int i = 0; i < ne; ++i) | ||
apf::setVector(f, e, i, b[i]); | ||
} | ||
else if (apf::getValueType(f) == apf::SCALAR) { | ||
apf::getScalarNodes(elem, ls); | ||
convertScalarFieldInterpolationPoints(n, ne, ls, c, bs); | ||
for(int i = 0; i < ne; ++i) | ||
apf::setScalar(f, e, i, bs[i]); | ||
} | ||
else | ||
printf("Field type not implemented\n"); | ||
apf::destroyElement(elem); | ||
apf::destroyMeshElement(me); | ||
} | ||
|
||
void convertInterpolatingFieldToBezier(apf::Mesh2* m_mesh, apf::Field* f) | ||
{ | ||
apf::FieldShape * fs = apf::getShape(f); | ||
int order = fs->getOrder(); | ||
|
||
//apf::Field* fnew = createField( | ||
// m_mesh, "copy_field", apf::getValueType(f), crv::getBezier(order)); | ||
//transferFields(m_mesh, f, fnew); | ||
|
||
int md = m_mesh->getDimension(); | ||
// | ||
int blendingOrder = getBlendingOrder(apf::Mesh::simplexTypes[md]); | ||
//blendingOrder = 0; | ||
// go downward, and convert interpolating to control points | ||
int startDim = md - (blendingOrder > 0); | ||
|
||
for(int d = startDim; d >= 1; --d){ | ||
if(!fs->hasNodesIn(d)) continue; | ||
int n = fs->getEntityShape(apf::Mesh::simplexTypes[d])->countNodes(); | ||
int ne = fs->countNodesOn(apf::Mesh::simplexTypes[d]); | ||
apf::NewArray<double> c; | ||
getBezierTransformationCoefficients(order, | ||
apf::Mesh::simplexTypes[d],c); | ||
apf::MeshEntity* e; | ||
apf::MeshIterator* it = m_mesh->begin(d); | ||
while ((e = m_mesh->iterate(it))){ | ||
if(m_mesh->isOwned(e)) | ||
convertInterpolationFieldPoints(e,f,n,ne,c); | ||
} | ||
m_mesh->end(it); | ||
} | ||
|
||
for( int d = 2; d <= md; ++d){ | ||
std::cout<<" blendingorder of dimension "<<d <<" "<< | ||
getBlendingOrder(apf::Mesh::simplexTypes[d])<<std::endl; | ||
if(!fs->hasNodesIn(d) || | ||
!getBlendingOrder(apf::Mesh::simplexTypes[d])) continue; | ||
int n = fs->getEntityShape(apf::Mesh::simplexTypes[d])->countNodes(); | ||
int ne = fs->countNodesOn(apf::Mesh::simplexTypes[d]); | ||
apf::NewArray<double> c; | ||
getInternalBezierTransformationCoefficients(m_mesh,order,1, | ||
apf::Mesh::simplexTypes[d],c); | ||
apf::MeshEntity* e; | ||
apf::MeshIterator* it = m_mesh->begin(d); | ||
while ((e = m_mesh->iterate(it))){ | ||
if(!isBoundaryEntity(m_mesh,e) && m_mesh->isOwned(e)) | ||
convertInterpolationFieldPoints(e,f,n-ne,ne,c); | ||
} | ||
m_mesh->end(it); | ||
} | ||
|
||
apf::synchronize(f); | ||
|
||
} | ||
|
||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@avinmoharana
Is this used by outside users or only internally?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mortezah
The converInterpolationFieldPoints is not currently used outside, but it would be nice to have an entity-specific convert routine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@avinmoharana
What do you mean by entity-specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mortezah
I meant while testing an operator we construct a toy example where this routine can get the control points/ interpolation points for a specific edge or a face.
The routine convertInterpolationFieldPoints is defined in crvBezierFields.cc and is used in crvBezierSolutionTransfer.cc and we don't have a header file defined for crvBezierFields.