Skip to content

Reply To: Segmentation fault for OpenLB 1.5

#6657
Fany
Participant

Here is parts of my code:

#include “olb3D.h”
#include “olb3D.hh”

// #ifndef OLB_PRECOMPILED // Unless precompiled version is used,
// #include “olb3D.hh” // include full template code;
// #endif
#include <vector>
#include <cmath>
#include <iostream>
#include <fstream>

using namespace olb;
using namespace olb::descriptors;
using namespace olb::graphics;
using namespace olb::util;
using namespace std;

typedef double T;

typedef D3Q19<FORCE> NSDESCRIPTOR;
typedef D3Q7<VELOCITY> TDESCRIPTOR;

//simulation parameters
const int N = 35; // resolution of the model
const int M = 100; // time discretization refinement
const bool bouzidiOn = false; // choice of boundary condition
const T maxPhysT = 50.; // max. simulation time in s, SI unit

// === 2nd Step: Prepare Geometry ===

// Instantiation of the STLreader class
// file name, voxel size in meter, stl unit in meter, outer voxel no., inner voxel no.
STLreader<T> stlReader( “test3d.stl”, converter.getConversionFactorLength(), 0.001, 0, true );
IndicatorLayer3D<T> extendedDomain( stlReader, converter.getConversionFactorLength() );

// Instantiation of a cuboidGeometry with weights
#ifdef PARALLEL_MODE_MPI
const int noOfCuboids =std::min( 16*N,2*singleton::mpi().getSize() ) ; //2*singleton::mpi().getSize()
#else
const int noOfCuboids = 2;
#endif
CuboidGeometry3D<T> cuboidGeometry( extendedDomain, converter.getConversionFactorLength(), noOfCuboids );

// Instantiation of a loadBalancer
HeuristicLoadBalancer<T> loadBalancer( cuboidGeometry );

// Instantiation of a superGeometry
SuperGeometry<T,3> superGeometry( cuboidGeometry, loadBalancer, 2);

prepareGeometry( converter, extendedDomain, stlReader, superGeometry );

// === 3rd Step: Prepare Lattice ===
SuperLattice<T, TDESCRIPTOR> ADlattice(superGeometry);
SuperLattice<T, NSDESCRIPTOR> NSlattice(superGeometry);

// ForcedBGKdynamics<T, NSDESCRIPTOR> NSbulkDynamics(
// converter.getLatticeRelaxationFrequency(),
// instances::getBulkMomenta<T,NSDESCRIPTOR>());

// AdvectionDiffusionBGKdynamics<T, TDESCRIPTOR> TbulkDynamics (
// converter.getLatticeThermalRelaxationFrequency(),
// instances::getAdvectionDiffusionBulkMomenta<T,TDESCRIPTOR>());

// std::vector<T> dir{0.0, 1.0, 0.0};

// T boussinesqForcePrefactor = 9.81 / converter.getConversionFactorVelocity() * converter.getConversionFactorTime() *
// converter.getCharPhysTemperatureDifference() * converter.getPhysThermalExpansionCoefficient();

///T boussinesqForcePrefactor=0;

//NavierStokesAdvectionDiffusionCouplingGenerator3D<T,NSDESCRIPTOR> coupling(0, converter.getLatticeLength(0.2388403+0.0058006 ), 0, converter.getLatticeLength(0.249987+0.0112342),
//0, converter.getLatticeLength(0.02246+0.0054686), boussinesqForcePrefactor, converter.getLatticeTemperature(Tcold), 1., dir);

//NSlattice.addLatticeCoupling(coupling, ADlattice);

Timer<T> timer1( converter.getLatticeTime( maxPhysT ), superGeometry.getStatistics().getNvoxel() );
timer1.start();

prepareLattice(converter,
NSlattice, ADlattice,

stlReader,
superGeometry );

timer1.stop();
timer1.printSummary();

// === 4th Step: Main Loop with Timer ===
clout << “starting simulation…” << std::endl;
Timer<T> timer( converter.getLatticeTime( maxPhysT ), superGeometry.getStatistics().getNvoxel() );
timer.start();

for ( std::size_t iT = 0; iT <= converter.getLatticeTime( maxPhysT ); iT++ ) {

// === 5th Step: Definition of Initial and Boundary Conditions ===
setBoundaryValues(converter, NSlattice, ADlattice, iT, superGeometry);

// === 6th Step: Collide and Stream Execution ===

NSlattice.collideAndStream();
ADlattice.collideAndStream();

//NSlattice.executeCoupling();

// === 7th Step: Computation and Output of the Results ===
getResults( converter, NSlattice, ADlattice, iT, superGeometry, timer, stlReader);

}

timer.stop();
timer.printSummary();
}