Skip to content

Commit baa3542

Browse files
committed
change to add interfacial nodes as interdomain ghost nodes. Thus only minimal change original schism uncombined file
is needed. Add 3d prism bottom index to plot prism center data correctly.
1 parent 7a0051a commit baa3542

7 files changed

Lines changed: 365 additions & 48 deletions

mdschism/MDSCHISMOutput.cpp

Lines changed: 95 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ MDSchismOutput::MDSchismOutput(const std::string a_outputFile,const std::string
1919
m_face_bottom(NULL),
2020
m_node_bottom(NULL),
2121
m_edge_bottom(NULL),
22+
m_prism_bottom(NULL),
2223
m_face_nodes(NULL),
2324
m_side_nodes(NULL),
2425
m_face_bottom_time_id(-1),
@@ -105,6 +106,10 @@ MDSchismOutput::~MDSchismOutput()
105106
delete m_edge_bottom;
106107
}
107108

109+
if (m_prism_bottom)
110+
{
111+
delete m_edge_bottom;
112+
}
108113
if(m_side_nodes)
109114
{
110115
delete m_side_nodes;
@@ -341,6 +346,19 @@ void MDSchismOutput::get_face_bottom(int* a_face_bottom,const int& a_time)
341346
a_face_bottom[i]=m_face_bottom[i];
342347
}
343348
}
349+
350+
void MDSchismOutput::get_prism_bottom(int* a_prism_bottom, const int& a_time)
351+
{
352+
NcDim * dimFacePtr = m_outputNcFilePtr->get_dim(MeshConstants10::DIM_MESH_FACES.c_str());
353+
long numMeshFaces = 0;
354+
numMeshFaces = dimFacePtr->size();
355+
356+
for (long i = 0; i < numMeshFaces; i++)
357+
{
358+
a_prism_bottom[i] = m_prism_bottom[i];
359+
}
360+
}
361+
344362
void MDSchismOutput::get_edge_bottom(int* a_edge_bottom,const int& a_time)
345363
{
346364
NcDim * dimEdgePtr = m_outputNcFilePtr->get_dim(MeshConstants10::DIM_MESH_EDGES.c_str());
@@ -491,6 +509,38 @@ void MDSchismOutput::update_ele_bottom(const int& a_time,int* a_node_bottom)
491509

492510
}
493511

512+
void MDSchismOutput::set_prism_bottom(const int& a_time, int* a_prism_bottom)
513+
{
514+
update_prism_bottom(a_time, a_prism_bottom);
515+
}
516+
517+
void MDSchismOutput::update_prism_bottom(const int& a_time, int* a_prism_bottom)
518+
{
519+
520+
NcDim * dimFacePtr = m_outputNcFilePtr->get_dim(MeshConstants10::DIM_MESH_FACES.c_str());
521+
long numMeshFaces = 0;
522+
numMeshFaces = dimFacePtr->size();
523+
NcDim * dimNodePtr = m_outputNcFilePtr->get_dim(MeshConstants10::DIM_MESH_NODES.c_str());
524+
long numMeshNodes = 0;
525+
numMeshNodes = dimNodePtr->size();
526+
527+
528+
if (!(m_prism_bottom))
529+
{
530+
m_prism_bottom = new int[numMeshFaces];
531+
}
532+
533+
for (long iface = 0; iface < numMeshFaces; iface++)
534+
{
535+
536+
m_prism_bottom[iface] = a_prism_bottom[iface];
537+
538+
}
539+
m_prism_bottom_time_id = a_time;
540+
541+
}
542+
543+
494544

495545
bool MDSchismOutput::load_dim_var()
496546
{
@@ -580,13 +630,43 @@ bool MDSchismOutput::load_dim_var()
580630

581631
std::string nc_att_name(att_var->name());
582632

583-
if ((!(nc_att_name.compare(MeshConstants10::CENTER)))||(!(nc_att_name.compare(MeshConstants10::LOCATION))))
584-
{
585-
schism_var->set_horizontal_center((att_var->as_string(0)));
586-
}
587-
else if (!(nc_att_name.compare(MeshConstants10::LAYER_CENTER)))
633+
//if ((!(nc_att_name.compare(MeshConstants10::CENTER)))||(!(nc_att_name.compare(MeshConstants10::LOCATION))))
634+
//{
635+
// schism_var->set_horizontal_center((att_var->as_string(0)));
636+
//}
637+
//else if (!(nc_att_name.compare(MeshConstants10::LAYER_CENTER)))
638+
//{
639+
// schism_var->set_vertical_center(att_var->as_string(0));
640+
//}
641+
642+
if (!(nc_att_name.compare(MeshConstants10::I23D)))
588643
{
589-
schism_var->set_vertical_center(att_var->as_string(0));
644+
int i23d = att_var->as_int(0);
645+
if (i23d <= 3)
646+
{
647+
schism_var->set_horizontal_center(MeshConstants10::NODE);
648+
}
649+
else if (i23d <= 6)
650+
{
651+
schism_var->set_horizontal_center(MeshConstants10::ELEM);
652+
}
653+
else if (i23d <= 9)
654+
{
655+
schism_var->set_horizontal_center(MeshConstants10::EDGE);
656+
}
657+
else
658+
{
659+
throw SCHISMVarException10("i23d is not a valid\n");
660+
}
661+
662+
if (!(i23d % 3))
663+
{
664+
schism_var->set_vertical_center(MeshConstants10::HALF_LAYER);
665+
}
666+
else
667+
{
668+
schism_var->set_vertical_center(MeshConstants10::FULL_LAYER);
669+
}
590670
}
591671

592672
}
@@ -652,7 +732,14 @@ void MDSchismOutputVar::fill_ncVar(NcVar * a_nc_var)
652732
}
653733
else
654734
{
655-
m_schismfilePtr->get_face_bottom(a_kbp00,m_current_record);
735+
if (m_vertical_center == MeshConstants10::HALF_LAYER)
736+
{
737+
m_schismfilePtr->get_prism_bottom(a_kbp00, m_current_record);
738+
}
739+
else
740+
{
741+
m_schismfilePtr->get_face_bottom(a_kbp00, m_current_record);
742+
}
656743
}
657744
}
658745

@@ -685,7 +772,7 @@ bool MDSchismOutputVar::get(int * a_buffer)
685772
{
686773

687774
int dataSize = computeDataNumPerTIMEStep();
688-
debug1 << "data size is " << dataSize<<"\n";
775+
//debug1 << "data size is " << dataSize<<"\n";
689776
if(m_data_cached)
690777
{
691778
//for(int idata=0;idata<dataSize;idata++)

mdschism/MDSCHISMOutput.h

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "SCHISMFile10.h"
22
#include "MeshConstants10.h"
33
#include "netcdfcpp.h"
4-
#include <DebugStream.h>
4+
//#include <DebugStream.h>
55
#ifndef _MDNETCDFSCHISMOUTPUT_H_
66
#define _MDNETCDFSCHISMOUTPUT_H_
77

@@ -19,6 +19,8 @@ class MDSchismOutput: public SCHISMFile10
1919
void get_node_bottom(int* a_node_bottom,const int& a_time);
2020
void get_face_bottom(int* a_face_bottom,const int& a_time);
2121
void get_edge_bottom(int* a_ele_bottom,const int& a_time);
22+
void get_prism_bottom(int* a_prism_bottom, const int& a_time);
23+
void set_prism_bottom(const int& a_time, int* a_prism_bottom);
2224
bool update_bottom_index(const int& a_time);
2325
int global_att_as_int(const std::string& a_att_name) const;
2426
std::string global_att_as_string(const std::string& a_att_name) const;
@@ -37,7 +39,7 @@ class MDSchismOutput: public SCHISMFile10
3739
bool update_node_bottom(const int& a_time);
3840
void update_edge_bottom(const int& a_time, int* a_node_bottom);
3941
void update_ele_bottom(const int& a_time,int* a_node_bottom);
40-
42+
void update_prism_bottom(const int& a_time, int* a_prism_bottom);
4143

4244

4345
NcFile* m_outputNcFilePtr;
@@ -49,9 +51,11 @@ class MDSchismOutput: public SCHISMFile10
4951
int* m_face_bottom;
5052
int* m_node_bottom;
5153
int* m_edge_bottom;
54+
int* m_prism_bottom;
5255
int m_face_bottom_time_id;
5356
int m_node_bottom_time_id;
5457
int m_edge_bottom_time_id;
58+
int m_prism_bottom_time_id;
5559
long * m_face_nodes;
5660
long * m_side_nodes;
5761
};
@@ -124,7 +128,7 @@ bool MDSchismOutputVar::load_from_file(T * a_buffer)
124128
int num_dim = ncvar->num_dims();
125129
long * current = new long [num_dim];
126130
long * count = new long [num_dim];
127-
debug1 << " begin load dims in load from file\n";
131+
//debug1 << " begin load dims in load from file\n";
128132
for(int idim =0; idim<num_dim;idim++)
129133
{
130134
// int dim_id = m_dimensions[idim];
@@ -153,7 +157,7 @@ bool MDSchismOutputVar::load_from_file(T * a_buffer)
153157
}
154158
}
155159

156-
//debug1 << " done load dims in load from file\n";
160+
//debug1 << " done load dims in load from file "<<buffer_size<<" "<<node_num<<" "<<num_layer<<"\n";
157161
if (num_layer ==1) // not 3d data
158162
{
159163

@@ -197,7 +201,7 @@ bool MDSchismOutputVar::load_from_file(T * a_buffer)
197201
int * bottom_layer = new int [node_num];
198202

199203
fill_current_bottom(bottom_layer);
200-
204+
201205
long * start_loc = new long [node_num];
202206

203207
for(long inode=0;inode<node_num;inode++)
@@ -253,9 +257,9 @@ bool MDSchismOutputVar::load_from_file(T * a_buffer)
253257
ncvar->get(buffer,count);
254258
}
255259

256-
260+
//debug1 << "done read ncvar data\n";
257261
int a_node_record_length_in_nc_buffer = buffer_size/node_num;
258-
262+
long total_valid_data_len = 0;
259263
for(long inode=0;inode<node_num;inode++)
260264
{
261265
long a_node_valid_data_start= start_loc[inode];
@@ -278,8 +282,10 @@ bool MDSchismOutputVar::load_from_file(T * a_buffer)
278282
a_buffer[valid_data_index] = buffer[nc_buffer_id];
279283
nc_buffer_id++;
280284
}
285+
//debug1 << "done read valid ncvar data "<<inode<<" " << valid_record_start_in_nc_buffer<<"\n";
286+
total_valid_data_len += a_node_valid_record_len;
281287
}
282-
288+
//debug1 << "done read valid ncvar data " <<total_valid_data_len<<"\n";
283289
delete buffer;
284290

285291

mdschism/MeshConstants10.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const std::string LAYER_CENTER("data_vertical_center");
6161
const std::string FULL_LAYER("full");
6262
const std::string HALF_LAYER("half");
6363
const std::string DYNAMIC_MESH("mesh_is_dynamic");
64+
const std::string I23D("i23d");
6465
const float DRY_ZCOR=-99999999.0;
6566
const long INVALID_NUM = -9999;
6667
const int MAX_NUM_NODE_PER_CELL = 4;

mdschism/SCHISMFile10.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,6 @@ bool SCHISMFile10::none_data_var(const std::string a_varName) const
624624
{
625625
return false;
626626
}
627-
628627
}
629628
std::string SCHISMFile10::file() const
630629
{
@@ -741,6 +740,10 @@ void SCHISMFile10::get_face_bottom(int* a_face_bottom,const int& a_time)
741740
return;
742741
}
743742

743+
void SCHISMFile10::get_prism_bottom(int* a_face_bottom, const int& a_time)
744+
{
745+
return;
746+
}
744747
void SCHISMFile10::get_edge_bottom(int* a_ele_bottom,const int& a_time)
745748
{
746749
return;

mdschism/SCHISMFile10.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ class SCHISMFile10
238238
virtual void get_node_bottom(int* a_node_bottom,const int& a_time);
239239
virtual void get_face_bottom(int* a_face_bottom,const int& a_time);
240240
virtual void get_edge_bottom(int* a_ele_bottom,const int& a_time);
241+
virtual void get_prism_bottom(int* a_ele_bottom, const int& a_time);
241242
virtual int global_att_as_int(const std::string& a_att_name) const;
242243
virtual std::string global_att_as_string(const std::string& a_att_name) const;
243244
private:

0 commit comments

Comments
 (0)