25 #include "mimmo_propagators.hpp"
47 std::array<double,3> center({{0.0,0.0,0.0}});
48 double radiusin(2.0), radiusout(5.0);
49 double azimuthin(0.0), azimuthout(0.5*BITPIT_PI);
50 double heightbottom(-1.0), heighttop(1.0);
51 int nr(6), nt(10), nh(6);
53 double deltar = (radiusout - radiusin)/
double(nr);
54 double deltat = (azimuthout - azimuthin)/
double(nt);
55 double deltah = (heighttop - heightbottom)/
double(nh);
57 std::vector<std::array<double,3> > verts ((nr+1)*(nt+1)*(nh+1));
60 for(
int k=0; k<=nh; ++k){
61 for(
int j=0; j<=nt; ++j){
62 for(
int i=0; i<=nr; ++i){
63 verts[counter][0] =(radiusin + i*deltar)*std::cos(azimuthin + j*deltat);
64 verts[counter][1] =(radiusin + i*deltar)*std::sin(azimuthin + j*deltat);
65 verts[counter][2] =(heightbottom + k*deltah);
73 mesh->getPatch()->reserveVertices((nr+1)*(nt+1)*(nh+1));
76 for(
const auto & vertex : verts){
77 mesh->addVertex(vertex);
79 mesh->getPatch()->reserveCells(nr*nt*nh);
82 std::vector<long> conn(8,0);
83 for(
int k=0; k<nh; ++k){
84 for(
int j=0; j<nt; ++j){
85 for(
int i=0; i<nr; ++i){
86 conn[0] = (nr+1)*(nt+1)*k + (nr+1)*j + i;
87 conn[1] = (nr+1)*(nt+1)*k + (nr+1)*j + i+1;
88 conn[2] = (nr+1)*(nt+1)*k + (nr+1)*(j+1) + i+1;
89 conn[3] = (nr+1)*(nt+1)*k + (nr+1)*(j+1) + i;
90 conn[4] = (nr+1)*(nt+1)*(k+1) + (nr+1)*j + i;
91 conn[5] = (nr+1)*(nt+1)*(k+1) + (nr+1)*j + i+1;
92 conn[6] = (nr+1)*(nt+1)*(k+1) + (nr+1)*(j+1) + i+1;
93 conn[7] = (nr+1)*(nt+1)*(k+1) + (nr+1)*(j+1) + i;
94 mesh->addConnectedCell(conn, bitpit::ElementType::HEXAHEDRON);
99 mesh->updateAdjacencies();
100 mesh->updateInterfaces();
103 bcdir1_vertlist.clear();
104 bcdir2_vertlist.clear();
105 bcdir1_vertlist.reserve(mesh->getNVertices());
106 bcdir2_vertlist.reserve(mesh->getNVertices());
108 for(
int k=0; k<=nh; ++k){
109 for(
int i=0; i<=nr; ++i){
110 bcdir1_vertlist.push_back((nr+1)*(nt+1)*k + i);
111 bcdir2_vertlist.push_back((nr+1)*(nt+1)*k + (nr+1)*nt + i);
126 std::vector<long> bc1list, bc2list;
129 livector1D cellInterfaceList1 = mesh->getInterfaceFromVertexList(bc1list,
true,
true);
130 livector1D cellInterfaceList2 = mesh->getInterfaceFromVertexList(bc2list,
true,
true);
134 bdirMesh->getPatch()->reserveVertices(bc1list.size()+bc2list.size());
135 bdirMesh->getPatch()->reserveCells(cellInterfaceList1.size()+cellInterfaceList2.size());
137 for(
auto & val : bc1list){
138 bdirMesh->addVertex(mesh->getVertexCoords(val), val);
140 for(
auto & val : bc2list){
141 bdirMesh->addVertex(mesh->getVertexCoords(val), val);
143 for(
auto & val : cellInterfaceList1){
144 int sizeconn =mesh->getInterfaces().at(val).getConnectSize();
145 long * conn = mesh->getInterfaces().at(val).getConnect();
146 bdirMesh->addConnectedCell(std::vector<long>(&conn[0], &conn[sizeconn]),
147 bitpit::ElementType::QUAD, val);
149 for(
auto & val : cellInterfaceList2){
150 int sizeconn =mesh->getInterfaces().at(val).getConnectSize();
151 long * conn = mesh->getInterfaces().at(val).getConnect();
152 bdirMesh->addConnectedCell(std::vector<long>(&conn[0], &conn[sizeconn]),
153 bitpit::ElementType::QUAD, val);
156 bdirMesh->updateAdjacencies();
160 long targetNode = (10 +1)*(6+1)*3 + (6+1)*5 + 3;
167 bc_surf_field.reserve(bdirMesh->getNVertices());
168 for(
auto & val : bc1list){
169 bc_surf_field.insert(val, 10.0);
171 for(
auto & val : bc2list){
172 bc_surf_field.insert(val, 0.0);
176 mimmo::PropagateScalarField * prop =
new mimmo::PropagateScalarField();
177 prop->setName(
"test00001_PropagateScalarField");
178 prop->setGeometry(mesh);
179 prop->addDirichletBoundaryPatch(bdirMesh);
180 prop->addDirichletConditions(&bc_surf_field);
181 prop->setDamping(
false);
182 prop->setPlotInExecution(
true);
184 mesh->getPatch()->write(
"mesh");
188 auto values = prop->getPropagatedField();
190 check = check || (std::abs(values->at(targetNode)-5.0) > 1.0E-6);
197 bc_surf_3Dfield.reserve(bdirMesh->getNVertices());
198 for(
auto & val : bc1list){
199 bc_surf_3Dfield.insert(val, {{10.0, 7.0, -4.0}});
201 for(
auto & val : bc2list){
202 bc_surf_3Dfield.insert(val, {{0.0,0.0,0.0}});
206 mimmo::PropagateVectorField * prop3D =
new mimmo::PropagateVectorField();
207 prop3D->setName(
"test00001_PropagateVectorField");
208 prop3D->setGeometry(mesh);
209 prop3D->addDirichletBoundaryPatch(bdirMesh);
210 prop3D->addDirichletConditions(&bc_surf_3Dfield);
211 prop3D->setDamping(
true);
212 prop3D->setDampingType(1);
213 prop3D->setDampingDecayFactor(1.0);
214 prop3D->setDampingInnerDistance(0.5);
215 prop3D->setDampingOuterDistance(3.5);
217 prop3D->setPlotInExecution(
true);
221 auto values3D = prop3D->getPropagatedField();
222 check = check || (norm2(values3D->at(targetNode)-std::array<double,3>({{5.0,3.5,-2.0}})) > 1.0E-6);
232 int main(
int argc,
char *argv[] ) {
238 MPI_Init(&argc, &argv);
245 catch(std::exception & e){
246 std::cout<<
"test_propagators_00001 exited with an error of type : "<<e.what()<<std::endl;