Merge remote-tracking branch 'origin/master' into boundarylayer_fixes

This commit is contained in:
Matthias Hochsteger 2024-05-23 20:35:02 +02:00
commit a253fa4e18
8 changed files with 41 additions and 86 deletions

View File

@ -429,45 +429,6 @@ namespace ngcore
}; // class NgMPI_Comm }; // class NgMPI_Comm
class MyMPI
{
bool initialized_by_me;
public:
MyMPI(int argc, char ** argv)
{
int is_init = -1;
NG_MPI_Initialized(&is_init);
if (!is_init)
{
NG_MPI_Init (&argc, &argv);
initialized_by_me = true;
}
else
initialized_by_me = false;
NgMPI_Comm comm(NG_MPI_COMM_WORLD);
NGSOStream::SetGlobalActive (comm.Rank() == 0);
if (comm.Size() > 1)
TaskManager::SetNumThreads (1);
}
~MyMPI()
{
if (initialized_by_me)
NG_MPI_Finalize ();
}
};
#else // PARALLEL #else // PARALLEL
class NG_MPI_Comm { class NG_MPI_Comm {
int nr; int nr;
@ -566,13 +527,6 @@ namespace ngcore
inline void MyMPI_WaitAll (FlatArray<NG_MPI_Request> requests) { ; } inline void MyMPI_WaitAll (FlatArray<NG_MPI_Request> requests) { ; }
inline int MyMPI_WaitAny (FlatArray<NG_MPI_Request> requests) { return 0; } inline int MyMPI_WaitAny (FlatArray<NG_MPI_Request> requests) { return 0; }
class MyMPI
{
public:
MyMPI(int argc, char ** argv) { ; }
};
#endif // PARALLEL #endif // PARALLEL
} // namespace ngcore } // namespace ngcore

View File

@ -24,6 +24,7 @@ namespace py = pybind11;
namespace ngcore { namespace ngcore {
NGCORE_API bool MPI_Loaded();
NGCORE_API void InitMPI( NGCORE_API void InitMPI(
std::optional<std::filesystem::path> mpi_lib_path = std::nullopt); std::optional<std::filesystem::path> mpi_lib_path = std::nullopt);

View File

@ -28,6 +28,10 @@ struct MPIFinalizer {
} }
} mpi_finalizer; } mpi_finalizer;
bool MPI_Loaded() {
return ng_mpi_lib != nullptr;
}
void InitMPI(std::optional<std::filesystem::path> mpi_lib_path) { void InitMPI(std::optional<std::filesystem::path> mpi_lib_path) {
if (ng_mpi_lib) return; if (ng_mpi_lib) return;

View File

@ -7,6 +7,7 @@
#include "archive.hpp" // for Demangle #include "archive.hpp" // for Demangle
#include "paje_trace.hpp" #include "paje_trace.hpp"
#include "ng_mpi.hpp"
#include "profiler.hpp" #include "profiler.hpp"
#include "mpi_wrapper.hpp" #include "mpi_wrapper.hpp"
@ -71,9 +72,12 @@ namespace ngcore
// sync start time when running in parallel // sync start time when running in parallel
#ifdef PARALLEL #ifdef PARALLEL
if(MPI_Loaded())
{
NgMPI_Comm comm(NG_MPI_COMM_WORLD); NgMPI_Comm comm(NG_MPI_COMM_WORLD);
for([[maybe_unused]] auto i : Range(5)) for([[maybe_unused]] auto i : Range(5))
comm.Barrier(); comm.Barrier();
}
#endif // PARALLEL #endif // PARALLEL
start_time = GetTimeCounter(); start_time = GetTimeCounter();
@ -113,8 +117,11 @@ namespace ngcore
for(auto i : IntRange(n_memory_events_at_start, memory_events.size())) for(auto i : IntRange(n_memory_events_at_start, memory_events.size()))
memory_events[i].time -= start_time; memory_events[i].time -= start_time;
NgMPI_Comm comm(NG_MPI_COMM_WORLD); NgMPI_Comm comm;
#ifdef PARALLEL
if(MPI_Loaded())
comm = NgMPI_Comm(NG_MPI_COMM_WORLD);
#endif
if(comm.Size()==1) if(comm.Size()==1)
{ {
Write(tracefile_name); Write(tracefile_name);
@ -487,14 +494,14 @@ namespace ngcore
std::vector <int> thread_aliases; std::vector <int> thread_aliases;
std::vector<int> container_nodes; std::vector<int> container_nodes;
NgMPI_Comm comm;
#ifdef PARALLEL #ifdef PARALLEL
// Hostnames if(MPI_Loaded())
NgMPI_Comm comm(NG_MPI_COMM_WORLD); comm = NgMPI_Comm(NG_MPI_COMM_WORLD);
// auto rank = comm.Rank(); if(comm.Size()>1)
auto nranks = comm.Size();
if(nranks>1)
{ {
nthreads = nranks; auto comm = NgMPI_Comm(NG_MPI_COMM_WORLD);
nthreads = comm.Size();
thread_aliases.reserve(nthreads); thread_aliases.reserve(nthreads);
std::array<char, ASSUMED_MPI_MAX_PROCESSOR_NAME+1> ahostname; std::array<char, ASSUMED_MPI_MAX_PROCESSOR_NAME+1> ahostname;
@ -505,7 +512,7 @@ namespace ngcore
std::map<std::string, int> host_map; std::map<std::string, int> host_map;
std::string name; std::string name;
for(auto i : IntRange(0, nranks)) for(auto i : IntRange(0, comm.Size()))
{ {
if(i!=MPI_PAJE_WRITER) if(i!=MPI_PAJE_WRITER)
comm.Recv(name, i, 0); comm.Recv(name, i, 0);
@ -520,7 +527,7 @@ namespace ngcore
} }
} }
else else
#endif // PARALLEL #endif
{ {
container_nodes.reserve(num_nodes); container_nodes.reserve(num_nodes);
for(int i=0; i<num_nodes; i++) for(int i=0; i<num_nodes; i++)
@ -596,10 +603,9 @@ namespace ngcore
for(auto id : timer_ids) for(auto id : timer_ids)
timer_names[id] = GetTimerName(id); timer_names[id] = GetTimerName(id);
#ifdef PARALLEL if(comm.Size()>1)
if(nranks>1)
{ {
for(auto src : IntRange(0, nranks)) for(auto src : IntRange(0, comm.Size()))
{ {
if(src==MPI_PAJE_WRITER) if(src==MPI_PAJE_WRITER)
continue; continue;
@ -618,7 +624,6 @@ namespace ngcore
} }
} }
} }
#endif // PARALLEL
for(auto id : timer_ids) for(auto id : timer_ids)
timer_aliases[id] = paje.DefineEntityValue( state_type_timer, timer_names[id], -1 ); timer_aliases[id] = paje.DefineEntityValue( state_type_timer, timer_names[id], -1 );
@ -743,7 +748,7 @@ namespace ngcore
} }
#ifdef PARALLEL #ifdef PARALLEL
if(nranks>1) if(comm.Size()>1)
{ {
for(auto & event : timer_events) for(auto & event : timer_events)
{ {
@ -759,7 +764,7 @@ namespace ngcore
Array<bool> is_start; Array<bool> is_start;
Array<int> thread_id; Array<int> thread_id;
for(auto src : IntRange(0, nranks)) for(auto src : IntRange(0, comm.Size()))
{ {
if(src==MPI_PAJE_WRITER) if(src==MPI_PAJE_WRITER)
continue; continue;

View File

@ -27,17 +27,7 @@ namespace netgen
static std::thread meshingthread; static std::thread meshingthread;
void RunParallel ( void * (*fun)(void *), void * in) void RunParallel ( void * (*fun)(void *), void * in)
{ {
bool parthread = netgen::mparam.parthread; if (netgen::mparam.parthread)
#ifdef PARALLEL
int provided;
netgen::NG_MPI_Query_thread(&provided);
if (provided < 3)
if (netgen::ntasks > 1) parthread = false;
// cout << "runparallel = " << parthread << endl;
#endif
if (parthread)
{ {
meshingthread = std::thread(fun, in); meshingthread = std::thread(fun, in);
meshingthread.detach(); meshingthread.detach();

View File

@ -206,13 +206,8 @@ namespace netgen
int calculated = 0; int calculated = 0;
cout << endl;
for(int i=0; i<potential_startpoints.Size(); i++) for(int i=0; i<potential_startpoints.Size(); i++)
{ {
cout << "\rFieldline Calculation " << int(100.*i/potential_startpoints.Size()) << "%"; cout.flush();
if(randomized) if(randomized)
SetCriticalValue((double(rand())/RAND_MAX)*crit); SetCriticalValue((double(rand())/RAND_MAX)*crit);
@ -235,7 +230,6 @@ namespace netgen
if(usable) calculated++; if(usable) calculated++;
} }
cout << "\rFieldline Calculation " << 100 << "%" << endl;
} }

View File

@ -497,7 +497,8 @@ namespace netgen
{ {
ntexcols = ncols; ntexcols = ncols;
GLubyte colortexture[4*32]; ArrayMem<GLubyte, 4*32> colortexture;
colortexture.SetSize(4*ncols);
const double colp[][3] = const double colp[][3] =
{ {
@ -532,8 +533,8 @@ namespace netgen
// glPixelStorei (GL_UNPACK_ALIGNMENT, 1); // glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
glTexImage1D (GL_TEXTURE_1D, 0, 4, ncols, 0, GL_RGBA, GL_UNSIGNED_BYTE, colortexture); glTexImage1D (GL_TEXTURE_1D, 0, 4, ncols, 0, GL_RGBA, GL_UNSIGNED_BYTE, colortexture.Data());
glTexImage2D (GL_TEXTURE_2D, 0, 4, ncols, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, colortexture); glTexImage2D (GL_TEXTURE_2D, 0, 4, ncols, 1, 0, GL_RGBA, GL_UNSIGNED_BYTE, colortexture.Data());
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, typ); // DECAL or MODULATE glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, typ); // DECAL or MODULATE

View File

@ -321,6 +321,11 @@ class WebGLScene(base):
if "gui_settings" not in d: if "gui_settings" not in d:
d["gui_settings"] = self.kwargs["settings"] d["gui_settings"] = self.kwargs["settings"]
if "euler_angles" in kwargs:
camera = d["gui_settings"].get("camera", {})
camera["euler_angles"] = kwargs["euler_angles"]
d["gui_settings"]['camera'] = camera
d["objects"] = [] d["objects"] = []
for obj in kwargs["objects"]: for obj in kwargs["objects"]:
if isinstance(obj, dict): if isinstance(obj, dict):
@ -367,6 +372,7 @@ def _get_draw_default_args():
nodal_p1=False, nodal_p1=False,
settings={}, settings={},
fullscreen=False, fullscreen=False,
scale=1.0,
width=_default_width, width=_default_width,
height=_default_height, height=_default_height,
) )