25 #include "mimmo_propagators.hpp"
27 #include "mimmo_parallel.hpp"
52 std::array<double,3> center({{0.0,0.0,0.0}});
53 double radiusin(2.0), radiusout(5.0);
54 double azimuthin(0.0), azimuthout(0.5*BITPIT_PI);
55 double heightbottom(-1.0), heighttop(1.0);
56 int nr(6), nt(10), nh(6);
58 double deltar = (radiusout - radiusin)/
double(nr);
59 double deltat = (azimuthout - azimuthin)/
double(nt);
60 double deltah = (heighttop - heightbottom)/
double(nh);
62 std::vector<std::array<double,3> > verts ((nr+1)*(nt+1)*(nh+1));
65 for(
int k=0; k<=nh; ++k){
66 for(
int j=0; j<=nt; ++j){
67 for(
int i=0; i<=nr; ++i){
68 verts[counter][0] =(radiusin + i*deltar)*std::cos(azimuthin + j*deltat);
69 verts[counter][1] =(radiusin + i*deltar)*std::sin(azimuthin + j*deltat);
70 verts[counter][2] =(heightbottom + k*deltah);
80 mesh->getPatch()->reserveVertices((nr+1)*(nt+1)*(nh+1));
83 for(
const auto & vertex : verts){
84 mesh->addVertex(vertex);
86 mesh->getPatch()->reserveCells(nr*nt*nh);
89 std::vector<long> conn(8,0);
90 for(
int k=0; k<nh; ++k){
91 for(
int j=0; j<nt; ++j){
92 for(
int i=0; i<nr; ++i){
93 conn[0] = (nr+1)*(nt+1)*k + (nr+1)*j + i;
94 conn[1] = (nr+1)*(nt+1)*k + (nr+1)*j + i+1;
95 conn[2] = (nr+1)*(nt+1)*k + (nr+1)*(j+1) + i+1;
96 conn[3] = (nr+1)*(nt+1)*k + (nr+1)*(j+1) + i;
97 conn[4] = (nr+1)*(nt+1)*(k+1) + (nr+1)*j + i;
98 conn[5] = (nr+1)*(nt+1)*(k+1) + (nr+1)*j + i+1;
99 conn[6] = (nr+1)*(nt+1)*(k+1) + (nr+1)*(j+1) + i+1;
100 conn[7] = (nr+1)*(nt+1)*(k+1) + (nr+1)*(j+1) + i;
101 mesh->addConnectedCell(conn, bitpit::ElementType::HEXAHEDRON);
108 boundary = mesh->extractBoundaryMesh();
111 std::vector<std::vector<long>> bverts(6, std::vector<long>());
114 for(
int k=0; k<=nh; ++k){
115 for(
int i=0; i<=nr; ++i){
116 bverts[0].push_back((nr+1)*(nt+1)*k + i);
117 bverts[1].push_back((nr+1)*(nt+1)*k + (nr+1)*nt + i);
122 for(
int j=0; j<=nt; ++j){
123 for(
int i=0; i<=nr; ++i){
124 bverts[2].push_back((nr+1)*j + i);
125 bverts[3].push_back((nr+1)*(nt+1)*nh + (nr+1)*j + i);
130 for(
int k=0; k<=nh; ++k){
131 for(
int j=0; j<=nt; ++j){
132 bverts[4].push_back((nr+1)*(nt+1)*k + (nr+1)*j);
133 bverts[5].push_back((nr+1)*(nt+1)*k + (nr+1)*j + nr);
141 livector1D boundaryfaces = boundary->getCellFromVertexList(vert,
true);
142 for(
long id : boundaryfaces){
143 pidfaces.insert(
id, pidder);
149 for(
auto it= pidfaces.begin(); it!= pidfaces.end(); ++it){
150 boundary->setPIDCell(it.getId(), *it);
153 boundary->updateAdjacencies();
155 boundary->getPatch()->write(
"piddedBoundary_test3");
162 if(!boundary)
return nullptr;
164 livector1D cellsID = boundary->extractPIDCells(pids);
165 livector1D vertID = boundary->getVertexFromCellList(cellsID);
169 extracted->getPatch()->reserveVertices(vertID.size());
170 extracted->getPatch()->reserveCells(cellsID.size());
172 for(
long id: vertID){
173 extracted->addVertex(boundary->getVertexCoords(
id),
id);
175 for(
long id: cellsID){
176 extracted->addCell(boundary->getCells().at(
id),
id);
179 extracted->updateAdjacencies();
192 MPI_Comm_size(MPI_COMM_WORLD, &nProcs);
193 MPI_Comm_rank(MPI_COMM_WORLD, &rank);
205 mimmo::Partition* partition =
new mimmo::Partition();
206 partition->setPlotInExecution(
true);
207 partition->setGeometry(mesh);
208 partition->setBoundaryGeometry(bDirMesh);
209 partition->setPartitionMethod(mimmo::PartitionMethod::PARTGEOM);
221 bc_surf_3Dfield.reserve(bDIR->getNVertices());
223 std::vector<long> d1 = bDIR->getVertexFromCellList(bDIR->extractPIDCells(1));
225 bc_surf_3Dfield.insert(
id, {{0.0, 0.0, 0.0}});
232 double alpha = 25.0*BITPIT_PI/180.0;
233 std::vector<long> d2 = bDIR->getVertexFromCellList(bDIR->extractPIDCells(2));
235 darray3E coord = bDIR->getVertexCoords(
id);
236 double normc = std::sqrt(coord[0]*coord[0] + coord[1]*coord[1]);
237 bc_surf_3Dfield.insert(
id, {{std::sin(alpha)*normc,
238 (std::cos(alpha)-1.0)*normc,
243 mimmo::PropagateVectorField * prop3D =
new mimmo::PropagateVectorField();
244 prop3D->setName(
"test00003_PropagateVectorField");
245 prop3D->setGeometry(mesh);
246 prop3D->addDirichletBoundaryPatch(bDIR);
247 prop3D->addDirichletConditions(&bc_surf_3Dfield);
248 prop3D->addSlipBoundarySurface(bSLIP);
249 prop3D->addSlipReferenceSurface(bSLIP);
251 prop3D->setDamping(
true);
252 prop3D->setDampingType(0);
253 prop3D->setDampingDecayFactor(2.0);
254 prop3D->setDampingInnerDistance(0.5);
255 prop3D->setDampingOuterDistance(2.5);
257 prop3D->setSolverMultiStep(40);
259 prop3D->setPlotInExecution(
true);
266 for(
auto it=values3D->begin(); it!=values3D->end(); ++it){
267 work = mesh->getVertexCoords(it.getId());
268 mesh->modifyVertex(work + *it, it.getId());
271 mesh->getPatch()->write(
"test00003_deformedMesh");
274 long targetNode = (10 +1)*(6+1)*3 + (6+1)*5 + 3;
276 value.fill(-1.0*std::numeric_limits<double>::max());
277 if(values3D->exists(targetNode)) value = values3D->at(targetNode);
280 MPI_Allreduce(MPI_IN_PLACE, value.data(), 3, MPI_DOUBLE, MPI_MAX, prop3D->getCommunicator());
284 std::cout<<targetNode<<
" "<<value<<std::endl;
285 check = check || (norm2(values3D->at(targetNode)-std::array<double,3>({{0.601253, -0.284719, 0.}})) > 1.0E-5);
296 int main(
int argc,
char *argv[] ) {
302 MPI_Init(&argc, &argv);
309 catch(std::exception & e){
310 std::cout<<
"test_propagators_00003 exited with an error of type : "<<e.what()<<std::endl;