mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-15 10:28:34 +05:00
Merge remote-tracking branch 'origin/master' into boundarylayer_fixes
This commit is contained in:
commit
a253fa4e18
@ -429,45 +429,6 @@ namespace ngcore
|
||||
|
||||
}; // 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
|
||||
class NG_MPI_Comm {
|
||||
int nr;
|
||||
@ -566,13 +527,6 @@ namespace ngcore
|
||||
inline void MyMPI_WaitAll (FlatArray<NG_MPI_Request> requests) { ; }
|
||||
inline int MyMPI_WaitAny (FlatArray<NG_MPI_Request> requests) { return 0; }
|
||||
|
||||
class MyMPI
|
||||
{
|
||||
public:
|
||||
MyMPI(int argc, char ** argv) { ; }
|
||||
};
|
||||
|
||||
|
||||
#endif // PARALLEL
|
||||
|
||||
} // namespace ngcore
|
||||
|
@ -24,6 +24,7 @@ namespace py = pybind11;
|
||||
|
||||
namespace ngcore {
|
||||
|
||||
NGCORE_API bool MPI_Loaded();
|
||||
NGCORE_API void InitMPI(
|
||||
std::optional<std::filesystem::path> mpi_lib_path = std::nullopt);
|
||||
|
||||
|
@ -28,6 +28,10 @@ struct MPIFinalizer {
|
||||
}
|
||||
} mpi_finalizer;
|
||||
|
||||
bool MPI_Loaded() {
|
||||
return ng_mpi_lib != nullptr;
|
||||
}
|
||||
|
||||
void InitMPI(std::optional<std::filesystem::path> mpi_lib_path) {
|
||||
if (ng_mpi_lib) return;
|
||||
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "archive.hpp" // for Demangle
|
||||
#include "paje_trace.hpp"
|
||||
#include "ng_mpi.hpp"
|
||||
#include "profiler.hpp"
|
||||
#include "mpi_wrapper.hpp"
|
||||
|
||||
@ -71,9 +72,12 @@ namespace ngcore
|
||||
|
||||
// sync start time when running in parallel
|
||||
#ifdef PARALLEL
|
||||
NgMPI_Comm comm(NG_MPI_COMM_WORLD);
|
||||
for([[maybe_unused]] auto i : Range(5))
|
||||
comm.Barrier();
|
||||
if(MPI_Loaded())
|
||||
{
|
||||
NgMPI_Comm comm(NG_MPI_COMM_WORLD);
|
||||
for([[maybe_unused]] auto i : Range(5))
|
||||
comm.Barrier();
|
||||
}
|
||||
#endif // PARALLEL
|
||||
|
||||
start_time = GetTimeCounter();
|
||||
@ -113,8 +117,11 @@ namespace ngcore
|
||||
for(auto i : IntRange(n_memory_events_at_start, memory_events.size()))
|
||||
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)
|
||||
{
|
||||
Write(tracefile_name);
|
||||
@ -487,14 +494,14 @@ namespace ngcore
|
||||
std::vector <int> thread_aliases;
|
||||
std::vector<int> container_nodes;
|
||||
|
||||
#ifdef PARALLEL
|
||||
// Hostnames
|
||||
NgMPI_Comm comm(NG_MPI_COMM_WORLD);
|
||||
// auto rank = comm.Rank();
|
||||
auto nranks = comm.Size();
|
||||
if(nranks>1)
|
||||
NgMPI_Comm comm;
|
||||
#ifdef PARALLEL
|
||||
if(MPI_Loaded())
|
||||
comm = NgMPI_Comm(NG_MPI_COMM_WORLD);
|
||||
if(comm.Size()>1)
|
||||
{
|
||||
nthreads = nranks;
|
||||
auto comm = NgMPI_Comm(NG_MPI_COMM_WORLD);
|
||||
nthreads = comm.Size();
|
||||
thread_aliases.reserve(nthreads);
|
||||
|
||||
std::array<char, ASSUMED_MPI_MAX_PROCESSOR_NAME+1> ahostname;
|
||||
@ -505,7 +512,7 @@ namespace ngcore
|
||||
std::map<std::string, int> host_map;
|
||||
|
||||
std::string name;
|
||||
for(auto i : IntRange(0, nranks))
|
||||
for(auto i : IntRange(0, comm.Size()))
|
||||
{
|
||||
if(i!=MPI_PAJE_WRITER)
|
||||
comm.Recv(name, i, 0);
|
||||
@ -520,7 +527,7 @@ namespace ngcore
|
||||
}
|
||||
}
|
||||
else
|
||||
#endif // PARALLEL
|
||||
#endif
|
||||
{
|
||||
container_nodes.reserve(num_nodes);
|
||||
for(int i=0; i<num_nodes; i++)
|
||||
@ -596,10 +603,9 @@ namespace ngcore
|
||||
for(auto id : timer_ids)
|
||||
timer_names[id] = GetTimerName(id);
|
||||
|
||||
#ifdef PARALLEL
|
||||
if(nranks>1)
|
||||
if(comm.Size()>1)
|
||||
{
|
||||
for(auto src : IntRange(0, nranks))
|
||||
for(auto src : IntRange(0, comm.Size()))
|
||||
{
|
||||
if(src==MPI_PAJE_WRITER)
|
||||
continue;
|
||||
@ -618,7 +624,6 @@ namespace ngcore
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // PARALLEL
|
||||
|
||||
for(auto id : timer_ids)
|
||||
timer_aliases[id] = paje.DefineEntityValue( state_type_timer, timer_names[id], -1 );
|
||||
@ -743,7 +748,7 @@ namespace ngcore
|
||||
}
|
||||
|
||||
#ifdef PARALLEL
|
||||
if(nranks>1)
|
||||
if(comm.Size()>1)
|
||||
{
|
||||
for(auto & event : timer_events)
|
||||
{
|
||||
@ -759,7 +764,7 @@ namespace ngcore
|
||||
Array<bool> is_start;
|
||||
Array<int> thread_id;
|
||||
|
||||
for(auto src : IntRange(0, nranks))
|
||||
for(auto src : IntRange(0, comm.Size()))
|
||||
{
|
||||
if(src==MPI_PAJE_WRITER)
|
||||
continue;
|
||||
|
@ -27,17 +27,7 @@ namespace netgen
|
||||
static std::thread meshingthread;
|
||||
void RunParallel ( void * (*fun)(void *), void * in)
|
||||
{
|
||||
bool parthread = 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)
|
||||
if (netgen::mparam.parthread)
|
||||
{
|
||||
meshingthread = std::thread(fun, in);
|
||||
meshingthread.detach();
|
||||
|
@ -206,13 +206,8 @@ namespace netgen
|
||||
|
||||
int calculated = 0;
|
||||
|
||||
cout << endl;
|
||||
|
||||
|
||||
for(int i=0; i<potential_startpoints.Size(); i++)
|
||||
{
|
||||
cout << "\rFieldline Calculation " << int(100.*i/potential_startpoints.Size()) << "%"; cout.flush();
|
||||
|
||||
if(randomized)
|
||||
SetCriticalValue((double(rand())/RAND_MAX)*crit);
|
||||
|
||||
@ -235,7 +230,6 @@ namespace netgen
|
||||
|
||||
if(usable) calculated++;
|
||||
}
|
||||
cout << "\rFieldline Calculation " << 100 << "%" << endl;
|
||||
|
||||
}
|
||||
|
||||
|
@ -497,7 +497,8 @@ namespace netgen
|
||||
{
|
||||
ntexcols = ncols;
|
||||
|
||||
GLubyte colortexture[4*32];
|
||||
ArrayMem<GLubyte, 4*32> colortexture;
|
||||
colortexture.SetSize(4*ncols);
|
||||
|
||||
const double colp[][3] =
|
||||
{
|
||||
@ -532,8 +533,8 @@ namespace netgen
|
||||
|
||||
// glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
|
||||
|
||||
glTexImage1D (GL_TEXTURE_1D, 0, 4, ncols, 0, GL_RGBA, GL_UNSIGNED_BYTE, colortexture);
|
||||
glTexImage2D (GL_TEXTURE_2D, 0, 4, ncols, 1, 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.Data());
|
||||
|
||||
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, typ); // DECAL or MODULATE
|
||||
|
||||
|
@ -321,6 +321,11 @@ class WebGLScene(base):
|
||||
if "gui_settings" not in d:
|
||||
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"] = []
|
||||
for obj in kwargs["objects"]:
|
||||
if isinstance(obj, dict):
|
||||
@ -367,6 +372,7 @@ def _get_draw_default_args():
|
||||
nodal_p1=False,
|
||||
settings={},
|
||||
fullscreen=False,
|
||||
scale=1.0,
|
||||
width=_default_width,
|
||||
height=_default_height,
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user