Example of reading,morphing and writing of a OpenFOAM case mesh. BEWARE: the case is meant for SERIAL version or MPI version running only with 1 processor.PART1 - reading,morphing and writing of a OpenFOAM case mesh.
Mesh is read from an OpenFOAM case. A FFD deformation is applied. The bulk volume mesh is deformed accordingly. In writing, moved bulk points update those on the target mesh.
PART 2 - Example of reading field from a OpenFOAM case mesh
Mesh and its boundary pressure scalar field are read from an OpenFOAM case. The applier get the scalar field and convert it in a vectorfield of geometrical displacements using the local boundary mesh normals. Then apply the displacements to the boundary mesh and save the deformed version in a vtu file.
Using: IOOFOAM, FFDLattice, IOOFOAMScalarField, Apply, Chain
To run: ./ioofoam_example_00001
To run (MPI version): mpirun -np 1 ioofoam_example_00001
Beware: mpi version of the example works only with np=1
visit: mimmo website
#include "mimmo_iogeneric.hpp"
#include "IOOFOAM.hpp"
#include "mimmo_manipulators.hpp"
void OFOAM_manip() {
mimmo::IOOFOAM * reader = new mimmo::IOOFOAM(false);
reader->setDir("geodata/OFOAM");
displ[4][1] = 0.045;
displ[5][1] = 0.045;
displ[6][1] = -0.045;
displ[7][1] = -0.045;
mimmo::IOOFOAM * writer = new mimmo::IOOFOAM(true);
writer->setDir("geodata/OFOAM");
writer->setWritePointsOnly(true);
writer->setOverwrite(false);
delete reader;
delete ffd;
delete applier;
delete writer;
}
void OFOAM_sensi() {
mimmo::IOOFOAM * reader = new mimmo::IOOFOAM(false);
reader->setDir("geodata/OFOAM");
mimmo::IOOFOAMScalarField * fieldreader = new mimmo::IOOFOAMScalarField(false);
fieldreader->setDir("geodata/OFOAM");
fieldreader->setFieldName("p");
delete reader;
delete fieldreader;
delete applier;
delete writer;
}
int main( int argc, char *argv[] ) {
BITPIT_UNUSED(argc);
BITPIT_UNUSED(argv);
#if MIMMO_ENABLE_MPI
MPI_Init(&argc, &argv);
#endif
try{
OFOAM_sensi() ;
}
catch(std::exception & e){
std::cout<<"test_ioofoam_00001 PART1 exit with the following errors :"<<e.what()<<std::endl;
return 1;
}
try{
OFOAM_manip() ;
}
catch(std::exception & e){
std::cout<<"test_ioofoam_00001 PART2 exit with the following errors :"<<e.what()<<std::endl;
return 1;
}
#if MIMMO_ENABLE_MPI
MPI_Finalize();
#endif
return 0;
}