00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <MeshExpression.hpp>
00021 #include <Variable.hpp>
00022
00023 #include <Mesh.hpp>
00024
00025 #include <MeshOfHexahedra.hpp>
00026 #include <MeshOfTetrahedra.hpp>
00027 #include <SpectralMesh.hpp>
00028 #include <Structured3DMesh.hpp>
00029
00030 #include <SurfaceMeshOfQuadrangles.hpp>
00031 #include <SurfaceMeshOfTriangles.hpp>
00032
00033 #include <Domain.hpp>
00034 #include <Scene.hpp>
00035
00036 #include <DomainExpression.hpp>
00037
00038 #include <Union.hpp>
00039
00040 #include <OctreeMeshBuilder.hpp>
00041
00042 #include <MeshDomainTetrahedrizor.hpp>
00043 #include <MeshTetrahedrizor.hpp>
00044 #include <MeshPeriodizer.hpp>
00045 #include <MeshSimplifier.hpp>
00046
00047 #include <MeshReader.hpp>
00048
00049 #include <MeshReaderAM_FMTFormat.hpp>
00050 #include <MeshReaderVTKFormat.hpp>
00051
00052 #include <MeshFormatReader.hpp>
00053 #include <GmshFormatReader.hpp>
00054
00055 #include <MeshTransformer.hpp>
00056
00057 #include <MeshExtractor.hpp>
00058
00059 #include <SurfaceMeshGenerator.hpp>
00060 #include <RealExpression.hpp>
00061
00062 #include <FieldExpression.hpp>
00063 #include <ScalarFunctionBase.hpp>
00064
00065 #include <StringExpression.hpp>
00066
00067 #include <VariableRepository.hpp>
00068
00069 ConstReferenceCounting<Mesh>
00070 MeshExpression::
00071 mesh() const
00072 {
00073 ASSERT(__typeOfMesh != MeshExpression::undefined);
00074 return __mesh;
00075 }
00076
00077 MeshExpression::
00078 MeshExpression(const MeshExpression& e)
00079 : Expression(e),
00080 __mesh(e.__mesh),
00081 __typeOfMesh(e.__typeOfMesh)
00082 {
00083 ;
00084 }
00085
00086 MeshExpression::
00087 MeshExpression(ReferenceCounting<Mesh> mesh,
00088 const MeshExpression::TypeOfMesh& t)
00089 : Expression(Expression::mesh),
00090 __mesh(mesh),
00091 __typeOfMesh(t)
00092 {
00093 ;
00094 }
00095
00096 MeshExpression::
00097 ~MeshExpression()
00098 {
00099 ;
00100 }
00101
00102
00103 std::ostream&
00104 MeshExpressionStructured::
00105 put(std::ostream& os) const
00106 {
00107 const Structured3DMesh& smesh = static_cast<const Structured3DMesh&>(*__mesh);
00108 os << "structured mesh of {(" << smesh.shape().shape().nx() << ','
00109 << smesh.shape().shape().ny() << ','<< smesh.shape().shape().nz()
00110 << ");" << smesh.shape().a() << ';' << smesh.shape().b() << '}';
00111 return os;
00112 }
00113
00114 void MeshExpressionStructured::
00115 execute()
00116 {
00117 TinyVector<3,real_t> a;
00118 TinyVector<3,real_t> b;
00119 TinyVector<3,size_t> n;
00120 __corner1->execute();
00121 __corner2->execute();
00122 __meshSize->execute();
00123 for (size_t i=0; i<3; ++i) {
00124 a[i] = __corner1->value(i);
00125 b[i] = __corner2->value(i);
00126 if (__meshSize->value(i) <= 1) {
00127 throw ErrorHandler(__FILE__,__LINE__,
00128 "Cannot build a structured mesh using "
00129 +stringify(__meshSize->value(i))
00130 +" vertices in direction "
00131 +stringify(i),
00132 ErrorHandler::normal);
00133 }
00134 n[i] = static_cast<size_t>(__meshSize->value(i));
00135 }
00136 ffout(2) << "Building Mesh ... ";
00137 Structured3DMeshShape S(n, a, b);
00138 __mesh
00139 = new Structured3DMesh(S,
00140 new VerticesCorrespondance(S.numberOfVertices()));
00141 ffout(2) << "done\n";
00142 }
00143
00144 MeshExpressionStructured::
00145 MeshExpressionStructured(ReferenceCounting<Vector3Expression> size,
00146 ReferenceCounting<Vector3Expression> corner1,
00147 ReferenceCounting<Vector3Expression> corner2)
00148 : MeshExpression(0, MeshExpression::structured),
00149 __meshSize(size),
00150 __corner1(corner1),
00151 __corner2(corner2)
00152 {
00153 ;
00154 }
00155
00156
00157 MeshExpressionStructured::
00158 MeshExpressionStructured(const MeshExpressionStructured& m)
00159 : MeshExpression(m),
00160 __meshSize(m.__meshSize),
00161 __corner1(m.__corner1),
00162 __corner2(m.__corner2)
00163 {
00164 ;
00165 }
00166
00167 MeshExpressionStructured::
00168 ~MeshExpressionStructured()
00169 {
00170 ;
00171 }
00172
00173
00174
00175 std::ostream&
00176 MeshExpressionSpectral::
00177 put(std::ostream& os) const
00178 {
00179 const SpectralMesh& smesh = static_cast<const SpectralMesh&>(*__mesh);
00180 os << "spectral mesh of {(" << smesh.shape().shape().nx() << ','
00181 << smesh.shape().shape().ny() << ','<< smesh.shape().shape().nz()
00182 << ");" << smesh.shape().a() << ';' << smesh.shape().b() << '}';
00183 return os;
00184 }
00185
00186 void MeshExpressionSpectral::
00187 execute()
00188 {
00189 TinyVector<3,real_t> a;
00190 TinyVector<3,real_t> b;
00191 TinyVector<3,size_t> n;
00192 __corner1->execute();
00193 __corner2->execute();
00194 __degree->execute();
00195 for (size_t i=0; i<3; ++i) {
00196 a[i] = __corner1->value(i);
00197 b[i] = __corner2->value(i);
00198 if (__degree->value(i) < 0) {
00199 throw ErrorHandler(__FILE__,__LINE__,
00200 "Cannot build a spectral mesh using degree "
00201 +stringify(__degree->value(i))
00202 +" in direction "
00203 +stringify(i),
00204 ErrorHandler::normal);
00205 }
00206 n[i] = static_cast<size_t>(__degree->value(i));
00207 }
00208 ffout(2) << "Building Mesh ... ";
00209 Structured3DMeshShape degrees(n, a, b);
00210 Structured3DMeshShape shape (n+TinyVector<3,size_t>(2,2,2), a, b);
00211 __mesh
00212 = new SpectralMesh(degrees,new VerticesCorrespondance(shape.numberOfVertices()));
00213 ffout(2) << "done\n";
00214 }
00215
00216 MeshExpressionSpectral::
00217 MeshExpressionSpectral(ReferenceCounting<Vector3Expression> degree,
00218 ReferenceCounting<Vector3Expression> corner1,
00219 ReferenceCounting<Vector3Expression> corner2)
00220 : MeshExpression(0, MeshExpression::spectral),
00221 __degree(degree),
00222 __corner1(corner1),
00223 __corner2(corner2)
00224 {
00225 ;
00226 }
00227
00228
00229 MeshExpressionSpectral::
00230 MeshExpressionSpectral(const MeshExpressionSpectral& m)
00231 : MeshExpression(m),
00232 __degree(m.__degree),
00233 __corner1(m.__corner1),
00234 __corner2(m.__corner2)
00235 {
00236 ;
00237 }
00238
00239 MeshExpressionSpectral::
00240 ~MeshExpressionSpectral()
00241 {
00242 ;
00243 }
00244
00245 std::ostream& MeshExpressionSurface::
00246 put(std::ostream& os) const
00247 {
00248 throw ErrorHandler(__FILE__,__LINE__,
00249 "not implemented",
00250 ErrorHandler::unexpected);
00251 return os;
00252 }
00253
00254 template <typename MeshType>
00255 void MeshExpressionSurface::
00256 __getSurfaceMesh(MeshType& mesh)
00257 {
00258 if (mesh.hasBorderMesh()) {
00259 __mesh = mesh.borderBaseMesh();
00260 } else {
00261 throw ErrorHandler(__FILE__,__LINE__,
00262 "mesh \""+stringify(*__volumeMesh)+"\" has no surface mesh",
00263 ErrorHandler::normal);
00264 }
00265 }
00266
00267
00268 void MeshExpressionSurface::
00269 execute()
00270 {
00271 __volumeMesh->execute();
00272
00273 if (__volumeMesh->mesh()->family() != Mesh::volume) {
00274 throw ErrorHandler(__FILE__,__LINE__,
00275 "Cannot build a surface mesh using mesh \""+
00276 stringify(*__volumeMesh)+
00277 "\" a volume mesh is mandatory!",
00278 ErrorHandler::normal);
00279 }
00280
00281 if (__domain == 0) {
00282
00283 switch (__volumeMesh->mesh()->type()) {
00284 case Mesh::cartesianHexahedraMesh: {
00285 this->__getSurfaceMesh(dynamic_cast<const Structured3DMesh&>(*__volumeMesh->mesh()));
00286 break;
00287 }
00288 case Mesh::hexahedraMesh: {
00289 this->__getSurfaceMesh(dynamic_cast<const MeshOfHexahedra&>(*__volumeMesh->mesh()));
00290 break;
00291 }
00292 case Mesh::tetrahedraMesh: {
00293 this->__getSurfaceMesh(dynamic_cast<const MeshOfTetrahedra&>(*__volumeMesh->mesh()));
00294 break;
00295 }
00296 case Mesh::spectralMesh: {
00297 this->__getSurfaceMesh(dynamic_cast<const SpectralMesh&>(*__volumeMesh->mesh()));
00298 break;
00299 }
00300 default: {
00301 throw ErrorHandler(__FILE__,__LINE__,
00302 "cannot get boundary of mesh \""+stringify(*__volumeMesh)+"\"",
00303 ErrorHandler::unexpected);
00304 }
00305 }
00306 } else {
00307 __domain->execute();
00308
00309 Domain& omega = *__domain->domain();
00310
00311 if(omega.isR3()) {
00312 throw ErrorHandler(__FILE__,__LINE__,
00313 "trying to mesh the boundary of R3!",
00314 ErrorHandler::normal);
00315 }
00316
00317 switch (__volumeMesh->mesh()->type()) {
00318 case Mesh::cartesianHexahedraMesh: {
00319 __mesh = new SurfaceMeshOfTriangles();
00320 const Structured3DMesh& volumeMesh
00321 = dynamic_cast<const Structured3DMesh&>(*__volumeMesh->mesh());
00322 #warning REMOVE THIS REINTERPRETE CAST
00323 SurfaceMeshOfTriangles& surfaceMesh
00324 = const_cast<SurfaceMeshOfTriangles&>(static_cast<const SurfaceMeshOfTriangles&>(*__mesh));
00325
00326 SurfaceMeshGenerator S;
00327 S.generateSurfacicMesh(omega,
00328 volumeMesh,
00329 surfaceMesh);
00330 break;
00331 }
00332 default: {
00333 throw ErrorHandler(__FILE__,__LINE__,
00334 "octree mesh generation not yet implemented for \""+
00335 stringify(*__volumeMesh)+"\"'s type",
00336 ErrorHandler::normal);
00337 }
00338 }
00339 }
00340 }
00341
00342 MeshExpressionSurface::
00343 MeshExpressionSurface(ReferenceCounting<DomainExpression> domain,
00344 ReferenceCounting<MeshExpression> volumeMesh)
00345 : MeshExpression(0, MeshExpression::surface),
00346 __domain(domain),
00347 __volumeMesh(volumeMesh)
00348 {
00349 ;
00350 }
00351
00352 MeshExpressionSurface::
00353 MeshExpressionSurface(ReferenceCounting<MeshExpression> volumeMesh)
00354 : MeshExpression(0, MeshExpression::surface),
00355 __domain(0),
00356 __volumeMesh(volumeMesh)
00357 {
00358 ;
00359 }
00360
00361
00362 MeshExpressionSurface::
00363 MeshExpressionSurface(const MeshExpressionSurface& m)
00364 : MeshExpression(m),
00365 __domain(m.__domain),
00366 __volumeMesh(m.__volumeMesh)
00367 {
00368 ;
00369 }
00370
00371 MeshExpressionSurface::
00372 ~MeshExpressionSurface()
00373 {
00374 ;
00375 }
00376
00377
00378 std::ostream&
00379 MeshExpressionOctree::
00380 put(std::ostream& os) const
00381 {
00382 throw ErrorHandler(__FILE__,__LINE__,
00383 "not implemented",
00384 ErrorHandler::unexpected);
00385 return os;
00386 }
00387
00388 void
00389 MeshExpressionOctree::
00390 execute()
00391 {
00392 __domainExpression->execute();
00393 __meshExpression->execute();
00394 __levelExpression->execute();
00395
00396 OctreeMeshBuilder builder(__domainExpression->domain(),
00397 __meshExpression->mesh(),
00398 __levelExpression->realValue());
00399 builder.buildMesh();
00400 __mesh = builder.getBaseMesh();
00401 }
00402
00403 MeshExpressionOctree::
00404 MeshExpressionOctree(ReferenceCounting<DomainExpression> domainExpression,
00405 ReferenceCounting<MeshExpression> meshExpression,
00406 ReferenceCounting<RealExpression> levelExpression)
00407 : MeshExpression(0, MeshExpression::octree),
00408 __domainExpression(domainExpression),
00409 __meshExpression(meshExpression),
00410 __levelExpression(levelExpression)
00411 {
00412 ;
00413 }
00414
00415 MeshExpressionOctree::
00416 MeshExpressionOctree(const MeshExpressionOctree& m)
00417 : MeshExpression(m),
00418 __domainExpression(m.__domainExpression),
00419 __meshExpression(m.__meshExpression),
00420 __levelExpression(m.__levelExpression)
00421 {
00422 ;
00423 }
00424
00425 MeshExpressionOctree::
00426 ~MeshExpressionOctree()
00427 {
00428 ;
00429 }
00430
00431
00432
00433 void MeshExpressionVariable::
00434 execute()
00435 {
00436 __meshVariable = VariableRepository::instance().findVariable<MeshVariable>(__meshName);
00437 __mesh = __meshVariable->expression()->mesh();
00438 }
00439
00440 MeshExpressionVariable::
00441 MeshExpressionVariable(const std::string& meshName)
00442 : MeshExpression(0,MeshExpression::variable),
00443 __meshName(meshName),
00444 __meshVariable(0)
00445 {
00446 ;
00447 }
00448
00449 MeshExpressionVariable::
00450 MeshExpressionVariable(const MeshExpressionVariable& e)
00451 : MeshExpression(e),
00452 __meshName(e.__meshName),
00453 __meshVariable(e.__meshVariable)
00454 {
00455 ;
00456 }
00457
00458 MeshExpressionVariable::
00459 ~MeshExpressionVariable()
00460 {
00461 ;
00462 }
00463
00464 std::ostream&
00465 MeshExpressionRead::
00466 put(std::ostream& os) const
00467 {
00468 os << "read(" << __fileDescriptor->formatName() << ",\"" << __filename->value() << "\")";
00469 return os;
00470 }
00471
00472 void MeshExpressionRead::
00473 execute()
00474 {
00475 __filename->execute();
00476 const std::string filename = __filename->value();
00477
00478 try {
00479 ReferenceCounting<MeshReader> reader;
00480
00481 switch (__fileDescriptor->format()) {
00482 case FileDescriptor::am_fmt:
00483 reader = new MeshReaderAM_FMTFormat(filename);
00484 break;
00485 case FileDescriptor::medit:
00486 reader = new MeshFormatReader(filename);
00487 break;
00488 case FileDescriptor::gmsh:
00489 reader = new GmshFormatReader(filename);
00490 break;
00491 case FileDescriptor::vtk:
00492 reader = new MeshReaderVTKFormat(filename);
00493 break;
00494 default:
00495 throw MeshReader::Error("no support for reading '"+__fileDescriptor->formatName()+"' format");
00496 break;
00497 }
00498 __mesh = reader->mesh();
00499 } catch (MeshReader::Error& e) {
00500 throw ErrorHandler(__FILE__,__LINE__,
00501 e.message(),
00502 ErrorHandler::normal);
00503 }
00504 }
00505
00506 MeshExpressionRead::
00507 MeshExpressionRead(ReferenceCounting<FileDescriptor> descriptor,
00508 ReferenceCounting<StringExpression> filename)
00509 : MeshExpression(0, MeshExpression::read),
00510 __fileDescriptor(descriptor),
00511 __filename(filename)
00512 {
00513 ;
00514 }
00515
00516 MeshExpressionRead::
00517 MeshExpressionRead(const MeshExpressionRead& m)
00518 : MeshExpression(m),
00519 __fileDescriptor(m.__fileDescriptor),
00520 __filename(m.__filename)
00521 {
00522 ;
00523 }
00524
00525 MeshExpressionRead::~MeshExpressionRead()
00526 {
00527 ;
00528 }
00529
00530 std::ostream&
00531 MeshExpressionSimplify::
00532 put(std::ostream& os) const
00533 {
00534 os << "simplify("
00535 << (*__originalMesh) << ')';
00536 return os;
00537 }
00538
00539 void
00540 MeshExpressionSimplify::
00541 execute()
00542 {
00543 (*__originalMesh).execute();
00544 MeshSimplifier M((*__originalMesh).mesh());
00545 __mesh = M.mesh();
00546 }
00547
00548 MeshExpressionSimplify::
00549 MeshExpressionSimplify(ReferenceCounting<MeshExpression> me)
00550 : MeshExpression(0, MeshExpression::simplify),
00551 __originalMesh(me)
00552 {
00553 ;
00554 }
00555
00556 MeshExpressionSimplify::
00557 MeshExpressionSimplify(const MeshExpressionSimplify& e)
00558 : MeshExpression(e),
00559 __originalMesh(e.__originalMesh)
00560 {
00561 ;
00562 }
00563
00564 MeshExpressionSimplify::
00565 ~MeshExpressionSimplify()
00566 {
00567 ;
00568 }
00569
00570
00571 std::ostream&
00572 MeshExpressionExtract::
00573 put(std::ostream& os) const
00574 {
00575 os << "extract(" << (*__originalMesh) << ','
00576 << (*__referenceToExtract) << ')';
00577 return os;
00578 }
00579
00580 template <typename ExtractedMeshType>
00581 void MeshExpressionExtract::__extract()
00582 {
00583 const Mesh* mesh = __originalMesh->mesh();
00584
00585 MeshExtractor<ExtractedMeshType>
00586 extractor(dynamic_cast<const ExtractedMeshType*>(mesh));
00587
00588 const int ref = static_cast<int>(__referenceToExtract->realValue());
00589 if (ref < 0) {
00590 throw ErrorHandler(__FILE__,__LINE__,
00591 "Element references have to be positives",
00592 ErrorHandler::normal);
00593 }
00594 std::set<size_t> refSet;
00595 refSet.insert(static_cast<size_t>(ref));
00596 __mesh = extractor(refSet);
00597 }
00598
00599 void
00600 MeshExpressionExtract::
00601 execute()
00602 {
00603 (*__originalMesh).execute();
00604 (*__referenceToExtract).execute();
00605
00606 switch ((*(*__originalMesh).mesh()).type()) {
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619 case Mesh::tetrahedraMesh: {
00620 this->__extract<MeshOfTetrahedra>();
00621 break;
00622 }
00623 case Mesh::surfaceMeshQuadrangles: {
00624 this->__extract<SurfaceMeshOfQuadrangles>();
00625 break;
00626 }
00627 case Mesh::surfaceMeshTriangles: {
00628 this->__extract<SurfaceMeshOfTriangles>();
00629 break;
00630 }
00631 default: {
00632 throw ErrorHandler(__FILE__,__LINE__,
00633 "not implemented",
00634 ErrorHandler::unexpected);
00635 }
00636 }
00637 }
00638
00639 MeshExpressionExtract::
00640 MeshExpressionExtract(ReferenceCounting<MeshExpression> me,
00641 ReferenceCounting<RealExpression> re)
00642 : MeshExpression(0, MeshExpression::extract),
00643 __originalMesh(me),
00644 __referenceToExtract(re)
00645 {
00646 ;
00647 }
00648
00649 MeshExpressionExtract::
00650 MeshExpressionExtract(const MeshExpressionExtract& e)
00651 : MeshExpression(e),
00652 __originalMesh(e.__originalMesh),
00653 __referenceToExtract(e.__referenceToExtract)
00654 {
00655 ;
00656 }
00657
00658 MeshExpressionExtract::
00659 ~MeshExpressionExtract()
00660 {
00661 ;
00662 }
00663
00664
00665
00666 void
00667 MeshExpressionTetrahedrize::execute()
00668 {
00669 (*__inputMesh).execute();
00670 ffout(3) << "Converting to tetrahedra "
00671 << (*__inputMesh) << '\n';
00672 MeshTetrahedrizor mt((*__inputMesh).mesh());
00673
00674 mt.run();
00675
00676 __mesh = mt.mesh();
00677 ffout(3) << "Converting to tetrahedra done\n";
00678 }
00679
00680 MeshExpressionTetrahedrize::
00681 MeshExpressionTetrahedrize(ReferenceCounting<MeshExpression> m)
00682 : MeshExpression(0,MeshExpression::tetrahedrize),
00683 __inputMesh(m)
00684 {
00685 ;
00686 }
00687
00688 MeshExpressionTetrahedrize::
00689 MeshExpressionTetrahedrize(const MeshExpressionTetrahedrize& m)
00690 : MeshExpression(m),
00691 __inputMesh(m.__inputMesh)
00692 {
00693 ;
00694 }
00695
00696 MeshExpressionTetrahedrize::
00697 ~MeshExpressionTetrahedrize()
00698 {
00699 ;
00700 }
00701
00702
00703
00704
00705 void
00706 MeshExpressionTetrahedrizeDomain
00707 ::execute()
00708 {
00709 (*__inputMesh).execute();
00710 (*__domain).execute();
00711 ffout(3) << "Building domain tetrahedral mesh\n";
00712 MeshDomainTetrahedrizor mt((*__inputMesh).mesh(),
00713 (*__domain).domain());
00714
00715 mt.run();
00716
00717 __mesh = mt.mesh();
00718 ffout(3) << "Building domain tetrahedral mesh: done\n";
00719 }
00720
00721 MeshExpressionTetrahedrizeDomain::
00722 MeshExpressionTetrahedrizeDomain(ReferenceCounting<MeshExpression> m,
00723 ReferenceCounting<DomainExpression> d)
00724 : MeshExpression(0,MeshExpression::tetrahedrizeDomain),
00725 __inputMesh(m),
00726 __domain(d)
00727 {
00728 ;
00729 }
00730
00731 MeshExpressionTetrahedrizeDomain::
00732 MeshExpressionTetrahedrizeDomain(const MeshExpressionTetrahedrizeDomain& m)
00733 : MeshExpression(m),
00734 __inputMesh(m.__inputMesh),
00735 __domain(m.__domain)
00736 {
00737 ;
00738 }
00739
00740 MeshExpressionTetrahedrizeDomain::
00741 ~MeshExpressionTetrahedrizeDomain()
00742 {
00743 ;
00744 }
00745
00746
00747
00748 void
00749 MeshExpressionTransform::execute()
00750 {
00751 __inputMesh->execute();
00752 __transformationField->execute();
00753
00754 if (__transformationField->numberOfComponents() != 3) {
00755 throw ErrorHandler(__FILE__,__LINE__,
00756 "mesh transformation needs a 3 component field:\n"
00757 +stringify(*__transformationField)+"has "
00758 +stringify(__transformationField->numberOfComponents())+" components",
00759 ErrorHandler::normal);
00760 }
00761
00762 MeshTransformer transformer(__inputMesh->mesh(),
00763 __transformationField->field());
00764
00765 transformer.transform();
00766
00767 __mesh = transformer.mesh();
00768 }
00769
00770 MeshExpressionTransform::
00771 MeshExpressionTransform(ReferenceCounting<MeshExpression> m,
00772 ReferenceCounting<FieldExpression> f)
00773 : MeshExpression(0,MeshExpression::transform),
00774 __inputMesh(m),
00775 __transformationField(f)
00776 {
00777 ;
00778 }
00779
00780 MeshExpressionTransform::
00781 MeshExpressionTransform(const MeshExpressionTransform& m)
00782 : MeshExpression(m),
00783 __inputMesh(m.__inputMesh),
00784 __transformationField(m.__transformationField)
00785 {
00786 ;
00787 }
00788
00789 MeshExpressionTransform::
00790 ~MeshExpressionTransform()
00791 {
00792 ;
00793 }
00794
00795
00796
00797 void
00798 MeshExpressionPeriodic::execute()
00799 {
00800 (*__inputMesh).execute();
00801
00802 MeshPeriodizer::ReferencesMapping referencesMapping;
00803
00804 MappedReferencesList& mappedReferences = (*__mappedReferences);
00805 for (MappedReferencesList::iterator i = mappedReferences.begin();
00806 i != mappedReferences.end(); ++i) {
00807 (*(*i).first).execute();
00808 (*(*i).second).execute();
00809 const real_t first = (*(*i).first).realValue();
00810 const real_t second= (*(*i).second).realValue();
00811 if ((first != int(first)) or (second != int(second))) {
00812 throw ErrorHandler(__FILE__,__LINE__,
00813 "invalid periodic references ("
00814 +stringify(first)+"<->"+stringify(second)
00815 +") You must give integers value",
00816 ErrorHandler::normal);
00817 }
00818 referencesMapping.push_back(std::make_pair(static_cast<size_t>(first),
00819 static_cast<size_t>(second)));
00820 }
00821
00822 MeshPeriodizer periodizer((*__inputMesh).mesh(), referencesMapping);
00823 periodizer.run();
00824 __mesh = periodizer.mesh();
00825 }
00826
00827 MeshExpressionPeriodic::
00828 MeshExpressionPeriodic(ReferenceCounting<MeshExpression> m,
00829 ReferenceCounting<MappedReferencesList> l)
00830 : MeshExpression(0,MeshExpression::periodic),
00831 __inputMesh(m),
00832 __mappedReferences(l)
00833 {
00834 ;
00835 }
00836
00837 MeshExpressionPeriodic::
00838 MeshExpressionPeriodic(const MeshExpressionPeriodic& m)
00839 : MeshExpression(m),
00840 __inputMesh(m.__inputMesh),
00841 __mappedReferences(m.__mappedReferences)
00842 {
00843 ;
00844 }
00845
00846 MeshExpressionPeriodic::
00847 ~MeshExpressionPeriodic()
00848 {
00849 ;
00850 }
00851
00852
00853 MeshExpressionUndefined::MeshExpressionUndefined()
00854 : MeshExpression(0, MeshExpression::undefined)
00855 {
00856 ;
00857 }
00858
00859 MeshExpressionUndefined
00860 ::MeshExpressionUndefined(const MeshExpressionUndefined& m)
00861 : MeshExpression(m)
00862 {
00863 ;
00864 }
00865
00866 MeshExpressionUndefined
00867 ::~MeshExpressionUndefined()
00868 {
00869 ;
00870 }
00871