Skip to content

Commit

Permalink
Apps: update tests unitaires
Browse files Browse the repository at this point in the history
  • Loading branch information
benoit128 committed Jan 28, 2025
1 parent 2152b00 commit 9b31edd
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 37 deletions.
12 changes: 6 additions & 6 deletions Cassiopee/Apps/Apps/Fast/IBM.py
Original file line number Diff line number Diff line change
Expand Up @@ -1402,7 +1402,7 @@ def __init__(self):
self.wallAdapt = None
self.yplus = 100.
self.yplusAdapt = 100.
self.ConservativeFlux = False
self.conservativeFlux = False

class IBM(Common):
"""Prepare IBM for FastS"""
Expand Down Expand Up @@ -3228,7 +3228,7 @@ def prepare(self, t_case, t_out, tc_out):
##OUT - tbbc :pytree of the bounding box of tc
tc=self.setInterpDataAndSetInterpTransfer__(t)

if self.input_var.ConservativeFlux==True: self.buildConservativeFlux__(t,tc)
if self.input_var.conservativeFlux: self.buildConservativeFlux__(t, tc)

## ================================================
## ======= Specific treatment for front 2 =========
Expand Down Expand Up @@ -3540,7 +3540,7 @@ def computeSnearOpt(Re=None, tb=None, Lref=1., q=1.2, yplus=300., Cf_law='ANSYS'
def prepare0(t_case, t_out, tc_out, snears=0.01, dfars=10.,
tbox=None, snearsf=None, yplus=100.,
vmin=21, check=False, format='single', frontType=1, recomputeDist=False,
expand=3, tinit=None, initWithBBox=-1., wallAdapt=None, dfarDir=0, check_snear=False, ConservativeFlux=False):
expand=3, tinit=None, initWithBBox=-1., wallAdapt=None, dfarDir=0, check_snear=False, conservativeFlux=False):
prep_local=IBM()
prep_local.input_var.snears =snears
prep_local.input_var.dfars =dfars
Expand All @@ -3558,7 +3558,7 @@ def prepare0(t_case, t_out, tc_out, snears=0.01, dfars=10.,
prep_local.input_var.initWithBBox =initWithBBox
prep_local.input_var.wallAdapt =wallAdapt
prep_local.input_var.dfarDir =dfarDir
prep_local.input_var.ConservativeFlux =ConservativeFlux
prep_local.input_var.conservativeFlux =conservativeFlux

t,tc = prep_local.prepare(t_case, t_out, tc_out)

Expand All @@ -3573,7 +3573,7 @@ def prepare1(t_case, t_out, tc_out, t_in=None, to=None, snears=0.01, dfars=10.,
distrib=True, expand=3, tinit=None, initWithBBox=-1., wallAdapt=None, yplusAdapt=100., dfarDir=0,
correctionMultiCorpsF42=False, blankingF42=False, twoFronts=False, redistribute=False, IBCType=1,
height_in=-1.0,isFilamentOnly=False, cleanCellN=True, check_snear=False, generateCartesianMeshOnly=False,
tbOneOver=None, ConservativeFlux=False):
tbOneOver=None, conservativeFlux=False):
prep_local=IBM()
prep_local.input_var.t_in =t_in
prep_local.input_var.to =to
Expand Down Expand Up @@ -3613,7 +3613,7 @@ def prepare1(t_case, t_out, tc_out, t_in=None, to=None, snears=0.01, dfars=10.,
prep_local.input_var.cleanCellN =cleanCellN
prep_local.input_var.generateCartesianMeshOnly = generateCartesianMeshOnly
prep_local.input_var.tbOneOver = tbOneOver
prep_local.input_var.ConservativeFlux =ConservativeFlux
prep_local.input_var.conservativeFlux =conservativeFlux

t,tc = prep_local.prepare(t_case, t_out, tc_out)
return t, tc
3 changes: 3 additions & 0 deletions Cassiopee/Apps/test/IBMOutletControlPressure_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@

Internal._rmNodesByName(t, '.Solver#Param')
Internal._rmNodesByName(t, '.Solver#ownData')

Internal._rmNodesByName(tc, '.Solver#Param')
Internal._rmNodesByName(tc, '.Solver#ownData')
Internal._rmNodesFromName(tc, 'Parameter_int')
Internal._rmNodesFromName(tc, 'Parameter_real')

test.testT(tc,4)
#test.testT(t ,5)
5 changes: 4 additions & 1 deletion Cassiopee/Apps/test/IBMrotationCompute_t1.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,12 @@

Internal._rmNodesByName(t, '.Solver#Param')
Internal._rmNodesByName(t, '.Solver#ownData')
Internal._rmNodesFromName(t, 'Parameter_int')
Internal._rmNodesFromName(t, 'Parameter_real')
Internal._rmNodesByName(tc, '.Solver#Param')
Internal._rmNodesByName(tc, '.Solver#ownData')

Internal._rmNodesFromName(tc, 'Parameter_int')
Internal._rmNodesFromName(tc, 'Parameter_real')
test.testT(t,1)
test.testT(tc,2)

Expand Down
4 changes: 2 additions & 2 deletions Cassiopee/CPlot/CPlot/Display/solidStyles.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
case 2:
// Couleur uniforme blanche
color1[0] = 1.; color1[1] = 1.; color1[2] = 1.;
color2[0] = 1.; color2[1] = 1.; color2[2] = 1;
color2[0] = 1.; color2[1] = 1.; color2[2] = 1;
break;

case 3:
// Couleur uniforme cyan
color1[0] = 0.9; color1[1] = 1.; color1[2] = 1.;
color2[0] = 0.1; color2[1] = 0.1; color2[2] = 1;
color2[0] = 0.1; color2[1] = 0.1; color2[2] = 1;
break;

case 4:
Expand Down
28 changes: 18 additions & 10 deletions Cassiopee/CPlot/CPlot/Shaders/ShaderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ ShaderManager::ShaderManager()
ShaderManager::~ShaderManager()
{
deactivate();
for ( std::vector<Shader *>::iterator itShad = _shaderList.begin();
itShad != _shaderList.end(); itShad++ ) {
for ( std::vector<Shader *>::iterator itShad = _shaderList.begin(); itShad != _shaderList.end(); itShad++ )
{
delete ( *itShad );
}
}
Expand Down Expand Up @@ -107,7 +107,8 @@ Shader* ShaderManager::addFromFile( const char *geomFile, const char *vertexFile
delete shad;
return nullptr;
}
} catch ( std::runtime_error &err ) {
} catch ( std::runtime_error &err )
{
std::cerr << "Failed to load shader : " << err.what() << std::endl;
return nullptr;
}
Expand Down Expand Up @@ -156,7 +157,8 @@ Shader* ShaderManager::addFromFile( const char* vertexFile,
delete shad;
return nullptr;
}
} catch ( std::runtime_error &err ) {
} catch ( std::runtime_error &err )
{
std::cerr << "Failed to load shader : " << err.what() << std::endl;
return nullptr;
}
Expand Down Expand Up @@ -193,8 +195,10 @@ unsigned short ShaderManager::getId(Shader* shad) const
bool ShaderManager::eraseShader( Shader *obj )
{
std::vector<Shader *>::iterator it = _shaderList.begin();
while ( it != _shaderList.end() ) {
if ( ( *it ) == obj ) {
while ( it != _shaderList.end() )
{
if ( ( *it ) == obj )
{
_shaderList.erase( it );
delete obj;
return true;
Expand All @@ -205,7 +209,8 @@ bool ShaderManager::eraseShader( Shader *obj )
//=============================================================================
void ShaderManager::set_tesselation( unsigned short idTess )
{
if ( idTess == 0 ) {
if ( idTess == 0 )
{
unset_tesselation();
return;
}
Expand All @@ -224,7 +229,8 @@ bool ShaderManager::has_tesselation() const
// ----------------------------------------------------------------------------
void ShaderManager::activate( unsigned short id )
{
if ( m_previous_shader != nullptr ) {
if ( m_previous_shader != nullptr )
{
m_previous_shader->end();
m_previous_shader = nullptr;
}
Expand All @@ -246,9 +252,11 @@ void ShaderManager::activate( Shader *shad )
_currentActiveShader = 0;
unsigned short id = 0;
std::vector<Shader *>::iterator it = _shaderList.begin();
while ( it != _shaderList.end() ) {
while ( it != _shaderList.end() )
{
id++;
if ( ( *it ) == shad ) {
if ( ( *it ) == shad )
{
activate( id );
_currentActiveShader = id;
m_previous_shader = shad;
Expand Down
18 changes: 12 additions & 6 deletions Cassiopee/CPlot/CPlot/Shaders2.0/ShaderManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ ShaderManager::~ShaderManager()
{
deactivate();
for ( std::vector<Shader *>::iterator itShad = _shaderList.begin();
itShad != _shaderList.end(); itShad++ ) {
itShad != _shaderList.end(); itShad++ )
{
delete ( *itShad );
}
}
Expand Down Expand Up @@ -160,8 +161,10 @@ unsigned short ShaderManager::getId(Shader* shad) const
bool ShaderManager::eraseShader(Shader* obj)
{
std::vector<Shader *>::iterator it = _shaderList.begin();
while ( it != _shaderList.end() ) {
if ( ( *it ) == obj ) {
while ( it != _shaderList.end() )
{
if ( ( *it ) == obj )
{
_shaderList.erase( it );
delete obj;
return true;
Expand Down Expand Up @@ -194,7 +197,8 @@ void ShaderManager::activate(unsigned short id)
// ----------------------------------------------------------------------------
void ShaderManager::activate( unsigned short id )
{
if ( m_previous_shader != nullptr ) {
if ( m_previous_shader != nullptr )
{
m_previous_shader->end();
m_previous_shader = nullptr;
}
Expand All @@ -216,9 +220,11 @@ void ShaderManager::activate(Shader* shad)
_currentActiveShader = 0;
unsigned short id = 0;
std::vector<Shader *>::iterator it = _shaderList.begin();
while ( it != _shaderList.end() ) {
while ( it != _shaderList.end() )
{
id++;
if ( ( *it ) == shad ) {
if ( ( *it ) == shad )
{
activate( id );
_currentActiveShader = id;
m_previous_shader = shad;
Expand Down
20 changes: 10 additions & 10 deletions Cassiopee/Generator/Generator/extendCartGrids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ PyObject* K_GENERATOR::extendCartGrids(PyObject* self, PyObject* args)
return NULL;
}
if (ext == 0) return arrays;
if (optimized != 0 && optimized != 1 && optimized != -1)
{printf("Warning: extendCartGrids: optimized is set to 1.\n"); optimized = 1;}
if (optimized != 0 && optimized != 1 && optimized != -1)
{ printf("Warning: extendCartGrids: optimized is set to 1.\n"); optimized = 1; }

// Extract infos from arrays
vector<E_Int> resl;
Expand Down Expand Up @@ -107,7 +107,7 @@ PyObject* K_GENERATOR::extendCartGrids(PyObject* self, PyObject* args)
}

// Determination des extensions pour chq zone a partir de l'octree
E_Int extg = ext; E_Int extf = ext; E_Int extff= ext;
E_Int extg = ext; E_Int extf = ext; E_Int extff = ext;
if (optimized == 1) {extg = ext-1; extff = extg;}
if (optimized ==-1) {extg = ext+1;}

Expand Down Expand Up @@ -325,22 +325,22 @@ PyObject* K_GENERATOR::extendCartGrids(PyObject* self, PyObject* args)
face.begin(3), cnf, xp, yp, zp,
p0, p1, p2, p);
dx = xp-xt1[indA1]; dy = yp-yt1[indA1]; dz = zp-zt1[indA1];
if ( ret > -1 && dx*dx + dy*dy + dz*dz <= tol2 )
{found1 = 1; dhmax = K_FUNC::E_max(dhmax,s2); }
if ( found1 == 1 ) goto finjmin2;
if (ret > -1 && dx*dx + dy*dy + dz*dz <= tol2)
{ found1 = 1; dhmax = K_FUNC::E_max(dhmax,s2); }
if (found1 == 1) goto finjmin2;

// projeter le pt B sur la facette opposee
ret = K_COMPGEOM::projectOrtho( xt1[indB1], yt1[indB1], zt1[indB1],
face.begin(1), face.begin(2),
face.begin(3), cnf, xp, yp, zp,
p0, p1, p2, p);
dx = xp-xt1[indB1]; dy = yp-yt1[indB1]; dz = zp-zt1[indB1];
if ( ret > -1 && dx*dx + dy*dy + dz*dz <= tol2 )
{ found2 = 1; dhmax = K_FUNC::E_max(dhmax,s2);}
if ( found2 == 1) goto finjmin2;
if (ret > -1 && dx*dx + dy*dy + dz*dz <= tol2)
{ found2 = 1; dhmax = K_FUNC::E_max(dhmax,s2); }
if (found2 == 1) goto finjmin2;
finjmin2:;

if ( found1+found2 > 0 )
if (found1+found2 > 0)
{
vector<E_Int>& dejaVu1 = dejaVu[v1]; dejaVu1.push_back(v2);
vector<E_Int>& dejaVu2 = dejaVu[v2]; dejaVu2.push_back(v1);
Expand Down
3 changes: 2 additions & 1 deletion Cassiopee/KCore/KCore/Acc/copyfrom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ PyObject* K_KCORE::copyfrom(PyObject* self, PyObject* args)
E_Float* ipttarget = f->begin();
E_Int sizetot = f->getSize();

#ifdef _OPENACC
//#pragma omp target update from (ipttarget[:sizetot])
//printf("copyfrom \n");
#endif

RELEASESHAREDN(numpyArray, f);

Expand Down
3 changes: 2 additions & 1 deletion Cassiopee/KCore/KCore/Acc/copyto.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ PyObject* K_KCORE::copyto(PyObject* self, PyObject* args)
E_Float* ipttarget = f->begin();
E_Int sizetot = f->getSize();

#ifdef _OPENACC
//#pragma omp target enter data map(to: ipttarget[:sizetot])
//printf("copy2gpu \n");
#endif

RELEASESHAREDN(numpyArray, f);

Expand Down

0 comments on commit 9b31edd

Please sign in to comment.